| author | |
| committer | |
| log | dfabf1586fa2fcd9350e204fa138f44f952acbfd |
| tree | 0772d518264f9deab3eb70b04167bb5df72ac88f |
| parent | 80212b03ff792ddfff82092b35aa7ed0fdf937a8 |
| signature |
425 files changed, 15825 insertions(+), 10341 deletions(-)
lib/libcxx/include/__algorithm/all_of.h+11-5| ... | @@ -10,24 +10,28 @@ | ... | @@ -10,24 +10,28 @@ |
| 10 | #ifndef _LIBCPP___ALGORITHM_ALL_OF_H | 10 | #ifndef _LIBCPP___ALGORITHM_ALL_OF_H |
| 11 | #define _LIBCPP___ALGORITHM_ALL_OF_H | 11 | #define _LIBCPP___ALGORITHM_ALL_OF_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/any_of.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__functional/identity.h> | 15 | #include <__functional/identity.h> |
| 15 | #include <__type_traits/invoke.h> | 16 | #include <__type_traits/invoke.h> |
| 17 | #include <__utility/forward.h> | ||
| 18 | #include <__utility/move.h> | ||
| 16 | 19 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 21 | # pragma GCC system_header |
| 19 | #endif | 22 | #endif |
| 20 | 23 | ||
| 24 | _LIBCPP_PUSH_MACROS | ||
| 25 | #include <__undef_macros> | ||
| 26 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 28 | ||
| 23 | template <class _Iter, class _Sent, class _Proj, class _Pred> | 29 | template <class _Iter, class _Sent, class _Proj, class _Pred> |
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool |
| 25 | __all_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | 31 | __all_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { |
| 26 | for (; __first != __last; ++__first) { | 32 | using _Ref = decltype(std::__invoke(__proj, *__first)); |
| 27 | if (!std::__invoke(__pred, std::__invoke(__proj, *__first))) | 33 | auto __negated_pred = [&__pred](_Ref __arg) -> bool { return !std::__invoke(__pred, std::forward<_Ref>(__arg)); }; |
| 28 | return false; | 34 | return !std::__any_of(std::move(__first), std::move(__last), __negated_pred, __proj); |
| 29 | } | ||
| 30 | return true; | ||
| 31 | } | 35 | } |
| 32 | 36 | ||
| 33 | template <class _InputIterator, class _Predicate> | 37 | template <class _InputIterator, class _Predicate> |
| ... | @@ -39,4 +43,6 @@ all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | ... | @@ -39,4 +43,6 @@ all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 39 | 43 | ||
| 40 | _LIBCPP_END_NAMESPACE_STD | 44 | _LIBCPP_END_NAMESPACE_STD |
| 41 | 45 | ||
| 46 | _LIBCPP_POP_MACROS | ||
| 47 | |||
| 42 | #endif // _LIBCPP___ALGORITHM_ALL_OF_H | 48 | #endif // _LIBCPP___ALGORITHM_ALL_OF_H |
lib/libcxx/include/__algorithm/comp.h+4| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/desugars_to.h> | 13 | #include <__type_traits/desugars_to.h> |
| 14 | #include <__type_traits/is_generic_transparent_comparator.h> | ||
| 14 | #include <__type_traits/is_integral.h> | 15 | #include <__type_traits/is_integral.h> |
| 15 | 16 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -48,6 +49,9 @@ inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true; | ... | @@ -48,6 +49,9 @@ inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true; |
| 48 | template <class _Tp> | 49 | template <class _Tp> |
| 49 | inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> = is_integral<_Tp>::value; | 50 | inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> = is_integral<_Tp>::value; |
| 50 | 51 | ||
| 52 | template <> | ||
| 53 | inline const bool __is_generic_transparent_comparator_v<__less<> > = true; | ||
| 54 | |||
| 51 | _LIBCPP_END_NAMESPACE_STD | 55 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 56 | ||
| 53 | #endif // _LIBCPP___ALGORITHM_COMP_H | 57 | #endif // _LIBCPP___ALGORITHM_COMP_H |
lib/libcxx/include/__algorithm/copy.h+28-147| ... | @@ -12,11 +12,10 @@ | ... | @@ -12,11 +12,10 @@ |
| 12 | #include <__algorithm/copy_move_common.h> | 12 | #include <__algorithm/copy_move_common.h> |
| 13 | #include <__algorithm/for_each_segment.h> | 13 | #include <__algorithm/for_each_segment.h> |
| 14 | #include <__algorithm/min.h> | 14 | #include <__algorithm/min.h> |
| 15 | #include <__algorithm/specialized_algorithms.h> | ||
| 15 | #include <__config> | 16 | #include <__config> |
| 16 | #include <__fwd/bit_reference.h> | ||
| 17 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__iterator/segmented_iterator.h> | 18 | #include <__iterator/segmented_iterator.h> |
| 19 | #include <__memory/pointer_traits.h> | ||
| 20 | #include <__type_traits/common_type.h> | 19 | #include <__type_traits/common_type.h> |
| 21 | #include <__type_traits/enable_if.h> | 20 | #include <__type_traits/enable_if.h> |
| 22 | #include <__utility/move.h> | 21 | #include <__utility/move.h> |
| ... | @@ -38,124 +37,14 @@ copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result); | ... | @@ -38,124 +37,14 @@ copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result); |
| 38 | template <class _InIter, class _Sent, class _OutIter> | 37 | template <class _InIter, class _Sent, class _OutIter> |
| 39 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); | 38 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); |
| 40 | 39 | ||
| 41 | template <class _Cp, bool _IsConst> | ||
| 42 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_aligned( | ||
| 43 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 44 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 45 | using difference_type = typename _In::difference_type; | ||
| 46 | using __storage_type = typename _In::__storage_type; | ||
| 47 | |||
| 48 | const int __bits_per_word = _In::__bits_per_word; | ||
| 49 | difference_type __n = __last - __first; | ||
| 50 | if (__n > 0) { | ||
| 51 | // do first word | ||
| 52 | if (__first.__ctz_ != 0) { | ||
| 53 | unsigned __clz = __bits_per_word - __first.__ctz_; | ||
| 54 | difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); | ||
| 55 | __n -= __dn; | ||
| 56 | __storage_type __m = std::__middle_mask<__storage_type>(__clz - __dn, __first.__ctz_); | ||
| 57 | __storage_type __b = *__first.__seg_ & __m; | ||
| 58 | *__result.__seg_ &= ~__m; | ||
| 59 | *__result.__seg_ |= __b; | ||
| 60 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 61 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 62 | ++__first.__seg_; | ||
| 63 | // __first.__ctz_ = 0; | ||
| 64 | } | ||
| 65 | // __first.__ctz_ == 0; | ||
| 66 | // do middle words | ||
| 67 | __storage_type __nw = __n / __bits_per_word; | ||
| 68 | std::copy(std::__to_address(__first.__seg_), | ||
| 69 | std::__to_address(__first.__seg_ + __nw), | ||
| 70 | std::__to_address(__result.__seg_)); | ||
| 71 | __n -= __nw * __bits_per_word; | ||
| 72 | __result.__seg_ += __nw; | ||
| 73 | // do last word | ||
| 74 | if (__n > 0) { | ||
| 75 | __first.__seg_ += __nw; | ||
| 76 | __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 77 | __storage_type __b = *__first.__seg_ & __m; | ||
| 78 | *__result.__seg_ &= ~__m; | ||
| 79 | *__result.__seg_ |= __b; | ||
| 80 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | return __result; | ||
| 84 | } | ||
| 85 | |||
| 86 | template <class _Cp, bool _IsConst> | ||
| 87 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_unaligned( | ||
| 88 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 89 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 90 | using difference_type = typename _In::difference_type; | ||
| 91 | using __storage_type = typename _In::__storage_type; | ||
| 92 | |||
| 93 | const int __bits_per_word = _In::__bits_per_word; | ||
| 94 | difference_type __n = __last - __first; | ||
| 95 | if (__n > 0) { | ||
| 96 | // do first word | ||
| 97 | if (__first.__ctz_ != 0) { | ||
| 98 | unsigned __clz_f = __bits_per_word - __first.__ctz_; | ||
| 99 | difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); | ||
| 100 | __n -= __dn; | ||
| 101 | __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first.__ctz_); | ||
| 102 | __storage_type __b = *__first.__seg_ & __m; | ||
| 103 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 104 | __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); | ||
| 105 | __m = std::__middle_mask<__storage_type>(__clz_r - __ddn, __result.__ctz_); | ||
| 106 | *__result.__seg_ &= ~__m; | ||
| 107 | if (__result.__ctz_ > __first.__ctz_) | ||
| 108 | *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); | ||
| 109 | else | ||
| 110 | *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); | ||
| 111 | __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; | ||
| 112 | __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); | ||
| 113 | __dn -= __ddn; | ||
| 114 | if (__dn > 0) { | ||
| 115 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __dn); | ||
| 116 | *__result.__seg_ &= ~__m; | ||
| 117 | *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); | ||
| 118 | __result.__ctz_ = static_cast<unsigned>(__dn); | ||
| 119 | } | ||
| 120 | ++__first.__seg_; | ||
| 121 | // __first.__ctz_ = 0; | ||
| 122 | } | ||
| 123 | // __first.__ctz_ == 0; | ||
| 124 | // do middle words | ||
| 125 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 126 | __storage_type __m = std::__leading_mask<__storage_type>(__result.__ctz_); | ||
| 127 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) { | ||
| 128 | __storage_type __b = *__first.__seg_; | ||
| 129 | *__result.__seg_ &= ~__m; | ||
| 130 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 131 | ++__result.__seg_; | ||
| 132 | *__result.__seg_ &= __m; | ||
| 133 | *__result.__seg_ |= __b >> __clz_r; | ||
| 134 | } | ||
| 135 | // do last word | ||
| 136 | if (__n > 0) { | ||
| 137 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 138 | __storage_type __b = *__first.__seg_ & __m; | ||
| 139 | __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r)); | ||
| 140 | __m = std::__middle_mask<__storage_type>(__clz_r - __dn, __result.__ctz_); | ||
| 141 | *__result.__seg_ &= ~__m; | ||
| 142 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 143 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 144 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 145 | __n -= __dn; | ||
| 146 | if (__n > 0) { | ||
| 147 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 148 | *__result.__seg_ &= ~__m; | ||
| 149 | *__result.__seg_ |= __b >> __dn; | ||
| 150 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | } | ||
| 154 | return __result; | ||
| 155 | } | ||
| 156 | |||
| 157 | struct __copy_impl { | 40 | struct __copy_impl { |
| 158 | template <class _InIter, class _Sent, class _OutIter> | 41 | template <class _InIter, |
| 42 | class _Sent, | ||
| 43 | class _OutIter, | ||
| 44 | __enable_if_t<!__specialized_algorithm<_Algorithm::__copy, | ||
| 45 | __iterator_pair<_InIter, _Sent>, | ||
| 46 | __single_iterator<_OutIter> >::__has_algorithm, | ||
| 47 | int> = 0> | ||
| 159 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 160 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { | 49 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { |
| 161 | while (__first != __last) { | 50 | while (__first != __last) { |
| ... | @@ -167,37 +56,39 @@ struct __copy_impl { | ... | @@ -167,37 +56,39 @@ struct __copy_impl { |
| 167 | return std::make_pair(std::move(__first), std::move(__result)); | 56 | return std::make_pair(std::move(__first), std::move(__result)); |
| 168 | } | 57 | } |
| 169 | 58 | ||
| 170 | template <class _InIter, class _OutIter> | 59 | template <class _InIter, |
| 171 | struct _CopySegment { | 60 | class _Sent, |
| 172 | using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>; | 61 | class _OutIter, |
| 173 | 62 | __enable_if_t<__specialized_algorithm<_Algorithm::__copy, | |
| 174 | _OutIter& __result_; | 63 | __iterator_pair<_InIter, _Sent>, |
| 175 | 64 | __single_iterator<_OutIter> >::__has_algorithm, | |
| 176 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit _CopySegment(_OutIter& __result) | 65 | int> = 0> |
| 177 | : __result_(__result) {} | 66 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static pair<_InIter, _OutIter> |
| 178 | 67 | operator()(_InIter __first, _Sent __last, _OutIter __result) { | |
| 179 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 68 | return __specialized_algorithm<_Algorithm::__copy, __iterator_pair<_InIter, _Sent>, __single_iterator<_OutIter> >()( |
| 180 | operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) { | 69 | std::move(__first), std::move(__last), std::move(__result)); |
| 181 | __result_ = std::__copy(__lfirst, __llast, std::move(__result_)).second; | 70 | } |
| 182 | } | ||
| 183 | }; | ||
| 184 | 71 | ||
| 185 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> | 72 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0> |
| 186 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 187 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 74 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| 188 | std::__for_each_segment(__first, __last, _CopySegment<_InIter, _OutIter>(__result)); | 75 | using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator; |
| 76 | std::__for_each_segment(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) { | ||
| 77 | __result = std::__copy(std::move(__lfirst), std::move(__llast), std::move(__result)).second; | ||
| 78 | }); | ||
| 189 | return std::make_pair(__last, std::move(__result)); | 79 | return std::make_pair(__last, std::move(__result)); |
| 190 | } | 80 | } |
| 191 | 81 | ||
| 192 | template <class _InIter, | 82 | template <class _InIter, |
| 193 | class _OutIter, | 83 | class _OutIter, |
| 194 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && | 84 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && |
| 195 | !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value, | 85 | !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, |
| 196 | int> = 0> | 86 | int> = 0> |
| 197 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 87 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 198 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 88 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| 199 | using _Traits = __segmented_iterator_traits<_OutIter>; | 89 | using _Traits = __segmented_iterator_traits<_OutIter>; |
| 200 | using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type; | 90 | using _DiffT = |
| 91 | typename common_type<__iterator_difference_type<_InIter>, __iterator_difference_type<_OutIter> >::type; | ||
| 201 | 92 | ||
| 202 | if (__first == __last) | 93 | if (__first == __last) |
| 203 | return std::make_pair(std::move(__first), std::move(__result)); | 94 | return std::make_pair(std::move(__first), std::move(__result)); |
| ... | @@ -217,16 +108,6 @@ struct __copy_impl { | ... | @@ -217,16 +108,6 @@ struct __copy_impl { |
| 217 | } | 108 | } |
| 218 | } | 109 | } |
| 219 | 110 | ||
| 220 | template <class _Cp, bool _IsConst> | ||
| 221 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> > | ||
| 222 | operator()(__bit_iterator<_Cp, _IsConst> __first, | ||
| 223 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 224 | __bit_iterator<_Cp, false> __result) const { | ||
| 225 | if (__first.__ctz_ == __result.__ctz_) | ||
| 226 | return std::make_pair(__last, std::__copy_aligned(__first, __last, __result)); | ||
| 227 | return std::make_pair(__last, std::__copy_unaligned(__first, __last, __result)); | ||
| 228 | } | ||
| 229 | |||
| 230 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 111 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. |
| 231 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> | 112 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> |
| 232 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
lib/libcxx/include/__algorithm/copy_backward.h+9-24| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy_move_common.h> | 12 | #include <__algorithm/copy_move_common.h> |
| 13 | #include <__algorithm/copy_n.h> | 13 | #include <__algorithm/copy_n.h> |
| 14 | #include <__algorithm/for_each_segment.h> | ||
| 14 | #include <__algorithm/iterator_operations.h> | 15 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/min.h> | 16 | #include <__algorithm/min.h> |
| 16 | #include <__config> | 17 | #include <__config> |
| ... | @@ -170,37 +171,20 @@ struct __copy_backward_impl { | ... | @@ -170,37 +171,20 @@ struct __copy_backward_impl { |
| 170 | return std::make_pair(std::move(__original_last_iter), std::move(__result)); | 171 | return std::make_pair(std::move(__original_last_iter), std::move(__result)); |
| 171 | } | 172 | } |
| 172 | 173 | ||
| 173 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> | 174 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0> |
| 174 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 175 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 175 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 176 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| 176 | using _Traits = __segmented_iterator_traits<_InIter>; | 177 | using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator; |
| 177 | auto __sfirst = _Traits::__segment(__first); | 178 | std::__for_each_segment_backward(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) { |
| 178 | auto __slast = _Traits::__segment(__last); | 179 | __result = std::__copy_backward<_AlgPolicy>(std::move(__lfirst), std::move(__llast), std::move(__result)).second; |
| 179 | if (__sfirst == __slast) { | 180 | }); |
| 180 | auto __iters = | ||
| 181 | std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result)); | ||
| 182 | return std::make_pair(__last, __iters.second); | ||
| 183 | } | ||
| 184 | |||
| 185 | __result = | ||
| 186 | std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result)) | ||
| 187 | .second; | ||
| 188 | --__slast; | ||
| 189 | while (__sfirst != __slast) { | ||
| 190 | __result = | ||
| 191 | std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result)) | ||
| 192 | .second; | ||
| 193 | --__slast; | ||
| 194 | } | ||
| 195 | __result = std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result)) | ||
| 196 | .second; | ||
| 197 | return std::make_pair(__last, std::move(__result)); | 181 | return std::make_pair(__last, std::move(__result)); |
| 198 | } | 182 | } |
| 199 | 183 | ||
| 200 | template <class _InIter, | 184 | template <class _InIter, |
| 201 | class _OutIter, | 185 | class _OutIter, |
| 202 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && | 186 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && |
| 203 | !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value, | 187 | !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, |
| 204 | int> = 0> | 188 | int> = 0> |
| 205 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 189 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 206 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 190 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| ... | @@ -214,7 +198,8 @@ struct __copy_backward_impl { | ... | @@ -214,7 +198,8 @@ struct __copy_backward_impl { |
| 214 | 198 | ||
| 215 | auto __local_last = _Traits::__local(__result); | 199 | auto __local_last = _Traits::__local(__result); |
| 216 | while (true) { | 200 | while (true) { |
| 217 | using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type; | 201 | using _DiffT = |
| 202 | typename common_type<__iterator_difference_type<_InIter>, __iterator_difference_type<_OutIter> >::type; | ||
| 218 | 203 | ||
| 219 | auto __local_first = _Traits::__begin(__segment_iterator); | 204 | auto __local_first = _Traits::__begin(__segment_iterator); |
| 220 | auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first); | 205 | auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first); |
lib/libcxx/include/__algorithm/copy_n.h+50-16| ... | @@ -10,31 +10,63 @@ | ... | @@ -10,31 +10,63 @@ |
| 10 | #define _LIBCPP___ALGORITHM_COPY_N_H | 10 | #define _LIBCPP___ALGORITHM_COPY_N_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy.h> | 12 | #include <__algorithm/copy.h> |
| 13 | #include <__algorithm/iterator_operations.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__iterator/iterator_traits.h> | 15 | #include <__iterator/iterator_traits.h> |
| 15 | #include <__type_traits/enable_if.h> | 16 | #include <__type_traits/enable_if.h> |
| 16 | #include <__utility/convert_to_integral.h> | 17 | #include <__utility/convert_to_integral.h> |
| 18 | #include <__utility/move.h> | ||
| 19 | #include <__utility/pair.h> | ||
| 17 | 20 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| 20 | #endif | 23 | #endif |
| 21 | 24 | ||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | #include <__undef_macros> | ||
| 27 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 29 | ||
| 30 | template <class _AlgPolicy, | ||
| 31 | class _InIter, | ||
| 32 | class _OutIter, | ||
| 33 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value, int> = 0> | ||
| 34 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter> | ||
| 35 | __copy_n(_InIter __first, typename _IterOps<_AlgPolicy>::template __difference_type<_InIter> __n, _OutIter __result) { | ||
| 36 | return std::__copy(__first, __first + __n, std::move(__result)); | ||
| 37 | } | ||
| 38 | |||
| 39 | template <class _AlgPolicy, | ||
| 40 | class _InIter, | ||
| 41 | class _OutIter, | ||
| 42 | __enable_if_t<!__has_random_access_iterator_category<_InIter>::value, int> = 0> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter> | ||
| 44 | __copy_n(_InIter __first, typename _IterOps<_AlgPolicy>::template __difference_type<_InIter> __n, _OutIter __result) { | ||
| 45 | while (__n != 0) { | ||
| 46 | *__result = *__first; | ||
| 47 | ++__first; | ||
| 48 | ++__result; | ||
| 49 | --__n; | ||
| 50 | } | ||
| 51 | return std::make_pair(std::move(__first), std::move(__result)); | ||
| 52 | } | ||
| 53 | |||
| 54 | // The InputIterator case is handled specially here because it's been written in a way to avoid incrementing __first | ||
| 55 | // if not absolutely required. This was done to allow its use with istream_iterator and we want to avoid breaking | ||
| 56 | // people, at least currently. | ||
| 57 | // See https://github.com/llvm/llvm-project/commit/99847d2bf132854fffa019bab19818768102ccad | ||
| 24 | template <class _InputIterator, | 58 | template <class _InputIterator, |
| 25 | class _Size, | 59 | class _Size, |
| 26 | class _OutputIterator, | 60 | class _OutputIterator, |
| 27 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value && | 61 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 28 | !__has_random_access_iterator_category<_InputIterator>::value, | 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 29 | int> = 0> | 63 | copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) { |
| 30 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 64 | using _IntegralSize = decltype(std::__convert_to_integral(__n)); |
| 31 | copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { | 65 | _IntegralSize __converted = __n; |
| 32 | typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize; | 66 | if (__converted > 0) { |
| 33 | _IntegralSize __n = __orig_n; | ||
| 34 | if (__n > 0) { | ||
| 35 | *__result = *__first; | 67 | *__result = *__first; |
| 36 | ++__result; | 68 | ++__result; |
| 37 | for (--__n; __n > 0; --__n) { | 69 | for (--__converted; __converted > 0; --__converted) { |
| 38 | ++__first; | 70 | ++__first; |
| 39 | *__result = *__first; | 71 | *__result = *__first; |
| 40 | ++__result; | 72 | ++__result; |
| ... | @@ -46,15 +78,17 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { | ... | @@ -46,15 +78,17 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { |
| 46 | template <class _InputIterator, | 78 | template <class _InputIterator, |
| 47 | class _Size, | 79 | class _Size, |
| 48 | class _OutputIterator, | 80 | class _OutputIterator, |
| 49 | __enable_if_t<__has_random_access_iterator_category<_InputIterator>::value, int> = 0> | 81 | __enable_if_t<!__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 50 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 82 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 51 | copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { | 83 | copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) { |
| 52 | typedef typename iterator_traits<_InputIterator>::difference_type difference_type; | 84 | using _IntegralSize = decltype(std::__convert_to_integral(__n)); |
| 53 | typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize; | 85 | _IntegralSize __converted = __n; |
| 54 | _IntegralSize __n = __orig_n; | 86 | return std::__copy_n<_ClassicAlgPolicy>(__first, __iterator_difference_type<_InputIterator>(__converted), __result) |
| 55 | return std::copy(__first, __first + difference_type(__n), __result); | 87 | .second; |
| 56 | } | 88 | } |
| 57 | 89 | ||
| 58 | _LIBCPP_END_NAMESPACE_STD | 90 | _LIBCPP_END_NAMESPACE_STD |
| 59 | 91 | ||
| 92 | _LIBCPP_POP_MACROS | ||
| 93 | |||
| 60 | #endif // _LIBCPP___ALGORITHM_COPY_N_H | 94 | #endif // _LIBCPP___ALGORITHM_COPY_N_H |
lib/libcxx/include/__algorithm/count.h+2-2| ... | @@ -72,7 +72,7 @@ __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_t | ... | @@ -72,7 +72,7 @@ __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_t |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | template <class, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0> | 74 | template <class, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0> |
| 75 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<__bit_iterator<_Cp, _IsConst> > | 75 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iterator_difference_type<__bit_iterator<_Cp, _IsConst> > |
| 76 | __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { | 76 | __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { |
| 77 | if (__value) | 77 | if (__value) |
| 78 | return std::__count_bool<true>( | 78 | return std::__count_bool<true>( |
| ... | @@ -82,7 +82,7 @@ __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __l | ... | @@ -82,7 +82,7 @@ __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __l |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | template <class _InputIterator, class _Tp> | 84 | template <class _InputIterator, class _Tp> |
| 85 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> | 85 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iterator_difference_type<_InputIterator> |
| 86 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { | 86 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { |
| 87 | __identity __proj; | 87 | __identity __proj; |
| 88 | return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj); | 88 | return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj); |
lib/libcxx/include/__algorithm/equal.h+43-55| ... | @@ -160,22 +160,28 @@ template <class _Cp, | ... | @@ -160,22 +160,28 @@ template <class _Cp, |
| 160 | bool _IsConst1, | 160 | bool _IsConst1, |
| 161 | bool _IsConst2, | 161 | bool _IsConst2, |
| 162 | class _BinaryPredicate, | 162 | class _BinaryPredicate, |
| 163 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, int> = 0> | 163 | class _Proj1, |
| 164 | class _Proj2, | ||
| 165 | __enable_if_t<__is_identity<_Proj1>::value && __is_identity<_Proj2>::value && | ||
| 166 | __desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, | ||
| 167 | int> = 0> | ||
| 164 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( | 168 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( |
| 165 | __bit_iterator<_Cp, _IsConst1> __first1, | 169 | __bit_iterator<_Cp, _IsConst1> __first1, |
| 166 | __bit_iterator<_Cp, _IsConst1> __last1, | 170 | __bit_iterator<_Cp, _IsConst1> __last1, |
| 167 | __bit_iterator<_Cp, _IsConst2> __first2, | 171 | __bit_iterator<_Cp, _IsConst2> __first2, |
| 168 | _BinaryPredicate) { | 172 | _BinaryPredicate, |
| 173 | _Proj1&, | ||
| 174 | _Proj2&) { | ||
| 169 | if (__first1.__ctz_ == __first2.__ctz_) | 175 | if (__first1.__ctz_ == __first2.__ctz_) |
| 170 | return std::__equal_aligned(__first1, __last1, __first2); | 176 | return std::__equal_aligned(__first1, __last1, __first2); |
| 171 | return std::__equal_unaligned(__first1, __last1, __first2); | 177 | return std::__equal_unaligned(__first1, __last1, __first2); |
| 172 | } | 178 | } |
| 173 | 179 | ||
| 174 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 180 | template <class _InIter1, class _Sent1, class _InIter2, class _Pred, class _Proj1, class _Proj2> |
| 175 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( | 181 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( |
| 176 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) { | 182 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 177 | for (; __first1 != __last1; ++__first1, (void)++__first2) | 183 | for (; __first1 != __last1; ++__first1, (void)++__first2) |
| 178 | if (!__pred(*__first1, *__first2)) | 184 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) |
| 179 | return false; | 185 | return false; |
| 180 | return true; | 186 | return true; |
| 181 | } | 187 | } |
| ... | @@ -183,19 +189,23 @@ template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | ... | @@ -183,19 +189,23 @@ template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 183 | template <class _Tp, | 189 | template <class _Tp, |
| 184 | class _Up, | 190 | class _Up, |
| 185 | class _BinaryPredicate, | 191 | class _BinaryPredicate, |
| 186 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value && | 192 | class _Proj1, |
| 187 | !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, | 193 | class _Proj2, |
| 194 | __enable_if_t<__is_identity<_Proj1>::value && __is_identity<_Proj2>::value && | ||
| 195 | __desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value && | ||
| 196 | !is_volatile<_Up>::value && __is_trivially_equality_comparable_v<_Tp, _Up>, | ||
| 188 | int> = 0> | 197 | int> = 0> |
| 189 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 198 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 190 | __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) { | 199 | __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&, _Proj1&, _Proj2&) { |
| 191 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); | 200 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); |
| 192 | } | 201 | } |
| 193 | 202 | ||
| 194 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 203 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 195 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 204 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 196 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { | 205 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { |
| 206 | __identity __proj; | ||
| 197 | return std::__equal_iter_impl( | 207 | return std::__equal_iter_impl( |
| 198 | std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred); | 208 | std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred, __proj, __proj); |
| 199 | } | 209 | } |
| 200 | 210 | ||
| 201 | template <class _InputIterator1, class _InputIterator2> | 211 | template <class _InputIterator1, class _InputIterator2> |
| ... | @@ -206,52 +216,28 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first | ... | @@ -206,52 +216,28 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first |
| 206 | 216 | ||
| 207 | #if _LIBCPP_STD_VER >= 14 | 217 | #if _LIBCPP_STD_VER >= 14 |
| 208 | 218 | ||
| 209 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | 219 | template <bool __known_equal_length, |
| 210 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( | 220 | class _Iter1, |
| 211 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) { | 221 | class _Sent1, |
| 212 | while (__first1 != __last1 && __first2 != __last2) { | 222 | class _Iter2, |
| 213 | if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | 223 | class _Sent2, |
| 214 | return false; | ||
| 215 | ++__first1; | ||
| 216 | ++__first2; | ||
| 217 | } | ||
| 218 | return __first1 == __last1 && __first2 == __last2; | ||
| 219 | } | ||
| 220 | |||
| 221 | template <class _Tp, | ||
| 222 | class _Up, | ||
| 223 | class _Pred, | ||
| 224 | class _Proj1, | ||
| 225 | class _Proj2, | ||
| 226 | __enable_if_t<__desugars_to_v<__equal_tag, _Pred, _Tp, _Up> && __is_identity<_Proj1>::value && | ||
| 227 | __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value && | ||
| 228 | __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, | ||
| 229 | int> = 0> | ||
| 230 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
| 231 | __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) { | ||
| 232 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); | ||
| 233 | } | ||
| 234 | |||
| 235 | template <class _Cp, | ||
| 236 | bool _IsConst1, | ||
| 237 | bool _IsConst2, | ||
| 238 | class _Pred, | 224 | class _Pred, |
| 239 | class _Proj1, | 225 | class _Proj1, |
| 240 | class _Proj2, | 226 | class _Proj2> |
| 241 | __enable_if_t<__desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value && | ||
| 242 | __is_identity<_Proj2>::value, | ||
| 243 | int> = 0> | ||
| 244 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( | 227 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( |
| 245 | __bit_iterator<_Cp, _IsConst1> __first1, | 228 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) { |
| 246 | __bit_iterator<_Cp, _IsConst1> __last1, | 229 | if constexpr (__known_equal_length) { |
| 247 | __bit_iterator<_Cp, _IsConst2> __first2, | 230 | return std::__equal_iter_impl( |
| 248 | __bit_iterator<_Cp, _IsConst2>, | 231 | std::move(__first1), std::move(__last1), std::move(__first2), __comp, __proj1, __proj2); |
| 249 | _Pred&, | 232 | } else { |
| 250 | _Proj1&, | 233 | while (__first1 != __last1 && __first2 != __last2) { |
| 251 | _Proj2&) { | 234 | if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) |
| 252 | if (__first1.__ctz_ == __first2.__ctz_) | 235 | return false; |
| 253 | return std::__equal_aligned(__first1, __last1, __first2); | 236 | ++__first1; |
| 254 | return std::__equal_unaligned(__first1, __last1, __first2); | 237 | ++__first2; |
| 238 | } | ||
| 239 | return __first1 == __last1 && __first2 == __last2; | ||
| 240 | } | ||
| 255 | } | 241 | } |
| 256 | 242 | ||
| 257 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 243 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| ... | @@ -261,13 +247,15 @@ equal(_InputIterator1 __first1, | ... | @@ -261,13 +247,15 @@ equal(_InputIterator1 __first1, |
| 261 | _InputIterator2 __first2, | 247 | _InputIterator2 __first2, |
| 262 | _InputIterator2 __last2, | 248 | _InputIterator2 __last2, |
| 263 | _BinaryPredicate __pred) { | 249 | _BinaryPredicate __pred) { |
| 264 | if constexpr (__has_random_access_iterator_category<_InputIterator1>::value && | 250 | static constexpr bool __both_random_access = |
| 265 | __has_random_access_iterator_category<_InputIterator2>::value) { | 251 | __has_random_access_iterator_category<_InputIterator1>::value && |
| 252 | __has_random_access_iterator_category<_InputIterator2>::value; | ||
| 253 | if constexpr (__both_random_access) { | ||
| 266 | if (std::distance(__first1, __last1) != std::distance(__first2, __last2)) | 254 | if (std::distance(__first1, __last1) != std::distance(__first2, __last2)) |
| 267 | return false; | 255 | return false; |
| 268 | } | 256 | } |
| 269 | __identity __proj; | 257 | __identity __proj; |
| 270 | return std::__equal_impl( | 258 | return std::__equal_impl<__both_random_access>( |
| 271 | std::__unwrap_iter(__first1), | 259 | std::__unwrap_iter(__first1), |
| 272 | std::__unwrap_iter(__last1), | 260 | std::__unwrap_iter(__last1), |
| 273 | std::__unwrap_iter(__first2), | 261 | std::__unwrap_iter(__first2), |
lib/libcxx/include/__algorithm/fill.h+26-8| ... | @@ -10,8 +10,12 @@ | ... | @@ -10,8 +10,12 @@ |
| 10 | #define _LIBCPP___ALGORITHM_FILL_H | 10 | #define _LIBCPP___ALGORITHM_FILL_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/fill_n.h> | 12 | #include <__algorithm/fill_n.h> |
| 13 | #include <__algorithm/for_each_segment.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__iterator/iterator_traits.h> | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__iterator/segmented_iterator.h> | ||
| 17 | #include <__type_traits/enable_if.h> | ||
| 18 | #include <__type_traits/is_same.h> | ||
| 15 | 19 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 21 | # pragma GCC system_header |
| ... | @@ -21,23 +25,37 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,23 +25,37 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 25 | ||
| 22 | // fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. | 26 | // fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. |
| 23 | 27 | ||
| 24 | template <class _ForwardIterator, class _Tp> | 28 | template <class _ForwardIterator, class _Sentinel, class _Tp> |
| 25 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 29 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 26 | __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag) { | 30 | __fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __value) { |
| 31 | #ifndef _LIBCPP_CXX03_LANG | ||
| 32 | if constexpr (is_same<_ForwardIterator, _Sentinel>::value && __is_segmented_iterator_v<_ForwardIterator>) { | ||
| 33 | using __local_iterator_t = typename __segmented_iterator_traits<_ForwardIterator>::__local_iterator; | ||
| 34 | std::__for_each_segment(__first, __last, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) { | ||
| 35 | std::__fill(__lfirst, __llast, __value); | ||
| 36 | }); | ||
| 37 | return __last; | ||
| 38 | } | ||
| 39 | #endif | ||
| 27 | for (; __first != __last; ++__first) | 40 | for (; __first != __last; ++__first) |
| 28 | *__first = __value; | 41 | *__first = __value; |
| 42 | return __first; | ||
| 29 | } | 43 | } |
| 30 | 44 | ||
| 31 | template <class _RandomAccessIterator, class _Tp> | 45 | template <class _RandomAccessIterator, |
| 32 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 46 | class _Tp, |
| 33 | __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag) { | 47 | __enable_if_t<__has_random_access_iterator_category<_RandomAccessIterator>::value && |
| 34 | std::fill_n(__first, __last - __first, __value); | 48 | !__is_segmented_iterator_v<_RandomAccessIterator>, |
| 49 | int> = 0> | ||
| 50 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | ||
| 51 | __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value) { | ||
| 52 | return std::__fill_n(__first, __last - __first, __value); | ||
| 35 | } | 53 | } |
| 36 | 54 | ||
| 37 | template <class _ForwardIterator, class _Tp> | 55 | template <class _ForwardIterator, class _Tp> |
| 38 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 56 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 39 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 57 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 40 | std::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category()); | 58 | std::__fill(__first, __last, __value); |
| 41 | } | 59 | } |
| 42 | 60 | ||
| 43 | _LIBCPP_END_NAMESPACE_STD | 61 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/fill_n.h+32-46| ... | @@ -9,11 +9,14 @@ | ... | @@ -9,11 +9,14 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_FILL_N_H | 9 | #ifndef _LIBCPP___ALGORITHM_FILL_N_H |
| 10 | #define _LIBCPP___ALGORITHM_FILL_N_H | 10 | #define _LIBCPP___ALGORITHM_FILL_N_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/min.h> | 12 | #include <__algorithm/for_each_n_segment.h> |
| 13 | #include <__algorithm/specialized_algorithms.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__fwd/bit_reference.h> | 15 | #include <__iterator/iterator_traits.h> |
| 15 | #include <__memory/pointer_traits.h> | 16 | #include <__iterator/segmented_iterator.h> |
| 17 | #include <__type_traits/enable_if.h> | ||
| 16 | #include <__utility/convert_to_integral.h> | 18 | #include <__utility/convert_to_integral.h> |
| 19 | #include <__utility/move.h> | ||
| 17 | 20 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -26,56 +29,39 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,56 +29,39 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 29 | ||
| 27 | // fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. | 30 | // fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. |
| 28 | 31 | ||
| 29 | template <class _OutputIterator, class _Size, class _Tp> | 32 | template < |
| 30 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 33 | class _OutputIterator, |
| 31 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value); | 34 | class _Size, |
| 32 | 35 | class _Tp, | |
| 33 | template <bool _FillVal, class _Cp> | 36 | __enable_if_t<!__specialized_algorithm<_Algorithm::__fill_n, __single_iterator<_OutputIterator> >::__has_algorithm, |
| 34 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 37 | int> = 0> |
| 35 | __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_type_traits<_Cp>::size_type __n) { | ||
| 36 | using _It = __bit_iterator<_Cp, false>; | ||
| 37 | using __storage_type = typename _It::__storage_type; | ||
| 38 | |||
| 39 | const int __bits_per_word = _It::__bits_per_word; | ||
| 40 | // do first partial word | ||
| 41 | if (__first.__ctz_ != 0) { | ||
| 42 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); | ||
| 43 | __storage_type __dn = std::min(__clz_f, __n); | ||
| 44 | std::__fill_masked_range(std::__to_address(__first.__seg_), __clz_f - __dn, __first.__ctz_, _FillVal); | ||
| 45 | __n -= __dn; | ||
| 46 | ++__first.__seg_; | ||
| 47 | } | ||
| 48 | // do middle whole words | ||
| 49 | __storage_type __nw = __n / __bits_per_word; | ||
| 50 | std::__fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0); | ||
| 51 | __n -= __nw * __bits_per_word; | ||
| 52 | // do last partial word | ||
| 53 | if (__n > 0) { | ||
| 54 | __first.__seg_ += __nw; | ||
| 55 | std::__fill_masked_range(std::__to_address(__first.__seg_), __bits_per_word - __n, 0u, _FillVal); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | template <class _Cp, class _Size> | ||
| 60 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> | ||
| 61 | __fill_n(__bit_iterator<_Cp, false> __first, _Size __n, const bool& __value) { | ||
| 62 | if (__n > 0) { | ||
| 63 | if (__value) | ||
| 64 | std::__fill_n_bool<true>(__first, __n); | ||
| 65 | else | ||
| 66 | std::__fill_n_bool<false>(__first, __n); | ||
| 67 | } | ||
| 68 | return __first + __n; | ||
| 69 | } | ||
| 70 | |||
| 71 | template <class _OutputIterator, class _Size, class _Tp> | ||
| 72 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 38 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 73 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { | 39 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { |
| 40 | #ifndef _LIBCPP_CXX03_LANG | ||
| 41 | if constexpr (__is_segmented_iterator_v<_OutputIterator>) { | ||
| 42 | using __local_iterator = typename __segmented_iterator_traits<_OutputIterator>::__local_iterator; | ||
| 43 | if constexpr (__has_random_access_iterator_category<__local_iterator>::value) { | ||
| 44 | return std::__for_each_n_segment(__first, __n, [&](__local_iterator __lfirst, __local_iterator __llast) { | ||
| 45 | std::__fill_n(__lfirst, __llast - __lfirst, __value); | ||
| 46 | }); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | #endif | ||
| 74 | for (; __n > 0; ++__first, (void)--__n) | 50 | for (; __n > 0; ++__first, (void)--__n) |
| 75 | *__first = __value; | 51 | *__first = __value; |
| 76 | return __first; | 52 | return __first; |
| 77 | } | 53 | } |
| 78 | 54 | ||
| 55 | template <class _OutIter, | ||
| 56 | class _Size, | ||
| 57 | class _Tp, | ||
| 58 | __enable_if_t<__specialized_algorithm<_Algorithm::__fill_n, __single_iterator<_OutIter> >::__has_algorithm, | ||
| 59 | int> = 0> | ||
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutIter __fill_n(_OutIter __first, _Size __n, const _Tp& __value) { | ||
| 61 | return __specialized_algorithm<_Algorithm::__fill_n, __single_iterator<_OutIter> >()( | ||
| 62 | std::move(__first), __n, __value); | ||
| 63 | } | ||
| 64 | |||
| 79 | template <class _OutputIterator, class _Size, class _Tp> | 65 | template <class _OutputIterator, class _Size, class _Tp> |
| 80 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 66 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 81 | fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { | 67 | fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) { |
lib/libcxx/include/__algorithm/find.h+96-39| ... | @@ -12,16 +12,19 @@ | ... | @@ -12,16 +12,19 @@ |
| 12 | 12 | ||
| 13 | #include <__algorithm/find_segment_if.h> | 13 | #include <__algorithm/find_segment_if.h> |
| 14 | #include <__algorithm/min.h> | 14 | #include <__algorithm/min.h> |
| 15 | #include <__algorithm/simd_utils.h> | ||
| 15 | #include <__algorithm/unwrap_iter.h> | 16 | #include <__algorithm/unwrap_iter.h> |
| 16 | #include <__bit/countr.h> | 17 | #include <__bit/countr.h> |
| 17 | #include <__bit/invert_if.h> | 18 | #include <__bit/invert_if.h> |
| 18 | #include <__config> | 19 | #include <__config> |
| 20 | #include <__cstddef/size_t.h> | ||
| 19 | #include <__functional/identity.h> | 21 | #include <__functional/identity.h> |
| 20 | #include <__fwd/bit_reference.h> | 22 | #include <__fwd/bit_reference.h> |
| 21 | #include <__iterator/segmented_iterator.h> | 23 | #include <__iterator/segmented_iterator.h> |
| 22 | #include <__string/constexpr_c_functions.h> | 24 | #include <__string/constexpr_c_functions.h> |
| 23 | #include <__type_traits/enable_if.h> | 25 | #include <__type_traits/enable_if.h> |
| 24 | #include <__type_traits/invoke.h> | 26 | #include <__type_traits/invoke.h> |
| 27 | #include <__type_traits/is_constant_evaluated.h> | ||
| 25 | #include <__type_traits/is_equality_comparable.h> | 28 | #include <__type_traits/is_equality_comparable.h> |
| 26 | #include <__type_traits/is_integral.h> | 29 | #include <__type_traits/is_integral.h> |
| 27 | #include <__type_traits/is_signed.h> | 30 | #include <__type_traits/is_signed.h> |
| ... | @@ -44,46 +47,108 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -44,46 +47,108 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 44 | // generic implementation | 47 | // generic implementation |
| 45 | template <class _Iter, class _Sent, class _Tp, class _Proj> | 48 | template <class _Iter, class _Sent, class _Tp, class _Proj> |
| 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter | 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter |
| 47 | __find(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { | 50 | __find_loop(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { |
| 48 | for (; __first != __last; ++__first) | 51 | for (; __first != __last; ++__first) |
| 49 | if (std::__invoke(__proj, *__first) == __value) | 52 | if (std::__invoke(__proj, *__first) == __value) |
| 50 | break; | 53 | break; |
| 51 | return __first; | 54 | return __first; |
| 52 | } | 55 | } |
| 53 | 56 | ||
| 54 | // trivially equality comparable implementations | 57 | template <class _Iter, class _Sent, class _Tp, class _Proj> |
| 55 | template <class _Tp, | 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter |
| 56 | class _Up, | 59 | __find(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { |
| 57 | class _Proj, | 60 | return std::__find_loop(std::move(__first), std::move(__last), __value, __proj); |
| 58 | __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && | ||
| 59 | sizeof(_Tp) == 1, | ||
| 60 | int> = 0> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { | ||
| 62 | if (auto __ret = std::__constexpr_memchr(__first, __value, __last - __first)) | ||
| 63 | return __ret; | ||
| 64 | return __last; | ||
| 65 | } | 61 | } |
| 66 | 62 | ||
| 67 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 63 | #if _LIBCPP_VECTORIZE_ALGORITHMS |
| 64 | template <class _Tp, class _Up> | ||
| 65 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI | ||
| 66 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find_vectorized(_Tp* __first, _Tp* __last, _Up __value) { | ||
| 67 | if (!__libcpp_is_constant_evaluated()) { | ||
| 68 | constexpr size_t __unroll_count = 4; | ||
| 69 | constexpr size_t __vec_size = __native_vector_size<_Tp>; | ||
| 70 | using __vec = __simd_vector<_Tp, __vec_size>; | ||
| 71 | |||
| 72 | auto __orig_first = __first; | ||
| 73 | |||
| 74 | auto __values = static_cast<__simd_vector<_Tp, __vec_size>>(__value); // broadcast the value | ||
| 75 | while (static_cast<size_t>(__last - __first) >= __unroll_count * __vec_size) [[__unlikely__]] { | ||
| 76 | __vec __lhs[__unroll_count]; | ||
| 77 | |||
| 78 | for (size_t __i = 0; __i != __unroll_count; ++__i) | ||
| 79 | __lhs[__i] = std::__load_vector<__vec>(__first + __i * __vec_size); | ||
| 80 | |||
| 81 | for (size_t __i = 0; __i != __unroll_count; ++__i) { | ||
| 82 | if (auto __cmp_res = __lhs[__i] == __values; std::__any_of(__cmp_res)) { | ||
| 83 | auto __offset = __i * __vec_size + std::__find_first_set(__cmp_res); | ||
| 84 | return __first + __offset; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | __first += __unroll_count * __vec_size; | ||
| 89 | } | ||
| 90 | |||
| 91 | // check the remaining 0-3 vectors | ||
| 92 | while (static_cast<size_t>(__last - __first) >= __vec_size) { | ||
| 93 | if (auto __cmp_res = std::__load_vector<__vec>(__first) == __values; std::__any_of(__cmp_res)) { | ||
| 94 | return __first + std::__find_first_set(__cmp_res); | ||
| 95 | } | ||
| 96 | __first += __vec_size; | ||
| 97 | } | ||
| 98 | |||
| 99 | if (__last - __first == 0) | ||
| 100 | return __first; | ||
| 101 | |||
| 102 | // Check if we can load elements in front of the current pointer. If that's the case load a vector at | ||
| 103 | // (last - vector_size) to check the remaining elements | ||
| 104 | if (static_cast<size_t>(__first - __orig_first) >= __vec_size) { | ||
| 105 | __first = __last - __vec_size; | ||
| 106 | return __first + std::__find_first_set(std::__load_vector<__vec>(__first) == __values); | ||
| 107 | } | ||
| 108 | } | ||
| 109 | |||
| 110 | __identity __proj; | ||
| 111 | return std::__find_loop(__first, __last, __value, __proj); | ||
| 112 | } | ||
| 113 | #endif | ||
| 114 | |||
| 115 | #ifndef _LIBCPP_CXX03_LANG | ||
| 116 | // trivially equality comparable implementations | ||
| 68 | template <class _Tp, | 117 | template <class _Tp, |
| 69 | class _Up, | 118 | class _Up, |
| 70 | class _Proj, | 119 | class _Proj, |
| 71 | __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && | 120 | __enable_if_t<__is_identity<_Proj>::value && __is_trivially_equality_comparable_v<_Tp, _Up>, int> = 0> |
| 72 | sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t), | ||
| 73 | int> = 0> | ||
| 74 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { | 121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { |
| 75 | if (auto __ret = std::__constexpr_wmemchr(__first, __value, __last - __first)) | 122 | if constexpr (sizeof(_Tp) == 1) { |
| 76 | return __ret; | 123 | if (auto __ret = std::__constexpr_memchr(__first, __value, __last - __first)) |
| 77 | return __last; | 124 | return __ret; |
| 125 | return __last; | ||
| 126 | } | ||
| 127 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 128 | else if constexpr (sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t)) { | ||
| 129 | if (auto __ret = std::__constexpr_wmemchr(__first, __value, __last - __first)) | ||
| 130 | return __ret; | ||
| 131 | return __last; | ||
| 132 | } | ||
| 133 | # endif | ||
| 134 | # if _LIBCPP_VECTORIZE_ALGORITHMS | ||
| 135 | else if constexpr (is_integral<_Tp>::value) { | ||
| 136 | return std::__find_vectorized(__first, __last, __value); | ||
| 137 | } | ||
| 138 | # endif | ||
| 139 | else { | ||
| 140 | __identity __proj; | ||
| 141 | return std::__find_loop(__first, __last, __value, __proj); | ||
| 142 | } | ||
| 78 | } | 143 | } |
| 79 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 144 | #endif |
| 80 | 145 | ||
| 81 | // TODO: This should also be possible to get right with different signedness | 146 | // TODO: This should also be possible to get right with different signedness |
| 82 | // cast integral types to allow vectorization | 147 | // cast integral types to allow vectorization |
| 83 | template <class _Tp, | 148 | template <class _Tp, |
| 84 | class _Up, | 149 | class _Up, |
| 85 | class _Proj, | 150 | class _Proj, |
| 86 | __enable_if_t<__is_identity<_Proj>::value && !__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value && | 151 | __enable_if_t<__is_identity<_Proj>::value && !__is_trivially_equality_comparable_v<_Tp, _Up> && |
| 87 | is_integral<_Tp>::value && is_integral<_Up>::value && | 152 | is_integral<_Tp>::value && is_integral<_Up>::value && |
| 88 | is_signed<_Tp>::value == is_signed<_Up>::value, | 153 | is_signed<_Tp>::value == is_signed<_Up>::value, |
| 89 | int> = 0> | 154 | int> = 0> |
| ... | @@ -143,31 +208,23 @@ __find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __la | ... | @@ -143,31 +208,23 @@ __find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __la |
| 143 | 208 | ||
| 144 | // segmented iterator implementation | 209 | // segmented iterator implementation |
| 145 | 210 | ||
| 146 | template <class> | ||
| 147 | struct __find_segment; | ||
| 148 | |||
| 149 | template <class _SegmentedIterator, | 211 | template <class _SegmentedIterator, |
| 150 | class _Tp, | 212 | class _Tp, |
| 151 | class _Proj, | 213 | class _Proj, |
| 152 | __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> | 214 | __enable_if_t<__is_segmented_iterator_v<_SegmentedIterator>, int> = 0> |
| 153 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator | 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator |
| 154 | __find(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) { | 216 | __find(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) { |
| 155 | return std::__find_segment_if(std::move(__first), std::move(__last), __find_segment<_Tp>(__value), __proj); | 217 | using __local_iterator = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator; |
| 218 | return std::__find_segment_if( | ||
| 219 | std::move(__first), | ||
| 220 | std::move(__last), | ||
| 221 | [&__value](__local_iterator __lfirst, __local_iterator __llast, _Proj& __lproj) { | ||
| 222 | return std::__rewrap_iter( | ||
| 223 | __lfirst, std::__find(std::__unwrap_iter(__lfirst), std::__unwrap_iter(__llast), __value, __lproj)); | ||
| 224 | }, | ||
| 225 | __proj); | ||
| 156 | } | 226 | } |
| 157 | 227 | ||
| 158 | template <class _Tp> | ||
| 159 | struct __find_segment { | ||
| 160 | const _Tp& __value_; | ||
| 161 | |||
| 162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __find_segment(const _Tp& __value) : __value_(__value) {} | ||
| 163 | |||
| 164 | template <class _InputIterator, class _Proj> | ||
| 165 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _InputIterator | ||
| 166 | operator()(_InputIterator __first, _InputIterator __last, _Proj& __proj) const { | ||
| 167 | return std::__find(__first, __last, __value_, __proj); | ||
| 168 | } | ||
| 169 | }; | ||
| 170 | |||
| 171 | // public API | 228 | // public API |
| 172 | template <class _InputIterator, class _Tp> | 229 | template <class _InputIterator, class _Tp> |
| 173 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | 230 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator |
lib/libcxx/include/__algorithm/find_end.h+105| ... | @@ -76,6 +76,111 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> | ... | @@ -76,6 +76,111 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | template <class _AlgPolicy, | ||
| 80 | class _Pred, | ||
| 81 | class _Iter1, | ||
| 82 | class _Sent1, | ||
| 83 | class _Iter2, | ||
| 84 | class _Sent2, | ||
| 85 | class _Proj1, | ||
| 86 | class _Proj2> | ||
| 87 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter1> __find_end_impl( | ||
| 88 | _Iter1 __first1, | ||
| 89 | _Sent1 __sent1, | ||
| 90 | _Iter2 __first2, | ||
| 91 | _Sent2 __sent2, | ||
| 92 | _Pred& __pred, | ||
| 93 | _Proj1& __proj1, | ||
| 94 | _Proj2& __proj2, | ||
| 95 | bidirectional_iterator_tag, | ||
| 96 | bidirectional_iterator_tag) { | ||
| 97 | auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1); | ||
| 98 | auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2); | ||
| 99 | // modeled after search algorithm (in reverse) | ||
| 100 | if (__first2 == __last2) | ||
| 101 | return std::make_pair(__last1, __last1); // Everything matches an empty sequence | ||
| 102 | _Iter1 __l1 = __last1; | ||
| 103 | _Iter2 __l2 = __last2; | ||
| 104 | --__l2; | ||
| 105 | while (true) { | ||
| 106 | // Find last element in sequence 1 that matches *(__last2-1), with a mininum of loop checks | ||
| 107 | while (true) { | ||
| 108 | if (__first1 == __l1) // return __last1 if no element matches *__first2 | ||
| 109 | return std::make_pair(__last1, __last1); | ||
| 110 | if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | ||
| 111 | break; | ||
| 112 | } | ||
| 113 | // *__l1 matches *__l2, now match elements before here | ||
| 114 | _Iter1 __match_last = __l1; | ||
| 115 | _Iter1 __m1 = __l1; | ||
| 116 | _Iter2 __m2 = __l2; | ||
| 117 | while (true) { | ||
| 118 | if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern) | ||
| 119 | return std::make_pair(__m1, ++__match_last); | ||
| 120 | if (__m1 == __first1) // Otherwise if source exhaused, pattern not found | ||
| 121 | return std::make_pair(__last1, __last1); | ||
| 122 | |||
| 123 | // if there is a mismatch, restart with a new __l1 | ||
| 124 | if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2))) { | ||
| 125 | break; | ||
| 126 | } // else there is a match, check next elements | ||
| 127 | } | ||
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | template <class _AlgPolicy, | ||
| 132 | class _Pred, | ||
| 133 | class _Iter1, | ||
| 134 | class _Sent1, | ||
| 135 | class _Iter2, | ||
| 136 | class _Sent2, | ||
| 137 | class _Proj1, | ||
| 138 | class _Proj2> | ||
| 139 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __find_end_impl( | ||
| 140 | _Iter1 __first1, | ||
| 141 | _Sent1 __sent1, | ||
| 142 | _Iter2 __first2, | ||
| 143 | _Sent2 __sent2, | ||
| 144 | _Pred& __pred, | ||
| 145 | _Proj1& __proj1, | ||
| 146 | _Proj2& __proj2, | ||
| 147 | random_access_iterator_tag, | ||
| 148 | random_access_iterator_tag) { | ||
| 149 | typedef typename iterator_traits<_Iter1>::difference_type _D1; | ||
| 150 | auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1); | ||
| 151 | auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2); | ||
| 152 | // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern | ||
| 153 | auto __len2 = __last2 - __first2; | ||
| 154 | if (__len2 == 0) | ||
| 155 | return std::make_pair(__last1, __last1); | ||
| 156 | auto __len1 = __last1 - __first1; | ||
| 157 | if (__len1 < __len2) | ||
| 158 | return std::make_pair(__last1, __last1); | ||
| 159 | const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here | ||
| 160 | _Iter1 __l1 = __last1; | ||
| 161 | _Iter2 __l2 = __last2; | ||
| 162 | --__l2; | ||
| 163 | while (true) { | ||
| 164 | while (true) { | ||
| 165 | if (__s == __l1) | ||
| 166 | return std::make_pair(__last1, __last1); | ||
| 167 | if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | ||
| 168 | break; | ||
| 169 | } | ||
| 170 | _Iter1 __last_match = __l1; | ||
| 171 | _Iter1 __m1 = __l1; | ||
| 172 | _Iter2 __m2 = __l2; | ||
| 173 | while (true) { | ||
| 174 | if (__m2 == __first2) | ||
| 175 | return std::make_pair(__m1, ++__last_match); | ||
| 176 | // no need to check range on __m1 because __s guarantees we have enough source | ||
| 177 | if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2))) { | ||
| 178 | break; | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 79 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 184 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 80 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic( | 185 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic( |
| 81 | _ForwardIterator1 __first1, | 186 | _ForwardIterator1 __first1, |
lib/libcxx/include/__algorithm/for_each.h+18-24| ... | @@ -11,45 +11,41 @@ | ... | @@ -11,45 +11,41 @@ |
| 11 | #define _LIBCPP___ALGORITHM_FOR_EACH_H | 11 | #define _LIBCPP___ALGORITHM_FOR_EACH_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/for_each_segment.h> | 13 | #include <__algorithm/for_each_segment.h> |
| 14 | #include <__algorithm/specialized_algorithms.h> | ||
| 14 | #include <__config> | 15 | #include <__config> |
| 15 | #include <__functional/identity.h> | 16 | #include <__functional/identity.h> |
| 16 | #include <__iterator/segmented_iterator.h> | 17 | #include <__iterator/segmented_iterator.h> |
| 17 | #include <__type_traits/enable_if.h> | ||
| 18 | #include <__type_traits/invoke.h> | 18 | #include <__type_traits/invoke.h> |
| 19 | #include <__utility/move.h> | 19 | #include <__type_traits/is_same.h> |
| 20 | 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| 23 | #endif | 23 | #endif |
| 24 | 24 | ||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | #include <__undef_macros> | ||
| 27 | |||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 26 | ||
| 30 | template <class _InputIterator, class _Sent, class _Func, class _Proj> | 27 | template <class _InputIterator, class _Sent, class _Func, class _Proj> |
| 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator |
| 32 | __for_each(_InputIterator __first, _Sent __last, _Func& __f, _Proj& __proj) { | 29 | __for_each(_InputIterator __first, _Sent __last, _Func& __func, _Proj& __proj) { |
| 30 | #ifndef _LIBCPP_CXX03_LANG | ||
| 31 | if constexpr (using _SpecialAlg = | ||
| 32 | __specialized_algorithm<_Algorithm::__for_each, __iterator_pair<_InputIterator, _Sent>>; | ||
| 33 | _SpecialAlg::__has_algorithm) { | ||
| 34 | _SpecialAlg()(__first, __last, __func, __proj); | ||
| 35 | return __last; | ||
| 36 | } else if constexpr (is_same<_InputIterator, _Sent>::value && __is_segmented_iterator_v<_InputIterator>) { | ||
| 37 | using __local_iterator_t = typename __segmented_iterator_traits<_InputIterator>::__local_iterator; | ||
| 38 | std::__for_each_segment(__first, __last, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) { | ||
| 39 | std::__for_each(__lfirst, __llast, __func, __proj); | ||
| 40 | }); | ||
| 41 | return __last; | ||
| 42 | } | ||
| 43 | #endif | ||
| 33 | for (; __first != __last; ++__first) | 44 | for (; __first != __last; ++__first) |
| 34 | std::__invoke(__f, std::__invoke(__proj, *__first)); | 45 | std::__invoke(__func, std::__invoke(__proj, *__first)); |
| 35 | return __first; | 46 | return __first; |
| 36 | } | 47 | } |
| 37 | 48 | ||
| 38 | #ifndef _LIBCPP_CXX03_LANG | ||
| 39 | template <class _SegmentedIterator, | ||
| 40 | class _Func, | ||
| 41 | class _Proj, | ||
| 42 | __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _SegmentedIterator | ||
| 44 | __for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Func& __func, _Proj& __proj) { | ||
| 45 | using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator; | ||
| 46 | std::__for_each_segment(__first, __last, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) { | ||
| 47 | std::__for_each(__lfirst, __llast, __func, __proj); | ||
| 48 | }); | ||
| 49 | return __last; | ||
| 50 | } | ||
| 51 | #endif // !_LIBCPP_CXX03_LANG | ||
| 52 | |||
| 53 | template <class _InputIterator, class _Func> | 49 | template <class _InputIterator, class _Func> |
| 54 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Func | 50 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Func |
| 55 | for_each(_InputIterator __first, _InputIterator __last, _Func __f) { | 51 | for_each(_InputIterator __first, _InputIterator __last, _Func __f) { |
| ... | @@ -60,6 +56,4 @@ for_each(_InputIterator __first, _InputIterator __last, _Func __f) { | ... | @@ -60,6 +56,4 @@ for_each(_InputIterator __first, _InputIterator __last, _Func __f) { |
| 60 | 56 | ||
| 61 | _LIBCPP_END_NAMESPACE_STD | 57 | _LIBCPP_END_NAMESPACE_STD |
| 62 | 58 | ||
| 63 | _LIBCPP_POP_MACROS | ||
| 64 | |||
| 65 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_H | 59 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_H |
lib/libcxx/include/__algorithm/for_each_n.h+20-47| ... | @@ -16,10 +16,7 @@ | ... | @@ -16,10 +16,7 @@ |
| 16 | #include <__functional/identity.h> | 16 | #include <__functional/identity.h> |
| 17 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__iterator/segmented_iterator.h> | 18 | #include <__iterator/segmented_iterator.h> |
| 19 | #include <__type_traits/disjunction.h> | ||
| 20 | #include <__type_traits/enable_if.h> | ||
| 21 | #include <__type_traits/invoke.h> | 19 | #include <__type_traits/invoke.h> |
| 22 | #include <__type_traits/negation.h> | ||
| 23 | #include <__utility/convert_to_integral.h> | 20 | #include <__utility/convert_to_integral.h> |
| 24 | #include <__utility/move.h> | 21 | #include <__utility/move.h> |
| 25 | 22 | ||
| ... | @@ -32,57 +29,33 @@ _LIBCPP_PUSH_MACROS | ... | @@ -32,57 +29,33 @@ _LIBCPP_PUSH_MACROS |
| 32 | 29 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 31 | ||
| 35 | template <class _InputIterator, | 32 | template <class _InputIterator, class _Size, class _Func, class _Proj> |
| 36 | class _Size, | ||
| 37 | class _Func, | ||
| 38 | class _Proj, | ||
| 39 | __enable_if_t<!__has_random_access_iterator_category<_InputIterator>::value && | ||
| 40 | _Or< _Not<__is_segmented_iterator<_InputIterator> >, | ||
| 41 | _Not<__has_random_access_local_iterator<_InputIterator> > >::value, | ||
| 42 | int> = 0> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | 33 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator |
| 44 | __for_each_n(_InputIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) { | 34 | __for_each_n(_InputIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) { |
| 45 | typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize; | 35 | typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize; |
| 46 | _IntegralSize __n = __orig_n; | 36 | _IntegralSize __n = __orig_n; |
| 47 | while (__n > 0) { | ||
| 48 | std::__invoke(__f, std::__invoke(__proj, *__first)); | ||
| 49 | ++__first; | ||
| 50 | --__n; | ||
| 51 | } | ||
| 52 | return std::move(__first); | ||
| 53 | } | ||
| 54 | |||
| 55 | template <class _RandIter, | ||
| 56 | class _Size, | ||
| 57 | class _Func, | ||
| 58 | class _Proj, | ||
| 59 | __enable_if_t<__has_random_access_iterator_category<_RandIter>::value, int> = 0> | ||
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandIter | ||
| 61 | __for_each_n(_RandIter __first, _Size __orig_n, _Func& __f, _Proj& __proj) { | ||
| 62 | typename std::iterator_traits<_RandIter>::difference_type __n = __orig_n; | ||
| 63 | auto __last = __first + __n; | ||
| 64 | std::__for_each(__first, __last, __f, __proj); | ||
| 65 | return __last; | ||
| 66 | } | ||
| 67 | 37 | ||
| 68 | #ifndef _LIBCPP_CXX03_LANG | 38 | #ifndef _LIBCPP_CXX03_LANG |
| 69 | template <class _SegmentedIterator, | 39 | if constexpr (__is_segmented_iterator_v<_InputIterator>) { |
| 70 | class _Size, | 40 | using __local_iterator = typename __segmented_iterator_traits<_InputIterator>::__local_iterator; |
| 71 | class _Func, | 41 | if constexpr (__has_random_access_iterator_category<__local_iterator>::value) { |
| 72 | class _Proj, | 42 | return std::__for_each_n_segment(__first, __orig_n, [&](__local_iterator __lfirst, __local_iterator __llast) { |
| 73 | __enable_if_t<!__has_random_access_iterator_category<_SegmentedIterator>::value && | 43 | std::__for_each(__lfirst, __llast, __f, __proj); |
| 74 | __is_segmented_iterator<_SegmentedIterator>::value && | 44 | }); |
| 75 | __has_random_access_iterator_category< | 45 | } else { |
| 76 | typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value, | 46 | return std::__for_each(__first, __first + __n, __f, __proj); |
| 77 | int> = 0> | 47 | } |
| 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _SegmentedIterator | 48 | } else |
| 79 | __for_each_n(_SegmentedIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) { | 49 | #endif |
| 80 | using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator; | 50 | { |
| 81 | return std::__for_each_n_segment(__first, __orig_n, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) { | 51 | while (__n > 0) { |
| 82 | std::__for_each(__lfirst, __llast, __f, __proj); | 52 | std::__invoke(__f, std::__invoke(__proj, *__first)); |
| 83 | }); | 53 | ++__first; |
| 54 | --__n; | ||
| 55 | } | ||
| 56 | return std::move(__first); | ||
| 57 | } | ||
| 84 | } | 58 | } |
| 85 | #endif // !_LIBCPP_CXX03_LANG | ||
| 86 | 59 | ||
| 87 | #if _LIBCPP_STD_VER >= 17 | 60 | #if _LIBCPP_STD_VER >= 17 |
| 88 | 61 |
lib/libcxx/include/__algorithm/for_each_n_segment.h+1-1| ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | template <class _SegmentedIterator, class _Size, class _Functor> | 27 | template <class _SegmentedIterator, class _Size, class _Functor> |
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator | 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator |
| 29 | __for_each_n_segment(_SegmentedIterator __first, _Size __orig_n, _Functor __func) { | 29 | __for_each_n_segment(_SegmentedIterator __first, _Size __orig_n, _Functor __func) { |
| 30 | static_assert(__is_segmented_iterator<_SegmentedIterator>::value && | 30 | static_assert(__is_segmented_iterator_v<_SegmentedIterator> && |
| 31 | __has_random_access_iterator_category< | 31 | __has_random_access_iterator_category< |
| 32 | typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value, | 32 | typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value, |
| 33 | "__for_each_n_segment only works with segmented iterators with random-access local iterators"); | 33 | "__for_each_n_segment only works with segmented iterators with random-access local iterators"); |
lib/libcxx/include/__algorithm/for_each_segment.h+26| ... | @@ -48,6 +48,32 @@ __for_each_segment(_SegmentedIterator __first, _SegmentedIterator __last, _Funct | ... | @@ -48,6 +48,32 @@ __for_each_segment(_SegmentedIterator __first, _SegmentedIterator __last, _Funct |
| 48 | __func(_Traits::__begin(__sfirst), _Traits::__local(__last)); | 48 | __func(_Traits::__begin(__sfirst), _Traits::__local(__last)); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | template <class _SegmentedIterator, class _Functor> | ||
| 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | ||
| 53 | __for_each_segment_backward(_SegmentedIterator __first, _SegmentedIterator __last, _Functor __func) { | ||
| 54 | using _Traits = __segmented_iterator_traits<_SegmentedIterator>; | ||
| 55 | |||
| 56 | auto __sfirst = _Traits::__segment(__first); | ||
| 57 | auto __slast = _Traits::__segment(__last); | ||
| 58 | |||
| 59 | // We are in a single segment, so we might not be at the beginning or end | ||
| 60 | if (__sfirst == __slast) { | ||
| 61 | __func(_Traits::__local(__first), _Traits::__local(__last)); | ||
| 62 | return; | ||
| 63 | } | ||
| 64 | |||
| 65 | // We have more than one segment. Iterate over the last segment, since we might not start at the end | ||
| 66 | __func(_Traits::__begin(__slast), _Traits::__local(__last)); | ||
| 67 | --__slast; | ||
| 68 | // iterate over the segments which are guaranteed to be completely in the range | ||
| 69 | while (__sfirst != __slast) { | ||
| 70 | __func(_Traits::__begin(__slast), _Traits::__end(__slast)); | ||
| 71 | --__slast; | ||
| 72 | } | ||
| 73 | // iterate over the first segment | ||
| 74 | __func(_Traits::__local(__first), _Traits::__end(__slast)); | ||
| 75 | } | ||
| 76 | |||
| 51 | _LIBCPP_END_NAMESPACE_STD | 77 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 78 | ||
| 53 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_SEGMENT_H | 79 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_SEGMENT_H |
lib/libcxx/include/__algorithm/generate.h+4-2| ... | @@ -9,7 +9,9 @@ | ... | @@ -9,7 +9,9 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_GENERATE_H | 9 | #ifndef _LIBCPP___ALGORITHM_GENERATE_H |
| 10 | #define _LIBCPP___ALGORITHM_GENERATE_H | 10 | #define _LIBCPP___ALGORITHM_GENERATE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/for_each.h> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__utility/forward.h> | ||
| 13 | 15 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| ... | @@ -20,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | template <class _ForwardIterator, class _Generator> | 22 | template <class _ForwardIterator, class _Generator> |
| 21 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 23 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 22 | generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { | 24 | generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { |
| 23 | for (; __first != __last; ++__first) | 25 | using __iter_ref = decltype(*__first); |
| 24 | *__first = __gen(); | 26 | std::for_each(__first, __last, [&](__iter_ref __element) { std::forward<__iter_ref>(__element) = __gen(); }); |
| 25 | } | 27 | } |
| 26 | 28 | ||
| 27 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/generate_n.h+19-6| ... | @@ -9,25 +9,38 @@ | ... | @@ -9,25 +9,38 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_GENERATE_N_H | 9 | #ifndef _LIBCPP___ALGORITHM_GENERATE_N_H |
| 10 | #define _LIBCPP___ALGORITHM_GENERATE_N_H | 10 | #define _LIBCPP___ALGORITHM_GENERATE_N_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/for_each_n.h> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 13 | #include <__utility/convert_to_integral.h> | 14 | #include <__functional/identity.h> |
| 15 | #include <__utility/forward.h> | ||
| 16 | #include <__utility/move.h> | ||
| 14 | 17 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 19 | # pragma GCC system_header |
| 17 | #endif | 20 | #endif |
| 18 | 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | ||
| 23 | #include <__undef_macros> | ||
| 24 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 26 | ||
| 27 | template <class _OutputIterator, class _Size, class _Generator> | ||
| 28 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | ||
| 29 | __generate_n(_OutputIterator __first, _Size __orig_n, _Generator& __gen) { | ||
| 30 | using __iter_ref = decltype(*__first); | ||
| 31 | __identity __proj; | ||
| 32 | auto __f = [&](__iter_ref __element) { std::forward<__iter_ref>(__element) = __gen(); }; | ||
| 33 | return std::__for_each_n(std::move(__first), __orig_n, __f, __proj); | ||
| 34 | } | ||
| 35 | |||
| 21 | template <class _OutputIterator, class _Size, class _Generator> | 36 | template <class _OutputIterator, class _Size, class _Generator> |
| 22 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 37 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 23 | generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) { | 38 | generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) { |
| 24 | typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize; | 39 | return std::__generate_n(std::move(__first), __orig_n, __gen); |
| 25 | _IntegralSize __n = __orig_n; | ||
| 26 | for (; __n > 0; ++__first, (void)--__n) | ||
| 27 | *__first = __gen(); | ||
| 28 | return __first; | ||
| 29 | } | 40 | } |
| 30 | 41 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | 42 | _LIBCPP_END_NAMESPACE_STD |
| 32 | 43 | ||
| 44 | _LIBCPP_POP_MACROS | ||
| 45 | |||
| 33 | #endif // _LIBCPP___ALGORITHM_GENERATE_N_H | 46 | #endif // _LIBCPP___ALGORITHM_GENERATE_N_H |
lib/libcxx/include/__algorithm/is_permutation.h+4-4| ... | @@ -78,7 +78,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl( | ... | @@ -78,7 +78,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl( |
| 78 | _Pred&& __pred, | 78 | _Pred&& __pred, |
| 79 | _Proj1&& __proj1, | 79 | _Proj1&& __proj1, |
| 80 | _Proj2&& __proj2) { | 80 | _Proj2&& __proj2) { |
| 81 | using _D1 = __iter_diff_t<_Iter1>; | 81 | using _D1 = __iterator_difference_type<_Iter1>; |
| 82 | 82 | ||
| 83 | for (auto __i = __first1; __i != __last1; ++__i) { | 83 | for (auto __i = __first1; __i != __last1; ++__i) { |
| 84 | // Have we already counted the number of *__i in [f1, l1)? | 84 | // Have we already counted the number of *__i in [f1, l1)? |
| ... | @@ -126,7 +126,7 @@ template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _Fo | ... | @@ -126,7 +126,7 @@ template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _Fo |
| 126 | return true; | 126 | return true; |
| 127 | 127 | ||
| 128 | // __first1 != __last1 && *__first1 != *__first2 | 128 | // __first1 != __last1 && *__first1 != *__first2 |
| 129 | using _D1 = __iter_diff_t<_ForwardIterator1>; | 129 | using _D1 = __iterator_difference_type<_ForwardIterator1>; |
| 130 | _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1); | 130 | _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1); |
| 131 | if (__l1 == _D1(1)) | 131 | if (__l1 == _D1(1)) |
| 132 | return false; | 132 | return false; |
| ... | @@ -173,10 +173,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( | ... | @@ -173,10 +173,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( |
| 173 | if (__first2 == __last2) // Second range is shorter | 173 | if (__first2 == __last2) // Second range is shorter |
| 174 | return false; | 174 | return false; |
| 175 | 175 | ||
| 176 | using _D1 = __iter_diff_t<_Iter1>; | 176 | using _D1 = __iterator_difference_type<_Iter1>; |
| 177 | _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1); | 177 | _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1); |
| 178 | 178 | ||
| 179 | using _D2 = __iter_diff_t<_Iter2>; | 179 | using _D2 = __iterator_difference_type<_Iter2>; |
| 180 | _D2 __l2 = _IterOps<_AlgPolicy>::distance(__first2, __last2); | 180 | _D2 __l2 = _IterOps<_AlgPolicy>::distance(__first2, __last2); |
| 181 | if (__l1 != __l2) | 181 | if (__l1 != __l2) |
| 182 | return false; | 182 | return false; |
lib/libcxx/include/__algorithm/iterator_operations.h+3| ... | @@ -219,6 +219,9 @@ private: | ... | @@ -219,6 +219,9 @@ private: |
| 219 | template <class _AlgPolicy, class _Iter> | 219 | template <class _AlgPolicy, class _Iter> |
| 220 | using __policy_iter_diff_t _LIBCPP_NODEBUG = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>; | 220 | using __policy_iter_diff_t _LIBCPP_NODEBUG = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>; |
| 221 | 221 | ||
| 222 | template <class _AlgPolicy, class _Iter> | ||
| 223 | using __policy_value_type _LIBCPP_NODEBUG = typename _IterOps<_AlgPolicy>::template __value_type<_Iter>; | ||
| 224 | |||
| 222 | _LIBCPP_END_NAMESPACE_STD | 225 | _LIBCPP_END_NAMESPACE_STD |
| 223 | 226 | ||
| 224 | _LIBCPP_POP_MACROS | 227 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__algorithm/lexicographical_compare.h+2-2| ... | @@ -66,8 +66,8 @@ template <class _Tp, | ... | @@ -66,8 +66,8 @@ template <class _Tp, |
| 66 | class _Proj2, | 66 | class _Proj2, |
| 67 | class _Comp, | 67 | class _Comp, |
| 68 | __enable_if_t<__desugars_to_v<__totally_ordered_less_tag, _Comp, _Tp, _Tp> && !is_volatile<_Tp>::value && | 68 | __enable_if_t<__desugars_to_v<__totally_ordered_less_tag, _Comp, _Tp, _Tp> && !is_volatile<_Tp>::value && |
| 69 | __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value && | 69 | __is_trivially_equality_comparable_v<_Tp, _Tp> && __is_identity<_Proj1>::value && |
| 70 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value, | 70 | __is_identity<_Proj2>::value, |
| 71 | int> = 0> | 71 | int> = 0> |
| 72 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 72 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 73 | __lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Comp&, _Proj1&, _Proj2&) { | 73 | __lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Comp&, _Proj1&, _Proj2&) { |
lib/libcxx/include/__algorithm/lexicographical_compare_three_way.h+6-6| ... | @@ -37,13 +37,13 @@ template <class _InputIterator1, class _InputIterator2, class _Cmp> | ... | @@ -37,13 +37,13 @@ template <class _InputIterator1, class _InputIterator2, class _Cmp> |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr auto __lexicographical_compare_three_way_fast_path( | 37 | _LIBCPP_HIDE_FROM_ABI constexpr auto __lexicographical_compare_three_way_fast_path( |
| 38 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Cmp& __comp) | 38 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Cmp& __comp) |
| 39 | -> decltype(__comp(*__first1, *__first2)) { | 39 | -> decltype(__comp(*__first1, *__first2)) { |
| 40 | static_assert( | 40 | static_assert(signed_integral<__iterator_difference_type<_InputIterator1>>, |
| 41 | signed_integral<__iter_diff_t<_InputIterator1>>, "Using a non-integral difference_type is undefined behavior."); | 41 | "Using a non-integral difference_type is undefined behavior."); |
| 42 | static_assert( | 42 | static_assert(signed_integral<__iterator_difference_type<_InputIterator2>>, |
| 43 | signed_integral<__iter_diff_t<_InputIterator2>>, "Using a non-integral difference_type is undefined behavior."); | 43 | "Using a non-integral difference_type is undefined behavior."); |
| 44 | 44 | ||
| 45 | using _Len1 = __iter_diff_t<_InputIterator1>; | 45 | using _Len1 = __iterator_difference_type<_InputIterator1>; |
| 46 | using _Len2 = __iter_diff_t<_InputIterator2>; | 46 | using _Len2 = __iterator_difference_type<_InputIterator2>; |
| 47 | using _Common = common_type_t<_Len1, _Len2>; | 47 | using _Common = common_type_t<_Len1, _Len2>; |
| 48 | 48 | ||
| 49 | _Len1 __len1 = __last1 - __first1; | 49 | _Len1 __len1 = __last1 - __first1; |
lib/libcxx/include/__algorithm/make_heap.h+16-4| ... | @@ -12,9 +12,11 @@ | ... | @@ -12,9 +12,11 @@ |
| 12 | #include <__algorithm/comp.h> | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/push_heap.h> | ||
| 15 | #include <__algorithm/sift_down.h> | 16 | #include <__algorithm/sift_down.h> |
| 16 | #include <__config> | 17 | #include <__config> |
| 17 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__type_traits/is_arithmetic.h> | ||
| 18 | #include <__utility/move.h> | 20 | #include <__utility/move.h> |
| 19 | 21 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -31,13 +33,23 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | ... | @@ -31,13 +33,23 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 31 | __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) { | 33 | __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) { |
| 32 | __comp_ref_type<_Compare> __comp_ref = __comp; | 34 | __comp_ref_type<_Compare> __comp_ref = __comp; |
| 33 | 35 | ||
| 34 | using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type; | 36 | using __diff_t = __iterator_difference_type<_RandomAccessIterator>; |
| 35 | difference_type __n = __last - __first; | 37 | const __diff_t __n = __last - __first; |
| 38 | |||
| 39 | const bool __assume_both_children = is_arithmetic<__iterator_value_type<_RandomAccessIterator> >::value; | ||
| 40 | |||
| 41 | // While it would be correct to always assume we have both children, in practice we observed this to be a performance | ||
| 42 | // improvement only for arithmetic types. | ||
| 43 | const __diff_t __sift_down_n = __assume_both_children ? ((__n & 1) ? __n : __n - 1) : __n; | ||
| 44 | |||
| 36 | if (__n > 1) { | 45 | if (__n > 1) { |
| 37 | // start from the first parent, there is no need to consider children | 46 | // start from the first parent, there is no need to consider children |
| 38 | for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) { | 47 | |
| 39 | std::__sift_down<_AlgPolicy>(__first, __comp_ref, __n, __first + __start); | 48 | for (__diff_t __start = (__sift_down_n - 2) / 2; __start >= 0; --__start) { |
| 49 | std::__sift_down<_AlgPolicy, __assume_both_children>(__first, __comp_ref, __sift_down_n, __start); | ||
| 40 | } | 50 | } |
| 51 | if _LIBCPP_CONSTEXPR (__assume_both_children) | ||
| 52 | std::__sift_up<_AlgPolicy>(__first, __last, __comp, __n); | ||
| 41 | } | 53 | } |
| 42 | } | 54 | } |
| 43 | 55 |
lib/libcxx/include/__algorithm/mismatch.h+2-2| ... | @@ -60,7 +60,7 @@ __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Pro | ... | @@ -60,7 +60,7 @@ __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Pro |
| 60 | template <class _Iter> | 60 | template <class _Iter> |
| 61 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> | 61 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> |
| 62 | __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { | 62 | __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { |
| 63 | using __value_type = __iter_value_type<_Iter>; | 63 | using __value_type = __iterator_value_type<_Iter>; |
| 64 | constexpr size_t __unroll_count = 4; | 64 | constexpr size_t __unroll_count = 4; |
| 65 | constexpr size_t __vec_size = __native_vector_size<__value_type>; | 65 | constexpr size_t __vec_size = __native_vector_size<__value_type>; |
| 66 | using __vec = __simd_vector<__value_type, __vec_size>; | 66 | using __vec = __simd_vector<__value_type, __vec_size>; |
| ... | @@ -136,7 +136,7 @@ template <class _Tp, | ... | @@ -136,7 +136,7 @@ template <class _Tp, |
| 136 | class _Proj2, | 136 | class _Proj2, |
| 137 | __enable_if_t<!is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> && | 137 | __enable_if_t<!is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> && |
| 138 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value && | 138 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value && |
| 139 | __can_map_to_integer_v<_Tp> && __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value, | 139 | __can_map_to_integer_v<_Tp> && __is_trivially_equality_comparable_v<_Tp, _Tp>, |
| 140 | int> = 0> | 140 | int> = 0> |
| 141 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | 141 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> |
| 142 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | 142 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
lib/libcxx/include/__algorithm/move.h+8-19| ... | @@ -50,37 +50,26 @@ struct __move_impl { | ... | @@ -50,37 +50,26 @@ struct __move_impl { |
| 50 | return std::make_pair(std::move(__first), std::move(__result)); | 50 | return std::make_pair(std::move(__first), std::move(__result)); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | template <class _InIter, class _OutIter> | 53 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0> |
| 54 | struct _MoveSegment { | ||
| 55 | using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>; | ||
| 56 | |||
| 57 | _OutIter& __result_; | ||
| 58 | |||
| 59 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit _MoveSegment(_OutIter& __result) | ||
| 60 | : __result_(__result) {} | ||
| 61 | |||
| 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | ||
| 63 | operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) { | ||
| 64 | __result_ = std::__move<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second; | ||
| 65 | } | ||
| 66 | }; | ||
| 67 | |||
| 68 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> | ||
| 69 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 54 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 70 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 55 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| 71 | std::__for_each_segment(__first, __last, _MoveSegment<_InIter, _OutIter>(__result)); | 56 | using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator; |
| 57 | std::__for_each_segment(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) { | ||
| 58 | __result = std::__move<_AlgPolicy>(__lfirst, __llast, std::move(__result)).second; | ||
| 59 | }); | ||
| 72 | return std::make_pair(__last, std::move(__result)); | 60 | return std::make_pair(__last, std::move(__result)); |
| 73 | } | 61 | } |
| 74 | 62 | ||
| 75 | template <class _InIter, | 63 | template <class _InIter, |
| 76 | class _OutIter, | 64 | class _OutIter, |
| 77 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && | 65 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && |
| 78 | !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value, | 66 | !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, |
| 79 | int> = 0> | 67 | int> = 0> |
| 80 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 68 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 81 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 69 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| 82 | using _Traits = __segmented_iterator_traits<_OutIter>; | 70 | using _Traits = __segmented_iterator_traits<_OutIter>; |
| 83 | using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type; | 71 | using _DiffT = |
| 72 | typename common_type<__iterator_difference_type<_InIter>, __iterator_difference_type<_OutIter> >::type; | ||
| 84 | 73 | ||
| 85 | if (__first == __last) | 74 | if (__first == __last) |
| 86 | return std::make_pair(std::move(__first), std::move(__result)); | 75 | return std::make_pair(std::move(__first), std::move(__result)); |
lib/libcxx/include/__algorithm/move_backward.h+9-24| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy_backward.h> | 12 | #include <__algorithm/copy_backward.h> |
| 13 | #include <__algorithm/copy_move_common.h> | 13 | #include <__algorithm/copy_move_common.h> |
| 14 | #include <__algorithm/for_each_segment.h> | ||
| 14 | #include <__algorithm/iterator_operations.h> | 15 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/min.h> | 16 | #include <__algorithm/min.h> |
| 16 | #include <__config> | 17 | #include <__config> |
| ... | @@ -51,42 +52,26 @@ struct __move_backward_impl { | ... | @@ -51,42 +52,26 @@ struct __move_backward_impl { |
| 51 | return std::make_pair(std::move(__original_last_iter), std::move(__result)); | 52 | return std::make_pair(std::move(__original_last_iter), std::move(__result)); |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> | 55 | template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0> |
| 55 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 56 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 56 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 57 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| 57 | using _Traits = __segmented_iterator_traits<_InIter>; | 58 | using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator; |
| 58 | auto __sfirst = _Traits::__segment(__first); | 59 | std::__for_each_segment_backward(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) { |
| 59 | auto __slast = _Traits::__segment(__last); | 60 | __result = std::__move_backward<_AlgPolicy>(std::move(__lfirst), std::move(__llast), std::move(__result)).second; |
| 60 | if (__sfirst == __slast) { | 61 | }); |
| 61 | auto __iters = | ||
| 62 | std::__move_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result)); | ||
| 63 | return std::make_pair(__last, __iters.second); | ||
| 64 | } | ||
| 65 | |||
| 66 | __result = | ||
| 67 | std::__move_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result)) | ||
| 68 | .second; | ||
| 69 | --__slast; | ||
| 70 | while (__sfirst != __slast) { | ||
| 71 | __result = | ||
| 72 | std::__move_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result)) | ||
| 73 | .second; | ||
| 74 | --__slast; | ||
| 75 | } | ||
| 76 | __result = std::__move_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result)) | ||
| 77 | .second; | ||
| 78 | return std::make_pair(__last, std::move(__result)); | 62 | return std::make_pair(__last, std::move(__result)); |
| 79 | } | 63 | } |
| 80 | 64 | ||
| 81 | template <class _InIter, | 65 | template <class _InIter, |
| 82 | class _OutIter, | 66 | class _OutIter, |
| 83 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && | 67 | __enable_if_t<__has_random_access_iterator_category<_InIter>::value && |
| 84 | !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value, | 68 | !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>, |
| 85 | int> = 0> | 69 | int> = 0> |
| 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 70 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| 87 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { | 71 | operator()(_InIter __first, _InIter __last, _OutIter __result) const { |
| 88 | using _Traits = __segmented_iterator_traits<_OutIter>; | 72 | using _Traits = __segmented_iterator_traits<_OutIter>; |
| 89 | using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type; | 73 | using _DiffT = |
| 74 | typename common_type<__iterator_difference_type<_InIter>, __iterator_difference_type<_OutIter> >::type; | ||
| 90 | 75 | ||
| 91 | // When the range contains no elements, __result might not be a valid iterator | 76 | // When the range contains no elements, __result might not be a valid iterator |
| 92 | if (__first == __last) | 77 | if (__first == __last) |
lib/libcxx/include/__algorithm/none_of.h+4-4| ... | @@ -10,7 +10,9 @@ | ... | @@ -10,7 +10,9 @@ |
| 10 | #ifndef _LIBCPP___ALGORITHM_NONE_OF_H | 10 | #ifndef _LIBCPP___ALGORITHM_NONE_OF_H |
| 11 | #define _LIBCPP___ALGORITHM_NONE_OF_H | 11 | #define _LIBCPP___ALGORITHM_NONE_OF_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/any_of.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | ||
| 14 | 16 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 18 | # pragma GCC system_header |
| ... | @@ -21,10 +23,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,10 +23,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | template <class _InputIterator, class _Predicate> | 23 | template <class _InputIterator, class _Predicate> |
| 22 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 24 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 23 | none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | 25 | none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | for (; __first != __last; ++__first) | 26 | __identity __proj; |
| 25 | if (__pred(*__first)) | 27 | return !std::__any_of(__first, __last, __pred, __proj); |
| 26 | return false; | ||
| 27 | return true; | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/partial_sort.h+1-1| ... | @@ -45,7 +45,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator __part | ... | @@ -45,7 +45,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator __part |
| 45 | for (; __i != __last; ++__i) { | 45 | for (; __i != __last; ++__i) { |
| 46 | if (__comp(*__i, *__first)) { | 46 | if (__comp(*__i, *__first)) { |
| 47 | _IterOps<_AlgPolicy>::iter_swap(__i, __first); | 47 | _IterOps<_AlgPolicy>::iter_swap(__i, __first); |
| 48 | std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first); | 48 | std::__sift_down<_AlgPolicy, false>(__first, __comp, __len, 0); |
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp); | 51 | std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp); |
lib/libcxx/include/__algorithm/partial_sort_copy.h+1-1| ... | @@ -60,7 +60,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator, _Random | ... | @@ -60,7 +60,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator, _Random |
| 60 | for (; __first != __last; ++__first) | 60 | for (; __first != __last; ++__first) |
| 61 | if (std::__invoke(__comp, std::__invoke(__proj1, *__first), std::__invoke(__proj2, *__result_first))) { | 61 | if (std::__invoke(__comp, std::__invoke(__proj1, *__first), std::__invoke(__proj2, *__result_first))) { |
| 62 | *__result_first = *__first; | 62 | *__result_first = *__first; |
| 63 | std::__sift_down<_AlgPolicy>(__result_first, __projected_comp, __len, __result_first); | 63 | std::__sift_down<_AlgPolicy, false>(__result_first, __projected_comp, __len, 0); |
| 64 | } | 64 | } |
| 65 | std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp); | 65 | std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp); |
| 66 | } | 66 | } |
lib/libcxx/include/__algorithm/pstl.h+9-9| ... | @@ -115,7 +115,7 @@ template <class _ExecutionPolicy, | ... | @@ -115,7 +115,7 @@ template <class _ExecutionPolicy, |
| 115 | class _Predicate, | 115 | class _Predicate, |
| 116 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 116 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 117 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 117 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 118 | _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> | 118 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __iterator_difference_type<_ForwardIterator> |
| 119 | count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | 119 | count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { |
| 120 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | 120 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( |
| 121 | _ForwardIterator, "count_if(first, last, pred) requires [first, last) to be ForwardIterators"); | 121 | _ForwardIterator, "count_if(first, last, pred) requires [first, last) to be ForwardIterators"); |
| ... | @@ -129,7 +129,7 @@ template <class _ExecutionPolicy, | ... | @@ -129,7 +129,7 @@ template <class _ExecutionPolicy, |
| 129 | class _Tp, | 129 | class _Tp, |
| 130 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 130 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 131 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 131 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 132 | _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> | 132 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __iterator_difference_type<_ForwardIterator> |
| 133 | count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 133 | count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 134 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( | 134 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR( |
| 135 | _ForwardIterator, "count(first, last, val) requires [first, last) to be ForwardIterators"); | 135 | _ForwardIterator, "count(first, last, val) requires [first, last) to be ForwardIterators"); |
| ... | @@ -144,7 +144,7 @@ template <class _ExecutionPolicy, | ... | @@ -144,7 +144,7 @@ template <class _ExecutionPolicy, |
| 144 | class _Pred, | 144 | class _Pred, |
| 145 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 145 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 146 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 146 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 147 | _LIBCPP_HIDE_FROM_ABI bool | 147 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool |
| 148 | equal(_ExecutionPolicy&& __policy, | 148 | equal(_ExecutionPolicy&& __policy, |
| 149 | _ForwardIterator1 __first1, | 149 | _ForwardIterator1 __first1, |
| 150 | _ForwardIterator1 __last1, | 150 | _ForwardIterator1 __last1, |
| ... | @@ -166,7 +166,7 @@ template <class _ExecutionPolicy, | ... | @@ -166,7 +166,7 @@ template <class _ExecutionPolicy, |
| 166 | class _ForwardIterator2, | 166 | class _ForwardIterator2, |
| 167 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 167 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 168 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 168 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 169 | _LIBCPP_HIDE_FROM_ABI bool | 169 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool |
| 170 | equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { | 170 | equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { |
| 171 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators"); | 171 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators"); |
| 172 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators"); | 172 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators"); |
| ... | @@ -185,7 +185,7 @@ template <class _ExecutionPolicy, | ... | @@ -185,7 +185,7 @@ template <class _ExecutionPolicy, |
| 185 | class _Pred, | 185 | class _Pred, |
| 186 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 186 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 187 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 187 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 188 | _LIBCPP_HIDE_FROM_ABI bool | 188 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool |
| 189 | equal(_ExecutionPolicy&& __policy, | 189 | equal(_ExecutionPolicy&& __policy, |
| 190 | _ForwardIterator1 __first1, | 190 | _ForwardIterator1 __first1, |
| 191 | _ForwardIterator1 __last1, | 191 | _ForwardIterator1 __last1, |
| ... | @@ -209,7 +209,7 @@ template <class _ExecutionPolicy, | ... | @@ -209,7 +209,7 @@ template <class _ExecutionPolicy, |
| 209 | class _ForwardIterator2, | 209 | class _ForwardIterator2, |
| 210 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 210 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 211 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 211 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 212 | _LIBCPP_HIDE_FROM_ABI bool | 212 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool |
| 213 | equal(_ExecutionPolicy&& __policy, | 213 | equal(_ExecutionPolicy&& __policy, |
| 214 | _ForwardIterator1 __first1, | 214 | _ForwardIterator1 __first1, |
| 215 | _ForwardIterator1 __last1, | 215 | _ForwardIterator1 __last1, |
| ... | @@ -259,7 +259,7 @@ template <class _ExecutionPolicy, | ... | @@ -259,7 +259,7 @@ template <class _ExecutionPolicy, |
| 259 | class _Predicate, | 259 | class _Predicate, |
| 260 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 260 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 261 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 261 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 262 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 262 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 263 | find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | 263 | find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { |
| 264 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if requires ForwardIterators"); | 264 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if requires ForwardIterators"); |
| 265 | using _Implementation = __pstl::__dispatch<__pstl::__find_if, __pstl::__current_configuration, _RawPolicy>; | 265 | using _Implementation = __pstl::__dispatch<__pstl::__find_if, __pstl::__current_configuration, _RawPolicy>; |
| ... | @@ -272,7 +272,7 @@ template <class _ExecutionPolicy, | ... | @@ -272,7 +272,7 @@ template <class _ExecutionPolicy, |
| 272 | class _Predicate, | 272 | class _Predicate, |
| 273 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 273 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 274 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 274 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 275 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 275 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 276 | find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | 276 | find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { |
| 277 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if_not requires ForwardIterators"); | 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>; | 278 | using _Implementation = __pstl::__dispatch<__pstl::__find_if_not, __pstl::__current_configuration, _RawPolicy>; |
| ... | @@ -285,7 +285,7 @@ template <class _ExecutionPolicy, | ... | @@ -285,7 +285,7 @@ template <class _ExecutionPolicy, |
| 285 | class _Tp, | 285 | class _Tp, |
| 286 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 286 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 287 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 287 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 288 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 288 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 289 | find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | 289 | find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 290 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find requires ForwardIterators"); | 290 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find requires ForwardIterators"); |
| 291 | using _Implementation = __pstl::__dispatch<__pstl::__find, __pstl::__current_configuration, _RawPolicy>; | 291 | using _Implementation = __pstl::__dispatch<__pstl::__find, __pstl::__current_configuration, _RawPolicy>; |
lib/libcxx/include/__algorithm/radix_sort.h+27-25| ... | @@ -72,14 +72,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -72,14 +72,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 72 | #if _LIBCPP_STD_VER >= 14 | 72 | #if _LIBCPP_STD_VER >= 14 |
| 73 | 73 | ||
| 74 | template <class _InputIterator, class _OutputIterator> | 74 | template <class _InputIterator, class _OutputIterator> |
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr pair<_OutputIterator, __iter_value_type<_InputIterator>> | 75 | _LIBCPP_HIDE_FROM_ABI constexpr pair<_OutputIterator, __iterator_value_type<_InputIterator>> |
| 76 | __partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | 76 | __partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { |
| 77 | if (__first == __last) | 77 | if (__first == __last) |
| 78 | return {__result, 0}; | 78 | return {__result, 0}; |
| 79 | 79 | ||
| 80 | auto __max = *__first; | 80 | auto __max = *__first; |
| 81 | __iter_value_type<_InputIterator> __sum = *__first; | 81 | __iterator_value_type<_InputIterator> __sum = *__first; |
| 82 | *__result = __sum; | 82 | *__result = __sum; |
| 83 | 83 | ||
| 84 | while (++__first != __last) { | 84 | while (++__first != __last) { |
| 85 | if (__max < *__first) { | 85 | if (__max < *__first) { |
| ... | @@ -124,7 +124,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __nth_radix(size_t __radix_number, _Radix _ | ... | @@ -124,7 +124,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __nth_radix(size_t __radix_number, _Radix _ |
| 124 | template <class _ForwardIterator, class _Map, class _RandomAccessIterator> | 124 | template <class _ForwardIterator, class _Map, class _RandomAccessIterator> |
| 125 | _LIBCPP_HIDE_FROM_ABI constexpr void | 125 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 126 | __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) { | 126 | __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) { |
| 127 | using __value_type = __iter_value_type<_ForwardIterator>; | 127 | using __value_type = __iterator_value_type<_ForwardIterator>; |
| 128 | using __traits = __counting_sort_traits<__value_type, _Map>; | 128 | using __traits = __counting_sort_traits<__value_type, _Map>; |
| 129 | 129 | ||
| 130 | std::for_each(__first, __last, [&__counters, &__map](const auto& __preimage) { ++__counters[__map(__preimage)]; }); | 130 | std::for_each(__first, __last, [&__counters, &__map](const auto& __preimage) { ++__counters[__map(__preimage)]; }); |
| ... | @@ -160,7 +160,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __collect_impl( | ... | @@ -160,7 +160,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __collect_impl( |
| 160 | _RandomAccessIterator1 __counters, | 160 | _RandomAccessIterator1 __counters, |
| 161 | _RandomAccessIterator2 __maximums, | 161 | _RandomAccessIterator2 __maximums, |
| 162 | index_sequence<_Radices...>) { | 162 | index_sequence<_Radices...>) { |
| 163 | using __value_type = __iter_value_type<_ForwardIterator>; | 163 | using __value_type = __iterator_value_type<_ForwardIterator>; |
| 164 | constexpr auto __radix_value_range = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_value_range; | 164 | constexpr auto __radix_value_range = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_value_range; |
| 165 | 165 | ||
| 166 | auto __previous = numeric_limits<__invoke_result_t<_Map, __value_type>>::min(); | 166 | auto __previous = numeric_limits<__invoke_result_t<_Map, __value_type>>::min(); |
| ... | @@ -189,7 +189,7 @@ __collect(_ForwardIterator __first, | ... | @@ -189,7 +189,7 @@ __collect(_ForwardIterator __first, |
| 189 | _Radix __radix, | 189 | _Radix __radix, |
| 190 | _RandomAccessIterator1 __counters, | 190 | _RandomAccessIterator1 __counters, |
| 191 | _RandomAccessIterator2 __maximums) { | 191 | _RandomAccessIterator2 __maximums) { |
| 192 | using __value_type = __iter_value_type<_ForwardIterator>; | 192 | using __value_type = __iterator_value_type<_ForwardIterator>; |
| 193 | constexpr auto __radix_count = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_count; | 193 | constexpr auto __radix_count = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_count; |
| 194 | return std::__collect_impl( | 194 | return std::__collect_impl( |
| 195 | __first, __last, __map, __radix, __counters, __maximums, make_index_sequence<__radix_count>()); | 195 | __first, __last, __map, __radix, __counters, __maximums, make_index_sequence<__radix_count>()); |
| ... | @@ -213,10 +213,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __dispose_backward( | ... | @@ -213,10 +213,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __dispose_backward( |
| 213 | template <class _ForwardIterator, class _RandomAccessIterator, class _Map> | 213 | template <class _ForwardIterator, class _RandomAccessIterator, class _Map> |
| 214 | _LIBCPP_HIDE_FROM_ABI constexpr _RandomAccessIterator | 214 | _LIBCPP_HIDE_FROM_ABI constexpr _RandomAccessIterator |
| 215 | __counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) { | 215 | __counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) { |
| 216 | using __value_type = __iter_value_type<_ForwardIterator>; | 216 | using __value_type = __iterator_value_type<_ForwardIterator>; |
| 217 | using __traits = __counting_sort_traits<__value_type, _Map>; | 217 | using __traits = __counting_sort_traits<__value_type, _Map>; |
| 218 | 218 | ||
| 219 | __iter_diff_t<_RandomAccessIterator> __counters[__traits::__value_range + 1] = {0}; | 219 | __iterator_difference_type<_RandomAccessIterator> __counters[__traits::__value_range + 1] = {0}; |
| 220 | 220 | ||
| 221 | std::__collect(__first, __last, __map, std::next(std::begin(__counters))); | 221 | std::__collect(__first, __last, __map, std::next(std::begin(__counters))); |
| 222 | std::__dispose(__first, __last, __result, __map, std::begin(__counters)); | 222 | std::__dispose(__first, __last, __result, __map, std::begin(__counters)); |
| ... | @@ -224,12 +224,13 @@ __counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomA | ... | @@ -224,12 +224,13 @@ __counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomA |
| 224 | return __result + __counters[__traits::__value_range]; | 224 | return __result + __counters[__traits::__value_range]; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | template <class _RandomAccessIterator1, | 227 | template < |
| 228 | class _RandomAccessIterator2, | 228 | class _RandomAccessIterator1, |
| 229 | class _Map, | 229 | class _RandomAccessIterator2, |
| 230 | class _Radix, | 230 | class _Map, |
| 231 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1, | 231 | class _Radix, |
| 232 | int> = 0> | 232 | enable_if_t<__radix_sort_traits<__iterator_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1, |
| 233 | int> = 0> | ||
| 233 | _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( | 234 | _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( |
| 234 | _RandomAccessIterator1 __first, | 235 | _RandomAccessIterator1 __first, |
| 235 | _RandomAccessIterator1 __last, | 236 | _RandomAccessIterator1 __last, |
| ... | @@ -243,24 +244,25 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( | ... | @@ -243,24 +244,25 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( |
| 243 | std::move(__buffer, __buffer_end, __first); | 244 | std::move(__buffer, __buffer_end, __first); |
| 244 | } | 245 | } |
| 245 | 246 | ||
| 246 | template < | 247 | template <class _RandomAccessIterator1, |
| 247 | class _RandomAccessIterator1, | 248 | class _RandomAccessIterator2, |
| 248 | class _RandomAccessIterator2, | 249 | class _Map, |
| 249 | class _Map, | 250 | class _Radix, |
| 250 | class _Radix, | 251 | enable_if_t< |
| 251 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0, | 252 | __radix_sort_traits<__iterator_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0, |
| 252 | int> = 0 > | 253 | int> = 0> |
| 253 | _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( | 254 | _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( |
| 254 | _RandomAccessIterator1 __first, | 255 | _RandomAccessIterator1 __first, |
| 255 | _RandomAccessIterator1 __last, | 256 | _RandomAccessIterator1 __last, |
| 256 | _RandomAccessIterator2 __buffer_begin, | 257 | _RandomAccessIterator2 __buffer_begin, |
| 257 | _Map __map, | 258 | _Map __map, |
| 258 | _Radix __radix) { | 259 | _Radix __radix) { |
| 259 | using __value_type = __iter_value_type<_RandomAccessIterator1>; | 260 | using __value_type = __iterator_value_type<_RandomAccessIterator1>; |
| 260 | using __traits = __radix_sort_traits<__value_type, _Map, _Radix>; | 261 | using __traits = __radix_sort_traits<__value_type, _Map, _Radix>; |
| 261 | 262 | ||
| 262 | __iter_diff_t<_RandomAccessIterator1> __counters[__traits::__radix_count][__traits::__radix_value_range] = {{0}}; | 263 | __iterator_difference_type<_RandomAccessIterator1> |
| 263 | __iter_diff_t<_RandomAccessIterator1> __maximums[__traits::__radix_count] = {0}; | 264 | __counters[__traits::__radix_count][__traits::__radix_value_range] = {{0}}; |
| 265 | __iterator_difference_type<_RandomAccessIterator1> __maximums[__traits::__radix_count] = {0}; | ||
| 264 | const auto __is_sorted = std::__collect(__first, __last, __map, __radix, __counters, __maximums); | 266 | const auto __is_sorted = std::__collect(__first, __last, __map, __radix, __counters, __maximums); |
| 265 | if (!__is_sorted) { | 267 | if (!__is_sorted) { |
| 266 | const auto __range_size = std::distance(__first, __last); | 268 | const auto __range_size = std::distance(__first, __last); |
lib/libcxx/include/__algorithm/ranges_copy_n.h+3-26| ... | @@ -9,16 +9,12 @@ | ... | @@ -9,16 +9,12 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COPY_N_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COPY_N_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_N_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_N_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy.h> | 12 | #include <__algorithm/copy_n.h> |
| 13 | #include <__algorithm/in_out_result.h> | 13 | #include <__algorithm/in_out_result.h> |
| 14 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/ranges_copy.h> | ||
| 16 | #include <__config> | 15 | #include <__config> |
| 17 | #include <__functional/identity.h> | ||
| 18 | #include <__iterator/concepts.h> | 16 | #include <__iterator/concepts.h> |
| 19 | #include <__iterator/incrementable_traits.h> | 17 | #include <__iterator/incrementable_traits.h> |
| 20 | #include <__iterator/unreachable_sentinel.h> | ||
| 21 | #include <__iterator/wrap_iter.h> | ||
| 22 | #include <__utility/move.h> | 18 | #include <__utility/move.h> |
| 23 | 19 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -37,32 +33,13 @@ namespace ranges { | ... | @@ -37,32 +33,13 @@ namespace ranges { |
| 37 | template <class _Ip, class _Op> | 33 | template <class _Ip, class _Op> |
| 38 | using copy_n_result = in_out_result<_Ip, _Op>; | 34 | using copy_n_result = in_out_result<_Ip, _Op>; |
| 39 | 35 | ||
| 40 | // TODO: Merge this with copy_n | ||
| 41 | struct __copy_n { | 36 | struct __copy_n { |
| 42 | template <class _InIter, class _DiffType, class _OutIter> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter> | ||
| 44 | __go(_InIter __first, _DiffType __n, _OutIter __result) { | ||
| 45 | while (__n != 0) { | ||
| 46 | *__result = *__first; | ||
| 47 | ++__first; | ||
| 48 | ++__result; | ||
| 49 | --__n; | ||
| 50 | } | ||
| 51 | return {std::move(__first), std::move(__result)}; | ||
| 52 | } | ||
| 53 | |||
| 54 | template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter> | ||
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter> | ||
| 56 | __go(_InIter __first, _DiffType __n, _OutIter __result) { | ||
| 57 | auto __ret = std::__copy(__first, __first + __n, __result); | ||
| 58 | return {__ret.first, __ret.second}; | ||
| 59 | } | ||
| 60 | |||
| 61 | template <input_iterator _Ip, weakly_incrementable _Op> | 37 | template <input_iterator _Ip, weakly_incrementable _Op> |
| 62 | requires indirectly_copyable<_Ip, _Op> | 38 | requires indirectly_copyable<_Ip, _Op> |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr copy_n_result<_Ip, _Op> | 39 | _LIBCPP_HIDE_FROM_ABI constexpr copy_n_result<_Ip, _Op> |
| 64 | operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const { | 40 | operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const { |
| 65 | return __go(std::move(__first), __n, std::move(__result)); | 41 | auto __res = std::__copy_n<_RangeAlgPolicy>(std::move(__first), __n, std::move(__result)); |
| 42 | return {std::move(__res.first), std::move(__res.second)}; | ||
| 66 | } | 43 | } |
| 67 | }; | 44 | }; |
| 68 | 45 |
lib/libcxx/include/__algorithm/ranges_equal.h+17-26| ... | @@ -13,13 +13,12 @@ | ... | @@ -13,13 +13,12 @@ |
| 13 | #include <__algorithm/unwrap_range.h> | 13 | #include <__algorithm/unwrap_range.h> |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | 15 | #include <__functional/identity.h> |
| 16 | #include <__functional/invoke.h> | ||
| 17 | #include <__functional/ranges_operations.h> | 16 | #include <__functional/ranges_operations.h> |
| 18 | #include <__iterator/concepts.h> | 17 | #include <__iterator/concepts.h> |
| 19 | #include <__iterator/distance.h> | ||
| 20 | #include <__iterator/indirectly_comparable.h> | 18 | #include <__iterator/indirectly_comparable.h> |
| 21 | #include <__ranges/access.h> | 19 | #include <__ranges/access.h> |
| 22 | #include <__ranges/concepts.h> | 20 | #include <__ranges/concepts.h> |
| 21 | #include <__ranges/size.h> | ||
| 23 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| 24 | 23 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -51,20 +50,17 @@ struct __equal { | ... | @@ -51,20 +50,17 @@ struct __equal { |
| 51 | _Pred __pred = {}, | 50 | _Pred __pred = {}, |
| 52 | _Proj1 __proj1 = {}, | 51 | _Proj1 __proj1 = {}, |
| 53 | _Proj2 __proj2 = {}) const { | 52 | _Proj2 __proj2 = {}) const { |
| 54 | if constexpr (sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>) { | 53 | static constexpr bool __both_sized = sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>; |
| 54 | if constexpr (__both_sized) { | ||
| 55 | if (__last1 - __first1 != __last2 - __first2) | 55 | if (__last1 - __first1 != __last2 - __first2) |
| 56 | return false; | 56 | return false; |
| 57 | } | 57 | } |
| 58 | auto __unwrapped1 = std::__unwrap_range(std::move(__first1), std::move(__last1)); | 58 | |
| 59 | auto __unwrapped2 = std::__unwrap_range(std::move(__first2), std::move(__last2)); | 59 | auto [__ufirst1, __ulast1] = std::__unwrap_range(std::move(__first1), std::move(__last1)); |
| 60 | return std::__equal_impl( | 60 | auto [__ufirst2, __ulast2] = std::__unwrap_range(std::move(__first2), std::move(__last2)); |
| 61 | std::move(__unwrapped1.first), | 61 | |
| 62 | std::move(__unwrapped1.second), | 62 | return std::__equal_impl<__both_sized>( |
| 63 | std::move(__unwrapped2.first), | 63 | std::move(__ufirst1), std::move(__ulast1), std::move(__ufirst2), std::move(__ulast2), __pred, __proj1, __proj2); |
| 64 | std::move(__unwrapped2.second), | ||
| 65 | __pred, | ||
| 66 | __proj1, | ||
| 67 | __proj2); | ||
| 68 | } | 64 | } |
| 69 | 65 | ||
| 70 | template <input_range _Range1, | 66 | template <input_range _Range1, |
| ... | @@ -75,21 +71,16 @@ struct __equal { | ... | @@ -75,21 +71,16 @@ struct __equal { |
| 75 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | 71 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 76 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | 72 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 77 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | 73 | _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 78 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { | 74 | static constexpr bool __both_sized = sized_range<_Range1> && sized_range<_Range2>; |
| 79 | if (ranges::distance(__range1) != ranges::distance(__range2)) | 75 | if constexpr (__both_sized) { |
| 76 | if (ranges::size(__range1) != ranges::size(__range2)) | ||
| 80 | return false; | 77 | return false; |
| 81 | } | 78 | } |
| 82 | auto __unwrapped1 = std::__unwrap_range(ranges::begin(__range1), ranges::end(__range1)); | 79 | |
| 83 | auto __unwrapped2 = std::__unwrap_range(ranges::begin(__range2), ranges::end(__range2)); | 80 | auto [__ufirst1, __ulast1] = std::__unwrap_range(ranges::begin(__range1), ranges::end(__range1)); |
| 84 | return std::__equal_impl( | 81 | auto [__ufirst2, __ulast2] = std::__unwrap_range(ranges::begin(__range2), ranges::end(__range2)); |
| 85 | std::move(__unwrapped1.first), | 82 | return std::__equal_impl<__both_sized>( |
| 86 | std::move(__unwrapped1.second), | 83 | std::move(__ufirst1), std::move(__ulast1), std::move(__ufirst2), std::move(__ulast2), __pred, __proj1, __proj2); |
| 87 | std::move(__unwrapped2.first), | ||
| 88 | std::move(__unwrapped2.second), | ||
| 89 | __pred, | ||
| 90 | __proj1, | ||
| 91 | __proj2); | ||
| 92 | return false; | ||
| 93 | } | 84 | } |
| 94 | }; | 85 | }; |
| 95 | 86 |
lib/libcxx/include/__algorithm/ranges_fill.h+7-6| ... | @@ -9,12 +9,14 @@ | ... | @@ -9,12 +9,14 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FILL_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FILL_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FILL_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_FILL_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/ranges_fill_n.h> | 12 | #include <__algorithm/fill.h> |
| 13 | #include <__algorithm/fill_n.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__iterator/concepts.h> | 15 | #include <__iterator/concepts.h> |
| 15 | #include <__ranges/access.h> | 16 | #include <__ranges/access.h> |
| 16 | #include <__ranges/concepts.h> | 17 | #include <__ranges/concepts.h> |
| 17 | #include <__ranges/dangling.h> | 18 | #include <__ranges/dangling.h> |
| 19 | #include <__utility/move.h> | ||
| 18 | 20 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -31,12 +33,11 @@ namespace ranges { | ... | @@ -31,12 +33,11 @@ namespace ranges { |
| 31 | struct __fill { | 33 | struct __fill { |
| 32 | template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent> | 34 | template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent> |
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const { | 35 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const { |
| 34 | if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) { | 36 | if constexpr (sized_sentinel_for<_Sent, _Iter>) { |
| 35 | return ranges::fill_n(__first, __last - __first, __value); | 37 | auto __n = __last - __first; |
| 38 | return std::__fill_n(std::move(__first), __n, __value); | ||
| 36 | } else { | 39 | } else { |
| 37 | for (; __first != __last; ++__first) | 40 | return std::__fill(std::move(__first), std::move(__last), __value); |
| 38 | *__first = __value; | ||
| 39 | return __first; | ||
| 40 | } | 41 | } |
| 41 | } | 42 | } |
| 42 | 43 |
lib/libcxx/include/__algorithm/ranges_for_each.h+9-1| ... | @@ -12,6 +12,7 @@ | ... | @@ -12,6 +12,7 @@ |
| 12 | #include <__algorithm/for_each.h> | 12 | #include <__algorithm/for_each.h> |
| 13 | #include <__algorithm/for_each_n.h> | 13 | #include <__algorithm/for_each_n.h> |
| 14 | #include <__algorithm/in_fun_result.h> | 14 | #include <__algorithm/in_fun_result.h> |
| 15 | #include <__algorithm/specialized_algorithms.h> | ||
| 15 | #include <__concepts/assignable.h> | 16 | #include <__concepts/assignable.h> |
| 16 | #include <__config> | 17 | #include <__config> |
| 17 | #include <__functional/identity.h> | 18 | #include <__functional/identity.h> |
| ... | @@ -20,6 +21,7 @@ | ... | @@ -20,6 +21,7 @@ |
| 20 | #include <__ranges/access.h> | 21 | #include <__ranges/access.h> |
| 21 | #include <__ranges/concepts.h> | 22 | #include <__ranges/concepts.h> |
| 22 | #include <__ranges/dangling.h> | 23 | #include <__ranges/dangling.h> |
| 24 | #include <__type_traits/remove_cvref.h> | ||
| 23 | #include <__utility/move.h> | 25 | #include <__utility/move.h> |
| 24 | 26 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -71,7 +73,13 @@ public: | ... | @@ -71,7 +73,13 @@ public: |
| 71 | indirectly_unary_invocable<projected<iterator_t<_Range>, _Proj>> _Func> | 73 | indirectly_unary_invocable<projected<iterator_t<_Range>, _Proj>> _Func> |
| 72 | _LIBCPP_HIDE_FROM_ABI constexpr for_each_result<borrowed_iterator_t<_Range>, _Func> | 74 | _LIBCPP_HIDE_FROM_ABI constexpr for_each_result<borrowed_iterator_t<_Range>, _Func> |
| 73 | operator()(_Range&& __range, _Func __func, _Proj __proj = {}) const { | 75 | operator()(_Range&& __range, _Func __func, _Proj __proj = {}) const { |
| 74 | return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj); | 76 | using _SpecialAlg = __specialized_algorithm<_Algorithm::__for_each, __single_range<remove_cvref_t<_Range>>>; |
| 77 | if constexpr (_SpecialAlg::__has_algorithm) { | ||
| 78 | auto [__iter, __func2] = _SpecialAlg()(__range, std::move(__func), std::move(__proj)); | ||
| 79 | return {std::move(__iter), std::move(__func)}; | ||
| 80 | } else { | ||
| 81 | return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj); | ||
| 82 | } | ||
| 75 | } | 83 | } |
| 76 | }; | 84 | }; |
| 77 | 85 |
lib/libcxx/include/__algorithm/ranges_generate_n.h+2-6| ... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/generate_n.h> | ||
| 12 | #include <__concepts/constructible.h> | 13 | #include <__concepts/constructible.h> |
| 13 | #include <__concepts/invocable.h> | 14 | #include <__concepts/invocable.h> |
| 14 | #include <__config> | 15 | #include <__config> |
| ... | @@ -38,12 +39,7 @@ struct __generate_n { | ... | @@ -38,12 +39,7 @@ struct __generate_n { |
| 38 | requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> | 39 | requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr _OutIter | 40 | _LIBCPP_HIDE_FROM_ABI constexpr _OutIter |
| 40 | operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const { | 41 | operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const { |
| 41 | for (; __n > 0; --__n) { | 42 | return std::__generate_n(std::move(__first), __n, __gen); |
| 42 | *__first = __gen(); | ||
| 43 | ++__first; | ||
| 44 | } | ||
| 45 | |||
| 46 | return __first; | ||
| 47 | } | 43 | } |
| 48 | }; | 44 | }; |
| 49 | 45 |
lib/libcxx/include/__algorithm/ranges_search_n.h+2-2| ... | @@ -54,8 +54,8 @@ struct __search_n { | ... | @@ -54,8 +54,8 @@ struct __search_n { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | if constexpr (random_access_iterator<_Iter1>) { | 56 | if constexpr (random_access_iterator<_Iter1>) { |
| 57 | auto __ret = std::__search_n_random_access_impl<_RangeAlgPolicy>( | 57 | auto __ret = |
| 58 | __first, __last, __count, __value, __pred, __proj, __size); | 58 | std::__search_n_random_access_impl<_RangeAlgPolicy>(__first, __count, __value, __pred, __proj, __size); |
| 59 | return {std::move(__ret.first), std::move(__ret.second)}; | 59 | return {std::move(__ret.first), std::move(__ret.second)}; |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
lib/libcxx/include/__algorithm/rotate.h+27-44| ... | @@ -12,16 +12,13 @@ | ... | @@ -12,16 +12,13 @@ |
| 12 | #include <__algorithm/copy.h> | 12 | #include <__algorithm/copy.h> |
| 13 | #include <__algorithm/copy_backward.h> | 13 | #include <__algorithm/copy_backward.h> |
| 14 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/min.h> | ||
| 15 | #include <__algorithm/move.h> | 16 | #include <__algorithm/move.h> |
| 16 | #include <__algorithm/move_backward.h> | 17 | #include <__algorithm/move_backward.h> |
| 17 | #include <__algorithm/swap_ranges.h> | 18 | #include <__algorithm/swap_ranges.h> |
| 18 | #include <__config> | 19 | #include <__config> |
| 19 | #include <__cstddef/size_t.h> | ||
| 20 | #include <__fwd/bit_reference.h> | 20 | #include <__fwd/bit_reference.h> |
| 21 | #include <__iterator/iterator_traits.h> | 21 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__memory/construct_at.h> | ||
| 23 | #include <__memory/pointer_traits.h> | ||
| 24 | #include <__type_traits/is_constant_evaluated.h> | ||
| 25 | #include <__type_traits/is_trivially_assignable.h> | 22 | #include <__type_traits/is_trivially_assignable.h> |
| 26 | #include <__utility/move.h> | 23 | #include <__utility/move.h> |
| 27 | #include <__utility/pair.h> | 24 | #include <__utility/pair.h> |
| ... | @@ -89,46 +86,32 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt | ... | @@ -89,46 +86,32 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt |
| 89 | return __r; | 86 | return __r; |
| 90 | } | 87 | } |
| 91 | 88 | ||
| 92 | template <typename _Integral> | 89 | template <class _AlgPolicy, class _Iter, class _Sent> |
| 93 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Integral __algo_gcd(_Integral __x, _Integral __y) { | 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter |
| 94 | do { | 91 | __rotate_random_access(_Iter __first, _Iter __middle, _Sent __sent) { |
| 95 | _Integral __t = __x % __y; | 92 | auto __left = _IterOps<_AlgPolicy>::distance(__first, __middle); |
| 96 | __x = __y; | 93 | auto __right = _IterOps<_AlgPolicy>::distance(__middle, __sent); |
| 97 | __y = __t; | 94 | auto __last = __first + __right; |
| 98 | } while (__y); | 95 | |
| 99 | return __x; | 96 | auto __min_len = std::min(__left, __right); |
| 100 | } | 97 | |
| 101 | 98 | while (__min_len > 0) { | |
| 102 | template <class _AlgPolicy, typename _RandomAccessIterator> | 99 | if (__left <= __right) { |
| 103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _RandomAccessIterator | 100 | do { |
| 104 | __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) { | 101 | std::__swap_ranges<_AlgPolicy>(__first, __first + __left, __first + __left); |
| 105 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | 102 | __first += __left; |
| 106 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | 103 | __right -= __left; |
| 107 | using _Ops = _IterOps<_AlgPolicy>; | 104 | } while (__left <= __right); |
| 108 | 105 | __min_len = __right; | |
| 109 | const difference_type __m1 = __middle - __first; | 106 | } else { |
| 110 | const difference_type __m2 = _Ops::distance(__middle, __last); | 107 | do { |
| 111 | if (__m1 == __m2) { | 108 | std::__swap_ranges<_AlgPolicy>(__first + (__left - __right), __first + __left, __first + __left); |
| 112 | std::__swap_ranges<_AlgPolicy>(__first, __middle, __middle, __last); | 109 | __left -= __right; |
| 113 | return __middle; | 110 | } while (__left > __right); |
| 114 | } | 111 | __min_len = __left; |
| 115 | const difference_type __g = std::__algo_gcd(__m1, __m2); | 112 | } |
| 116 | for (_RandomAccessIterator __p = __first + __g; __p != __first;) { | ||
| 117 | value_type __t(_Ops::__iter_move(--__p)); | ||
| 118 | _RandomAccessIterator __p1 = __p; | ||
| 119 | _RandomAccessIterator __p2 = __p1 + __m1; | ||
| 120 | do { | ||
| 121 | *__p1 = _Ops::__iter_move(__p2); | ||
| 122 | __p1 = __p2; | ||
| 123 | const difference_type __d = _Ops::distance(__p2, __last); | ||
| 124 | if (__m1 < __d) | ||
| 125 | __p2 += __m1; | ||
| 126 | else | ||
| 127 | __p2 = __first + (__m1 - __d); | ||
| 128 | } while (__p2 != __p); | ||
| 129 | *__p1 = std::move(__t); | ||
| 130 | } | 113 | } |
| 131 | return __first + __m2; | 114 | return __last; |
| 132 | } | 115 | } |
| 133 | 116 | ||
| 134 | template <class _AlgPolicy, class _ForwardIterator> | 117 | template <class _AlgPolicy, class _ForwardIterator> |
| ... | @@ -170,7 +153,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator | ... | @@ -170,7 +153,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator |
| 170 | return std::__rotate_left<_AlgPolicy>(__first, __last); | 153 | return std::__rotate_left<_AlgPolicy>(__first, __last); |
| 171 | if (_IterOps<_AlgPolicy>::next(__middle) == __last) | 154 | if (_IterOps<_AlgPolicy>::next(__middle) == __last) |
| 172 | return std::__rotate_right<_AlgPolicy>(__first, __last); | 155 | return std::__rotate_right<_AlgPolicy>(__first, __last); |
| 173 | return std::__rotate_gcd<_AlgPolicy>(__first, __middle, __last); | 156 | return std::__rotate_random_access<_AlgPolicy>(__first, __middle, __last); |
| 174 | } | 157 | } |
| 175 | return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last); | 158 | return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last); |
| 176 | } | 159 | } |
lib/libcxx/include/__algorithm/search_n.h+49-37| ... | @@ -14,11 +14,7 @@ | ... | @@ -14,11 +14,7 @@ |
| 14 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__functional/identity.h> | 16 | #include <__functional/identity.h> |
| 17 | #include <__iterator/advance.h> | ||
| 18 | #include <__iterator/concepts.h> | ||
| 19 | #include <__iterator/distance.h> | ||
| 20 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__ranges/concepts.h> | ||
| 22 | #include <__type_traits/enable_if.h> | 18 | #include <__type_traits/enable_if.h> |
| 23 | #include <__type_traits/invoke.h> | 19 | #include <__type_traits/invoke.h> |
| 24 | #include <__type_traits/is_callable.h> | 20 | #include <__type_traits/is_callable.h> |
| ... | @@ -68,44 +64,60 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> __search_ | ... | @@ -68,44 +64,60 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> __search_ |
| 68 | } | 64 | } |
| 69 | } | 65 | } |
| 70 | 66 | ||
| 71 | template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT> | 67 | // Finds the longest suffix in [__first, __last) where each element satisfies __pred. |
| 68 | template <class _RAIter, class _Pred, class _Proj, class _ValueT> | ||
| 69 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _RAIter | ||
| 70 | __find_longest_suffix(_RAIter __first, _RAIter __last, const _ValueT& __value, _Pred& __pred, _Proj& __proj) { | ||
| 71 | while (__first != __last) { | ||
| 72 | if (!std::__invoke(__pred, std::__invoke(__proj, *--__last), __value)) { | ||
| 73 | return ++__last; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | return __first; | ||
| 77 | } | ||
| 78 | |||
| 79 | template <class _AlgPolicy, class _Pred, class _Iter, class _SizeT, class _Type, class _Proj, class _DiffT> | ||
| 72 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 std::pair<_Iter, _Iter> __search_n_random_access_impl( | 80 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 std::pair<_Iter, _Iter> __search_n_random_access_impl( |
| 73 | _Iter __first, _Sent __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj, _DiffT __size1) { | 81 | _Iter __first, _SizeT __count_in, const _Type& __value, _Pred& __pred, _Proj& __proj, _DiffT __size) { |
| 74 | using difference_type = typename iterator_traits<_Iter>::difference_type; | 82 | auto __last = __first + __size; |
| 83 | auto __count = static_cast<_DiffT>(__count_in); | ||
| 84 | |||
| 75 | if (__count == 0) | 85 | if (__count == 0) |
| 76 | return std::make_pair(__first, __first); | 86 | return std::make_pair(__first, __first); |
| 77 | if (__size1 < static_cast<_DiffT>(__count)) { | 87 | if (__size < __count) |
| 78 | _IterOps<_AlgPolicy>::__advance_to(__first, __last); | 88 | return std::make_pair(__last, __last); |
| 79 | return std::make_pair(__first, __first); | 89 | |
| 80 | } | 90 | // [__match_start, __match_start + __count) is the subrange which we currently check whether it only contains matching |
| 91 | // elements. This subrange is returned in case all the elements match. | ||
| 92 | // [__match_start, __matched_until) is the longest subrange where all elements are known to match at any given point | ||
| 93 | // in time. | ||
| 94 | // [__matched_until, __match_start + __count) is the subrange where we don't know whether the elements match. | ||
| 95 | |||
| 96 | // This algorithm tries to expand the subrange [__match_start, __matched_until) into a range of sufficient length. | ||
| 97 | // When we fail to do that because we find a mismatching element, we move it forward to the beginning of the next | ||
| 98 | // consecutive sequence that is not known not to match. | ||
| 99 | |||
| 100 | const _Iter __try_match_until = __last - __count; | ||
| 101 | _Iter __match_start = __first; | ||
| 102 | _Iter __matched_until = __first; | ||
| 81 | 103 | ||
| 82 | const auto __s = __first + __size1 - difference_type(__count - 1); // Start of pattern match can't go beyond here | ||
| 83 | while (true) { | 104 | while (true) { |
| 84 | // Find first element in sequence that matchs __value, with a mininum of loop checks | 105 | // There's no chance of expanding the subrange into a sequence of sufficient length, since we don't have enough |
| 85 | while (true) { | 106 | // elements in the haystack anymore. |
| 86 | if (__first >= __s) { // return __last if no element matches __value | 107 | if (__match_start > __try_match_until) |
| 87 | _IterOps<_AlgPolicy>::__advance_to(__first, __last); | 108 | return std::make_pair(__last, __last); |
| 88 | return std::make_pair(__first, __first); | ||
| 89 | } | ||
| 90 | if (std::__invoke(__pred, std::__invoke(__proj, *__first), __value)) | ||
| 91 | break; | ||
| 92 | ++__first; | ||
| 93 | } | ||
| 94 | // *__first matches __value_, now match elements after here | ||
| 95 | auto __m = __first; | ||
| 96 | _SizeT __c(0); | ||
| 97 | while (true) { | ||
| 98 | if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) | ||
| 99 | return std::make_pair(__first, __first + _DiffT(__count)); | ||
| 100 | ++__m; // no need to check range on __m because __s guarantees we have enough source | ||
| 101 | 109 | ||
| 102 | // if there is a mismatch, restart with a new __first | 110 | auto __mismatch = std::__find_longest_suffix(__matched_until, __match_start + __count, __value, __pred, __proj); |
| 103 | if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value)) { | 111 | |
| 104 | __first = __m; | 112 | // If all elements in [__matched_until, __match_start + __count) match, we know that |
| 105 | ++__first; | 113 | // [__match_start, __match_start + __count) is a full sequence of matching elements, so we're done. |
| 106 | break; | 114 | if (__mismatch == __matched_until) |
| 107 | } // else there is a match, check next elements | 115 | return std::make_pair(__match_start, __match_start + __count); |
| 108 | } | 116 | |
| 117 | // Otherwise, we have to move the [__match_start, __matched_until) subrange forward past the point where we know for | ||
| 118 | // sure a match is impossible. | ||
| 119 | __matched_until = __match_start + __count; | ||
| 120 | __match_start = __mismatch; | ||
| 109 | } | 121 | } |
| 110 | } | 122 | } |
| 111 | 123 | ||
| ... | @@ -119,7 +131,7 @@ template <class _Iter, | ... | @@ -119,7 +131,7 @@ template <class _Iter, |
| 119 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> | 131 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> |
| 120 | __search_n_impl(_Iter __first, _Sent __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { | 132 | __search_n_impl(_Iter __first, _Sent __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { |
| 121 | return std::__search_n_random_access_impl<_ClassicAlgPolicy>( | 133 | return std::__search_n_random_access_impl<_ClassicAlgPolicy>( |
| 122 | __first, __last, __count, __value, __pred, __proj, __last - __first); | 134 | __first, __count, __value, __pred, __proj, __last - __first); |
| 123 | } | 135 | } |
| 124 | 136 | ||
| 125 | template <class _Iter1, | 137 | template <class _Iter1, |
lib/libcxx/include/__algorithm/sift_down.h+19-18| ... | @@ -24,59 +24,60 @@ _LIBCPP_PUSH_MACROS | ... | @@ -24,59 +24,60 @@ _LIBCPP_PUSH_MACROS |
| 24 | 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | 27 | template <class _AlgPolicy, bool __assume_both_children, class _Compare, class _RandomAccessIterator> |
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 29 | __sift_down(_RandomAccessIterator __first, | 29 | __sift_down(_RandomAccessIterator __first, |
| 30 | _Compare&& __comp, | 30 | _Compare&& __comp, |
| 31 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, | 31 | __iterator_difference_type<_RandomAccessIterator> __len, |
| 32 | _RandomAccessIterator __start) { | 32 | __iterator_difference_type<_RandomAccessIterator> __start) { |
| 33 | using _Ops = _IterOps<_AlgPolicy>; | 33 | using _Ops = _IterOps<_AlgPolicy>; |
| 34 | 34 | ||
| 35 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | 35 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 36 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | 36 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 37 | // left-child of __start is at 2 * __start + 1 | 37 | // left-child of __start is at 2 * __start + 1 |
| 38 | // right-child of __start is at 2 * __start + 2 | 38 | // right-child of __start is at 2 * __start + 2 |
| 39 | difference_type __child = __start - __first; | 39 | difference_type __child = __start; |
| 40 | 40 | ||
| 41 | if (__len < 2 || (__len - 2) / 2 < __child) | 41 | if (__len < 2 || (__len - 2) / 2 < __child) |
| 42 | return; | 42 | return; |
| 43 | 43 | ||
| 44 | __child = 2 * __child + 1; | 44 | __child = 2 * __child + 1; |
| 45 | _RandomAccessIterator __child_i = __first + __child; | ||
| 46 | 45 | ||
| 47 | if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) { | 46 | if _LIBCPP_CONSTEXPR (__assume_both_children) { |
| 47 | // right-child exists and is greater than left-child | ||
| 48 | __child += __comp(__first[__child], __first[__child + 1]); | ||
| 49 | } else if ((__child + 1) < __len && __comp(__first[__child], __first[__child + 1])) { | ||
| 48 | // right-child exists and is greater than left-child | 50 | // right-child exists and is greater than left-child |
| 49 | ++__child_i; | ||
| 50 | ++__child; | 51 | ++__child; |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | // check if we are in heap-order | 54 | // check if we are in heap-order |
| 54 | if (__comp(*__child_i, *__start)) | 55 | if (__comp(__first[__child], __first[__start])) |
| 55 | // we are, __start is larger than its largest child | 56 | // we are, __start is larger than its largest child |
| 56 | return; | 57 | return; |
| 57 | 58 | ||
| 58 | value_type __top(_Ops::__iter_move(__start)); | 59 | value_type __top(_Ops::__iter_move(__first + __start)); |
| 59 | do { | 60 | do { |
| 60 | // we are not in heap-order, swap the parent with its largest child | 61 | // we are not in heap-order, swap the parent with its largest child |
| 61 | *__start = _Ops::__iter_move(__child_i); | 62 | __first[__start] = _Ops::__iter_move(__first + __child); |
| 62 | __start = __child_i; | 63 | __start = __child; |
| 63 | 64 | ||
| 64 | if ((__len - 2) / 2 < __child) | 65 | if ((__len - 2) / 2 < __child) |
| 65 | break; | 66 | break; |
| 66 | 67 | ||
| 67 | // recompute the child based off of the updated parent | 68 | // recompute the child based off of the updated parent |
| 68 | __child = 2 * __child + 1; | 69 | __child = 2 * __child + 1; |
| 69 | __child_i = __first + __child; | ||
| 70 | 70 | ||
| 71 | if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) { | 71 | if _LIBCPP_CONSTEXPR (__assume_both_children) { |
| 72 | __child += __comp(__first[__child], __first[__child + 1]); | ||
| 73 | } else if ((__child + 1) < __len && __comp(__first[__child], __first[__child + 1])) { | ||
| 72 | // right-child exists and is greater than left-child | 74 | // right-child exists and is greater than left-child |
| 73 | ++__child_i; | ||
| 74 | ++__child; | 75 | ++__child; |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | // check if we are in heap-order | 78 | // check if we are in heap-order |
| 78 | } while (!__comp(*__child_i, __top)); | 79 | } while (!__comp(__first[__child], __top)); |
| 79 | *__start = std::move(__top); | 80 | __first[__start] = std::move(__top); |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | 83 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> |
lib/libcxx/include/__algorithm/simd_utils.h+33-4| ... | @@ -26,9 +26,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,9 +26,7 @@ _LIBCPP_PUSH_MACROS |
| 26 | #include <__undef_macros> | 26 | #include <__undef_macros> |
| 27 | 27 | ||
| 28 | // TODO: Find out how altivec changes things and allow vectorizations there too. | 28 | // TODO: Find out how altivec changes things and allow vectorizations there too. |
| 29 | // TODO: Simplify this condition once we stop building with AppleClang 15 in the CI. | 29 | #if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(__ALTIVEC__) |
| 30 | #if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(__ALTIVEC__) && \ | ||
| 31 | !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600) | ||
| 32 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1 | 30 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1 |
| 33 | #else | 31 | #else |
| 34 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0 | 32 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0 |
| ... | @@ -116,16 +114,47 @@ template <class _VecT, class _Iter> | ... | @@ -116,16 +114,47 @@ template <class _VecT, class _Iter> |
| 116 | }(make_index_sequence<__simd_vector_size_v<_VecT>>{}); | 114 | }(make_index_sequence<__simd_vector_size_v<_VecT>>{}); |
| 117 | } | 115 | } |
| 118 | 116 | ||
| 117 | // Load the first _Np elements, zero the rest | ||
| 118 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 119 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpsabi") | ||
| 120 | template <class _VecT, size_t _Np, class _Iter> | ||
| 121 | [[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __partial_load(_Iter __iter) noexcept { | ||
| 122 | return [=]<size_t... _LoadIndices, size_t... _ZeroIndices>( | ||
| 123 | index_sequence<_LoadIndices...>, index_sequence<_ZeroIndices...>) _LIBCPP_ALWAYS_INLINE noexcept { | ||
| 124 | return _VecT{__iter[_LoadIndices]..., ((void)_ZeroIndices, 0)...}; | ||
| 125 | }(make_index_sequence<_Np>{}, make_index_sequence<__simd_vector_size_v<_VecT> - _Np>{}); | ||
| 126 | } | ||
| 127 | |||
| 128 | // Create a vector where every elements is __val | ||
| 129 | template <class _VecT> | ||
| 130 | [[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT | ||
| 131 | __broadcast(__simd_vector_underlying_type_t<_VecT> __val) { | ||
| 132 | return [&]<std::size_t... _Indices>(index_sequence<_Indices...>) { | ||
| 133 | return _VecT{((void)_Indices, __val)...}; | ||
| 134 | }(make_index_sequence<__simd_vector_size_v<_VecT>>()); | ||
| 135 | } | ||
| 136 | _LIBCPP_DIAGNOSTIC_POP | ||
| 137 | |||
| 138 | template <class _Tp, size_t _Np> | ||
| 139 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __any_of(__simd_vector<_Tp, _Np> __vec) noexcept { | ||
| 140 | return __builtin_reduce_or(__builtin_convertvector(__vec, __simd_vector<bool, _Np>)); | ||
| 141 | } | ||
| 142 | |||
| 119 | template <class _Tp, size_t _Np> | 143 | template <class _Tp, size_t _Np> |
| 120 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept { | 144 | [[__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>)); | 145 | return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>)); |
| 122 | } | 146 | } |
| 123 | 147 | ||
| 148 | template <class _Tp, size_t _Np> | ||
| 149 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __none_of(__simd_vector<_Tp, _Np> __vec) noexcept { | ||
| 150 | return !__builtin_reduce_or(__builtin_convertvector(__vec, __simd_vector<bool, _Np>)); | ||
| 151 | } | ||
| 152 | |||
| 124 | template <class _Tp, size_t _Np> | 153 | template <class _Tp, size_t _Np> |
| 125 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept { | 154 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept { |
| 126 | using __mask_vec = __simd_vector<bool, _Np>; | 155 | using __mask_vec = __simd_vector<bool, _Np>; |
| 127 | 156 | ||
| 128 | // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876 | 157 | // This has MSan disabled du to https://llvm.org/PR85876 |
| 129 | auto __impl = [&]<class _MaskT>(_MaskT) _LIBCPP_NO_SANITIZE("memory") noexcept { | 158 | auto __impl = [&]<class _MaskT>(_MaskT) _LIBCPP_NO_SANITIZE("memory") noexcept { |
| 130 | # if defined(_LIBCPP_BIG_ENDIAN) | 159 | # if defined(_LIBCPP_BIG_ENDIAN) |
| 131 | return std::min<size_t>( | 160 | return std::min<size_t>( |
lib/libcxx/include/__algorithm/specialized_algorithms.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___ALGORITHM_SPECIALIZED_ALGORITHMS_H | ||
| 10 | #define _LIBCPP___ALGORITHM_SPECIALIZED_ALGORITHMS_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 | namespace _Algorithm { | ||
| 21 | struct __copy {}; | ||
| 22 | struct __fill_n {}; | ||
| 23 | struct __for_each {}; | ||
| 24 | } // namespace _Algorithm | ||
| 25 | |||
| 26 | template <class> | ||
| 27 | struct __single_iterator; | ||
| 28 | |||
| 29 | template <class, class> | ||
| 30 | struct __iterator_pair; | ||
| 31 | |||
| 32 | template <class> | ||
| 33 | struct __single_range; | ||
| 34 | |||
| 35 | // This struct allows specializing algorithms for specific arguments. This is useful when we know a more efficient | ||
| 36 | // algorithm implementation for e.g. library-defined iterators. _Alg is one of tags defined inside the _Algorithm | ||
| 37 | // namespace above. _Ranges is an essentially arbitrary subset of the arguments to the algorithm that are used for | ||
| 38 | // dispatching. This set is specific to the algorithm: look at each algorithm to see which arguments they use for | ||
| 39 | // dispatching to specialized algorithms. | ||
| 40 | // | ||
| 41 | // A specialization of `__specialized_algorithm` has to define `__has_algorithm` to true for the specialized algorithm | ||
| 42 | // to be used. This is intended for cases where iterators can do generic unwrapping and forward to a different | ||
| 43 | // specialization of `__specialized_algorithm`. | ||
| 44 | // | ||
| 45 | // If __has_algorithm is true, there has to be an operator() which will get called with the actual arguments to the | ||
| 46 | // algorithm. | ||
| 47 | template <class _Alg, class... _Ranges> | ||
| 48 | struct __specialized_algorithm { | ||
| 49 | static const bool __has_algorithm = false; | ||
| 50 | }; | ||
| 51 | |||
| 52 | _LIBCPP_END_NAMESPACE_STD | ||
| 53 | |||
| 54 | #endif // _LIBCPP___ALGORITHM_SPECIALIZED_ALGORITHMS_H | ||
lib/libcxx/include/__algorithm/stable_sort.h+1-1| ... | @@ -247,7 +247,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort( | ... | @@ -247,7 +247,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort( |
| 247 | constexpr auto __default_comp = __desugars_to_v<__less_tag, _Compare, value_type, value_type >; | 247 | constexpr auto __default_comp = __desugars_to_v<__less_tag, _Compare, value_type, value_type >; |
| 248 | constexpr auto __radix_sortable = | 248 | constexpr auto __radix_sortable = |
| 249 | __is_ordered_integer_representable_v<value_type> && | 249 | __is_ordered_integer_representable_v<value_type> && |
| 250 | is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>; | 250 | is_same_v< value_type&, __iterator_reference<_RandomAccessIterator>>; |
| 251 | if constexpr (__default_comp && __radix_sortable) { | 251 | if constexpr (__default_comp && __radix_sortable) { |
| 252 | if (__len <= __buff_size && __len >= static_cast<difference_type>(std::__radix_sort_min_bound<value_type>()) && | 252 | if (__len <= __buff_size && __len >= static_cast<difference_type>(std::__radix_sort_min_bound<value_type>()) && |
| 253 | __len <= static_cast<difference_type>(std::__radix_sort_max_bound<value_type>())) { | 253 | __len <= static_cast<difference_type>(std::__radix_sort_max_bound<value_type>())) { |
lib/libcxx/include/__assertion_handler+31-4| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | # include <__cxx03/__verbose_trap> | 16 | # include <__cxx03/__verbose_trap> |
| 17 | #else | 17 | #else |
| 18 | # include <__config> | 18 | # include <__config> |
| 19 | # include <__log_hardening_failure> | ||
| 19 | # include <__verbose_abort> | 20 | # include <__verbose_abort> |
| 20 | # include <__verbose_trap> | 21 | # include <__verbose_trap> |
| 21 | #endif | 22 | #endif |
| ... | @@ -24,14 +25,40 @@ | ... | @@ -24,14 +25,40 @@ |
| 24 | # pragma GCC system_header | 25 | # pragma GCC system_header |
| 25 | #endif | 26 | #endif |
| 26 | 27 | ||
| 27 | #if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | 28 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 28 | 29 | ||
| 29 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) | 30 | // Keep the old implementation that doesn't support assertion semantics for backward compatibility with the frozen C++03 |
| 31 | // mode. | ||
| 32 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | ||
| 33 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) | ||
| 34 | # else | ||
| 35 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) | ||
| 36 | # endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | ||
| 30 | 37 | ||
| 31 | #else | 38 | #else |
| 32 | 39 | ||
| 33 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) | 40 | # if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_IGNORE |
| 41 | # define _LIBCPP_ASSERTION_HANDLER(message) ((void)0) | ||
| 42 | |||
| 43 | # elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE | ||
| 44 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_LOG_HARDENING_FAILURE(message) | ||
| 45 | |||
| 46 | # elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE | ||
| 47 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) | ||
| 48 | |||
| 49 | # elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE | ||
| 50 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message) | ||
| 51 | |||
| 52 | # else | ||
| 53 | |||
| 54 | # error _LIBCPP_ASSERTION_SEMANTIC must be set to one of the following values: \ | ||
| 55 | _LIBCPP_ASSERTION_SEMANTIC_IGNORE, \ | ||
| 56 | _LIBCPP_ASSERTION_SEMANTIC_OBSERVE, \ | ||
| 57 | _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE, \ | ||
| 58 | _LIBCPP_ASSERTION_SEMANTIC_ENFORCE | ||
| 59 | |||
| 60 | # endif // _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_IGNORE | ||
| 34 | 61 | ||
| 35 | #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | 62 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 36 | 63 | ||
| 37 | #endif // _LIBCPP___ASSERTION_HANDLER | 64 | #endif // _LIBCPP___ASSERTION_HANDLER |
lib/libcxx/include/__atomic/atomic.h+36-60| ... | @@ -10,7 +10,9 @@ | ... | @@ -10,7 +10,9 @@ |
| 10 | #define _LIBCPP___ATOMIC_ATOMIC_H | 10 | #define _LIBCPP___ATOMIC_ATOMIC_H |
| 11 | 11 | ||
| 12 | #include <__atomic/atomic_sync.h> | 12 | #include <__atomic/atomic_sync.h> |
| 13 | #include <__atomic/atomic_waitable_traits.h> | ||
| 13 | #include <__atomic/check_memory_order.h> | 14 | #include <__atomic/check_memory_order.h> |
| 15 | #include <__atomic/floating_point_helper.h> | ||
| 14 | #include <__atomic/is_always_lock_free.h> | 16 | #include <__atomic/is_always_lock_free.h> |
| 15 | #include <__atomic/memory_order.h> | 17 | #include <__atomic/memory_order.h> |
| 16 | #include <__atomic/support.h> | 18 | #include <__atomic/support.h> |
| ... | @@ -47,10 +49,10 @@ struct __atomic_base // false | ... | @@ -47,10 +49,10 @@ struct __atomic_base // false |
| 47 | static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; | 49 | static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; |
| 48 | #endif | 50 | #endif |
| 49 | 51 | ||
| 50 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT { | 52 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT { |
| 51 | return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>)); | 53 | return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>)); |
| 52 | } | 54 | } |
| 53 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const _NOEXCEPT { | 55 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const _NOEXCEPT { |
| 54 | return static_cast<__atomic_base const volatile*>(this)->is_lock_free(); | 56 | return static_cast<__atomic_base const volatile*>(this)->is_lock_free(); |
| 55 | } | 57 | } |
| 56 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT | 58 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT |
| ... | @@ -61,11 +63,11 @@ struct __atomic_base // false | ... | @@ -61,11 +63,11 @@ struct __atomic_base // false |
| 61 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) { | 63 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) { |
| 62 | std::__cxx_atomic_store(std::addressof(__a_), __d, __m); | 64 | std::__cxx_atomic_store(std::addressof(__a_), __d, __m); |
| 63 | } | 65 | } |
| 64 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT | 66 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT |
| 65 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | 67 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { |
| 66 | return std::__cxx_atomic_load(std::addressof(__a_), __m); | 68 | return std::__cxx_atomic_load(std::addressof(__a_), __m); |
| 67 | } | 69 | } |
| 68 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT | 70 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT |
| 69 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | 71 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { |
| 70 | return std::__cxx_atomic_load(std::addressof(__a_), __m); | 72 | return std::__cxx_atomic_load(std::addressof(__a_), __m); |
| 71 | } | 73 | } |
| ... | @@ -113,22 +115,16 @@ struct __atomic_base // false | ... | @@ -113,22 +115,16 @@ struct __atomic_base // false |
| 113 | } | 115 | } |
| 114 | 116 | ||
| 115 | #if _LIBCPP_STD_VER >= 20 | 117 | #if _LIBCPP_STD_VER >= 20 |
| 116 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const | 118 | _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT { |
| 117 | volatile _NOEXCEPT { | ||
| 118 | std::__atomic_wait(*this, __v, __m); | 119 | std::__atomic_wait(*this, __v, __m); |
| 119 | } | 120 | } |
| 120 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 121 | _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { |
| 121 | wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { | ||
| 122 | std::__atomic_wait(*this, __v, __m); | 122 | std::__atomic_wait(*this, __v, __m); |
| 123 | } | 123 | } |
| 124 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | 124 | _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { std::__atomic_notify_one(*this); } |
| 125 | std::__atomic_notify_one(*this); | 125 | _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } |
| 126 | } | 126 | _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { std::__atomic_notify_all(*this); } |
| 127 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } | 127 | _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } |
| 128 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { | ||
| 129 | std::__atomic_notify_all(*this); | ||
| 130 | } | ||
| 131 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } | ||
| 132 | #endif // _LIBCPP_STD_VER >= 20 | 128 | #endif // _LIBCPP_STD_VER >= 20 |
| 133 | 129 | ||
| 134 | #if _LIBCPP_STD_VER >= 20 | 130 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -205,12 +201,15 @@ struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { | ... | @@ -205,12 +201,15 @@ struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { |
| 205 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; } | 201 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; } |
| 206 | }; | 202 | }; |
| 207 | 203 | ||
| 204 | #if _LIBCPP_STD_VER >= 20 | ||
| 208 | // Here we need _IsIntegral because the default template argument is not enough | 205 | // Here we need _IsIntegral because the default template argument is not enough |
| 209 | // e.g __atomic_base<int> is __atomic_base<int, true>, which inherits from | 206 | // e.g __atomic_base<int> is __atomic_base<int, true>, which inherits from |
| 210 | // __atomic_base<int, false> and the caller of the wait function is | 207 | // __atomic_base<int, false> and the caller of the wait function is |
| 211 | // __atomic_base<int, false>. So specializing __atomic_base<_Tp> does not work | 208 | // __atomic_base<int, false>. So specializing __atomic_base<_Tp> does not work |
| 212 | template <class _Tp, bool _IsIntegral> | 209 | template <class _Tp, bool _IsIntegral> |
| 213 | struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { | 210 | struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { |
| 211 | using __value_type _LIBCPP_NODEBUG = _Tp; | ||
| 212 | |||
| 214 | static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_base<_Tp, _IsIntegral>& __a, memory_order __order) { | 213 | static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_base<_Tp, _IsIntegral>& __a, memory_order __order) { |
| 215 | return __a.load(__order); | 214 | return __a.load(__order); |
| 216 | } | 215 | } |
| ... | @@ -231,6 +230,8 @@ struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { | ... | @@ -231,6 +230,8 @@ struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { |
| 231 | } | 230 | } |
| 232 | }; | 231 | }; |
| 233 | 232 | ||
| 233 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 234 | |||
| 234 | template <typename _Tp> | 235 | template <typename _Tp> |
| 235 | struct __check_atomic_mandates { | 236 | struct __check_atomic_mandates { |
| 236 | using type _LIBCPP_NODEBUG = _Tp; | 237 | using type _LIBCPP_NODEBUG = _Tp; |
| ... | @@ -324,50 +325,26 @@ struct atomic<_Tp*> : public __atomic_base<_Tp*> { | ... | @@ -324,50 +325,26 @@ struct atomic<_Tp*> : public __atomic_base<_Tp*> { |
| 324 | atomic& operator=(const atomic&) volatile = delete; | 325 | atomic& operator=(const atomic&) volatile = delete; |
| 325 | }; | 326 | }; |
| 326 | 327 | ||
| 328 | #if _LIBCPP_STD_VER >= 20 | ||
| 327 | template <class _Tp> | 329 | template <class _Tp> |
| 328 | struct __atomic_waitable_traits<atomic<_Tp> > : __atomic_waitable_traits<__atomic_base<_Tp> > {}; | 330 | struct __atomic_waitable_traits<atomic<_Tp> > : __atomic_waitable_traits<__atomic_base<_Tp> > {}; |
| 329 | 331 | ||
| 330 | #if _LIBCPP_STD_VER >= 20 | ||
| 331 | template <class _Tp> | 332 | template <class _Tp> |
| 332 | requires is_floating_point_v<_Tp> | 333 | requires is_floating_point_v<_Tp> |
| 333 | struct atomic<_Tp> : __atomic_base<_Tp> { | 334 | struct atomic<_Tp> : __atomic_base<_Tp> { |
| 334 | private: | 335 | private: |
| 335 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __is_fp80_long_double() { | ||
| 336 | // Only x87-fp80 long double has 64-bit mantissa | ||
| 337 | return __LDBL_MANT_DIG__ == 64 && std::is_same_v<_Tp, long double>; | ||
| 338 | } | ||
| 339 | |||
| 340 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __has_rmw_builtin() { | ||
| 341 | # ifndef _LIBCPP_COMPILER_CLANG_BASED | ||
| 342 | return false; | ||
| 343 | # else | ||
| 344 | // The builtin __cxx_atomic_fetch_add errors during compilation for | ||
| 345 | // long double on platforms with fp80 format. | ||
| 346 | // For more details, see | ||
| 347 | // lib/Sema/SemaChecking.cpp function IsAllowedValueType | ||
| 348 | // LLVM Parser does not allow atomicrmw with x86_fp80 type. | ||
| 349 | // if (ValType->isSpecificBuiltinType(BuiltinType::LongDouble) && | ||
| 350 | // &Context.getTargetInfo().getLongDoubleFormat() == | ||
| 351 | // &llvm::APFloat::x87DoubleExtended()) | ||
| 352 | // For more info | ||
| 353 | // https://github.com/llvm/llvm-project/issues/68602 | ||
| 354 | // https://reviews.llvm.org/D53965 | ||
| 355 | return !__is_fp80_long_double(); | ||
| 356 | # endif | ||
| 357 | } | ||
| 358 | |||
| 359 | template <class _This, class _Operation, class _BuiltinOp> | 336 | template <class _This, class _Operation, class _BuiltinOp> |
| 360 | _LIBCPP_HIDE_FROM_ABI static _Tp | 337 | _LIBCPP_HIDE_FROM_ABI static _Tp |
| 361 | __rmw_op(_This&& __self, _Tp __operand, memory_order __m, _Operation __operation, _BuiltinOp __builtin_op) { | 338 | __rmw_op(_This&& __self, _Tp __operand, memory_order __m, _Operation __operation, _BuiltinOp __builtin_op) { |
| 362 | if constexpr (__has_rmw_builtin()) { | 339 | if constexpr (std::__has_rmw_builtin<_Tp>()) { |
| 363 | return __builtin_op(std::addressof(std::forward<_This>(__self).__a_), __operand, __m); | 340 | return __builtin_op(std::addressof(std::forward<_This>(__self).__a_), __operand, __m); |
| 364 | } else { | 341 | } else { |
| 365 | _Tp __old = __self.load(memory_order_relaxed); | 342 | _Tp __old = __self.load(memory_order_relaxed); |
| 366 | _Tp __new = __operation(__old, __operand); | 343 | _Tp __new = __operation(__old, __operand); |
| 367 | while (!__self.compare_exchange_weak(__old, __new, __m, memory_order_relaxed)) { | 344 | while (!__self.compare_exchange_weak(__old, __new, __m, memory_order_relaxed)) { |
| 368 | # ifdef _LIBCPP_COMPILER_CLANG_BASED | 345 | # ifdef _LIBCPP_COMPILER_CLANG_BASED |
| 369 | if constexpr (__is_fp80_long_double()) { | 346 | if constexpr (std::__is_fp80_long_double<_Tp>()) { |
| 370 | // https://github.com/llvm/llvm-project/issues/47978 | 347 | // https://llvm.org/PR47978 |
| 371 | // clang bug: __old is not updated on failure for atomic<long double>::compare_exchange_weak | 348 | // clang bug: __old is not updated on failure for atomic<long double>::compare_exchange_weak |
| 372 | // Note __old = __self.load(memory_order_relaxed) will not work | 349 | // Note __old = __self.load(memory_order_relaxed) will not work |
| 373 | std::__cxx_atomic_load_inplace(std::addressof(__self.__a_), std::addressof(__old), memory_order_relaxed); | 350 | std::__cxx_atomic_load_inplace(std::addressof(__self.__a_), std::addressof(__old), memory_order_relaxed); |
| ... | @@ -462,12 +439,12 @@ public: | ... | @@ -462,12 +439,12 @@ public: |
| 462 | // atomic_is_lock_free | 439 | // atomic_is_lock_free |
| 463 | 440 | ||
| 464 | template <class _Tp> | 441 | template <class _Tp> |
| 465 | _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT { | 442 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT { |
| 466 | return __o->is_lock_free(); | 443 | return __o->is_lock_free(); |
| 467 | } | 444 | } |
| 468 | 445 | ||
| 469 | template <class _Tp> | 446 | template <class _Tp> |
| 470 | _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT { | 447 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT { |
| 471 | return __o->is_lock_free(); | 448 | return __o->is_lock_free(); |
| 472 | } | 449 | } |
| 473 | 450 | ||
| ... | @@ -516,25 +493,25 @@ atomic_store_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, me | ... | @@ -516,25 +493,25 @@ atomic_store_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d, me |
| 516 | // atomic_load | 493 | // atomic_load |
| 517 | 494 | ||
| 518 | template <class _Tp> | 495 | template <class _Tp> |
| 519 | _LIBCPP_HIDE_FROM_ABI _Tp atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT { | 496 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT { |
| 520 | return __o->load(); | 497 | return __o->load(); |
| 521 | } | 498 | } |
| 522 | 499 | ||
| 523 | template <class _Tp> | 500 | template <class _Tp> |
| 524 | _LIBCPP_HIDE_FROM_ABI _Tp atomic_load(const atomic<_Tp>* __o) _NOEXCEPT { | 501 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp atomic_load(const atomic<_Tp>* __o) _NOEXCEPT { |
| 525 | return __o->load(); | 502 | return __o->load(); |
| 526 | } | 503 | } |
| 527 | 504 | ||
| 528 | // atomic_load_explicit | 505 | // atomic_load_explicit |
| 529 | 506 | ||
| 530 | template <class _Tp> | 507 | template <class _Tp> |
| 531 | _LIBCPP_HIDE_FROM_ABI _Tp atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT | 508 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp |
| 532 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | 509 | atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { |
| 533 | return __o->load(__m); | 510 | return __o->load(__m); |
| 534 | } | 511 | } |
| 535 | 512 | ||
| 536 | template <class _Tp> | 513 | template <class _Tp> |
| 537 | _LIBCPP_HIDE_FROM_ABI _Tp atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT | 514 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT |
| 538 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | 515 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { |
| 539 | return __o->load(__m); | 516 | return __o->load(__m); |
| 540 | } | 517 | } |
| ... | @@ -642,28 +619,27 @@ _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit( | ... | @@ -642,28 +619,27 @@ _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit( |
| 642 | // atomic_wait | 619 | // atomic_wait |
| 643 | 620 | ||
| 644 | template <class _Tp> | 621 | template <class _Tp> |
| 645 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 622 | _LIBCPP_HIDE_FROM_ABI void |
| 646 | atomic_wait(const volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v) _NOEXCEPT { | 623 | atomic_wait(const volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v) _NOEXCEPT { |
| 647 | return __o->wait(__v); | 624 | return __o->wait(__v); |
| 648 | } | 625 | } |
| 649 | 626 | ||
| 650 | template <class _Tp> | 627 | template <class _Tp> |
| 651 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 628 | _LIBCPP_HIDE_FROM_ABI void atomic_wait(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v) _NOEXCEPT { |
| 652 | atomic_wait(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v) _NOEXCEPT { | ||
| 653 | return __o->wait(__v); | 629 | return __o->wait(__v); |
| 654 | } | 630 | } |
| 655 | 631 | ||
| 656 | // atomic_wait_explicit | 632 | // atomic_wait_explicit |
| 657 | 633 | ||
| 658 | template <class _Tp> | 634 | template <class _Tp> |
| 659 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 635 | _LIBCPP_HIDE_FROM_ABI void |
| 660 | atomic_wait_explicit(const volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v, memory_order __m) _NOEXCEPT | 636 | atomic_wait_explicit(const volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v, memory_order __m) _NOEXCEPT |
| 661 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | 637 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { |
| 662 | return __o->wait(__v, __m); | 638 | return __o->wait(__v, __m); |
| 663 | } | 639 | } |
| 664 | 640 | ||
| 665 | template <class _Tp> | 641 | template <class _Tp> |
| 666 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 642 | _LIBCPP_HIDE_FROM_ABI void |
| 667 | atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v, memory_order __m) _NOEXCEPT | 643 | atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __v, memory_order __m) _NOEXCEPT |
| 668 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | 644 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { |
| 669 | return __o->wait(__v, __m); | 645 | return __o->wait(__v, __m); |
| ... | @@ -672,22 +648,22 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __ | ... | @@ -672,22 +648,22 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __ |
| 672 | // atomic_notify_one | 648 | // atomic_notify_one |
| 673 | 649 | ||
| 674 | template <class _Tp> | 650 | template <class _Tp> |
| 675 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { | 651 | _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { |
| 676 | __o->notify_one(); | 652 | __o->notify_one(); |
| 677 | } | 653 | } |
| 678 | template <class _Tp> | 654 | template <class _Tp> |
| 679 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { | 655 | _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { |
| 680 | __o->notify_one(); | 656 | __o->notify_one(); |
| 681 | } | 657 | } |
| 682 | 658 | ||
| 683 | // atomic_notify_all | 659 | // atomic_notify_all |
| 684 | 660 | ||
| 685 | template <class _Tp> | 661 | template <class _Tp> |
| 686 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { | 662 | _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { |
| 687 | __o->notify_all(); | 663 | __o->notify_all(); |
| 688 | } | 664 | } |
| 689 | template <class _Tp> | 665 | template <class _Tp> |
| 690 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { | 666 | _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { |
| 691 | __o->notify_all(); | 667 | __o->notify_all(); |
| 692 | } | 668 | } |
| 693 | 669 |
lib/libcxx/include/__atomic/atomic_flag.h+19-37| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___ATOMIC_ATOMIC_FLAG_H | 10 | #define _LIBCPP___ATOMIC_ATOMIC_FLAG_H |
| 11 | 11 | ||
| 12 | #include <__atomic/atomic_sync.h> | 12 | #include <__atomic/atomic_sync.h> |
| 13 | #include <__atomic/atomic_waitable_traits.h> | ||
| 13 | #include <__atomic/contention_t.h> | 14 | #include <__atomic/contention_t.h> |
| 14 | #include <__atomic/memory_order.h> | 15 | #include <__atomic/memory_order.h> |
| 15 | #include <__atomic/support.h> | 16 | #include <__atomic/support.h> |
| ... | @@ -49,22 +50,16 @@ struct atomic_flag { | ... | @@ -49,22 +50,16 @@ struct atomic_flag { |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | #if _LIBCPP_STD_VER >= 20 | 52 | #if _LIBCPP_STD_VER >= 20 |
| 52 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const | 53 | _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT { |
| 53 | volatile _NOEXCEPT { | ||
| 54 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); | 54 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); |
| 55 | } | 55 | } |
| 56 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 56 | _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { |
| 57 | wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { | ||
| 58 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); | 57 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); |
| 59 | } | 58 | } |
| 60 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | 59 | _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { std::__atomic_notify_one(*this); } |
| 61 | std::__atomic_notify_one(*this); | 60 | _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } |
| 62 | } | 61 | _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { std::__atomic_notify_all(*this); } |
| 63 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } | 62 | _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } |
| 64 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { | ||
| 65 | std::__atomic_notify_all(*this); | ||
| 66 | } | ||
| 67 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } | ||
| 68 | #endif | 63 | #endif |
| 69 | 64 | ||
| 70 | #if _LIBCPP_STD_VER >= 20 | 65 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -80,8 +75,11 @@ struct atomic_flag { | ... | @@ -80,8 +75,11 @@ struct atomic_flag { |
| 80 | atomic_flag& operator=(const atomic_flag&) volatile = delete; | 75 | atomic_flag& operator=(const atomic_flag&) volatile = delete; |
| 81 | }; | 76 | }; |
| 82 | 77 | ||
| 78 | #if _LIBCPP_STD_VER >= 20 | ||
| 83 | template <> | 79 | template <> |
| 84 | struct __atomic_waitable_traits<atomic_flag> { | 80 | struct __atomic_waitable_traits<atomic_flag> { |
| 81 | using __value_type _LIBCPP_NODEBUG = _LIBCPP_ATOMIC_FLAG_TYPE; | ||
| 82 | |||
| 85 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE __atomic_load(const atomic_flag& __a, memory_order __order) { | 83 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE __atomic_load(const atomic_flag& __a, memory_order __order) { |
| 86 | return std::__cxx_atomic_load(&__a.__a_, __order); | 84 | return std::__cxx_atomic_load(&__a.__a_, __order); |
| 87 | } | 85 | } |
| ... | @@ -101,6 +99,7 @@ struct __atomic_waitable_traits<atomic_flag> { | ... | @@ -101,6 +99,7 @@ struct __atomic_waitable_traits<atomic_flag> { |
| 101 | return std::addressof(__a.__a_); | 99 | return std::addressof(__a.__a_); |
| 102 | } | 100 | } |
| 103 | }; | 101 | }; |
| 102 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 104 | 103 | ||
| 105 | inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT { return __o->test(); } | 104 | inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT { return __o->test(); } |
| 106 | 105 | ||
| ... | @@ -143,43 +142,26 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m | ... | @@ -143,43 +142,26 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m |
| 143 | } | 142 | } |
| 144 | 143 | ||
| 145 | #if _LIBCPP_STD_VER >= 20 | 144 | #if _LIBCPP_STD_VER >= 20 |
| 146 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 145 | inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT { |
| 147 | atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT { | ||
| 148 | __o->wait(__v); | 146 | __o->wait(__v); |
| 149 | } | 147 | } |
| 150 | 148 | ||
| 151 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 149 | inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT { __o->wait(__v); } |
| 152 | atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT { | ||
| 153 | __o->wait(__v); | ||
| 154 | } | ||
| 155 | 150 | ||
| 156 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 151 | inline _LIBCPP_HIDE_FROM_ABI void |
| 157 | atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { | 152 | atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { |
| 158 | __o->wait(__v, __m); | 153 | __o->wait(__v, __m); |
| 159 | } | 154 | } |
| 160 | 155 | ||
| 161 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 156 | inline _LIBCPP_HIDE_FROM_ABI void |
| 162 | atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { | 157 | atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { |
| 163 | __o->wait(__v, __m); | 158 | __o->wait(__v, __m); |
| 164 | } | 159 | } |
| 165 | 160 | ||
| 166 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | 161 | inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT { __o->notify_one(); } |
| 167 | atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT { | 162 | inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { __o->notify_one(); } |
| 168 | __o->notify_one(); | 163 | inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT { __o->notify_all(); } |
| 169 | } | 164 | inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { __o->notify_all(); } |
| 170 | |||
| 171 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { | ||
| 172 | __o->notify_one(); | ||
| 173 | } | ||
| 174 | |||
| 175 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | ||
| 176 | atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT { | ||
| 177 | __o->notify_all(); | ||
| 178 | } | ||
| 179 | |||
| 180 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { | ||
| 181 | __o->notify_all(); | ||
| 182 | } | ||
| 183 | #endif // _LIBCPP_STD_VER >= 20 | 165 | #endif // _LIBCPP_STD_VER >= 20 |
| 184 | 166 | ||
| 185 | _LIBCPP_END_NAMESPACE_STD | 167 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__atomic/atomic_ref.h+29-12| ... | @@ -19,7 +19,9 @@ | ... | @@ -19,7 +19,9 @@ |
| 19 | 19 | ||
| 20 | #include <__assert> | 20 | #include <__assert> |
| 21 | #include <__atomic/atomic_sync.h> | 21 | #include <__atomic/atomic_sync.h> |
| 22 | #include <__atomic/atomic_waitable_traits.h> | ||
| 22 | #include <__atomic/check_memory_order.h> | 23 | #include <__atomic/check_memory_order.h> |
| 24 | #include <__atomic/floating_point_helper.h> | ||
| 23 | #include <__atomic/memory_order.h> | 25 | #include <__atomic/memory_order.h> |
| 24 | #include <__atomic/to_gcc_order.h> | 26 | #include <__atomic/to_gcc_order.h> |
| 25 | #include <__concepts/arithmetic.h> | 27 | #include <__concepts/arithmetic.h> |
| ... | @@ -121,7 +123,9 @@ public: | ... | @@ -121,7 +123,9 @@ public: |
| 121 | static constexpr bool is_always_lock_free = | 123 | static constexpr bool is_always_lock_free = |
| 122 | __atomic_always_lock_free(sizeof(_Tp), std::addressof(__get_aligner_instance<required_alignment>::__instance)); | 124 | __atomic_always_lock_free(sizeof(_Tp), std::addressof(__get_aligner_instance<required_alignment>::__instance)); |
| 123 | 125 | ||
| 124 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); } | 126 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { |
| 127 | return __atomic_is_lock_free(sizeof(_Tp), __ptr_); | ||
| 128 | } | ||
| 125 | 129 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept | 130 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept |
| 127 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__order) { | 131 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__order) { |
| ... | @@ -136,7 +140,7 @@ public: | ... | @@ -136,7 +140,7 @@ public: |
| 136 | return __desired; | 140 | return __desired; |
| 137 | } | 141 | } |
| 138 | 142 | ||
| 139 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __order = memory_order::seq_cst) const noexcept | 143 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __order = memory_order::seq_cst) const noexcept |
| 140 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__order) { | 144 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__order) { |
| 141 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 145 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 142 | __order == memory_order::relaxed || __order == memory_order::consume || __order == memory_order::acquire || | 146 | __order == memory_order::relaxed || __order == memory_order::consume || __order == memory_order::acquire || |
| ... | @@ -219,6 +223,9 @@ public: | ... | @@ -219,6 +223,9 @@ public: |
| 219 | } | 223 | } |
| 220 | _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { std::__atomic_notify_one(*this); } | 224 | _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { std::__atomic_notify_one(*this); } |
| 221 | _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); } | 225 | _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); } |
| 226 | # if _LIBCPP_STD_VER >= 26 | ||
| 227 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* address() const noexcept { return __ptr_; } | ||
| 228 | # endif | ||
| 222 | 229 | ||
| 223 | protected: | 230 | protected: |
| 224 | using _Aligned_Tp [[__gnu__::__aligned__(required_alignment), __gnu__::__nodebug__]] = _Tp; | 231 | using _Aligned_Tp [[__gnu__::__aligned__(required_alignment), __gnu__::__nodebug__]] = _Tp; |
| ... | @@ -229,6 +236,8 @@ protected: | ... | @@ -229,6 +236,8 @@ protected: |
| 229 | 236 | ||
| 230 | template <class _Tp> | 237 | template <class _Tp> |
| 231 | struct __atomic_waitable_traits<__atomic_ref_base<_Tp>> { | 238 | struct __atomic_waitable_traits<__atomic_ref_base<_Tp>> { |
| 239 | using __value_type _LIBCPP_NODEBUG = _Tp; | ||
| 240 | |||
| 232 | static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_ref_base<_Tp>& __a, memory_order __order) { | 241 | static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_ref_base<_Tp>& __a, memory_order __order) { |
| 233 | return __a.load(__order); | 242 | return __a.load(__order); |
| 234 | } | 243 | } |
| ... | @@ -322,20 +331,28 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { | ... | @@ -322,20 +331,28 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { |
| 322 | atomic_ref& operator=(const atomic_ref&) = delete; | 331 | atomic_ref& operator=(const atomic_ref&) = delete; |
| 323 | 332 | ||
| 324 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | 333 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { |
| 325 | _Tp __old = this->load(memory_order_relaxed); | 334 | if constexpr (std::__has_rmw_builtin<_Tp>()) { |
| 326 | _Tp __new = __old + __arg; | 335 | return __atomic_fetch_add(this->__ptr_, __arg, std::__to_gcc_order(__order)); |
| 327 | while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) { | 336 | } else { |
| 328 | __new = __old + __arg; | 337 | _Tp __old = this->load(memory_order_relaxed); |
| 338 | _Tp __new = __old + __arg; | ||
| 339 | while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) { | ||
| 340 | __new = __old + __arg; | ||
| 341 | } | ||
| 342 | return __old; | ||
| 329 | } | 343 | } |
| 330 | return __old; | ||
| 331 | } | 344 | } |
| 332 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { | 345 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept { |
| 333 | _Tp __old = this->load(memory_order_relaxed); | 346 | if constexpr (std::__has_rmw_builtin<_Tp>()) { |
| 334 | _Tp __new = __old - __arg; | 347 | return __atomic_fetch_sub(this->__ptr_, __arg, std::__to_gcc_order(__order)); |
| 335 | while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) { | 348 | } else { |
| 336 | __new = __old - __arg; | 349 | _Tp __old = this->load(memory_order_relaxed); |
| 350 | _Tp __new = __old - __arg; | ||
| 351 | while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) { | ||
| 352 | __new = __old - __arg; | ||
| 353 | } | ||
| 354 | return __old; | ||
| 337 | } | 355 | } |
| 338 | return __old; | ||
| 339 | } | 356 | } |
| 340 | 357 | ||
| 341 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __arg) const noexcept { return fetch_add(__arg) + __arg; } | 358 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __arg) const noexcept { return fetch_add(__arg) + __arg; } |
lib/libcxx/include/__atomic/atomic_sync.h+127-55| ... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ATOMIC_ATOMIC_SYNC_H | 9 | #ifndef _LIBCPP___ATOMIC_ATOMIC_SYNC_H |
| 10 | #define _LIBCPP___ATOMIC_ATOMIC_SYNC_H | 10 | #define _LIBCPP___ATOMIC_ATOMIC_SYNC_H |
| 11 | 11 | ||
| 12 | #include <__atomic/atomic_waitable_traits.h> | ||
| 12 | #include <__atomic/contention_t.h> | 13 | #include <__atomic/contention_t.h> |
| 13 | #include <__atomic/memory_order.h> | 14 | #include <__atomic/memory_order.h> |
| 14 | #include <__atomic/to_gcc_order.h> | 15 | #include <__atomic/to_gcc_order.h> |
| ... | @@ -19,6 +20,7 @@ | ... | @@ -19,6 +20,7 @@ |
| 19 | #include <__type_traits/conjunction.h> | 20 | #include <__type_traits/conjunction.h> |
| 20 | #include <__type_traits/decay.h> | 21 | #include <__type_traits/decay.h> |
| 21 | #include <__type_traits/invoke.h> | 22 | #include <__type_traits/invoke.h> |
| 23 | #include <__type_traits/is_same.h> | ||
| 22 | #include <__type_traits/void_t.h> | 24 | #include <__type_traits/void_t.h> |
| 23 | #include <__utility/declval.h> | 25 | #include <__utility/declval.h> |
| 24 | #include <cstring> | 26 | #include <cstring> |
| ... | @@ -29,50 +31,89 @@ | ... | @@ -29,50 +31,89 @@ |
| 29 | 31 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 33 | ||
| 32 | // The customisation points to enable the following functions: | ||
| 33 | // - __atomic_wait | ||
| 34 | // - __atomic_wait_unless | ||
| 35 | // - __atomic_notify_one | ||
| 36 | // - __atomic_notify_all | ||
| 37 | // Note that std::atomic<T>::wait was back-ported to C++03 | ||
| 38 | // The below implementations look ugly to support C++03 | ||
| 39 | template <class _Tp, class = void> | ||
| 40 | struct __atomic_waitable_traits { | ||
| 41 | template <class _AtomicWaitable> | ||
| 42 | static void __atomic_load(_AtomicWaitable&&, memory_order) = delete; | ||
| 43 | |||
| 44 | template <class _AtomicWaitable> | ||
| 45 | static void __atomic_contention_address(_AtomicWaitable&&) = delete; | ||
| 46 | }; | ||
| 47 | |||
| 48 | template <class _Tp, class = void> | ||
| 49 | struct __atomic_waitable : false_type {}; | ||
| 50 | |||
| 51 | template <class _Tp> | ||
| 52 | struct __atomic_waitable< _Tp, | ||
| 53 | __void_t<decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_load( | ||
| 54 | std::declval<const _Tp&>(), std::declval<memory_order>())), | ||
| 55 | decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_contention_address( | ||
| 56 | std::declval<const _Tp&>()))> > : true_type {}; | ||
| 57 | |||
| 58 | #if _LIBCPP_STD_VER >= 20 | 34 | #if _LIBCPP_STD_VER >= 20 |
| 59 | # if _LIBCPP_HAS_THREADS | 35 | # if _LIBCPP_HAS_THREADS |
| 60 | 36 | ||
| 61 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT; | 37 | # if !_LIBCPP_AVAILABILITY_HAS_NEW_SYNC |
| 62 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT; | 38 | |
| 63 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t | 39 | // old dylib interface kept for backwards compatibility |
| 64 | __libcpp_atomic_monitor(void const volatile*) _NOEXCEPT; | 40 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT; |
| 65 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 41 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT; |
| 66 | __libcpp_atomic_wait(void const volatile*, __cxx_contention_t) _NOEXCEPT; | 42 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile*) _NOEXCEPT; |
| 67 | 43 | _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile*, __cxx_contention_t) _NOEXCEPT; | |
| 68 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 44 | |
| 69 | __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; | 45 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; |
| 70 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 46 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; |
| 71 | __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; | 47 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t |
| 72 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t | ||
| 73 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; | 48 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*) _NOEXCEPT; |
| 74 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 49 | _LIBCPP_EXPORTED_FROM_ABI void |
| 75 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t) _NOEXCEPT; | 50 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t) _NOEXCEPT; |
| 51 | # endif // !_LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 52 | |||
| 53 | // new dylib interface | ||
| 54 | |||
| 55 | // return the global contention state's current value for the address | ||
| 56 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t | ||
| 57 | __atomic_monitor_global(void const* __address) _NOEXCEPT; | ||
| 58 | |||
| 59 | // wait on the global contention state to be changed from the given value for the address | ||
| 60 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void | ||
| 61 | __atomic_wait_global_table(void const* __address, __cxx_contention_t __monitor_value) _NOEXCEPT; | ||
| 62 | |||
| 63 | // notify one waiter waiting on the global contention state for the address | ||
| 64 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one_global_table(void const*) _NOEXCEPT; | ||
| 65 | |||
| 66 | // notify all waiters waiting on the global contention state for the address | ||
| 67 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_global_table(void const*) _NOEXCEPT; | ||
| 68 | |||
| 69 | // wait on the address directly with the native platform wait | ||
| 70 | template <std::size_t _Size> | ||
| 71 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void | ||
| 72 | __atomic_wait_native(void const* __address, void const* __old_value) _NOEXCEPT; | ||
| 73 | |||
| 74 | // notify one waiter waiting on the address directly with the native platform wait | ||
| 75 | template <std::size_t _Size> | ||
| 76 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one_native(const void*) _NOEXCEPT; | ||
| 77 | |||
| 78 | // notify all waiters waiting on the address directly with the native platform wait | ||
| 79 | template <std::size_t _Size> | ||
| 80 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_native(const void*) _NOEXCEPT; | ||
| 81 | |||
| 82 | # if _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 83 | |||
| 84 | template <class _AtomicWaitable, class _Poll> | ||
| 85 | struct __atomic_wait_backoff_impl { | ||
| 86 | const _AtomicWaitable& __a_; | ||
| 87 | _Poll __poll_; | ||
| 88 | memory_order __order_; | ||
| 89 | |||
| 90 | using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | ||
| 91 | using __value_type _LIBCPP_NODEBUG = typename __waitable_traits::__value_type; | ||
| 92 | |||
| 93 | _LIBCPP_HIDE_FROM_ABI __backoff_results operator()(chrono::nanoseconds __elapsed) const { | ||
| 94 | if (__elapsed > chrono::microseconds(4)) { | ||
| 95 | auto __contention_address = const_cast<const void*>( | ||
| 96 | static_cast<const volatile void*>(__waitable_traits::__atomic_contention_address(__a_))); | ||
| 97 | |||
| 98 | if constexpr (__has_native_atomic_wait<__value_type>) { | ||
| 99 | auto __atomic_value = __waitable_traits::__atomic_load(__a_, __order_); | ||
| 100 | if (__poll_(__atomic_value)) | ||
| 101 | return __backoff_results::__poll_success; | ||
| 102 | std::__atomic_wait_native<sizeof(__value_type)>(__contention_address, std::addressof(__atomic_value)); | ||
| 103 | } else { | ||
| 104 | __cxx_contention_t __monitor_val = std::__atomic_monitor_global(__contention_address); | ||
| 105 | auto __atomic_value = __waitable_traits::__atomic_load(__a_, __order_); | ||
| 106 | if (__poll_(__atomic_value)) | ||
| 107 | return __backoff_results::__poll_success; | ||
| 108 | std::__atomic_wait_global_table(__contention_address, __monitor_val); | ||
| 109 | } | ||
| 110 | } else { | ||
| 111 | } // poll | ||
| 112 | return __backoff_results::__continue_poll; | ||
| 113 | } | ||
| 114 | }; | ||
| 115 | |||
| 116 | # else // _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 76 | 117 | ||
| 77 | template <class _AtomicWaitable, class _Poll> | 118 | template <class _AtomicWaitable, class _Poll> |
| 78 | struct __atomic_wait_backoff_impl { | 119 | struct __atomic_wait_backoff_impl { |
| ... | @@ -82,7 +123,6 @@ struct __atomic_wait_backoff_impl { | ... | @@ -82,7 +123,6 @@ struct __atomic_wait_backoff_impl { |
| 82 | 123 | ||
| 83 | using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | 124 | using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; |
| 84 | 125 | ||
| 85 | _LIBCPP_AVAILABILITY_SYNC | ||
| 86 | _LIBCPP_HIDE_FROM_ABI bool | 126 | _LIBCPP_HIDE_FROM_ABI bool |
| 87 | __update_monitor_val_and_poll(__cxx_atomic_contention_t const volatile*, __cxx_contention_t& __monitor_val) const { | 127 | __update_monitor_val_and_poll(__cxx_atomic_contention_t const volatile*, __cxx_contention_t& __monitor_val) const { |
| 88 | // In case the contention type happens to be __cxx_atomic_contention_t, i.e. __cxx_atomic_impl<int64_t>, | 128 | // In case the contention type happens to be __cxx_atomic_contention_t, i.e. __cxx_atomic_impl<int64_t>, |
| ... | @@ -95,7 +135,6 @@ struct __atomic_wait_backoff_impl { | ... | @@ -95,7 +135,6 @@ struct __atomic_wait_backoff_impl { |
| 95 | return __poll_(__monitor_val); | 135 | return __poll_(__monitor_val); |
| 96 | } | 136 | } |
| 97 | 137 | ||
| 98 | _LIBCPP_AVAILABILITY_SYNC | ||
| 99 | _LIBCPP_HIDE_FROM_ABI bool | 138 | _LIBCPP_HIDE_FROM_ABI bool |
| 100 | __update_monitor_val_and_poll(void const volatile* __contention_address, __cxx_contention_t& __monitor_val) const { | 139 | __update_monitor_val_and_poll(void const volatile* __contention_address, __cxx_contention_t& __monitor_val) const { |
| 101 | // In case the contention type is anything else, platform wait is monitoring a __cxx_atomic_contention_t | 140 | // In case the contention type is anything else, platform wait is monitoring a __cxx_atomic_contention_t |
| ... | @@ -105,20 +144,21 @@ struct __atomic_wait_backoff_impl { | ... | @@ -105,20 +144,21 @@ struct __atomic_wait_backoff_impl { |
| 105 | return __poll_(__current_val); | 144 | return __poll_(__current_val); |
| 106 | } | 145 | } |
| 107 | 146 | ||
| 108 | _LIBCPP_AVAILABILITY_SYNC | 147 | _LIBCPP_HIDE_FROM_ABI __backoff_results operator()(chrono::nanoseconds __elapsed) const { |
| 109 | _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const { | ||
| 110 | if (__elapsed > chrono::microseconds(4)) { | 148 | if (__elapsed > chrono::microseconds(4)) { |
| 111 | auto __contention_address = __waitable_traits::__atomic_contention_address(__a_); | 149 | auto __contention_address = __waitable_traits::__atomic_contention_address(__a_); |
| 112 | __cxx_contention_t __monitor_val; | 150 | __cxx_contention_t __monitor_val; |
| 113 | if (__update_monitor_val_and_poll(__contention_address, __monitor_val)) | 151 | if (__update_monitor_val_and_poll(__contention_address, __monitor_val)) |
| 114 | return true; | 152 | return __backoff_results::__poll_success; |
| 115 | std::__libcpp_atomic_wait(__contention_address, __monitor_val); | 153 | std::__libcpp_atomic_wait(__contention_address, __monitor_val); |
| 116 | } else { | 154 | } else { |
| 117 | } // poll | 155 | } // poll |
| 118 | return false; | 156 | return __backoff_results::__continue_poll; |
| 119 | } | 157 | } |
| 120 | }; | 158 | }; |
| 121 | 159 | ||
| 160 | # endif // _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 161 | |||
| 122 | // The semantics of this function are similar to `atomic`'s | 162 | // The semantics of this function are similar to `atomic`'s |
| 123 | // `.wait(T old, std::memory_order order)`, but instead of having a hardcoded | 163 | // `.wait(T old, std::memory_order order)`, but instead of having a hardcoded |
| 124 | // predicate (is the loaded value unequal to `old`?), the predicate function is | 164 | // predicate (is the loaded value unequal to `old`?), the predicate function is |
| ... | @@ -128,9 +168,8 @@ struct __atomic_wait_backoff_impl { | ... | @@ -128,9 +168,8 @@ struct __atomic_wait_backoff_impl { |
| 128 | // `false`, it must set the argument to its current understanding of the atomic | 168 | // `false`, it must set the argument to its current understanding of the atomic |
| 129 | // value. The predicate function must not return `false` spuriously. | 169 | // value. The predicate function must not return `false` spuriously. |
| 130 | template <class _AtomicWaitable, class _Poll> | 170 | template <class _AtomicWaitable, class _Poll> |
| 131 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 171 | _LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& __poll) { |
| 132 | __atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& __poll) { | 172 | static_assert(__atomic_waitable<_AtomicWaitable>); |
| 133 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); | ||
| 134 | __atomic_wait_backoff_impl<_AtomicWaitable, __decay_t<_Poll> > __backoff_fn = {__a, __poll, __order}; | 173 | __atomic_wait_backoff_impl<_AtomicWaitable, __decay_t<_Poll> > __backoff_fn = {__a, __poll, __order}; |
| 135 | std::__libcpp_thread_poll_with_backoff( | 174 | std::__libcpp_thread_poll_with_backoff( |
| 136 | /* poll */ | 175 | /* poll */ |
| ... | @@ -141,18 +180,52 @@ __atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& _ | ... | @@ -141,18 +180,52 @@ __atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& _ |
| 141 | /* backoff */ __backoff_fn); | 180 | /* backoff */ __backoff_fn); |
| 142 | } | 181 | } |
| 143 | 182 | ||
| 183 | # if _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 184 | |||
| 144 | template <class _AtomicWaitable> | 185 | template <class _AtomicWaitable> |
| 145 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable& __a) { | 186 | _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable& __a) { |
| 146 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); | 187 | static_assert(__atomic_waitable<_AtomicWaitable>); |
| 188 | using __value_type _LIBCPP_NODEBUG = typename __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__value_type; | ||
| 189 | using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | ||
| 190 | auto __contention_address = | ||
| 191 | const_cast<const void*>(static_cast<const volatile void*>(__waitable_traits::__atomic_contention_address(__a))); | ||
| 192 | if constexpr (__has_native_atomic_wait<__value_type>) { | ||
| 193 | std::__atomic_notify_one_native<sizeof(__value_type)>(__contention_address); | ||
| 194 | } else { | ||
| 195 | std::__atomic_notify_one_global_table(__contention_address); | ||
| 196 | } | ||
| 197 | } | ||
| 198 | |||
| 199 | template <class _AtomicWaitable> | ||
| 200 | _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable& __a) { | ||
| 201 | static_assert(__atomic_waitable<_AtomicWaitable>); | ||
| 202 | using __value_type _LIBCPP_NODEBUG = typename __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__value_type; | ||
| 203 | using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | ||
| 204 | auto __contention_address = | ||
| 205 | const_cast<const void*>(static_cast<const volatile void*>(__waitable_traits::__atomic_contention_address(__a))); | ||
| 206 | if constexpr (__has_native_atomic_wait<__value_type>) { | ||
| 207 | std::__atomic_notify_all_native<sizeof(__value_type)>(__contention_address); | ||
| 208 | } else { | ||
| 209 | std::__atomic_notify_all_global_table(__contention_address); | ||
| 210 | } | ||
| 211 | } | ||
| 212 | |||
| 213 | # else // _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 214 | |||
| 215 | template <class _AtomicWaitable> | ||
| 216 | _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable& __a) { | ||
| 217 | static_assert(__atomic_waitable<_AtomicWaitable>); | ||
| 147 | std::__cxx_atomic_notify_one(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a)); | 218 | std::__cxx_atomic_notify_one(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a)); |
| 148 | } | 219 | } |
| 149 | 220 | ||
| 150 | template <class _AtomicWaitable> | 221 | template <class _AtomicWaitable> |
| 151 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable& __a) { | 222 | _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable& __a) { |
| 152 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); | 223 | static_assert(__atomic_waitable<_AtomicWaitable>); |
| 153 | std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a)); | 224 | std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a)); |
| 154 | } | 225 | } |
| 155 | 226 | ||
| 227 | # endif | ||
| 228 | |||
| 156 | # else // _LIBCPP_HAS_THREADS | 229 | # else // _LIBCPP_HAS_THREADS |
| 157 | 230 | ||
| 158 | template <class _AtomicWaitable, class _Poll> | 231 | template <class _AtomicWaitable, class _Poll> |
| ... | @@ -180,9 +253,8 @@ _LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp c | ... | @@ -180,9 +253,8 @@ _LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp c |
| 180 | } | 253 | } |
| 181 | 254 | ||
| 182 | template <class _AtomicWaitable, class _Tp> | 255 | template <class _AtomicWaitable, class _Tp> |
| 183 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | 256 | _LIBCPP_HIDE_FROM_ABI void __atomic_wait(_AtomicWaitable& __a, _Tp __val, memory_order __order) { |
| 184 | __atomic_wait(_AtomicWaitable& __a, _Tp __val, memory_order __order) { | 257 | static_assert(__atomic_waitable<_AtomicWaitable>); |
| 185 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); | ||
| 186 | std::__atomic_wait_unless(__a, __order, [&](_Tp const& __current) { | 258 | std::__atomic_wait_unless(__a, __order, [&](_Tp const& __current) { |
| 187 | return !std::__cxx_nonatomic_compare_equal(__current, __val); | 259 | return !std::__cxx_nonatomic_compare_equal(__current, __val); |
| 188 | }); | 260 | }); |
lib/libcxx/include/__atomic/atomic_sync_timed.h created+144| ... | @@ -0,0 +1,144 @@ | ||
| 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_ATOMIC_SYNC_TIMED_H | ||
| 10 | #define _LIBCPP___ATOMIC_ATOMIC_SYNC_TIMED_H | ||
| 11 | |||
| 12 | #include <__atomic/atomic_waitable_traits.h> | ||
| 13 | #include <__atomic/contention_t.h> | ||
| 14 | #include <__atomic/memory_order.h> | ||
| 15 | #include <__atomic/to_gcc_order.h> | ||
| 16 | #include <__chrono/duration.h> | ||
| 17 | #include <__config> | ||
| 18 | #include <__memory/addressof.h> | ||
| 19 | #include <__thread/poll_with_backoff.h> | ||
| 20 | #include <__thread/timed_backoff_policy.h> | ||
| 21 | #include <__type_traits/conjunction.h> | ||
| 22 | #include <__type_traits/decay.h> | ||
| 23 | #include <__type_traits/has_unique_object_representation.h> | ||
| 24 | #include <__type_traits/invoke.h> | ||
| 25 | #include <__type_traits/is_same.h> | ||
| 26 | #include <__type_traits/is_trivially_copyable.h> | ||
| 27 | #include <__type_traits/void_t.h> | ||
| 28 | #include <__utility/declval.h> | ||
| 29 | #include <cstdint> | ||
| 30 | #include <cstring> | ||
| 31 | |||
| 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 33 | # pragma GCC system_header | ||
| 34 | #endif | ||
| 35 | |||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 37 | |||
| 38 | #if _LIBCPP_STD_VER >= 20 | ||
| 39 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 40 | |||
| 41 | _LIBCPP_AVAILABILITY_NEW_SYNC | ||
| 42 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __atomic_monitor_global(void const* __address) _NOEXCEPT; | ||
| 43 | |||
| 44 | // wait on the global contention state to be changed from the given value for the address | ||
| 45 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_global_table_with_timeout( | ||
| 46 | void const* __address, __cxx_contention_t __monitor_value, uint64_t __timeout_ns) _NOEXCEPT; | ||
| 47 | |||
| 48 | // wait on the address directly with the native platform wait | ||
| 49 | template <std::size_t _Size> | ||
| 50 | _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void | ||
| 51 | __atomic_wait_native_with_timeout(void const* __address, void const* __old_value, uint64_t __timeout_ns) _NOEXCEPT; | ||
| 52 | |||
| 53 | template <class _AtomicWaitable, class _Poll, class _Rep, class _Period> | ||
| 54 | struct __atomic_wait_timed_backoff_impl { | ||
| 55 | const _AtomicWaitable& __a_; | ||
| 56 | _Poll __poll_; | ||
| 57 | memory_order __order_; | ||
| 58 | chrono::duration<_Rep, _Period> __rel_time_; | ||
| 59 | |||
| 60 | using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | ||
| 61 | using __value_type _LIBCPP_NODEBUG = typename __waitable_traits::__value_type; | ||
| 62 | |||
| 63 | _LIBCPP_HIDE_FROM_ABI __backoff_results operator()(chrono::nanoseconds __elapsed) const { | ||
| 64 | if (__elapsed > chrono::microseconds(4)) { | ||
| 65 | auto __contention_address = const_cast<const void*>( | ||
| 66 | static_cast<const volatile void*>(__waitable_traits::__atomic_contention_address(__a_))); | ||
| 67 | |||
| 68 | uint64_t __timeout_ns = | ||
| 69 | static_cast<uint64_t>((chrono::duration_cast<chrono::nanoseconds>(__rel_time_) - __elapsed).count()); | ||
| 70 | |||
| 71 | if constexpr (__has_native_atomic_wait<__value_type>) { | ||
| 72 | auto __atomic_value = __waitable_traits::__atomic_load(__a_, __order_); | ||
| 73 | if (__poll_(__atomic_value)) | ||
| 74 | return __backoff_results::__poll_success; | ||
| 75 | std::__atomic_wait_native_with_timeout<sizeof(__value_type)>( | ||
| 76 | __contention_address, std::addressof(__atomic_value), __timeout_ns); | ||
| 77 | } else { | ||
| 78 | __cxx_contention_t __monitor_val = std::__atomic_monitor_global(__contention_address); | ||
| 79 | auto __atomic_value = __waitable_traits::__atomic_load(__a_, __order_); | ||
| 80 | if (__poll_(__atomic_value)) | ||
| 81 | return __backoff_results::__poll_success; | ||
| 82 | std::__atomic_wait_global_table_with_timeout(__contention_address, __monitor_val, __timeout_ns); | ||
| 83 | } | ||
| 84 | } else { | ||
| 85 | } // poll | ||
| 86 | return __backoff_results::__continue_poll; | ||
| 87 | } | ||
| 88 | }; | ||
| 89 | |||
| 90 | // The semantics of this function are similar to `atomic`'s | ||
| 91 | // `.wait(T old, std::memory_order order)` with a timeout, but instead of having a hardcoded | ||
| 92 | // predicate (is the loaded value unequal to `old`?), the predicate function is | ||
| 93 | // specified as an argument. The loaded value is given as an in-out argument to | ||
| 94 | // the predicate. If the predicate function returns `true`, | ||
| 95 | // `__atomic_wait_unless_with_timeout` will return. If the predicate function returns | ||
| 96 | // `false`, it must set the argument to its current understanding of the atomic | ||
| 97 | // value. The predicate function must not return `false` spuriously. | ||
| 98 | template <class _AtomicWaitable, class _Poll, class _Rep, class _Period> | ||
| 99 | _LIBCPP_HIDE_FROM_ABI bool __atomic_wait_unless_with_timeout( | ||
| 100 | const _AtomicWaitable& __a, | ||
| 101 | memory_order __order, | ||
| 102 | _Poll&& __poll, | ||
| 103 | chrono::duration<_Rep, _Period> const& __rel_time) { | ||
| 104 | static_assert(__atomic_waitable<_AtomicWaitable>, ""); | ||
| 105 | __atomic_wait_timed_backoff_impl<_AtomicWaitable, __decay_t<_Poll>, _Rep, _Period> __backoff_fn = { | ||
| 106 | __a, __poll, __order, __rel_time}; | ||
| 107 | auto __poll_result = std::__libcpp_thread_poll_with_backoff( | ||
| 108 | /* poll */ | ||
| 109 | [&]() { | ||
| 110 | auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a, __order); | ||
| 111 | return __poll(__current_val); | ||
| 112 | }, | ||
| 113 | /* backoff */ __backoff_fn, | ||
| 114 | __rel_time); | ||
| 115 | |||
| 116 | return __poll_result == __poll_with_backoff_results::__poll_success; | ||
| 117 | } | ||
| 118 | |||
| 119 | # elif _LIBCPP_HAS_THREADS // _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 120 | |||
| 121 | template <class _AtomicWaitable, class _Poll, class _Rep, class _Period> | ||
| 122 | _LIBCPP_HIDE_FROM_ABI bool __atomic_wait_unless_with_timeout( | ||
| 123 | const _AtomicWaitable& __a, | ||
| 124 | memory_order __order, | ||
| 125 | _Poll&& __poll, | ||
| 126 | chrono::duration<_Rep, _Period> const& __rel_time) { | ||
| 127 | auto __res = std::__libcpp_thread_poll_with_backoff( | ||
| 128 | /* poll */ | ||
| 129 | [&]() { | ||
| 130 | auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a, __order); | ||
| 131 | return __poll(__current_val); | ||
| 132 | }, | ||
| 133 | /* backoff */ __libcpp_timed_backoff_policy(), | ||
| 134 | __rel_time); | ||
| 135 | return __res == __poll_with_backoff_results::__poll_success; | ||
| 136 | } | ||
| 137 | |||
| 138 | # endif // _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_NEW_SYNC | ||
| 139 | |||
| 140 | #endif // C++20 | ||
| 141 | |||
| 142 | _LIBCPP_END_NAMESPACE_STD | ||
| 143 | |||
| 144 | #endif // _LIBCPP___ATOMIC_ATOMIC_SYNC_TIMED_H | ||
lib/libcxx/include/__atomic/atomic_waitable_traits.h created+103| ... | @@ -0,0 +1,103 @@ | ||
| 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_ATOMIC_WAITABLE_TRAITS_H | ||
| 10 | #define _LIBCPP___ATOMIC_ATOMIC_WAITABLE_TRAITS_H | ||
| 11 | |||
| 12 | #include <__atomic/contention_t.h> | ||
| 13 | #include <__atomic/memory_order.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__type_traits/decay.h> | ||
| 16 | #include <__type_traits/has_unique_object_representation.h> | ||
| 17 | #include <__type_traits/is_same.h> | ||
| 18 | #include <__type_traits/is_trivially_copyable.h> | ||
| 19 | #include <__type_traits/void_t.h> | ||
| 20 | #include <__utility/declval.h> | ||
| 21 | #include <cstring> | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 24 | # pragma GCC system_header | ||
| 25 | #endif | ||
| 26 | |||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 28 | |||
| 29 | #if _LIBCPP_STD_VER >= 20 | ||
| 30 | |||
| 31 | // The customisation points to enable the following functions: | ||
| 32 | // - __atomic_wait | ||
| 33 | // - __atomic_wait_unless | ||
| 34 | // - __atomic_notify_one | ||
| 35 | // - __atomic_notify_all | ||
| 36 | template <class _Tp, class = void> | ||
| 37 | struct __atomic_waitable_traits { | ||
| 38 | using __value_type _LIBCPP_NODEBUG = void; | ||
| 39 | |||
| 40 | template <class _AtomicWaitable> | ||
| 41 | static void __atomic_load(_AtomicWaitable&&, memory_order) = delete; | ||
| 42 | |||
| 43 | template <class _AtomicWaitable> | ||
| 44 | static void __atomic_contention_address(_AtomicWaitable&&) = delete; | ||
| 45 | }; | ||
| 46 | |||
| 47 | template <class _Tp> | ||
| 48 | concept __atomic_waitable = requires(const _Tp __t, memory_order __order) { | ||
| 49 | typename __atomic_waitable_traits<__decay_t<_Tp> >::__value_type; | ||
| 50 | { __atomic_waitable_traits<__decay_t<_Tp> >::__atomic_load(__t, __order) }; | ||
| 51 | { __atomic_waitable_traits<__decay_t<_Tp> >::__atomic_contention_address(__t) }; | ||
| 52 | }; | ||
| 53 | |||
| 54 | # ifdef __linux__ | ||
| 55 | # define _LIBCPP_NATIVE_PLATFORM_WAIT_SIZES(_APPLY) _APPLY(4) | ||
| 56 | # elif defined(__APPLE__) | ||
| 57 | # define _LIBCPP_NATIVE_PLATFORM_WAIT_SIZES(_APPLY) \ | ||
| 58 | _APPLY(4) \ | ||
| 59 | _APPLY(8) | ||
| 60 | # elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8 | ||
| 61 | # define _LIBCPP_NATIVE_PLATFORM_WAIT_SIZES(_APPLY) _APPLY(8) | ||
| 62 | # elif defined(_WIN32) | ||
| 63 | # define _LIBCPP_NATIVE_PLATFORM_WAIT_SIZES(_APPLY) _APPLY(8) | ||
| 64 | # else | ||
| 65 | # define _LIBCPP_NATIVE_PLATFORM_WAIT_SIZES(_APPLY) _APPLY(sizeof(__cxx_contention_t)) | ||
| 66 | # endif // __linux__ | ||
| 67 | |||
| 68 | // concepts defines the types are supported natively by the platform's wait | ||
| 69 | |||
| 70 | # if defined(_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE) | ||
| 71 | |||
| 72 | template <class _Tp> | ||
| 73 | _LIBCPP_HIDE_FROM_ABI constexpr bool __has_native_atomic_wait_impl() { | ||
| 74 | if (alignof(_Tp) % sizeof(_Tp) != 0) | ||
| 75 | return false; | ||
| 76 | switch (sizeof(_Tp)) { | ||
| 77 | # define _LIBCPP_MAKE_CASE(n) \ | ||
| 78 | case n: \ | ||
| 79 | return true; | ||
| 80 | _LIBCPP_NATIVE_PLATFORM_WAIT_SIZES(_LIBCPP_MAKE_CASE) | ||
| 81 | default: | ||
| 82 | return false; | ||
| 83 | # undef _LIBCPP_MAKE_CASE | ||
| 84 | }; | ||
| 85 | } | ||
| 86 | |||
| 87 | template <class _Tp> | ||
| 88 | concept __has_native_atomic_wait = | ||
| 89 | has_unique_object_representations_v<_Tp> && is_trivially_copyable_v<_Tp> && | ||
| 90 | std::__has_native_atomic_wait_impl<_Tp>(); | ||
| 91 | |||
| 92 | # else // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE | ||
| 93 | |||
| 94 | template <class _Tp> | ||
| 95 | concept __has_native_atomic_wait = is_same_v<_Tp, __cxx_contention_t>; | ||
| 96 | |||
| 97 | # endif // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE | ||
| 98 | |||
| 99 | #endif // C++20 | ||
| 100 | |||
| 101 | _LIBCPP_END_NAMESPACE_STD | ||
| 102 | |||
| 103 | #endif // _LIBCPP___ATOMIC_ATOMIC_WAITABLE_TRAITS_H | ||
lib/libcxx/include/__atomic/contention_t.h+27-3| ... | @@ -19,11 +19,35 @@ | ... | @@ -19,11 +19,35 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__)) | 22 | // The original definition of `__cxx_contention_t` seemed a bit arbitrary. |
| 23 | // When we enable the _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE ABI, | ||
| 24 | // use definitions that are based on what the underlying platform supports | ||
| 25 | // instead. | ||
| 26 | #if defined(_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE) | ||
| 27 | |||
| 28 | # ifdef __linux__ | ||
| 29 | using __cxx_contention_t _LIBCPP_NODEBUG = int32_t; | ||
| 30 | # elif defined(__APPLE__) | ||
| 31 | using __cxx_contention_t _LIBCPP_NODEBUG = int64_t; | ||
| 32 | # elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8 | ||
| 33 | using __cxx_contention_t _LIBCPP_NODEBUG = int64_t; | ||
| 34 | # elif defined(_AIX) && !defined(__64BIT__) | ||
| 35 | using __cxx_contention_t _LIBCPP_NODEBUG = int32_t; | ||
| 36 | # elif defined(_WIN32) | ||
| 37 | using __cxx_contention_t _LIBCPP_NODEBUG = int64_t; | ||
| 38 | # else | ||
| 39 | using __cxx_contention_t _LIBCPP_NODEBUG = int64_t; | ||
| 40 | # endif // __linux__ | ||
| 41 | |||
| 42 | #else // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE | ||
| 43 | |||
| 44 | # if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__)) | ||
| 23 | using __cxx_contention_t _LIBCPP_NODEBUG = int32_t; | 45 | using __cxx_contention_t _LIBCPP_NODEBUG = int32_t; |
| 24 | #else | 46 | # else |
| 25 | using __cxx_contention_t _LIBCPP_NODEBUG = int64_t; | 47 | using __cxx_contention_t _LIBCPP_NODEBUG = int64_t; |
| 26 | #endif // __linux__ || (_AIX && !__64BIT__) | 48 | # endif // __linux__ || (_AIX && !__64BIT__) |
| 49 | |||
| 50 | #endif // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE | ||
| 27 | 51 | ||
| 28 | using __cxx_atomic_contention_t _LIBCPP_NODEBUG = __cxx_atomic_impl<__cxx_contention_t>; | 52 | using __cxx_atomic_contention_t _LIBCPP_NODEBUG = __cxx_atomic_impl<__cxx_contention_t>; |
| 29 | 53 |
lib/libcxx/include/__atomic/floating_point_helper.h created+55| ... | @@ -0,0 +1,55 @@ | ||
| 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_FLOATING_POINT_HELPER_H | ||
| 10 | #define _LIBCPP___ATOMIC_FLOATING_POINT_HELPER_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/is_floating_point.h> | ||
| 14 | #include <__type_traits/is_same.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 | |||
| 24 | template <class _Tp> | ||
| 25 | _LIBCPP_HIDE_FROM_ABI constexpr bool __is_fp80_long_double() { | ||
| 26 | // Only x87-fp80 long double has 64-bit mantissa | ||
| 27 | return __LDBL_MANT_DIG__ == 64 && std::is_same_v<_Tp, long double>; | ||
| 28 | } | ||
| 29 | |||
| 30 | template <class _Tp> | ||
| 31 | _LIBCPP_HIDE_FROM_ABI constexpr bool __has_rmw_builtin() { | ||
| 32 | static_assert(std::is_floating_point_v<_Tp>); | ||
| 33 | # ifndef _LIBCPP_COMPILER_CLANG_BASED | ||
| 34 | return false; | ||
| 35 | # else | ||
| 36 | // The builtin __cxx_atomic_fetch_add errors during compilation for | ||
| 37 | // long double on platforms with fp80 format. | ||
| 38 | // For more details, see | ||
| 39 | // lib/Sema/SemaChecking.cpp function IsAllowedValueType | ||
| 40 | // LLVM Parser does not allow atomicrmw with x86_fp80 type. | ||
| 41 | // if (ValType->isSpecificBuiltinType(BuiltinType::LongDouble) && | ||
| 42 | // &Context.getTargetInfo().getLongDoubleFormat() == | ||
| 43 | // &llvm::APFloat::x87DoubleExtended()) | ||
| 44 | // For more info | ||
| 45 | // https://llvm.org/PR68602 | ||
| 46 | // https://reviews.llvm.org/D53965 | ||
| 47 | return !std::__is_fp80_long_double<_Tp>(); | ||
| 48 | # endif | ||
| 49 | } | ||
| 50 | |||
| 51 | #endif | ||
| 52 | |||
| 53 | _LIBCPP_END_NAMESPACE_STD | ||
| 54 | |||
| 55 | #endif // _LIBCPP___ATOMIC_FLOATING_POINT_HELPER_H | ||
lib/libcxx/include/__bit/countl.h+1-2| ... | @@ -24,7 +24,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,7 +24,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | ||
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { | 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { |
| 27 | static_assert(__is_unsigned_integer_v<_Tp>, "__countl_zero requires an unsigned integer type"); | ||
| 28 | return __builtin_clzg(__t, numeric_limits<_Tp>::digits); | 27 | return __builtin_clzg(__t, numeric_limits<_Tp>::digits); |
| 29 | } | 28 | } |
| 30 | 29 | ||
| ... | @@ -37,7 +36,7 @@ template <__unsigned_integer _Tp> | ... | @@ -37,7 +36,7 @@ template <__unsigned_integer _Tp> |
| 37 | 36 | ||
| 38 | template <__unsigned_integer _Tp> | 37 | template <__unsigned_integer _Tp> |
| 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { | 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { |
| 40 | return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | 39 | return std::countl_zero(static_cast<_Tp>(~__t)); |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | #endif // _LIBCPP_STD_VER >= 20 | 42 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__bit/countr.h+1-2| ... | @@ -24,7 +24,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,7 +24,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | ||
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| 26 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT { | 26 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT { |
| 27 | static_assert(__is_unsigned_integer_v<_Tp>, "__countr_zero only works with unsigned types"); | ||
| 28 | return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); | 27 | return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); |
| 29 | } | 28 | } |
| 30 | 29 | ||
| ... | @@ -37,7 +36,7 @@ template <__unsigned_integer _Tp> | ... | @@ -37,7 +36,7 @@ template <__unsigned_integer _Tp> |
| 37 | 36 | ||
| 38 | template <__unsigned_integer _Tp> | 37 | template <__unsigned_integer _Tp> |
| 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { | 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { |
| 40 | return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | 39 | return std::countr_zero(static_cast<_Tp>(~__t)); |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | #endif // _LIBCPP_STD_VER >= 20 | 42 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__bit/has_single_bit.h+1-1| ... | @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | template <__unsigned_integer _Tp> | 26 | template <__unsigned_integer _Tp> |
| 27 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept { | 27 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept { |
| 28 | return __t != 0 && (((__t & (__t - 1)) == 0)); | 28 | return __builtin_popcountg(__t) == 1; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | 31 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__bit/popcount.h-1| ... | @@ -23,7 +23,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +23,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | template <class _Tp> | 24 | template <class _Tp> |
| 25 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT { | 25 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT { |
| 26 | static_assert(__is_unsigned_integer_v<_Tp>, "__popcount only works with unsigned types"); | ||
| 27 | return __builtin_popcountg(__t); | 26 | return __builtin_popcountg(__t); |
| 28 | } | 27 | } |
| 29 | 28 |
lib/libcxx/include/__bit/rotate.h+15-26| ... | @@ -22,46 +22,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,46 +22,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | // Writing two full functions for rotl and rotr makes it easier for the compiler | 22 | // Writing two full functions for rotl and rotr makes it easier for the compiler |
| 23 | // to optimize the code. On x86 this function becomes the ROL instruction and | 23 | // to optimize the code. On x86 this function becomes the ROL instruction and |
| 24 | // the rotr function becomes the ROR instruction. | 24 | // the rotr function becomes the ROR instruction. |
| 25 | template <class _Tp> | 25 | |
| 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT { | 26 | #if _LIBCPP_STD_VER >= 20 |
| 27 | static_assert(__is_unsigned_integer_v<_Tp>, "__rotl requires an unsigned integer type"); | 27 | |
| 28 | template <__unsigned_integer _Tp> | ||
| 29 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept { | ||
| 28 | const int __n = numeric_limits<_Tp>::digits; | 30 | const int __n = numeric_limits<_Tp>::digits; |
| 29 | int __r = __s % __n; | 31 | int __r = __cnt % __n; |
| 30 | 32 | ||
| 31 | if (__r == 0) | 33 | if (__r == 0) |
| 32 | return __x; | 34 | return __t; |
| 33 | 35 | ||
| 34 | if (__r > 0) | 36 | if (__r > 0) |
| 35 | return (__x << __r) | (__x >> (__n - __r)); | 37 | return (__t << __r) | (__t >> (__n - __r)); |
| 36 | 38 | ||
| 37 | return (__x >> -__r) | (__x << (__n + __r)); | 39 | return (__t >> -__r) | (__t << (__n + __r)); |
| 38 | } | 40 | } |
| 39 | 41 | ||
| 40 | template <class _Tp> | 42 | template <__unsigned_integer _Tp> |
| 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT { | 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept { |
| 42 | static_assert(__is_unsigned_integer_v<_Tp>, "__rotr requires an unsigned integer type"); | ||
| 43 | const int __n = numeric_limits<_Tp>::digits; | 44 | const int __n = numeric_limits<_Tp>::digits; |
| 44 | int __r = __s % __n; | 45 | int __r = __cnt % __n; |
| 45 | 46 | ||
| 46 | if (__r == 0) | 47 | if (__r == 0) |
| 47 | return __x; | 48 | return __t; |
| 48 | 49 | ||
| 49 | if (__r > 0) | 50 | if (__r > 0) |
| 50 | return (__x >> __r) | (__x << (__n - __r)); | 51 | return (__t >> __r) | (__t << (__n - __r)); |
| 51 | |||
| 52 | return (__x << -__r) | (__x >> (__n + __r)); | ||
| 53 | } | ||
| 54 | 52 | ||
| 55 | #if _LIBCPP_STD_VER >= 20 | 53 | return (__t << -__r) | (__t >> (__n + __r)); |
| 56 | |||
| 57 | template <__unsigned_integer _Tp> | ||
| 58 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept { | ||
| 59 | return std::__rotl(__t, __cnt); | ||
| 60 | } | ||
| 61 | |||
| 62 | template <__unsigned_integer _Tp> | ||
| 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept { | ||
| 64 | return std::__rotr(__t, __cnt); | ||
| 65 | } | 54 | } |
| 66 | 55 | ||
| 67 | #endif // _LIBCPP_STD_VER >= 20 | 56 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__bit_reference+207-18| ... | @@ -15,8 +15,10 @@ | ... | @@ -15,8 +15,10 @@ |
| 15 | #include <__algorithm/copy_backward.h> | 15 | #include <__algorithm/copy_backward.h> |
| 16 | #include <__algorithm/copy_n.h> | 16 | #include <__algorithm/copy_n.h> |
| 17 | #include <__algorithm/equal.h> | 17 | #include <__algorithm/equal.h> |
| 18 | #include <__algorithm/fill_n.h> | ||
| 18 | #include <__algorithm/min.h> | 19 | #include <__algorithm/min.h> |
| 19 | #include <__algorithm/rotate.h> | 20 | #include <__algorithm/rotate.h> |
| 21 | #include <__algorithm/specialized_algorithms.h> | ||
| 20 | #include <__algorithm/swap_ranges.h> | 22 | #include <__algorithm/swap_ranges.h> |
| 21 | #include <__assert> | 23 | #include <__assert> |
| 22 | #include <__bit/countr.h> | 24 | #include <__bit/countr.h> |
| ... | @@ -137,7 +139,7 @@ public: | ... | @@ -137,7 +139,7 @@ public: |
| 137 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator bool() const _NOEXCEPT { | 139 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator bool() const _NOEXCEPT { |
| 138 | return static_cast<bool>(*__seg_ & __mask_); | 140 | return static_cast<bool>(*__seg_ & __mask_); |
| 139 | } | 141 | } |
| 140 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator~() const _NOEXCEPT { | 142 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator~() const _NOEXCEPT { |
| 141 | return !static_cast<bool>(*this); | 143 | return !static_cast<bool>(*this); |
| 142 | } | 144 | } |
| 143 | 145 | ||
| ... | @@ -307,6 +309,15 @@ public: | ... | @@ -307,6 +309,15 @@ public: |
| 307 | { | 309 | { |
| 308 | } | 310 | } |
| 309 | 311 | ||
| 312 | #ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_BIT_ITERATOR | ||
| 313 | template <bool _IsConstDep = _IsConst, __enable_if_t<_IsConstDep, int> = 0> | ||
| 314 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT | ||
| 315 | : __seg_(__it.__seg_), | ||
| 316 | __ctz_(__it.__ctz_) {} | ||
| 317 | |||
| 318 | _LIBCPP_HIDE_FROM_ABI __bit_iterator(const __bit_iterator&) = default; | ||
| 319 | _LIBCPP_HIDE_FROM_ABI __bit_iterator& operator=(const __bit_iterator&) = default; | ||
| 320 | #else | ||
| 310 | // When _IsConst=false, this is the copy constructor. | 321 | // When _IsConst=false, this is the copy constructor. |
| 311 | // It is non-trivial. Making it trivial would break ABI. | 322 | // It is non-trivial. Making it trivial would break ABI. |
| 312 | // When _IsConst=true, this is a converting constructor; | 323 | // When _IsConst=true, this is a converting constructor; |
| ... | @@ -327,6 +338,7 @@ public: | ... | @@ -327,6 +338,7 @@ public: |
| 327 | __ctz_ = __it.__ctz_; | 338 | __ctz_ = __it.__ctz_; |
| 328 | return *this; | 339 | return *this; |
| 329 | } | 340 | } |
| 341 | #endif | ||
| 330 | 342 | ||
| 331 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT { | 343 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT { |
| 332 | _LIBCPP_ASSERT_INTERNAL(__ctz_ < __bits_per_word, "Dereferencing an invalid __bit_iterator."); | 344 | _LIBCPP_ASSERT_INTERNAL(__ctz_ < __bits_per_word, "Dereferencing an invalid __bit_iterator."); |
| ... | @@ -467,20 +479,6 @@ private: | ... | @@ -467,20 +479,6 @@ private: |
| 467 | template <class _Dp> | 479 | template <class _Dp> |
| 468 | friend struct __bit_array; | 480 | friend struct __bit_array; |
| 469 | 481 | ||
| 470 | template <bool _FillVal, class _Dp> | ||
| 471 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void | ||
| 472 | __fill_n_bool(__bit_iterator<_Dp, false> __first, typename __size_difference_type_traits<_Dp>::size_type __n); | ||
| 473 | |||
| 474 | template <class _Dp, bool _IC> | ||
| 475 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned( | ||
| 476 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | ||
| 477 | template <class _Dp, bool _IC> | ||
| 478 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_unaligned( | ||
| 479 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | ||
| 480 | template <class _Dp, bool _IC> | ||
| 481 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Dp, _IC>, __bit_iterator<_Dp, false> > | ||
| 482 | __copy_impl::operator()( | ||
| 483 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result) const; | ||
| 484 | template <class _Dp, bool _IC> | 482 | template <class _Dp, bool _IC> |
| 485 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_aligned( | 483 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_aligned( |
| 486 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | 484 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); |
| ... | @@ -511,10 +509,20 @@ private: | ... | @@ -511,10 +509,20 @@ private: |
| 511 | bool _IsConst1, | 509 | bool _IsConst1, |
| 512 | bool _IsConst2, | 510 | bool _IsConst2, |
| 513 | class _BinaryPredicate, | 511 | class _BinaryPredicate, |
| 514 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, int> > | 512 | class _Proj1, |
| 513 | class _Proj2, | ||
| 514 | __enable_if_t<__is_identity<_Proj1>::value && __is_identity<_Proj2>::value && | ||
| 515 | __desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, | ||
| 516 | int> > | ||
| 515 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool __equal_iter_impl( | 517 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool __equal_iter_impl( |
| 516 | __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst2>, _BinaryPredicate); | 518 | __bit_iterator<_Dp, _IsConst1>, |
| 517 | template <class _Dp, | 519 | __bit_iterator<_Dp, _IsConst1>, |
| 520 | __bit_iterator<_Dp, _IsConst2>, | ||
| 521 | _BinaryPredicate, | ||
| 522 | _Proj1&, | ||
| 523 | _Proj2&); | ||
| 524 | template <bool, | ||
| 525 | class _Dp, | ||
| 518 | bool _IsConst1, | 526 | bool _IsConst1, |
| 519 | bool _IsConst2, | 527 | bool _IsConst2, |
| 520 | class _Pred, | 528 | class _Pred, |
| ... | @@ -537,6 +545,187 @@ private: | ... | @@ -537,6 +545,187 @@ private: |
| 537 | template <bool _ToCount, class _Dp, bool _IC> | 545 | template <bool _ToCount, class _Dp, bool _IC> |
| 538 | friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 546 | friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 539 | __count_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type); | 547 | __count_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type); |
| 548 | |||
| 549 | template <class, class...> | ||
| 550 | friend struct __specialized_algorithm; | ||
| 551 | }; | ||
| 552 | |||
| 553 | template <class _Cp> | ||
| 554 | struct __specialized_algorithm<_Algorithm::__fill_n, __single_iterator<__bit_iterator<_Cp, false> > > { | ||
| 555 | static const bool __has_algorithm = true; | ||
| 556 | |||
| 557 | template <bool _FillVal> | ||
| 558 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void | ||
| 559 | __impl(__bit_iterator<_Cp, false> __first, typename __size_difference_type_traits<_Cp>::size_type __n) { | ||
| 560 | using _It = __bit_iterator<_Cp, false>; | ||
| 561 | using __storage_type = typename _It::__storage_type; | ||
| 562 | |||
| 563 | const int __bits_per_word = _It::__bits_per_word; | ||
| 564 | // do first partial word | ||
| 565 | if (__first.__ctz_ != 0) { | ||
| 566 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); | ||
| 567 | __storage_type __dn = std::min(__clz_f, __n); | ||
| 568 | std::__fill_masked_range(std::__to_address(__first.__seg_), __clz_f - __dn, __first.__ctz_, _FillVal); | ||
| 569 | __n -= __dn; | ||
| 570 | ++__first.__seg_; | ||
| 571 | } | ||
| 572 | // do middle whole words | ||
| 573 | __storage_type __nw = __n / __bits_per_word; | ||
| 574 | std::__fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0); | ||
| 575 | __n -= __nw * __bits_per_word; | ||
| 576 | // do last partial word | ||
| 577 | if (__n > 0) { | ||
| 578 | __first.__seg_ += __nw; | ||
| 579 | std::__fill_masked_range(std::__to_address(__first.__seg_), __bits_per_word - __n, 0u, _FillVal); | ||
| 580 | } | ||
| 581 | } | ||
| 582 | |||
| 583 | template <class _Size, class _Tp> | ||
| 584 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static __bit_iterator<_Cp, false> | ||
| 585 | operator()(__bit_iterator<_Cp, false> __first, _Size __n, const _Tp& __value) { | ||
| 586 | if (__n > 0) { | ||
| 587 | if (__value) | ||
| 588 | __impl<true>(__first, __n); | ||
| 589 | else | ||
| 590 | __impl<false>(__first, __n); | ||
| 591 | } | ||
| 592 | return __first + __n; | ||
| 593 | } | ||
| 594 | }; | ||
| 595 | |||
| 596 | template <class _Cp, bool _IsConst> | ||
| 597 | struct __specialized_algorithm<_Algorithm::__copy, | ||
| 598 | __iterator_pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, _IsConst> >, | ||
| 599 | __single_iterator<__bit_iterator<_Cp, false> > > { | ||
| 600 | static const bool __has_algorithm = true; | ||
| 601 | |||
| 602 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static __bit_iterator<_Cp, false> | ||
| 603 | __aligned_impl(__bit_iterator<_Cp, _IsConst> __first, | ||
| 604 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 605 | __bit_iterator<_Cp, false> __result) { | ||
| 606 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 607 | using difference_type = typename _In::difference_type; | ||
| 608 | using __storage_type = typename _In::__storage_type; | ||
| 609 | |||
| 610 | const int __bits_per_word = _In::__bits_per_word; | ||
| 611 | difference_type __n = __last - __first; | ||
| 612 | if (__n > 0) { | ||
| 613 | // do first word | ||
| 614 | if (__first.__ctz_ != 0) { | ||
| 615 | unsigned __clz = __bits_per_word - __first.__ctz_; | ||
| 616 | difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); | ||
| 617 | __n -= __dn; | ||
| 618 | __storage_type __m = std::__middle_mask<__storage_type>(__clz - __dn, __first.__ctz_); | ||
| 619 | __storage_type __b = *__first.__seg_ & __m; | ||
| 620 | *__result.__seg_ &= ~__m; | ||
| 621 | *__result.__seg_ |= __b; | ||
| 622 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 623 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 624 | ++__first.__seg_; | ||
| 625 | // __first.__ctz_ = 0; | ||
| 626 | } | ||
| 627 | // __first.__ctz_ == 0; | ||
| 628 | // do middle words | ||
| 629 | __storage_type __nw = __n / __bits_per_word; | ||
| 630 | std::copy(std::__to_address(__first.__seg_), | ||
| 631 | std::__to_address(__first.__seg_ + __nw), | ||
| 632 | std::__to_address(__result.__seg_)); | ||
| 633 | __n -= __nw * __bits_per_word; | ||
| 634 | __result.__seg_ += __nw; | ||
| 635 | // do last word | ||
| 636 | if (__n > 0) { | ||
| 637 | __first.__seg_ += __nw; | ||
| 638 | __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 639 | __storage_type __b = *__first.__seg_ & __m; | ||
| 640 | *__result.__seg_ &= ~__m; | ||
| 641 | *__result.__seg_ |= __b; | ||
| 642 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 643 | } | ||
| 644 | } | ||
| 645 | return __result; | ||
| 646 | } | ||
| 647 | |||
| 648 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static __bit_iterator<_Cp, false> | ||
| 649 | __unaligned_impl(__bit_iterator<_Cp, _IsConst> __first, | ||
| 650 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 651 | __bit_iterator<_Cp, false> __result) { | ||
| 652 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 653 | using difference_type = typename _In::difference_type; | ||
| 654 | using __storage_type = typename _In::__storage_type; | ||
| 655 | |||
| 656 | const int __bits_per_word = _In::__bits_per_word; | ||
| 657 | difference_type __n = __last - __first; | ||
| 658 | if (__n > 0) { | ||
| 659 | // do first word | ||
| 660 | if (__first.__ctz_ != 0) { | ||
| 661 | unsigned __clz_f = __bits_per_word - __first.__ctz_; | ||
| 662 | difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); | ||
| 663 | __n -= __dn; | ||
| 664 | __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first.__ctz_); | ||
| 665 | __storage_type __b = *__first.__seg_ & __m; | ||
| 666 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 667 | __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); | ||
| 668 | __m = std::__middle_mask<__storage_type>(__clz_r - __ddn, __result.__ctz_); | ||
| 669 | *__result.__seg_ &= ~__m; | ||
| 670 | if (__result.__ctz_ > __first.__ctz_) | ||
| 671 | *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); | ||
| 672 | else | ||
| 673 | *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); | ||
| 674 | __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; | ||
| 675 | __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); | ||
| 676 | __dn -= __ddn; | ||
| 677 | if (__dn > 0) { | ||
| 678 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __dn); | ||
| 679 | *__result.__seg_ &= ~__m; | ||
| 680 | *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); | ||
| 681 | __result.__ctz_ = static_cast<unsigned>(__dn); | ||
| 682 | } | ||
| 683 | ++__first.__seg_; | ||
| 684 | // __first.__ctz_ = 0; | ||
| 685 | } | ||
| 686 | // __first.__ctz_ == 0; | ||
| 687 | // do middle words | ||
| 688 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 689 | __storage_type __m = std::__leading_mask<__storage_type>(__result.__ctz_); | ||
| 690 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) { | ||
| 691 | __storage_type __b = *__first.__seg_; | ||
| 692 | *__result.__seg_ &= ~__m; | ||
| 693 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 694 | ++__result.__seg_; | ||
| 695 | *__result.__seg_ &= __m; | ||
| 696 | *__result.__seg_ |= __b >> __clz_r; | ||
| 697 | } | ||
| 698 | // do last word | ||
| 699 | if (__n > 0) { | ||
| 700 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 701 | __storage_type __b = *__first.__seg_ & __m; | ||
| 702 | __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r)); | ||
| 703 | __m = std::__middle_mask<__storage_type>(__clz_r - __dn, __result.__ctz_); | ||
| 704 | *__result.__seg_ &= ~__m; | ||
| 705 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 706 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 707 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 708 | __n -= __dn; | ||
| 709 | if (__n > 0) { | ||
| 710 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 711 | *__result.__seg_ &= ~__m; | ||
| 712 | *__result.__seg_ |= __b >> __dn; | ||
| 713 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 714 | } | ||
| 715 | } | ||
| 716 | } | ||
| 717 | return __result; | ||
| 718 | } | ||
| 719 | |||
| 720 | _LIBCPP_HIDE_FROM_ABI | ||
| 721 | _LIBCPP_CONSTEXPR_SINCE_CXX20 static pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> > | ||
| 722 | operator()(__bit_iterator<_Cp, _IsConst> __first, | ||
| 723 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 724 | __bit_iterator<_Cp, false> __result) { | ||
| 725 | if (__first.__ctz_ == __result.__ctz_) | ||
| 726 | return std::make_pair(__last, __aligned_impl(__first, __last, __result)); | ||
| 727 | return std::make_pair(__last, __unaligned_impl(__first, __last, __result)); | ||
| 728 | } | ||
| 540 | }; | 729 | }; |
| 541 | 730 | ||
| 542 | _LIBCPP_END_NAMESPACE_STD | 731 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__charconv/from_chars_integral.h+1-1| ... | @@ -18,8 +18,8 @@ | ... | @@ -18,8 +18,8 @@ |
| 18 | #include <__memory/addressof.h> | 18 | #include <__memory/addressof.h> |
| 19 | #include <__system_error/errc.h> | 19 | #include <__system_error/errc.h> |
| 20 | #include <__type_traits/enable_if.h> | 20 | #include <__type_traits/enable_if.h> |
| 21 | #include <__type_traits/integral_constant.h> | ||
| 22 | #include <__type_traits/is_integral.h> | 21 | #include <__type_traits/is_integral.h> |
| 22 | #include <__type_traits/is_signed.h> | ||
| 23 | #include <__type_traits/is_unsigned.h> | 23 | #include <__type_traits/is_unsigned.h> |
| 24 | #include <__type_traits/make_unsigned.h> | 24 | #include <__type_traits/make_unsigned.h> |
| 25 | #include <limits> | 25 | #include <limits> |
lib/libcxx/include/__charconv/from_chars_result.h+1-1| ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if _LIBCPP_STD_VER >= 17 | 22 | #if _LIBCPP_STD_VER >= 17 |
| 23 | 23 | ||
| 24 | struct _LIBCPP_EXPORTED_FROM_ABI from_chars_result { | 24 | struct from_chars_result { |
| 25 | const char* ptr; | 25 | const char* ptr; |
| 26 | errc ec; | 26 | errc ec; |
| 27 | # if _LIBCPP_STD_VER >= 20 | 27 | # if _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__charconv/to_chars_integral.h+1| ... | @@ -24,6 +24,7 @@ | ... | @@ -24,6 +24,7 @@ |
| 24 | #include <__type_traits/integral_constant.h> | 24 | #include <__type_traits/integral_constant.h> |
| 25 | #include <__type_traits/is_integral.h> | 25 | #include <__type_traits/is_integral.h> |
| 26 | #include <__type_traits/is_same.h> | 26 | #include <__type_traits/is_same.h> |
| 27 | #include <__type_traits/is_signed.h> | ||
| 27 | #include <__type_traits/make_32_64_or_128_bit.h> | 28 | #include <__type_traits/make_32_64_or_128_bit.h> |
| 28 | #include <__type_traits/make_unsigned.h> | 29 | #include <__type_traits/make_unsigned.h> |
| 29 | #include <__utility/unreachable.h> | 30 | #include <__utility/unreachable.h> |
lib/libcxx/include/__charconv/to_chars_result.h+1-1| ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if _LIBCPP_STD_VER >= 17 | 22 | #if _LIBCPP_STD_VER >= 17 |
| 23 | 23 | ||
| 24 | struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result { | 24 | struct to_chars_result { |
| 25 | char* ptr; | 25 | char* ptr; |
| 26 | errc ec; | 26 | errc ec; |
| 27 | # if _LIBCPP_STD_VER >= 20 | 27 | # if _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__charconv/traits.h+3-24| ... | @@ -113,31 +113,10 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u | ... | @@ -113,31 +113,10 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u |
| 113 | }; | 113 | }; |
| 114 | # endif | 114 | # endif |
| 115 | 115 | ||
| 116 | template <typename _Tp> | ||
| 117 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool | ||
| 118 | __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r) { | ||
| 119 | auto __c = __a * __b; | ||
| 120 | __r = __c; | ||
| 121 | return __c > numeric_limits<unsigned char>::max(); | ||
| 122 | } | ||
| 123 | |||
| 124 | template <typename _Tp> | ||
| 125 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool | ||
| 126 | __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) { | ||
| 127 | auto __c = __a * __b; | ||
| 128 | __r = __c; | ||
| 129 | return __c > numeric_limits<unsigned short>::max(); | ||
| 130 | } | ||
| 131 | |||
| 132 | template <typename _Tp> | ||
| 133 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) { | ||
| 134 | static_assert(is_unsigned<_Tp>::value, ""); | ||
| 135 | return __builtin_mul_overflow(__a, __b, std::addressof(__r)); | ||
| 136 | } | ||
| 137 | |||
| 138 | template <typename _Tp, typename _Up> | 116 | template <typename _Tp, typename _Up> |
| 139 | inline _LIBCPP_HIDE_FROM_ABI bool _LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed(_Tp __a, _Up __b, _Tp& __r) { | 117 | _LIBCPP_HIDE_FROM_ABI bool _LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed(_Tp __a, _Up __b, _Tp& __r) { |
| 140 | return __itoa::__mul_overflowed(__a, static_cast<_Tp>(__b), __r); | 118 | static_assert(is_unsigned<_Tp>::value); |
| 119 | return __builtin_mul_overflow(__a, static_cast<_Tp>(__b), std::addressof(__r)); | ||
| 141 | } | 120 | } |
| 142 | 121 | ||
| 143 | template <typename _Tp> | 122 | template <typename _Tp> |
lib/libcxx/include/__chrono/day.h+11| ... | @@ -13,6 +13,8 @@ | ... | @@ -13,6 +13,8 @@ |
| 13 | #include <__chrono/duration.h> | 13 | #include <__chrono/duration.h> |
| 14 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | ||
| 17 | #include <__functional/hash.h> | ||
| 16 | 18 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 20 | # pragma GCC system_header |
| ... | @@ -92,6 +94,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator-=(const days& __dd) no | ... | @@ -92,6 +94,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator-=(const days& __dd) no |
| 92 | 94 | ||
| 93 | } // namespace chrono | 95 | } // namespace chrono |
| 94 | 96 | ||
| 97 | # if _LIBCPP_STD_VER >= 26 | ||
| 98 | |||
| 99 | template <> | ||
| 100 | struct hash<chrono::day> { | ||
| 101 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::day& __d) noexcept { return static_cast<unsigned>(__d); } | ||
| 102 | }; | ||
| 103 | |||
| 104 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 105 | |||
| 95 | _LIBCPP_END_NAMESPACE_STD | 106 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 107 | ||
| 97 | #endif // _LIBCPP_STD_VER >= 20 | 108 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/duration.h+58-33| ... | @@ -13,6 +13,8 @@ | ... | @@ -13,6 +13,8 @@ |
| 13 | #include <__compare/ordering.h> | 13 | #include <__compare/ordering.h> |
| 14 | #include <__compare/three_way_comparable.h> | 14 | #include <__compare/three_way_comparable.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | ||
| 17 | #include <__functional/hash.h> | ||
| 16 | #include <__type_traits/common_type.h> | 18 | #include <__type_traits/common_type.h> |
| 17 | #include <__type_traits/enable_if.h> | 19 | #include <__type_traits/enable_if.h> |
| 18 | #include <__type_traits/is_convertible.h> | 20 | #include <__type_traits/is_convertible.h> |
| ... | @@ -102,7 +104,8 @@ struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> { | ... | @@ -102,7 +104,8 @@ struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> { |
| 102 | }; | 104 | }; |
| 103 | 105 | ||
| 104 | template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | 106 | template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 105 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const duration<_Rep, _Period>& __fd) { | 107 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration |
| 108 | duration_cast(const duration<_Rep, _Period>& __fd) { | ||
| 106 | return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); | 109 | return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); |
| 107 | } | 110 | } |
| 108 | 111 | ||
| ... | @@ -117,14 +120,18 @@ inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>: | ... | @@ -117,14 +120,18 @@ inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>: |
| 117 | template <class _Rep> | 120 | template <class _Rep> |
| 118 | struct duration_values { | 121 | struct duration_values { |
| 119 | public: | 122 | public: |
| 120 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); } | 123 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); } |
| 121 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); } | 124 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { |
| 122 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT { return numeric_limits<_Rep>::lowest(); } | 125 | return numeric_limits<_Rep>::max(); |
| 126 | } | ||
| 127 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT { | ||
| 128 | return numeric_limits<_Rep>::lowest(); | ||
| 129 | } | ||
| 123 | }; | 130 | }; |
| 124 | 131 | ||
| 125 | #if _LIBCPP_STD_VER >= 17 | 132 | #if _LIBCPP_STD_VER >= 17 |
| 126 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | 133 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 127 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) { | 134 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) { |
| 128 | _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); | 135 | _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); |
| 129 | if (__t > __d) | 136 | if (__t > __d) |
| 130 | __t = __t - _ToDuration{1}; | 137 | __t = __t - _ToDuration{1}; |
| ... | @@ -132,7 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration< | ... | @@ -132,7 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration< |
| 132 | } | 139 | } |
| 133 | 140 | ||
| 134 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | 141 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 135 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) { | 142 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) { |
| 136 | _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); | 143 | _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); |
| 137 | if (__t < __d) | 144 | if (__t < __d) |
| 138 | __t = __t + _ToDuration{1}; | 145 | __t = __t + _ToDuration{1}; |
| ... | @@ -140,7 +147,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_ | ... | @@ -140,7 +147,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_ |
| 140 | } | 147 | } |
| 141 | 148 | ||
| 142 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | 149 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 143 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) { | 150 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) { |
| 144 | _ToDuration __lower = chrono::floor<_ToDuration>(__d); | 151 | _ToDuration __lower = chrono::floor<_ToDuration>(__d); |
| 145 | _ToDuration __upper = __lower + _ToDuration{1}; | 152 | _ToDuration __upper = __lower + _ToDuration{1}; |
| 146 | auto __lower_diff = __d - __lower; | 153 | auto __lower_diff = __d - __lower; |
| ... | @@ -220,14 +227,14 @@ public: | ... | @@ -220,14 +227,14 @@ public: |
| 220 | 227 | ||
| 221 | // observer | 228 | // observer |
| 222 | 229 | ||
| 223 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR rep count() const { return __rep_; } | 230 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR rep count() const { return __rep_; } |
| 224 | 231 | ||
| 225 | // arithmetic | 232 | // arithmetic |
| 226 | 233 | ||
| 227 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const { | 234 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const { |
| 228 | return typename common_type<duration>::type(*this); | 235 | return typename common_type<duration>::type(*this); |
| 229 | } | 236 | } |
| 230 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const { | 237 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const { |
| 231 | return typename common_type<duration>::type(-__rep_); | 238 | return typename common_type<duration>::type(-__rep_); |
| 232 | } | 239 | } |
| 233 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() { | 240 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() { |
| ... | @@ -269,13 +276,13 @@ public: | ... | @@ -269,13 +276,13 @@ public: |
| 269 | 276 | ||
| 270 | // special values | 277 | // special values |
| 271 | 278 | ||
| 272 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT { | 279 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT { |
| 273 | return duration(duration_values<rep>::zero()); | 280 | return duration(duration_values<rep>::zero()); |
| 274 | } | 281 | } |
| 275 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT { | 282 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT { |
| 276 | return duration(duration_values<rep>::min()); | 283 | return duration(duration_values<rep>::min()); |
| 277 | } | 284 | } |
| 278 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT { | 285 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT { |
| 279 | return duration(duration_values<rep>::max()); | 286 | return duration(duration_values<rep>::max()); |
| 280 | } | 287 | } |
| 281 | }; | 288 | }; |
| ... | @@ -389,7 +396,7 @@ operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Perio | ... | @@ -389,7 +396,7 @@ operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Perio |
| 389 | // Duration + | 396 | // Duration + |
| 390 | 397 | ||
| 391 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 398 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 392 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 399 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 393 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | 400 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type |
| 394 | operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 401 | operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 395 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | 402 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; |
| ... | @@ -399,7 +406,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 | ... | @@ -399,7 +406,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 |
| 399 | // Duration - | 406 | // Duration - |
| 400 | 407 | ||
| 401 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 408 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 402 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 409 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 403 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | 410 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type |
| 404 | operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 411 | operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 405 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | 412 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; |
| ... | @@ -412,7 +419,8 @@ template <class _Rep1, | ... | @@ -412,7 +419,8 @@ template <class _Rep1, |
| 412 | class _Period, | 419 | class _Period, |
| 413 | class _Rep2, | 420 | class _Rep2, |
| 414 | __enable_if_t<is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> | 421 | __enable_if_t<is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> |
| 415 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 422 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 423 | _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | ||
| 416 | operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | 424 | operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 417 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | 425 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; |
| 418 | typedef duration<_Cr, _Period> _Cd; | 426 | typedef duration<_Cr, _Period> _Cd; |
| ... | @@ -423,7 +431,8 @@ template <class _Rep1, | ... | @@ -423,7 +431,8 @@ template <class _Rep1, |
| 423 | class _Period, | 431 | class _Period, |
| 424 | class _Rep2, | 432 | class _Rep2, |
| 425 | __enable_if_t<is_convertible<const _Rep1&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> | 433 | __enable_if_t<is_convertible<const _Rep1&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> |
| 426 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 434 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 435 | _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | ||
| 427 | operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { | 436 | operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { |
| 428 | return __d * __s; | 437 | return __d * __s; |
| 429 | } | 438 | } |
| ... | @@ -436,7 +445,8 @@ template <class _Rep1, | ... | @@ -436,7 +445,8 @@ template <class _Rep1, |
| 436 | __enable_if_t<!__is_duration_v<_Rep2> && | 445 | __enable_if_t<!__is_duration_v<_Rep2> && |
| 437 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, | 446 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, |
| 438 | int> = 0> | 447 | int> = 0> |
| 439 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 448 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 449 | _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | ||
| 440 | operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | 450 | operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 441 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | 451 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; |
| 442 | typedef duration<_Cr, _Period> _Cd; | 452 | typedef duration<_Cr, _Period> _Cd; |
| ... | @@ -444,7 +454,7 @@ operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | ... | @@ -444,7 +454,7 @@ operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 444 | } | 454 | } |
| 445 | 455 | ||
| 446 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 456 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 447 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<_Rep1, _Rep2>::type | 457 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename common_type<_Rep1, _Rep2>::type |
| 448 | operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 458 | operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 449 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct; | 459 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct; |
| 450 | return _Ct(__lhs).count() / _Ct(__rhs).count(); | 460 | return _Ct(__lhs).count() / _Ct(__rhs).count(); |
| ... | @@ -458,7 +468,8 @@ template <class _Rep1, | ... | @@ -458,7 +468,8 @@ template <class _Rep1, |
| 458 | __enable_if_t<!__is_duration_v<_Rep2> && | 468 | __enable_if_t<!__is_duration_v<_Rep2> && |
| 459 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, | 469 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, |
| 460 | int> = 0> | 470 | int> = 0> |
| 461 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | 471 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 472 | _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> | ||
| 462 | operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | 473 | operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 463 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | 474 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; |
| 464 | typedef duration<_Cr, _Period> _Cd; | 475 | typedef duration<_Cr, _Period> _Cd; |
| ... | @@ -466,7 +477,7 @@ operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { | ... | @@ -466,7 +477,7 @@ operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { |
| 466 | } | 477 | } |
| 467 | 478 | ||
| 468 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 479 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 469 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 480 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 470 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | 481 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type |
| 471 | operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 482 | operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 472 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | 483 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; |
| ... | @@ -481,51 +492,53 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 | ... | @@ -481,51 +492,53 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 |
| 481 | inline namespace literals { | 492 | inline namespace literals { |
| 482 | inline namespace chrono_literals { | 493 | inline namespace chrono_literals { |
| 483 | 494 | ||
| 484 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) { | 495 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) { |
| 485 | return chrono::hours(static_cast<chrono::hours::rep>(__h)); | 496 | return chrono::hours(static_cast<chrono::hours::rep>(__h)); |
| 486 | } | 497 | } |
| 487 | 498 | ||
| 488 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600, 1>> operator""h(long double __h) { | 499 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600, 1>> |
| 500 | operator""h(long double __h) { | ||
| 489 | return chrono::duration<long double, ratio<3600, 1>>(__h); | 501 | return chrono::duration<long double, ratio<3600, 1>>(__h); |
| 490 | } | 502 | } |
| 491 | 503 | ||
| 492 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m) { | 504 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m) { |
| 493 | return chrono::minutes(static_cast<chrono::minutes::rep>(__m)); | 505 | return chrono::minutes(static_cast<chrono::minutes::rep>(__m)); |
| 494 | } | 506 | } |
| 495 | 507 | ||
| 496 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60, 1>> operator""min(long double __m) { | 508 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60, 1>> |
| 509 | operator""min(long double __m) { | ||
| 497 | return chrono::duration<long double, ratio<60, 1>>(__m); | 510 | return chrono::duration<long double, ratio<60, 1>>(__m); |
| 498 | } | 511 | } |
| 499 | 512 | ||
| 500 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s) { | 513 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s) { |
| 501 | return chrono::seconds(static_cast<chrono::seconds::rep>(__s)); | 514 | return chrono::seconds(static_cast<chrono::seconds::rep>(__s)); |
| 502 | } | 515 | } |
| 503 | 516 | ||
| 504 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s) { | 517 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s) { |
| 505 | return chrono::duration<long double>(__s); | 518 | return chrono::duration<long double>(__s); |
| 506 | } | 519 | } |
| 507 | 520 | ||
| 508 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms) { | 521 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms) { |
| 509 | return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms)); | 522 | return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms)); |
| 510 | } | 523 | } |
| 511 | 524 | ||
| 512 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms) { | 525 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms) { |
| 513 | return chrono::duration<long double, milli>(__ms); | 526 | return chrono::duration<long double, milli>(__ms); |
| 514 | } | 527 | } |
| 515 | 528 | ||
| 516 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us) { | 529 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us) { |
| 517 | return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us)); | 530 | return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us)); |
| 518 | } | 531 | } |
| 519 | 532 | ||
| 520 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us) { | 533 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us) { |
| 521 | return chrono::duration<long double, micro>(__us); | 534 | return chrono::duration<long double, micro>(__us); |
| 522 | } | 535 | } |
| 523 | 536 | ||
| 524 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) { | 537 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) { |
| 525 | return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns)); | 538 | return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns)); |
| 526 | } | 539 | } |
| 527 | 540 | ||
| 528 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns) { | 541 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns) { |
| 529 | return chrono::duration<long double, nano>(__ns); | 542 | return chrono::duration<long double, nano>(__ns); |
| 530 | } | 543 | } |
| 531 | 544 | ||
| ... | @@ -538,6 +551,18 @@ using namespace literals::chrono_literals; | ... | @@ -538,6 +551,18 @@ using namespace literals::chrono_literals; |
| 538 | 551 | ||
| 539 | #endif // _LIBCPP_STD_VER >= 14 | 552 | #endif // _LIBCPP_STD_VER >= 14 |
| 540 | 553 | ||
| 554 | #if _LIBCPP_STD_VER >= 26 | ||
| 555 | |||
| 556 | template <class _Rep, class _Period> | ||
| 557 | requires __has_enabled_hash<_Rep>::value | ||
| 558 | struct hash<chrono::duration<_Rep, _Period>> { | ||
| 559 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::duration<_Rep, _Period>& __d) { | ||
| 560 | return hash<_Rep>{}(__d.count()); | ||
| 561 | } | ||
| 562 | }; | ||
| 563 | |||
| 564 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 565 | |||
| 541 | _LIBCPP_END_NAMESPACE_STD | 566 | _LIBCPP_END_NAMESPACE_STD |
| 542 | 567 | ||
| 543 | _LIBCPP_POP_MACROS | 568 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__chrono/file_clock.h+4-2| ... | @@ -60,16 +60,18 @@ struct _FilesystemClock { | ... | @@ -60,16 +60,18 @@ struct _FilesystemClock { |
| 60 | 60 | ||
| 61 | _LIBCPP_EXPORTED_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false; | 61 | _LIBCPP_EXPORTED_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false; |
| 62 | 62 | ||
| 63 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI static time_point now() noexcept; | 63 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI static time_point now() noexcept; |
| 64 | 64 | ||
| 65 | # if _LIBCPP_STD_VER >= 20 | 65 | # if _LIBCPP_STD_VER >= 20 |
| 66 | template <class _Duration> | 66 | template <class _Duration> |
| 67 | [[nodiscard]] | ||
| 67 | _LIBCPP_HIDE_FROM_ABI static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) { | 68 | _LIBCPP_HIDE_FROM_ABI static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) { |
| 68 | return chrono::sys_time<_Duration>(__t.time_since_epoch()); | 69 | return chrono::sys_time<_Duration>(__t.time_since_epoch()); |
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | template <class _Duration> | 72 | template <class _Duration> |
| 72 | _LIBCPP_HIDE_FROM_ABI static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) { | 73 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static chrono::file_time<_Duration> |
| 74 | from_sys(const chrono::sys_time<_Duration>& __t) { | ||
| 73 | return chrono::file_time<_Duration>(__t.time_since_epoch()); | 75 | return chrono::file_time<_Duration>(__t.time_since_epoch()); |
| 74 | } | 76 | } |
| 75 | # endif // _LIBCPP_STD_VER >= 20 | 77 | # endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/is_clock.h created+72| ... | @@ -0,0 +1,72 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CHRONO_IS_CLOCK_H | ||
| 11 | #define _LIBCPP___CHRONO_IS_CLOCK_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #include <__chrono/duration.h> | ||
| 16 | #include <__chrono/time_point.h> | ||
| 17 | #include <__concepts/same_as.h> | ||
| 18 | #include <__type_traits/integral_constant.h> | ||
| 19 | #include <__type_traits/is_arithmetic.h> | ||
| 20 | #include <__type_traits/is_class.h> | ||
| 21 | #include <__type_traits/is_union.h> | ||
| 22 | #include <ratio> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #if _LIBCPP_STD_VER >= 20 | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | namespace chrono { | ||
| 33 | |||
| 34 | // Helper to check that _Tp::time_point has the form time_point<_, typename _Tp::duration>. | ||
| 35 | template <class _TimePoint, class _ClockType> | ||
| 36 | inline constexpr bool __is_valid_clock_time_point_v = false; | ||
| 37 | |||
| 38 | template <class _TimePointClock, class _ClockType> | ||
| 39 | inline constexpr bool | ||
| 40 | __is_valid_clock_time_point_v<time_point<_TimePointClock, typename _ClockType::duration>, _ClockType> = true; | ||
| 41 | |||
| 42 | // Check if a clock satisfies the Cpp17Clock requirements as defined in [time.clock.req] | ||
| 43 | template <class _Tp> | ||
| 44 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_clock_v = requires { | ||
| 45 | typename _Tp::rep; | ||
| 46 | requires is_arithmetic_v<typename _Tp::rep> || is_class_v<typename _Tp::rep> || is_union_v<typename _Tp::rep>; | ||
| 47 | |||
| 48 | typename _Tp::period; | ||
| 49 | requires __is_ratio_v<typename _Tp::period>; | ||
| 50 | |||
| 51 | typename _Tp::duration; | ||
| 52 | requires same_as<typename _Tp::duration, duration<typename _Tp::rep, typename _Tp::period>>; | ||
| 53 | |||
| 54 | typename _Tp::time_point; | ||
| 55 | requires __is_valid_clock_time_point_v<typename _Tp::time_point, _Tp>; | ||
| 56 | |||
| 57 | _Tp::is_steady; | ||
| 58 | requires same_as<decltype((_Tp::is_steady)), const bool&>; | ||
| 59 | |||
| 60 | _Tp::now(); | ||
| 61 | requires same_as<decltype(_Tp::now()), typename _Tp::time_point>; | ||
| 62 | }; | ||
| 63 | |||
| 64 | template <class _Tp> | ||
| 65 | struct _LIBCPP_NO_SPECIALIZATIONS is_clock : bool_constant<is_clock_v<_Tp>> {}; | ||
| 66 | |||
| 67 | } // namespace chrono | ||
| 68 | |||
| 69 | _LIBCPP_END_NAMESPACE_STD | ||
| 70 | |||
| 71 | #endif // _LIBCPP_STD_VER | ||
| 72 | #endif // _LIBCPP___CHRONO_IS_CLOCK_H | ||
lib/libcxx/include/__chrono/leap_second.h+13| ... | @@ -22,6 +22,8 @@ | ... | @@ -22,6 +22,8 @@ |
| 22 | # include <__compare/ordering.h> | 22 | # include <__compare/ordering.h> |
| 23 | # include <__compare/three_way_comparable.h> | 23 | # include <__compare/three_way_comparable.h> |
| 24 | # include <__config> | 24 | # include <__config> |
| 25 | # include <__cstddef/size_t.h> | ||
| 26 | # include <__functional/hash.h> | ||
| 25 | # include <__utility/private_constructor_tag.h> | 27 | # include <__utility/private_constructor_tag.h> |
| 26 | 28 | ||
| 27 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 29 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -122,6 +124,17 @@ private: | ... | @@ -122,6 +124,17 @@ private: |
| 122 | 124 | ||
| 123 | } // namespace chrono | 125 | } // namespace chrono |
| 124 | 126 | ||
| 127 | # if _LIBCPP_STD_VER >= 26 | ||
| 128 | |||
| 129 | template <> | ||
| 130 | struct hash<chrono::leap_second> { | ||
| 131 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::leap_second& __lp) noexcept { | ||
| 132 | return std::__hash_combine(hash<chrono::sys_seconds>{}(__lp.date()), hash<chrono::seconds>{}(__lp.value())); | ||
| 133 | } | ||
| 134 | }; | ||
| 135 | |||
| 136 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 137 | |||
| 125 | # endif // _LIBCPP_STD_VER >= 20 | 138 | # endif // _LIBCPP_STD_VER >= 20 |
| 126 | 139 | ||
| 127 | _LIBCPP_END_NAMESPACE_STD | 140 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__chrono/month.h+13| ... | @@ -13,6 +13,8 @@ | ... | @@ -13,6 +13,8 @@ |
| 13 | #include <__chrono/duration.h> | 13 | #include <__chrono/duration.h> |
| 14 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | ||
| 17 | #include <__functional/hash.h> | ||
| 16 | 18 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 20 | # pragma GCC system_header |
| ... | @@ -108,6 +110,17 @@ inline constexpr month December{12}; | ... | @@ -108,6 +110,17 @@ inline constexpr month December{12}; |
| 108 | 110 | ||
| 109 | } // namespace chrono | 111 | } // namespace chrono |
| 110 | 112 | ||
| 113 | # if _LIBCPP_STD_VER >= 26 | ||
| 114 | |||
| 115 | template <> | ||
| 116 | struct hash<chrono::month> { | ||
| 117 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month& __m) noexcept { | ||
| 118 | return static_cast<unsigned>(__m); | ||
| 119 | } | ||
| 120 | }; | ||
| 121 | |||
| 122 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 123 | |||
| 111 | _LIBCPP_END_NAMESPACE_STD | 124 | _LIBCPP_END_NAMESPACE_STD |
| 112 | 125 | ||
| 113 | #endif // _LIBCPP_STD_VER >= 20 | 126 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/month_weekday.h+22| ... | @@ -13,6 +13,8 @@ | ... | @@ -13,6 +13,8 @@ |
| 13 | #include <__chrono/month.h> | 13 | #include <__chrono/month.h> |
| 14 | #include <__chrono/weekday.h> | 14 | #include <__chrono/weekday.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | ||
| 17 | #include <__functional/hash.h> | ||
| 16 | 18 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 20 | # pragma GCC system_header |
| ... | @@ -98,6 +100,26 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekda | ... | @@ -98,6 +100,26 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekda |
| 98 | } | 100 | } |
| 99 | } // namespace chrono | 101 | } // namespace chrono |
| 100 | 102 | ||
| 103 | # if _LIBCPP_STD_VER >= 26 | ||
| 104 | |||
| 105 | template <> | ||
| 106 | struct hash<chrono::month_weekday> { | ||
| 107 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday& __mw) noexcept { | ||
| 108 | return std::__hash_combine( | ||
| 109 | hash<chrono::month>{}(__mw.month()), hash<chrono::weekday_indexed>{}(__mw.weekday_indexed())); | ||
| 110 | } | ||
| 111 | }; | ||
| 112 | |||
| 113 | template <> | ||
| 114 | struct hash<chrono::month_weekday_last> { | ||
| 115 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday_last& __mwl) noexcept { | ||
| 116 | return std::__hash_combine( | ||
| 117 | hash<chrono::month>{}(__mwl.month()), hash<chrono::weekday_last>{}(__mwl.weekday_last())); | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 121 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 122 | |||
| 101 | _LIBCPP_END_NAMESPACE_STD | 123 | _LIBCPP_END_NAMESPACE_STD |
| 102 | 124 | ||
| 103 | #endif // _LIBCPP_STD_VER >= 20 | 125 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/monthday.h+20| ... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
| 15 | #include <__chrono/month.h> | 15 | #include <__chrono/month.h> |
| 16 | #include <__compare/ordering.h> | 16 | #include <__compare/ordering.h> |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__cstddef/size_t.h> | ||
| 19 | #include <__functional/hash.h> | ||
| 18 | 20 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -126,6 +128,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, int _ | ... | @@ -126,6 +128,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, int _ |
| 126 | 128 | ||
| 127 | } // namespace chrono | 129 | } // namespace chrono |
| 128 | 130 | ||
| 131 | # if _LIBCPP_STD_VER >= 26 | ||
| 132 | |||
| 133 | template <> | ||
| 134 | struct hash<chrono::month_day> { | ||
| 135 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day& __md) noexcept { | ||
| 136 | return std::__hash_combine(hash<chrono::month>{}(__md.month()), hash<chrono::day>{}(__md.day())); | ||
| 137 | } | ||
| 138 | }; | ||
| 139 | |||
| 140 | template <> | ||
| 141 | struct hash<chrono::month_day_last> { | ||
| 142 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day_last& __mdl) noexcept { | ||
| 143 | return hash<chrono::month>{}(__mdl.month()); | ||
| 144 | } | ||
| 145 | }; | ||
| 146 | |||
| 147 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 148 | |||
| 129 | _LIBCPP_END_NAMESPACE_STD | 149 | _LIBCPP_END_NAMESPACE_STD |
| 130 | 150 | ||
| 131 | #endif // _LIBCPP_STD_VER >= 20 | 151 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/steady_clock.h+1-1| ... | @@ -31,7 +31,7 @@ public: | ... | @@ -31,7 +31,7 @@ public: |
| 31 | typedef chrono::time_point<steady_clock, duration> time_point; | 31 | typedef chrono::time_point<steady_clock, duration> time_point; |
| 32 | static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = true; | 32 | static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = true; |
| 33 | 33 | ||
| 34 | static time_point now() _NOEXCEPT; | 34 | [[__nodiscard__]] static time_point now() _NOEXCEPT; |
| 35 | }; | 35 | }; |
| 36 | #endif | 36 | #endif |
| 37 | 37 |
lib/libcxx/include/__chrono/system_clock.h+3-3| ... | @@ -31,9 +31,9 @@ public: | ... | @@ -31,9 +31,9 @@ public: |
| 31 | typedef chrono::time_point<system_clock> time_point; | 31 | typedef chrono::time_point<system_clock> time_point; |
| 32 | static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false; | 32 | static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false; |
| 33 | 33 | ||
| 34 | static time_point now() _NOEXCEPT; | 34 | [[__nodiscard__]] static time_point now() _NOEXCEPT; |
| 35 | static time_t to_time_t(const time_point& __t) _NOEXCEPT; | 35 | [[__nodiscard__]] static time_t to_time_t(const time_point& __t) _NOEXCEPT; |
| 36 | static time_point from_time_t(time_t __t) _NOEXCEPT; | 36 | [[__nodiscard__]] static time_point from_time_t(time_t __t) _NOEXCEPT; |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | #if _LIBCPP_STD_VER >= 20 | 39 | #if _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/time_point.h+37-13| ... | @@ -14,6 +14,8 @@ | ... | @@ -14,6 +14,8 @@ |
| 14 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 15 | #include <__compare/three_way_comparable.h> | 15 | #include <__compare/three_way_comparable.h> |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__cstddef/size_t.h> | ||
| 18 | #include <__functional/hash.h> | ||
| 17 | #include <__type_traits/common_type.h> | 19 | #include <__type_traits/common_type.h> |
| 18 | #include <__type_traits/enable_if.h> | 20 | #include <__type_traits/enable_if.h> |
| 19 | #include <__type_traits/is_convertible.h> | 21 | #include <__type_traits/is_convertible.h> |
| ... | @@ -54,7 +56,9 @@ public: | ... | @@ -54,7 +56,9 @@ public: |
| 54 | 56 | ||
| 55 | // observer | 57 | // observer |
| 56 | 58 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 duration time_since_epoch() const { return __d_; } | 59 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 duration time_since_epoch() const { |
| 60 | return __d_; | ||
| 61 | } | ||
| 58 | 62 | ||
| 59 | // arithmetic | 63 | // arithmetic |
| 60 | 64 | ||
| ... | @@ -82,8 +86,12 @@ public: | ... | @@ -82,8 +86,12 @@ public: |
| 82 | 86 | ||
| 83 | // special values | 87 | // special values |
| 84 | 88 | ||
| 85 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT { return time_point(duration::min()); } | 89 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT { |
| 86 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT { return time_point(duration::max()); } | 90 | return time_point(duration::min()); |
| 91 | } | ||
| 92 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT { | ||
| 93 | return time_point(duration::max()); | ||
| 94 | } | ||
| 87 | }; | 95 | }; |
| 88 | 96 | ||
| 89 | } // namespace chrono | 97 | } // namespace chrono |
| ... | @@ -95,30 +103,33 @@ struct common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_C | ... | @@ -95,30 +103,33 @@ struct common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_C |
| 95 | 103 | ||
| 96 | namespace chrono { | 104 | namespace chrono { |
| 97 | 105 | ||
| 98 | template <class _ToDuration, class _Clock, class _Duration> | 106 | template <class _ToDuration, class _Clock, class _Duration, __enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 99 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, _ToDuration> | 107 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, _ToDuration> |
| 100 | time_point_cast(const time_point<_Clock, _Duration>& __t) { | 108 | time_point_cast(const time_point<_Clock, _Duration>& __t) { |
| 101 | return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); | 109 | return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); |
| 102 | } | 110 | } |
| 103 | 111 | ||
| 104 | #if _LIBCPP_STD_VER >= 17 | 112 | #if _LIBCPP_STD_VER >= 17 |
| 105 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | 113 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 106 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) { | 114 | [[nodiscard]] inline |
| 115 | _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) { | ||
| 107 | return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())}; | 116 | return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())}; |
| 108 | } | 117 | } |
| 109 | 118 | ||
| 110 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | 119 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 111 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) { | 120 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> |
| 121 | ceil(const time_point<_Clock, _Duration>& __t) { | ||
| 112 | return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())}; | 122 | return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())}; |
| 113 | } | 123 | } |
| 114 | 124 | ||
| 115 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | 125 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> |
| 116 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) { | 126 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> |
| 127 | round(const time_point<_Clock, _Duration>& __t) { | ||
| 117 | return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())}; | 128 | return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())}; |
| 118 | } | 129 | } |
| 119 | 130 | ||
| 120 | template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0> | 131 | template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0> |
| 121 | inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) { | 132 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) { |
| 122 | return __d >= __d.zero() ? +__d : -__d; | 133 | return __d >= __d.zero() ? +__d : -__d; |
| 123 | } | 134 | } |
| 124 | #endif // _LIBCPP_STD_VER >= 17 | 135 | #endif // _LIBCPP_STD_VER >= 17 |
| ... | @@ -188,7 +199,7 @@ operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock | ... | @@ -188,7 +199,7 @@ operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock |
| 188 | // time_point operator+(time_point x, duration y); | 199 | // time_point operator+(time_point x, duration y); |
| 189 | 200 | ||
| 190 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | 201 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> |
| 191 | inline _LIBCPP_HIDE_FROM_ABI | 202 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 192 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | 203 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> |
| 193 | operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 204 | operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 194 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; | 205 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; |
| ... | @@ -198,7 +209,7 @@ operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe | ... | @@ -198,7 +209,7 @@ operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe |
| 198 | // time_point operator+(duration x, time_point y); | 209 | // time_point operator+(duration x, time_point y); |
| 199 | 210 | ||
| 200 | template <class _Rep1, class _Period1, class _Clock, class _Duration2> | 211 | template <class _Rep1, class _Period1, class _Clock, class _Duration2> |
| 201 | inline _LIBCPP_HIDE_FROM_ABI | 212 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 202 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> | 213 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> |
| 203 | operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { | 214 | operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { |
| 204 | return __rhs + __lhs; | 215 | return __rhs + __lhs; |
| ... | @@ -207,7 +218,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dura | ... | @@ -207,7 +218,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dura |
| 207 | // time_point operator-(time_point x, duration y); | 218 | // time_point operator-(time_point x, duration y); |
| 208 | 219 | ||
| 209 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | 220 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> |
| 210 | inline _LIBCPP_HIDE_FROM_ABI | 221 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 211 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | 222 | _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> |
| 212 | operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { | 223 | operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) { |
| 213 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; | 224 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; |
| ... | @@ -217,13 +228,26 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe | ... | @@ -217,13 +228,26 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe |
| 217 | // duration operator-(time_point x, time_point y); | 228 | // duration operator-(time_point x, time_point y); |
| 218 | 229 | ||
| 219 | template <class _Clock, class _Duration1, class _Duration2> | 230 | template <class _Clock, class _Duration1, class _Duration2> |
| 220 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename common_type<_Duration1, _Duration2>::type | 231 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 232 | typename common_type<_Duration1, _Duration2>::type | ||
| 221 | operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { | 233 | operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) { |
| 222 | return __lhs.time_since_epoch() - __rhs.time_since_epoch(); | 234 | return __lhs.time_since_epoch() - __rhs.time_since_epoch(); |
| 223 | } | 235 | } |
| 224 | 236 | ||
| 225 | } // namespace chrono | 237 | } // namespace chrono |
| 226 | 238 | ||
| 239 | #if _LIBCPP_STD_VER >= 26 | ||
| 240 | |||
| 241 | template <class _Clock, class _Duration> | ||
| 242 | requires __has_enabled_hash<_Duration>::value | ||
| 243 | struct hash<chrono::time_point<_Clock, _Duration>> { | ||
| 244 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::time_point<_Clock, _Duration>& __tp) { | ||
| 245 | return hash<_Duration>{}(__tp.time_since_epoch()); | ||
| 246 | } | ||
| 247 | }; | ||
| 248 | |||
| 249 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 250 | |||
| 227 | _LIBCPP_END_NAMESPACE_STD | 251 | _LIBCPP_END_NAMESPACE_STD |
| 228 | 252 | ||
| 229 | _LIBCPP_POP_MACROS | 253 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__chrono/weekday.h+25| ... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
| 15 | #include <__chrono/system_clock.h> | 15 | #include <__chrono/system_clock.h> |
| 16 | #include <__chrono/time_point.h> | 16 | #include <__chrono/time_point.h> |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__cstddef/size_t.h> | ||
| 19 | #include <__functional/hash.h> | ||
| 18 | 20 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -160,6 +162,29 @@ inline constexpr weekday Saturday{6}; | ... | @@ -160,6 +162,29 @@ inline constexpr weekday Saturday{6}; |
| 160 | 162 | ||
| 161 | } // namespace chrono | 163 | } // namespace chrono |
| 162 | 164 | ||
| 165 | # if _LIBCPP_STD_VER >= 26 | ||
| 166 | |||
| 167 | template <> | ||
| 168 | struct hash<chrono::weekday> { | ||
| 169 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday& __w) noexcept { return __w.c_encoding(); } | ||
| 170 | }; | ||
| 171 | |||
| 172 | template <> | ||
| 173 | struct hash<chrono::weekday_indexed> { | ||
| 174 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_indexed& __wi) noexcept { | ||
| 175 | return std::__hash_combine(hash<chrono::weekday>{}(__wi.weekday()), __wi.index()); | ||
| 176 | } | ||
| 177 | }; | ||
| 178 | |||
| 179 | template <> | ||
| 180 | struct hash<chrono::weekday_last> { | ||
| 181 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_last& __wl) noexcept { | ||
| 182 | return hash<chrono::weekday>{}(__wl.weekday()); | ||
| 183 | } | ||
| 184 | }; | ||
| 185 | |||
| 186 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 187 | |||
| 163 | _LIBCPP_END_NAMESPACE_STD | 188 | _LIBCPP_END_NAMESPACE_STD |
| 164 | 189 | ||
| 165 | #endif // _LIBCPP_STD_VER >= 20 | 190 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/year.h+11| ... | @@ -13,6 +13,8 @@ | ... | @@ -13,6 +13,8 @@ |
| 13 | #include <__chrono/duration.h> | 13 | #include <__chrono/duration.h> |
| 14 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | ||
| 17 | #include <__functional/hash.h> | ||
| 16 | #include <limits> | 18 | #include <limits> |
| 17 | 19 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -109,6 +111,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept { | ... | @@ -109,6 +111,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept { |
| 109 | 111 | ||
| 110 | } // namespace chrono | 112 | } // namespace chrono |
| 111 | 113 | ||
| 114 | # if _LIBCPP_STD_VER >= 26 | ||
| 115 | |||
| 116 | template <> | ||
| 117 | struct hash<chrono::year> { | ||
| 118 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year& __y) noexcept { return static_cast<int>(__y); } | ||
| 119 | }; | ||
| 120 | |||
| 121 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 122 | |||
| 112 | _LIBCPP_END_NAMESPACE_STD | 123 | _LIBCPP_END_NAMESPACE_STD |
| 113 | 124 | ||
| 114 | #endif // _LIBCPP_STD_VER >= 20 | 125 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/year_month.h+13| ... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
| 15 | #include <__chrono/year.h> | 15 | #include <__chrono/year.h> |
| 16 | #include <__compare/ordering.h> | 16 | #include <__compare/ordering.h> |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__cstddef/size_t.h> | ||
| 19 | #include <__functional/hash.h> | ||
| 18 | 20 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -116,6 +118,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& year_month::operator-=(const | ... | @@ -116,6 +118,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& year_month::operator-=(const |
| 116 | 118 | ||
| 117 | } // namespace chrono | 119 | } // namespace chrono |
| 118 | 120 | ||
| 121 | # if _LIBCPP_STD_VER >= 26 | ||
| 122 | |||
| 123 | template <> | ||
| 124 | struct hash<chrono::year_month> { | ||
| 125 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month& __ym) noexcept { | ||
| 126 | return std::__hash_combine(hash<chrono::year>{}(__ym.year()), hash<chrono::month>{}(__ym.month())); | ||
| 127 | } | ||
| 128 | }; | ||
| 129 | |||
| 130 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 131 | |||
| 119 | _LIBCPP_END_NAMESPACE_STD | 132 | _LIBCPP_END_NAMESPACE_STD |
| 120 | 133 | ||
| 121 | #endif // _LIBCPP_STD_VER >= 20 | 134 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/year_month_day.h+23| ... | @@ -21,6 +21,8 @@ | ... | @@ -21,6 +21,8 @@ |
| 21 | #include <__chrono/year_month.h> | 21 | #include <__chrono/year_month.h> |
| 22 | #include <__compare/ordering.h> | 22 | #include <__compare/ordering.h> |
| 23 | #include <__config> | 23 | #include <__config> |
| 24 | #include <__cstddef/size_t.h> | ||
| 25 | #include <__functional/hash.h> | ||
| 24 | #include <limits> | 26 | #include <limits> |
| 25 | 27 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -330,6 +332,27 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool year_month_day::ok() const noexcept | ... | @@ -330,6 +332,27 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool year_month_day::ok() const noexcept |
| 330 | 332 | ||
| 331 | } // namespace chrono | 333 | } // namespace chrono |
| 332 | 334 | ||
| 335 | # if _LIBCPP_STD_VER >= 26 | ||
| 336 | |||
| 337 | template <> | ||
| 338 | struct hash<chrono::year_month_day> { | ||
| 339 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day& __ymd) noexcept { | ||
| 340 | return std::__hash_combine( | ||
| 341 | hash<chrono::year>{}(__ymd.year()), | ||
| 342 | std::__hash_combine(hash<chrono::month>{}(__ymd.month()), hash<chrono::day>{}(__ymd.day()))); | ||
| 343 | } | ||
| 344 | }; | ||
| 345 | |||
| 346 | template <> | ||
| 347 | struct hash<chrono::year_month_day_last> { | ||
| 348 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day_last& __ymdl) noexcept { | ||
| 349 | return std::__hash_combine( | ||
| 350 | hash<chrono::year>{}(__ymdl.year()), hash<chrono::month_day_last>{}(__ymdl.month_day_last())); | ||
| 351 | } | ||
| 352 | }; | ||
| 353 | |||
| 354 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 355 | |||
| 333 | _LIBCPP_END_NAMESPACE_STD | 356 | _LIBCPP_END_NAMESPACE_STD |
| 334 | 357 | ||
| 335 | #endif // _LIBCPP_STD_VER >= 20 | 358 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/year_month_weekday.h+26| ... | @@ -22,6 +22,8 @@ | ... | @@ -22,6 +22,8 @@ |
| 22 | #include <__chrono/year_month.h> | 22 | #include <__chrono/year_month.h> |
| 23 | #include <__chrono/year_month_day.h> | 23 | #include <__chrono/year_month_day.h> |
| 24 | #include <__config> | 24 | #include <__config> |
| 25 | #include <__cstddef/size_t.h> | ||
| 26 | #include <__functional/hash.h> | ||
| 25 | 27 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | # pragma GCC system_header | 29 | # pragma GCC system_header |
| ... | @@ -280,6 +282,30 @@ year_month_weekday_last::operator-=(const years& __dy) noexcept { | ... | @@ -280,6 +282,30 @@ year_month_weekday_last::operator-=(const years& __dy) noexcept { |
| 280 | 282 | ||
| 281 | } // namespace chrono | 283 | } // namespace chrono |
| 282 | 284 | ||
| 285 | # if _LIBCPP_STD_VER >= 26 | ||
| 286 | |||
| 287 | template <> | ||
| 288 | struct hash<chrono::year_month_weekday> { | ||
| 289 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday& __ymw) noexcept { | ||
| 290 | return std::__hash_combine( | ||
| 291 | hash<chrono::year>{}(__ymw.year()), | ||
| 292 | std::__hash_combine( | ||
| 293 | hash<chrono::month>{}(__ymw.month()), hash<chrono::weekday_indexed>{}(__ymw.weekday_indexed()))); | ||
| 294 | } | ||
| 295 | }; | ||
| 296 | |||
| 297 | template <> | ||
| 298 | struct hash<chrono::year_month_weekday_last> { | ||
| 299 | _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday_last& __ymwl) noexcept { | ||
| 300 | return std::__hash_combine( | ||
| 301 | hash<chrono::year>{}(__ymwl.year()), | ||
| 302 | std::__hash_combine( | ||
| 303 | hash<chrono::month>{}(__ymwl.month()), hash<chrono::weekday_last>{}(__ymwl.weekday_last()))); | ||
| 304 | } | ||
| 305 | }; | ||
| 306 | |||
| 307 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 308 | |||
| 283 | _LIBCPP_END_NAMESPACE_STD | 309 | _LIBCPP_END_NAMESPACE_STD |
| 284 | 310 | ||
| 285 | #endif // _LIBCPP_STD_VER >= 20 | 311 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__chrono/zoned_time.h+16| ... | @@ -24,6 +24,8 @@ | ... | @@ -24,6 +24,8 @@ |
| 24 | # include <__chrono/tzdb_list.h> | 24 | # include <__chrono/tzdb_list.h> |
| 25 | # include <__concepts/constructible.h> | 25 | # include <__concepts/constructible.h> |
| 26 | # include <__config> | 26 | # include <__config> |
| 27 | # include <__cstddef/size_t.h> | ||
| 28 | # include <__functional/hash.h> | ||
| 27 | # include <__type_traits/common_type.h> | 29 | # include <__type_traits/common_type.h> |
| 28 | # include <__type_traits/conditional.h> | 30 | # include <__type_traits/conditional.h> |
| 29 | # include <__type_traits/remove_cvref.h> | 31 | # include <__type_traits/remove_cvref.h> |
| ... | @@ -216,6 +218,20 @@ operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_ | ... | @@ -216,6 +218,20 @@ operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_ |
| 216 | 218 | ||
| 217 | } // namespace chrono | 219 | } // namespace chrono |
| 218 | 220 | ||
| 221 | # if _LIBCPP_STD_VER >= 26 | ||
| 222 | |||
| 223 | template <class _Duration, class _TimeZonePtr> | ||
| 224 | requires __has_enabled_hash<_Duration>::value && __has_enabled_hash<_TimeZonePtr>::value | ||
| 225 | struct hash<chrono::zoned_time<_Duration, _TimeZonePtr>> { | ||
| 226 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t | ||
| 227 | operator()(const chrono::zoned_time<_Duration, _TimeZonePtr>& __zt) { | ||
| 228 | return std::__hash_combine( | ||
| 229 | hash<chrono::sys_time<_Duration>>{}(__zt.get_sys_time()), hash<_TimeZonePtr>{}(__zt.get_time_zone())); | ||
| 230 | } | ||
| 231 | }; | ||
| 232 | |||
| 233 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 234 | |||
| 219 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | 235 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && |
| 220 | // _LIBCPP_HAS_LOCALIZATION | 236 | // _LIBCPP_HAS_LOCALIZATION |
| 221 | 237 |
lib/libcxx/include/__compare/is_eq.h+6-6| ... | @@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 20 | 21 | #if _LIBCPP_STD_VER >= 20 |
| 22 | 22 | ||
| 23 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_eq(partial_ordering __c) noexcept { return __c == 0; } | 23 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_eq(partial_ordering __c) noexcept { return __c == 0; } |
| 24 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_neq(partial_ordering __c) noexcept { return __c != 0; } | 24 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_neq(partial_ordering __c) noexcept { return __c != 0; } |
| 25 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lt(partial_ordering __c) noexcept { return __c < 0; } | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lt(partial_ordering __c) noexcept { return __c < 0; } |
| 26 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lteq(partial_ordering __c) noexcept { return __c <= 0; } | 26 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lteq(partial_ordering __c) noexcept { return __c <= 0; } |
| 27 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gt(partial_ordering __c) noexcept { return __c > 0; } | 27 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gt(partial_ordering __c) noexcept { return __c > 0; } |
| 28 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gteq(partial_ordering __c) noexcept { return __c >= 0; } | 28 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gteq(partial_ordering __c) noexcept { return __c >= 0; } |
| 29 | 29 | ||
| 30 | #endif // _LIBCPP_STD_VER >= 20 | 30 | #endif // _LIBCPP_STD_VER >= 20 |
| 31 | 31 |
lib/libcxx/include/__compare/strong_order.h+12-30| ... | @@ -13,7 +13,6 @@ | ... | @@ -13,7 +13,6 @@ |
| 13 | #include <__compare/compare_three_way.h> | 13 | #include <__compare/compare_three_way.h> |
| 14 | #include <__compare/ordering.h> | 14 | #include <__compare/ordering.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__math/exponential_functions.h> | ||
| 17 | #include <__math/traits.h> | 16 | #include <__math/traits.h> |
| 18 | #include <__type_traits/conditional.h> | 17 | #include <__type_traits/conditional.h> |
| 19 | #include <__type_traits/decay.h> | 18 | #include <__type_traits/decay.h> |
| ... | @@ -53,38 +52,21 @@ struct __fn { | ... | @@ -53,38 +52,21 @@ struct __fn { |
| 53 | template <class _Tp, class _Up, class _Dp = decay_t<_Tp>> | 52 | template <class _Tp, class _Up, class _Dp = decay_t<_Tp>> |
| 54 | requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> | 53 | requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> |
| 55 | _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept { | 54 | _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept { |
| 56 | if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int32_t)) { | 55 | if constexpr (numeric_limits<_Dp>::is_iec559 && |
| 57 | int32_t __rx = std::bit_cast<int32_t>(__t); | 56 | (sizeof(_Dp) == sizeof(int32_t) || sizeof(_Dp) == sizeof(int64_t))) { |
| 58 | int32_t __ry = std::bit_cast<int32_t>(__u); | 57 | using _IntT = conditional_t<sizeof(_Dp) == sizeof(int32_t), int32_t, int64_t>; |
| 59 | __rx = (__rx < 0) ? (numeric_limits<int32_t>::min() - __rx - 1) : __rx; | 58 | _IntT __rx = std::bit_cast<_IntT>(__t); |
| 60 | __ry = (__ry < 0) ? (numeric_limits<int32_t>::min() - __ry - 1) : __ry; | 59 | _IntT __ry = std::bit_cast<_IntT>(__u); |
| 61 | return (__rx <=> __ry); | 60 | __rx = (__rx < 0) ? (numeric_limits<_IntT>::min() - __rx - 1) : __rx; |
| 62 | } else if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int64_t)) { | 61 | __ry = (__ry < 0) ? (numeric_limits<_IntT>::min() - __ry - 1) : __ry; |
| 63 | int64_t __rx = std::bit_cast<int64_t>(__t); | ||
| 64 | int64_t __ry = std::bit_cast<int64_t>(__u); | ||
| 65 | __rx = (__rx < 0) ? (numeric_limits<int64_t>::min() - __rx - 1) : __rx; | ||
| 66 | __ry = (__ry < 0) ? (numeric_limits<int64_t>::min() - __ry - 1) : __ry; | ||
| 67 | return (__rx <=> __ry); | 62 | return (__rx <=> __ry); |
| 68 | } else if (__t < __u) { | 63 | } else if (__t < __u) { |
| 69 | return strong_ordering::less; | 64 | return strong_ordering::less; |
| 70 | } else if (__t > __u) { | 65 | } else if (__t > __u) { |
| 71 | return strong_ordering::greater; | 66 | return strong_ordering::greater; |
| 72 | } else if (__t == __u) { | 67 | } else if (__t == __u) { |
| 73 | if constexpr (numeric_limits<_Dp>::radix == 2) { | 68 | static_assert(numeric_limits<_Dp>::radix == 2, "floating point type with a radix other than 2?"); |
| 74 | return __math::signbit(__u) <=> __math::signbit(__t); | 69 | return __math::signbit(__u) <=> __math::signbit(__t); |
| 75 | } else { | ||
| 76 | // This is bullet 3 of the IEEE754 algorithm, relevant | ||
| 77 | // only for decimal floating-point; | ||
| 78 | // see https://stackoverflow.com/questions/69068075/ | ||
| 79 | if (__t == 0 || __math::isinf(__t)) { | ||
| 80 | return __math::signbit(__u) <=> __math::signbit(__t); | ||
| 81 | } else { | ||
| 82 | int __texp, __uexp; | ||
| 83 | (void)__math::frexp(__t, &__texp); | ||
| 84 | (void)__math::frexp(__u, &__uexp); | ||
| 85 | return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } else { | 70 | } else { |
| 89 | // They're unordered, so one of them must be a NAN. | 71 | // They're unordered, so one of them must be a NAN. |
| 90 | // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN. | 72 | // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN. |
| ... | @@ -93,9 +75,9 @@ struct __fn { | ... | @@ -93,9 +75,9 @@ struct __fn { |
| 93 | bool __t_is_negative = __math::signbit(__t); | 75 | bool __t_is_negative = __math::signbit(__t); |
| 94 | bool __u_is_negative = __math::signbit(__u); | 76 | bool __u_is_negative = __math::signbit(__u); |
| 95 | using _IntType = | 77 | using _IntType = |
| 96 | conditional_t< sizeof(__t) == sizeof(int32_t), | 78 | conditional_t<sizeof(__t) == sizeof(int32_t), |
| 97 | int32_t, | 79 | int32_t, |
| 98 | conditional_t< sizeof(__t) == sizeof(int64_t), int64_t, void> >; | 80 | conditional_t<sizeof(__t) == sizeof(int64_t), int64_t, void>>; |
| 99 | if constexpr (is_same_v<_IntType, void>) { | 81 | if constexpr (is_same_v<_IntType, void>) { |
| 100 | static_assert(sizeof(_Dp) == 0, "std::strong_order is unimplemented for this floating-point type"); | 82 | static_assert(sizeof(_Dp) == 0, "std::strong_order is unimplemented for this floating-point type"); |
| 101 | } else if (__t_is_nan && __u_is_nan) { | 83 | } else if (__t_is_nan && __u_is_nan) { |
lib/libcxx/include/__compare/three_way_comparable.h+2-2| ... | @@ -12,6 +12,7 @@ | ... | @@ -12,6 +12,7 @@ |
| 12 | #include <__compare/common_comparison_category.h> | 12 | #include <__compare/common_comparison_category.h> |
| 13 | #include <__compare/ordering.h> | 13 | #include <__compare/ordering.h> |
| 14 | #include <__concepts/common_reference_with.h> | 14 | #include <__concepts/common_reference_with.h> |
| 15 | #include <__concepts/comparison_common_type.h> | ||
| 15 | #include <__concepts/equality_comparable.h> | 16 | #include <__concepts/equality_comparable.h> |
| 16 | #include <__concepts/same_as.h> | 17 | #include <__concepts/same_as.h> |
| 17 | #include <__concepts/totally_ordered.h> | 18 | #include <__concepts/totally_ordered.h> |
| ... | @@ -39,8 +40,7 @@ concept three_way_comparable = | ... | @@ -39,8 +40,7 @@ concept three_way_comparable = |
| 39 | 40 | ||
| 40 | template <class _Tp, class _Up, class _Cat = partial_ordering> | 41 | template <class _Tp, class _Up, class _Cat = partial_ordering> |
| 41 | concept three_way_comparable_with = | 42 | concept three_way_comparable_with = |
| 42 | three_way_comparable<_Tp, _Cat> && three_way_comparable<_Up, _Cat> && | 43 | three_way_comparable<_Tp, _Cat> && three_way_comparable<_Up, _Cat> && __comparison_common_type_with<_Tp, _Up> && |
| 43 | common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && | ||
| 44 | three_way_comparable<common_reference_t<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>, _Cat> && | 44 | three_way_comparable<common_reference_t<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>, _Cat> && |
| 45 | __weakly_equality_comparable_with<_Tp, _Up> && __partially_ordered_with<_Tp, _Up> && | 45 | __weakly_equality_comparable_with<_Tp, _Up> && __partially_ordered_with<_Tp, _Up> && |
| 46 | requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { | 46 | requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { |
lib/libcxx/include/__concepts/comparison_common_type.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___CONCEPTS_COMPARISON_COMMON_TYPE_H | ||
| 10 | #define _LIBCPP___CONCEPTS_COMPARISON_COMMON_TYPE_H | ||
| 11 | |||
| 12 | #include <__concepts/convertible_to.h> | ||
| 13 | #include <__concepts/same_as.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__type_traits/common_reference.h> | ||
| 16 | #include <__type_traits/remove_cvref.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 >= 20 | ||
| 25 | |||
| 26 | template <class _Tp, class _Up, class _CommonRef = common_reference_t<const _Tp&, const _Up&>> | ||
| 27 | concept __comparison_common_type_with_impl = | ||
| 28 | same_as<common_reference_t<const _Tp&, const _Up&>, common_reference_t<const _Up&, const _Tp&>> && requires { | ||
| 29 | requires convertible_to<const _Tp&, const _CommonRef&> || convertible_to<_Tp, const _CommonRef&>; | ||
| 30 | requires convertible_to<const _Up&, const _CommonRef&> || convertible_to<_Up, const _CommonRef&>; | ||
| 31 | }; | ||
| 32 | |||
| 33 | template <class _Tp, class _Up> | ||
| 34 | concept __comparison_common_type_with = __comparison_common_type_with_impl<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>; | ||
| 35 | |||
| 36 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 37 | |||
| 38 | _LIBCPP_END_NAMESPACE_STD | ||
| 39 | |||
| 40 | #endif // _LIBCPP___CONCEPTS_COMPARISON_COMMON_TYPE_H | ||
lib/libcxx/include/__concepts/equality_comparable.h+2-1| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__concepts/boolean_testable.h> | 12 | #include <__concepts/boolean_testable.h> |
| 13 | #include <__concepts/common_reference_with.h> | 13 | #include <__concepts/common_reference_with.h> |
| 14 | #include <__concepts/comparison_common_type.h> | ||
| 14 | #include <__config> | 15 | #include <__config> |
| 15 | #include <__type_traits/common_reference.h> | 16 | #include <__type_traits/common_reference.h> |
| 16 | #include <__type_traits/make_const_lvalue_ref.h> | 17 | #include <__type_traits/make_const_lvalue_ref.h> |
| ... | @@ -41,7 +42,7 @@ concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>; | ... | @@ -41,7 +42,7 @@ concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>; |
| 41 | template <class _Tp, class _Up> | 42 | template <class _Tp, class _Up> |
| 42 | concept equality_comparable_with = | 43 | concept equality_comparable_with = |
| 43 | equality_comparable<_Tp> && equality_comparable<_Up> && | 44 | equality_comparable<_Tp> && equality_comparable<_Up> && |
| 44 | common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && | 45 | __comparison_common_type_with<_Tp, _Up> && |
| 45 | equality_comparable< | 46 | equality_comparable< |
| 46 | common_reference_t< | 47 | common_reference_t< |
| 47 | __make_const_lvalue_ref<_Tp>, | 48 | __make_const_lvalue_ref<_Tp>, |
lib/libcxx/include/__condition_variable/condition_variable.h+1-1| ... | @@ -170,7 +170,7 @@ public: | ... | @@ -170,7 +170,7 @@ public: |
| 170 | wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); | 170 | wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); |
| 171 | 171 | ||
| 172 | typedef __libcpp_condvar_t* native_handle_type; | 172 | typedef __libcpp_condvar_t* native_handle_type; |
| 173 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__cv_; } | 173 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__cv_; } |
| 174 | 174 | ||
| 175 | private: | 175 | private: |
| 176 | void | 176 | void |
lib/libcxx/include/__config+63-280| ... | @@ -14,6 +14,8 @@ | ... | @@ -14,6 +14,8 @@ |
| 14 | #include <__configuration/abi.h> | 14 | #include <__configuration/abi.h> |
| 15 | #include <__configuration/availability.h> | 15 | #include <__configuration/availability.h> |
| 16 | #include <__configuration/compiler.h> | 16 | #include <__configuration/compiler.h> |
| 17 | #include <__configuration/experimental.h> | ||
| 18 | #include <__configuration/hardening.h> | ||
| 17 | #include <__configuration/language.h> | 19 | #include <__configuration/language.h> |
| 18 | #include <__configuration/platform.h> | 20 | #include <__configuration/platform.h> |
| 19 | 21 | ||
| ... | @@ -28,7 +30,7 @@ | ... | @@ -28,7 +30,7 @@ |
| 28 | // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. | 30 | // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. |
| 29 | // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is | 31 | // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is |
| 30 | // defined to XXYYZZ. | 32 | // defined to XXYYZZ. |
| 31 | # define _LIBCPP_VERSION 210100 | 33 | # define _LIBCPP_VERSION 220104 |
| 32 | 34 | ||
| 33 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y | 35 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y |
| 34 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) | 36 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) |
| ... | @@ -38,195 +40,6 @@ | ... | @@ -38,195 +40,6 @@ |
| 38 | # define _LIBCPP_FREESTANDING | 40 | # define _LIBCPP_FREESTANDING |
| 39 | # endif | 41 | # endif |
| 40 | 42 | ||
| 41 | // NOLINTNEXTLINE(libcpp-cpp-version-check) | ||
| 42 | # if __cplusplus < 201103L | ||
| 43 | # define _LIBCPP_CXX03_LANG | ||
| 44 | # endif | ||
| 45 | |||
| 46 | # if __has_feature(experimental_library) | ||
| 47 | # ifndef _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 48 | # define _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 49 | # endif | ||
| 50 | # endif | ||
| 51 | |||
| 52 | // Incomplete features get their own specific disabling flags. This makes it | ||
| 53 | // easier to grep for target specific flags once the feature is complete. | ||
| 54 | # if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 55 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1 | ||
| 56 | # else | ||
| 57 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0 | ||
| 58 | # endif | ||
| 59 | |||
| 60 | # define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 61 | # define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 62 | # define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 63 | # define _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 64 | |||
| 65 | // HARDENING { | ||
| 66 | |||
| 67 | // TODO(LLVM 23): Remove this. We're making these an error to catch folks who might not have migrated. | ||
| 68 | // Since hardening went through several changes (many of which impacted user-facing macros), | ||
| 69 | // we're keeping these checks around for a bit longer than usual. Failure to properly configure | ||
| 70 | // hardening results in checks being dropped silently, which is a pretty big deal. | ||
| 71 | # if defined(_LIBCPP_ENABLE_ASSERTIONS) | ||
| 72 | # error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 73 | # endif | ||
| 74 | # if defined(_LIBCPP_ENABLE_HARDENED_MODE) | ||
| 75 | # error "_LIBCPP_ENABLE_HARDENED_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 76 | # endif | ||
| 77 | # if defined(_LIBCPP_ENABLE_SAFE_MODE) | ||
| 78 | # error "_LIBCPP_ENABLE_SAFE_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 79 | # endif | ||
| 80 | # if defined(_LIBCPP_ENABLE_DEBUG_MODE) | ||
| 81 | # error "_LIBCPP_ENABLE_DEBUG_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 82 | # endif | ||
| 83 | |||
| 84 | // The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values: | ||
| 85 | // | ||
| 86 | // - `_LIBCPP_HARDENING_MODE_NONE`; | ||
| 87 | // - `_LIBCPP_HARDENING_MODE_FAST`; | ||
| 88 | // - `_LIBCPP_HARDENING_MODE_EXTENSIVE`; | ||
| 89 | // - `_LIBCPP_HARDENING_MODE_DEBUG`. | ||
| 90 | // | ||
| 91 | // These values have the following effects: | ||
| 92 | // | ||
| 93 | // - `_LIBCPP_HARDENING_MODE_NONE` -- sets the hardening mode to "none" which disables all runtime hardening checks; | ||
| 94 | // | ||
| 95 | // - `_LIBCPP_HARDENING_MODE_FAST` -- sets that hardening mode to "fast". The fast mode enables security-critical checks | ||
| 96 | // that can be done with relatively little runtime overhead in constant time; | ||
| 97 | // | ||
| 98 | // - `_LIBCPP_HARDENING_MODE_EXTENSIVE` -- sets the hardening mode to "extensive". The extensive mode is a superset of | ||
| 99 | // the fast mode that additionally enables checks that are relatively cheap and prevent common types of logic errors | ||
| 100 | // but are not necessarily security-critical; | ||
| 101 | // | ||
| 102 | // - `_LIBCPP_HARDENING_MODE_DEBUG` -- sets the hardening mode to "debug". The debug mode is a superset of the extensive | ||
| 103 | // mode and enables all checks available in the library, including internal assertions. Checks that are part of the | ||
| 104 | // debug mode can be very expensive and thus the debug mode is intended to be used for testing, not in production. | ||
| 105 | |||
| 106 | // Inside the library, assertions are categorized so they can be cherry-picked based on the chosen hardening mode. These | ||
| 107 | // macros are only for internal use -- users should only pick one of the high-level hardening modes described above. | ||
| 108 | // | ||
| 109 | // - `_LIBCPP_ASSERT_VALID_INPUT_RANGE` -- checks that ranges (whether expressed as an iterator pair, an iterator and | ||
| 110 | // a sentinel, an iterator and a count, or a `std::range`) given as input to library functions are valid: | ||
| 111 | // - the sentinel is reachable from the begin iterator; | ||
| 112 | // - TODO(hardening): both iterators refer to the same container. | ||
| 113 | // | ||
| 114 | // - `_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS` -- checks that any attempts to access a container element, whether through | ||
| 115 | // the container object or through an iterator, are valid and do not attempt to go out of bounds or otherwise access | ||
| 116 | // a non-existent element. For iterator checks to work, bounded iterators must be enabled in the ABI. Types like | ||
| 117 | // `optional` and `function` are considered one-element containers for the purposes of this check. | ||
| 118 | // | ||
| 119 | // - `_LIBCPP_ASSERT_NON_NULL` -- checks that the pointer being dereferenced is not null. On most modern platforms zero | ||
| 120 | // address does not refer to an actual location in memory, so a null pointer dereference would not compromize the | ||
| 121 | // memory security of a program (however, it is still undefined behavior that can result in strange errors due to | ||
| 122 | // compiler optimizations). | ||
| 123 | // | ||
| 124 | // - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the | ||
| 125 | // given ranges do not overlap. | ||
| 126 | // | ||
| 127 | // - `_LIBCPP_ASSERT_VALID_DEALLOCATION` -- checks that an attempt to deallocate memory is valid (e.g. the given object | ||
| 128 | // was allocated by the given allocator). Violating this category typically results in a memory leak. | ||
| 129 | // | ||
| 130 | // - `_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL` -- checks that a call to an external API doesn't fail in | ||
| 131 | // an unexpected manner. This includes triggering documented cases of undefined behavior in an external library (like | ||
| 132 | // attempting to unlock an unlocked mutex in pthreads). Any API external to the library falls under this category | ||
| 133 | // (from system calls to compiler intrinsics). We generally don't expect these failures to compromize memory safety or | ||
| 134 | // otherwise create an immediate security issue. | ||
| 135 | // | ||
| 136 | // - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure | ||
| 137 | // the containers have compatible allocators. | ||
| 138 | // | ||
| 139 | // - `_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN` -- checks that the given argument is within the domain of valid arguments | ||
| 140 | // for the function. Violating this typically produces an incorrect result (e.g. the clamp algorithm returns the | ||
| 141 | // original value without clamping it due to incorrect functors) or puts an object into an invalid state (e.g. | ||
| 142 | // a string view where only a subset of elements is possible to access). This category is for assertions violating | ||
| 143 | // which doesn't cause any immediate issues in the library -- whatever the consequences are, they will happen in the | ||
| 144 | // user code. | ||
| 145 | // | ||
| 146 | // - `_LIBCPP_ASSERT_PEDANTIC` -- checks prerequisites which are imposed by the Standard, but violating which happens to | ||
| 147 | // be benign in our implementation. | ||
| 148 | // | ||
| 149 | // - `_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT` -- checks that the given argument satisfies the semantic requirements imposed | ||
| 150 | // by the Standard. Typically, there is no simple way to completely prove that a semantic requirement is satisfied; | ||
| 151 | // thus, this would often be a heuristic check and it might be quite expensive. | ||
| 152 | // | ||
| 153 | // - `_LIBCPP_ASSERT_INTERNAL` -- checks that internal invariants of the library hold. These assertions don't depend on | ||
| 154 | // user input. | ||
| 155 | // | ||
| 156 | // - `_LIBCPP_ASSERT_UNCATEGORIZED` -- for assertions that haven't been properly classified yet. | ||
| 157 | |||
| 158 | // clang-format off | ||
| 159 | # define _LIBCPP_HARDENING_MODE_NONE (1 << 1) | ||
| 160 | # define _LIBCPP_HARDENING_MODE_FAST (1 << 2) | ||
| 161 | # define _LIBCPP_HARDENING_MODE_EXTENSIVE (1 << 4) // Deliberately not ordered. | ||
| 162 | # define _LIBCPP_HARDENING_MODE_DEBUG (1 << 3) | ||
| 163 | // clang-format on | ||
| 164 | |||
| 165 | # ifndef _LIBCPP_HARDENING_MODE | ||
| 166 | |||
| 167 | # ifndef _LIBCPP_HARDENING_MODE_DEFAULT | ||
| 168 | # error _LIBCPP_HARDENING_MODE_DEFAULT is not defined. This definition should be set at configuration time in the \ | ||
| 169 | `__config_site` header, please make sure your installation of libc++ is not broken. | ||
| 170 | # endif | ||
| 171 | |||
| 172 | # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT | ||
| 173 | # endif | ||
| 174 | |||
| 175 | # if _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_NONE && \ | ||
| 176 | _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_FAST && \ | ||
| 177 | _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_EXTENSIVE && \ | ||
| 178 | _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_DEBUG | ||
| 179 | # error _LIBCPP_HARDENING_MODE must be set to one of the following values: \ | ||
| 180 | _LIBCPP_HARDENING_MODE_NONE, \ | ||
| 181 | _LIBCPP_HARDENING_MODE_FAST, \ | ||
| 182 | _LIBCPP_HARDENING_MODE_EXTENSIVE, \ | ||
| 183 | _LIBCPP_HARDENING_MODE_DEBUG | ||
| 184 | # endif | ||
| 185 | |||
| 186 | // Hardening assertion semantics generally mirror the evaluation semantics of C++26 Contracts: | ||
| 187 | // - `ignore` evaluates the assertion but doesn't do anything if it fails (note that it differs from the Contracts | ||
| 188 | // `ignore` semantic which wouldn't evaluate the assertion at all); | ||
| 189 | // - `observe` logs an error (indicating, if possible, that the error is fatal) and continues execution; | ||
| 190 | // - `quick-enforce` terminates the program as fast as possible (via trapping); | ||
| 191 | // - `enforce` logs an error and then terminates the program. | ||
| 192 | // | ||
| 193 | // Notes: | ||
| 194 | // - Continuing execution after a hardening check fails results in undefined behavior; the `observe` semantic is meant | ||
| 195 | // to make adopting hardening easier but should not be used outside of this scenario; | ||
| 196 | // - C++26 wording for Library Hardening precludes a conforming Hardened implementation from using the Contracts | ||
| 197 | // `ignore` semantic when evaluating hardened preconditions in the Library. Libc++ allows using this semantic for | ||
| 198 | // hardened preconditions, however, be aware that using `ignore` does not produce a conforming "Hardened" | ||
| 199 | // implementation, unlike the other semantics above. | ||
| 200 | // clang-format off | ||
| 201 | # define _LIBCPP_ASSERTION_SEMANTIC_IGNORE (1 << 1) | ||
| 202 | # define _LIBCPP_ASSERTION_SEMANTIC_OBSERVE (1 << 2) | ||
| 203 | # define _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE (1 << 3) | ||
| 204 | # define _LIBCPP_ASSERTION_SEMANTIC_ENFORCE (1 << 4) | ||
| 205 | // clang-format on | ||
| 206 | |||
| 207 | // Allow users to define an arbitrary assertion semantic; otherwise, use the default mapping from modes to semantics. | ||
| 208 | // The default is for production-capable modes to use `quick-enforce` (i.e., trap) and for the `debug` mode to use | ||
| 209 | // `enforce` (i.e., log and abort). | ||
| 210 | # ifndef _LIBCPP_ASSERTION_SEMANTIC | ||
| 211 | |||
| 212 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | ||
| 213 | # define _LIBCPP_ASSERTION_SEMANTIC _LIBCPP_ASSERTION_SEMANTIC_ENFORCE | ||
| 214 | # else | ||
| 215 | # define _LIBCPP_ASSERTION_SEMANTIC _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE | ||
| 216 | # endif | ||
| 217 | |||
| 218 | # else | ||
| 219 | # if !_LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 220 | # error "Assertion semantics are an experimental feature." | ||
| 221 | # endif | ||
| 222 | # if defined(_LIBCPP_CXX03_LANG) | ||
| 223 | # error "Assertion semantics are not available in the C++03 mode." | ||
| 224 | # endif | ||
| 225 | |||
| 226 | # endif // _LIBCPP_ASSERTION_SEMANTIC | ||
| 227 | |||
| 228 | // } HARDENING | ||
| 229 | |||
| 230 | # define _LIBCPP_TOSTRING2(x) #x | 43 | # define _LIBCPP_TOSTRING2(x) #x |
| 231 | # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) | 44 | # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) |
| 232 | 45 | ||
| ... | @@ -320,13 +133,6 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -320,13 +133,6 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 320 | // When this option is used, the token passed to `std::random_device`'s | 133 | // When this option is used, the token passed to `std::random_device`'s |
| 321 | // constructor *must* be "/dev/urandom" -- anything else is an error. | 134 | // constructor *must* be "/dev/urandom" -- anything else is an error. |
| 322 | // | 135 | // |
| 323 | // _LIBCPP_USING_NACL_RANDOM | ||
| 324 | // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, | ||
| 325 | // including accesses to the special files under `/dev`. This implementation | ||
| 326 | // uses the NaCL syscall `nacl_secure_random_init()` to get entropy. | ||
| 327 | // When this option is used, the token passed to `std::random_device`'s | ||
| 328 | // constructor *must* be "/dev/urandom" -- anything else is an error. | ||
| 329 | // | ||
| 330 | // _LIBCPP_USING_WIN32_RANDOM | 136 | // _LIBCPP_USING_WIN32_RANDOM |
| 331 | // Use rand_s(), for use on Windows. | 137 | // Use rand_s(), for use on Windows. |
| 332 | // When this option is used, the token passed to `std::random_device`'s | 138 | // When this option is used, the token passed to `std::random_device`'s |
| ... | @@ -338,8 +144,6 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -338,8 +144,6 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 338 | # define _LIBCPP_USING_GETENTROPY | 144 | # define _LIBCPP_USING_GETENTROPY |
| 339 | # elif defined(__Fuchsia__) | 145 | # elif defined(__Fuchsia__) |
| 340 | # define _LIBCPP_USING_FUCHSIA_CPRNG | 146 | # define _LIBCPP_USING_FUCHSIA_CPRNG |
| 341 | # elif defined(__native_client__) | ||
| 342 | # define _LIBCPP_USING_NACL_RANDOM | ||
| 343 | # elif defined(_LIBCPP_WIN32API) | 147 | # elif defined(_LIBCPP_WIN32API) |
| 344 | # define _LIBCPP_USING_WIN32_RANDOM | 148 | # define _LIBCPP_USING_WIN32_RANDOM |
| 345 | # else | 149 | # else |
| ... | @@ -348,7 +152,7 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -348,7 +152,7 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 348 | 152 | ||
| 349 | # ifndef _LIBCPP_CXX03_LANG | 153 | # ifndef _LIBCPP_CXX03_LANG |
| 350 | 154 | ||
| 351 | # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) | 155 | # define _LIBCPP_ALIGNOF(...) alignof(__VA_ARGS__) |
| 352 | # define _ALIGNAS_TYPE(x) alignas(x) | 156 | # define _ALIGNAS_TYPE(x) alignas(x) |
| 353 | # define _ALIGNAS(x) alignas(x) | 157 | # define _ALIGNAS(x) alignas(x) |
| 354 | # define _NOEXCEPT noexcept | 158 | # define _NOEXCEPT noexcept |
| ... | @@ -357,7 +161,7 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -357,7 +161,7 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 357 | 161 | ||
| 358 | # else | 162 | # else |
| 359 | 163 | ||
| 360 | # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) | 164 | # define _LIBCPP_ALIGNOF(...) _Alignof(__VA_ARGS__) |
| 361 | # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) | 165 | # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
| 362 | # define _ALIGNAS(x) __attribute__((__aligned__(x))) | 166 | # define _ALIGNAS(x) __attribute__((__aligned__(x))) |
| 363 | # define nullptr __nullptr | 167 | # define nullptr __nullptr |
| ... | @@ -471,6 +275,12 @@ typedef __char32_t char32_t; | ... | @@ -471,6 +275,12 @@ typedef __char32_t char32_t; |
| 471 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) | 275 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) |
| 472 | # endif | 276 | # endif |
| 473 | 277 | ||
| 278 | // Macros to enter and leave a state where deprecation warnings are suppressed. | ||
| 279 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ | ||
| 280 | _LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") \ | ||
| 281 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") | ||
| 282 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_DIAGNOSTIC_POP | ||
| 283 | |||
| 474 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST | 284 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST |
| 475 | # define _LIBCPP_HARDENING_SIG f | 285 | # define _LIBCPP_HARDENING_SIG f |
| 476 | # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE | 286 | # elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE |
| ... | @@ -481,6 +291,16 @@ typedef __char32_t char32_t; | ... | @@ -481,6 +291,16 @@ typedef __char32_t char32_t; |
| 481 | # define _LIBCPP_HARDENING_SIG n // "none" | 291 | # define _LIBCPP_HARDENING_SIG n // "none" |
| 482 | # endif | 292 | # endif |
| 483 | 293 | ||
| 294 | # if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE | ||
| 295 | # define _LIBCPP_ASSERTION_SEMANTIC_SIG o | ||
| 296 | # elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE | ||
| 297 | # define _LIBCPP_ASSERTION_SEMANTIC_SIG q | ||
| 298 | # elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE | ||
| 299 | # define _LIBCPP_ASSERTION_SEMANTIC_SIG e | ||
| 300 | # else | ||
| 301 | # define _LIBCPP_ASSERTION_SEMANTIC_SIG i // `ignore` | ||
| 302 | # endif | ||
| 303 | |||
| 484 | # if !_LIBCPP_HAS_EXCEPTIONS | 304 | # if !_LIBCPP_HAS_EXCEPTIONS |
| 485 | # define _LIBCPP_EXCEPTIONS_SIG n | 305 | # define _LIBCPP_EXCEPTIONS_SIG n |
| 486 | # else | 306 | # else |
| ... | @@ -488,7 +308,9 @@ typedef __char32_t char32_t; | ... | @@ -488,7 +308,9 @@ typedef __char32_t char32_t; |
| 488 | # endif | 308 | # endif |
| 489 | 309 | ||
| 490 | # define _LIBCPP_ODR_SIGNATURE \ | 310 | # define _LIBCPP_ODR_SIGNATURE \ |
| 491 | _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION) | 311 | _LIBCPP_CONCAT( \ |
| 312 | _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_ASSERTION_SEMANTIC_SIG), _LIBCPP_EXCEPTIONS_SIG), \ | ||
| 313 | _LIBCPP_VERSION) | ||
| 492 | 314 | ||
| 493 | // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved | 315 | // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved |
| 494 | // on two levels: | 316 | // on two levels: |
| ... | @@ -550,16 +372,6 @@ typedef __char32_t char32_t; | ... | @@ -550,16 +372,6 @@ typedef __char32_t char32_t; |
| 550 | # endif | 372 | # endif |
| 551 | # define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION | 373 | # define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION |
| 552 | 374 | ||
| 553 | # ifdef _LIBCPP_BUILDING_LIBRARY | ||
| 554 | # if _LIBCPP_ABI_VERSION > 1 | ||
| 555 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | ||
| 556 | # else | ||
| 557 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 | ||
| 558 | # endif | ||
| 559 | # else | ||
| 560 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | ||
| 561 | # endif | ||
| 562 | |||
| 563 | // Clang modules take a significant compile time hit when pushing and popping diagnostics. | 375 | // Clang modules take a significant compile time hit when pushing and popping diagnostics. |
| 564 | // Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can | 376 | // Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can |
| 565 | // simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined. | 377 | // simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined. |
| ... | @@ -676,27 +488,6 @@ typedef __char32_t char32_t; | ... | @@ -676,27 +488,6 @@ typedef __char32_t char32_t; |
| 676 | # endif | 488 | # endif |
| 677 | # endif | 489 | # endif |
| 678 | 490 | ||
| 679 | // It is not yet possible to use aligned_alloc() on all Apple platforms since | ||
| 680 | // 10.15 was the first version to ship an implementation of aligned_alloc(). | ||
| 681 | # if defined(__APPLE__) | ||
| 682 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ | ||
| 683 | __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ | ||
| 684 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ | ||
| 685 | __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 686 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \ | ||
| 687 | __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) || \ | ||
| 688 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) | ||
| 689 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 | ||
| 690 | # else | ||
| 691 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 | ||
| 692 | # endif | ||
| 693 | # elif defined(__ANDROID__) && __ANDROID_API__ < 28 | ||
| 694 | // Android only provides aligned_alloc when targeting API 28 or higher. | ||
| 695 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 | ||
| 696 | # else | ||
| 697 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 | ||
| 698 | # endif | ||
| 699 | |||
| 700 | # if defined(__APPLE__) || defined(__FreeBSD__) | 491 | # if defined(__APPLE__) || defined(__FreeBSD__) |
| 701 | # define _LIBCPP_WCTYPE_IS_MASK | 492 | # define _LIBCPP_WCTYPE_IS_MASK |
| 702 | # endif | 493 | # endif |
| ... | @@ -727,6 +518,15 @@ typedef __char32_t char32_t; | ... | @@ -727,6 +518,15 @@ typedef __char32_t char32_t; |
| 727 | # define _LIBCPP_DEPRECATED_(m) | 518 | # define _LIBCPP_DEPRECATED_(m) |
| 728 | # endif | 519 | # endif |
| 729 | 520 | ||
| 521 | // FIXME: using `#warning` causes diagnostics from system headers which include deprecated headers. This can only be | ||
| 522 | // enabled again once https://github.com/llvm/llvm-project/pull/168041 (or a similar feature) has landed, since that | ||
| 523 | // allows suppression in system headers. | ||
| 524 | # if defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && 0 | ||
| 525 | # define _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS 1 | ||
| 526 | # else | ||
| 527 | # define _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS 0 | ||
| 528 | # endif | ||
| 529 | |||
| 730 | # if !defined(_LIBCPP_CXX03_LANG) | 530 | # if !defined(_LIBCPP_CXX03_LANG) |
| 731 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED | 531 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED |
| 732 | # else | 532 | # else |
| ... | @@ -771,17 +571,6 @@ typedef __char32_t char32_t; | ... | @@ -771,17 +571,6 @@ typedef __char32_t char32_t; |
| 771 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T | 571 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T |
| 772 | # endif | 572 | # endif |
| 773 | 573 | ||
| 774 | // Macros to enter and leave a state where deprecation warnings are suppressed. | ||
| 775 | # if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) | ||
| 776 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ | ||
| 777 | _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ | ||
| 778 | _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") | ||
| 779 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") | ||
| 780 | # else | ||
| 781 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 782 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 783 | # endif | ||
| 784 | |||
| 785 | # if _LIBCPP_STD_VER <= 11 | 574 | # if _LIBCPP_STD_VER <= 11 |
| 786 | # define _LIBCPP_EXPLICIT_SINCE_CXX14 | 575 | # define _LIBCPP_EXPLICIT_SINCE_CXX14 |
| 787 | # else | 576 | # else |
| ... | @@ -861,18 +650,10 @@ typedef __char32_t char32_t; | ... | @@ -861,18 +650,10 @@ typedef __char32_t char32_t; |
| 861 | # endif // _LIBCPP_HAS_THREAD_API | 650 | # endif // _LIBCPP_HAS_THREAD_API |
| 862 | # endif // _LIBCPP_HAS_THREADS | 651 | # endif // _LIBCPP_HAS_THREADS |
| 863 | 652 | ||
| 864 | # if _LIBCPP_HAS_THREAD_API_PTHREAD | 653 | # if !_LIBCPP_HAS_THREAD_API_PTHREAD |
| 865 | # if defined(__ANDROID__) && __ANDROID_API__ >= 30 | 654 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 |
| 866 | # define _LIBCPP_HAS_COND_CLOCKWAIT 1 | 655 | # elif (defined(__ANDROID__) && __ANDROID_API__ >= 30) || _LIBCPP_GLIBC_PREREQ(2, 30) |
| 867 | # elif defined(_LIBCPP_GLIBC_PREREQ) | 656 | # define _LIBCPP_HAS_COND_CLOCKWAIT 1 |
| 868 | # if _LIBCPP_GLIBC_PREREQ(2, 30) | ||
| 869 | # define _LIBCPP_HAS_COND_CLOCKWAIT 1 | ||
| 870 | # else | ||
| 871 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 | ||
| 872 | # endif | ||
| 873 | # else | ||
| 874 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 | ||
| 875 | # endif | ||
| 876 | # else | 657 | # else |
| 877 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 | 658 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 |
| 878 | # endif | 659 | # endif |
| ... | @@ -951,8 +732,8 @@ typedef __char32_t char32_t; | ... | @@ -951,8 +732,8 @@ typedef __char32_t char32_t; |
| 951 | # endif | 732 | # endif |
| 952 | # endif | 733 | # endif |
| 953 | 734 | ||
| 954 | # if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__) | 735 | # if __has_cpp_attribute(_Clang::__no_thread_safety_analysis__) |
| 955 | # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((__no_thread_safety_analysis__)) | 736 | # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS [[_Clang::__no_thread_safety_analysis__]] |
| 956 | # else | 737 | # else |
| 957 | # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS | 738 | # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS |
| 958 | # endif | 739 | # endif |
| ... | @@ -1038,12 +819,8 @@ typedef __char32_t char32_t; | ... | @@ -1038,12 +819,8 @@ typedef __char32_t char32_t; |
| 1038 | // the latter depends on internal GNU libc details that are not appropriate | 819 | // the latter depends on internal GNU libc details that are not appropriate |
| 1039 | // to depend on here, so any declarations present when __cpp_char8_t is not | 820 | // to depend on here, so any declarations present when __cpp_char8_t is not |
| 1040 | // defined are ignored. | 821 | // defined are ignored. |
| 1041 | # if defined(_LIBCPP_GLIBC_PREREQ) | 822 | # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t) |
| 1042 | # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t) | 823 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1 |
| 1043 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1 | ||
| 1044 | # else | ||
| 1045 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0 | ||
| 1046 | # endif | ||
| 1047 | # else | 824 | # else |
| 1048 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0 | 825 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0 |
| 1049 | # endif | 826 | # endif |
| ... | @@ -1067,8 +844,7 @@ typedef __char32_t char32_t; | ... | @@ -1067,8 +844,7 @@ typedef __char32_t char32_t; |
| 1067 | # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "") | 844 | # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "") |
| 1068 | # endif | 845 | # endif |
| 1069 | 846 | ||
| 1070 | // TODO(LLVM 22): Remove the workaround | 847 | # if defined(__OBJC__) && defined(_LIBCPP_APPLE_CLANG_VER) |
| 1071 | # if defined(__OBJC__) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER < 2001) | ||
| 1072 | # define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS | 848 | # define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS |
| 1073 | # endif | 849 | # endif |
| 1074 | 850 | ||
| ... | @@ -1153,12 +929,33 @@ typedef __char32_t char32_t; | ... | @@ -1153,12 +929,33 @@ typedef __char32_t char32_t; |
| 1153 | # define _LIBCPP_DIAGNOSE_WARNING(...) | 929 | # define _LIBCPP_DIAGNOSE_WARNING(...) |
| 1154 | # endif | 930 | # endif |
| 1155 | 931 | ||
| 932 | # if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_APPLE_CLANG_VER) && \ | ||
| 933 | (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 2001) | ||
| 934 | # define _LIBCPP_DIAGNOSE_IF(...) __attribute__((__diagnose_if__(__VA_ARGS__))) | ||
| 935 | # else | ||
| 936 | # define _LIBCPP_DIAGNOSE_IF(...) | ||
| 937 | # endif | ||
| 938 | |||
| 939 | # define _LIBCPP_DIAGNOSE_NULLPTR_IF(condition, condition_description) \ | ||
| 940 | _LIBCPP_DIAGNOSE_IF( \ | ||
| 941 | condition, \ | ||
| 942 | "null passed to callee that requires a non-null argument" condition_description, \ | ||
| 943 | "warning", \ | ||
| 944 | "nonnull") | ||
| 945 | |||
| 1156 | # if __has_cpp_attribute(_Clang::__lifetimebound__) | 946 | # if __has_cpp_attribute(_Clang::__lifetimebound__) |
| 1157 | # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]] | 947 | # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]] |
| 1158 | # else | 948 | # else |
| 1159 | # define _LIBCPP_LIFETIMEBOUND | 949 | # define _LIBCPP_LIFETIMEBOUND |
| 1160 | # endif | 950 | # endif |
| 1161 | 951 | ||
| 952 | // This is to work around https://llvm.org/PR156809 | ||
| 953 | # ifndef _LIBCPP_CXX03_LANG | ||
| 954 | # define _LIBCPP_CTOR_LIFETIMEBOUND _LIBCPP_LIFETIMEBOUND | ||
| 955 | # else | ||
| 956 | # define _LIBCPP_CTOR_LIFETIMEBOUND | ||
| 957 | # endif | ||
| 958 | |||
| 1162 | # if __has_cpp_attribute(_Clang::__noescape__) | 959 | # if __has_cpp_attribute(_Clang::__noescape__) |
| 1163 | # define _LIBCPP_NOESCAPE [[_Clang::__noescape__]] | 960 | # define _LIBCPP_NOESCAPE [[_Clang::__noescape__]] |
| 1164 | # else | 961 | # else |
| ... | @@ -1172,12 +969,6 @@ typedef __char32_t char32_t; | ... | @@ -1172,12 +969,6 @@ typedef __char32_t char32_t; |
| 1172 | # define _LIBCPP_NO_SPECIALIZATIONS | 969 | # define _LIBCPP_NO_SPECIALIZATIONS |
| 1173 | # endif | 970 | # endif |
| 1174 | 971 | ||
| 1175 | # if __has_cpp_attribute(_Clang::__standalone_debug__) | ||
| 1176 | # define _LIBCPP_STANDALONE_DEBUG [[_Clang::__standalone_debug__]] | ||
| 1177 | # else | ||
| 1178 | # define _LIBCPP_STANDALONE_DEBUG | ||
| 1179 | # endif | ||
| 1180 | |||
| 1181 | # if __has_cpp_attribute(_Clang::__preferred_name__) | 972 | # if __has_cpp_attribute(_Clang::__preferred_name__) |
| 1182 | # define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]] | 973 | # define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]] |
| 1183 | # else | 974 | # else |
| ... | @@ -1257,14 +1048,6 @@ typedef __char32_t char32_t; | ... | @@ -1257,14 +1048,6 @@ typedef __char32_t char32_t; |
| 1257 | # define _LIBCPP_DIAGNOSE_NULLPTR | 1048 | # define _LIBCPP_DIAGNOSE_NULLPTR |
| 1258 | # endif | 1049 | # endif |
| 1259 | 1050 | ||
| 1260 | // TODO(LLVM 22): Remove this macro once LLVM19 support ends. __cpp_explicit_this_parameter has been set in LLVM20. | ||
| 1261 | // Clang-18 has support for deducing this, but it does not set the FTM. | ||
| 1262 | # if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800) | ||
| 1263 | # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1 | ||
| 1264 | # else | ||
| 1265 | # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0 | ||
| 1266 | # endif | ||
| 1267 | |||
| 1268 | #endif // __cplusplus | 1051 | #endif // __cplusplus |
| 1269 | 1052 | ||
| 1270 | #endif // _LIBCPP___CONFIG | 1053 | #endif // _LIBCPP___CONFIG |
lib/libcxx/include/__configuration/abi.h+14-24| ... | @@ -61,19 +61,9 @@ | ... | @@ -61,19 +61,9 @@ |
| 61 | // According to the Standard, `bitset::operator[] const` returns bool | 61 | // According to the Standard, `bitset::operator[] const` returns bool |
| 62 | # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | 62 | # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL |
| 63 | 63 | ||
| 64 | // In LLVM 20, we've changed to take these ABI breaks unconditionally. These flags only exist in case someone is running | ||
| 65 | // into the static_asserts we added to catch the ABI break and don't care that it is one. | ||
| 66 | // TODO(LLVM 22): Remove these flags | ||
| 67 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | ||
| 68 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | ||
| 69 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | ||
| 70 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | ||
| 71 | |||
| 72 | // These flags are documented in ABIGuarantees.rst | 64 | // These flags are documented in ABIGuarantees.rst |
| 73 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 65 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
| 74 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | 66 | # define _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE |
| 75 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | ||
| 76 | # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | ||
| 77 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI | 67 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI |
| 78 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI | 68 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI |
| 79 | # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION | 69 | # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION |
| ... | @@ -84,25 +74,16 @@ | ... | @@ -84,25 +74,16 @@ |
| 84 | # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE | 74 | # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE |
| 85 | # define _LIBCPP_ABI_NO_ITERATOR_BASES | 75 | # define _LIBCPP_ABI_NO_ITERATOR_BASES |
| 86 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT | 76 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT |
| 77 | # define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER | ||
| 87 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION | 78 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION |
| 88 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | 79 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO |
| 89 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | 80 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 90 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY | 81 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY |
| 91 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW | 82 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW |
| 92 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | 83 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION |
| 84 | # define _LIBCPP_ABI_TRIVIALLY_COPYABLE_BIT_ITERATOR | ||
| 93 | 85 | ||
| 94 | #elif _LIBCPP_ABI_VERSION == 1 | 86 | #elif _LIBCPP_ABI_VERSION == 1 |
| 95 | # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) | ||
| 96 | // Enable compiling copies of now inline methods into the dylib to support | ||
| 97 | // applications compiled against older libraries. This is unnecessary with | ||
| 98 | // COFF dllexport semantics, since dllexport forces a non-inline definition | ||
| 99 | // of inline functions to be emitted anyway. Our own non-inline copy would | ||
| 100 | // conflict with the dllexport-emitted copy, so we disable it. For XCOFF, | ||
| 101 | // the linker will take issue with the symbols in the shared object if the | ||
| 102 | // weak inline methods get visibility (such as from -fvisibility-inlines-hidden), | ||
| 103 | // so disable it. | ||
| 104 | # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | ||
| 105 | # endif | ||
| 106 | // Feature macros for disabling pre ABI v1 features. All of these options | 87 | // Feature macros for disabling pre ABI v1 features. All of these options |
| 107 | // are deprecated. | 88 | // are deprecated. |
| 108 | # if defined(__FreeBSD__) | 89 | # if defined(__FreeBSD__) |
| ... | @@ -110,11 +91,20 @@ | ... | @@ -110,11 +91,20 @@ |
| 110 | # endif | 91 | # endif |
| 111 | #endif | 92 | #endif |
| 112 | 93 | ||
| 94 | // TODO(LLVM 22): Remove this check | ||
| 95 | #if defined(_LIBCPP_ABI_NO_ITERATOR_BASES) && !defined(_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER) | ||
| 96 | # ifndef _LIBCPP_ONLY_NO_ITERATOR_BASES | ||
| 97 | # error "You probably want to define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER. This has been split out from" \ | ||
| 98 | " _LIBCPP_ABI_NO_ITERATOR_BASES to allow only removing the second iterator member, since they aren't really related." \ | ||
| 99 | "If you actually want this ABI configuration, please define _LIBCPP_ONLY_NO_ITERATOR_BASES instead." | ||
| 100 | # endif | ||
| 101 | #endif | ||
| 102 | |||
| 113 | // We had some bugs where we use [[no_unique_address]] together with construct_at, | 103 | // We had some bugs where we use [[no_unique_address]] together with construct_at, |
| 114 | // which causes UB as the call on construct_at could write to overlapping subobjects | 104 | // which causes UB as the call on construct_at could write to overlapping subobjects |
| 115 | // | 105 | // |
| 116 | // https://github.com/llvm/llvm-project/issues/70506 | 106 | // https://llvm.org/PR70506 |
| 117 | // https://github.com/llvm/llvm-project/issues/70494 | 107 | // https://llvm.org/PR70494 |
| 118 | // | 108 | // |
| 119 | // To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions. | 109 | // To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions. |
| 120 | // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. | 110 | // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. |
lib/libcxx/include/__configuration/availability.h+65-118| ... | @@ -17,62 +17,17 @@ | ... | @@ -17,62 +17,17 @@ |
| 17 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | // Libc++ is shipped by various vendors. In particular, it is used as a system | 20 | // This file defines a framework that can be used by vendors to encode the version of an operating system that various |
| 21 | // library on macOS, iOS and other Apple platforms. In order for users to be | 21 | // features of libc++ has been shipped in. This is primarily intended to allow safely deploying an executable built with |
| 22 | // able to compile a binary that is intended to be deployed to an older version | 22 | // a new version of the library on a platform containing an older version of the built library. |
| 23 | // of a platform, Clang provides availability attributes [1]. These attributes | 23 | // Detailed documentation for this can be found at https://libcxx.llvm.org/VendorDocumentation.html#availability-markup |
| 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 | 24 | ||
| 70 | // Availability markup is disabled when building the library, or when a non-Clang | 25 | // Availability markup is disabled when building the library, or when a non-Clang |
| 71 | // compiler is used because only Clang supports the necessary attributes. | 26 | // compiler is used because only Clang supports the necessary attributes. |
| 72 | // | 27 | // |
| 73 | // We also allow users to force-disable availability markup via the `_LIBCPP_DISABLE_AVAILABILITY` | 28 | // We also allow users to force-disable availability markup via the `_LIBCPP_DISABLE_AVAILABILITY` |
| 74 | // macro because that is the only way to work around a Clang bug related to availability | 29 | // macro because that is the only way to work around a Clang bug related to availability |
| 75 | // attributes: https://github.com/llvm/llvm-project/issues/134151. | 30 | // attributes: https://llvm.org/PR134151. |
| 76 | // Once that bug has been fixed, we should remove the macro. | 31 | // Once that bug has been fixed, we should remove the macro. |
| 77 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || \ | 32 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || \ |
| 78 | !defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_DISABLE_AVAILABILITY) | 33 | !defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_DISABLE_AVAILABILITY) |
| ... | @@ -84,6 +39,9 @@ | ... | @@ -84,6 +39,9 @@ |
| 84 | // in all versions of the library are available. | 39 | // in all versions of the library are available. |
| 85 | #if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS | 40 | #if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS |
| 86 | 41 | ||
| 42 | # define _LIBCPP_INTRODUCED_IN_LLVM_22 1 | ||
| 43 | # define _LIBCPP_INTRODUCED_IN_LLVM_22_ATTRIBUTE /* nothing */ | ||
| 44 | |||
| 87 | # define _LIBCPP_INTRODUCED_IN_LLVM_21 1 | 45 | # define _LIBCPP_INTRODUCED_IN_LLVM_21 1 |
| 88 | # define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE /* nothing */ | 46 | # define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE /* nothing */ |
| 89 | 47 | ||
| ... | @@ -108,32 +66,55 @@ | ... | @@ -108,32 +66,55 @@ |
| 108 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 1 | 66 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 1 |
| 109 | # define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */ | 67 | # define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */ |
| 110 | 68 | ||
| 111 | # define _LIBCPP_INTRODUCED_IN_LLVM_11 1 | ||
| 112 | # define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE /* nothing */ | ||
| 113 | |||
| 114 | # define _LIBCPP_INTRODUCED_IN_LLVM_9 1 | ||
| 115 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE /* nothing */ | ||
| 116 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */ | ||
| 117 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */ | ||
| 118 | |||
| 119 | #elif defined(__APPLE__) | 69 | #elif defined(__APPLE__) |
| 120 | 70 | ||
| 121 | // clang-format off | 71 | // clang-format off |
| 122 | 72 | ||
| 73 | // LLVM 22 | ||
| 74 | // TODO: Fill this in | ||
| 75 | # define _LIBCPP_INTRODUCED_IN_LLVM_22 0 | ||
| 76 | # define _LIBCPP_INTRODUCED_IN_LLVM_22_ATTRIBUTE __attribute__((unavailable)) | ||
| 77 | |||
| 123 | // LLVM 21 | 78 | // LLVM 21 |
| 124 | // TODO: Fill this in | 79 | // TODO: Fill this in |
| 125 | # define _LIBCPP_INTRODUCED_IN_LLVM_21 0 | 80 | # define _LIBCPP_INTRODUCED_IN_LLVM_21 0 |
| 126 | # define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable)) | 81 | # define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable)) |
| 127 | 82 | ||
| 128 | // LLVM 20 | 83 | // LLVM 20 |
| 129 | // TODO: Fill this in | 84 | // |
| 130 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 0 | 85 | // Note that versions for most Apple OSes were bumped forward and aligned in that release. |
| 131 | # define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE __attribute__((unavailable)) | 86 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 260000) || \ |
| 87 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 260000) || \ | ||
| 88 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 260000) || \ | ||
| 89 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 260000) || \ | ||
| 90 | (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 100000) | ||
| 91 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 0 | ||
| 92 | # else | ||
| 93 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 1 | ||
| 94 | # endif | ||
| 95 | # define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE \ | ||
| 96 | __attribute__((availability(macos, strict, introduced = 26.0))) \ | ||
| 97 | __attribute__((availability(ios, strict, introduced = 26.0))) \ | ||
| 98 | __attribute__((availability(tvos, strict, introduced = 26.0))) \ | ||
| 99 | __attribute__((availability(watchos, strict, introduced = 26.0))) \ | ||
| 100 | __attribute__((availability(bridgeos, strict, introduced = 10.0))) | ||
| 132 | 101 | ||
| 133 | // LLVM 19 | 102 | // LLVM 19 |
| 134 | // TODO: Fill this in | 103 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150400) || \ |
| 135 | # define _LIBCPP_INTRODUCED_IN_LLVM_19 0 | 104 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 180400) || \ |
| 136 | # define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable)) | 105 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 180400) || \ |
| 106 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 110400) || \ | ||
| 107 | (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 90400) | ||
| 108 | # define _LIBCPP_INTRODUCED_IN_LLVM_19 0 | ||
| 109 | # else | ||
| 110 | # define _LIBCPP_INTRODUCED_IN_LLVM_19 1 | ||
| 111 | # endif | ||
| 112 | # define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE \ | ||
| 113 | __attribute__((availability(macos, strict, introduced = 15.4))) \ | ||
| 114 | __attribute__((availability(ios, strict, introduced = 18.4))) \ | ||
| 115 | __attribute__((availability(tvos, strict, introduced = 18.4))) \ | ||
| 116 | __attribute__((availability(watchos, strict, introduced = 11.4))) \ | ||
| 117 | __attribute__((availability(bridgeos, strict, introduced = 9.4))) | ||
| 137 | 118 | ||
| 138 | // LLVM 18 | 119 | // LLVM 18 |
| 139 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150000) || \ | 120 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150000) || \ |
| ... | @@ -215,47 +196,13 @@ | ... | @@ -215,47 +196,13 @@ |
| 215 | __attribute__((availability(bridgeos, strict, introduced = 6.0))) \ | 196 | __attribute__((availability(bridgeos, strict, introduced = 6.0))) \ |
| 216 | __attribute__((availability(driverkit, strict, introduced = 21.3))) | 197 | __attribute__((availability(driverkit, strict, introduced = 21.3))) |
| 217 | 198 | ||
| 218 | // LLVM 11 | 199 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \ |
| 219 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \ | 200 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150000) || \ |
| 220 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \ | 201 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150000) || \ |
| 221 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \ | 202 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80000) || \ |
| 222 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000) | 203 | (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 200000) |
| 223 | # define _LIBCPP_INTRODUCED_IN_LLVM_11 0 | 204 | # warning "The selected platform is no longer supported by libc++." |
| 224 | # else | ||
| 225 | # define _LIBCPP_INTRODUCED_IN_LLVM_11 1 | ||
| 226 | # endif | 205 | # endif |
| 227 | # define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE \ | ||
| 228 | __attribute__((availability(macos, strict, introduced = 11.0))) \ | ||
| 229 | __attribute__((availability(ios, strict, introduced = 14.0))) \ | ||
| 230 | __attribute__((availability(tvos, strict, introduced = 14.0))) \ | ||
| 231 | __attribute__((availability(watchos, strict, introduced = 7.0))) | ||
| 232 | |||
| 233 | // LLVM 9 | ||
| 234 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ | ||
| 235 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 236 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \ | ||
| 237 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) | ||
| 238 | # define _LIBCPP_INTRODUCED_IN_LLVM_9 0 | ||
| 239 | # else | ||
| 240 | # define _LIBCPP_INTRODUCED_IN_LLVM_9 1 | ||
| 241 | # endif | ||
| 242 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE \ | ||
| 243 | __attribute__((availability(macos, strict, introduced = 10.15))) \ | ||
| 244 | __attribute__((availability(ios, strict, introduced = 13.0))) \ | ||
| 245 | __attribute__((availability(tvos, strict, introduced = 13.0))) \ | ||
| 246 | __attribute__((availability(watchos, strict, introduced = 6.0))) | ||
| 247 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH \ | ||
| 248 | _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \ | ||
| 249 | _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \ | ||
| 250 | _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \ | ||
| 251 | _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))") | ||
| 252 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP \ | ||
| 253 | _Pragma("clang attribute pop") \ | ||
| 254 | _Pragma("clang attribute pop") \ | ||
| 255 | _Pragma("clang attribute pop") \ | ||
| 256 | _Pragma("clang attribute pop") | ||
| 257 | |||
| 258 | // clang-format on | ||
| 259 | 206 | ||
| 260 | #else | 207 | #else |
| 261 | 208 | ||
| ... | @@ -266,19 +213,12 @@ | ... | @@ -266,19 +213,12 @@ |
| 266 | 213 | ||
| 267 | #endif | 214 | #endif |
| 268 | 215 | ||
| 269 | // These macros control the availability of all parts of <filesystem> that | 216 | // This controls the availability of new implementation of std::atomic's |
| 270 | // depend on something in the dylib. | 217 | // wait, notify_one and notify_all. The new implementation uses |
| 271 | #define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9 | 218 | // the native atomic wait/notify operations on platforms that support them |
| 272 | #define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE | 219 | // based on the size of the atomic type, instead of the type itself. |
| 273 | #define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH | 220 | #define _LIBCPP_AVAILABILITY_HAS_NEW_SYNC _LIBCPP_INTRODUCED_IN_LLVM_22 |
| 274 | #define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP | 221 | #define _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_INTRODUCED_IN_LLVM_22_ATTRIBUTE |
| 275 | |||
| 276 | // This controls the availability of the C++20 synchronization library, | ||
| 277 | // which requires shared library support for various operations | ||
| 278 | // (see libcxx/src/atomic.cpp). This includes <barier>, <latch>, | ||
| 279 | // <semaphore>, and notification functions on std::atomic. | ||
| 280 | #define _LIBCPP_AVAILABILITY_HAS_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11 | ||
| 281 | #define _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE | ||
| 282 | 222 | ||
| 283 | // Enable additional explicit instantiations of iostreams components. This | 223 | // Enable additional explicit instantiations of iostreams components. This |
| 284 | // reduces the number of weak definitions generated in programs that use | 224 | // reduces the number of weak definitions generated in programs that use |
| ... | @@ -307,7 +247,7 @@ | ... | @@ -307,7 +247,7 @@ |
| 307 | // This controls the availability of the C++17 std::pmr library, | 247 | // This controls the availability of the C++17 std::pmr library, |
| 308 | // which is implemented in large part in the built library. | 248 | // which is implemented in large part in the built library. |
| 309 | // | 249 | // |
| 310 | // TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed | 250 | // TODO: Enable std::pmr markup once https://llvm.org/PR40340 has been fixed |
| 311 | // Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support | 251 | // Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support |
| 312 | // 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 | 252 | // it and it'll be a load-time error, but we don't have a good alternative because the library won't compile if we |
| 313 | // use availability annotations until that bug has been fixed. | 253 | // use availability annotations until that bug has been fixed. |
| ... | @@ -364,4 +304,11 @@ | ... | @@ -364,4 +304,11 @@ |
| 364 | # define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION | 304 | # define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION |
| 365 | #endif | 305 | #endif |
| 366 | 306 | ||
| 307 | // Only define a bunch of symbols in the dylib if we need to be compatible with LLVM 7 headers or older | ||
| 308 | # if defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 8 | ||
| 309 | # define _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 | ||
| 310 | # else | ||
| 311 | # define _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 _LIBCPP_HIDE_FROM_ABI | ||
| 312 | # endif | ||
| 313 | |||
| 367 | #endif // _LIBCPP___CONFIGURATION_AVAILABILITY_H | 314 | #endif // _LIBCPP___CONFIGURATION_AVAILABILITY_H |
lib/libcxx/include/__configuration/compiler.h+6-6| ... | @@ -33,16 +33,16 @@ | ... | @@ -33,16 +33,16 @@ |
| 33 | // Warn if a compiler version is used that is not supported anymore | 33 | // Warn if a compiler version is used that is not supported anymore |
| 34 | // LLVM RELEASE Update the minimum compiler versions | 34 | // LLVM RELEASE Update the minimum compiler versions |
| 35 | # if defined(_LIBCPP_CLANG_VER) | 35 | # if defined(_LIBCPP_CLANG_VER) |
| 36 | # if _LIBCPP_CLANG_VER < 1900 | 36 | # if _LIBCPP_CLANG_VER < 2001 |
| 37 | # warning "Libc++ only supports Clang 19 and later" | 37 | # warning "Libc++ only supports Clang 20 and later" |
| 38 | # endif | 38 | # endif |
| 39 | # elif defined(_LIBCPP_APPLE_CLANG_VER) | 39 | # elif defined(_LIBCPP_APPLE_CLANG_VER) |
| 40 | # if _LIBCPP_APPLE_CLANG_VER < 1500 | 40 | # if _LIBCPP_APPLE_CLANG_VER < 1700 |
| 41 | # warning "Libc++ only supports AppleClang 15 and later" | 41 | # warning "Libc++ only supports AppleClang 26 and later" |
| 42 | # endif | 42 | # endif |
| 43 | # elif defined(_LIBCPP_GCC_VER) | 43 | # elif defined(_LIBCPP_GCC_VER) |
| 44 | # if _LIBCPP_GCC_VER < 1400 | 44 | # if _LIBCPP_GCC_VER < 1500 |
| 45 | # warning "Libc++ only supports GCC 14 and later" | 45 | # warning "Libc++ only supports GCC 15 and later" |
| 46 | # endif | 46 | # endif |
| 47 | # endif | 47 | # endif |
| 48 | 48 |
lib/libcxx/include/__configuration/experimental.h created+38| ... | @@ -0,0 +1,38 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___CONFIGURATION_EXPERIMENTAL_H | ||
| 10 | #define _LIBCPP___CONFIGURATION_EXPERIMENTAL_H | ||
| 11 | |||
| 12 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ | ||
| 13 | |||
| 14 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #if __has_feature(experimental_library) | ||
| 19 | # ifndef _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 20 | # define _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 21 | # endif | ||
| 22 | #endif | ||
| 23 | |||
| 24 | // Incomplete features get their own specific disabling flags. This makes it | ||
| 25 | // easier to grep for target specific flags once the feature is complete. | ||
| 26 | #if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 27 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1 | ||
| 28 | #else | ||
| 29 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0 | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 33 | #define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 34 | #define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 35 | #define _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 36 | #define _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 37 | |||
| 38 | #endif // _LIBCPP___CONFIGURATION_EXPERIMENTAL_H | ||
lib/libcxx/include/__configuration/hardening.h created+215| ... | @@ -0,0 +1,215 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___CONFIGURATION_HARDENING_H | ||
| 10 | #define _LIBCPP___CONFIGURATION_HARDENING_H | ||
| 11 | |||
| 12 | /* zig patch: instead of including __config_site, zig adds -D flags when compiling */ | ||
| 13 | #include <__configuration/experimental.h> | ||
| 14 | #include <__configuration/language.h> | ||
| 15 | |||
| 16 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | // TODO(LLVM 23): Remove this. We're making these an error to catch folks who might not have migrated. | ||
| 21 | // Since hardening went through several changes (many of which impacted user-facing macros), | ||
| 22 | // we're keeping these checks around for a bit longer than usual. Failure to properly configure | ||
| 23 | // hardening results in checks being dropped silently, which is a pretty big deal. | ||
| 24 | #if defined(_LIBCPP_ENABLE_ASSERTIONS) | ||
| 25 | # error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 26 | #endif | ||
| 27 | #if defined(_LIBCPP_ENABLE_HARDENED_MODE) | ||
| 28 | # error "_LIBCPP_ENABLE_HARDENED_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 29 | #endif | ||
| 30 | #if defined(_LIBCPP_ENABLE_SAFE_MODE) | ||
| 31 | # error "_LIBCPP_ENABLE_SAFE_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 32 | #endif | ||
| 33 | #if defined(_LIBCPP_ENABLE_DEBUG_MODE) | ||
| 34 | # error "_LIBCPP_ENABLE_DEBUG_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 35 | #endif | ||
| 36 | |||
| 37 | // The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values: | ||
| 38 | // | ||
| 39 | // - `_LIBCPP_HARDENING_MODE_NONE`; | ||
| 40 | // - `_LIBCPP_HARDENING_MODE_FAST`; | ||
| 41 | // - `_LIBCPP_HARDENING_MODE_EXTENSIVE`; | ||
| 42 | // - `_LIBCPP_HARDENING_MODE_DEBUG`. | ||
| 43 | // | ||
| 44 | // These values have the following effects: | ||
| 45 | // | ||
| 46 | // - `_LIBCPP_HARDENING_MODE_NONE` -- sets the hardening mode to "none" which disables all runtime hardening checks; | ||
| 47 | // | ||
| 48 | // - `_LIBCPP_HARDENING_MODE_FAST` -- sets that hardening mode to "fast". The fast mode enables security-critical checks | ||
| 49 | // that can be done with relatively little runtime overhead in constant time; | ||
| 50 | // | ||
| 51 | // - `_LIBCPP_HARDENING_MODE_EXTENSIVE` -- sets the hardening mode to "extensive". The extensive mode is a superset of | ||
| 52 | // the fast mode that additionally enables checks that are relatively cheap and prevent common types of logic errors | ||
| 53 | // but are not necessarily security-critical; | ||
| 54 | // | ||
| 55 | // - `_LIBCPP_HARDENING_MODE_DEBUG` -- sets the hardening mode to "debug". The debug mode is a superset of the extensive | ||
| 56 | // mode and enables all checks available in the library, including internal assertions. Checks that are part of the | ||
| 57 | // debug mode can be very expensive and thus the debug mode is intended to be used for testing, not in production. | ||
| 58 | |||
| 59 | // Inside the library, assertions are categorized so they can be cherry-picked based on the chosen hardening mode. These | ||
| 60 | // macros are only for internal use -- users should only pick one of the high-level hardening modes described above. | ||
| 61 | // | ||
| 62 | // - `_LIBCPP_ASSERT_VALID_INPUT_RANGE` -- checks that ranges (whether expressed as an iterator pair, an iterator and | ||
| 63 | // a sentinel, an iterator and a count, or a `std::range`) given as input to library functions are valid: | ||
| 64 | // - the sentinel is reachable from the begin iterator; | ||
| 65 | // - TODO(hardening): both iterators refer to the same container. | ||
| 66 | // | ||
| 67 | // - `_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS` -- checks that any attempts to access a container element, whether through | ||
| 68 | // the container object or through an iterator, are valid and do not attempt to go out of bounds or otherwise access | ||
| 69 | // a non-existent element. For iterator checks to work, bounded iterators must be enabled in the ABI. Types like | ||
| 70 | // `optional` and `function` are considered one-element containers for the purposes of this check. | ||
| 71 | // | ||
| 72 | // - `_LIBCPP_ASSERT_NON_NULL` -- checks that the pointer being dereferenced is not null. On most modern platforms zero | ||
| 73 | // address does not refer to an actual location in memory, so a null pointer dereference would not compromize the | ||
| 74 | // memory security of a program (however, it is still undefined behavior that can result in strange errors due to | ||
| 75 | // compiler optimizations). | ||
| 76 | // | ||
| 77 | // - `_LIBCPP_ASSERT_NON_OVERLAPPING_RANGES` -- for functions that take several ranges as arguments, checks that the | ||
| 78 | // given ranges do not overlap. | ||
| 79 | // | ||
| 80 | // - `_LIBCPP_ASSERT_VALID_DEALLOCATION` -- checks that an attempt to deallocate memory is valid (e.g. the given object | ||
| 81 | // was allocated by the given allocator). Violating this category typically results in a memory leak. | ||
| 82 | // | ||
| 83 | // - `_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL` -- checks that a call to an external API doesn't fail in | ||
| 84 | // an unexpected manner. This includes triggering documented cases of undefined behavior in an external library (like | ||
| 85 | // attempting to unlock an unlocked mutex in pthreads). Any API external to the library falls under this category | ||
| 86 | // (from system calls to compiler intrinsics). We generally don't expect these failures to compromize memory safety or | ||
| 87 | // otherwise create an immediate security issue. | ||
| 88 | // | ||
| 89 | // - `_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR` -- checks any operations that exchange nodes between containers to make sure | ||
| 90 | // the containers have compatible allocators. | ||
| 91 | // | ||
| 92 | // - `_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN` -- checks that the given argument is within the domain of valid arguments | ||
| 93 | // for the function. Violating this typically produces an incorrect result (e.g. the clamp algorithm returns the | ||
| 94 | // original value without clamping it due to incorrect functors) or puts an object into an invalid state (e.g. | ||
| 95 | // a string view where only a subset of elements is possible to access). This category is for assertions violating | ||
| 96 | // which doesn't cause any immediate issues in the library -- whatever the consequences are, they will happen in the | ||
| 97 | // user code. | ||
| 98 | // | ||
| 99 | // - `_LIBCPP_ASSERT_PEDANTIC` -- checks prerequisites which are imposed by the Standard, but violating which happens to | ||
| 100 | // be benign in our implementation. | ||
| 101 | // | ||
| 102 | // - `_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT` -- checks that the given argument satisfies the semantic requirements imposed | ||
| 103 | // by the Standard. Typically, there is no simple way to completely prove that a semantic requirement is satisfied; | ||
| 104 | // thus, this would often be a heuristic check and it might be quite expensive. | ||
| 105 | // | ||
| 106 | // - `_LIBCPP_ASSERT_INTERNAL` -- checks that internal invariants of the library hold. These assertions don't depend on | ||
| 107 | // user input. | ||
| 108 | // | ||
| 109 | // - `_LIBCPP_ASSERT_UNCATEGORIZED` -- for assertions that haven't been properly classified yet. | ||
| 110 | |||
| 111 | // clang-format off | ||
| 112 | # define _LIBCPP_HARDENING_MODE_NONE (1 << 1) | ||
| 113 | # define _LIBCPP_HARDENING_MODE_FAST (1 << 2) | ||
| 114 | # define _LIBCPP_HARDENING_MODE_EXTENSIVE (1 << 4) // Deliberately not ordered. | ||
| 115 | # define _LIBCPP_HARDENING_MODE_DEBUG (1 << 3) | ||
| 116 | // clang-format on | ||
| 117 | |||
| 118 | #ifndef _LIBCPP_HARDENING_MODE | ||
| 119 | |||
| 120 | # ifndef _LIBCPP_HARDENING_MODE_DEFAULT | ||
| 121 | # error _LIBCPP_HARDENING_MODE_DEFAULT is not defined. This definition should be set at configuration time in the \ | ||
| 122 | `__config_site` header, please make sure your installation of libc++ is not broken. | ||
| 123 | # endif | ||
| 124 | |||
| 125 | # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT | ||
| 126 | #endif | ||
| 127 | |||
| 128 | #if _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_NONE && _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_FAST && \ | ||
| 129 | _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_EXTENSIVE && \ | ||
| 130 | _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_DEBUG | ||
| 131 | # error _LIBCPP_HARDENING_MODE must be set to one of the following values: \ | ||
| 132 | _LIBCPP_HARDENING_MODE_NONE, \ | ||
| 133 | _LIBCPP_HARDENING_MODE_FAST, \ | ||
| 134 | _LIBCPP_HARDENING_MODE_EXTENSIVE, \ | ||
| 135 | _LIBCPP_HARDENING_MODE_DEBUG | ||
| 136 | #endif | ||
| 137 | |||
| 138 | // The library provides the macro `_LIBCPP_ASSERTION_SEMANTIC` for configuring the assertion semantic used by hardening; | ||
| 139 | // it can be set to one of the following values: | ||
| 140 | // | ||
| 141 | // - `_LIBCPP_ASSERTION_SEMANTIC_IGNORE`; | ||
| 142 | // - `_LIBCPP_ASSERTION_SEMANTIC_OBSERVE`; | ||
| 143 | // - `_LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE`; | ||
| 144 | // - `_LIBCPP_ASSERTION_SEMANTIC_ENFORCE`. | ||
| 145 | // | ||
| 146 | // libc++ assertion semantics generally mirror the evaluation semantics of C++26 Contracts: | ||
| 147 | // - `ignore` evaluates the assertion but doesn't do anything if it fails (note that it differs from the Contracts | ||
| 148 | // `ignore` semantic which wouldn't evaluate the assertion at all); | ||
| 149 | // - `observe` logs an error (indicating, if possible, that the error is fatal) and continues execution; | ||
| 150 | // - `quick-enforce` terminates the program as fast as possible (via trapping); | ||
| 151 | // - `enforce` logs an error and then terminates the program. | ||
| 152 | // | ||
| 153 | // Additionally, a special `hardening-dependent` value selects the assertion semantic based on the hardening mode in | ||
| 154 | // effect: the production-capable modes (`fast` and `extensive`) map to `quick_enforce` and the `debug` mode maps to | ||
| 155 | // `enforce`. The `hardening-dependent` semantic cannot be selected explicitly, it is only used when no assertion | ||
| 156 | // semantic is provided by the user _and_ the library's default semantic is configured to be dependent on hardening. | ||
| 157 | // | ||
| 158 | // Notes: | ||
| 159 | // - Continuing execution after a hardening check fails results in undefined behavior; the `observe` semantic is meant | ||
| 160 | // to make adopting hardening easier but should not be used outside of this scenario; | ||
| 161 | // - C++26 wording for Library Hardening precludes a conforming Hardened implementation from using the Contracts | ||
| 162 | // `ignore` semantic when evaluating hardened preconditions in the Library. Libc++ allows using this semantic for | ||
| 163 | // hardened preconditions, however, be aware that using `ignore` does not produce a conforming "Hardened" | ||
| 164 | // implementation, unlike the other semantics above. | ||
| 165 | // clang-format off | ||
| 166 | # define _LIBCPP_ASSERTION_SEMANTIC_HARDENING_DEPENDENT (1 << 1) | ||
| 167 | # define _LIBCPP_ASSERTION_SEMANTIC_IGNORE (1 << 2) | ||
| 168 | # define _LIBCPP_ASSERTION_SEMANTIC_OBSERVE (1 << 3) | ||
| 169 | # define _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE (1 << 4) | ||
| 170 | # define _LIBCPP_ASSERTION_SEMANTIC_ENFORCE (1 << 5) | ||
| 171 | // clang-format on | ||
| 172 | |||
| 173 | // If the user attempts to configure the assertion semantic, check that it is allowed in the current environment. | ||
| 174 | #if defined(_LIBCPP_ASSERTION_SEMANTIC) | ||
| 175 | # if !_LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 176 | # error "Assertion semantics are an experimental feature." | ||
| 177 | # endif | ||
| 178 | # if defined(_LIBCPP_CXX03_LANG) | ||
| 179 | # error "Assertion semantics are not available in the C++03 mode." | ||
| 180 | # endif | ||
| 181 | #endif // defined(_LIBCPP_ASSERTION_SEMANTIC) | ||
| 182 | |||
| 183 | // User-provided semantic takes top priority -- don't override if set. | ||
| 184 | #ifndef _LIBCPP_ASSERTION_SEMANTIC | ||
| 185 | |||
| 186 | # ifndef _LIBCPP_ASSERTION_SEMANTIC_DEFAULT | ||
| 187 | # error _LIBCPP_ASSERTION_SEMANTIC_DEFAULT is not defined. This definition should be set at configuration time in \ | ||
| 188 | the `__config_site` header, please make sure your installation of libc++ is not broken. | ||
| 189 | # endif | ||
| 190 | |||
| 191 | # if _LIBCPP_ASSERTION_SEMANTIC_DEFAULT != _LIBCPP_ASSERTION_SEMANTIC_HARDENING_DEPENDENT | ||
| 192 | # define _LIBCPP_ASSERTION_SEMANTIC _LIBCPP_ASSERTION_SEMANTIC_DEFAULT | ||
| 193 | # else | ||
| 194 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | ||
| 195 | # define _LIBCPP_ASSERTION_SEMANTIC _LIBCPP_ASSERTION_SEMANTIC_ENFORCE | ||
| 196 | # else | ||
| 197 | # define _LIBCPP_ASSERTION_SEMANTIC _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE | ||
| 198 | # endif | ||
| 199 | # endif // _LIBCPP_ASSERTION_SEMANTIC_DEFAULT != _LIBCPP_ASSERTION_SEMANTIC_HARDENING_DEPENDENT | ||
| 200 | |||
| 201 | #endif // #ifndef _LIBCPP_ASSERTION_SEMANTIC | ||
| 202 | |||
| 203 | // Finally, validate the selected semantic (in case the user tries setting it to an incorrect value): | ||
| 204 | #if _LIBCPP_ASSERTION_SEMANTIC != _LIBCPP_ASSERTION_SEMANTIC_IGNORE && \ | ||
| 205 | _LIBCPP_ASSERTION_SEMANTIC != _LIBCPP_ASSERTION_SEMANTIC_OBSERVE && \ | ||
| 206 | _LIBCPP_ASSERTION_SEMANTIC != _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE && \ | ||
| 207 | _LIBCPP_ASSERTION_SEMANTIC != _LIBCPP_ASSERTION_SEMANTIC_ENFORCE | ||
| 208 | # error _LIBCPP_ASSERTION_SEMANTIC must be set to one of the following values: \ | ||
| 209 | _LIBCPP_ASSERTION_SEMANTIC_IGNORE, \ | ||
| 210 | _LIBCPP_ASSERTION_SEMANTIC_OBSERVE, \ | ||
| 211 | _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE, \ | ||
| 212 | _LIBCPP_ASSERTION_SEMANTIC_ENFORCE | ||
| 213 | #endif | ||
| 214 | |||
| 215 | #endif // _LIBCPP___CONFIGURATION_HARDENING_H | ||
lib/libcxx/include/__configuration/language.h+3| ... | @@ -18,6 +18,9 @@ | ... | @@ -18,6 +18,9 @@ |
| 18 | 18 | ||
| 19 | // NOLINTBEGIN(libcpp-cpp-version-check) | 19 | // NOLINTBEGIN(libcpp-cpp-version-check) |
| 20 | #ifdef __cplusplus | 20 | #ifdef __cplusplus |
| 21 | # if __cplusplus < 201103L | ||
| 22 | # define _LIBCPP_CXX03_LANG | ||
| 23 | # endif | ||
| 21 | # if __cplusplus <= 201103L | 24 | # if __cplusplus <= 201103L |
| 22 | # define _LIBCPP_STD_VER 11 | 25 | # define _LIBCPP_STD_VER 11 |
| 23 | # elif __cplusplus <= 201402L | 26 | # elif __cplusplus <= 201402L |
lib/libcxx/include/__configuration/platform.h+9-16| ... | @@ -31,22 +31,15 @@ | ... | @@ -31,22 +31,15 @@ |
| 31 | #endif | 31 | #endif |
| 32 | 32 | ||
| 33 | // Need to detect which libc we're using if we're on Linux. | 33 | // Need to detect which libc we're using if we're on Linux. |
| 34 | #if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__) | 34 | #if (defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)) && __has_include(<features.h>) |
| 35 | # if __has_include(<features.h>) | 35 | # include <features.h> |
| 36 | # include <features.h> | 36 | # if defined(__GLIBC_PREREQ) |
| 37 | # if defined(__GLIBC_PREREQ) | 37 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) |
| 38 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) | 38 | # else |
| 39 | # else | 39 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 |
| 40 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 | 40 | # endif // defined(__GLIBC_PREREQ) |
| 41 | # endif // defined(__GLIBC_PREREQ) | 41 | #else |
| 42 | # endif | 42 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 |
| 43 | #endif | ||
| 44 | |||
| 45 | // This is required in order for _NEWLIB_VERSION to be defined in places where we use it. | ||
| 46 | // TODO: We shouldn't be including arbitrarily-named headers from libc++ since this can break valid | ||
| 47 | // user code. Move code paths that need _NEWLIB_VERSION to another customization mechanism. | ||
| 48 | #if __has_include(<picolibc.h>) | ||
| 49 | # include <picolibc.h> | ||
| 50 | #endif | 43 | #endif |
| 51 | 44 | ||
| 52 | #ifndef __BYTE_ORDER__ | 45 | #ifndef __BYTE_ORDER__ |
lib/libcxx/include/__coroutine/coroutine_handle.h+9-9| ... | @@ -44,9 +44,9 @@ public: | ... | @@ -44,9 +44,9 @@ public: |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | // [coroutine.handle.export.import], export/import | 46 | // [coroutine.handle.export.import], export/import |
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; } | 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; } |
| 48 | 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI static constexpr coroutine_handle from_address(void* __addr) noexcept { | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr coroutine_handle from_address(void* __addr) noexcept { |
| 50 | coroutine_handle __tmp; | 50 | coroutine_handle __tmp; |
| 51 | __tmp.__handle_ = __addr; | 51 | __tmp.__handle_ = __addr; |
| 52 | return __tmp; | 52 | return __tmp; |
| ... | @@ -55,7 +55,7 @@ public: | ... | @@ -55,7 +55,7 @@ public: |
| 55 | // [coroutine.handle.observers], observers | 55 | // [coroutine.handle.observers], observers |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __handle_ != nullptr; } | 56 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __handle_ != nullptr; } |
| 57 | 57 | ||
| 58 | _LIBCPP_HIDE_FROM_ABI bool done() const { | 58 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool done() const { |
| 59 | _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "done() can be called only on suspended coroutines"); | 59 | _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "done() can be called only on suspended coroutines"); |
| 60 | return __builtin_coro_done(__handle_); | 60 | return __builtin_coro_done(__handle_); |
| 61 | } | 61 | } |
| ... | @@ -100,7 +100,7 @@ public: | ... | @@ -100,7 +100,7 @@ public: |
| 100 | 100 | ||
| 101 | _LIBCPP_HIDE_FROM_ABI constexpr coroutine_handle(nullptr_t) noexcept {} | 101 | _LIBCPP_HIDE_FROM_ABI constexpr coroutine_handle(nullptr_t) noexcept {} |
| 102 | 102 | ||
| 103 | _LIBCPP_HIDE_FROM_ABI static coroutine_handle from_promise(_Promise& __promise) { | 103 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static coroutine_handle from_promise(_Promise& __promise) { |
| 104 | using _RawPromise = __remove_cv_t<_Promise>; | 104 | using _RawPromise = __remove_cv_t<_Promise>; |
| 105 | coroutine_handle __tmp; | 105 | coroutine_handle __tmp; |
| 106 | __tmp.__handle_ = | 106 | __tmp.__handle_ = |
| ... | @@ -114,9 +114,9 @@ public: | ... | @@ -114,9 +114,9 @@ public: |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | // [coroutine.handle.export.import], export/import | 116 | // [coroutine.handle.export.import], export/import |
| 117 | _LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; } | 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; } |
| 118 | 118 | ||
| 119 | _LIBCPP_HIDE_FROM_ABI static constexpr coroutine_handle from_address(void* __addr) noexcept { | 119 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr coroutine_handle from_address(void* __addr) noexcept { |
| 120 | coroutine_handle __tmp; | 120 | coroutine_handle __tmp; |
| 121 | __tmp.__handle_ = __addr; | 121 | __tmp.__handle_ = __addr; |
| 122 | return __tmp; | 122 | return __tmp; |
| ... | @@ -130,7 +130,7 @@ public: | ... | @@ -130,7 +130,7 @@ public: |
| 130 | // [coroutine.handle.observers], observers | 130 | // [coroutine.handle.observers], observers |
| 131 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __handle_ != nullptr; } | 131 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __handle_ != nullptr; } |
| 132 | 132 | ||
| 133 | _LIBCPP_HIDE_FROM_ABI bool done() const { | 133 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool done() const { |
| 134 | _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "done() can be called only on suspended coroutines"); | 134 | _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "done() can be called only on suspended coroutines"); |
| 135 | return __builtin_coro_done(__handle_); | 135 | return __builtin_coro_done(__handle_); |
| 136 | } | 136 | } |
| ... | @@ -150,7 +150,7 @@ public: | ... | @@ -150,7 +150,7 @@ public: |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | // [coroutine.handle.promise], promise access | 152 | // [coroutine.handle.promise], promise access |
| 153 | _LIBCPP_HIDE_FROM_ABI _Promise& promise() const { | 153 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Promise& promise() const { |
| 154 | return *static_cast<_Promise*>(__builtin_coro_promise(this->__handle_, alignof(_Promise), false)); | 154 | return *static_cast<_Promise*>(__builtin_coro_promise(this->__handle_, alignof(_Promise), false)); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| ... | @@ -165,7 +165,7 @@ private: | ... | @@ -165,7 +165,7 @@ private: |
| 165 | // [coroutine.handle.hash] | 165 | // [coroutine.handle.hash] |
| 166 | template <class _Tp> | 166 | template <class _Tp> |
| 167 | struct hash<coroutine_handle<_Tp>> { | 167 | struct hash<coroutine_handle<_Tp>> { |
| 168 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const coroutine_handle<_Tp>& __v) const noexcept { | 168 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t operator()(const coroutine_handle<_Tp>& __v) const noexcept { |
| 169 | return hash<void*>()(__v.address()); | 169 | return hash<void*>()(__v.address()); |
| 170 | } | 170 | } |
| 171 | }; | 171 | }; |
lib/libcxx/include/__coroutine/noop_coroutine_handle.h+11-13| ... | @@ -20,8 +20,6 @@ | ... | @@ -20,8 +20,6 @@ |
| 20 | 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | # if __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC) | ||
| 24 | |||
| 25 | // [coroutine.noop] | 23 | // [coroutine.noop] |
| 26 | // [coroutine.promise.noop] | 24 | // [coroutine.promise.noop] |
| 27 | struct noop_coroutine_promise {}; | 25 | struct noop_coroutine_promise {}; |
| ... | @@ -37,7 +35,7 @@ public: | ... | @@ -37,7 +35,7 @@ public: |
| 37 | 35 | ||
| 38 | // [coroutine.handle.noop.observers], observers | 36 | // [coroutine.handle.noop.observers], observers |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return true; } | 37 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return true; } |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr bool done() const noexcept { return false; } | 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool done() const noexcept { return false; } |
| 41 | 39 | ||
| 42 | // [coroutine.handle.noop.resumption], resumption | 40 | // [coroutine.handle.noop.resumption], resumption |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr void operator()() const noexcept {} | 41 | _LIBCPP_HIDE_FROM_ABI constexpr void operator()() const noexcept {} |
| ... | @@ -45,23 +43,23 @@ public: | ... | @@ -45,23 +43,23 @@ public: |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr void destroy() const noexcept {} | 43 | _LIBCPP_HIDE_FROM_ABI constexpr void destroy() const noexcept {} |
| 46 | 44 | ||
| 47 | // [coroutine.handle.noop.promise], promise access | 45 | // [coroutine.handle.noop.promise], promise access |
| 48 | _LIBCPP_HIDE_FROM_ABI noop_coroutine_promise& promise() const noexcept { | 46 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI noop_coroutine_promise& promise() const noexcept { |
| 49 | return *static_cast<noop_coroutine_promise*>( | 47 | return *static_cast<noop_coroutine_promise*>( |
| 50 | __builtin_coro_promise(this->__handle_, alignof(noop_coroutine_promise), false)); | 48 | __builtin_coro_promise(this->__handle_, alignof(noop_coroutine_promise), false)); |
| 51 | } | 49 | } |
| 52 | 50 | ||
| 53 | // [coroutine.handle.noop.address], address | 51 | // [coroutine.handle.noop.address], address |
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; } | 52 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; } |
| 55 | 53 | ||
| 56 | private: | 54 | private: |
| 57 | _LIBCPP_HIDE_FROM_ABI friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept; | 55 | _LIBCPP_HIDE_FROM_ABI friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept; |
| 58 | 56 | ||
| 59 | # if __has_builtin(__builtin_coro_noop) | 57 | # if __has_builtin(__builtin_coro_noop) |
| 60 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { this->__handle_ = __builtin_coro_noop(); } | 58 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { this->__handle_ = __builtin_coro_noop(); } |
| 61 | 59 | ||
| 62 | void* __handle_ = nullptr; | 60 | void* __handle_ = nullptr; |
| 63 | 61 | ||
| 64 | # elif defined(_LIBCPP_COMPILER_GCC) | 62 | # elif defined(_LIBCPP_COMPILER_GCC) |
| 65 | // GCC doesn't implement __builtin_coro_noop(). | 63 | // GCC doesn't implement __builtin_coro_noop(). |
| 66 | // Construct the coroutine frame manually instead. | 64 | // Construct the coroutine frame manually instead. |
| 67 | struct __noop_coroutine_frame_ty_ { | 65 | struct __noop_coroutine_frame_ty_ { |
| ... | @@ -78,19 +76,19 @@ private: | ... | @@ -78,19 +76,19 @@ private: |
| 78 | 76 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept = default; | 77 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept = default; |
| 80 | 78 | ||
| 81 | # endif // __has_builtin(__builtin_coro_noop) | 79 | # endif // __has_builtin(__builtin_coro_noop) |
| 82 | }; | 80 | }; |
| 83 | 81 | ||
| 84 | using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>; | 82 | using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>; |
| 85 | 83 | ||
| 86 | # if defined(_LIBCPP_COMPILER_GCC) | 84 | # if defined(_LIBCPP_COMPILER_GCC) |
| 87 | inline noop_coroutine_handle::__noop_coroutine_frame_ty_ noop_coroutine_handle::__noop_coroutine_frame_{}; | 85 | inline noop_coroutine_handle::__noop_coroutine_frame_ty_ noop_coroutine_handle::__noop_coroutine_frame_{}; |
| 88 | # endif | 86 | # endif |
| 89 | 87 | ||
| 90 | // [coroutine.noop.coroutine] | 88 | // [coroutine.noop.coroutine] |
| 91 | inline _LIBCPP_HIDE_FROM_ABI noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); } | 89 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI noop_coroutine_handle noop_coroutine() noexcept { |
| 92 | 90 | return noop_coroutine_handle(); | |
| 93 | # endif // __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC) | 91 | } |
| 94 | 92 | ||
| 95 | _LIBCPP_END_NAMESPACE_STD | 93 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 94 |
lib/libcxx/include/__debug_utils/strict_weak_ordering_check.h+1-1| ... | @@ -27,7 +27,7 @@ template <class _RandomAccessIterator, class _Comp> | ... | @@ -27,7 +27,7 @@ template <class _RandomAccessIterator, class _Comp> |
| 27 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 27 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 28 | __check_strict_weak_ordering_sorted(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) { | 28 | __check_strict_weak_ordering_sorted(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) { |
| 29 | #if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | 29 | #if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG |
| 30 | using __diff_t = __iter_diff_t<_RandomAccessIterator>; | 30 | using __diff_t = __iterator_difference_type<_RandomAccessIterator>; |
| 31 | using _Comp_ref = __comp_ref_type<_Comp>; | 31 | using _Comp_ref = __comp_ref_type<_Comp>; |
| 32 | if (!__libcpp_is_constant_evaluated()) { | 32 | if (!__libcpp_is_constant_evaluated()) { |
| 33 | // Check if the range is actually sorted. | 33 | // Check if the range is actually sorted. |
lib/libcxx/include/__exception/exception.h+6-4| ... | @@ -48,13 +48,15 @@ public: | ... | @@ -48,13 +48,15 @@ public: |
| 48 | __data_._DoFree = true; | 48 | __data_._DoFree = true; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | exception(exception const&) _NOEXCEPT {} | 51 | exception(exception const&) _NOEXCEPT : __data_() {} |
| 52 | 52 | ||
| 53 | exception& operator=(exception const&) _NOEXCEPT { return *this; } | 53 | exception& operator=(exception const&) _NOEXCEPT { return *this; } |
| 54 | 54 | ||
| 55 | virtual ~exception() _NOEXCEPT {} | 55 | virtual ~exception() _NOEXCEPT {} |
| 56 | 56 | ||
| 57 | virtual char const* what() const _NOEXCEPT { return __data_._What ? __data_._What : "Unknown exception"; } | 57 | [[__nodiscard__]] virtual char const* what() const _NOEXCEPT { |
| 58 | return __data_._What ? __data_._What : "Unknown exception"; | ||
| 59 | } | ||
| 58 | 60 | ||
| 59 | private: | 61 | private: |
| 60 | __std_exception_data __data_; | 62 | __std_exception_data __data_; |
| ... | @@ -76,7 +78,7 @@ public: | ... | @@ -76,7 +78,7 @@ public: |
| 76 | _LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default; | 78 | _LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default; |
| 77 | 79 | ||
| 78 | virtual ~exception() _NOEXCEPT; | 80 | virtual ~exception() _NOEXCEPT; |
| 79 | virtual const char* what() const _NOEXCEPT; | 81 | [[__nodiscard__]] virtual const char* what() const _NOEXCEPT; |
| 80 | }; | 82 | }; |
| 81 | 83 | ||
| 82 | class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception { | 84 | class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception { |
| ... | @@ -85,7 +87,7 @@ public: | ... | @@ -85,7 +87,7 @@ public: |
| 85 | _LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default; | 87 | _LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default; |
| 86 | _LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default; | 88 | _LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default; |
| 87 | ~bad_exception() _NOEXCEPT override; | 89 | ~bad_exception() _NOEXCEPT override; |
| 88 | const char* what() const _NOEXCEPT override; | 90 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 89 | }; | 91 | }; |
| 90 | #endif // !_LIBCPP_ABI_VCRUNTIME | 92 | #endif // !_LIBCPP_ABI_VCRUNTIME |
| 91 | 93 |
lib/libcxx/include/__exception/exception_ptr.h+27-5| ... | @@ -11,18 +11,24 @@ | ... | @@ -11,18 +11,24 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/nullptr_t.h> | 13 | #include <__cstddef/nullptr_t.h> |
| 14 | #include <__cstddef/size_t.h> | ||
| 14 | #include <__exception/operations.h> | 15 | #include <__exception/operations.h> |
| 15 | #include <__memory/addressof.h> | 16 | #include <__memory/addressof.h> |
| 16 | #include <__memory/construct_at.h> | 17 | #include <__memory/construct_at.h> |
| 17 | #include <__type_traits/decay.h> | 18 | #include <__type_traits/decay.h> |
| 18 | #include <__type_traits/is_pointer.h> | 19 | #include <__type_traits/is_pointer.h> |
| 19 | #include <cstdlib> | 20 | #include <__utility/move.h> |
| 21 | #include <__utility/swap.h> | ||
| 22 | #include <__verbose_abort> | ||
| 20 | #include <typeinfo> | 23 | #include <typeinfo> |
| 21 | 24 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | # pragma GCC system_header | 26 | # pragma GCC system_header |
| 24 | #endif | 27 | #endif |
| 25 | 28 | ||
| 29 | _LIBCPP_PUSH_MACROS | ||
| 30 | #include <__undef_macros> | ||
| 31 | |||
| 26 | #ifndef _LIBCPP_ABI_MICROSOFT | 32 | #ifndef _LIBCPP_ABI_MICROSOFT |
| 27 | 33 | ||
| 28 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION | 34 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION |
| ... | @@ -30,7 +36,7 @@ | ... | @@ -30,7 +36,7 @@ |
| 30 | namespace __cxxabiv1 { | 36 | namespace __cxxabiv1 { |
| 31 | 37 | ||
| 32 | extern "C" { | 38 | extern "C" { |
| 33 | _LIBCPP_OVERRIDABLE_FUNC_VIS void* __cxa_allocate_exception(size_t) throw(); | 39 | _LIBCPP_OVERRIDABLE_FUNC_VIS void* __cxa_allocate_exception(std::size_t) throw(); |
| 34 | _LIBCPP_OVERRIDABLE_FUNC_VIS void __cxa_free_exception(void*) throw(); | 40 | _LIBCPP_OVERRIDABLE_FUNC_VIS void __cxa_free_exception(void*) throw(); |
| 35 | 41 | ||
| 36 | struct __cxa_exception; | 42 | struct __cxa_exception; |
| ... | @@ -57,6 +63,8 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD | ... | @@ -57,6 +63,8 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 57 | 63 | ||
| 58 | #ifndef _LIBCPP_ABI_MICROSOFT | 64 | #ifndef _LIBCPP_ABI_MICROSOFT |
| 59 | 65 | ||
| 66 | inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT; | ||
| 67 | |||
| 60 | class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { | 68 | class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { |
| 61 | void* __ptr_; | 69 | void* __ptr_; |
| 62 | 70 | ||
| ... | @@ -67,15 +75,21 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { | ... | @@ -67,15 +75,21 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { |
| 67 | 75 | ||
| 68 | public: | 76 | public: |
| 69 | // exception_ptr is basically a COW string so it is trivially relocatable. | 77 | // exception_ptr is basically a COW string so it is trivially relocatable. |
| 70 | // It is also replaceable because assignment has normal value semantics. | ||
| 71 | using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr; | 78 | using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr; |
| 72 | using __replaceable _LIBCPP_NODEBUG = exception_ptr; | ||
| 73 | 79 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {} | 80 | _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {} |
| 75 | _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} | 81 | _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} |
| 76 | 82 | ||
| 77 | exception_ptr(const exception_ptr&) _NOEXCEPT; | 83 | exception_ptr(const exception_ptr&) _NOEXCEPT; |
| 84 | _LIBCPP_HIDE_FROM_ABI exception_ptr(exception_ptr&& __other) _NOEXCEPT : __ptr_(__other.__ptr_) { | ||
| 85 | __other.__ptr_ = nullptr; | ||
| 86 | } | ||
| 78 | exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; | 87 | exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; |
| 88 | _LIBCPP_HIDE_FROM_ABI exception_ptr& operator=(exception_ptr&& __other) _NOEXCEPT { | ||
| 89 | exception_ptr __tmp(std::move(__other)); | ||
| 90 | std::swap(__tmp, *this); | ||
| 91 | return *this; | ||
| 92 | } | ||
| 79 | ~exception_ptr() _NOEXCEPT; | 93 | ~exception_ptr() _NOEXCEPT; |
| 80 | 94 | ||
| 81 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __ptr_ != nullptr; } | 95 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __ptr_ != nullptr; } |
| ... | @@ -88,10 +102,16 @@ public: | ... | @@ -88,10 +102,16 @@ public: |
| 88 | return !(__x == __y); | 102 | return !(__x == __y); |
| 89 | } | 103 | } |
| 90 | 104 | ||
| 105 | friend _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT; | ||
| 106 | |||
| 91 | friend _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; | 107 | friend _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; |
| 92 | friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | 108 | friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); |
| 93 | }; | 109 | }; |
| 94 | 110 | ||
| 111 | inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT { | ||
| 112 | std::swap(__x.__ptr_, __y.__ptr_); | ||
| 113 | } | ||
| 114 | |||
| 95 | # if _LIBCPP_HAS_EXCEPTIONS | 115 | # if _LIBCPP_HAS_EXCEPTIONS |
| 96 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION | 116 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION |
| 97 | template <class _Ep> | 117 | template <class _Ep> |
| ... | @@ -153,7 +173,7 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { | ... | @@ -153,7 +173,7 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { |
| 153 | # else // !_LIBCPP_HAS_EXCEPTIONS | 173 | # else // !_LIBCPP_HAS_EXCEPTIONS |
| 154 | template <class _Ep> | 174 | template <class _Ep> |
| 155 | _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT { | 175 | _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT { |
| 156 | std::abort(); | 176 | _LIBCPP_VERBOSE_ABORT("make_exception_ptr was called in -fno-exceptions mode"); |
| 157 | } | 177 | } |
| 158 | # endif // _LIBCPP_HAS_EXCEPTIONS | 178 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 159 | 179 | ||
| ... | @@ -201,4 +221,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { | ... | @@ -201,4 +221,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { |
| 201 | #endif // _LIBCPP_ABI_MICROSOFT | 221 | #endif // _LIBCPP_ABI_MICROSOFT |
| 202 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD | 222 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 203 | 223 | ||
| 224 | _LIBCPP_POP_MACROS | ||
| 225 | |||
| 204 | #endif // _LIBCPP___EXCEPTION_EXCEPTION_PTR_H | 226 | #endif // _LIBCPP___EXCEPTION_EXCEPTION_PTR_H |
lib/libcxx/include/__exception/nested_exception.h+2-2| ... | @@ -40,7 +40,7 @@ public: | ... | @@ -40,7 +40,7 @@ public: |
| 40 | 40 | ||
| 41 | // access functions | 41 | // access functions |
| 42 | [[__noreturn__]] void rethrow_nested() const; | 42 | [[__noreturn__]] void rethrow_nested() const; |
| 43 | _LIBCPP_HIDE_FROM_ABI exception_ptr nested_ptr() const _NOEXCEPT { return __ptr_; } | 43 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI exception_ptr nested_ptr() const _NOEXCEPT { return __ptr_; } |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | template <class _Tp> | 46 | template <class _Tp> |
| ... | @@ -73,7 +73,7 @@ template <class _Tp> | ... | @@ -73,7 +73,7 @@ template <class _Tp> |
| 73 | __throw_with_nested<_Tp, | 73 | __throw_with_nested<_Tp, |
| 74 | _Up, | 74 | _Up, |
| 75 | is_class<_Up>::value && !is_base_of<nested_exception, _Up>::value && | 75 | is_class<_Up>::value && !is_base_of<nested_exception, _Up>::value && |
| 76 | !__libcpp_is_final<_Up>::value>::__do_throw(std::forward<_Tp>(__t)); | 76 | !__is_final_v<_Up> >::__do_throw(std::forward<_Tp>(__t)); |
| 77 | #else | 77 | #else |
| 78 | ((void)__t); | 78 | ((void)__t); |
| 79 | // FIXME: Make this abort | 79 | // FIXME: Make this abort |
lib/libcxx/include/__exception/operations.h+5-5| ... | @@ -20,22 +20,22 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD | ... | @@ -20,22 +20,22 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 20 | defined(_LIBCPP_BUILDING_LIBRARY) | 20 | defined(_LIBCPP_BUILDING_LIBRARY) |
| 21 | using unexpected_handler = void (*)(); | 21 | using unexpected_handler = void (*)(); |
| 22 | _LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT; | 22 | _LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT; |
| 23 | _LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT; | 23 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT; |
| 24 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void unexpected(); | 24 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void unexpected(); |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | using terminate_handler = void (*)(); | 27 | using terminate_handler = void (*)(); |
| 28 | _LIBCPP_EXPORTED_FROM_ABI terminate_handler set_terminate(terminate_handler) _NOEXCEPT; | 28 | _LIBCPP_EXPORTED_FROM_ABI terminate_handler set_terminate(terminate_handler) _NOEXCEPT; |
| 29 | _LIBCPP_EXPORTED_FROM_ABI terminate_handler get_terminate() _NOEXCEPT; | 29 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI terminate_handler get_terminate() _NOEXCEPT; |
| 30 | 30 | ||
| 31 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) | 31 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) |
| 32 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 bool uncaught_exception() _NOEXCEPT; | 32 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 bool uncaught_exception() _NOEXCEPT; |
| 33 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) | 33 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) |
| 34 | _LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT; | 34 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT; |
| 35 | 35 | ||
| 36 | class _LIBCPP_EXPORTED_FROM_ABI exception_ptr; | 36 | class _LIBCPP_EXPORTED_FROM_ABI exception_ptr; |
| 37 | 37 | ||
| 38 | _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; | 38 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; |
| 39 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | 39 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); |
| 40 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD | 40 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 41 | 41 |
lib/libcxx/include/__expected/bad_expected_access.h+8-6| ... | @@ -43,9 +43,11 @@ protected: | ... | @@ -43,9 +43,11 @@ protected: |
| 43 | 43 | ||
| 44 | public: | 44 | public: |
| 45 | # if _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION | 45 | # if _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION |
| 46 | const char* what() const noexcept override; | 46 | [[nodiscard]] const char* what() const noexcept override; |
| 47 | # else | 47 | # else |
| 48 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const noexcept override { return "bad access to std::expected"; } | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const noexcept override { |
| 49 | return "bad access to std::expected"; | ||
| 50 | } | ||
| 49 | # endif | 51 | # endif |
| 50 | }; | 52 | }; |
| 51 | _LIBCPP_DIAGNOSTIC_POP | 53 | _LIBCPP_DIAGNOSTIC_POP |
| ... | @@ -55,10 +57,10 @@ class bad_expected_access : public bad_expected_access<void> { | ... | @@ -55,10 +57,10 @@ class bad_expected_access : public bad_expected_access<void> { |
| 55 | public: | 57 | public: |
| 56 | _LIBCPP_HIDE_FROM_ABI explicit bad_expected_access(_Err __e) : __unex_(std::move(__e)) {} | 58 | _LIBCPP_HIDE_FROM_ABI explicit bad_expected_access(_Err __e) : __unex_(std::move(__e)) {} |
| 57 | 59 | ||
| 58 | _LIBCPP_HIDE_FROM_ABI _Err& error() & noexcept { return __unex_; } | 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Err& error() & noexcept { return __unex_; } |
| 59 | _LIBCPP_HIDE_FROM_ABI const _Err& error() const& noexcept { return __unex_; } | 61 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const _Err& error() const& noexcept { return __unex_; } |
| 60 | _LIBCPP_HIDE_FROM_ABI _Err&& error() && noexcept { return std::move(__unex_); } | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Err&& error() && noexcept { return std::move(__unex_); } |
| 61 | _LIBCPP_HIDE_FROM_ABI const _Err&& error() const&& noexcept { return std::move(__unex_); } | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const _Err&& error() const&& noexcept { return std::move(__unex_); } |
| 62 | 64 | ||
| 63 | private: | 65 | private: |
| 64 | _Err __unex_; | 66 | _Err __unex_; |
lib/libcxx/include/__expected/expected.h+62-64| ... | @@ -30,7 +30,6 @@ | ... | @@ -30,7 +30,6 @@ |
| 30 | #include <__type_traits/is_nothrow_assignable.h> | 30 | #include <__type_traits/is_nothrow_assignable.h> |
| 31 | #include <__type_traits/is_nothrow_constructible.h> | 31 | #include <__type_traits/is_nothrow_constructible.h> |
| 32 | #include <__type_traits/is_reference.h> | 32 | #include <__type_traits/is_reference.h> |
| 33 | #include <__type_traits/is_replaceable.h> | ||
| 34 | #include <__type_traits/is_same.h> | 33 | #include <__type_traits/is_same.h> |
| 35 | #include <__type_traits/is_swappable.h> | 34 | #include <__type_traits/is_swappable.h> |
| 36 | #include <__type_traits/is_trivially_constructible.h> | 35 | #include <__type_traits/is_trivially_constructible.h> |
| ... | @@ -472,8 +471,6 @@ public: | ... | @@ -472,8 +471,6 @@ public: |
| 472 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value, | 471 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value, |
| 473 | expected, | 472 | expected, |
| 474 | void>; | 473 | void>; |
| 475 | using __replaceable _LIBCPP_NODEBUG = | ||
| 476 | __conditional_t<__is_replaceable_v<_Tp> && __is_replaceable_v<_Err>, expected, void>; | ||
| 477 | 474 | ||
| 478 | template <class _Up> | 475 | template <class _Up> |
| 479 | using rebind = expected<_Up, error_type>; | 476 | using rebind = expected<_Up, error_type>; |
| ... | @@ -555,9 +552,10 @@ public: | ... | @@ -555,9 +552,10 @@ public: |
| 555 | is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened | 552 | is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened |
| 556 | : __base(__other.__has_val(), std::move(__other.__union())) {} | 553 | : __base(__other.__has_val(), std::move(__other.__union())) {} |
| 557 | 554 | ||
| 558 | template <class _Up = _Tp> | 555 | template <class _Up = remove_cv_t<_Tp>> |
| 559 | requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> && | 556 | requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> && |
| 560 | is_constructible_v<_Tp, _Up> && !__is_std_unexpected<remove_cvref_t<_Up>>::value && | 557 | !is_same_v<remove_cvref_t<_Up>, unexpect_t> && is_constructible_v<_Tp, _Up> && |
| 558 | !__is_std_unexpected<remove_cvref_t<_Up>>::value && | ||
| 561 | (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_expected<remove_cvref_t<_Up>>::value)) | 559 | (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_expected<remove_cvref_t<_Up>>::value)) |
| 562 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>) | 560 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>) |
| 563 | expected(_Up&& __u) noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened | 561 | expected(_Up&& __u) noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened |
| ... | @@ -668,7 +666,7 @@ public: | ... | @@ -668,7 +666,7 @@ public: |
| 668 | return *this; | 666 | return *this; |
| 669 | } | 667 | } |
| 670 | 668 | ||
| 671 | template <class _Up = _Tp> | 669 | template <class _Up = remove_cv_t<_Tp>> |
| 672 | _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(_Up&& __v) | 670 | _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(_Up&& __v) |
| 673 | requires(!is_same_v<expected, remove_cvref_t<_Up>> && !__is_std_unexpected<remove_cvref_t<_Up>>::value && | 671 | requires(!is_same_v<expected, remove_cvref_t<_Up>> && !__is_std_unexpected<remove_cvref_t<_Up>>::value && |
| 674 | is_constructible_v<_Tp, _Up> && is_assignable_v<_Tp&, _Up> && | 672 | is_constructible_v<_Tp, _Up> && is_assignable_v<_Tp&, _Up> && |
| ... | @@ -800,25 +798,25 @@ public: | ... | @@ -800,25 +798,25 @@ public: |
| 800 | return std::addressof(this->__val()); | 798 | return std::addressof(this->__val()); |
| 801 | } | 799 | } |
| 802 | 800 | ||
| 803 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const& noexcept { | 801 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const& noexcept { |
| 804 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 802 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 805 | this->__has_val(), "expected::operator* requires the expected to contain a value"); | 803 | this->__has_val(), "expected::operator* requires the expected to contain a value"); |
| 806 | return this->__val(); | 804 | return this->__val(); |
| 807 | } | 805 | } |
| 808 | 806 | ||
| 809 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() & noexcept { | 807 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() & noexcept { |
| 810 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 808 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 811 | this->__has_val(), "expected::operator* requires the expected to contain a value"); | 809 | this->__has_val(), "expected::operator* requires the expected to contain a value"); |
| 812 | return this->__val(); | 810 | return this->__val(); |
| 813 | } | 811 | } |
| 814 | 812 | ||
| 815 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& operator*() const&& noexcept { | 813 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& operator*() const&& noexcept { |
| 816 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 814 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 817 | this->__has_val(), "expected::operator* requires the expected to contain a value"); | 815 | this->__has_val(), "expected::operator* requires the expected to contain a value"); |
| 818 | return std::move(this->__val()); | 816 | return std::move(this->__val()); |
| 819 | } | 817 | } |
| 820 | 818 | ||
| 821 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator*() && noexcept { | 819 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator*() && noexcept { |
| 822 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 820 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 823 | this->__has_val(), "expected::operator* requires the expected to contain a value"); | 821 | this->__has_val(), "expected::operator* requires the expected to contain a value"); |
| 824 | return std::move(this->__val()); | 822 | return std::move(this->__val()); |
| ... | @@ -826,9 +824,9 @@ public: | ... | @@ -826,9 +824,9 @@ public: |
| 826 | 824 | ||
| 827 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return this->__has_val(); } | 825 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return this->__has_val(); } |
| 828 | 826 | ||
| 829 | _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__has_val(); } | 827 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__has_val(); } |
| 830 | 828 | ||
| 831 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& value() const& { | 829 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& value() const& { |
| 832 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); | 830 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); |
| 833 | if (!this->__has_val()) { | 831 | if (!this->__has_val()) { |
| 834 | std::__throw_bad_expected_access<_Err>(std::as_const(error())); | 832 | std::__throw_bad_expected_access<_Err>(std::as_const(error())); |
| ... | @@ -836,7 +834,7 @@ public: | ... | @@ -836,7 +834,7 @@ public: |
| 836 | return this->__val(); | 834 | return this->__val(); |
| 837 | } | 835 | } |
| 838 | 836 | ||
| 839 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() & { | 837 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() & { |
| 840 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); | 838 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); |
| 841 | if (!this->__has_val()) { | 839 | if (!this->__has_val()) { |
| 842 | std::__throw_bad_expected_access<_Err>(std::as_const(error())); | 840 | std::__throw_bad_expected_access<_Err>(std::as_const(error())); |
| ... | @@ -844,7 +842,7 @@ public: | ... | @@ -844,7 +842,7 @@ public: |
| 844 | return this->__val(); | 842 | return this->__val(); |
| 845 | } | 843 | } |
| 846 | 844 | ||
| 847 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& value() const&& { | 845 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& value() const&& { |
| 848 | static_assert(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>, | 846 | static_assert(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>, |
| 849 | "error_type has to be both copy constructible and constructible from decltype(std::move(error()))"); | 847 | "error_type has to be both copy constructible and constructible from decltype(std::move(error()))"); |
| 850 | if (!this->__has_val()) { | 848 | if (!this->__has_val()) { |
| ... | @@ -853,7 +851,7 @@ public: | ... | @@ -853,7 +851,7 @@ public: |
| 853 | return std::move(this->__val()); | 851 | return std::move(this->__val()); |
| 854 | } | 852 | } |
| 855 | 853 | ||
| 856 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() && { | 854 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() && { |
| 857 | static_assert(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>, | 855 | static_assert(is_copy_constructible_v<_Err> && is_constructible_v<_Err, decltype(std::move(error()))>, |
| 858 | "error_type has to be both copy constructible and constructible from decltype(std::move(error()))"); | 856 | "error_type has to be both copy constructible and constructible from decltype(std::move(error()))"); |
| 859 | if (!this->__has_val()) { | 857 | if (!this->__has_val()) { |
| ... | @@ -862,46 +860,46 @@ public: | ... | @@ -862,46 +860,46 @@ public: |
| 862 | return std::move(this->__val()); | 860 | return std::move(this->__val()); |
| 863 | } | 861 | } |
| 864 | 862 | ||
| 865 | _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { | 863 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { |
| 866 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 864 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 867 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 865 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 868 | return this->__unex(); | 866 | return this->__unex(); |
| 869 | } | 867 | } |
| 870 | 868 | ||
| 871 | _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { | 869 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { |
| 872 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 870 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 873 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 871 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 874 | return this->__unex(); | 872 | return this->__unex(); |
| 875 | } | 873 | } |
| 876 | 874 | ||
| 877 | _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { | 875 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { |
| 878 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 876 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 879 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 877 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 880 | return std::move(this->__unex()); | 878 | return std::move(this->__unex()); |
| 881 | } | 879 | } |
| 882 | 880 | ||
| 883 | _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { | 881 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { |
| 884 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 882 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 885 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 883 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 886 | return std::move(this->__unex()); | 884 | return std::move(this->__unex()); |
| 887 | } | 885 | } |
| 888 | 886 | ||
| 889 | template <class _Up> | 887 | template <class _Up = remove_cv_t<_Tp>> |
| 890 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) const& { | 888 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) const& { |
| 891 | static_assert(is_copy_constructible_v<_Tp>, "value_type has to be copy constructible"); | 889 | static_assert(is_copy_constructible_v<_Tp>, "value_type has to be copy constructible"); |
| 892 | static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type"); | 890 | static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type"); |
| 893 | return this->__has_val() ? this->__val() : static_cast<_Tp>(std::forward<_Up>(__v)); | 891 | return this->__has_val() ? this->__val() : static_cast<_Tp>(std::forward<_Up>(__v)); |
| 894 | } | 892 | } |
| 895 | 893 | ||
| 896 | template <class _Up> | 894 | template <class _Up = remove_cv_t<_Tp>> |
| 897 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) && { | 895 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) && { |
| 898 | static_assert(is_move_constructible_v<_Tp>, "value_type has to be move constructible"); | 896 | static_assert(is_move_constructible_v<_Tp>, "value_type has to be move constructible"); |
| 899 | static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type"); | 897 | static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type"); |
| 900 | return this->__has_val() ? std::move(this->__val()) : static_cast<_Tp>(std::forward<_Up>(__v)); | 898 | return this->__has_val() ? std::move(this->__val()) : static_cast<_Tp>(std::forward<_Up>(__v)); |
| 901 | } | 899 | } |
| 902 | 900 | ||
| 903 | template <class _Up = _Err> | 901 | template <class _Up = _Err> |
| 904 | _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) const& { | 902 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) const& { |
| 905 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); | 903 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); |
| 906 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); | 904 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); |
| 907 | if (has_value()) | 905 | if (has_value()) |
| ... | @@ -910,7 +908,7 @@ public: | ... | @@ -910,7 +908,7 @@ public: |
| 910 | } | 908 | } |
| 911 | 909 | ||
| 912 | template <class _Up = _Err> | 910 | template <class _Up = _Err> |
| 913 | _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) && { | 911 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) && { |
| 914 | static_assert(is_move_constructible_v<_Err>, "error_type has to be move constructible"); | 912 | static_assert(is_move_constructible_v<_Err>, "error_type has to be move constructible"); |
| 915 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); | 913 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); |
| 916 | if (has_value()) | 914 | if (has_value()) |
| ... | @@ -921,7 +919,7 @@ public: | ... | @@ -921,7 +919,7 @@ public: |
| 921 | // [expected.void.monadic], monadic | 919 | // [expected.void.monadic], monadic |
| 922 | template <class _Func> | 920 | template <class _Func> |
| 923 | requires is_constructible_v<_Err, _Err&> | 921 | requires is_constructible_v<_Err, _Err&> |
| 924 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { | 922 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { |
| 925 | using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>; | 923 | using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>; |
| 926 | static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); | 924 | static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); |
| 927 | static_assert(is_same_v<typename _Up::error_type, _Err>, | 925 | static_assert(is_same_v<typename _Up::error_type, _Err>, |
| ... | @@ -934,7 +932,7 @@ public: | ... | @@ -934,7 +932,7 @@ public: |
| 934 | 932 | ||
| 935 | template <class _Func> | 933 | template <class _Func> |
| 936 | requires is_constructible_v<_Err, const _Err&> | 934 | requires is_constructible_v<_Err, const _Err&> |
| 937 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { | 935 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { |
| 938 | using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&>>; | 936 | using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&>>; |
| 939 | static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); | 937 | static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); |
| 940 | static_assert(is_same_v<typename _Up::error_type, _Err>, | 938 | static_assert(is_same_v<typename _Up::error_type, _Err>, |
| ... | @@ -947,7 +945,7 @@ public: | ... | @@ -947,7 +945,7 @@ public: |
| 947 | 945 | ||
| 948 | template <class _Func> | 946 | template <class _Func> |
| 949 | requires is_constructible_v<_Err, _Err&&> | 947 | requires is_constructible_v<_Err, _Err&&> |
| 950 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { | 948 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { |
| 951 | using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&&>>; | 949 | using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&&>>; |
| 952 | static_assert( | 950 | static_assert( |
| 953 | __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); | 951 | __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); |
| ... | @@ -961,7 +959,7 @@ public: | ... | @@ -961,7 +959,7 @@ public: |
| 961 | 959 | ||
| 962 | template <class _Func> | 960 | template <class _Func> |
| 963 | requires is_constructible_v<_Err, const _Err&&> | 961 | requires is_constructible_v<_Err, const _Err&&> |
| 964 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { | 962 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { |
| 965 | using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&&>>; | 963 | using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&&>>; |
| 966 | static_assert( | 964 | static_assert( |
| 967 | __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); | 965 | __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); |
| ... | @@ -975,7 +973,7 @@ public: | ... | @@ -975,7 +973,7 @@ public: |
| 975 | 973 | ||
| 976 | template <class _Func> | 974 | template <class _Func> |
| 977 | requires is_constructible_v<_Tp, _Tp&> | 975 | requires is_constructible_v<_Tp, _Tp&> |
| 978 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) & { | 976 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) & { |
| 979 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&>>; | 977 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&>>; |
| 980 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); | 978 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); |
| 981 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, | 979 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, |
| ... | @@ -988,7 +986,7 @@ public: | ... | @@ -988,7 +986,7 @@ public: |
| 988 | 986 | ||
| 989 | template <class _Func> | 987 | template <class _Func> |
| 990 | requires is_constructible_v<_Tp, const _Tp&> | 988 | requires is_constructible_v<_Tp, const _Tp&> |
| 991 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const& { | 989 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const& { |
| 992 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&>>; | 990 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&>>; |
| 993 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); | 991 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); |
| 994 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, | 992 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, |
| ... | @@ -1001,7 +999,7 @@ public: | ... | @@ -1001,7 +999,7 @@ public: |
| 1001 | 999 | ||
| 1002 | template <class _Func> | 1000 | template <class _Func> |
| 1003 | requires is_constructible_v<_Tp, _Tp&&> | 1001 | requires is_constructible_v<_Tp, _Tp&&> |
| 1004 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) && { | 1002 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) && { |
| 1005 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&&>>; | 1003 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&&>>; |
| 1006 | static_assert( | 1004 | static_assert( |
| 1007 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); | 1005 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); |
| ... | @@ -1015,7 +1013,7 @@ public: | ... | @@ -1015,7 +1013,7 @@ public: |
| 1015 | 1013 | ||
| 1016 | template <class _Func> | 1014 | template <class _Func> |
| 1017 | requires is_constructible_v<_Tp, const _Tp&&> | 1015 | requires is_constructible_v<_Tp, const _Tp&&> |
| 1018 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const&& { | 1016 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const&& { |
| 1019 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&&>>; | 1017 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&&>>; |
| 1020 | static_assert( | 1018 | static_assert( |
| 1021 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); | 1019 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); |
| ... | @@ -1029,7 +1027,7 @@ public: | ... | @@ -1029,7 +1027,7 @@ public: |
| 1029 | 1027 | ||
| 1030 | template <class _Func> | 1028 | template <class _Func> |
| 1031 | requires is_constructible_v<_Err, _Err&> | 1029 | requires is_constructible_v<_Err, _Err&> |
| 1032 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & { | 1030 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & { |
| 1033 | using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&>>; | 1031 | using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&>>; |
| 1034 | if (!has_value()) { | 1032 | if (!has_value()) { |
| 1035 | return expected<_Up, _Err>(unexpect, error()); | 1033 | return expected<_Up, _Err>(unexpect, error()); |
| ... | @@ -1045,7 +1043,7 @@ public: | ... | @@ -1045,7 +1043,7 @@ public: |
| 1045 | 1043 | ||
| 1046 | template <class _Func> | 1044 | template <class _Func> |
| 1047 | requires is_constructible_v<_Err, const _Err&> | 1045 | requires is_constructible_v<_Err, const _Err&> |
| 1048 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& { | 1046 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& { |
| 1049 | using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&>>; | 1047 | using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&>>; |
| 1050 | if (!has_value()) { | 1048 | if (!has_value()) { |
| 1051 | return expected<_Up, _Err>(unexpect, error()); | 1049 | return expected<_Up, _Err>(unexpect, error()); |
| ... | @@ -1061,7 +1059,7 @@ public: | ... | @@ -1061,7 +1059,7 @@ public: |
| 1061 | 1059 | ||
| 1062 | template <class _Func> | 1060 | template <class _Func> |
| 1063 | requires is_constructible_v<_Err, _Err&&> | 1061 | requires is_constructible_v<_Err, _Err&&> |
| 1064 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && { | 1062 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && { |
| 1065 | using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&&>>; | 1063 | using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&&>>; |
| 1066 | if (!has_value()) { | 1064 | if (!has_value()) { |
| 1067 | return expected<_Up, _Err>(unexpect, std::move(error())); | 1065 | return expected<_Up, _Err>(unexpect, std::move(error())); |
| ... | @@ -1077,7 +1075,7 @@ public: | ... | @@ -1077,7 +1075,7 @@ public: |
| 1077 | 1075 | ||
| 1078 | template <class _Func> | 1076 | template <class _Func> |
| 1079 | requires is_constructible_v<_Err, const _Err&&> | 1077 | requires is_constructible_v<_Err, const _Err&&> |
| 1080 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& { | 1078 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& { |
| 1081 | using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&&>>; | 1079 | using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&&>>; |
| 1082 | if (!has_value()) { | 1080 | if (!has_value()) { |
| 1083 | return expected<_Up, _Err>(unexpect, std::move(error())); | 1081 | return expected<_Up, _Err>(unexpect, std::move(error())); |
| ... | @@ -1093,7 +1091,7 @@ public: | ... | @@ -1093,7 +1091,7 @@ public: |
| 1093 | 1091 | ||
| 1094 | template <class _Func> | 1092 | template <class _Func> |
| 1095 | requires is_constructible_v<_Tp, _Tp&> | 1093 | requires is_constructible_v<_Tp, _Tp&> |
| 1096 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) & { | 1094 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) & { |
| 1097 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&>>; | 1095 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&>>; |
| 1098 | static_assert(__valid_std_unexpected<_Gp>::value, | 1096 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1099 | "The result of f(error()) must be a valid template argument for unexpected"); | 1097 | "The result of f(error()) must be a valid template argument for unexpected"); |
| ... | @@ -1105,7 +1103,7 @@ public: | ... | @@ -1105,7 +1103,7 @@ public: |
| 1105 | 1103 | ||
| 1106 | template <class _Func> | 1104 | template <class _Func> |
| 1107 | requires is_constructible_v<_Tp, const _Tp&> | 1105 | requires is_constructible_v<_Tp, const _Tp&> |
| 1108 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const& { | 1106 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const& { |
| 1109 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&>>; | 1107 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&>>; |
| 1110 | static_assert(__valid_std_unexpected<_Gp>::value, | 1108 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1111 | "The result of f(error()) must be a valid template argument for unexpected"); | 1109 | "The result of f(error()) must be a valid template argument for unexpected"); |
| ... | @@ -1117,7 +1115,7 @@ public: | ... | @@ -1117,7 +1115,7 @@ public: |
| 1117 | 1115 | ||
| 1118 | template <class _Func> | 1116 | template <class _Func> |
| 1119 | requires is_constructible_v<_Tp, _Tp&&> | 1117 | requires is_constructible_v<_Tp, _Tp&&> |
| 1120 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) && { | 1118 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) && { |
| 1121 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&&>>; | 1119 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&&>>; |
| 1122 | static_assert(__valid_std_unexpected<_Gp>::value, | 1120 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1123 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); | 1121 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); |
| ... | @@ -1130,7 +1128,7 @@ public: | ... | @@ -1130,7 +1128,7 @@ public: |
| 1130 | 1128 | ||
| 1131 | template <class _Func> | 1129 | template <class _Func> |
| 1132 | requires is_constructible_v<_Tp, const _Tp&&> | 1130 | requires is_constructible_v<_Tp, const _Tp&&> |
| 1133 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const&& { | 1131 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const&& { |
| 1134 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&&>>; | 1132 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&&>>; |
| 1135 | static_assert(__valid_std_unexpected<_Gp>::value, | 1133 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1136 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); | 1134 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); |
| ... | @@ -1597,7 +1595,7 @@ public: | ... | @@ -1597,7 +1595,7 @@ public: |
| 1597 | // [expected.void.obs], observers | 1595 | // [expected.void.obs], observers |
| 1598 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return this->__has_val(); } | 1596 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return this->__has_val(); } |
| 1599 | 1597 | ||
| 1600 | _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__has_val(); } | 1598 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__has_val(); } |
| 1601 | 1599 | ||
| 1602 | _LIBCPP_HIDE_FROM_ABI constexpr void operator*() const noexcept { | 1600 | _LIBCPP_HIDE_FROM_ABI constexpr void operator*() const noexcept { |
| 1603 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 1601 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| ... | @@ -1618,32 +1616,32 @@ public: | ... | @@ -1618,32 +1616,32 @@ public: |
| 1618 | } | 1616 | } |
| 1619 | } | 1617 | } |
| 1620 | 1618 | ||
| 1621 | _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { | 1619 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { |
| 1622 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 1620 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 1623 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 1621 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 1624 | return this->__unex(); | 1622 | return this->__unex(); |
| 1625 | } | 1623 | } |
| 1626 | 1624 | ||
| 1627 | _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { | 1625 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { |
| 1628 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 1626 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 1629 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 1627 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 1630 | return this->__unex(); | 1628 | return this->__unex(); |
| 1631 | } | 1629 | } |
| 1632 | 1630 | ||
| 1633 | _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { | 1631 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { |
| 1634 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 1632 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 1635 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 1633 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 1636 | return std::move(this->__unex()); | 1634 | return std::move(this->__unex()); |
| 1637 | } | 1635 | } |
| 1638 | 1636 | ||
| 1639 | _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { | 1637 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { |
| 1640 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 1638 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 1641 | !this->__has_val(), "expected::error requires the expected to contain an error"); | 1639 | !this->__has_val(), "expected::error requires the expected to contain an error"); |
| 1642 | return std::move(this->__unex()); | 1640 | return std::move(this->__unex()); |
| 1643 | } | 1641 | } |
| 1644 | 1642 | ||
| 1645 | template <class _Up = _Err> | 1643 | template <class _Up = _Err> |
| 1646 | _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) const& { | 1644 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) const& { |
| 1647 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); | 1645 | static_assert(is_copy_constructible_v<_Err>, "error_type has to be copy constructible"); |
| 1648 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); | 1646 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); |
| 1649 | if (has_value()) { | 1647 | if (has_value()) { |
| ... | @@ -1653,7 +1651,7 @@ public: | ... | @@ -1653,7 +1651,7 @@ public: |
| 1653 | } | 1651 | } |
| 1654 | 1652 | ||
| 1655 | template <class _Up = _Err> | 1653 | template <class _Up = _Err> |
| 1656 | _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) && { | 1654 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err error_or(_Up&& __error) && { |
| 1657 | static_assert(is_move_constructible_v<_Err>, "error_type has to be move constructible"); | 1655 | static_assert(is_move_constructible_v<_Err>, "error_type has to be move constructible"); |
| 1658 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); | 1656 | static_assert(is_convertible_v<_Up, _Err>, "argument has to be convertible to error_type"); |
| 1659 | if (has_value()) { | 1657 | if (has_value()) { |
| ... | @@ -1665,7 +1663,7 @@ public: | ... | @@ -1665,7 +1663,7 @@ public: |
| 1665 | // [expected.void.monadic], monadic | 1663 | // [expected.void.monadic], monadic |
| 1666 | template <class _Func> | 1664 | template <class _Func> |
| 1667 | requires is_constructible_v<_Err, _Err&> | 1665 | requires is_constructible_v<_Err, _Err&> |
| 1668 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { | 1666 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { |
| 1669 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; | 1667 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; |
| 1670 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); | 1668 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); |
| 1671 | static_assert( | 1669 | static_assert( |
| ... | @@ -1678,7 +1676,7 @@ public: | ... | @@ -1678,7 +1676,7 @@ public: |
| 1678 | 1676 | ||
| 1679 | template <class _Func> | 1677 | template <class _Func> |
| 1680 | requires is_constructible_v<_Err, const _Err&> | 1678 | requires is_constructible_v<_Err, const _Err&> |
| 1681 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { | 1679 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { |
| 1682 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; | 1680 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; |
| 1683 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); | 1681 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); |
| 1684 | static_assert( | 1682 | static_assert( |
| ... | @@ -1691,7 +1689,7 @@ public: | ... | @@ -1691,7 +1689,7 @@ public: |
| 1691 | 1689 | ||
| 1692 | template <class _Func> | 1690 | template <class _Func> |
| 1693 | requires is_constructible_v<_Err, _Err&&> | 1691 | requires is_constructible_v<_Err, _Err&&> |
| 1694 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { | 1692 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { |
| 1695 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; | 1693 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; |
| 1696 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); | 1694 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); |
| 1697 | static_assert( | 1695 | static_assert( |
| ... | @@ -1704,7 +1702,7 @@ public: | ... | @@ -1704,7 +1702,7 @@ public: |
| 1704 | 1702 | ||
| 1705 | template <class _Func> | 1703 | template <class _Func> |
| 1706 | requires is_constructible_v<_Err, const _Err&&> | 1704 | requires is_constructible_v<_Err, const _Err&&> |
| 1707 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { | 1705 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { |
| 1708 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; | 1706 | using _Up = remove_cvref_t<invoke_result_t<_Func>>; |
| 1709 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); | 1707 | static_assert(__is_std_expected<_Up>::value, "The result of f() must be a specialization of std::expected"); |
| 1710 | static_assert( | 1708 | static_assert( |
| ... | @@ -1716,7 +1714,7 @@ public: | ... | @@ -1716,7 +1714,7 @@ public: |
| 1716 | } | 1714 | } |
| 1717 | 1715 | ||
| 1718 | template <class _Func> | 1716 | template <class _Func> |
| 1719 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) & { | 1717 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) & { |
| 1720 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&>>; | 1718 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&>>; |
| 1721 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); | 1719 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); |
| 1722 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, | 1720 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, |
| ... | @@ -1728,7 +1726,7 @@ public: | ... | @@ -1728,7 +1726,7 @@ public: |
| 1728 | } | 1726 | } |
| 1729 | 1727 | ||
| 1730 | template <class _Func> | 1728 | template <class _Func> |
| 1731 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const& { | 1729 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const& { |
| 1732 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&>>; | 1730 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&>>; |
| 1733 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); | 1731 | static_assert(__is_std_expected<_Gp>::value, "The result of f(error()) must be a specialization of std::expected"); |
| 1734 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, | 1732 | static_assert(is_same_v<typename _Gp::value_type, _Tp>, |
| ... | @@ -1740,7 +1738,7 @@ public: | ... | @@ -1740,7 +1738,7 @@ public: |
| 1740 | } | 1738 | } |
| 1741 | 1739 | ||
| 1742 | template <class _Func> | 1740 | template <class _Func> |
| 1743 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) && { | 1741 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) && { |
| 1744 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&&>>; | 1742 | using _Gp = remove_cvref_t<invoke_result_t<_Func, _Err&&>>; |
| 1745 | static_assert( | 1743 | static_assert( |
| 1746 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); | 1744 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); |
| ... | @@ -1753,7 +1751,7 @@ public: | ... | @@ -1753,7 +1751,7 @@ public: |
| 1753 | } | 1751 | } |
| 1754 | 1752 | ||
| 1755 | template <class _Func> | 1753 | template <class _Func> |
| 1756 | _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const&& { | 1754 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto or_else(_Func&& __f) const&& { |
| 1757 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&&>>; | 1755 | using _Gp = remove_cvref_t<invoke_result_t<_Func, const _Err&&>>; |
| 1758 | static_assert( | 1756 | static_assert( |
| 1759 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); | 1757 | __is_std_expected<_Gp>::value, "The result of f(std::move(error())) must be a specialization of std::expected"); |
| ... | @@ -1767,7 +1765,7 @@ public: | ... | @@ -1767,7 +1765,7 @@ public: |
| 1767 | 1765 | ||
| 1768 | template <class _Func> | 1766 | template <class _Func> |
| 1769 | requires is_constructible_v<_Err, _Err&> | 1767 | requires is_constructible_v<_Err, _Err&> |
| 1770 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & { | 1768 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & { |
| 1771 | using _Up = remove_cv_t<invoke_result_t<_Func>>; | 1769 | using _Up = remove_cv_t<invoke_result_t<_Func>>; |
| 1772 | if (!has_value()) { | 1770 | if (!has_value()) { |
| 1773 | return expected<_Up, _Err>(unexpect, error()); | 1771 | return expected<_Up, _Err>(unexpect, error()); |
| ... | @@ -1782,7 +1780,7 @@ public: | ... | @@ -1782,7 +1780,7 @@ public: |
| 1782 | 1780 | ||
| 1783 | template <class _Func> | 1781 | template <class _Func> |
| 1784 | requires is_constructible_v<_Err, const _Err&> | 1782 | requires is_constructible_v<_Err, const _Err&> |
| 1785 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& { | 1783 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& { |
| 1786 | using _Up = remove_cv_t<invoke_result_t<_Func>>; | 1784 | using _Up = remove_cv_t<invoke_result_t<_Func>>; |
| 1787 | if (!has_value()) { | 1785 | if (!has_value()) { |
| 1788 | return expected<_Up, _Err>(unexpect, error()); | 1786 | return expected<_Up, _Err>(unexpect, error()); |
| ... | @@ -1797,7 +1795,7 @@ public: | ... | @@ -1797,7 +1795,7 @@ public: |
| 1797 | 1795 | ||
| 1798 | template <class _Func> | 1796 | template <class _Func> |
| 1799 | requires is_constructible_v<_Err, _Err&&> | 1797 | requires is_constructible_v<_Err, _Err&&> |
| 1800 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && { | 1798 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && { |
| 1801 | using _Up = remove_cv_t<invoke_result_t<_Func>>; | 1799 | using _Up = remove_cv_t<invoke_result_t<_Func>>; |
| 1802 | if (!has_value()) { | 1800 | if (!has_value()) { |
| 1803 | return expected<_Up, _Err>(unexpect, std::move(error())); | 1801 | return expected<_Up, _Err>(unexpect, std::move(error())); |
| ... | @@ -1812,7 +1810,7 @@ public: | ... | @@ -1812,7 +1810,7 @@ public: |
| 1812 | 1810 | ||
| 1813 | template <class _Func> | 1811 | template <class _Func> |
| 1814 | requires is_constructible_v<_Err, const _Err&&> | 1812 | requires is_constructible_v<_Err, const _Err&&> |
| 1815 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& { | 1813 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& { |
| 1816 | using _Up = remove_cv_t<invoke_result_t<_Func>>; | 1814 | using _Up = remove_cv_t<invoke_result_t<_Func>>; |
| 1817 | if (!has_value()) { | 1815 | if (!has_value()) { |
| 1818 | return expected<_Up, _Err>(unexpect, std::move(error())); | 1816 | return expected<_Up, _Err>(unexpect, std::move(error())); |
| ... | @@ -1826,7 +1824,7 @@ public: | ... | @@ -1826,7 +1824,7 @@ public: |
| 1826 | } | 1824 | } |
| 1827 | 1825 | ||
| 1828 | template <class _Func> | 1826 | template <class _Func> |
| 1829 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) & { | 1827 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) & { |
| 1830 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&>>; | 1828 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&>>; |
| 1831 | static_assert(__valid_std_unexpected<_Gp>::value, | 1829 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1832 | "The result of f(error()) must be a valid template argument for unexpected"); | 1830 | "The result of f(error()) must be a valid template argument for unexpected"); |
| ... | @@ -1837,7 +1835,7 @@ public: | ... | @@ -1837,7 +1835,7 @@ public: |
| 1837 | } | 1835 | } |
| 1838 | 1836 | ||
| 1839 | template <class _Func> | 1837 | template <class _Func> |
| 1840 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const& { | 1838 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const& { |
| 1841 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&>>; | 1839 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&>>; |
| 1842 | static_assert(__valid_std_unexpected<_Gp>::value, | 1840 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1843 | "The result of f(error()) must be a valid template argument for unexpected"); | 1841 | "The result of f(error()) must be a valid template argument for unexpected"); |
| ... | @@ -1848,7 +1846,7 @@ public: | ... | @@ -1848,7 +1846,7 @@ public: |
| 1848 | } | 1846 | } |
| 1849 | 1847 | ||
| 1850 | template <class _Func> | 1848 | template <class _Func> |
| 1851 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) && { | 1849 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) && { |
| 1852 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&&>>; | 1850 | using _Gp = remove_cv_t<invoke_result_t<_Func, _Err&&>>; |
| 1853 | static_assert(__valid_std_unexpected<_Gp>::value, | 1851 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1854 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); | 1852 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); |
| ... | @@ -1860,7 +1858,7 @@ public: | ... | @@ -1860,7 +1858,7 @@ public: |
| 1860 | } | 1858 | } |
| 1861 | 1859 | ||
| 1862 | template <class _Func> | 1860 | template <class _Func> |
| 1863 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const&& { | 1861 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform_error(_Func&& __f) const&& { |
| 1864 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&&>>; | 1862 | using _Gp = remove_cv_t<invoke_result_t<_Func, const _Err&&>>; |
| 1865 | static_assert(__valid_std_unexpected<_Gp>::value, | 1863 | static_assert(__valid_std_unexpected<_Gp>::value, |
| 1866 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); | 1864 | "The result of f(std::move(error())) must be a valid template argument for unexpected"); |
lib/libcxx/include/__expected/unexpected.h+4-4| ... | @@ -89,10 +89,10 @@ public: | ... | @@ -89,10 +89,10 @@ public: |
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(const unexpected&) = default; | 89 | _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(const unexpected&) = default; |
| 90 | _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(unexpected&&) = default; | 90 | _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(unexpected&&) = default; |
| 91 | 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { return __unex_; } | 92 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { return __unex_; } |
| 93 | _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { return __unex_; } | 93 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { return __unex_; } |
| 94 | _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { return std::move(__unex_); } | 94 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { return std::move(__unex_); } |
| 95 | _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { return std::move(__unex_); } | 95 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { return std::move(__unex_); } |
| 96 | 96 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(unexpected& __other) noexcept(is_nothrow_swappable_v<_Err>) { | 97 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(unexpected& __other) noexcept(is_nothrow_swappable_v<_Err>) { |
| 98 | static_assert(is_swappable_v<_Err>, "unexpected::swap requires is_swappable_v<E> to be true"); | 98 | static_assert(is_swappable_v<_Err>, "unexpected::swap requires is_swappable_v<E> to be true"); |
lib/libcxx/include/__filesystem/copy_options.h+4-4| ... | @@ -34,19 +34,19 @@ enum class copy_options : unsigned short { | ... | @@ -34,19 +34,19 @@ enum class copy_options : unsigned short { |
| 34 | __in_recursive_copy = 512, | 34 | __in_recursive_copy = 512, |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator&(copy_options __lhs, copy_options __rhs) { | 37 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator&(copy_options __lhs, copy_options __rhs) { |
| 38 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) & static_cast<unsigned short>(__rhs)); | 38 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) & static_cast<unsigned short>(__rhs)); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator|(copy_options __lhs, copy_options __rhs) { | 41 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator|(copy_options __lhs, copy_options __rhs) { |
| 42 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) | static_cast<unsigned short>(__rhs)); | 42 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) | static_cast<unsigned short>(__rhs)); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator^(copy_options __lhs, copy_options __rhs) { | 45 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator^(copy_options __lhs, copy_options __rhs) { |
| 46 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) ^ static_cast<unsigned short>(__rhs)); | 46 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) ^ static_cast<unsigned short>(__rhs)); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator~(copy_options __lhs) { | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr copy_options operator~(copy_options __lhs) { |
| 50 | return static_cast<copy_options>(~static_cast<unsigned short>(__lhs)); | 50 | return static_cast<copy_options>(~static_cast<unsigned short>(__lhs)); |
| 51 | } | 51 | } |
| 52 | 52 |
lib/libcxx/include/__filesystem/directory_entry.h+37-33| ... | @@ -40,8 +40,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -40,8 +40,6 @@ _LIBCPP_PUSH_MACROS |
| 40 | 40 | ||
| 41 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 41 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 42 | 42 | ||
| 43 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH | ||
| 44 | |||
| 45 | class directory_entry { | 43 | class directory_entry { |
| 46 | typedef filesystem::path _Path; | 44 | typedef filesystem::path _Path; |
| 47 | 45 | ||
| ... | @@ -89,80 +87,88 @@ public: | ... | @@ -89,80 +87,88 @@ public: |
| 89 | 87 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI void refresh(error_code& __ec) noexcept { __refresh(&__ec); } | 88 | _LIBCPP_HIDE_FROM_ABI void refresh(error_code& __ec) noexcept { __refresh(&__ec); } |
| 91 | 89 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI _Path const& path() const noexcept { return __p_; } | 90 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Path const& path() const noexcept { return __p_; } |
| 93 | 91 | ||
| 94 | _LIBCPP_HIDE_FROM_ABI operator const _Path&() const noexcept { return __p_; } | 92 | _LIBCPP_HIDE_FROM_ABI operator const _Path&() const noexcept { return __p_; } |
| 95 | 93 | ||
| 96 | _LIBCPP_HIDE_FROM_ABI bool exists() const { return filesystem::exists(file_status{__get_ft()}); } | 94 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool exists() const { return filesystem::exists(file_status{__get_ft()}); } |
| 97 | 95 | ||
| 98 | _LIBCPP_HIDE_FROM_ABI bool exists(error_code& __ec) const noexcept { | 96 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool exists(error_code& __ec) const noexcept { |
| 99 | return filesystem::exists(file_status{__get_ft(&__ec)}); | 97 | return filesystem::exists(file_status{__get_ft(&__ec)}); |
| 100 | } | 98 | } |
| 101 | 99 | ||
| 102 | _LIBCPP_HIDE_FROM_ABI bool is_block_file() const { return __get_ft() == file_type::block; } | 100 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_block_file() const { return __get_ft() == file_type::block; } |
| 103 | 101 | ||
| 104 | _LIBCPP_HIDE_FROM_ABI bool is_block_file(error_code& __ec) const noexcept { | 102 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_block_file(error_code& __ec) const noexcept { |
| 105 | return __get_ft(&__ec) == file_type::block; | 103 | return __get_ft(&__ec) == file_type::block; |
| 106 | } | 104 | } |
| 107 | 105 | ||
| 108 | _LIBCPP_HIDE_FROM_ABI bool is_character_file() const { return __get_ft() == file_type::character; } | 106 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_character_file() const { return __get_ft() == file_type::character; } |
| 109 | 107 | ||
| 110 | _LIBCPP_HIDE_FROM_ABI bool is_character_file(error_code& __ec) const noexcept { | 108 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_character_file(error_code& __ec) const noexcept { |
| 111 | return __get_ft(&__ec) == file_type::character; | 109 | return __get_ft(&__ec) == file_type::character; |
| 112 | } | 110 | } |
| 113 | 111 | ||
| 114 | _LIBCPP_HIDE_FROM_ABI bool is_directory() const { return __get_ft() == file_type::directory; } | 112 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_directory() const { return __get_ft() == file_type::directory; } |
| 115 | 113 | ||
| 116 | _LIBCPP_HIDE_FROM_ABI bool is_directory(error_code& __ec) const noexcept { | 114 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_directory(error_code& __ec) const noexcept { |
| 117 | return __get_ft(&__ec) == file_type::directory; | 115 | return __get_ft(&__ec) == file_type::directory; |
| 118 | } | 116 | } |
| 119 | 117 | ||
| 120 | _LIBCPP_HIDE_FROM_ABI bool is_fifo() const { return __get_ft() == file_type::fifo; } | 118 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_fifo() const { return __get_ft() == file_type::fifo; } |
| 121 | 119 | ||
| 122 | _LIBCPP_HIDE_FROM_ABI bool is_fifo(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::fifo; } | 120 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_fifo(error_code& __ec) const noexcept { |
| 121 | return __get_ft(&__ec) == file_type::fifo; | ||
| 122 | } | ||
| 123 | 123 | ||
| 124 | _LIBCPP_HIDE_FROM_ABI bool is_other() const { return filesystem::is_other(file_status{__get_ft()}); } | 124 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_other() const { return filesystem::is_other(file_status{__get_ft()}); } |
| 125 | 125 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI bool is_other(error_code& __ec) const noexcept { | 126 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_other(error_code& __ec) const noexcept { |
| 127 | return filesystem::is_other(file_status{__get_ft(&__ec)}); | 127 | return filesystem::is_other(file_status{__get_ft(&__ec)}); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | _LIBCPP_HIDE_FROM_ABI bool is_regular_file() const { return __get_ft() == file_type::regular; } | 130 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_regular_file() const { return __get_ft() == file_type::regular; } |
| 131 | 131 | ||
| 132 | _LIBCPP_HIDE_FROM_ABI bool is_regular_file(error_code& __ec) const noexcept { | 132 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_regular_file(error_code& __ec) const noexcept { |
| 133 | return __get_ft(&__ec) == file_type::regular; | 133 | return __get_ft(&__ec) == file_type::regular; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | _LIBCPP_HIDE_FROM_ABI bool is_socket() const { return __get_ft() == file_type::socket; } | 136 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_socket() const { return __get_ft() == file_type::socket; } |
| 137 | 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI bool is_socket(error_code& __ec) const noexcept { return __get_ft(&__ec) == file_type::socket; } | 138 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_socket(error_code& __ec) const noexcept { |
| 139 | return __get_ft(&__ec) == file_type::socket; | ||
| 140 | } | ||
| 139 | 141 | ||
| 140 | _LIBCPP_HIDE_FROM_ABI bool is_symlink() const { return __get_sym_ft() == file_type::symlink; } | 142 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_symlink() const { return __get_sym_ft() == file_type::symlink; } |
| 141 | 143 | ||
| 142 | _LIBCPP_HIDE_FROM_ABI bool is_symlink(error_code& __ec) const noexcept { | 144 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_symlink(error_code& __ec) const noexcept { |
| 143 | return __get_sym_ft(&__ec) == file_type::symlink; | 145 | return __get_sym_ft(&__ec) == file_type::symlink; |
| 144 | } | 146 | } |
| 145 | _LIBCPP_HIDE_FROM_ABI uintmax_t file_size() const { return __get_size(); } | 147 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI uintmax_t file_size() const { return __get_size(); } |
| 146 | 148 | ||
| 147 | _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(error_code& __ec) const noexcept { return __get_size(&__ec); } | 149 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(error_code& __ec) const noexcept { return __get_size(&__ec); } |
| 148 | 150 | ||
| 149 | _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count() const { return __get_nlink(); } | 151 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count() const { return __get_nlink(); } |
| 150 | 152 | ||
| 151 | _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(error_code& __ec) const noexcept { return __get_nlink(&__ec); } | 153 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(error_code& __ec) const noexcept { |
| 154 | return __get_nlink(&__ec); | ||
| 155 | } | ||
| 152 | 156 | ||
| 153 | _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time() const { return __get_write_time(); } | 157 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time() const { return __get_write_time(); } |
| 154 | 158 | ||
| 155 | _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(error_code& __ec) const noexcept { | 159 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(error_code& __ec) const noexcept { |
| 156 | return __get_write_time(&__ec); | 160 | return __get_write_time(&__ec); |
| 157 | } | 161 | } |
| 158 | 162 | ||
| 159 | _LIBCPP_HIDE_FROM_ABI file_status status() const { return __get_status(); } | 163 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI file_status status() const { return __get_status(); } |
| 160 | 164 | ||
| 161 | _LIBCPP_HIDE_FROM_ABI file_status status(error_code& __ec) const noexcept { return __get_status(&__ec); } | 165 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI file_status status(error_code& __ec) const noexcept { |
| 166 | return __get_status(&__ec); | ||
| 167 | } | ||
| 162 | 168 | ||
| 163 | _LIBCPP_HIDE_FROM_ABI file_status symlink_status() const { return __get_symlink_status(); } | 169 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI file_status symlink_status() const { return __get_symlink_status(); } |
| 164 | 170 | ||
| 165 | _LIBCPP_HIDE_FROM_ABI file_status symlink_status(error_code& __ec) const noexcept { | 171 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI file_status symlink_status(error_code& __ec) const noexcept { |
| 166 | return __get_symlink_status(&__ec); | 172 | return __get_symlink_status(&__ec); |
| 167 | } | 173 | } |
| 168 | 174 | ||
| ... | @@ -459,8 +465,6 @@ private: | ... | @@ -459,8 +465,6 @@ private: |
| 459 | directory_entry __elem_; | 465 | directory_entry __elem_; |
| 460 | }; | 466 | }; |
| 461 | 467 | ||
| 462 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP | ||
| 463 | |||
| 464 | _LIBCPP_END_NAMESPACE_FILESYSTEM | 468 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 465 | 469 | ||
| 466 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | 470 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM |
lib/libcxx/include/__filesystem/directory_iterator.h+9-11| ... | @@ -34,8 +34,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -34,8 +34,6 @@ _LIBCPP_PUSH_MACROS |
| 34 | 34 | ||
| 35 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 35 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 36 | 36 | ||
| 37 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH | ||
| 38 | |||
| 39 | class _LIBCPP_HIDDEN __dir_stream; | 37 | class _LIBCPP_HIDDEN __dir_stream; |
| 40 | class directory_iterator { | 38 | class directory_iterator { |
| 41 | public: | 39 | public: |
| ... | @@ -73,7 +71,7 @@ public: | ... | @@ -73,7 +71,7 @@ public: |
| 73 | 71 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI ~directory_iterator() = default; | 72 | _LIBCPP_HIDE_FROM_ABI ~directory_iterator() = default; |
| 75 | 73 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI const directory_entry& operator*() const { | 74 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const directory_entry& operator*() const { |
| 77 | // Note: this check duplicates a check in `__dereference()`. | 75 | // Note: this check duplicates a check in `__dereference()`. |
| 78 | _LIBCPP_ASSERT_NON_NULL(__imp_, "The end iterator cannot be dereferenced"); | 76 | _LIBCPP_ASSERT_NON_NULL(__imp_, "The end iterator cannot be dereferenced"); |
| 79 | return __dereference(); | 77 | return __dereference(); |
| ... | @@ -123,23 +121,23 @@ operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs) noe | ... | @@ -123,23 +121,23 @@ operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs) noe |
| 123 | } | 121 | } |
| 124 | 122 | ||
| 125 | // enable directory_iterator range-based for statements | 123 | // enable directory_iterator range-based for statements |
| 126 | inline _LIBCPP_HIDE_FROM_ABI directory_iterator begin(directory_iterator __iter) noexcept { return __iter; } | 124 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI directory_iterator begin(directory_iterator __iter) noexcept { |
| 127 | 125 | return __iter; | |
| 128 | inline _LIBCPP_HIDE_FROM_ABI directory_iterator end(directory_iterator) noexcept { return directory_iterator(); } | 126 | } |
| 129 | 127 | ||
| 130 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP | 128 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI directory_iterator end(directory_iterator) noexcept { |
| 129 | return directory_iterator(); | ||
| 130 | } | ||
| 131 | 131 | ||
| 132 | _LIBCPP_END_NAMESPACE_FILESYSTEM | 132 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 133 | 133 | ||
| 134 | # if _LIBCPP_STD_VER >= 20 | 134 | # if _LIBCPP_STD_VER >= 20 |
| 135 | 135 | ||
| 136 | template <> | 136 | template <> |
| 137 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool | 137 | inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; |
| 138 | std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; | ||
| 139 | 138 | ||
| 140 | template <> | 139 | template <> |
| 141 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool | 140 | inline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; |
| 142 | std::ranges::enable_view<std::filesystem::directory_iterator> = true; | ||
| 143 | 141 | ||
| 144 | # endif // _LIBCPP_STD_VER >= 20 | 142 | # endif // _LIBCPP_STD_VER >= 20 |
| 145 | 143 |
lib/libcxx/include/__filesystem/directory_options.h+7-4| ... | @@ -22,19 +22,22 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | ... | @@ -22,19 +22,22 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 22 | 22 | ||
| 23 | enum class directory_options : unsigned char { none = 0, follow_directory_symlink = 1, skip_permission_denied = 2 }; | 23 | enum class directory_options : unsigned char { none = 0, follow_directory_symlink = 1, skip_permission_denied = 2 }; |
| 24 | 24 | ||
| 25 | _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options operator&(directory_options __lhs, directory_options __rhs) { | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options |
| 26 | operator&(directory_options __lhs, directory_options __rhs) { | ||
| 26 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); | 27 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options operator|(directory_options __lhs, directory_options __rhs) { | 30 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options |
| 31 | operator|(directory_options __lhs, directory_options __rhs) { | ||
| 30 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); | 32 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); |
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options operator^(directory_options __lhs, directory_options __rhs) { | 35 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options |
| 36 | operator^(directory_options __lhs, directory_options __rhs) { | ||
| 34 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); | 37 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); |
| 35 | } | 38 | } |
| 36 | 39 | ||
| 37 | _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options operator~(directory_options __lhs) { | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr directory_options operator~(directory_options __lhs) { |
| 38 | return static_cast<directory_options>(~static_cast<unsigned char>(__lhs)); | 41 | return static_cast<directory_options>(~static_cast<unsigned char>(__lhs)); |
| 39 | } | 42 | } |
| 40 | 43 |
lib/libcxx/include/__filesystem/file_status.h+3-3| ... | @@ -22,7 +22,7 @@ | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 23 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 24 | 24 | ||
| 25 | class _LIBCPP_EXPORTED_FROM_ABI file_status { | 25 | class file_status { |
| 26 | public: | 26 | public: |
| 27 | // constructors | 27 | // constructors |
| 28 | _LIBCPP_HIDE_FROM_ABI file_status() noexcept : file_status(file_type::none) {} | 28 | _LIBCPP_HIDE_FROM_ABI file_status() noexcept : file_status(file_type::none) {} |
| ... | @@ -38,9 +38,9 @@ public: | ... | @@ -38,9 +38,9 @@ public: |
| 38 | _LIBCPP_HIDE_FROM_ABI file_status& operator=(file_status&&) noexcept = default; | 38 | _LIBCPP_HIDE_FROM_ABI file_status& operator=(file_status&&) noexcept = default; |
| 39 | 39 | ||
| 40 | // observers | 40 | // observers |
| 41 | _LIBCPP_HIDE_FROM_ABI file_type type() const noexcept { return __ft_; } | 41 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI file_type type() const noexcept { return __ft_; } |
| 42 | 42 | ||
| 43 | _LIBCPP_HIDE_FROM_ABI perms permissions() const noexcept { return __prms_; } | 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI perms permissions() const noexcept { return __prms_; } |
| 44 | 44 | ||
| 45 | // modifiers | 45 | // modifiers |
| 46 | _LIBCPP_HIDE_FROM_ABI void type(file_type __ft) noexcept { __ft_ = __ft; } | 46 | _LIBCPP_HIDE_FROM_ABI void type(file_type __ft) noexcept { __ft_ = __ft; } |
lib/libcxx/include/__filesystem/filesystem_error.h+9-10| ... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 28 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 29 | 29 | ||
| 30 | class _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI filesystem_error : public system_error { | 30 | class _LIBCPP_EXPORTED_FROM_ABI filesystem_error : public system_error { |
| 31 | public: | 31 | public: |
| 32 | _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, error_code __ec) | 32 | _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, error_code __ec) |
| 33 | : system_error(__ec, __what), __storage_(make_shared<_Storage>(path(), path())) { | 33 | : system_error(__ec, __what), __storage_(make_shared<_Storage>(path(), path())) { |
| ... | @@ -44,15 +44,16 @@ public: | ... | @@ -44,15 +44,16 @@ public: |
| 44 | __create_what(2); | 44 | __create_what(2); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | _LIBCPP_HIDE_FROM_ABI const path& path1() const noexcept { return __storage_->__p1_; } | 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const path& path1() const noexcept { return __storage_->__p1_; } |
| 48 | 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI const path& path2() const noexcept { return __storage_->__p2_; } | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const path& path2() const noexcept { return __storage_->__p2_; } |
| 50 | 50 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI filesystem_error(const filesystem_error&) = default; | 51 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI filesystem_error(const filesystem_error&) = default; |
| 52 | ~filesystem_error() override; // key function | 52 | ~filesystem_error() override; // key function |
| 53 | 53 | ||
| 54 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const noexcept override { |
| 55 | const char* what() const noexcept override { return __storage_->__what_.c_str(); } | 55 | return __storage_->__what_.c_str(); |
| 56 | } | ||
| 56 | 57 | ||
| 57 | void __create_what(int __num_paths); | 58 | void __create_what(int __num_paths); |
| 58 | 59 | ||
| ... | @@ -69,14 +70,12 @@ private: | ... | @@ -69,14 +70,12 @@ private: |
| 69 | 70 | ||
| 70 | # if _LIBCPP_HAS_EXCEPTIONS | 71 | # if _LIBCPP_HAS_EXCEPTIONS |
| 71 | template <class... _Args> | 72 | template <class... _Args> |
| 72 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void | 73 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_filesystem_error(_Args&&... __args) { |
| 73 | __throw_filesystem_error(_Args&&... __args) { | ||
| 74 | throw filesystem_error(std::forward<_Args>(__args)...); | 74 | throw filesystem_error(std::forward<_Args>(__args)...); |
| 75 | } | 75 | } |
| 76 | # else | 76 | # else |
| 77 | template <class... _Args> | 77 | template <class... _Args> |
| 78 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void | 78 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_filesystem_error(_Args&&...) { |
| 79 | __throw_filesystem_error(_Args&&...) { | ||
| 80 | _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode"); | 79 | _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode"); |
| 81 | } | 80 | } |
| 82 | # endif | 81 | # endif |
lib/libcxx/include/__filesystem/operations.h+97-66| ... | @@ -31,8 +31,6 @@ | ... | @@ -31,8 +31,6 @@ |
| 31 | 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 32 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 33 | 33 | ||
| 34 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH | ||
| 35 | |||
| 36 | _LIBCPP_EXPORTED_FROM_ABI path __absolute(const path&, error_code* __ec = nullptr); | 34 | _LIBCPP_EXPORTED_FROM_ABI path __absolute(const path&, error_code* __ec = nullptr); |
| 37 | _LIBCPP_EXPORTED_FROM_ABI path __canonical(const path&, error_code* __ec = nullptr); | 35 | _LIBCPP_EXPORTED_FROM_ABI path __canonical(const path&, error_code* __ec = nullptr); |
| 38 | _LIBCPP_EXPORTED_FROM_ABI bool | 36 | _LIBCPP_EXPORTED_FROM_ABI bool |
| ... | @@ -70,10 +68,14 @@ _LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = | ... | @@ -70,10 +68,14 @@ _LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = |
| 70 | _LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr); | 68 | _LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr); |
| 71 | _LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr); | 69 | _LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr); |
| 72 | 70 | ||
| 73 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); } | 71 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); } |
| 74 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); } | 72 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { |
| 75 | inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p) { return __canonical(__p); } | 73 | return __absolute(__p, &__ec); |
| 76 | inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); } | 74 | } |
| 75 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p) { return __canonical(__p); } | ||
| 76 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p, error_code& __ec) { | ||
| 77 | return __canonical(__p, &__ec); | ||
| 78 | } | ||
| 77 | inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to) { | 79 | inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to) { |
| 78 | return __copy_file(__from, __to, copy_options::none); | 80 | return __copy_file(__from, __to, copy_options::none); |
| 79 | } | 81 | } |
| ... | @@ -137,85 +139,112 @@ inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const pat | ... | @@ -137,85 +139,112 @@ inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const pat |
| 137 | inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { | 139 | inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { |
| 138 | return __create_symlink(__target, __link, &__ec); | 140 | return __create_symlink(__target, __link, &__ec); |
| 139 | } | 141 | } |
| 140 | inline _LIBCPP_HIDE_FROM_ABI path current_path() { return __current_path(); } | 142 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path current_path() { return __current_path(); } |
| 141 | inline _LIBCPP_HIDE_FROM_ABI path current_path(error_code& __ec) { return __current_path(&__ec); } | 143 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path current_path(error_code& __ec) { return __current_path(&__ec); } |
| 142 | inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p) { __current_path(__p); } | 144 | inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p) { __current_path(__p); } |
| 143 | inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p, error_code& __ec) noexcept { | 145 | inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p, error_code& __ec) noexcept { |
| 144 | __current_path(__p, &__ec); | 146 | __current_path(__p, &__ec); |
| 145 | } | 147 | } |
| 146 | inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); } | 148 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2) { |
| 147 | inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { | 149 | return __equivalent(__p1, __p2); |
| 150 | } | ||
| 151 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool | ||
| 152 | equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { | ||
| 148 | return __equivalent(__p1, __p2, &__ec); | 153 | return __equivalent(__p1, __p2, &__ec); |
| 149 | } | 154 | } |
| 150 | inline _LIBCPP_HIDE_FROM_ABI bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; } | 155 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool status_known(file_status __s) noexcept { |
| 151 | inline _LIBCPP_HIDE_FROM_ABI bool exists(file_status __s) noexcept { | 156 | return __s.type() != file_type::none; |
| 157 | } | ||
| 158 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool exists(file_status __s) noexcept { | ||
| 152 | return status_known(__s) && __s.type() != file_type::not_found; | 159 | return status_known(__s) && __s.type() != file_type::not_found; |
| 153 | } | 160 | } |
| 154 | inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p) { return exists(__status(__p)); } | 161 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p) { return exists(__status(__p)); } |
| 155 | 162 | ||
| 156 | inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p, error_code& __ec) noexcept { | 163 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p, error_code& __ec) noexcept { |
| 157 | auto __s = __status(__p, &__ec); | 164 | auto __s = __status(__p, &__ec); |
| 158 | if (status_known(__s)) | 165 | if (status_known(__s)) |
| 159 | __ec.clear(); | 166 | __ec.clear(); |
| 160 | return exists(__s); | 167 | return exists(__s); |
| 161 | } | 168 | } |
| 162 | 169 | ||
| 163 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p) { return __file_size(__p); } | 170 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p) { return __file_size(__p); } |
| 164 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p, error_code& __ec) noexcept { | 171 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p, error_code& __ec) noexcept { |
| 165 | return __file_size(__p, &__ec); | 172 | return __file_size(__p, &__ec); |
| 166 | } | 173 | } |
| 167 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); } | 174 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); } |
| 168 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { | 175 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { |
| 169 | return __hard_link_count(__p, &__ec); | 176 | return __hard_link_count(__p, &__ec); |
| 170 | } | 177 | } |
| 171 | inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; } | 178 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(file_status __s) noexcept { |
| 172 | inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p) { return is_block_file(__status(__p)); } | 179 | return __s.type() == file_type::block; |
| 173 | inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p, error_code& __ec) noexcept { | 180 | } |
| 181 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p) { return is_block_file(__status(__p)); } | ||
| 182 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p, error_code& __ec) noexcept { | ||
| 174 | return is_block_file(__status(__p, &__ec)); | 183 | return is_block_file(__status(__p, &__ec)); |
| 175 | } | 184 | } |
| 176 | inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(file_status __s) noexcept { | 185 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(file_status __s) noexcept { |
| 177 | return __s.type() == file_type::character; | 186 | return __s.type() == file_type::character; |
| 178 | } | 187 | } |
| 179 | inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p) { return is_character_file(__status(__p)); } | 188 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p) { |
| 180 | inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p, error_code& __ec) noexcept { | 189 | return is_character_file(__status(__p)); |
| 190 | } | ||
| 191 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p, error_code& __ec) noexcept { | ||
| 181 | return is_character_file(__status(__p, &__ec)); | 192 | return is_character_file(__status(__p, &__ec)); |
| 182 | } | 193 | } |
| 183 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; } | 194 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_directory(file_status __s) noexcept { |
| 184 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_directory(__status(__p)); } | 195 | return __s.type() == file_type::directory; |
| 185 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { | 196 | } |
| 197 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_directory(__status(__p)); } | ||
| 198 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { | ||
| 186 | return is_directory(__status(__p, &__ec)); | 199 | return is_directory(__status(__p, &__ec)); |
| 187 | } | 200 | } |
| 188 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); } | 201 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); } |
| 189 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } | 202 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { |
| 190 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; } | 203 | return __fs_is_empty(__p, &__ec); |
| 191 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p) { return is_fifo(__status(__p)); } | 204 | } |
| 192 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p, error_code& __ec) noexcept { | 205 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { |
| 206 | return __s.type() == file_type::fifo; | ||
| 207 | } | ||
| 208 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p) { return is_fifo(__status(__p)); } | ||
| 209 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p, error_code& __ec) noexcept { | ||
| 193 | return is_fifo(__status(__p, &__ec)); | 210 | return is_fifo(__status(__p, &__ec)); |
| 194 | } | 211 | } |
| 195 | inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; } | 212 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(file_status __s) noexcept { |
| 196 | inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); } | 213 | return __s.type() == file_type::regular; |
| 197 | inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p, error_code& __ec) noexcept { | 214 | } |
| 215 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p) { | ||
| 216 | return is_regular_file(__status(__p)); | ||
| 217 | } | ||
| 218 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p, error_code& __ec) noexcept { | ||
| 198 | return is_regular_file(__status(__p, &__ec)); | 219 | return is_regular_file(__status(__p, &__ec)); |
| 199 | } | 220 | } |
| 200 | inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; } | 221 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(file_status __s) noexcept { |
| 201 | inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); } | 222 | return __s.type() == file_type::symlink; |
| 202 | inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p, error_code& __ec) noexcept { | 223 | } |
| 224 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p) { | ||
| 225 | return is_symlink(__symlink_status(__p)); | ||
| 226 | } | ||
| 227 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p, error_code& __ec) noexcept { | ||
| 203 | return is_symlink(__symlink_status(__p, &__ec)); | 228 | return is_symlink(__symlink_status(__p, &__ec)); |
| 204 | } | 229 | } |
| 205 | inline _LIBCPP_HIDE_FROM_ABI bool is_other(file_status __s) noexcept { | 230 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_other(file_status __s) noexcept { |
| 206 | return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); | 231 | return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); |
| 207 | } | 232 | } |
| 208 | inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p) { return is_other(__status(__p)); } | 233 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p) { return is_other(__status(__p)); } |
| 209 | inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p, error_code& __ec) noexcept { | 234 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p, error_code& __ec) noexcept { |
| 210 | return is_other(__status(__p, &__ec)); | 235 | return is_other(__status(__p, &__ec)); |
| 211 | } | 236 | } |
| 212 | inline _LIBCPP_HIDE_FROM_ABI bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; } | 237 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_socket(file_status __s) noexcept { |
| 213 | inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p) { return is_socket(__status(__p)); } | 238 | return __s.type() == file_type::socket; |
| 214 | inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p, error_code& __ec) noexcept { | 239 | } |
| 240 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p) { return is_socket(__status(__p)); } | ||
| 241 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p, error_code& __ec) noexcept { | ||
| 215 | return is_socket(__status(__p, &__ec)); | 242 | return is_socket(__status(__p, &__ec)); |
| 216 | } | 243 | } |
| 217 | inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p) { return __last_write_time(__p); } | 244 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p) { |
| 218 | inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { | 245 | return __last_write_time(__p); |
| 246 | } | ||
| 247 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { | ||
| 219 | return __last_write_time(__p, &__ec); | 248 | return __last_write_time(__p, &__ec); |
| 220 | } | 249 | } |
| 221 | inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); } | 250 | inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); } |
| ... | @@ -233,7 +262,7 @@ inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, per | ... | @@ -233,7 +262,7 @@ inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, per |
| 233 | __permissions(__p, __prms, __opts, &__ec); | 262 | __permissions(__p, __prms, __opts, &__ec); |
| 234 | } | 263 | } |
| 235 | 264 | ||
| 236 | inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base, error_code& __ec) { | 265 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base, error_code& __ec) { |
| 237 | path __tmp = __weakly_canonical(__p, &__ec); | 266 | path __tmp = __weakly_canonical(__p, &__ec); |
| 238 | if (__ec) | 267 | if (__ec) |
| 239 | return {}; | 268 | return {}; |
| ... | @@ -243,16 +272,18 @@ inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base, | ... | @@ -243,16 +272,18 @@ inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base, |
| 243 | return __tmp.lexically_proximate(__tmp_base); | 272 | return __tmp.lexically_proximate(__tmp_base); |
| 244 | } | 273 | } |
| 245 | 274 | ||
| 246 | inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, error_code& __ec) { | 275 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, error_code& __ec) { |
| 247 | return proximate(__p, current_path(), __ec); | 276 | return proximate(__p, current_path(), __ec); |
| 248 | } | 277 | } |
| 249 | inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base = current_path()) { | 278 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base = current_path()) { |
| 250 | return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); | 279 | return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); |
| 251 | } | 280 | } |
| 252 | inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p) { return __read_symlink(__p); } | 281 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p) { return __read_symlink(__p); } |
| 253 | inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); } | 282 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p, error_code& __ec) { |
| 283 | return __read_symlink(__p, &__ec); | ||
| 284 | } | ||
| 254 | 285 | ||
| 255 | inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base, error_code& __ec) { | 286 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base, error_code& __ec) { |
| 256 | path __tmp = __weakly_canonical(__p, &__ec); | 287 | path __tmp = __weakly_canonical(__p, &__ec); |
| 257 | if (__ec) | 288 | if (__ec) |
| 258 | return path(); | 289 | return path(); |
| ... | @@ -262,10 +293,10 @@ inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base, | ... | @@ -262,10 +293,10 @@ inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base, |
| 262 | return __tmp.lexically_relative(__tmpbase); | 293 | return __tmp.lexically_relative(__tmpbase); |
| 263 | } | 294 | } |
| 264 | 295 | ||
| 265 | inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, error_code& __ec) { | 296 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, error_code& __ec) { |
| 266 | return relative(__p, current_path(), __ec); | 297 | return relative(__p, current_path(), __ec); |
| 267 | } | 298 | } |
| 268 | inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base = current_path()) { | 299 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base = current_path()) { |
| 269 | return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); | 300 | return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); |
| 270 | } | 301 | } |
| 271 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p) { return __remove_all(__p); } | 302 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p) { return __remove_all(__p); } |
| ... | @@ -282,27 +313,27 @@ inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { | ... | @@ -282,27 +313,27 @@ inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { |
| 282 | inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { | 313 | inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { |
| 283 | return __resize_file(__p, __ns, &__ec); | 314 | return __resize_file(__p, __ns, &__ec); |
| 284 | } | 315 | } |
| 285 | inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); } | 316 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); } |
| 286 | inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept { | 317 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept { |
| 287 | return __space(__p, &__ec); | 318 | return __space(__p, &__ec); |
| 288 | } | 319 | } |
| 289 | inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p) { return __status(__p); } | 320 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p) { return __status(__p); } |
| 290 | inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p, error_code& __ec) noexcept { | 321 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p, error_code& __ec) noexcept { |
| 291 | return __status(__p, &__ec); | 322 | return __status(__p, &__ec); |
| 292 | } | 323 | } |
| 293 | inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p) { return __symlink_status(__p); } | 324 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p) { return __symlink_status(__p); } |
| 294 | inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p, error_code& __ec) noexcept { | 325 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p, error_code& __ec) noexcept { |
| 295 | return __symlink_status(__p, &__ec); | 326 | return __symlink_status(__p, &__ec); |
| 296 | } | 327 | } |
| 297 | inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path() { return __temp_directory_path(); } | 328 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path() { return __temp_directory_path(); } |
| 298 | inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); } | 329 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path(error_code& __ec) { |
| 299 | inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p) { return __weakly_canonical(__p); } | 330 | return __temp_directory_path(&__ec); |
| 300 | inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p, error_code& __ec) { | 331 | } |
| 332 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p) { return __weakly_canonical(__p); } | ||
| 333 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p, error_code& __ec) { | ||
| 301 | return __weakly_canonical(__p, &__ec); | 334 | return __weakly_canonical(__p, &__ec); |
| 302 | } | 335 | } |
| 303 | 336 | ||
| 304 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP | ||
| 305 | |||
| 306 | _LIBCPP_END_NAMESPACE_FILESYSTEM | 337 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 307 | 338 | ||
| 308 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | 339 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM |
lib/libcxx/include/__filesystem/path.h+68-64| ... | @@ -42,8 +42,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -42,8 +42,6 @@ _LIBCPP_PUSH_MACROS |
| 42 | 42 | ||
| 43 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 43 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 44 | 44 | ||
| 45 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH | ||
| 46 | |||
| 47 | template <class _Tp> | 45 | template <class _Tp> |
| 48 | struct __can_convert_char { | 46 | struct __can_convert_char { |
| 49 | static const bool value = false; | 47 | static const bool value = false; |
| ... | @@ -326,6 +324,7 @@ struct _PathCVT<char> { | ... | @@ -326,6 +324,7 @@ struct _PathCVT<char> { |
| 326 | } | 324 | } |
| 327 | }; | 325 | }; |
| 328 | 326 | ||
| 327 | # if _LIBCPP_HAS_LOCALIZATION | ||
| 329 | template <class _ECharT> | 328 | template <class _ECharT> |
| 330 | struct _PathExport { | 329 | struct _PathExport { |
| 331 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; | 330 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; |
| ... | @@ -366,7 +365,7 @@ struct _PathExport<char16_t> { | ... | @@ -366,7 +365,7 @@ struct _PathExport<char16_t> { |
| 366 | } | 365 | } |
| 367 | }; | 366 | }; |
| 368 | 367 | ||
| 369 | # if _LIBCPP_HAS_CHAR8_T | 368 | # if _LIBCPP_HAS_CHAR8_T |
| 370 | template <> | 369 | template <> |
| 371 | struct _PathExport<char8_t> { | 370 | struct _PathExport<char8_t> { |
| 372 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; | 371 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; |
| ... | @@ -376,8 +375,9 @@ struct _PathExport<char8_t> { | ... | @@ -376,8 +375,9 @@ struct _PathExport<char8_t> { |
| 376 | _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); | 375 | _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); |
| 377 | } | 376 | } |
| 378 | }; | 377 | }; |
| 379 | # endif // _LIBCPP_HAS_CHAR8_T | 378 | # endif // _LIBCPP_HAS_CHAR8_T |
| 380 | # endif /* _LIBCPP_WIN32API */ | 379 | # endif // _LIBCPP_HAS_LOCALIZATION |
| 380 | # endif // _LIBCPP_WIN32API | ||
| 381 | 381 | ||
| 382 | class _LIBCPP_EXPORTED_FROM_ABI path { | 382 | class _LIBCPP_EXPORTED_FROM_ABI path { |
| 383 | template <class _SourceOrIter, class _Tp = path&> | 383 | template <class _SourceOrIter, class _Tp = path&> |
| ... | @@ -667,16 +667,16 @@ public: | ... | @@ -667,16 +667,16 @@ public: |
| 667 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __s) { __pn_.reserve(__s); } | 667 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __s) { __pn_.reserve(__s); } |
| 668 | 668 | ||
| 669 | // native format observers | 669 | // native format observers |
| 670 | _LIBCPP_HIDE_FROM_ABI const string_type& native() const noexcept { return __pn_; } | 670 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const string_type& native() const noexcept { return __pn_; } |
| 671 | 671 | ||
| 672 | _LIBCPP_HIDE_FROM_ABI const value_type* c_str() const noexcept { return __pn_.c_str(); } | 672 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const value_type* c_str() const noexcept { return __pn_.c_str(); } |
| 673 | 673 | ||
| 674 | _LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; } | 674 | _LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; } |
| 675 | 675 | ||
| 676 | # if defined(_LIBCPP_WIN32API) | 676 | # if defined(_LIBCPP_WIN32API) |
| 677 | _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return __pn_; } | 677 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return __pn_; } |
| 678 | 678 | ||
| 679 | _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { | 679 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { |
| 680 | std::wstring __s; | 680 | std::wstring __s; |
| 681 | __s.resize(__pn_.size()); | 681 | __s.resize(__pn_.size()); |
| 682 | std::replace_copy(__pn_.begin(), __pn_.end(), __s.begin(), '\\', '/'); | 682 | std::replace_copy(__pn_.begin(), __pn_.end(), __s.begin(), '\\', '/'); |
| ... | @@ -685,6 +685,7 @@ public: | ... | @@ -685,6 +685,7 @@ public: |
| 685 | 685 | ||
| 686 | # if _LIBCPP_HAS_LOCALIZATION | 686 | # if _LIBCPP_HAS_LOCALIZATION |
| 687 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > | 687 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > |
| 688 | [[nodiscard]] | ||
| 688 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const { | 689 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const { |
| 689 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | 690 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; |
| 690 | _Str __s(__a); | 691 | _Str __s(__a); |
| ... | @@ -693,8 +694,8 @@ public: | ... | @@ -693,8 +694,8 @@ public: |
| 693 | return __s; | 694 | return __s; |
| 694 | } | 695 | } |
| 695 | 696 | ||
| 696 | _LIBCPP_HIDE_FROM_ABI std::string string() const { return string<char>(); } | 697 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::string string() const { return string<char>(); } |
| 697 | _LIBCPP_HIDE_FROM_ABI __u8_string u8string() const { | 698 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __u8_string u8string() const { |
| 698 | using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | 699 | using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>; |
| 699 | __u8_string __s; | 700 | __u8_string __s; |
| 700 | __s.reserve(__pn_.size()); | 701 | __s.reserve(__pn_.size()); |
| ... | @@ -702,12 +703,12 @@ public: | ... | @@ -702,12 +703,12 @@ public: |
| 702 | return __s; | 703 | return __s; |
| 703 | } | 704 | } |
| 704 | 705 | ||
| 705 | _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); } | 706 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); } |
| 706 | _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); } | 707 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); } |
| 707 | 708 | ||
| 708 | // generic format observers | 709 | // generic format observers |
| 709 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > | 710 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > |
| 710 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> | 711 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> |
| 711 | generic_string(const _Allocator& __a = _Allocator()) const { | 712 | generic_string(const _Allocator& __a = _Allocator()) const { |
| 712 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | 713 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; |
| 713 | _Str __s = string<_ECharT, _Traits, _Allocator>(__a); | 714 | _Str __s = string<_ECharT, _Traits, _Allocator>(__a); |
| ... | @@ -718,10 +719,10 @@ public: | ... | @@ -718,10 +719,10 @@ public: |
| 718 | return __s; | 719 | return __s; |
| 719 | } | 720 | } |
| 720 | 721 | ||
| 721 | _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return generic_string<char>(); } | 722 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return generic_string<char>(); } |
| 722 | _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return generic_string<char16_t>(); } | 723 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return generic_string<char16_t>(); } |
| 723 | _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return generic_string<char32_t>(); } | 724 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return generic_string<char32_t>(); } |
| 724 | _LIBCPP_HIDE_FROM_ABI __u8_string generic_u8string() const { | 725 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __u8_string generic_u8string() const { |
| 725 | __u8_string __s = u8string(); | 726 | __u8_string __s = u8string(); |
| 726 | std::replace(__s.begin(), __s.end(), '\\', '/'); | 727 | std::replace(__s.begin(), __s.end(), '\\', '/'); |
| 727 | return __s; | 728 | return __s; |
| ... | @@ -729,15 +730,18 @@ public: | ... | @@ -729,15 +730,18 @@ public: |
| 729 | # endif // _LIBCPP_HAS_LOCALIZATION | 730 | # endif // _LIBCPP_HAS_LOCALIZATION |
| 730 | # else /* _LIBCPP_WIN32API */ | 731 | # else /* _LIBCPP_WIN32API */ |
| 731 | 732 | ||
| 732 | _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; } | 733 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; } |
| 733 | # if _LIBCPP_HAS_CHAR8_T | 734 | # if _LIBCPP_HAS_CHAR8_T |
| 734 | _LIBCPP_HIDE_FROM_ABI std::u8string u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); } | 735 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u8string u8string() const { |
| 736 | return std::u8string(__pn_.begin(), __pn_.end()); | ||
| 737 | } | ||
| 735 | # else | 738 | # else |
| 736 | _LIBCPP_HIDE_FROM_ABI std::string u8string() const { return __pn_; } | 739 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::string u8string() const { return __pn_; } |
| 737 | # endif | 740 | # endif |
| 738 | 741 | ||
| 739 | # if _LIBCPP_HAS_LOCALIZATION | 742 | # if _LIBCPP_HAS_LOCALIZATION |
| 740 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > | 743 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > |
| 744 | [[nodiscard]] | ||
| 741 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const { | 745 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const { |
| 742 | using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>; | 746 | using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>; |
| 743 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | 747 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; |
| ... | @@ -748,32 +752,34 @@ public: | ... | @@ -748,32 +752,34 @@ public: |
| 748 | } | 752 | } |
| 749 | 753 | ||
| 750 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 754 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 751 | _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return string<wchar_t>(); } | 755 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return string<wchar_t>(); } |
| 752 | # endif | 756 | # endif |
| 753 | _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); } | 757 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); } |
| 754 | _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); } | 758 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); } |
| 755 | # endif // _LIBCPP_HAS_LOCALIZATION | 759 | # endif // _LIBCPP_HAS_LOCALIZATION |
| 756 | 760 | ||
| 757 | // generic format observers | 761 | // generic format observers |
| 758 | _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return __pn_; } | 762 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return __pn_; } |
| 759 | # if _LIBCPP_HAS_CHAR8_T | 763 | # if _LIBCPP_HAS_CHAR8_T |
| 760 | _LIBCPP_HIDE_FROM_ABI std::u8string generic_u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); } | 764 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u8string generic_u8string() const { |
| 765 | return std::u8string(__pn_.begin(), __pn_.end()); | ||
| 766 | } | ||
| 761 | # else | 767 | # else |
| 762 | _LIBCPP_HIDE_FROM_ABI std::string generic_u8string() const { return __pn_; } | 768 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::string generic_u8string() const { return __pn_; } |
| 763 | # endif | 769 | # endif |
| 764 | 770 | ||
| 765 | # if _LIBCPP_HAS_LOCALIZATION | 771 | # if _LIBCPP_HAS_LOCALIZATION |
| 766 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > | 772 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > |
| 767 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> | 773 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> |
| 768 | generic_string(const _Allocator& __a = _Allocator()) const { | 774 | generic_string(const _Allocator& __a = _Allocator()) const { |
| 769 | return string<_ECharT, _Traits, _Allocator>(__a); | 775 | return string<_ECharT, _Traits, _Allocator>(__a); |
| 770 | } | 776 | } |
| 771 | 777 | ||
| 772 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 778 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 773 | _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { return string<wchar_t>(); } | 779 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { return string<wchar_t>(); } |
| 774 | # endif | 780 | # endif |
| 775 | _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return string<char16_t>(); } | 781 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return string<char16_t>(); } |
| 776 | _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return string<char32_t>(); } | 782 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return string<char32_t>(); } |
| 777 | # endif // _LIBCPP_HAS_LOCALIZATION | 783 | # endif // _LIBCPP_HAS_LOCALIZATION |
| 778 | # endif /* !_LIBCPP_WIN32API */ | 784 | # endif /* !_LIBCPP_WIN32API */ |
| 779 | 785 | ||
| ... | @@ -790,40 +796,40 @@ private: | ... | @@ -790,40 +796,40 @@ private: |
| 790 | 796 | ||
| 791 | public: | 797 | public: |
| 792 | // compare | 798 | // compare |
| 793 | _LIBCPP_HIDE_FROM_ABI int compare(const path& __p) const noexcept { return __compare(__p.__pn_); } | 799 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int compare(const path& __p) const noexcept { return __compare(__p.__pn_); } |
| 794 | _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return __compare(__s); } | 800 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return __compare(__s); } |
| 795 | _LIBCPP_HIDE_FROM_ABI int compare(__string_view __s) const { return __compare(__s); } | 801 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int compare(__string_view __s) const { return __compare(__s); } |
| 796 | _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return __compare(__s); } | 802 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return __compare(__s); } |
| 797 | 803 | ||
| 798 | // decomposition | 804 | // decomposition |
| 799 | _LIBCPP_HIDE_FROM_ABI path root_name() const { return string_type(__root_name()); } | 805 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path root_name() const { return string_type(__root_name()); } |
| 800 | _LIBCPP_HIDE_FROM_ABI path root_directory() const { return string_type(__root_directory()); } | 806 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path root_directory() const { return string_type(__root_directory()); } |
| 801 | _LIBCPP_HIDE_FROM_ABI path root_path() const { | 807 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path root_path() const { |
| 802 | # if defined(_LIBCPP_WIN32API) | 808 | # if defined(_LIBCPP_WIN32API) |
| 803 | return string_type(__root_path_raw()); | 809 | return string_type(__root_path_raw()); |
| 804 | # else | 810 | # else |
| 805 | return root_name().append(string_type(__root_directory())); | 811 | return root_name().append(string_type(__root_directory())); |
| 806 | # endif | 812 | # endif |
| 807 | } | 813 | } |
| 808 | _LIBCPP_HIDE_FROM_ABI path relative_path() const { return string_type(__relative_path()); } | 814 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path relative_path() const { return string_type(__relative_path()); } |
| 809 | _LIBCPP_HIDE_FROM_ABI path parent_path() const { return string_type(__parent_path()); } | 815 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path parent_path() const { return string_type(__parent_path()); } |
| 810 | _LIBCPP_HIDE_FROM_ABI path filename() const { return string_type(__filename()); } | 816 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path filename() const { return string_type(__filename()); } |
| 811 | _LIBCPP_HIDE_FROM_ABI path stem() const { return string_type(__stem()); } | 817 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path stem() const { return string_type(__stem()); } |
| 812 | _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); } | 818 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); } |
| 813 | 819 | ||
| 814 | // query | 820 | // query |
| 815 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } | 821 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } |
| 816 | 822 | ||
| 817 | _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); } | 823 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); } |
| 818 | _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); } | 824 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); } |
| 819 | _LIBCPP_HIDE_FROM_ABI bool has_root_path() const { return !__root_path_raw().empty(); } | 825 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_root_path() const { return !__root_path_raw().empty(); } |
| 820 | _LIBCPP_HIDE_FROM_ABI bool has_relative_path() const { return !__relative_path().empty(); } | 826 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_relative_path() const { return !__relative_path().empty(); } |
| 821 | _LIBCPP_HIDE_FROM_ABI bool has_parent_path() const { return !__parent_path().empty(); } | 827 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_parent_path() const { return !__parent_path().empty(); } |
| 822 | _LIBCPP_HIDE_FROM_ABI bool has_filename() const { return !__filename().empty(); } | 828 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_filename() const { return !__filename().empty(); } |
| 823 | _LIBCPP_HIDE_FROM_ABI bool has_stem() const { return !__stem().empty(); } | 829 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_stem() const { return !__stem().empty(); } |
| 824 | _LIBCPP_HIDE_FROM_ABI bool has_extension() const { return !__extension().empty(); } | 830 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_extension() const { return !__extension().empty(); } |
| 825 | 831 | ||
| 826 | _LIBCPP_HIDE_FROM_ABI bool is_absolute() const { | 832 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_absolute() const { |
| 827 | # if defined(_LIBCPP_WIN32API) | 833 | # if defined(_LIBCPP_WIN32API) |
| 828 | __string_view __root_name_str = __root_name(); | 834 | __string_view __root_name_str = __root_name(); |
| 829 | __string_view __root_dir = __root_directory(); | 835 | __string_view __root_dir = __root_directory(); |
| ... | @@ -847,13 +853,13 @@ public: | ... | @@ -847,13 +853,13 @@ public: |
| 847 | return has_root_directory(); | 853 | return has_root_directory(); |
| 848 | # endif | 854 | # endif |
| 849 | } | 855 | } |
| 850 | _LIBCPP_HIDE_FROM_ABI bool is_relative() const { return !is_absolute(); } | 856 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_relative() const { return !is_absolute(); } |
| 851 | 857 | ||
| 852 | // relative paths | 858 | // relative paths |
| 853 | path lexically_normal() const; | 859 | [[nodiscard]] path lexically_normal() const; |
| 854 | path lexically_relative(const path& __base) const; | 860 | [[nodiscard]] path lexically_relative(const path& __base) const; |
| 855 | 861 | ||
| 856 | _LIBCPP_HIDE_FROM_ABI path lexically_proximate(const path& __base) const { | 862 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI path lexically_proximate(const path& __base) const { |
| 857 | path __result = this->lexically_relative(__base); | 863 | path __result = this->lexically_relative(__base); |
| 858 | if (__result.native().empty()) | 864 | if (__result.native().empty()) |
| 859 | return *this; | 865 | return *this; |
| ... | @@ -861,11 +867,11 @@ public: | ... | @@ -861,11 +867,11 @@ public: |
| 861 | } | 867 | } |
| 862 | 868 | ||
| 863 | // iterators | 869 | // iterators |
| 864 | class _LIBCPP_EXPORTED_FROM_ABI iterator; | 870 | class iterator; |
| 865 | typedef iterator const_iterator; | 871 | typedef iterator const_iterator; |
| 866 | 872 | ||
| 867 | iterator begin() const; | 873 | [[nodiscard]] iterator begin() const; |
| 868 | iterator end() const; | 874 | [[nodiscard]] iterator end() const; |
| 869 | 875 | ||
| 870 | # if _LIBCPP_HAS_LOCALIZATION | 876 | # if _LIBCPP_HAS_LOCALIZATION |
| 871 | template < | 877 | template < |
| ... | @@ -908,17 +914,15 @@ private: | ... | @@ -908,17 +914,15 @@ private: |
| 908 | 914 | ||
| 909 | inline _LIBCPP_HIDE_FROM_ABI void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); } | 915 | inline _LIBCPP_HIDE_FROM_ABI void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); } |
| 910 | 916 | ||
| 911 | _LIBCPP_EXPORTED_FROM_ABI size_t hash_value(const path& __p) noexcept; | 917 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI size_t hash_value(const path& __p) noexcept; |
| 912 | |||
| 913 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP | ||
| 914 | 918 | ||
| 915 | _LIBCPP_END_NAMESPACE_FILESYSTEM | 919 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 916 | 920 | ||
| 917 | _LIBCPP_BEGIN_NAMESPACE_STD | 921 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 918 | 922 | ||
| 919 | template <> | 923 | template <> |
| 920 | struct _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY hash<filesystem::path> : __unary_function<filesystem::path, size_t> { | 924 | struct hash<filesystem::path> : __unary_function<filesystem::path, size_t> { |
| 921 | _LIBCPP_HIDE_FROM_ABI size_t operator()(filesystem::path const& __p) const noexcept { | 925 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t operator()(filesystem::path const& __p) const noexcept { |
| 922 | return filesystem::hash_value(__p); | 926 | return filesystem::hash_value(__p); |
| 923 | } | 927 | } |
| 924 | }; | 928 | }; |
lib/libcxx/include/__filesystem/path_iterator.h+1-3| ... | @@ -52,7 +52,7 @@ public: | ... | @@ -52,7 +52,7 @@ public: |
| 52 | 52 | ||
| 53 | _LIBCPP_HIDE_FROM_ABI iterator& operator=(const iterator&) = default; | 53 | _LIBCPP_HIDE_FROM_ABI iterator& operator=(const iterator&) = default; |
| 54 | 54 | ||
| 55 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __stashed_elem_; } | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __stashed_elem_; } |
| 56 | 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return &__stashed_elem_; } | 57 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return &__stashed_elem_; } |
| 58 | 58 | ||
| ... | @@ -95,12 +95,10 @@ private: | ... | @@ -95,12 +95,10 @@ private: |
| 95 | _ParserState __state_; | 95 | _ParserState __state_; |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY | ||
| 99 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(const path::iterator& __lhs, const path::iterator& __rhs) { | 98 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(const path::iterator& __lhs, const path::iterator& __rhs) { |
| 100 | return __lhs.__path_ptr_ == __rhs.__path_ptr_ && __lhs.__entry_.data() == __rhs.__entry_.data(); | 99 | return __lhs.__path_ptr_ == __rhs.__path_ptr_ && __lhs.__entry_.data() == __rhs.__entry_.data(); |
| 101 | } | 100 | } |
| 102 | 101 | ||
| 103 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY | ||
| 104 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const path::iterator& __lhs, const path::iterator& __rhs) { | 102 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const path::iterator& __lhs, const path::iterator& __rhs) { |
| 105 | return !(__lhs == __rhs); | 103 | return !(__lhs == __rhs); |
| 106 | } | 104 | } |
lib/libcxx/include/__filesystem/perm_options.h+4-4| ... | @@ -22,19 +22,19 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | ... | @@ -22,19 +22,19 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 22 | 22 | ||
| 23 | enum class perm_options : unsigned char { replace = 1, add = 2, remove = 4, nofollow = 8 }; | 23 | enum class perm_options : unsigned char { replace = 1, add = 2, remove = 4, nofollow = 8 }; |
| 24 | 24 | ||
| 25 | _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator&(perm_options __lhs, perm_options __rhs) { | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator&(perm_options __lhs, perm_options __rhs) { |
| 26 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) & static_cast<unsigned>(__rhs)); | 26 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) & static_cast<unsigned>(__rhs)); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator|(perm_options __lhs, perm_options __rhs) { | 29 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator|(perm_options __lhs, perm_options __rhs) { |
| 30 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) | static_cast<unsigned>(__rhs)); | 30 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) | static_cast<unsigned>(__rhs)); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator^(perm_options __lhs, perm_options __rhs) { | 33 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator^(perm_options __lhs, perm_options __rhs) { |
| 34 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) ^ static_cast<unsigned>(__rhs)); | 34 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) ^ static_cast<unsigned>(__rhs)); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator~(perm_options __lhs) { | 37 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perm_options operator~(perm_options __lhs) { |
| 38 | return static_cast<perm_options>(~static_cast<unsigned>(__lhs)); | 38 | return static_cast<perm_options>(~static_cast<unsigned>(__lhs)); |
| 39 | } | 39 | } |
| 40 | 40 |
lib/libcxx/include/__filesystem/perms.h+4-4| ... | @@ -51,19 +51,19 @@ enum class perms : unsigned { | ... | @@ -51,19 +51,19 @@ enum class perms : unsigned { |
| 51 | unknown = 0xFFFF, | 51 | unknown = 0xFFFF, |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator&(perms __lhs, perms __rhs) { | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator&(perms __lhs, perms __rhs) { |
| 55 | return static_cast<perms>(static_cast<unsigned>(__lhs) & static_cast<unsigned>(__rhs)); | 55 | return static_cast<perms>(static_cast<unsigned>(__lhs) & static_cast<unsigned>(__rhs)); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator|(perms __lhs, perms __rhs) { | 58 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator|(perms __lhs, perms __rhs) { |
| 59 | return static_cast<perms>(static_cast<unsigned>(__lhs) | static_cast<unsigned>(__rhs)); | 59 | return static_cast<perms>(static_cast<unsigned>(__lhs) | static_cast<unsigned>(__rhs)); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator^(perms __lhs, perms __rhs) { | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator^(perms __lhs, perms __rhs) { |
| 63 | return static_cast<perms>(static_cast<unsigned>(__lhs) ^ static_cast<unsigned>(__rhs)); | 63 | return static_cast<perms>(static_cast<unsigned>(__lhs) ^ static_cast<unsigned>(__rhs)); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator~(perms __lhs) { | 66 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr perms operator~(perms __lhs) { |
| 67 | return static_cast<perms>(~static_cast<unsigned>(__lhs)); | 67 | return static_cast<perms>(~static_cast<unsigned>(__lhs)); |
| 68 | } | 68 | } |
| 69 | 69 |
lib/libcxx/include/__filesystem/recursive_directory_iterator.h+9-14| ... | @@ -33,8 +33,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -33,8 +33,6 @@ _LIBCPP_PUSH_MACROS |
| 33 | 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 34 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 35 | 35 | ||
| 36 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH | ||
| 37 | |||
| 38 | class recursive_directory_iterator { | 36 | class recursive_directory_iterator { |
| 39 | public: | 37 | public: |
| 40 | using value_type = directory_entry; | 38 | using value_type = directory_entry; |
| ... | @@ -73,7 +71,7 @@ public: | ... | @@ -73,7 +71,7 @@ public: |
| 73 | 71 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI ~recursive_directory_iterator() = default; | 72 | _LIBCPP_HIDE_FROM_ABI ~recursive_directory_iterator() = default; |
| 75 | 73 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI const directory_entry& operator*() const { return __dereference(); } | 74 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const directory_entry& operator*() const { return __dereference(); } |
| 77 | 75 | ||
| 78 | _LIBCPP_HIDE_FROM_ABI const directory_entry* operator->() const { return &__dereference(); } | 76 | _LIBCPP_HIDE_FROM_ABI const directory_entry* operator->() const { return &__dereference(); } |
| 79 | 77 | ||
| ... | @@ -87,14 +85,14 @@ public: | ... | @@ -87,14 +85,14 @@ public: |
| 87 | 85 | ||
| 88 | _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } | 86 | _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } |
| 89 | 87 | ||
| 90 | _LIBCPP_EXPORTED_FROM_ABI directory_options options() const; | 88 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI directory_options options() const; |
| 91 | _LIBCPP_EXPORTED_FROM_ABI int depth() const; | 89 | [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI int depth() const; |
| 92 | 90 | ||
| 93 | _LIBCPP_HIDE_FROM_ABI void pop() { __pop(); } | 91 | _LIBCPP_HIDE_FROM_ABI void pop() { __pop(); } |
| 94 | 92 | ||
| 95 | _LIBCPP_HIDE_FROM_ABI void pop(error_code& __ec) { __pop(&__ec); } | 93 | _LIBCPP_HIDE_FROM_ABI void pop(error_code& __ec) { __pop(&__ec); } |
| 96 | 94 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI bool recursion_pending() const { return __rec_; } | 95 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool recursion_pending() const { return __rec_; } |
| 98 | 96 | ||
| 99 | _LIBCPP_HIDE_FROM_ABI void disable_recursion_pending() { __rec_ = false; } | 97 | _LIBCPP_HIDE_FROM_ABI void disable_recursion_pending() { __rec_ = false; } |
| 100 | 98 | ||
| ... | @@ -132,27 +130,24 @@ operator!=(const recursive_directory_iterator& __lhs, const recursive_directory_ | ... | @@ -132,27 +130,24 @@ operator!=(const recursive_directory_iterator& __lhs, const recursive_directory_ |
| 132 | return !(__lhs == __rhs); | 130 | return !(__lhs == __rhs); |
| 133 | } | 131 | } |
| 134 | // enable recursive_directory_iterator range-based for statements | 132 | // enable recursive_directory_iterator range-based for statements |
| 135 | inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator begin(recursive_directory_iterator __iter) noexcept { | 133 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator |
| 134 | begin(recursive_directory_iterator __iter) noexcept { | ||
| 136 | return __iter; | 135 | return __iter; |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator end(recursive_directory_iterator) noexcept { | 138 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator end(recursive_directory_iterator) noexcept { |
| 140 | return recursive_directory_iterator(); | 139 | return recursive_directory_iterator(); |
| 141 | } | 140 | } |
| 142 | 141 | ||
| 143 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP | ||
| 144 | |||
| 145 | _LIBCPP_END_NAMESPACE_FILESYSTEM | 142 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 146 | 143 | ||
| 147 | # if _LIBCPP_STD_VER >= 20 | 144 | # if _LIBCPP_STD_VER >= 20 |
| 148 | 145 | ||
| 149 | template <> | 146 | template <> |
| 150 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool | 147 | inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; |
| 151 | std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; | ||
| 152 | 148 | ||
| 153 | template <> | 149 | template <> |
| 154 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool | 150 | inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; |
| 155 | std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; | ||
| 156 | 151 | ||
| 157 | # endif // _LIBCPP_STD_VER >= 20 | 152 | # endif // _LIBCPP_STD_VER >= 20 |
| 158 | 153 |
lib/libcxx/include/__filesystem/space_info.h+1-1| ... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 22 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 23 | 23 | ||
| 24 | struct _LIBCPP_EXPORTED_FROM_ABI space_info { | 24 | struct space_info { |
| 25 | uintmax_t capacity; | 25 | uintmax_t capacity; |
| 26 | uintmax_t free; | 26 | uintmax_t free; |
| 27 | uintmax_t available; | 27 | uintmax_t available; |
lib/libcxx/include/__filesystem/u8path.h+12-14| ... | @@ -24,32 +24,32 @@ | ... | @@ -24,32 +24,32 @@ |
| 24 | 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | 25 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 26 | 26 | ||
| 27 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH | 27 | # if !defined(_LIBCPP_WIN32API) || _LIBCPP_HAS_LOCALIZATION |
| 28 | |||
| 29 | template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> | 28 | template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> |
| 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) { | 29 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) { |
| 31 | static_assert( | 30 | static_assert( |
| 32 | # if _LIBCPP_HAS_CHAR8_T | 31 | # if _LIBCPP_HAS_CHAR8_T |
| 33 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || | 32 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || |
| 34 | # endif | 33 | # endif |
| 35 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, | 34 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, |
| 36 | "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" | 35 | "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" |
| 37 | " or 'char8_t'"); | 36 | " or 'char8_t'"); |
| 38 | # if defined(_LIBCPP_WIN32API) | 37 | # if defined(_LIBCPP_WIN32API) |
| 39 | string __tmp(__f, __l); | 38 | string __tmp(__f, __l); |
| 40 | using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | 39 | using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>; |
| 41 | std::wstring __w; | 40 | std::wstring __w; |
| 42 | __w.reserve(__tmp.size()); | 41 | __w.reserve(__tmp.size()); |
| 43 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); | 42 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); |
| 44 | return path(__w); | 43 | return path(__w); |
| 45 | # else | 44 | # else |
| 46 | return path(__f, __l); | 45 | return path(__f, __l); |
| 47 | # endif /* !_LIBCPP_WIN32API */ | 46 | # endif // defined(_LIBCPP_WIN32API) |
| 48 | } | 47 | } |
| 48 | # endif // !defined(_LIBCPP_WIN32API) || _LIBCPP_HAS_LOCALIZATION | ||
| 49 | 49 | ||
| 50 | # if defined(_LIBCPP_WIN32API) | 50 | # if defined(_LIBCPP_WIN32API) && _LIBCPP_HAS_LOCALIZATION |
| 51 | template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> | 51 | template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> |
| 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) { | 52 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) { |
| 53 | static_assert( | 53 | static_assert( |
| 54 | # if _LIBCPP_HAS_CHAR8_T | 54 | # if _LIBCPP_HAS_CHAR8_T |
| 55 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || | 55 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || |
| ... | @@ -67,10 +67,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, | ... | @@ -67,10 +67,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, |
| 67 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); | 67 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); |
| 68 | return path(__w); | 68 | return path(__w); |
| 69 | } | 69 | } |
| 70 | # endif /* _LIBCPP_WIN32API */ | 70 | # endif // defined(_LIBCPP_WIN32API) && _LIBCPP_HAS_LOCALIZATION |
| 71 | 71 | ||
| 72 | template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0> | 72 | template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0> |
| 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) { | 73 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) { |
| 74 | static_assert( | 74 | static_assert( |
| 75 | # if _LIBCPP_HAS_CHAR8_T | 75 | # if _LIBCPP_HAS_CHAR8_T |
| 76 | is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value || | 76 | is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value || |
| ... | @@ -86,8 +86,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& | ... | @@ -86,8 +86,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& |
| 86 | # endif | 86 | # endif |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP | ||
| 90 | |||
| 91 | _LIBCPP_END_NAMESPACE_FILESYSTEM | 89 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 92 | 90 | ||
| 93 | #endif // _LIBCPP_STD_VER >= 17 | 91 | #endif // _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/__flat_map/flat_map.h+88-71| ... | @@ -29,7 +29,6 @@ | ... | @@ -29,7 +29,6 @@ |
| 29 | #include <__flat_map/key_value_iterator.h> | 29 | #include <__flat_map/key_value_iterator.h> |
| 30 | #include <__flat_map/sorted_unique.h> | 30 | #include <__flat_map/sorted_unique.h> |
| 31 | #include <__flat_map/utils.h> | 31 | #include <__flat_map/utils.h> |
| 32 | #include <__functional/invoke.h> | ||
| 33 | #include <__functional/is_transparent.h> | 32 | #include <__functional/is_transparent.h> |
| 34 | #include <__functional/operations.h> | 33 | #include <__functional/operations.h> |
| 35 | #include <__fwd/memory.h> | 34 | #include <__fwd/memory.h> |
| ... | @@ -48,7 +47,7 @@ | ... | @@ -48,7 +47,7 @@ |
| 48 | #include <__ranges/container_compatible_range.h> | 47 | #include <__ranges/container_compatible_range.h> |
| 49 | #include <__ranges/drop_view.h> | 48 | #include <__ranges/drop_view.h> |
| 50 | #include <__ranges/from_range.h> | 49 | #include <__ranges/from_range.h> |
| 51 | #include <__ranges/ref_view.h> | 50 | #include <__ranges/range_adaptor.h> |
| 52 | #include <__ranges/size.h> | 51 | #include <__ranges/size.h> |
| 53 | #include <__ranges/subrange.h> | 52 | #include <__ranges/subrange.h> |
| 54 | #include <__ranges/zip_view.h> | 53 | #include <__ranges/zip_view.h> |
| ... | @@ -410,41 +409,45 @@ public: | ... | @@ -410,41 +409,45 @@ public: |
| 410 | } | 409 | } |
| 411 | 410 | ||
| 412 | // iterators | 411 | // iterators |
| 413 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { | 412 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { |
| 414 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); | 413 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); |
| 415 | } | 414 | } |
| 416 | 415 | ||
| 417 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { | 416 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { |
| 418 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); | 417 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); |
| 419 | } | 418 | } |
| 420 | 419 | ||
| 421 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { | 420 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { |
| 422 | return iterator(__containers_.keys.end(), __containers_.values.end()); | 421 | return iterator(__containers_.keys.end(), __containers_.values.end()); |
| 423 | } | 422 | } |
| 424 | 423 | ||
| 425 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { | 424 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { |
| 426 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); | 425 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); |
| 427 | } | 426 | } |
| 428 | 427 | ||
| 429 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { | 428 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { |
| 430 | return reverse_iterator(end()); | 429 | return reverse_iterator(end()); |
| 431 | } | 430 | } |
| 432 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { | 431 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { |
| 433 | return const_reverse_iterator(end()); | 432 | return const_reverse_iterator(end()); |
| 434 | } | 433 | } |
| 435 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { | 434 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { |
| 436 | return reverse_iterator(begin()); | 435 | return reverse_iterator(begin()); |
| 437 | } | 436 | } |
| 438 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { | 437 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { |
| 439 | return const_reverse_iterator(begin()); | 438 | return const_reverse_iterator(begin()); |
| 440 | } | 439 | } |
| 441 | 440 | ||
| 442 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { return begin(); } | 441 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { |
| 443 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { return end(); } | 442 | return begin(); |
| 444 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { | 443 | } |
| 444 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { | ||
| 445 | return end(); | ||
| 446 | } | ||
| 447 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { | ||
| 445 | return const_reverse_iterator(end()); | 448 | return const_reverse_iterator(end()); |
| 446 | } | 449 | } |
| 447 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { | 450 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { |
| 448 | return const_reverse_iterator(begin()); | 451 | return const_reverse_iterator(begin()); |
| 449 | } | 452 | } |
| 450 | 453 | ||
| ... | @@ -453,11 +456,11 @@ public: | ... | @@ -453,11 +456,11 @@ public: |
| 453 | return __containers_.keys.empty(); | 456 | return __containers_.keys.empty(); |
| 454 | } | 457 | } |
| 455 | 458 | ||
| 456 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { | 459 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { |
| 457 | return __containers_.keys.size(); | 460 | return __containers_.keys.size(); |
| 458 | } | 461 | } |
| 459 | 462 | ||
| 460 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { | 463 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { |
| 461 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); | 464 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); |
| 462 | } | 465 | } |
| 463 | 466 | ||
| ... | @@ -481,7 +484,7 @@ public: | ... | @@ -481,7 +484,7 @@ public: |
| 481 | return try_emplace(std::forward<_Kp>(__x)).first->second; | 484 | return try_emplace(std::forward<_Kp>(__x)).first->second; |
| 482 | } | 485 | } |
| 483 | 486 | ||
| 484 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const key_type& __x) { | 487 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const key_type& __x) { |
| 485 | auto __it = find(__x); | 488 | auto __it = find(__x); |
| 486 | if (__it == end()) { | 489 | if (__it == end()) { |
| 487 | std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist"); | 490 | std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist"); |
| ... | @@ -489,7 +492,7 @@ public: | ... | @@ -489,7 +492,7 @@ public: |
| 489 | return __it->second; | 492 | return __it->second; |
| 490 | } | 493 | } |
| 491 | 494 | ||
| 492 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const key_type& __x) const { | 495 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const key_type& __x) const { |
| 493 | auto __it = find(__x); | 496 | auto __it = find(__x); |
| 494 | if (__it == end()) { | 497 | if (__it == end()) { |
| 495 | std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist"); | 498 | std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist"); |
| ... | @@ -499,7 +502,7 @@ public: | ... | @@ -499,7 +502,7 @@ public: |
| 499 | 502 | ||
| 500 | template <class _Kp> | 503 | template <class _Kp> |
| 501 | requires __is_compare_transparent | 504 | requires __is_compare_transparent |
| 502 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const _Kp& __x) { | 505 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const _Kp& __x) { |
| 503 | auto __it = find(__x); | 506 | auto __it = find(__x); |
| 504 | if (__it == end()) { | 507 | if (__it == end()) { |
| 505 | std::__throw_out_of_range("flat_map::at(const K&): Key does not exist"); | 508 | std::__throw_out_of_range("flat_map::at(const K&): Key does not exist"); |
| ... | @@ -509,7 +512,7 @@ public: | ... | @@ -509,7 +512,7 @@ public: |
| 509 | 512 | ||
| 510 | template <class _Kp> | 513 | template <class _Kp> |
| 511 | requires __is_compare_transparent | 514 | requires __is_compare_transparent |
| 512 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const _Kp& __x) const { | 515 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const _Kp& __x) const { |
| 513 | auto __it = find(__x); | 516 | auto __it = find(__x); |
| 514 | if (__it == end()) { | 517 | if (__it == end()) { |
| 515 | std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist"); | 518 | std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist"); |
| ... | @@ -589,6 +592,15 @@ public: | ... | @@ -589,6 +592,15 @@ public: |
| 589 | __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); | 592 | __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); |
| 590 | } | 593 | } |
| 591 | 594 | ||
| 595 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 596 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(sorted_unique_t, _Range&& __range) { | ||
| 597 | if constexpr (ranges::sized_range<_Range>) { | ||
| 598 | __reserve(ranges::size(__range)); | ||
| 599 | } | ||
| 600 | |||
| 601 | __append_sort_merge_unique</*WasSorted = */ true>(ranges::begin(__range), ranges::end(__range)); | ||
| 602 | } | ||
| 603 | |||
| 592 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { | 604 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { |
| 593 | insert(__il.begin(), __il.end()); | 605 | insert(__il.begin(), __il.end()); |
| 594 | } | 606 | } |
| ... | @@ -597,7 +609,7 @@ public: | ... | @@ -597,7 +609,7 @@ public: |
| 597 | insert(sorted_unique, __il.begin(), __il.end()); | 609 | insert(sorted_unique, __il.begin(), __il.end()); |
| 598 | } | 610 | } |
| 599 | 611 | ||
| 600 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 containers extract() && { | 612 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 containers extract() && { |
| 601 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | 613 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); |
| 602 | auto __ret = std::move(__containers_); | 614 | auto __ret = std::move(__containers_); |
| 603 | return __ret; | 615 | return __ret; |
| ... | @@ -738,14 +750,17 @@ public: | ... | @@ -738,14 +750,17 @@ public: |
| 738 | return iterator(std::move(__key_it), std::move(__mapped_it)); | 750 | return iterator(std::move(__key_it), std::move(__mapped_it)); |
| 739 | } | 751 | } |
| 740 | 752 | ||
| 741 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_map& __y) noexcept { | 753 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 742 | // warning: The spec has unconditional noexcept, which means that | 754 | swap(flat_map& __y) noexcept(is_nothrow_swappable_v<key_container_type> && |
| 743 | // if any of the following functions throw an exception, | 755 | is_nothrow_swappable_v<mapped_container_type> && is_nothrow_swappable_v<key_compare>) { |
| 744 | // std::terminate will be called. | 756 | auto __on_failure = std::__make_exception_guard([&]() noexcept { |
| 745 | // This is discussed in P2767, which hasn't been voted on yet. | 757 | clear() /* noexcept */; |
| 758 | __y.clear() /* noexcept */; | ||
| 759 | }); | ||
| 746 | ranges::swap(__compare_, __y.__compare_); | 760 | ranges::swap(__compare_, __y.__compare_); |
| 747 | ranges::swap(__containers_.keys, __y.__containers_.keys); | 761 | ranges::swap(__containers_.keys, __y.__containers_.keys); |
| 748 | ranges::swap(__containers_.values, __y.__containers_.values); | 762 | ranges::swap(__containers_.values, __y.__containers_.values); |
| 763 | __on_failure.__complete(); | ||
| 749 | } | 764 | } |
| 750 | 765 | ||
| 751 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { | 766 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { |
| ... | @@ -754,116 +769,121 @@ public: | ... | @@ -754,116 +769,121 @@ public: |
| 754 | } | 769 | } |
| 755 | 770 | ||
| 756 | // observers | 771 | // observers |
| 757 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } | 772 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } |
| 758 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { | 773 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { |
| 759 | return value_compare(__compare_); | 774 | return value_compare(__compare_); |
| 760 | } | 775 | } |
| 761 | 776 | ||
| 762 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const key_container_type& keys() const noexcept { | 777 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const key_container_type& keys() const noexcept { |
| 763 | return __containers_.keys; | 778 | return __containers_.keys; |
| 764 | } | 779 | } |
| 765 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_container_type& values() const noexcept { | 780 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_container_type& |
| 781 | values() const noexcept { | ||
| 766 | return __containers_.values; | 782 | return __containers_.values; |
| 767 | } | 783 | } |
| 768 | 784 | ||
| 769 | // map operations | 785 | // map operations |
| 770 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { | 786 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { |
| 771 | return __find_impl(*this, __x); | 787 | return __find_impl(*this, __x); |
| 772 | } | 788 | } |
| 773 | 789 | ||
| 774 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { | 790 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { |
| 775 | return __find_impl(*this, __x); | 791 | return __find_impl(*this, __x); |
| 776 | } | 792 | } |
| 777 | 793 | ||
| 778 | template <class _Kp> | 794 | template <class _Kp> |
| 779 | requires __is_compare_transparent | 795 | requires __is_compare_transparent |
| 780 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { | 796 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { |
| 781 | return __find_impl(*this, __x); | 797 | return __find_impl(*this, __x); |
| 782 | } | 798 | } |
| 783 | 799 | ||
| 784 | template <class _Kp> | 800 | template <class _Kp> |
| 785 | requires __is_compare_transparent | 801 | requires __is_compare_transparent |
| 786 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { | 802 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { |
| 787 | return __find_impl(*this, __x); | 803 | return __find_impl(*this, __x); |
| 788 | } | 804 | } |
| 789 | 805 | ||
| 790 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { | 806 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { |
| 791 | return contains(__x) ? 1 : 0; | 807 | return contains(__x) ? 1 : 0; |
| 792 | } | 808 | } |
| 793 | 809 | ||
| 794 | template <class _Kp> | 810 | template <class _Kp> |
| 795 | requires __is_compare_transparent | 811 | requires __is_compare_transparent |
| 796 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { | 812 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { |
| 797 | return contains(__x) ? 1 : 0; | 813 | return contains(__x) ? 1 : 0; |
| 798 | } | 814 | } |
| 799 | 815 | ||
| 800 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { | 816 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { |
| 801 | return find(__x) != end(); | 817 | return find(__x) != end(); |
| 802 | } | 818 | } |
| 803 | 819 | ||
| 804 | template <class _Kp> | 820 | template <class _Kp> |
| 805 | requires __is_compare_transparent | 821 | requires __is_compare_transparent |
| 806 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { | 822 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { |
| 807 | return find(__x) != end(); | 823 | return find(__x) != end(); |
| 808 | } | 824 | } |
| 809 | 825 | ||
| 810 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { | 826 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { |
| 811 | return __lower_bound<iterator>(*this, __x); | 827 | return __lower_bound<iterator>(*this, __x); |
| 812 | } | 828 | } |
| 813 | 829 | ||
| 814 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __x) const { | 830 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 831 | lower_bound(const key_type& __x) const { | ||
| 815 | return __lower_bound<const_iterator>(*this, __x); | 832 | return __lower_bound<const_iterator>(*this, __x); |
| 816 | } | 833 | } |
| 817 | 834 | ||
| 818 | template <class _Kp> | 835 | template <class _Kp> |
| 819 | requires __is_compare_transparent | 836 | requires __is_compare_transparent |
| 820 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { | 837 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { |
| 821 | return __lower_bound<iterator>(*this, __x); | 838 | return __lower_bound<iterator>(*this, __x); |
| 822 | } | 839 | } |
| 823 | 840 | ||
| 824 | template <class _Kp> | 841 | template <class _Kp> |
| 825 | requires __is_compare_transparent | 842 | requires __is_compare_transparent |
| 826 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { | 843 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { |
| 827 | return __lower_bound<const_iterator>(*this, __x); | 844 | return __lower_bound<const_iterator>(*this, __x); |
| 828 | } | 845 | } |
| 829 | 846 | ||
| 830 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { | 847 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { |
| 831 | return __upper_bound<iterator>(*this, __x); | 848 | return __upper_bound<iterator>(*this, __x); |
| 832 | } | 849 | } |
| 833 | 850 | ||
| 834 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __x) const { | 851 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 852 | upper_bound(const key_type& __x) const { | ||
| 835 | return __upper_bound<const_iterator>(*this, __x); | 853 | return __upper_bound<const_iterator>(*this, __x); |
| 836 | } | 854 | } |
| 837 | 855 | ||
| 838 | template <class _Kp> | 856 | template <class _Kp> |
| 839 | requires __is_compare_transparent | 857 | requires __is_compare_transparent |
| 840 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { | 858 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { |
| 841 | return __upper_bound<iterator>(*this, __x); | 859 | return __upper_bound<iterator>(*this, __x); |
| 842 | } | 860 | } |
| 843 | 861 | ||
| 844 | template <class _Kp> | 862 | template <class _Kp> |
| 845 | requires __is_compare_transparent | 863 | requires __is_compare_transparent |
| 846 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { | 864 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { |
| 847 | return __upper_bound<const_iterator>(*this, __x); | 865 | return __upper_bound<const_iterator>(*this, __x); |
| 848 | } | 866 | } |
| 849 | 867 | ||
| 850 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __x) { | 868 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 869 | equal_range(const key_type& __x) { | ||
| 851 | return __equal_range_impl(*this, __x); | 870 | return __equal_range_impl(*this, __x); |
| 852 | } | 871 | } |
| 853 | 872 | ||
| 854 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> | 873 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 855 | equal_range(const key_type& __x) const { | 874 | equal_range(const key_type& __x) const { |
| 856 | return __equal_range_impl(*this, __x); | 875 | return __equal_range_impl(*this, __x); |
| 857 | } | 876 | } |
| 858 | 877 | ||
| 859 | template <class _Kp> | 878 | template <class _Kp> |
| 860 | requires __is_compare_transparent | 879 | requires __is_compare_transparent |
| 861 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _Kp& __x) { | 880 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 881 | equal_range(const _Kp& __x) { | ||
| 862 | return __equal_range_impl(*this, __x); | 882 | return __equal_range_impl(*this, __x); |
| 863 | } | 883 | } |
| 864 | template <class _Kp> | 884 | template <class _Kp> |
| 865 | requires __is_compare_transparent | 885 | requires __is_compare_transparent |
| 866 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> | 886 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 867 | equal_range(const _Kp& __x) const { | 887 | equal_range(const _Kp& __x) const { |
| 868 | return __equal_range_impl(*this, __x); | 888 | return __equal_range_impl(*this, __x); |
| 869 | } | 889 | } |
| ... | @@ -878,7 +898,8 @@ public: | ... | @@ -878,7 +898,8 @@ public: |
| 878 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 898 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 879 | } | 899 | } |
| 880 | 900 | ||
| 881 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_map& __x, flat_map& __y) noexcept { | 901 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 902 | swap(flat_map& __x, flat_map& __y) noexcept(noexcept(__x.swap(__y))) { | ||
| 882 | __x.swap(__y); | 903 | __x.swap(__y); |
| 883 | } | 904 | } |
| 884 | 905 | ||
| ... | @@ -913,7 +934,7 @@ private: | ... | @@ -913,7 +934,7 @@ private: |
| 913 | __compare_(std::forward<_CompArg>(__comp)...) {} | 934 | __compare_(std::forward<_CompArg>(__comp)...) {} |
| 914 | 935 | ||
| 915 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const { | 936 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const { |
| 916 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); }; | 937 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) -> bool { return !__compare_(__x, __y); }; |
| 917 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); | 938 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); |
| 918 | } | 939 | } |
| 919 | 940 | ||
| ... | @@ -946,7 +967,7 @@ private: | ... | @@ -946,7 +967,7 @@ private: |
| 946 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | 967 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); |
| 947 | auto __append_start_offset = __containers_.keys.size() - __num_of_appended; | 968 | auto __append_start_offset = __containers_.keys.size() - __num_of_appended; |
| 948 | auto __end = __zv.end(); | 969 | auto __end = __zv.end(); |
| 949 | auto __compare_key = [this](const auto& __p1, const auto& __p2) { | 970 | auto __compare_key = [this](const auto& __p1, const auto& __p2) -> bool { |
| 950 | return __compare_(std::get<0>(__p1), std::get<0>(__p2)); | 971 | return __compare_(std::get<0>(__p1), std::get<0>(__p2)); |
| 951 | }; | 972 | }; |
| 952 | if constexpr (!_WasSorted) { | 973 | if constexpr (!_WasSorted) { |
| ... | @@ -1125,8 +1146,7 @@ private: | ... | @@ -1125,8 +1146,7 @@ private: |
| 1125 | }; | 1146 | }; |
| 1126 | 1147 | ||
| 1127 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | 1148 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 1128 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 1149 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 1129 | !__is_allocator<_MappedContainer>::value && | ||
| 1130 | is_invocable_v<const _Compare&, | 1150 | is_invocable_v<const _Compare&, |
| 1131 | const typename _KeyContainer::value_type&, | 1151 | const typename _KeyContainer::value_type&, |
| 1132 | const typename _KeyContainer::value_type&>) | 1152 | const typename _KeyContainer::value_type&>) |
| ... | @@ -1139,7 +1159,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare = _Compare()) | ... | @@ -1139,7 +1159,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare = _Compare()) |
| 1139 | 1159 | ||
| 1140 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | 1160 | template <class _KeyContainer, class _MappedContainer, class _Allocator> |
| 1141 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | 1161 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 1142 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | 1162 | !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>) |
| 1143 | flat_map(_KeyContainer, _MappedContainer, _Allocator) | 1163 | flat_map(_KeyContainer, _MappedContainer, _Allocator) |
| 1144 | -> flat_map<typename _KeyContainer::value_type, | 1164 | -> flat_map<typename _KeyContainer::value_type, |
| 1145 | typename _MappedContainer::value_type, | 1165 | typename _MappedContainer::value_type, |
| ... | @@ -1148,9 +1168,8 @@ flat_map(_KeyContainer, _MappedContainer, _Allocator) | ... | @@ -1148,9 +1168,8 @@ flat_map(_KeyContainer, _MappedContainer, _Allocator) |
| 1148 | _MappedContainer>; | 1168 | _MappedContainer>; |
| 1149 | 1169 | ||
| 1150 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | 1170 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> |
| 1151 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 1171 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 1152 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | 1172 | uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 1153 | uses_allocator_v<_MappedContainer, _Allocator> && | ||
| 1154 | is_invocable_v<const _Compare&, | 1173 | is_invocable_v<const _Compare&, |
| 1155 | const typename _KeyContainer::value_type&, | 1174 | const typename _KeyContainer::value_type&, |
| 1156 | const typename _KeyContainer::value_type&>) | 1175 | const typename _KeyContainer::value_type&>) |
| ... | @@ -1162,8 +1181,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare, _Allocator) | ... | @@ -1162,8 +1181,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare, _Allocator) |
| 1162 | _MappedContainer>; | 1181 | _MappedContainer>; |
| 1163 | 1182 | ||
| 1164 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | 1183 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 1165 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 1184 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 1166 | !__is_allocator<_MappedContainer>::value && | ||
| 1167 | is_invocable_v<const _Compare&, | 1185 | is_invocable_v<const _Compare&, |
| 1168 | const typename _KeyContainer::value_type&, | 1186 | const typename _KeyContainer::value_type&, |
| 1169 | const typename _KeyContainer::value_type&>) | 1187 | const typename _KeyContainer::value_type&>) |
| ... | @@ -1176,7 +1194,7 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare = _Compare() | ... | @@ -1176,7 +1194,7 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare = _Compare() |
| 1176 | 1194 | ||
| 1177 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | 1195 | template <class _KeyContainer, class _MappedContainer, class _Allocator> |
| 1178 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | 1196 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 1179 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | 1197 | !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>) |
| 1180 | flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator) | 1198 | flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator) |
| 1181 | -> flat_map<typename _KeyContainer::value_type, | 1199 | -> flat_map<typename _KeyContainer::value_type, |
| 1182 | typename _MappedContainer::value_type, | 1200 | typename _MappedContainer::value_type, |
| ... | @@ -1185,9 +1203,8 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator) | ... | @@ -1185,9 +1203,8 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator) |
| 1185 | _MappedContainer>; | 1203 | _MappedContainer>; |
| 1186 | 1204 | ||
| 1187 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | 1205 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> |
| 1188 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 1206 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 1189 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | 1207 | uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 1190 | uses_allocator_v<_MappedContainer, _Allocator> && | ||
| 1191 | is_invocable_v<const _Compare&, | 1208 | is_invocable_v<const _Compare&, |
| 1192 | const typename _KeyContainer::value_type&, | 1209 | const typename _KeyContainer::value_type&, |
| 1193 | const typename _KeyContainer::value_type&>) | 1210 | const typename _KeyContainer::value_type&>) |
| ... | @@ -1199,19 +1216,19 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare, _Allocator) | ... | @@ -1199,19 +1216,19 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare, _Allocator) |
| 1199 | _MappedContainer>; | 1216 | _MappedContainer>; |
| 1200 | 1217 | ||
| 1201 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | 1218 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> |
| 1202 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 1219 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 1203 | flat_map(_InputIterator, _InputIterator, _Compare = _Compare()) | 1220 | flat_map(_InputIterator, _InputIterator, _Compare = _Compare()) |
| 1204 | -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | 1221 | -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; |
| 1205 | 1222 | ||
| 1206 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | 1223 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> |
| 1207 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 1224 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 1208 | flat_map(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare()) | 1225 | flat_map(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare()) |
| 1209 | -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | 1226 | -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; |
| 1210 | 1227 | ||
| 1211 | template <ranges::input_range _Range, | 1228 | template <ranges::input_range _Range, |
| 1212 | class _Compare = less<__range_key_type<_Range>>, | 1229 | class _Compare = less<__range_key_type<_Range>>, |
| 1213 | class _Allocator = allocator<byte>, | 1230 | class _Allocator = allocator<byte>, |
| 1214 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | 1231 | class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>> |
| 1215 | flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_map< | 1232 | flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_map< |
| 1216 | __range_key_type<_Range>, | 1233 | __range_key_type<_Range>, |
| 1217 | __range_mapped_type<_Range>, | 1234 | __range_mapped_type<_Range>, |
| ... | @@ -1219,7 +1236,7 @@ flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator( | ... | @@ -1219,7 +1236,7 @@ flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator( |
| 1219 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, | 1236 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, |
| 1220 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | 1237 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; |
| 1221 | 1238 | ||
| 1222 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | 1239 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>> |
| 1223 | flat_map(from_range_t, _Range&&, _Allocator) -> flat_map< | 1240 | flat_map(from_range_t, _Range&&, _Allocator) -> flat_map< |
| 1224 | __range_key_type<_Range>, | 1241 | __range_key_type<_Range>, |
| 1225 | __range_mapped_type<_Range>, | 1242 | __range_mapped_type<_Range>, |
| ... | @@ -1228,11 +1245,11 @@ flat_map(from_range_t, _Range&&, _Allocator) -> flat_map< | ... | @@ -1228,11 +1245,11 @@ flat_map(from_range_t, _Range&&, _Allocator) -> flat_map< |
| 1228 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | 1245 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; |
| 1229 | 1246 | ||
| 1230 | template <class _Key, class _Tp, class _Compare = less<_Key>> | 1247 | template <class _Key, class _Tp, class _Compare = less<_Key>> |
| 1231 | requires(!__is_allocator<_Compare>::value) | 1248 | requires(!__is_allocator_v<_Compare>) |
| 1232 | flat_map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>; | 1249 | flat_map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>; |
| 1233 | 1250 | ||
| 1234 | template <class _Key, class _Tp, class _Compare = less<_Key>> | 1251 | template <class _Key, class _Tp, class _Compare = less<_Key>> |
| 1235 | requires(!__is_allocator<_Compare>::value) | 1252 | requires(!__is_allocator_v<_Compare>) |
| 1236 | flat_map(sorted_unique_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>; | 1253 | flat_map(sorted_unique_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>; |
| 1237 | 1254 | ||
| 1238 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator> | 1255 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator> |
lib/libcxx/include/__flat_map/flat_multimap.h+251-172| ... | @@ -22,7 +22,6 @@ | ... | @@ -22,7 +22,6 @@ |
| 22 | #include <__algorithm/upper_bound.h> | 22 | #include <__algorithm/upper_bound.h> |
| 23 | #include <__assert> | 23 | #include <__assert> |
| 24 | #include <__compare/synth_three_way.h> | 24 | #include <__compare/synth_three_way.h> |
| 25 | #include <__concepts/convertible_to.h> | ||
| 26 | #include <__concepts/swappable.h> | 25 | #include <__concepts/swappable.h> |
| 27 | #include <__config> | 26 | #include <__config> |
| 28 | #include <__cstddef/byte.h> | 27 | #include <__cstddef/byte.h> |
| ... | @@ -30,7 +29,6 @@ | ... | @@ -30,7 +29,6 @@ |
| 30 | #include <__flat_map/key_value_iterator.h> | 29 | #include <__flat_map/key_value_iterator.h> |
| 31 | #include <__flat_map/sorted_equivalent.h> | 30 | #include <__flat_map/sorted_equivalent.h> |
| 32 | #include <__flat_map/utils.h> | 31 | #include <__flat_map/utils.h> |
| 33 | #include <__functional/invoke.h> | ||
| 34 | #include <__functional/is_transparent.h> | 32 | #include <__functional/is_transparent.h> |
| 35 | #include <__functional/operations.h> | 33 | #include <__functional/operations.h> |
| 36 | #include <__fwd/vector.h> | 34 | #include <__fwd/vector.h> |
| ... | @@ -47,7 +45,7 @@ | ... | @@ -47,7 +45,7 @@ |
| 47 | #include <__ranges/container_compatible_range.h> | 45 | #include <__ranges/container_compatible_range.h> |
| 48 | #include <__ranges/drop_view.h> | 46 | #include <__ranges/drop_view.h> |
| 49 | #include <__ranges/from_range.h> | 47 | #include <__ranges/from_range.h> |
| 50 | #include <__ranges/ref_view.h> | 48 | #include <__ranges/range_adaptor.h> |
| 51 | #include <__ranges/size.h> | 49 | #include <__ranges/size.h> |
| 52 | #include <__ranges/subrange.h> | 50 | #include <__ranges/subrange.h> |
| 53 | #include <__ranges/zip_view.h> | 51 | #include <__ranges/zip_view.h> |
| ... | @@ -57,14 +55,12 @@ | ... | @@ -57,14 +55,12 @@ |
| 57 | #include <__type_traits/is_allocator.h> | 55 | #include <__type_traits/is_allocator.h> |
| 58 | #include <__type_traits/is_nothrow_constructible.h> | 56 | #include <__type_traits/is_nothrow_constructible.h> |
| 59 | #include <__type_traits/is_same.h> | 57 | #include <__type_traits/is_same.h> |
| 60 | #include <__type_traits/maybe_const.h> | ||
| 61 | #include <__utility/exception_guard.h> | 58 | #include <__utility/exception_guard.h> |
| 62 | #include <__utility/move.h> | 59 | #include <__utility/move.h> |
| 63 | #include <__utility/pair.h> | 60 | #include <__utility/pair.h> |
| 64 | #include <__utility/scope_guard.h> | 61 | #include <__utility/scope_guard.h> |
| 65 | #include <__vector/vector.h> | 62 | #include <__vector/vector.h> |
| 66 | #include <initializer_list> | 63 | #include <initializer_list> |
| 67 | #include <stdexcept> | ||
| 68 | 64 | ||
| 69 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 65 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 70 | # pragma GCC system_header | 66 | # pragma GCC system_header |
| ... | @@ -114,11 +110,12 @@ public: | ... | @@ -114,11 +110,12 @@ public: |
| 114 | class value_compare { | 110 | class value_compare { |
| 115 | private: | 111 | private: |
| 116 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_; | 112 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_; |
| 117 | _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {} | 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare(key_compare __c) : __comp_(__c) {} |
| 118 | friend flat_multimap; | 114 | friend flat_multimap; |
| 119 | 115 | ||
| 120 | public: | 116 | public: |
| 121 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool |
| 118 | operator()(const_reference __x, const_reference __y) const { | ||
| 122 | return __comp_(__x.first, __y.first); | 119 | return __comp_(__x.first, __y.first); |
| 123 | } | 120 | } |
| 124 | }; | 121 | }; |
| ... | @@ -137,17 +134,17 @@ private: | ... | @@ -137,17 +134,17 @@ private: |
| 137 | 134 | ||
| 138 | public: | 135 | public: |
| 139 | // [flat.map.cons], construct/copy/destroy | 136 | // [flat.map.cons], construct/copy/destroy |
| 140 | _LIBCPP_HIDE_FROM_ABI flat_multimap() noexcept( | 137 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap() noexcept( |
| 141 | is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> && | 138 | is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> && |
| 142 | is_nothrow_default_constructible_v<_Compare>) | 139 | is_nothrow_default_constructible_v<_Compare>) |
| 143 | : __containers_(), __compare_() {} | 140 | : __containers_(), __compare_() {} |
| 144 | 141 | ||
| 145 | _LIBCPP_HIDE_FROM_ABI flat_multimap(const flat_multimap&) = default; | 142 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap(const flat_multimap&) = default; |
| 146 | 143 | ||
| 147 | // The copy/move constructors are not specified in the spec, which means they should be defaulted. | 144 | // The copy/move constructors are not specified in the spec, which means they should be defaulted. |
| 148 | // However, the move constructor can potentially leave a moved-from object in an inconsistent | 145 | // However, the move constructor can potentially leave a moved-from object in an inconsistent |
| 149 | // state if an exception is thrown. | 146 | // state if an exception is thrown. |
| 150 | _LIBCPP_HIDE_FROM_ABI flat_multimap(flat_multimap&& __other) noexcept( | 147 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap(flat_multimap&& __other) noexcept( |
| 151 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> && | 148 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> && |
| 152 | is_nothrow_move_constructible_v<_Compare>) | 149 | is_nothrow_move_constructible_v<_Compare>) |
| 153 | # if _LIBCPP_HAS_EXCEPTIONS | 150 | # if _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -168,7 +165,8 @@ public: | ... | @@ -168,7 +165,8 @@ public: |
| 168 | 165 | ||
| 169 | template <class _Allocator> | 166 | template <class _Allocator> |
| 170 | requires __allocator_ctor_constraint<_Allocator> | 167 | requires __allocator_ctor_constraint<_Allocator> |
| 171 | _LIBCPP_HIDE_FROM_ABI flat_multimap(const flat_multimap& __other, const _Allocator& __alloc) | 168 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 169 | flat_multimap(const flat_multimap& __other, const _Allocator& __alloc) | ||
| 172 | : flat_multimap(__ctor_uses_allocator_tag{}, | 170 | : flat_multimap(__ctor_uses_allocator_tag{}, |
| 173 | __alloc, | 171 | __alloc, |
| 174 | __other.__containers_.keys, | 172 | __other.__containers_.keys, |
| ... | @@ -177,7 +175,7 @@ public: | ... | @@ -177,7 +175,7 @@ public: |
| 177 | 175 | ||
| 178 | template <class _Allocator> | 176 | template <class _Allocator> |
| 179 | requires __allocator_ctor_constraint<_Allocator> | 177 | requires __allocator_ctor_constraint<_Allocator> |
| 180 | _LIBCPP_HIDE_FROM_ABI flat_multimap(flat_multimap&& __other, const _Allocator& __alloc) | 178 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap(flat_multimap&& __other, const _Allocator& __alloc) |
| 181 | # if _LIBCPP_HAS_EXCEPTIONS | 179 | # if _LIBCPP_HAS_EXCEPTIONS |
| 182 | try | 180 | try |
| 183 | # endif // _LIBCPP_HAS_EXCEPTIONS | 181 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -194,7 +192,7 @@ public: | ... | @@ -194,7 +192,7 @@ public: |
| 194 | # endif // _LIBCPP_HAS_EXCEPTIONS | 192 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 195 | } | 193 | } |
| 196 | 194 | ||
| 197 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | 195 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 198 | key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare()) | 196 | key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare()) |
| 199 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { | 197 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { |
| 200 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 198 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| ... | @@ -204,7 +202,7 @@ public: | ... | @@ -204,7 +202,7 @@ public: |
| 204 | 202 | ||
| 205 | template <class _Allocator> | 203 | template <class _Allocator> |
| 206 | requires __allocator_ctor_constraint<_Allocator> | 204 | requires __allocator_ctor_constraint<_Allocator> |
| 207 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | 205 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 208 | const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc) | 206 | const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc) |
| 209 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { | 207 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { |
| 210 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 208 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| ... | @@ -214,22 +212,22 @@ public: | ... | @@ -214,22 +212,22 @@ public: |
| 214 | 212 | ||
| 215 | template <class _Allocator> | 213 | template <class _Allocator> |
| 216 | requires __allocator_ctor_constraint<_Allocator> | 214 | requires __allocator_ctor_constraint<_Allocator> |
| 217 | _LIBCPP_HIDE_FROM_ABI | 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 218 | flat_multimap(const key_container_type& __key_cont, | 216 | const key_container_type& __key_cont, |
| 219 | const mapped_container_type& __mapped_cont, | 217 | const mapped_container_type& __mapped_cont, |
| 220 | const key_compare& __comp, | 218 | const key_compare& __comp, |
| 221 | const _Allocator& __alloc) | 219 | const _Allocator& __alloc) |
| 222 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { | 220 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { |
| 223 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 221 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| 224 | "flat_multimap keys and mapped containers have different size"); | 222 | "flat_multimap keys and mapped containers have different size"); |
| 225 | __sort(); | 223 | __sort(); |
| 226 | } | 224 | } |
| 227 | 225 | ||
| 228 | _LIBCPP_HIDE_FROM_ABI | 226 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 229 | flat_multimap(sorted_equivalent_t, | 227 | sorted_equivalent_t, |
| 230 | key_container_type __key_cont, | 228 | key_container_type __key_cont, |
| 231 | mapped_container_type __mapped_cont, | 229 | mapped_container_type __mapped_cont, |
| 232 | const key_compare& __comp = key_compare()) | 230 | const key_compare& __comp = key_compare()) |
| 233 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { | 231 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { |
| 234 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 232 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| 235 | "flat_multimap keys and mapped containers have different size"); | 233 | "flat_multimap keys and mapped containers have different size"); |
| ... | @@ -238,11 +236,11 @@ public: | ... | @@ -238,11 +236,11 @@ public: |
| 238 | 236 | ||
| 239 | template <class _Allocator> | 237 | template <class _Allocator> |
| 240 | requires __allocator_ctor_constraint<_Allocator> | 238 | requires __allocator_ctor_constraint<_Allocator> |
| 241 | _LIBCPP_HIDE_FROM_ABI | 239 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 242 | flat_multimap(sorted_equivalent_t, | 240 | sorted_equivalent_t, |
| 243 | const key_container_type& __key_cont, | 241 | const key_container_type& __key_cont, |
| 244 | const mapped_container_type& __mapped_cont, | 242 | const mapped_container_type& __mapped_cont, |
| 245 | const _Allocator& __alloc) | 243 | const _Allocator& __alloc) |
| 246 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { | 244 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { |
| 247 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 245 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| 248 | "flat_multimap keys and mapped containers have different size"); | 246 | "flat_multimap keys and mapped containers have different size"); |
| ... | @@ -251,33 +249,35 @@ public: | ... | @@ -251,33 +249,35 @@ public: |
| 251 | 249 | ||
| 252 | template <class _Allocator> | 250 | template <class _Allocator> |
| 253 | requires __allocator_ctor_constraint<_Allocator> | 251 | requires __allocator_ctor_constraint<_Allocator> |
| 254 | _LIBCPP_HIDE_FROM_ABI | 252 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 255 | flat_multimap(sorted_equivalent_t, | 253 | sorted_equivalent_t, |
| 256 | const key_container_type& __key_cont, | 254 | const key_container_type& __key_cont, |
| 257 | const mapped_container_type& __mapped_cont, | 255 | const mapped_container_type& __mapped_cont, |
| 258 | const key_compare& __comp, | 256 | const key_compare& __comp, |
| 259 | const _Allocator& __alloc) | 257 | const _Allocator& __alloc) |
| 260 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { | 258 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { |
| 261 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 259 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| 262 | "flat_multimap keys and mapped containers have different size"); | 260 | "flat_multimap keys and mapped containers have different size"); |
| 263 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted"); | 261 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted"); |
| 264 | } | 262 | } |
| 265 | 263 | ||
| 266 | _LIBCPP_HIDE_FROM_ABI explicit flat_multimap(const key_compare& __comp) : __containers_(), __compare_(__comp) {} | 264 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_multimap(const key_compare& __comp) |
| 265 | : __containers_(), __compare_(__comp) {} | ||
| 267 | 266 | ||
| 268 | template <class _Allocator> | 267 | template <class _Allocator> |
| 269 | requires __allocator_ctor_constraint<_Allocator> | 268 | requires __allocator_ctor_constraint<_Allocator> |
| 270 | _LIBCPP_HIDE_FROM_ABI flat_multimap(const key_compare& __comp, const _Allocator& __alloc) | 269 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 270 | flat_multimap(const key_compare& __comp, const _Allocator& __alloc) | ||
| 271 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {} | 271 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {} |
| 272 | 272 | ||
| 273 | template <class _Allocator> | 273 | template <class _Allocator> |
| 274 | requires __allocator_ctor_constraint<_Allocator> | 274 | requires __allocator_ctor_constraint<_Allocator> |
| 275 | _LIBCPP_HIDE_FROM_ABI explicit flat_multimap(const _Allocator& __alloc) | 275 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_multimap(const _Allocator& __alloc) |
| 276 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) {} | 276 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) {} |
| 277 | 277 | ||
| 278 | template <class _InputIterator> | 278 | template <class _InputIterator> |
| 279 | requires __has_input_iterator_category<_InputIterator>::value | 279 | requires __has_input_iterator_category<_InputIterator>::value |
| 280 | _LIBCPP_HIDE_FROM_ABI | 280 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 281 | flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | 281 | flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) |
| 282 | : __containers_(), __compare_(__comp) { | 282 | : __containers_(), __compare_(__comp) { |
| 283 | insert(__first, __last); | 283 | insert(__first, __last); |
| ... | @@ -285,7 +285,7 @@ public: | ... | @@ -285,7 +285,7 @@ public: |
| 285 | 285 | ||
| 286 | template <class _InputIterator, class _Allocator> | 286 | template <class _InputIterator, class _Allocator> |
| 287 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | 287 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) |
| 288 | _LIBCPP_HIDE_FROM_ABI | 288 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 289 | flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) | 289 | flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) |
| 290 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | 290 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { |
| 291 | insert(__first, __last); | 291 | insert(__first, __last); |
| ... | @@ -293,91 +293,99 @@ public: | ... | @@ -293,91 +293,99 @@ public: |
| 293 | 293 | ||
| 294 | template <class _InputIterator, class _Allocator> | 294 | template <class _InputIterator, class _Allocator> |
| 295 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | 295 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) |
| 296 | _LIBCPP_HIDE_FROM_ABI flat_multimap(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | 296 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 297 | flat_multimap(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | ||
| 297 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { | 298 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { |
| 298 | insert(__first, __last); | 299 | insert(__first, __last); |
| 299 | } | 300 | } |
| 300 | 301 | ||
| 301 | template <_ContainerCompatibleRange<value_type> _Range> | 302 | template <_ContainerCompatibleRange<value_type> _Range> |
| 302 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t __fr, _Range&& __rg) | 303 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap(from_range_t __fr, _Range&& __rg) |
| 303 | : flat_multimap(__fr, std::forward<_Range>(__rg), key_compare()) {} | 304 | : flat_multimap(__fr, std::forward<_Range>(__rg), key_compare()) {} |
| 304 | 305 | ||
| 305 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | 306 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> |
| 306 | requires __allocator_ctor_constraint<_Allocator> | 307 | requires __allocator_ctor_constraint<_Allocator> |
| 307 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const _Allocator& __alloc) | 308 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 309 | flat_multimap(from_range_t, _Range&& __rg, const _Allocator& __alloc) | ||
| 308 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { | 310 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { |
| 309 | insert_range(std::forward<_Range>(__rg)); | 311 | insert_range(std::forward<_Range>(__rg)); |
| 310 | } | 312 | } |
| 311 | 313 | ||
| 312 | template <_ContainerCompatibleRange<value_type> _Range> | 314 | template <_ContainerCompatibleRange<value_type> _Range> |
| 313 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_multimap(__comp) { | 315 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 316 | flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp) | ||
| 317 | : flat_multimap(__comp) { | ||
| 314 | insert_range(std::forward<_Range>(__rg)); | 318 | insert_range(std::forward<_Range>(__rg)); |
| 315 | } | 319 | } |
| 316 | 320 | ||
| 317 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | 321 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> |
| 318 | requires __allocator_ctor_constraint<_Allocator> | 322 | requires __allocator_ctor_constraint<_Allocator> |
| 319 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | 323 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 324 | flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | ||
| 320 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | 325 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { |
| 321 | insert_range(std::forward<_Range>(__rg)); | 326 | insert_range(std::forward<_Range>(__rg)); |
| 322 | } | 327 | } |
| 323 | 328 | ||
| 324 | template <class _InputIterator> | 329 | template <class _InputIterator> |
| 325 | requires __has_input_iterator_category<_InputIterator>::value | 330 | requires __has_input_iterator_category<_InputIterator>::value |
| 326 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | 331 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 327 | sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | 332 | sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) |
| 328 | : __containers_(), __compare_(__comp) { | 333 | : __containers_(), __compare_(__comp) { |
| 329 | insert(sorted_equivalent, __first, __last); | 334 | insert(sorted_equivalent, __first, __last); |
| 330 | } | 335 | } |
| 331 | template <class _InputIterator, class _Allocator> | 336 | template <class _InputIterator, class _Allocator> |
| 332 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | 337 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) |
| 333 | _LIBCPP_HIDE_FROM_ABI | 338 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 334 | flat_multimap(sorted_equivalent_t, | 339 | sorted_equivalent_t, |
| 335 | _InputIterator __first, | 340 | _InputIterator __first, |
| 336 | _InputIterator __last, | 341 | _InputIterator __last, |
| 337 | const key_compare& __comp, | 342 | const key_compare& __comp, |
| 338 | const _Allocator& __alloc) | 343 | const _Allocator& __alloc) |
| 339 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | 344 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { |
| 340 | insert(sorted_equivalent, __first, __last); | 345 | insert(sorted_equivalent, __first, __last); |
| 341 | } | 346 | } |
| 342 | 347 | ||
| 343 | template <class _InputIterator, class _Allocator> | 348 | template <class _InputIterator, class _Allocator> |
| 344 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | 349 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) |
| 345 | _LIBCPP_HIDE_FROM_ABI | 350 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 346 | flat_multimap(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | 351 | flat_multimap(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) |
| 347 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { | 352 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { |
| 348 | insert(sorted_equivalent, __first, __last); | 353 | insert(sorted_equivalent, __first, __last); |
| 349 | } | 354 | } |
| 350 | 355 | ||
| 351 | _LIBCPP_HIDE_FROM_ABI flat_multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 357 | flat_multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | ||
| 352 | : flat_multimap(__il.begin(), __il.end(), __comp) {} | 358 | : flat_multimap(__il.begin(), __il.end(), __comp) {} |
| 353 | 359 | ||
| 354 | template <class _Allocator> | 360 | template <class _Allocator> |
| 355 | requires __allocator_ctor_constraint<_Allocator> | 361 | requires __allocator_ctor_constraint<_Allocator> |
| 356 | _LIBCPP_HIDE_FROM_ABI | 362 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 357 | flat_multimap(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | 363 | flat_multimap(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) |
| 358 | : flat_multimap(__il.begin(), __il.end(), __comp, __alloc) {} | 364 | : flat_multimap(__il.begin(), __il.end(), __comp, __alloc) {} |
| 359 | 365 | ||
| 360 | template <class _Allocator> | 366 | template <class _Allocator> |
| 361 | requires __allocator_ctor_constraint<_Allocator> | 367 | requires __allocator_ctor_constraint<_Allocator> |
| 362 | _LIBCPP_HIDE_FROM_ABI flat_multimap(initializer_list<value_type> __il, const _Allocator& __alloc) | 368 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 369 | flat_multimap(initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 363 | : flat_multimap(__il.begin(), __il.end(), __alloc) {} | 370 | : flat_multimap(__il.begin(), __il.end(), __alloc) {} |
| 364 | 371 | ||
| 365 | _LIBCPP_HIDE_FROM_ABI | 372 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 366 | flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 373 | flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 367 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp) {} | 374 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp) {} |
| 368 | 375 | ||
| 369 | template <class _Allocator> | 376 | template <class _Allocator> |
| 370 | requires __allocator_ctor_constraint<_Allocator> | 377 | requires __allocator_ctor_constraint<_Allocator> |
| 371 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | 378 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 372 | sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | 379 | sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) |
| 373 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {} | 380 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {} |
| 374 | 381 | ||
| 375 | template <class _Allocator> | 382 | template <class _Allocator> |
| 376 | requires __allocator_ctor_constraint<_Allocator> | 383 | requires __allocator_ctor_constraint<_Allocator> |
| 377 | _LIBCPP_HIDE_FROM_ABI flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc) | 384 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 385 | flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 378 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __alloc) {} | 386 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __alloc) {} |
| 379 | 387 | ||
| 380 | _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(initializer_list<value_type> __il) { | 388 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap& operator=(initializer_list<value_type> __il) { |
| 381 | clear(); | 389 | clear(); |
| 382 | insert(__il); | 390 | insert(__il); |
| 383 | return *this; | 391 | return *this; |
| ... | @@ -386,9 +394,9 @@ public: | ... | @@ -386,9 +394,9 @@ public: |
| 386 | // copy/move assignment are not specified in the spec (defaulted) | 394 | // copy/move assignment are not specified in the spec (defaulted) |
| 387 | // but move assignment can potentially leave moved from object in an inconsistent | 395 | // but move assignment can potentially leave moved from object in an inconsistent |
| 388 | // state if an exception is thrown | 396 | // state if an exception is thrown |
| 389 | _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(const flat_multimap&) = default; | 397 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap& operator=(const flat_multimap&) = default; |
| 390 | 398 | ||
| 391 | _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(flat_multimap&& __other) noexcept( | 399 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap& operator=(flat_multimap&& __other) noexcept( |
| 392 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> && | 400 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> && |
| 393 | is_nothrow_move_assignable_v<_Compare>) { | 401 | is_nothrow_move_assignable_v<_Compare>) { |
| 394 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); | 402 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); |
| ... | @@ -400,38 +408,58 @@ public: | ... | @@ -400,38 +408,58 @@ public: |
| 400 | } | 408 | } |
| 401 | 409 | ||
| 402 | // iterators | 410 | // iterators |
| 403 | _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { | 411 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { |
| 404 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); | 412 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); |
| 405 | } | 413 | } |
| 406 | 414 | ||
| 407 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { | 415 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { |
| 408 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); | 416 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); |
| 409 | } | 417 | } |
| 410 | 418 | ||
| 411 | _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { | 419 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { |
| 412 | return iterator(__containers_.keys.end(), __containers_.values.end()); | 420 | return iterator(__containers_.keys.end(), __containers_.values.end()); |
| 413 | } | 421 | } |
| 414 | 422 | ||
| 415 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { | 423 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { |
| 416 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); | 424 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); |
| 417 | } | 425 | } |
| 418 | 426 | ||
| 419 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } | 427 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { |
| 420 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } | 428 | return reverse_iterator(end()); |
| 421 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); } | 429 | } |
| 422 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } | 430 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { |
| 431 | return const_reverse_iterator(end()); | ||
| 432 | } | ||
| 433 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { | ||
| 434 | return reverse_iterator(begin()); | ||
| 435 | } | ||
| 436 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { | ||
| 437 | return const_reverse_iterator(begin()); | ||
| 438 | } | ||
| 423 | 439 | ||
| 424 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); } | 440 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { |
| 425 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); } | 441 | return begin(); |
| 426 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } | 442 | } |
| 427 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } | 443 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { |
| 444 | return end(); | ||
| 445 | } | ||
| 446 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { | ||
| 447 | return const_reverse_iterator(end()); | ||
| 448 | } | ||
| 449 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { | ||
| 450 | return const_reverse_iterator(begin()); | ||
| 451 | } | ||
| 428 | 452 | ||
| 429 | // [flat.map.capacity], capacity | 453 | // [flat.map.capacity], capacity |
| 430 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __containers_.keys.empty(); } | 454 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const noexcept { |
| 455 | return __containers_.keys.empty(); | ||
| 456 | } | ||
| 431 | 457 | ||
| 432 | _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __containers_.keys.size(); } | 458 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { |
| 459 | return __containers_.keys.size(); | ||
| 460 | } | ||
| 433 | 461 | ||
| 434 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { | 462 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { |
| 435 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); | 463 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); |
| 436 | } | 464 | } |
| 437 | 465 | ||
| ... | @@ -439,7 +467,7 @@ public: | ... | @@ -439,7 +467,7 @@ public: |
| 439 | template <class... _Args> | 467 | template <class... _Args> |
| 440 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> && is_move_constructible_v<key_type> && | 468 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> && is_move_constructible_v<key_type> && |
| 441 | is_move_constructible_v<mapped_type> | 469 | is_move_constructible_v<mapped_type> |
| 442 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { | 470 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace(_Args&&... __args) { |
| 443 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | 471 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); |
| 444 | auto __key_it = std::upper_bound(__containers_.keys.begin(), __containers_.keys.end(), __pair.first, __compare_); | 472 | auto __key_it = std::upper_bound(__containers_.keys.begin(), __containers_.keys.end(), __pair.first, __compare_); |
| 445 | auto __mapped_it = __corresponding_mapped_it(*this, __key_it); | 473 | auto __mapped_it = __corresponding_mapped_it(*this, __key_it); |
| ... | @@ -450,7 +478,7 @@ public: | ... | @@ -450,7 +478,7 @@ public: |
| 450 | 478 | ||
| 451 | template <class... _Args> | 479 | template <class... _Args> |
| 452 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> | 480 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> |
| 453 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) { | 481 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __hint, _Args&&... __args) { |
| 454 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | 482 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); |
| 455 | 483 | ||
| 456 | auto __prev_larger = __hint != cbegin() && __compare_(__pair.first, (__hint - 1)->first); | 484 | auto __prev_larger = __hint != cbegin() && __compare_(__pair.first, (__hint - 1)->first); |
| ... | @@ -490,33 +518,35 @@ public: | ... | @@ -490,33 +518,35 @@ public: |
| 490 | *this, __key_iter, __mapped_iter, std::move(__pair.first), std::move(__pair.second)); | 518 | *this, __key_iter, __mapped_iter, std::move(__pair.first), std::move(__pair.second)); |
| 491 | } | 519 | } |
| 492 | 520 | ||
| 493 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return emplace(__x); } | 521 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const value_type& __x) { return emplace(__x); } |
| 494 | 522 | ||
| 495 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return emplace(std::move(__x)); } | 523 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(value_type&& __x) { |
| 524 | return emplace(std::move(__x)); | ||
| 525 | } | ||
| 496 | 526 | ||
| 497 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) { | 527 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, const value_type& __x) { |
| 498 | return emplace_hint(__hint, __x); | 528 | return emplace_hint(__hint, __x); |
| 499 | } | 529 | } |
| 500 | 530 | ||
| 501 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) { | 531 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, value_type&& __x) { |
| 502 | return emplace_hint(__hint, std::move(__x)); | 532 | return emplace_hint(__hint, std::move(__x)); |
| 503 | } | 533 | } |
| 504 | 534 | ||
| 505 | template <class _PairLike> | 535 | template <class _PairLike> |
| 506 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | 536 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> |
| 507 | _LIBCPP_HIDE_FROM_ABI iterator insert(_PairLike&& __x) { | 537 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(_PairLike&& __x) { |
| 508 | return emplace(std::forward<_PairLike>(__x)); | 538 | return emplace(std::forward<_PairLike>(__x)); |
| 509 | } | 539 | } |
| 510 | 540 | ||
| 511 | template <class _PairLike> | 541 | template <class _PairLike> |
| 512 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | 542 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> |
| 513 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _PairLike&& __x) { | 543 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, _PairLike&& __x) { |
| 514 | return emplace_hint(__hint, std::forward<_PairLike>(__x)); | 544 | return emplace_hint(__hint, std::forward<_PairLike>(__x)); |
| 515 | } | 545 | } |
| 516 | 546 | ||
| 517 | template <class _InputIterator> | 547 | template <class _InputIterator> |
| 518 | requires __has_input_iterator_category<_InputIterator>::value | 548 | requires __has_input_iterator_category<_InputIterator>::value |
| 519 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { | 549 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) { |
| 520 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | 550 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { |
| 521 | __reserve(__last - __first); | 551 | __reserve(__last - __first); |
| 522 | } | 552 | } |
| ... | @@ -525,7 +555,8 @@ public: | ... | @@ -525,7 +555,8 @@ public: |
| 525 | 555 | ||
| 526 | template <class _InputIterator> | 556 | template <class _InputIterator> |
| 527 | requires __has_input_iterator_category<_InputIterator>::value | 557 | requires __has_input_iterator_category<_InputIterator>::value |
| 528 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) { | 558 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 559 | insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) { | ||
| 529 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | 560 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { |
| 530 | __reserve(__last - __first); | 561 | __reserve(__last - __first); |
| 531 | } | 562 | } |
| ... | @@ -534,7 +565,7 @@ public: | ... | @@ -534,7 +565,7 @@ public: |
| 534 | } | 565 | } |
| 535 | 566 | ||
| 536 | template <_ContainerCompatibleRange<value_type> _Range> | 567 | template <_ContainerCompatibleRange<value_type> _Range> |
| 537 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 568 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) { |
| 538 | if constexpr (ranges::sized_range<_Range>) { | 569 | if constexpr (ranges::sized_range<_Range>) { |
| 539 | __reserve(ranges::size(__range)); | 570 | __reserve(ranges::size(__range)); |
| 540 | } | 571 | } |
| ... | @@ -542,19 +573,32 @@ public: | ... | @@ -542,19 +573,32 @@ public: |
| 542 | __append_sort_merge</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); | 573 | __append_sort_merge</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); |
| 543 | } | 574 | } |
| 544 | 575 | ||
| 545 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 576 | template <_ContainerCompatibleRange<value_type> _Range> |
| 577 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(sorted_equivalent_t, _Range&& __range) { | ||
| 578 | if constexpr (ranges::sized_range<_Range>) { | ||
| 579 | __reserve(ranges::size(__range)); | ||
| 580 | } | ||
| 581 | |||
| 582 | __append_sort_merge</*WasSorted = */ true>(ranges::begin(__range), ranges::end(__range)); | ||
| 583 | } | ||
| 584 | |||
| 585 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { | ||
| 586 | insert(__il.begin(), __il.end()); | ||
| 587 | } | ||
| 546 | 588 | ||
| 547 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, initializer_list<value_type> __il) { | 589 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 590 | insert(sorted_equivalent_t, initializer_list<value_type> __il) { | ||
| 548 | insert(sorted_equivalent, __il.begin(), __il.end()); | 591 | insert(sorted_equivalent, __il.begin(), __il.end()); |
| 549 | } | 592 | } |
| 550 | 593 | ||
| 551 | _LIBCPP_HIDE_FROM_ABI containers extract() && { | 594 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 containers extract() && { |
| 552 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | 595 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); |
| 553 | auto __ret = std::move(__containers_); | 596 | auto __ret = std::move(__containers_); |
| 554 | return __ret; | 597 | return __ret; |
| 555 | } | 598 | } |
| 556 | 599 | ||
| 557 | _LIBCPP_HIDE_FROM_ABI void replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) { | 600 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 601 | replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) { | ||
| 558 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | 602 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( |
| 559 | __key_cont.size() == __mapped_cont.size(), "flat_multimap keys and mapped containers have different size"); | 603 | __key_cont.size() == __mapped_cont.size(), "flat_multimap keys and mapped containers have different size"); |
| 560 | 604 | ||
| ... | @@ -565,15 +609,15 @@ public: | ... | @@ -565,15 +609,15 @@ public: |
| 565 | __guard.__complete(); | 609 | __guard.__complete(); |
| 566 | } | 610 | } |
| 567 | 611 | ||
| 568 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) { | 612 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __position) { |
| 569 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | 613 | return __erase(__position.__key_iter_, __position.__mapped_iter_); |
| 570 | } | 614 | } |
| 571 | 615 | ||
| 572 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) { | 616 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __position) { |
| 573 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | 617 | return __erase(__position.__key_iter_, __position.__mapped_iter_); |
| 574 | } | 618 | } |
| 575 | 619 | ||
| 576 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) { | 620 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __x) { |
| 577 | auto [__first, __last] = equal_range(__x); | 621 | auto [__first, __last] = equal_range(__x); |
| 578 | auto __res = __last - __first; | 622 | auto __res = __last - __first; |
| 579 | erase(__first, __last); | 623 | erase(__first, __last); |
| ... | @@ -583,14 +627,14 @@ public: | ... | @@ -583,14 +627,14 @@ public: |
| 583 | template <class _Kp> | 627 | template <class _Kp> |
| 584 | requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> && | 628 | requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> && |
| 585 | !is_convertible_v<_Kp &&, const_iterator>) | 629 | !is_convertible_v<_Kp &&, const_iterator>) |
| 586 | _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) { | 630 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(_Kp&& __x) { |
| 587 | auto [__first, __last] = equal_range(__x); | 631 | auto [__first, __last] = equal_range(__x); |
| 588 | auto __res = __last - __first; | 632 | auto __res = __last - __first; |
| 589 | erase(__first, __last); | 633 | erase(__first, __last); |
| 590 | return __res; | 634 | return __res; |
| 591 | } | 635 | } |
| 592 | 636 | ||
| 593 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { | 637 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __first, const_iterator __last) { |
| 594 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 638 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 595 | auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_); | 639 | auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_); |
| 596 | auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_); | 640 | auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_); |
| ... | @@ -598,146 +642,178 @@ public: | ... | @@ -598,146 +642,178 @@ public: |
| 598 | return iterator(std::move(__key_it), std::move(__mapped_it)); | 642 | return iterator(std::move(__key_it), std::move(__mapped_it)); |
| 599 | } | 643 | } |
| 600 | 644 | ||
| 601 | _LIBCPP_HIDE_FROM_ABI void swap(flat_multimap& __y) noexcept { | 645 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_multimap& __y) noexcept( |
| 602 | // warning: The spec has unconditional noexcept, which means that | 646 | is_nothrow_swappable_v<key_container_type> && is_nothrow_swappable_v<mapped_container_type> && |
| 603 | // if any of the following functions throw an exception, | 647 | is_nothrow_swappable_v<key_compare>) { |
| 604 | // std::terminate will be called | 648 | auto __on_failure = std::__make_exception_guard([&]() noexcept { |
| 649 | clear() /* noexcept */; | ||
| 650 | __y.clear() /* noexcept */; | ||
| 651 | }); | ||
| 605 | ranges::swap(__compare_, __y.__compare_); | 652 | ranges::swap(__compare_, __y.__compare_); |
| 606 | ranges::swap(__containers_.keys, __y.__containers_.keys); | 653 | ranges::swap(__containers_.keys, __y.__containers_.keys); |
| 607 | ranges::swap(__containers_.values, __y.__containers_.values); | 654 | ranges::swap(__containers_.values, __y.__containers_.values); |
| 655 | __on_failure.__complete(); | ||
| 608 | } | 656 | } |
| 609 | 657 | ||
| 610 | _LIBCPP_HIDE_FROM_ABI void clear() noexcept { | 658 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { |
| 611 | __containers_.keys.clear(); | 659 | __containers_.keys.clear(); |
| 612 | __containers_.values.clear(); | 660 | __containers_.values.clear(); |
| 613 | } | 661 | } |
| 614 | 662 | ||
| 615 | // observers | 663 | // observers |
| 616 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; } | 664 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } |
| 617 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); } | 665 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { |
| 666 | return value_compare(__compare_); | ||
| 667 | } | ||
| 618 | 668 | ||
| 619 | _LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; } | 669 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const key_container_type& keys() const noexcept { |
| 620 | _LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; } | 670 | return __containers_.keys; |
| 671 | } | ||
| 672 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_container_type& | ||
| 673 | values() const noexcept { | ||
| 674 | return __containers_.values; | ||
| 675 | } | ||
| 621 | 676 | ||
| 622 | // map operations | 677 | // map operations |
| 623 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); } | 678 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { |
| 679 | return __find_impl(*this, __x); | ||
| 680 | } | ||
| 624 | 681 | ||
| 625 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); } | 682 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { |
| 683 | return __find_impl(*this, __x); | ||
| 684 | } | ||
| 626 | 685 | ||
| 627 | template <class _Kp> | 686 | template <class _Kp> |
| 628 | requires __is_compare_transparent | 687 | requires __is_compare_transparent |
| 629 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) { | 688 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { |
| 630 | return __find_impl(*this, __x); | 689 | return __find_impl(*this, __x); |
| 631 | } | 690 | } |
| 632 | 691 | ||
| 633 | template <class _Kp> | 692 | template <class _Kp> |
| 634 | requires __is_compare_transparent | 693 | requires __is_compare_transparent |
| 635 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const { | 694 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { |
| 636 | return __find_impl(*this, __x); | 695 | return __find_impl(*this, __x); |
| 637 | } | 696 | } |
| 638 | 697 | ||
| 639 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { | 698 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { |
| 640 | auto [__first, __last] = equal_range(__x); | 699 | auto [__first, __last] = equal_range(__x); |
| 641 | return __last - __first; | 700 | return __last - __first; |
| 642 | } | 701 | } |
| 643 | 702 | ||
| 644 | template <class _Kp> | 703 | template <class _Kp> |
| 645 | requires __is_compare_transparent | 704 | requires __is_compare_transparent |
| 646 | _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const { | 705 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { |
| 647 | auto [__first, __last] = equal_range(__x); | 706 | auto [__first, __last] = equal_range(__x); |
| 648 | return __last - __first; | 707 | return __last - __first; |
| 649 | } | 708 | } |
| 650 | 709 | ||
| 651 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); } | 710 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { |
| 711 | return find(__x) != end(); | ||
| 712 | } | ||
| 652 | 713 | ||
| 653 | template <class _Kp> | 714 | template <class _Kp> |
| 654 | requires __is_compare_transparent | 715 | requires __is_compare_transparent |
| 655 | _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const { | 716 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { |
| 656 | return find(__x) != end(); | 717 | return find(__x) != end(); |
| 657 | } | 718 | } |
| 658 | 719 | ||
| 659 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { return __lower_bound<iterator>(*this, __x); } | 720 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { |
| 721 | return __lower_bound<iterator>(*this, __x); | ||
| 722 | } | ||
| 660 | 723 | ||
| 661 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const { | 724 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 725 | lower_bound(const key_type& __x) const { | ||
| 662 | return __lower_bound<const_iterator>(*this, __x); | 726 | return __lower_bound<const_iterator>(*this, __x); |
| 663 | } | 727 | } |
| 664 | 728 | ||
| 665 | template <class _Kp> | 729 | template <class _Kp> |
| 666 | requires __is_compare_transparent | 730 | requires __is_compare_transparent |
| 667 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) { | 731 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { |
| 668 | return __lower_bound<iterator>(*this, __x); | 732 | return __lower_bound<iterator>(*this, __x); |
| 669 | } | 733 | } |
| 670 | 734 | ||
| 671 | template <class _Kp> | 735 | template <class _Kp> |
| 672 | requires __is_compare_transparent | 736 | requires __is_compare_transparent |
| 673 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const { | 737 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { |
| 674 | return __lower_bound<const_iterator>(*this, __x); | 738 | return __lower_bound<const_iterator>(*this, __x); |
| 675 | } | 739 | } |
| 676 | 740 | ||
| 677 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { return __upper_bound<iterator>(*this, __x); } | 741 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { |
| 742 | return __upper_bound<iterator>(*this, __x); | ||
| 743 | } | ||
| 678 | 744 | ||
| 679 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const { | 745 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 746 | upper_bound(const key_type& __x) const { | ||
| 680 | return __upper_bound<const_iterator>(*this, __x); | 747 | return __upper_bound<const_iterator>(*this, __x); |
| 681 | } | 748 | } |
| 682 | 749 | ||
| 683 | template <class _Kp> | 750 | template <class _Kp> |
| 684 | requires __is_compare_transparent | 751 | requires __is_compare_transparent |
| 685 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) { | 752 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { |
| 686 | return __upper_bound<iterator>(*this, __x); | 753 | return __upper_bound<iterator>(*this, __x); |
| 687 | } | 754 | } |
| 688 | 755 | ||
| 689 | template <class _Kp> | 756 | template <class _Kp> |
| 690 | requires __is_compare_transparent | 757 | requires __is_compare_transparent |
| 691 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const { | 758 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { |
| 692 | return __upper_bound<const_iterator>(*this, __x); | 759 | return __upper_bound<const_iterator>(*this, __x); |
| 693 | } | 760 | } |
| 694 | 761 | ||
| 695 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) { | 762 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 763 | equal_range(const key_type& __x) { | ||
| 696 | return __equal_range_impl(*this, __x); | 764 | return __equal_range_impl(*this, __x); |
| 697 | } | 765 | } |
| 698 | 766 | ||
| 699 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { | 767 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 768 | equal_range(const key_type& __x) const { | ||
| 700 | return __equal_range_impl(*this, __x); | 769 | return __equal_range_impl(*this, __x); |
| 701 | } | 770 | } |
| 702 | 771 | ||
| 703 | template <class _Kp> | 772 | template <class _Kp> |
| 704 | requires __is_compare_transparent | 773 | requires __is_compare_transparent |
| 705 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) { | 774 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 775 | equal_range(const _Kp& __x) { | ||
| 706 | return __equal_range_impl(*this, __x); | 776 | return __equal_range_impl(*this, __x); |
| 707 | } | 777 | } |
| 708 | template <class _Kp> | 778 | template <class _Kp> |
| 709 | requires __is_compare_transparent | 779 | requires __is_compare_transparent |
| 710 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const { | 780 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 781 | equal_range(const _Kp& __x) const { | ||
| 711 | return __equal_range_impl(*this, __x); | 782 | return __equal_range_impl(*this, __x); |
| 712 | } | 783 | } |
| 713 | 784 | ||
| 714 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_multimap& __x, const flat_multimap& __y) { | 785 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool |
| 786 | operator==(const flat_multimap& __x, const flat_multimap& __y) { | ||
| 715 | return ranges::equal(__x, __y); | 787 | return ranges::equal(__x, __y); |
| 716 | } | 788 | } |
| 717 | 789 | ||
| 718 | friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_multimap& __x, const flat_multimap& __y) { | 790 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto |
| 791 | operator<=>(const flat_multimap& __x, const flat_multimap& __y) { | ||
| 719 | return std::lexicographical_compare_three_way( | 792 | return std::lexicographical_compare_three_way( |
| 720 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 793 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 721 | } | 794 | } |
| 722 | 795 | ||
| 723 | friend _LIBCPP_HIDE_FROM_ABI void swap(flat_multimap& __x, flat_multimap& __y) noexcept { __x.swap(__y); } | 796 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 797 | swap(flat_multimap& __x, flat_multimap& __y) noexcept(noexcept(__x.swap(__y))) { | ||
| 798 | __x.swap(__y); | ||
| 799 | } | ||
| 724 | 800 | ||
| 725 | private: | 801 | private: |
| 726 | struct __ctor_uses_allocator_tag { | 802 | struct __ctor_uses_allocator_tag { |
| 727 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_tag() = default; | 803 | explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __ctor_uses_allocator_tag() = default; |
| 728 | }; | 804 | }; |
| 729 | struct __ctor_uses_allocator_empty_tag { | 805 | struct __ctor_uses_allocator_empty_tag { |
| 730 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_empty_tag() = default; | 806 | explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __ctor_uses_allocator_empty_tag() = default; |
| 731 | }; | 807 | }; |
| 732 | 808 | ||
| 733 | template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg> | 809 | template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg> |
| 734 | requires __allocator_ctor_constraint<_Allocator> | 810 | requires __allocator_ctor_constraint<_Allocator> |
| 735 | _LIBCPP_HIDE_FROM_ABI | 811 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multimap( |
| 736 | flat_multimap(__ctor_uses_allocator_tag, | 812 | __ctor_uses_allocator_tag, |
| 737 | const _Allocator& __alloc, | 813 | const _Allocator& __alloc, |
| 738 | _KeyCont&& __key_cont, | 814 | _KeyCont&& __key_cont, |
| 739 | _MappedCont&& __mapped_cont, | 815 | _MappedCont&& __mapped_cont, |
| 740 | _CompArg&&... __comp) | 816 | _CompArg&&... __comp) |
| 741 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>( | 817 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>( |
| 742 | __alloc, std::forward<_KeyCont>(__key_cont)), | 818 | __alloc, std::forward<_KeyCont>(__key_cont)), |
| 743 | .values = std::make_obj_using_allocator<mapped_container_type>( | 819 | .values = std::make_obj_using_allocator<mapped_container_type>( |
| ... | @@ -746,36 +822,39 @@ private: | ... | @@ -746,36 +822,39 @@ private: |
| 746 | 822 | ||
| 747 | template <class _Allocator, class... _CompArg> | 823 | template <class _Allocator, class... _CompArg> |
| 748 | requires __allocator_ctor_constraint<_Allocator> | 824 | requires __allocator_ctor_constraint<_Allocator> |
| 749 | _LIBCPP_HIDE_FROM_ABI flat_multimap(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp) | 825 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 826 | flat_multimap(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp) | ||
| 750 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc), | 827 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc), |
| 751 | .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)}, | 828 | .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)}, |
| 752 | __compare_(std::forward<_CompArg>(__comp)...) {} | 829 | __compare_(std::forward<_CompArg>(__comp)...) {} |
| 753 | 830 | ||
| 754 | _LIBCPP_HIDE_FROM_ABI bool __is_sorted(auto&& __key_container) const { | 831 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted(auto&& __key_container) const { |
| 755 | return ranges::is_sorted(__key_container, __compare_); | 832 | return ranges::is_sorted(__key_container, __compare_); |
| 756 | } | 833 | } |
| 757 | 834 | ||
| 758 | _LIBCPP_HIDE_FROM_ABI void __sort() { | 835 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __sort() { |
| 759 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | 836 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); |
| 760 | ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); }); | 837 | ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); }); |
| 761 | } | 838 | } |
| 762 | 839 | ||
| 763 | template <class _Self, class _KeyIter> | 840 | template <class _Self, class _KeyIter> |
| 764 | _LIBCPP_HIDE_FROM_ABI static auto __corresponding_mapped_it(_Self&& __self, _KeyIter&& __key_iter) { | 841 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto |
| 842 | __corresponding_mapped_it(_Self&& __self, _KeyIter&& __key_iter) { | ||
| 765 | return __self.__containers_.values.begin() + | 843 | return __self.__containers_.values.begin() + |
| 766 | static_cast<ranges::range_difference_t<mapped_container_type>>( | 844 | static_cast<ranges::range_difference_t<mapped_container_type>>( |
| 767 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); | 845 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); |
| 768 | } | 846 | } |
| 769 | 847 | ||
| 770 | template <bool _WasSorted, class _InputIterator, class _Sentinel> | 848 | template <bool _WasSorted, class _InputIterator, class _Sentinel> |
| 771 | _LIBCPP_HIDE_FROM_ABI void __append_sort_merge(_InputIterator __first, _Sentinel __last) { | 849 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 850 | __append_sort_merge(_InputIterator __first, _Sentinel __last) { | ||
| 772 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 851 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 773 | size_t __num_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last)); | 852 | size_t __num_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last)); |
| 774 | if (__num_appended != 0) { | 853 | if (__num_appended != 0) { |
| 775 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | 854 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); |
| 776 | auto __append_start_offset = __containers_.keys.size() - __num_appended; | 855 | auto __append_start_offset = __containers_.keys.size() - __num_appended; |
| 777 | auto __end = __zv.end(); | 856 | auto __end = __zv.end(); |
| 778 | auto __compare_key = [this](const auto& __p1, const auto& __p2) { | 857 | auto __compare_key = [this](const auto& __p1, const auto& __p2) -> bool { |
| 779 | return __compare_(std::get<0>(__p1), std::get<0>(__p2)); | 858 | return __compare_(std::get<0>(__p1), std::get<0>(__p2)); |
| 780 | }; | 859 | }; |
| 781 | if constexpr (!_WasSorted) { | 860 | if constexpr (!_WasSorted) { |
| ... | @@ -791,7 +870,7 @@ private: | ... | @@ -791,7 +870,7 @@ private: |
| 791 | } | 870 | } |
| 792 | 871 | ||
| 793 | template <class _Self, class _Kp> | 872 | template <class _Self, class _Kp> |
| 794 | _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) { | 873 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __find_impl(_Self&& __self, const _Kp& __key) { |
| 795 | auto __it = __self.lower_bound(__key); | 874 | auto __it = __self.lower_bound(__key); |
| 796 | auto __last = __self.end(); | 875 | auto __last = __self.end(); |
| 797 | if (__it == __last || __self.__compare_(__key, __it->first)) { | 876 | if (__it == __last || __self.__compare_(__key, __it->first)) { |
| ... | @@ -801,7 +880,7 @@ private: | ... | @@ -801,7 +880,7 @@ private: |
| 801 | } | 880 | } |
| 802 | 881 | ||
| 803 | template <class _Self, class _Kp> | 882 | template <class _Self, class _Kp> |
| 804 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | 883 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { |
| 805 | auto [__key_first, __key_last] = | 884 | auto [__key_first, __key_last] = |
| 806 | std::equal_range(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __key, __self.__compare_); | 885 | std::equal_range(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __key, __self.__compare_); |
| 807 | 886 | ||
| ... | @@ -811,7 +890,7 @@ private: | ... | @@ -811,7 +890,7 @@ private: |
| 811 | } | 890 | } |
| 812 | 891 | ||
| 813 | template <class _Res, class _Self, class _Kp> | 892 | template <class _Res, class _Self, class _Kp> |
| 814 | _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) { | 893 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static _Res __lower_bound(_Self&& __self, _Kp& __x) { |
| 815 | auto __key_iter = | 894 | auto __key_iter = |
| 816 | std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); | 895 | std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); |
| 817 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | 896 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); |
| ... | @@ -819,14 +898,14 @@ private: | ... | @@ -819,14 +898,14 @@ private: |
| 819 | } | 898 | } |
| 820 | 899 | ||
| 821 | template <class _Res, class _Self, class _Kp> | 900 | template <class _Res, class _Self, class _Kp> |
| 822 | _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) { | 901 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static _Res __upper_bound(_Self&& __self, _Kp& __x) { |
| 823 | auto __key_iter = | 902 | auto __key_iter = |
| 824 | std::upper_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); | 903 | std::upper_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); |
| 825 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | 904 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); |
| 826 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | 905 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); |
| 827 | } | 906 | } |
| 828 | 907 | ||
| 829 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { | 908 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __reserve(size_t __size) { |
| 830 | if constexpr (__container_traits<_KeyContainer>::__reservable) { | 909 | if constexpr (__container_traits<_KeyContainer>::__reservable) { |
| 831 | __containers_.keys.reserve(__size); | 910 | __containers_.keys.reserve(__size); |
| 832 | } | 911 | } |
| ... | @@ -837,7 +916,8 @@ private: | ... | @@ -837,7 +916,8 @@ private: |
| 837 | } | 916 | } |
| 838 | 917 | ||
| 839 | template <class _KIter, class _MIter> | 918 | template <class _KIter, class _MIter> |
| 840 | _LIBCPP_HIDE_FROM_ABI iterator __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) { | 919 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 920 | __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) { | ||
| 841 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 921 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 842 | auto __key_iter = __containers_.keys.erase(__key_iter_to_remove); | 922 | auto __key_iter = __containers_.keys.erase(__key_iter_to_remove); |
| 843 | auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove); | 923 | auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove); |
| ... | @@ -847,7 +927,8 @@ private: | ... | @@ -847,7 +927,8 @@ private: |
| 847 | 927 | ||
| 848 | template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate> | 928 | template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate> |
| 849 | friend typename flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type | 929 | friend typename flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type |
| 850 | erase_if(flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate); | 930 | _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 931 | erase_if(flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate); | ||
| 851 | 932 | ||
| 852 | friend __flat_map_utils; | 933 | friend __flat_map_utils; |
| 853 | 934 | ||
| ... | @@ -855,8 +936,9 @@ private: | ... | @@ -855,8 +936,9 @@ private: |
| 855 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; | 936 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; |
| 856 | 937 | ||
| 857 | struct __key_equiv { | 938 | struct __key_equiv { |
| 858 | _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {} | 939 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {} |
| 859 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | 940 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool |
| 941 | operator()(const_reference __x, const_reference __y) const { | ||
| 860 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); | 942 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); |
| 861 | } | 943 | } |
| 862 | key_compare __comp_; | 944 | key_compare __comp_; |
| ... | @@ -864,8 +946,7 @@ private: | ... | @@ -864,8 +946,7 @@ private: |
| 864 | }; | 946 | }; |
| 865 | 947 | ||
| 866 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | 948 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 867 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 949 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 868 | !__is_allocator<_MappedContainer>::value && | ||
| 869 | is_invocable_v<const _Compare&, | 950 | is_invocable_v<const _Compare&, |
| 870 | const typename _KeyContainer::value_type&, | 951 | const typename _KeyContainer::value_type&, |
| 871 | const typename _KeyContainer::value_type&>) | 952 | const typename _KeyContainer::value_type&>) |
| ... | @@ -878,7 +959,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare = _Compare()) | ... | @@ -878,7 +959,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare = _Compare()) |
| 878 | 959 | ||
| 879 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | 960 | template <class _KeyContainer, class _MappedContainer, class _Allocator> |
| 880 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | 961 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 881 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | 962 | !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>) |
| 882 | flat_multimap(_KeyContainer, _MappedContainer, _Allocator) | 963 | flat_multimap(_KeyContainer, _MappedContainer, _Allocator) |
| 883 | -> flat_multimap<typename _KeyContainer::value_type, | 964 | -> flat_multimap<typename _KeyContainer::value_type, |
| 884 | typename _MappedContainer::value_type, | 965 | typename _MappedContainer::value_type, |
| ... | @@ -887,9 +968,8 @@ flat_multimap(_KeyContainer, _MappedContainer, _Allocator) | ... | @@ -887,9 +968,8 @@ flat_multimap(_KeyContainer, _MappedContainer, _Allocator) |
| 887 | _MappedContainer>; | 968 | _MappedContainer>; |
| 888 | 969 | ||
| 889 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | 970 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> |
| 890 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 971 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 891 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | 972 | uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 892 | uses_allocator_v<_MappedContainer, _Allocator> && | ||
| 893 | is_invocable_v<const _Compare&, | 973 | is_invocable_v<const _Compare&, |
| 894 | const typename _KeyContainer::value_type&, | 974 | const typename _KeyContainer::value_type&, |
| 895 | const typename _KeyContainer::value_type&>) | 975 | const typename _KeyContainer::value_type&>) |
| ... | @@ -901,8 +981,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare, _Allocator) | ... | @@ -901,8 +981,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare, _Allocator) |
| 901 | _MappedContainer>; | 981 | _MappedContainer>; |
| 902 | 982 | ||
| 903 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | 983 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 904 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 984 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 905 | !__is_allocator<_MappedContainer>::value && | ||
| 906 | is_invocable_v<const _Compare&, | 985 | is_invocable_v<const _Compare&, |
| 907 | const typename _KeyContainer::value_type&, | 986 | const typename _KeyContainer::value_type&, |
| 908 | const typename _KeyContainer::value_type&>) | 987 | const typename _KeyContainer::value_type&>) |
| ... | @@ -915,7 +994,7 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare = _ | ... | @@ -915,7 +994,7 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare = _ |
| 915 | 994 | ||
| 916 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | 995 | template <class _KeyContainer, class _MappedContainer, class _Allocator> |
| 917 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | 996 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 918 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | 997 | !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>) |
| 919 | flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator) | 998 | flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator) |
| 920 | -> flat_multimap<typename _KeyContainer::value_type, | 999 | -> flat_multimap<typename _KeyContainer::value_type, |
| 921 | typename _MappedContainer::value_type, | 1000 | typename _MappedContainer::value_type, |
| ... | @@ -924,9 +1003,8 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator) | ... | @@ -924,9 +1003,8 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator) |
| 924 | _MappedContainer>; | 1003 | _MappedContainer>; |
| 925 | 1004 | ||
| 926 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | 1005 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> |
| 927 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 1006 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> && |
| 928 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | 1007 | uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && |
| 929 | uses_allocator_v<_MappedContainer, _Allocator> && | ||
| 930 | is_invocable_v<const _Compare&, | 1008 | is_invocable_v<const _Compare&, |
| 931 | const typename _KeyContainer::value_type&, | 1009 | const typename _KeyContainer::value_type&, |
| 932 | const typename _KeyContainer::value_type&>) | 1010 | const typename _KeyContainer::value_type&>) |
| ... | @@ -938,19 +1016,19 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare, _A | ... | @@ -938,19 +1016,19 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare, _A |
| 938 | _MappedContainer>; | 1016 | _MappedContainer>; |
| 939 | 1017 | ||
| 940 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | 1018 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> |
| 941 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 1019 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 942 | flat_multimap(_InputIterator, _InputIterator, _Compare = _Compare()) | 1020 | flat_multimap(_InputIterator, _InputIterator, _Compare = _Compare()) |
| 943 | -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | 1021 | -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; |
| 944 | 1022 | ||
| 945 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | 1023 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> |
| 946 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 1024 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 947 | flat_multimap(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare()) | 1025 | flat_multimap(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare()) |
| 948 | -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | 1026 | -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; |
| 949 | 1027 | ||
| 950 | template <ranges::input_range _Range, | 1028 | template <ranges::input_range _Range, |
| 951 | class _Compare = less<__range_key_type<_Range>>, | 1029 | class _Compare = less<__range_key_type<_Range>>, |
| 952 | class _Allocator = allocator<byte>, | 1030 | class _Allocator = allocator<byte>, |
| 953 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | 1031 | class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>> |
| 954 | flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multimap< | 1032 | flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multimap< |
| 955 | __range_key_type<_Range>, | 1033 | __range_key_type<_Range>, |
| 956 | __range_mapped_type<_Range>, | 1034 | __range_mapped_type<_Range>, |
| ... | @@ -958,7 +1036,7 @@ flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Alloc | ... | @@ -958,7 +1036,7 @@ flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Alloc |
| 958 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, | 1036 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, |
| 959 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | 1037 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; |
| 960 | 1038 | ||
| 961 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | 1039 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>> |
| 962 | flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap< | 1040 | flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap< |
| 963 | __range_key_type<_Range>, | 1041 | __range_key_type<_Range>, |
| 964 | __range_mapped_type<_Range>, | 1042 | __range_mapped_type<_Range>, |
| ... | @@ -967,11 +1045,11 @@ flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap< | ... | @@ -967,11 +1045,11 @@ flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap< |
| 967 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | 1045 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; |
| 968 | 1046 | ||
| 969 | template <class _Key, class _Tp, class _Compare = less<_Key>> | 1047 | template <class _Key, class _Tp, class _Compare = less<_Key>> |
| 970 | requires(!__is_allocator<_Compare>::value) | 1048 | requires(!__is_allocator_v<_Compare>) |
| 971 | flat_multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_multimap<_Key, _Tp, _Compare>; | 1049 | flat_multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_multimap<_Key, _Tp, _Compare>; |
| 972 | 1050 | ||
| 973 | template <class _Key, class _Tp, class _Compare = less<_Key>> | 1051 | template <class _Key, class _Tp, class _Compare = less<_Key>> |
| 974 | requires(!__is_allocator<_Compare>::value) | 1052 | requires(!__is_allocator_v<_Compare>) |
| 975 | flat_multimap(sorted_equivalent_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) | 1053 | flat_multimap(sorted_equivalent_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) |
| 976 | -> flat_multimap<_Key, _Tp, _Compare>; | 1054 | -> flat_multimap<_Key, _Tp, _Compare>; |
| 977 | 1055 | ||
| ... | @@ -980,8 +1058,9 @@ struct uses_allocator<flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedC | ... | @@ -980,8 +1058,9 @@ struct uses_allocator<flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedC |
| 980 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {}; | 1058 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {}; |
| 981 | 1059 | ||
| 982 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate> | 1060 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate> |
| 983 | _LIBCPP_HIDE_FROM_ABI typename flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type | 1061 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 984 | erase_if(flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_multimap, _Predicate __pred) { | 1062 | typename flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type |
| 1063 | erase_if(flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_multimap, _Predicate __pred) { | ||
| 985 | auto __zv = ranges::views::zip(__flat_multimap.__containers_.keys, __flat_multimap.__containers_.values); | 1064 | auto __zv = ranges::views::zip(__flat_multimap.__containers_.keys, __flat_multimap.__containers_.values); |
| 986 | auto __first = __zv.begin(); | 1065 | auto __first = __zv.begin(); |
| 987 | auto __last = __zv.end(); | 1066 | auto __last = __zv.end(); |
lib/libcxx/include/__flat_map/key_value_iterator.h-1| ... | @@ -20,7 +20,6 @@ | ... | @@ -20,7 +20,6 @@ |
| 20 | #include <__type_traits/conditional.h> | 20 | #include <__type_traits/conditional.h> |
| 21 | #include <__utility/forward.h> | 21 | #include <__utility/forward.h> |
| 22 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| 23 | #include <__utility/pair.h> | ||
| 24 | 23 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | # pragma GCC system_header | 25 | # pragma GCC system_header |
lib/libcxx/include/__flat_map/utils.h+1| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | #include <__utility/exception_guard.h> | 16 | #include <__utility/exception_guard.h> |
| 17 | #include <__utility/forward.h> | 17 | #include <__utility/forward.h> |
| 18 | #include <__utility/move.h> | 18 | #include <__utility/move.h> |
| 19 | #include <__vector/container_traits.h> | ||
| 19 | 20 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | # pragma GCC system_header | 22 | # pragma GCC system_header |
lib/libcxx/include/__flat_set/flat_multiset.h+211-143| ... | @@ -13,54 +13,41 @@ | ... | @@ -13,54 +13,41 @@ |
| 13 | #include <__algorithm/equal_range.h> | 13 | #include <__algorithm/equal_range.h> |
| 14 | #include <__algorithm/lexicographical_compare_three_way.h> | 14 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 15 | #include <__algorithm/lower_bound.h> | 15 | #include <__algorithm/lower_bound.h> |
| 16 | #include <__algorithm/min.h> | ||
| 17 | #include <__algorithm/ranges_equal.h> | 16 | #include <__algorithm/ranges_equal.h> |
| 18 | #include <__algorithm/ranges_inplace_merge.h> | 17 | #include <__algorithm/ranges_inplace_merge.h> |
| 19 | #include <__algorithm/ranges_is_sorted.h> | 18 | #include <__algorithm/ranges_is_sorted.h> |
| 20 | #include <__algorithm/ranges_sort.h> | 19 | #include <__algorithm/ranges_sort.h> |
| 21 | #include <__algorithm/ranges_unique.h> | ||
| 22 | #include <__algorithm/remove_if.h> | 20 | #include <__algorithm/remove_if.h> |
| 23 | #include <__algorithm/upper_bound.h> | 21 | #include <__algorithm/upper_bound.h> |
| 24 | #include <__assert> | 22 | #include <__assert> |
| 25 | #include <__compare/synth_three_way.h> | 23 | #include <__compare/synth_three_way.h> |
| 26 | #include <__concepts/convertible_to.h> | ||
| 27 | #include <__concepts/swappable.h> | 24 | #include <__concepts/swappable.h> |
| 28 | #include <__config> | 25 | #include <__config> |
| 29 | #include <__cstddef/byte.h> | ||
| 30 | #include <__cstddef/ptrdiff_t.h> | ||
| 31 | #include <__flat_map/key_value_iterator.h> | ||
| 32 | #include <__flat_map/sorted_equivalent.h> | 26 | #include <__flat_map/sorted_equivalent.h> |
| 33 | #include <__flat_set/ra_iterator.h> | 27 | #include <__flat_set/ra_iterator.h> |
| 34 | #include <__flat_set/utils.h> | 28 | #include <__flat_set/utils.h> |
| 35 | #include <__functional/invoke.h> | ||
| 36 | #include <__functional/is_transparent.h> | 29 | #include <__functional/is_transparent.h> |
| 37 | #include <__functional/operations.h> | 30 | #include <__functional/operations.h> |
| 38 | #include <__fwd/vector.h> | 31 | #include <__fwd/vector.h> |
| 39 | #include <__iterator/concepts.h> | 32 | #include <__iterator/concepts.h> |
| 40 | #include <__iterator/distance.h> | ||
| 41 | #include <__iterator/iterator_traits.h> | 33 | #include <__iterator/iterator_traits.h> |
| 42 | #include <__iterator/prev.h> | 34 | #include <__iterator/prev.h> |
| 43 | #include <__iterator/ranges_iterator_traits.h> | ||
| 44 | #include <__iterator/reverse_iterator.h> | 35 | #include <__iterator/reverse_iterator.h> |
| 45 | #include <__memory/allocator_traits.h> | 36 | #include <__memory/allocator_traits.h> |
| 46 | #include <__memory/uses_allocator.h> | 37 | #include <__memory/uses_allocator.h> |
| 47 | #include <__memory/uses_allocator_construction.h> | 38 | #include <__memory/uses_allocator_construction.h> |
| 48 | #include <__ranges/access.h> | ||
| 49 | #include <__ranges/concepts.h> | 39 | #include <__ranges/concepts.h> |
| 50 | #include <__ranges/container_compatible_range.h> | 40 | #include <__ranges/container_compatible_range.h> |
| 51 | #include <__ranges/drop_view.h> | 41 | #include <__ranges/drop_view.h> |
| 52 | #include <__ranges/from_range.h> | 42 | #include <__ranges/from_range.h> |
| 53 | #include <__ranges/ref_view.h> | 43 | #include <__ranges/range_adaptor.h> |
| 54 | #include <__ranges/size.h> | 44 | #include <__ranges/size.h> |
| 55 | #include <__ranges/subrange.h> | 45 | #include <__ranges/subrange.h> |
| 56 | #include <__ranges/zip_view.h> | ||
| 57 | #include <__type_traits/conjunction.h> | ||
| 58 | #include <__type_traits/container_traits.h> | 46 | #include <__type_traits/container_traits.h> |
| 59 | #include <__type_traits/invoke.h> | 47 | #include <__type_traits/invoke.h> |
| 60 | #include <__type_traits/is_allocator.h> | 48 | #include <__type_traits/is_allocator.h> |
| 61 | #include <__type_traits/is_nothrow_constructible.h> | 49 | #include <__type_traits/is_nothrow_constructible.h> |
| 62 | #include <__type_traits/is_same.h> | 50 | #include <__type_traits/is_same.h> |
| 63 | #include <__type_traits/maybe_const.h> | ||
| 64 | #include <__utility/as_const.h> | 51 | #include <__utility/as_const.h> |
| 65 | #include <__utility/exception_guard.h> | 52 | #include <__utility/exception_guard.h> |
| 66 | #include <__utility/move.h> | 53 | #include <__utility/move.h> |
| ... | @@ -108,16 +95,16 @@ public: | ... | @@ -108,16 +95,16 @@ public: |
| 108 | 95 | ||
| 109 | public: | 96 | public: |
| 110 | // [flat.multiset.cons], constructors | 97 | // [flat.multiset.cons], constructors |
| 111 | _LIBCPP_HIDE_FROM_ABI flat_multiset() noexcept(is_nothrow_default_constructible_v<_KeyContainer> && | 98 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset() noexcept( |
| 112 | is_nothrow_default_constructible_v<_Compare>) | 99 | is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_Compare>) |
| 113 | : __keys_(), __compare_() {} | 100 | : __keys_(), __compare_() {} |
| 114 | 101 | ||
| 115 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset&) = default; | 102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset(const flat_multiset&) = default; |
| 116 | 103 | ||
| 117 | // The copy/move constructors are not specified in the spec, which means they should be defaulted. | 104 | // The copy/move constructors are not specified in the spec, which means they should be defaulted. |
| 118 | // However, the move constructor can potentially leave a moved-from object in an inconsistent | 105 | // However, the move constructor can potentially leave a moved-from object in an inconsistent |
| 119 | // state if an exception is thrown. | 106 | // state if an exception is thrown. |
| 120 | _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other) noexcept( | 107 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset(flat_multiset&& __other) noexcept( |
| 121 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>) | 108 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>) |
| 122 | # if _LIBCPP_HAS_EXCEPTIONS | 109 | # if _LIBCPP_HAS_EXCEPTIONS |
| 123 | try | 110 | try |
| ... | @@ -134,14 +121,16 @@ public: | ... | @@ -134,14 +121,16 @@ public: |
| 134 | # endif // _LIBCPP_HAS_EXCEPTIONS | 121 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 135 | } | 122 | } |
| 136 | 123 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const key_compare& __comp) : __keys_(), __compare_(__comp) {} | 124 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_multiset(const key_compare& __comp) |
| 125 | : __keys_(), __compare_(__comp) {} | ||
| 138 | 126 | ||
| 139 | _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(container_type __keys, const key_compare& __comp = key_compare()) | 127 | _LIBCPP_HIDE_FROM_ABI |
| 128 | _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_multiset(container_type __keys, const key_compare& __comp = key_compare()) | ||
| 140 | : __keys_(std::move(__keys)), __compare_(__comp) { | 129 | : __keys_(std::move(__keys)), __compare_(__comp) { |
| 141 | ranges::sort(__keys_, __compare_); | 130 | ranges::sort(__keys_, __compare_); |
| 142 | } | 131 | } |
| 143 | 132 | ||
| 144 | _LIBCPP_HIDE_FROM_ABI | 133 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 145 | flat_multiset(sorted_equivalent_t, container_type __keys, const key_compare& __comp = key_compare()) | 134 | flat_multiset(sorted_equivalent_t, container_type __keys, const key_compare& __comp = key_compare()) |
| 146 | : __keys_(std::move(__keys)), __compare_(__comp) { | 135 | : __keys_(std::move(__keys)), __compare_(__comp) { |
| 147 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | 136 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); |
| ... | @@ -149,7 +138,7 @@ public: | ... | @@ -149,7 +138,7 @@ public: |
| 149 | 138 | ||
| 150 | template <class _InputIterator> | 139 | template <class _InputIterator> |
| 151 | requires __has_input_iterator_category<_InputIterator>::value | 140 | requires __has_input_iterator_category<_InputIterator>::value |
| 152 | _LIBCPP_HIDE_FROM_ABI | 141 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 153 | flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | 142 | flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) |
| 154 | : __keys_(), __compare_(__comp) { | 143 | : __keys_(), __compare_(__comp) { |
| 155 | insert(__first, __last); | 144 | insert(__first, __last); |
| ... | @@ -157,48 +146,53 @@ public: | ... | @@ -157,48 +146,53 @@ public: |
| 157 | 146 | ||
| 158 | template <class _InputIterator> | 147 | template <class _InputIterator> |
| 159 | requires __has_input_iterator_category<_InputIterator>::value | 148 | requires __has_input_iterator_category<_InputIterator>::value |
| 160 | _LIBCPP_HIDE_FROM_ABI flat_multiset( | 149 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset( |
| 161 | sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | 150 | sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) |
| 162 | : __keys_(__first, __last), __compare_(__comp) { | 151 | : __keys_(__first, __last), __compare_(__comp) { |
| 163 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | 152 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); |
| 164 | } | 153 | } |
| 165 | 154 | ||
| 166 | template <_ContainerCompatibleRange<value_type> _Range> | 155 | template <_ContainerCompatibleRange<value_type> _Range> |
| 167 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t __fr, _Range&& __rg) | 156 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset(from_range_t __fr, _Range&& __rg) |
| 168 | : flat_multiset(__fr, std::forward<_Range>(__rg), key_compare()) {} | 157 | : flat_multiset(__fr, std::forward<_Range>(__rg), key_compare()) {} |
| 169 | 158 | ||
| 170 | template <_ContainerCompatibleRange<value_type> _Range> | 159 | template <_ContainerCompatibleRange<value_type> _Range> |
| 171 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_multiset(__comp) { | 160 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 161 | flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp) | ||
| 162 | : flat_multiset(__comp) { | ||
| 172 | insert_range(std::forward<_Range>(__rg)); | 163 | insert_range(std::forward<_Range>(__rg)); |
| 173 | } | 164 | } |
| 174 | 165 | ||
| 175 | _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 166 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 167 | flat_multiset(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | ||
| 176 | : flat_multiset(__il.begin(), __il.end(), __comp) {} | 168 | : flat_multiset(__il.begin(), __il.end(), __comp) {} |
| 177 | 169 | ||
| 178 | _LIBCPP_HIDE_FROM_ABI | 170 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 179 | flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 171 | flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 180 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp) {} | 172 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp) {} |
| 181 | 173 | ||
| 182 | template <class _Allocator> | 174 | template <class _Allocator> |
| 183 | requires uses_allocator<container_type, _Allocator>::value | 175 | requires uses_allocator<container_type, _Allocator>::value |
| 184 | _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const _Allocator& __alloc) | 176 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_multiset(const _Allocator& __alloc) |
| 185 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {} | 177 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {} |
| 186 | 178 | ||
| 187 | template <class _Allocator> | 179 | template <class _Allocator> |
| 188 | requires uses_allocator<container_type, _Allocator>::value | 180 | requires uses_allocator<container_type, _Allocator>::value |
| 189 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const key_compare& __comp, const _Allocator& __alloc) | 181 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 182 | flat_multiset(const key_compare& __comp, const _Allocator& __alloc) | ||
| 190 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {} | 183 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {} |
| 191 | 184 | ||
| 192 | template <class _Allocator> | 185 | template <class _Allocator> |
| 193 | requires uses_allocator<container_type, _Allocator>::value | 186 | requires uses_allocator<container_type, _Allocator>::value |
| 194 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const container_type& __keys, const _Allocator& __alloc) | 187 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 188 | flat_multiset(const container_type& __keys, const _Allocator& __alloc) | ||
| 195 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { | 189 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { |
| 196 | ranges::sort(__keys_, __compare_); | 190 | ranges::sort(__keys_, __compare_); |
| 197 | } | 191 | } |
| 198 | 192 | ||
| 199 | template <class _Allocator> | 193 | template <class _Allocator> |
| 200 | requires uses_allocator<container_type, _Allocator>::value | 194 | requires uses_allocator<container_type, _Allocator>::value |
| 201 | _LIBCPP_HIDE_FROM_ABI | 195 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 202 | flat_multiset(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) | 196 | flat_multiset(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) |
| 203 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { | 197 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { |
| 204 | ranges::sort(__keys_, __compare_); | 198 | ranges::sort(__keys_, __compare_); |
| ... | @@ -206,14 +200,15 @@ public: | ... | @@ -206,14 +200,15 @@ public: |
| 206 | 200 | ||
| 207 | template <class _Allocator> | 201 | template <class _Allocator> |
| 208 | requires uses_allocator<container_type, _Allocator>::value | 202 | requires uses_allocator<container_type, _Allocator>::value |
| 209 | _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, const container_type& __keys, const _Allocator& __alloc) | 203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 204 | flat_multiset(sorted_equivalent_t, const container_type& __keys, const _Allocator& __alloc) | ||
| 210 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { | 205 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { |
| 211 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | 206 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); |
| 212 | } | 207 | } |
| 213 | 208 | ||
| 214 | template <class _Allocator> | 209 | template <class _Allocator> |
| 215 | requires uses_allocator<container_type, _Allocator>::value | 210 | requires uses_allocator<container_type, _Allocator>::value |
| 216 | _LIBCPP_HIDE_FROM_ABI | 211 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 217 | flat_multiset(sorted_equivalent_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) | 212 | flat_multiset(sorted_equivalent_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) |
| 218 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { | 213 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { |
| 219 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | 214 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); |
| ... | @@ -221,13 +216,14 @@ public: | ... | @@ -221,13 +216,14 @@ public: |
| 221 | 216 | ||
| 222 | template <class _Allocator> | 217 | template <class _Allocator> |
| 223 | requires uses_allocator<container_type, _Allocator>::value | 218 | requires uses_allocator<container_type, _Allocator>::value |
| 224 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset& __other, const _Allocator& __alloc) | 219 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 220 | flat_multiset(const flat_multiset& __other, const _Allocator& __alloc) | ||
| 225 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)), | 221 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)), |
| 226 | __compare_(__other.__compare_) {} | 222 | __compare_(__other.__compare_) {} |
| 227 | 223 | ||
| 228 | template <class _Allocator> | 224 | template <class _Allocator> |
| 229 | requires uses_allocator<container_type, _Allocator>::value | 225 | requires uses_allocator<container_type, _Allocator>::value |
| 230 | _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other, const _Allocator& __alloc) | 226 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset(flat_multiset&& __other, const _Allocator& __alloc) |
| 231 | # if _LIBCPP_HAS_EXCEPTIONS | 227 | # if _LIBCPP_HAS_EXCEPTIONS |
| 232 | try | 228 | try |
| 233 | # endif // _LIBCPP_HAS_EXCEPTIONS | 229 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -243,14 +239,15 @@ public: | ... | @@ -243,14 +239,15 @@ public: |
| 243 | 239 | ||
| 244 | template <class _InputIterator, class _Allocator> | 240 | template <class _InputIterator, class _Allocator> |
| 245 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | 241 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) |
| 246 | _LIBCPP_HIDE_FROM_ABI flat_multiset(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | 242 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 243 | flat_multiset(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | ||
| 247 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { | 244 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { |
| 248 | insert(__first, __last); | 245 | insert(__first, __last); |
| 249 | } | 246 | } |
| 250 | 247 | ||
| 251 | template <class _InputIterator, class _Allocator> | 248 | template <class _InputIterator, class _Allocator> |
| 252 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | 249 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) |
| 253 | _LIBCPP_HIDE_FROM_ABI | 250 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 254 | flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) | 251 | flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) |
| 255 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { | 252 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { |
| 256 | insert(__first, __last); | 253 | insert(__first, __last); |
| ... | @@ -258,7 +255,7 @@ public: | ... | @@ -258,7 +255,7 @@ public: |
| 258 | 255 | ||
| 259 | template <class _InputIterator, class _Allocator> | 256 | template <class _InputIterator, class _Allocator> |
| 260 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | 257 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) |
| 261 | _LIBCPP_HIDE_FROM_ABI | 258 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 262 | flat_multiset(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | 259 | flat_multiset(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) |
| 263 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() { | 260 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() { |
| 264 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | 261 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); |
| ... | @@ -266,53 +263,57 @@ public: | ... | @@ -266,53 +263,57 @@ public: |
| 266 | 263 | ||
| 267 | template <class _InputIterator, class _Allocator> | 264 | template <class _InputIterator, class _Allocator> |
| 268 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | 265 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) |
| 269 | _LIBCPP_HIDE_FROM_ABI | 266 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset( |
| 270 | flat_multiset(sorted_equivalent_t, | 267 | sorted_equivalent_t, |
| 271 | _InputIterator __first, | 268 | _InputIterator __first, |
| 272 | _InputIterator __last, | 269 | _InputIterator __last, |
| 273 | const key_compare& __comp, | 270 | const key_compare& __comp, |
| 274 | const _Allocator& __alloc) | 271 | const _Allocator& __alloc) |
| 275 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) { | 272 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) { |
| 276 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | 273 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); |
| 277 | } | 274 | } |
| 278 | 275 | ||
| 279 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | 276 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> |
| 280 | requires uses_allocator<container_type, _Allocator>::value | 277 | requires uses_allocator<container_type, _Allocator>::value |
| 281 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const _Allocator& __alloc) | 278 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 279 | flat_multiset(from_range_t, _Range&& __rg, const _Allocator& __alloc) | ||
| 282 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { | 280 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { |
| 283 | insert_range(std::forward<_Range>(__rg)); | 281 | insert_range(std::forward<_Range>(__rg)); |
| 284 | } | 282 | } |
| 285 | 283 | ||
| 286 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | 284 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> |
| 287 | requires uses_allocator<container_type, _Allocator>::value | 285 | requires uses_allocator<container_type, _Allocator>::value |
| 288 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | 286 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 287 | flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | ||
| 289 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { | 288 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { |
| 290 | insert_range(std::forward<_Range>(__rg)); | 289 | insert_range(std::forward<_Range>(__rg)); |
| 291 | } | 290 | } |
| 292 | 291 | ||
| 293 | template <class _Allocator> | 292 | template <class _Allocator> |
| 294 | requires uses_allocator<container_type, _Allocator>::value | 293 | requires uses_allocator<container_type, _Allocator>::value |
| 295 | _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const _Allocator& __alloc) | 294 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 295 | flat_multiset(initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 296 | : flat_multiset(__il.begin(), __il.end(), __alloc) {} | 296 | : flat_multiset(__il.begin(), __il.end(), __alloc) {} |
| 297 | 297 | ||
| 298 | template <class _Allocator> | 298 | template <class _Allocator> |
| 299 | requires uses_allocator<container_type, _Allocator>::value | 299 | requires uses_allocator<container_type, _Allocator>::value |
| 300 | _LIBCPP_HIDE_FROM_ABI | 300 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 301 | flat_multiset(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | 301 | flat_multiset(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) |
| 302 | : flat_multiset(__il.begin(), __il.end(), __comp, __alloc) {} | 302 | : flat_multiset(__il.begin(), __il.end(), __comp, __alloc) {} |
| 303 | 303 | ||
| 304 | template <class _Allocator> | 304 | template <class _Allocator> |
| 305 | requires uses_allocator<container_type, _Allocator>::value | 305 | requires uses_allocator<container_type, _Allocator>::value |
| 306 | _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc) | 306 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 307 | flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 307 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __alloc) {} | 308 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __alloc) {} |
| 308 | 309 | ||
| 309 | template <class _Allocator> | 310 | template <class _Allocator> |
| 310 | requires uses_allocator<container_type, _Allocator>::value | 311 | requires uses_allocator<container_type, _Allocator>::value |
| 311 | _LIBCPP_HIDE_FROM_ABI flat_multiset( | 312 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset( |
| 312 | sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | 313 | sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) |
| 313 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {} | 314 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {} |
| 314 | 315 | ||
| 315 | _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(initializer_list<value_type> __il) { | 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset& operator=(initializer_list<value_type> __il) { |
| 316 | clear(); | 317 | clear(); |
| 317 | insert(__il); | 318 | insert(__il); |
| 318 | return *this; | 319 | return *this; |
| ... | @@ -321,9 +322,9 @@ public: | ... | @@ -321,9 +322,9 @@ public: |
| 321 | // copy/move assignment are not specified in the spec (defaulted) | 322 | // copy/move assignment are not specified in the spec (defaulted) |
| 322 | // but move assignment can potentially leave moved from object in an inconsistent | 323 | // but move assignment can potentially leave moved from object in an inconsistent |
| 323 | // state if an exception is thrown | 324 | // state if an exception is thrown |
| 324 | _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(const flat_multiset&) = default; | 325 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset& operator=(const flat_multiset&) = default; |
| 325 | 326 | ||
| 326 | _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(flat_multiset&& __other) noexcept( | 327 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_multiset& operator=(flat_multiset&& __other) noexcept( |
| 327 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) { | 328 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) { |
| 328 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); | 329 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); |
| 329 | auto __clear_self_guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 330 | auto __clear_self_guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| ... | @@ -334,30 +335,60 @@ public: | ... | @@ -334,30 +335,60 @@ public: |
| 334 | } | 335 | } |
| 335 | 336 | ||
| 336 | // iterators | 337 | // iterators |
| 337 | _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { return iterator(std::as_const(__keys_).begin()); } | 338 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { |
| 338 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return const_iterator(__keys_.begin()); } | 339 | return iterator(std::as_const(__keys_).begin()); |
| 339 | _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { return iterator(std::as_const(__keys_).end()); } | 340 | } |
| 340 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return const_iterator(__keys_.end()); } | 341 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { |
| 342 | return const_iterator(__keys_.begin()); | ||
| 343 | } | ||
| 344 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { | ||
| 345 | return iterator(std::as_const(__keys_).end()); | ||
| 346 | } | ||
| 347 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { | ||
| 348 | return const_iterator(__keys_.end()); | ||
| 349 | } | ||
| 341 | 350 | ||
| 342 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } | 351 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { |
| 343 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } | 352 | return reverse_iterator(end()); |
| 344 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); } | 353 | } |
| 345 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } | 354 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { |
| 355 | return const_reverse_iterator(end()); | ||
| 356 | } | ||
| 357 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { | ||
| 358 | return reverse_iterator(begin()); | ||
| 359 | } | ||
| 360 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { | ||
| 361 | return const_reverse_iterator(begin()); | ||
| 362 | } | ||
| 346 | 363 | ||
| 347 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); } | 364 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { |
| 348 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); } | 365 | return begin(); |
| 349 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } | 366 | } |
| 350 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } | 367 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { |
| 368 | return end(); | ||
| 369 | } | ||
| 370 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { | ||
| 371 | return const_reverse_iterator(end()); | ||
| 372 | } | ||
| 373 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { | ||
| 374 | return const_reverse_iterator(begin()); | ||
| 375 | } | ||
| 351 | 376 | ||
| 352 | // capacity | 377 | // capacity |
| 353 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __keys_.empty(); } | 378 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const noexcept { |
| 354 | _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __keys_.size(); } | 379 | return __keys_.empty(); |
| 355 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { return __keys_.max_size(); } | 380 | } |
| 381 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { | ||
| 382 | return __keys_.size(); | ||
| 383 | } | ||
| 384 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { | ||
| 385 | return __keys_.max_size(); | ||
| 386 | } | ||
| 356 | 387 | ||
| 357 | // [flat.multiset.modifiers], modifiers | 388 | // [flat.multiset.modifiers], modifiers |
| 358 | template <class... _Args> | 389 | template <class... _Args> |
| 359 | requires is_constructible_v<value_type, _Args...> | 390 | requires is_constructible_v<value_type, _Args...> |
| 360 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { | 391 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace(_Args&&... __args) { |
| 361 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { | 392 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { |
| 362 | return __emplace(std::forward<_Args>(__args)...); | 393 | return __emplace(std::forward<_Args>(__args)...); |
| 363 | } else { | 394 | } else { |
| ... | @@ -367,7 +398,7 @@ public: | ... | @@ -367,7 +398,7 @@ public: |
| 367 | 398 | ||
| 368 | template <class... _Args> | 399 | template <class... _Args> |
| 369 | requires is_constructible_v<value_type, _Args...> | 400 | requires is_constructible_v<value_type, _Args...> |
| 370 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) { | 401 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __hint, _Args&&... __args) { |
| 371 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { | 402 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { |
| 372 | return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...); | 403 | return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...); |
| 373 | } else { | 404 | } else { |
| ... | @@ -375,21 +406,23 @@ public: | ... | @@ -375,21 +406,23 @@ public: |
| 375 | } | 406 | } |
| 376 | } | 407 | } |
| 377 | 408 | ||
| 378 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return emplace(__x); } | 409 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const value_type& __x) { return emplace(__x); } |
| 379 | 410 | ||
| 380 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return emplace(std::move(__x)); } | 411 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(value_type&& __x) { |
| 412 | return emplace(std::move(__x)); | ||
| 413 | } | ||
| 381 | 414 | ||
| 382 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) { | 415 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, const value_type& __x) { |
| 383 | return emplace_hint(__hint, __x); | 416 | return emplace_hint(__hint, __x); |
| 384 | } | 417 | } |
| 385 | 418 | ||
| 386 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) { | 419 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, value_type&& __x) { |
| 387 | return emplace_hint(__hint, std::move(__x)); | 420 | return emplace_hint(__hint, std::move(__x)); |
| 388 | } | 421 | } |
| 389 | 422 | ||
| 390 | template <class _InputIterator> | 423 | template <class _InputIterator> |
| 391 | requires __has_input_iterator_category<_InputIterator>::value | 424 | requires __has_input_iterator_category<_InputIterator>::value |
| 392 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { | 425 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) { |
| 393 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | 426 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { |
| 394 | __reserve(__last - __first); | 427 | __reserve(__last - __first); |
| 395 | } | 428 | } |
| ... | @@ -398,7 +431,8 @@ public: | ... | @@ -398,7 +431,8 @@ public: |
| 398 | 431 | ||
| 399 | template <class _InputIterator> | 432 | template <class _InputIterator> |
| 400 | requires __has_input_iterator_category<_InputIterator>::value | 433 | requires __has_input_iterator_category<_InputIterator>::value |
| 401 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) { | 434 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 435 | insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) { | ||
| 402 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | 436 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { |
| 403 | __reserve(__last - __first); | 437 | __reserve(__last - __first); |
| 404 | } | 438 | } |
| ... | @@ -407,7 +441,7 @@ public: | ... | @@ -407,7 +441,7 @@ public: |
| 407 | } | 441 | } |
| 408 | 442 | ||
| 409 | template <_ContainerCompatibleRange<value_type> _Range> | 443 | template <_ContainerCompatibleRange<value_type> _Range> |
| 410 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 444 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) { |
| 411 | if constexpr (ranges::sized_range<_Range>) { | 445 | if constexpr (ranges::sized_range<_Range>) { |
| 412 | __reserve(ranges::size(__range)); | 446 | __reserve(ranges::size(__range)); |
| 413 | } | 447 | } |
| ... | @@ -415,26 +449,38 @@ public: | ... | @@ -415,26 +449,38 @@ public: |
| 415 | __append_sort_merge</*WasSorted = */ false>(std::forward<_Range>(__range)); | 449 | __append_sort_merge</*WasSorted = */ false>(std::forward<_Range>(__range)); |
| 416 | } | 450 | } |
| 417 | 451 | ||
| 418 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 452 | template <_ContainerCompatibleRange<value_type> _Range> |
| 453 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(sorted_equivalent_t, _Range&& __range) { | ||
| 454 | if constexpr (ranges::sized_range<_Range>) { | ||
| 455 | __reserve(ranges::size(__range)); | ||
| 456 | } | ||
| 419 | 457 | ||
| 420 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, initializer_list<value_type> __il) { | 458 | __append_sort_merge</*WasSorted = */ true>(std::forward<_Range>(__range)); |
| 459 | } | ||
| 460 | |||
| 461 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { | ||
| 462 | insert(__il.begin(), __il.end()); | ||
| 463 | } | ||
| 464 | |||
| 465 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void | ||
| 466 | insert(sorted_equivalent_t, initializer_list<value_type> __il) { | ||
| 421 | insert(sorted_equivalent, __il.begin(), __il.end()); | 467 | insert(sorted_equivalent, __il.begin(), __il.end()); |
| 422 | } | 468 | } |
| 423 | 469 | ||
| 424 | _LIBCPP_HIDE_FROM_ABI container_type extract() && { | 470 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 container_type extract() && { |
| 425 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | 471 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); |
| 426 | auto __ret = std::move(__keys_); | 472 | auto __ret = std::move(__keys_); |
| 427 | return __ret; | 473 | return __ret; |
| 428 | } | 474 | } |
| 429 | 475 | ||
| 430 | _LIBCPP_HIDE_FROM_ABI void replace(container_type&& __keys) { | 476 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void replace(container_type&& __keys) { |
| 431 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys, __compare_), "Key container is not sorted"); | 477 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys, __compare_), "Key container is not sorted"); |
| 432 | auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 478 | auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 433 | __keys_ = std::move(__keys); | 479 | __keys_ = std::move(__keys); |
| 434 | __guard.__complete(); | 480 | __guard.__complete(); |
| 435 | } | 481 | } |
| 436 | 482 | ||
| 437 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) { | 483 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __position) { |
| 438 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 484 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 439 | auto __key_iter = __keys_.erase(__position.__base()); | 485 | auto __key_iter = __keys_.erase(__position.__base()); |
| 440 | __on_failure.__complete(); | 486 | __on_failure.__complete(); |
| ... | @@ -444,7 +490,7 @@ public: | ... | @@ -444,7 +490,7 @@ public: |
| 444 | // The following overload is the same as the iterator overload | 490 | // The following overload is the same as the iterator overload |
| 445 | // iterator erase(const_iterator __position); | 491 | // iterator erase(const_iterator __position); |
| 446 | 492 | ||
| 447 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) { | 493 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __x) { |
| 448 | auto [__first, __last] = equal_range(__x); | 494 | auto [__first, __last] = equal_range(__x); |
| 449 | auto __res = __last - __first; | 495 | auto __res = __last - __first; |
| 450 | erase(__first, __last); | 496 | erase(__first, __last); |
| ... | @@ -454,149 +500,170 @@ public: | ... | @@ -454,149 +500,170 @@ public: |
| 454 | template <class _Kp> | 500 | template <class _Kp> |
| 455 | requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> && | 501 | requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> && |
| 456 | !is_convertible_v<_Kp &&, const_iterator>) | 502 | !is_convertible_v<_Kp &&, const_iterator>) |
| 457 | _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) { | 503 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(_Kp&& __x) { |
| 458 | auto [__first, __last] = equal_range(__x); | 504 | auto [__first, __last] = equal_range(__x); |
| 459 | auto __res = __last - __first; | 505 | auto __res = __last - __first; |
| 460 | erase(__first, __last); | 506 | erase(__first, __last); |
| 461 | return __res; | 507 | return __res; |
| 462 | } | 508 | } |
| 463 | 509 | ||
| 464 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { | 510 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __first, const_iterator __last) { |
| 465 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 511 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 466 | auto __key_it = __keys_.erase(__first.__base(), __last.__base()); | 512 | auto __key_it = __keys_.erase(__first.__base(), __last.__base()); |
| 467 | __on_failure.__complete(); | 513 | __on_failure.__complete(); |
| 468 | return iterator(std::move(__key_it)); | 514 | return iterator(std::move(__key_it)); |
| 469 | } | 515 | } |
| 470 | 516 | ||
| 471 | _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __y) noexcept { | 517 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 472 | // warning: The spec has unconditional noexcept, which means that | 518 | swap(flat_multiset& __y) noexcept(is_nothrow_swappable_v<container_type> && is_nothrow_swappable_v<key_compare>) { |
| 473 | // if any of the following functions throw an exception, | 519 | auto __on_failure = std::__make_exception_guard([&]() noexcept { |
| 474 | // std::terminate will be called | 520 | clear() /* noexcept */; |
| 475 | // This is discussed in P3567, which hasn't been voted on yet. | 521 | __y.clear() /* noexcept */; |
| 522 | }); | ||
| 476 | ranges::swap(__compare_, __y.__compare_); | 523 | ranges::swap(__compare_, __y.__compare_); |
| 477 | ranges::swap(__keys_, __y.__keys_); | 524 | ranges::swap(__keys_, __y.__keys_); |
| 525 | __on_failure.__complete(); | ||
| 478 | } | 526 | } |
| 479 | 527 | ||
| 480 | _LIBCPP_HIDE_FROM_ABI void clear() noexcept { __keys_.clear(); } | 528 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { __keys_.clear(); } |
| 481 | 529 | ||
| 482 | // observers | 530 | // observers |
| 483 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; } | 531 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } |
| 484 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __compare_; } | 532 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { |
| 533 | return __compare_; | ||
| 534 | } | ||
| 485 | 535 | ||
| 486 | // map operations | 536 | // map operations |
| 487 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); } | 537 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { |
| 538 | return __find_impl(*this, __x); | ||
| 539 | } | ||
| 488 | 540 | ||
| 489 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); } | 541 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { |
| 542 | return __find_impl(*this, __x); | ||
| 543 | } | ||
| 490 | 544 | ||
| 491 | template <class _Kp> | 545 | template <class _Kp> |
| 492 | requires __is_transparent_v<_Compare> | 546 | requires __is_transparent_v<_Compare> |
| 493 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) { | 547 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { |
| 494 | return __find_impl(*this, __x); | 548 | return __find_impl(*this, __x); |
| 495 | } | 549 | } |
| 496 | 550 | ||
| 497 | template <class _Kp> | 551 | template <class _Kp> |
| 498 | requires __is_transparent_v<_Compare> | 552 | requires __is_transparent_v<_Compare> |
| 499 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const { | 553 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { |
| 500 | return __find_impl(*this, __x); | 554 | return __find_impl(*this, __x); |
| 501 | } | 555 | } |
| 502 | 556 | ||
| 503 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { | 557 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { |
| 504 | auto [__first, __last] = equal_range(__x); | 558 | auto [__first, __last] = equal_range(__x); |
| 505 | return __last - __first; | 559 | return __last - __first; |
| 506 | } | 560 | } |
| 507 | 561 | ||
| 508 | template <class _Kp> | 562 | template <class _Kp> |
| 509 | requires __is_transparent_v<_Compare> | 563 | requires __is_transparent_v<_Compare> |
| 510 | _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const { | 564 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { |
| 511 | auto [__first, __last] = equal_range(__x); | 565 | auto [__first, __last] = equal_range(__x); |
| 512 | return __last - __first; | 566 | return __last - __first; |
| 513 | } | 567 | } |
| 514 | 568 | ||
| 515 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); } | 569 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { |
| 570 | return find(__x) != end(); | ||
| 571 | } | ||
| 516 | 572 | ||
| 517 | template <class _Kp> | 573 | template <class _Kp> |
| 518 | requires __is_transparent_v<_Compare> | 574 | requires __is_transparent_v<_Compare> |
| 519 | _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const { | 575 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { |
| 520 | return find(__x) != end(); | 576 | return find(__x) != end(); |
| 521 | } | 577 | } |
| 522 | 578 | ||
| 523 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { | 579 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { |
| 524 | const auto& __keys = __keys_; | 580 | const auto& __keys = __keys_; |
| 525 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 581 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 526 | } | 582 | } |
| 527 | 583 | ||
| 528 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const { | 584 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 585 | lower_bound(const key_type& __x) const { | ||
| 529 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 586 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 530 | } | 587 | } |
| 531 | 588 | ||
| 532 | template <class _Kp> | 589 | template <class _Kp> |
| 533 | requires __is_transparent_v<_Compare> | 590 | requires __is_transparent_v<_Compare> |
| 534 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) { | 591 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { |
| 535 | const auto& __keys = __keys_; | 592 | const auto& __keys = __keys_; |
| 536 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 593 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 537 | } | 594 | } |
| 538 | 595 | ||
| 539 | template <class _Kp> | 596 | template <class _Kp> |
| 540 | requires __is_transparent_v<_Compare> | 597 | requires __is_transparent_v<_Compare> |
| 541 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const { | 598 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { |
| 542 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 599 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 543 | } | 600 | } |
| 544 | 601 | ||
| 545 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { | 602 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { |
| 546 | const auto& __keys = __keys_; | 603 | const auto& __keys = __keys_; |
| 547 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 604 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 548 | } | 605 | } |
| 549 | 606 | ||
| 550 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const { | 607 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 608 | upper_bound(const key_type& __x) const { | ||
| 551 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 609 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 552 | } | 610 | } |
| 553 | 611 | ||
| 554 | template <class _Kp> | 612 | template <class _Kp> |
| 555 | requires __is_transparent_v<_Compare> | 613 | requires __is_transparent_v<_Compare> |
| 556 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) { | 614 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { |
| 557 | const auto& __keys = __keys_; | 615 | const auto& __keys = __keys_; |
| 558 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 616 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 559 | } | 617 | } |
| 560 | 618 | ||
| 561 | template <class _Kp> | 619 | template <class _Kp> |
| 562 | requires __is_transparent_v<_Compare> | 620 | requires __is_transparent_v<_Compare> |
| 563 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const { | 621 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { |
| 564 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 622 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 565 | } | 623 | } |
| 566 | 624 | ||
| 567 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) { | 625 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 626 | equal_range(const key_type& __x) { | ||
| 568 | return __equal_range_impl(*this, __x); | 627 | return __equal_range_impl(*this, __x); |
| 569 | } | 628 | } |
| 570 | 629 | ||
| 571 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { | 630 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 631 | equal_range(const key_type& __x) const { | ||
| 572 | return __equal_range_impl(*this, __x); | 632 | return __equal_range_impl(*this, __x); |
| 573 | } | 633 | } |
| 574 | 634 | ||
| 575 | template <class _Kp> | 635 | template <class _Kp> |
| 576 | requires __is_transparent_v<_Compare> | 636 | requires __is_transparent_v<_Compare> |
| 577 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) { | 637 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 638 | equal_range(const _Kp& __x) { | ||
| 578 | return __equal_range_impl(*this, __x); | 639 | return __equal_range_impl(*this, __x); |
| 579 | } | 640 | } |
| 580 | template <class _Kp> | 641 | template <class _Kp> |
| 581 | requires __is_transparent_v<_Compare> | 642 | requires __is_transparent_v<_Compare> |
| 582 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const { | 643 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 644 | equal_range(const _Kp& __x) const { | ||
| 583 | return __equal_range_impl(*this, __x); | 645 | return __equal_range_impl(*this, __x); |
| 584 | } | 646 | } |
| 585 | 647 | ||
| 586 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_multiset& __x, const flat_multiset& __y) { | 648 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool |
| 649 | operator==(const flat_multiset& __x, const flat_multiset& __y) { | ||
| 587 | return ranges::equal(__x, __y); | 650 | return ranges::equal(__x, __y); |
| 588 | } | 651 | } |
| 589 | 652 | ||
| 590 | friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_multiset& __x, const flat_multiset& __y) { | 653 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto |
| 654 | operator<=>(const flat_multiset& __x, const flat_multiset& __y) { | ||
| 591 | return std::lexicographical_compare_three_way( | 655 | return std::lexicographical_compare_three_way( |
| 592 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 656 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 593 | } | 657 | } |
| 594 | 658 | ||
| 595 | friend _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __x, flat_multiset& __y) noexcept { __x.swap(__y); } | 659 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 660 | swap(flat_multiset& __x, flat_multiset& __y) noexcept(noexcept(__x.swap(__y))) { | ||
| 661 | __x.swap(__y); | ||
| 662 | } | ||
| 596 | 663 | ||
| 597 | private: | 664 | private: |
| 598 | template <bool _WasSorted, class... _Args> | 665 | template <bool _WasSorted, class... _Args> |
| 599 | _LIBCPP_HIDE_FROM_ABI void __append_sort_merge(_Args&&... __args) { | 666 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __append_sort_merge(_Args&&... __args) { |
| 600 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 667 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 601 | size_type __old_size = size(); | 668 | size_type __old_size = size(); |
| 602 | __flat_set_utils::__append(*this, std::forward<_Args>(__args)...); | 669 | __flat_set_utils::__append(*this, std::forward<_Args>(__args)...); |
| ... | @@ -604,20 +671,20 @@ private: | ... | @@ -604,20 +671,20 @@ private: |
| 604 | ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_); | 671 | ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_); |
| 605 | } else { | 672 | } else { |
| 606 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | 673 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( |
| 607 | ranges::is_sorted(__keys_ | ranges::views::drop(__old_size)), "Key container is not sorted"); | 674 | ranges::is_sorted(__keys_ | ranges::views::drop(__old_size), __compare_), "Key container is not sorted"); |
| 608 | } | 675 | } |
| 609 | ranges::inplace_merge(__keys_.begin(), __keys_.begin() + __old_size, __keys_.end(), __compare_); | 676 | ranges::inplace_merge(__keys_.begin(), __keys_.begin() + __old_size, __keys_.end(), __compare_); |
| 610 | __on_failure.__complete(); | 677 | __on_failure.__complete(); |
| 611 | } | 678 | } |
| 612 | 679 | ||
| 613 | template <class _Kp> | 680 | template <class _Kp> |
| 614 | _LIBCPP_HIDE_FROM_ABI iterator __emplace(_Kp&& __key) { | 681 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace(_Kp&& __key) { |
| 615 | auto __it = upper_bound(__key); | 682 | auto __it = upper_bound(__key); |
| 616 | return __flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key)); | 683 | return __flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key)); |
| 617 | } | 684 | } |
| 618 | 685 | ||
| 619 | template <class _Kp> | 686 | template <class _Kp> |
| 620 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint(const_iterator __hint, _Kp&& __key) { | 687 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint(const_iterator __hint, _Kp&& __key) { |
| 621 | auto __prev_larger = __hint != cbegin() && __compare_(__key, *std::prev(__hint)); | 688 | auto __prev_larger = __hint != cbegin() && __compare_(__key, *std::prev(__hint)); |
| 622 | auto __next_smaller = __hint != cend() && __compare_(*__hint, __key); | 689 | auto __next_smaller = __hint != cend() && __compare_(*__hint, __key); |
| 623 | 690 | ||
| ... | @@ -649,7 +716,7 @@ private: | ... | @@ -649,7 +716,7 @@ private: |
| 649 | } | 716 | } |
| 650 | 717 | ||
| 651 | template <class _Self, class _Kp> | 718 | template <class _Self, class _Kp> |
| 652 | _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) { | 719 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __find_impl(_Self&& __self, const _Kp& __key) { |
| 653 | auto __it = __self.lower_bound(__key); | 720 | auto __it = __self.lower_bound(__key); |
| 654 | auto __last = __self.end(); | 721 | auto __last = __self.end(); |
| 655 | if (__it == __last || __self.__compare_(__key, *__it)) { | 722 | if (__it == __last || __self.__compare_(__key, *__it)) { |
| ... | @@ -659,29 +726,30 @@ private: | ... | @@ -659,29 +726,30 @@ private: |
| 659 | } | 726 | } |
| 660 | 727 | ||
| 661 | template <class _Self, class _Kp> | 728 | template <class _Self, class _Kp> |
| 662 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | 729 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { |
| 663 | using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>; | 730 | using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>; |
| 664 | auto [__key_first, __key_last] = | 731 | auto [__key_first, __key_last] = |
| 665 | std::equal_range(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_); | 732 | std::equal_range(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_); |
| 666 | return std::make_pair(__iter(__key_first), __iter(__key_last)); | 733 | return std::make_pair(__iter(__key_first), __iter(__key_last)); |
| 667 | } | 734 | } |
| 668 | 735 | ||
| 669 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { | 736 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __reserve(size_t __size) { |
| 670 | if constexpr (__container_traits<_KeyContainer>::__reservable) { | 737 | if constexpr (__container_traits<_KeyContainer>::__reservable) { |
| 671 | __keys_.reserve(__size); | 738 | __keys_.reserve(__size); |
| 672 | } | 739 | } |
| 673 | } | 740 | } |
| 674 | 741 | ||
| 675 | template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate> | 742 | template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate> |
| 676 | friend typename flat_multiset<_Key2, _Compare2, _KeyContainer2>::size_type | 743 | friend typename flat_multiset<_Key2, _Compare2, _KeyContainer2>::size_type _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 677 | erase_if(flat_multiset<_Key2, _Compare2, _KeyContainer2>&, _Predicate); | 744 | erase_if(flat_multiset<_Key2, _Compare2, _KeyContainer2>&, _Predicate); |
| 678 | 745 | ||
| 679 | _KeyContainer __keys_; | 746 | _KeyContainer __keys_; |
| 680 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; | 747 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; |
| 681 | 748 | ||
| 682 | struct __key_equiv { | 749 | struct __key_equiv { |
| 683 | _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {} | 750 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {} |
| 684 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | 751 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool |
| 752 | operator()(const_reference __x, const_reference __y) const { | ||
| 685 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); | 753 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); |
| 686 | } | 754 | } |
| 687 | key_compare __comp_; | 755 | key_compare __comp_; |
| ... | @@ -689,7 +757,7 @@ private: | ... | @@ -689,7 +757,7 @@ private: |
| 689 | }; | 757 | }; |
| 690 | 758 | ||
| 691 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | 759 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 692 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 760 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 693 | is_invocable_v<const _Compare&, | 761 | is_invocable_v<const _Compare&, |
| 694 | const typename _KeyContainer::value_type&, | 762 | const typename _KeyContainer::value_type&, |
| 695 | const typename _KeyContainer::value_type&>) | 763 | const typename _KeyContainer::value_type&>) |
| ... | @@ -697,12 +765,12 @@ flat_multiset(_KeyContainer, _Compare = _Compare()) | ... | @@ -697,12 +765,12 @@ flat_multiset(_KeyContainer, _Compare = _Compare()) |
| 697 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 765 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 698 | 766 | ||
| 699 | template <class _KeyContainer, class _Allocator> | 767 | template <class _KeyContainer, class _Allocator> |
| 700 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | 768 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator_v<_KeyContainer>) |
| 701 | flat_multiset(_KeyContainer, _Allocator) | 769 | flat_multiset(_KeyContainer, _Allocator) |
| 702 | -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | 770 | -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; |
| 703 | 771 | ||
| 704 | template <class _KeyContainer, class _Compare, class _Allocator> | 772 | template <class _KeyContainer, class _Compare, class _Allocator> |
| 705 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 773 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 706 | uses_allocator_v<_KeyContainer, _Allocator> && | 774 | uses_allocator_v<_KeyContainer, _Allocator> && |
| 707 | is_invocable_v<const _Compare&, | 775 | is_invocable_v<const _Compare&, |
| 708 | const typename _KeyContainer::value_type&, | 776 | const typename _KeyContainer::value_type&, |
| ... | @@ -711,7 +779,7 @@ flat_multiset(_KeyContainer, _Compare, _Allocator) | ... | @@ -711,7 +779,7 @@ flat_multiset(_KeyContainer, _Compare, _Allocator) |
| 711 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 779 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 712 | 780 | ||
| 713 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | 781 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 714 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 782 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 715 | is_invocable_v<const _Compare&, | 783 | is_invocable_v<const _Compare&, |
| 716 | const typename _KeyContainer::value_type&, | 784 | const typename _KeyContainer::value_type&, |
| 717 | const typename _KeyContainer::value_type&>) | 785 | const typename _KeyContainer::value_type&>) |
| ... | @@ -719,12 +787,12 @@ flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare()) | ... | @@ -719,12 +787,12 @@ flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare()) |
| 719 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 787 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 720 | 788 | ||
| 721 | template <class _KeyContainer, class _Allocator> | 789 | template <class _KeyContainer, class _Allocator> |
| 722 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | 790 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator_v<_KeyContainer>) |
| 723 | flat_multiset(sorted_equivalent_t, _KeyContainer, _Allocator) | 791 | flat_multiset(sorted_equivalent_t, _KeyContainer, _Allocator) |
| 724 | -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | 792 | -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; |
| 725 | 793 | ||
| 726 | template <class _KeyContainer, class _Compare, class _Allocator> | 794 | template <class _KeyContainer, class _Compare, class _Allocator> |
| 727 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 795 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 728 | uses_allocator_v<_KeyContainer, _Allocator> && | 796 | uses_allocator_v<_KeyContainer, _Allocator> && |
| 729 | is_invocable_v<const _Compare&, | 797 | is_invocable_v<const _Compare&, |
| 730 | const typename _KeyContainer::value_type&, | 798 | const typename _KeyContainer::value_type&, |
| ... | @@ -732,37 +800,37 @@ template <class _KeyContainer, class _Compare, class _Allocator> | ... | @@ -732,37 +800,37 @@ template <class _KeyContainer, class _Compare, class _Allocator> |
| 732 | flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Allocator) | 800 | flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Allocator) |
| 733 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 801 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 734 | 802 | ||
| 735 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | 803 | template <class _InputIterator, class _Compare = less<__iterator_value_type<_InputIterator>>> |
| 736 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 804 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 737 | flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare()) | 805 | flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare()) |
| 738 | -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>; | 806 | -> flat_multiset<__iterator_value_type<_InputIterator>, _Compare>; |
| 739 | 807 | ||
| 740 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | 808 | template <class _InputIterator, class _Compare = less<__iterator_value_type<_InputIterator>>> |
| 741 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 809 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 742 | flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare()) | 810 | flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare()) |
| 743 | -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>; | 811 | -> flat_multiset<__iterator_value_type<_InputIterator>, _Compare>; |
| 744 | 812 | ||
| 745 | template <ranges::input_range _Range, | 813 | template <ranges::input_range _Range, |
| 746 | class _Compare = less<ranges::range_value_t<_Range>>, | 814 | class _Compare = less<ranges::range_value_t<_Range>>, |
| 747 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | 815 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 748 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | 816 | class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>> |
| 749 | flat_multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multiset< | 817 | flat_multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multiset< |
| 750 | ranges::range_value_t<_Range>, | 818 | ranges::range_value_t<_Range>, |
| 751 | _Compare, | 819 | _Compare, |
| 752 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | 820 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; |
| 753 | 821 | ||
| 754 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | 822 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>> |
| 755 | flat_multiset(from_range_t, _Range&&, _Allocator) -> flat_multiset< | 823 | flat_multiset(from_range_t, _Range&&, _Allocator) -> flat_multiset< |
| 756 | ranges::range_value_t<_Range>, | 824 | ranges::range_value_t<_Range>, |
| 757 | less<ranges::range_value_t<_Range>>, | 825 | less<ranges::range_value_t<_Range>>, |
| 758 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | 826 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; |
| 759 | 827 | ||
| 760 | template <class _Key, class _Compare = less<_Key>> | 828 | template <class _Key, class _Compare = less<_Key>> |
| 761 | requires(!__is_allocator<_Compare>::value) | 829 | requires(!__is_allocator_v<_Compare>) |
| 762 | flat_multiset(initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>; | 830 | flat_multiset(initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>; |
| 763 | 831 | ||
| 764 | template <class _Key, class _Compare = less<_Key>> | 832 | template <class _Key, class _Compare = less<_Key>> |
| 765 | requires(!__is_allocator<_Compare>::value) | 833 | requires(!__is_allocator_v<_Compare>) |
| 766 | flat_multiset(sorted_equivalent_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>; | 834 | flat_multiset(sorted_equivalent_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>; |
| 767 | 835 | ||
| 768 | template <class _Key, class _Compare, class _KeyContainer, class _Allocator> | 836 | template <class _Key, class _Compare, class _KeyContainer, class _Allocator> |
| ... | @@ -770,7 +838,7 @@ struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Allocator> | ... | @@ -770,7 +838,7 @@ struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Allocator> |
| 770 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> > {}; | 838 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> > {}; |
| 771 | 839 | ||
| 772 | template <class _Key, class _Compare, class _KeyContainer, class _Predicate> | 840 | template <class _Key, class _Compare, class _KeyContainer, class _Predicate> |
| 773 | _LIBCPP_HIDE_FROM_ABI typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type | 841 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type |
| 774 | erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __flat_multiset, _Predicate __pred) { | 842 | erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __flat_multiset, _Predicate __pred) { |
| 775 | auto __guard = std::__make_exception_guard([&] { __flat_multiset.clear(); }); | 843 | auto __guard = std::__make_exception_guard([&] { __flat_multiset.clear(); }); |
| 776 | auto __it = | 844 | auto __it = |
lib/libcxx/include/__flat_set/flat_set.h+86-68| ... | @@ -12,7 +12,6 @@ | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | ||
| 13 | #include <__algorithm/lexicographical_compare_three_way.h> | 13 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 14 | #include <__algorithm/lower_bound.h> | 14 | #include <__algorithm/lower_bound.h> |
| 15 | #include <__algorithm/min.h> | ||
| 16 | #include <__algorithm/ranges_adjacent_find.h> | 15 | #include <__algorithm/ranges_adjacent_find.h> |
| 17 | #include <__algorithm/ranges_equal.h> | 16 | #include <__algorithm/ranges_equal.h> |
| 18 | #include <__algorithm/ranges_inplace_merge.h> | 17 | #include <__algorithm/ranges_inplace_merge.h> |
| ... | @@ -24,20 +23,16 @@ | ... | @@ -24,20 +23,16 @@ |
| 24 | #include <__compare/synth_three_way.h> | 23 | #include <__compare/synth_three_way.h> |
| 25 | #include <__concepts/swappable.h> | 24 | #include <__concepts/swappable.h> |
| 26 | #include <__config> | 25 | #include <__config> |
| 27 | #include <__cstddef/ptrdiff_t.h> | ||
| 28 | #include <__flat_map/sorted_unique.h> | 26 | #include <__flat_map/sorted_unique.h> |
| 29 | #include <__flat_set/ra_iterator.h> | 27 | #include <__flat_set/ra_iterator.h> |
| 30 | #include <__flat_set/utils.h> | 28 | #include <__flat_set/utils.h> |
| 31 | #include <__functional/invoke.h> | ||
| 32 | #include <__functional/is_transparent.h> | 29 | #include <__functional/is_transparent.h> |
| 33 | #include <__functional/operations.h> | 30 | #include <__functional/operations.h> |
| 34 | #include <__fwd/vector.h> | 31 | #include <__fwd/vector.h> |
| 35 | #include <__iterator/concepts.h> | 32 | #include <__iterator/concepts.h> |
| 36 | #include <__iterator/distance.h> | ||
| 37 | #include <__iterator/iterator_traits.h> | 33 | #include <__iterator/iterator_traits.h> |
| 38 | #include <__iterator/next.h> | 34 | #include <__iterator/next.h> |
| 39 | #include <__iterator/prev.h> | 35 | #include <__iterator/prev.h> |
| 40 | #include <__iterator/ranges_iterator_traits.h> | ||
| 41 | #include <__iterator/reverse_iterator.h> | 36 | #include <__iterator/reverse_iterator.h> |
| 42 | #include <__memory/allocator_traits.h> | 37 | #include <__memory/allocator_traits.h> |
| 43 | #include <__memory/uses_allocator.h> | 38 | #include <__memory/uses_allocator.h> |
| ... | @@ -47,10 +42,7 @@ | ... | @@ -47,10 +42,7 @@ |
| 47 | #include <__ranges/container_compatible_range.h> | 42 | #include <__ranges/container_compatible_range.h> |
| 48 | #include <__ranges/drop_view.h> | 43 | #include <__ranges/drop_view.h> |
| 49 | #include <__ranges/from_range.h> | 44 | #include <__ranges/from_range.h> |
| 50 | #include <__ranges/ref_view.h> | ||
| 51 | #include <__ranges/size.h> | 45 | #include <__ranges/size.h> |
| 52 | #include <__ranges/subrange.h> | ||
| 53 | #include <__type_traits/conjunction.h> | ||
| 54 | #include <__type_traits/container_traits.h> | 46 | #include <__type_traits/container_traits.h> |
| 55 | #include <__type_traits/invoke.h> | 47 | #include <__type_traits/invoke.h> |
| 56 | #include <__type_traits/is_allocator.h> | 48 | #include <__type_traits/is_allocator.h> |
| ... | @@ -347,38 +339,42 @@ public: | ... | @@ -347,38 +339,42 @@ public: |
| 347 | } | 339 | } |
| 348 | 340 | ||
| 349 | // iterators | 341 | // iterators |
| 350 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { | 342 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { |
| 351 | return iterator(std::as_const(__keys_).begin()); | 343 | return iterator(std::as_const(__keys_).begin()); |
| 352 | } | 344 | } |
| 353 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { | 345 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { |
| 354 | return const_iterator(__keys_.begin()); | 346 | return const_iterator(__keys_.begin()); |
| 355 | } | 347 | } |
| 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { | 348 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { |
| 357 | return iterator(std::as_const(__keys_).end()); | 349 | return iterator(std::as_const(__keys_).end()); |
| 358 | } | 350 | } |
| 359 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { | 351 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { |
| 360 | return const_iterator(__keys_.end()); | 352 | return const_iterator(__keys_.end()); |
| 361 | } | 353 | } |
| 362 | 354 | ||
| 363 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { | 355 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { |
| 364 | return reverse_iterator(end()); | 356 | return reverse_iterator(end()); |
| 365 | } | 357 | } |
| 366 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { | 358 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { |
| 367 | return const_reverse_iterator(end()); | 359 | return const_reverse_iterator(end()); |
| 368 | } | 360 | } |
| 369 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { | 361 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { |
| 370 | return reverse_iterator(begin()); | 362 | return reverse_iterator(begin()); |
| 371 | } | 363 | } |
| 372 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { | 364 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { |
| 373 | return const_reverse_iterator(begin()); | 365 | return const_reverse_iterator(begin()); |
| 374 | } | 366 | } |
| 375 | 367 | ||
| 376 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { return begin(); } | 368 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { |
| 377 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { return end(); } | 369 | return begin(); |
| 378 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { | 370 | } |
| 371 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { | ||
| 372 | return end(); | ||
| 373 | } | ||
| 374 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { | ||
| 379 | return const_reverse_iterator(end()); | 375 | return const_reverse_iterator(end()); |
| 380 | } | 376 | } |
| 381 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { | 377 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { |
| 382 | return const_reverse_iterator(begin()); | 378 | return const_reverse_iterator(begin()); |
| 383 | } | 379 | } |
| 384 | 380 | ||
| ... | @@ -387,9 +383,13 @@ public: | ... | @@ -387,9 +383,13 @@ public: |
| 387 | return __keys_.empty(); | 383 | return __keys_.empty(); |
| 388 | } | 384 | } |
| 389 | 385 | ||
| 390 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { return __keys_.size(); } | 386 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { |
| 387 | return __keys_.size(); | ||
| 388 | } | ||
| 391 | 389 | ||
| 392 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { return __keys_.max_size(); } | 390 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { |
| 391 | return __keys_.max_size(); | ||
| 392 | } | ||
| 393 | 393 | ||
| 394 | // [flat.set.modifiers], modifiers | 394 | // [flat.set.modifiers], modifiers |
| 395 | template <class... _Args> | 395 | template <class... _Args> |
| ... | @@ -466,6 +466,15 @@ public: | ... | @@ -466,6 +466,15 @@ public: |
| 466 | __append_sort_merge_unique</*WasSorted = */ false>(std::forward<_Range>(__range)); | 466 | __append_sort_merge_unique</*WasSorted = */ false>(std::forward<_Range>(__range)); |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 470 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(std::sorted_unique_t, _Range&& __range) { | ||
| 471 | if constexpr (ranges::sized_range<_Range>) { | ||
| 472 | __reserve(ranges::size(__range)); | ||
| 473 | } | ||
| 474 | |||
| 475 | __append_sort_merge_unique</*WasSorted = */ true>(std::forward<_Range>(__range)); | ||
| 476 | } | ||
| 477 | |||
| 469 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { | 478 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { |
| 470 | insert(__il.begin(), __il.end()); | 479 | insert(__il.begin(), __il.end()); |
| 471 | } | 480 | } |
| ... | @@ -474,7 +483,7 @@ public: | ... | @@ -474,7 +483,7 @@ public: |
| 474 | insert(sorted_unique, __il.begin(), __il.end()); | 483 | insert(sorted_unique, __il.begin(), __il.end()); |
| 475 | } | 484 | } |
| 476 | 485 | ||
| 477 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 container_type extract() && { | 486 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 container_type extract() && { |
| 478 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | 487 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); |
| 479 | auto __ret = std::move(__keys_); | 488 | auto __ret = std::move(__keys_); |
| 480 | return __ret; | 489 | return __ret; |
| ... | @@ -524,123 +533,131 @@ public: | ... | @@ -524,123 +533,131 @@ public: |
| 524 | return iterator(std::move(__key_it)); | 533 | return iterator(std::move(__key_it)); |
| 525 | } | 534 | } |
| 526 | 535 | ||
| 527 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __y) noexcept { | 536 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 528 | // warning: The spec has unconditional noexcept, which means that | 537 | swap(flat_set& __y) noexcept(is_nothrow_swappable_v<container_type> && is_nothrow_swappable_v<key_compare>) { |
| 529 | // if any of the following functions throw an exception, | 538 | auto __on_failure = std::__make_exception_guard([&]() noexcept { |
| 530 | // std::terminate will be called. | 539 | clear() /* noexcept */; |
| 531 | // This is discussed in P2767, which hasn't been voted on yet. | 540 | __y.clear() /* noexcept */; |
| 541 | }); | ||
| 532 | ranges::swap(__compare_, __y.__compare_); | 542 | ranges::swap(__compare_, __y.__compare_); |
| 533 | ranges::swap(__keys_, __y.__keys_); | 543 | ranges::swap(__keys_, __y.__keys_); |
| 544 | __on_failure.__complete(); | ||
| 534 | } | 545 | } |
| 535 | 546 | ||
| 536 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { __keys_.clear(); } | 547 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { __keys_.clear(); } |
| 537 | 548 | ||
| 538 | // observers | 549 | // observers |
| 539 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } | 550 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } |
| 540 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { return __compare_; } | 551 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { |
| 552 | return __compare_; | ||
| 553 | } | ||
| 541 | 554 | ||
| 542 | // set operations | 555 | // set operations |
| 543 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { | 556 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { |
| 544 | return __find_impl(*this, __x); | 557 | return __find_impl(*this, __x); |
| 545 | } | 558 | } |
| 546 | 559 | ||
| 547 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { | 560 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { |
| 548 | return __find_impl(*this, __x); | 561 | return __find_impl(*this, __x); |
| 549 | } | 562 | } |
| 550 | 563 | ||
| 551 | template <class _Kp> | 564 | template <class _Kp> |
| 552 | requires __is_transparent_v<_Compare> | 565 | requires __is_transparent_v<_Compare> |
| 553 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { | 566 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { |
| 554 | return __find_impl(*this, __x); | 567 | return __find_impl(*this, __x); |
| 555 | } | 568 | } |
| 556 | 569 | ||
| 557 | template <class _Kp> | 570 | template <class _Kp> |
| 558 | requires __is_transparent_v<_Compare> | 571 | requires __is_transparent_v<_Compare> |
| 559 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { | 572 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { |
| 560 | return __find_impl(*this, __x); | 573 | return __find_impl(*this, __x); |
| 561 | } | 574 | } |
| 562 | 575 | ||
| 563 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { | 576 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { |
| 564 | return contains(__x) ? 1 : 0; | 577 | return contains(__x) ? 1 : 0; |
| 565 | } | 578 | } |
| 566 | 579 | ||
| 567 | template <class _Kp> | 580 | template <class _Kp> |
| 568 | requires __is_transparent_v<_Compare> | 581 | requires __is_transparent_v<_Compare> |
| 569 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { | 582 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { |
| 570 | return contains(__x) ? 1 : 0; | 583 | return contains(__x) ? 1 : 0; |
| 571 | } | 584 | } |
| 572 | 585 | ||
| 573 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { | 586 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { |
| 574 | return find(__x) != end(); | 587 | return find(__x) != end(); |
| 575 | } | 588 | } |
| 576 | 589 | ||
| 577 | template <class _Kp> | 590 | template <class _Kp> |
| 578 | requires __is_transparent_v<_Compare> | 591 | requires __is_transparent_v<_Compare> |
| 579 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { | 592 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { |
| 580 | return find(__x) != end(); | 593 | return find(__x) != end(); |
| 581 | } | 594 | } |
| 582 | 595 | ||
| 583 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { | 596 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { |
| 584 | const auto& __keys = __keys_; | 597 | const auto& __keys = __keys_; |
| 585 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 598 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 586 | } | 599 | } |
| 587 | 600 | ||
| 588 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __x) const { | 601 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 602 | lower_bound(const key_type& __x) const { | ||
| 589 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 603 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 590 | } | 604 | } |
| 591 | 605 | ||
| 592 | template <class _Kp> | 606 | template <class _Kp> |
| 593 | requires __is_transparent_v<_Compare> | 607 | requires __is_transparent_v<_Compare> |
| 594 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { | 608 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { |
| 595 | const auto& __keys = __keys_; | 609 | const auto& __keys = __keys_; |
| 596 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 610 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 597 | } | 611 | } |
| 598 | 612 | ||
| 599 | template <class _Kp> | 613 | template <class _Kp> |
| 600 | requires __is_transparent_v<_Compare> | 614 | requires __is_transparent_v<_Compare> |
| 601 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { | 615 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { |
| 602 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 616 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 603 | } | 617 | } |
| 604 | 618 | ||
| 605 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { | 619 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { |
| 606 | const auto& __keys = __keys_; | 620 | const auto& __keys = __keys_; |
| 607 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 621 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 608 | } | 622 | } |
| 609 | 623 | ||
| 610 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __x) const { | 624 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator |
| 625 | upper_bound(const key_type& __x) const { | ||
| 611 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 626 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 612 | } | 627 | } |
| 613 | 628 | ||
| 614 | template <class _Kp> | 629 | template <class _Kp> |
| 615 | requires __is_transparent_v<_Compare> | 630 | requires __is_transparent_v<_Compare> |
| 616 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { | 631 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { |
| 617 | const auto& __keys = __keys_; | 632 | const auto& __keys = __keys_; |
| 618 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | 633 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); |
| 619 | } | 634 | } |
| 620 | 635 | ||
| 621 | template <class _Kp> | 636 | template <class _Kp> |
| 622 | requires __is_transparent_v<_Compare> | 637 | requires __is_transparent_v<_Compare> |
| 623 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { | 638 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { |
| 624 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | 639 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); |
| 625 | } | 640 | } |
| 626 | 641 | ||
| 627 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __x) { | 642 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 643 | equal_range(const key_type& __x) { | ||
| 628 | return __equal_range_impl(*this, __x); | 644 | return __equal_range_impl(*this, __x); |
| 629 | } | 645 | } |
| 630 | 646 | ||
| 631 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> | 647 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 632 | equal_range(const key_type& __x) const { | 648 | equal_range(const key_type& __x) const { |
| 633 | return __equal_range_impl(*this, __x); | 649 | return __equal_range_impl(*this, __x); |
| 634 | } | 650 | } |
| 635 | 651 | ||
| 636 | template <class _Kp> | 652 | template <class _Kp> |
| 637 | requires __is_transparent_v<_Compare> | 653 | requires __is_transparent_v<_Compare> |
| 638 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _Kp& __x) { | 654 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> |
| 655 | equal_range(const _Kp& __x) { | ||
| 639 | return __equal_range_impl(*this, __x); | 656 | return __equal_range_impl(*this, __x); |
| 640 | } | 657 | } |
| 641 | template <class _Kp> | 658 | template <class _Kp> |
| 642 | requires __is_transparent_v<_Compare> | 659 | requires __is_transparent_v<_Compare> |
| 643 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> | 660 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 644 | equal_range(const _Kp& __x) const { | 661 | equal_range(const _Kp& __x) const { |
| 645 | return __equal_range_impl(*this, __x); | 662 | return __equal_range_impl(*this, __x); |
| 646 | } | 663 | } |
| ... | @@ -655,13 +672,14 @@ public: | ... | @@ -655,13 +672,14 @@ public: |
| 655 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 672 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 656 | } | 673 | } |
| 657 | 674 | ||
| 658 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __x, flat_set& __y) noexcept { | 675 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 676 | swap(flat_set& __x, flat_set& __y) noexcept(noexcept(__x.swap(__y))) { | ||
| 659 | __x.swap(__y); | 677 | __x.swap(__y); |
| 660 | } | 678 | } |
| 661 | 679 | ||
| 662 | private: | 680 | private: |
| 663 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const { | 681 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const { |
| 664 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); }; | 682 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) -> bool { return !__compare_(__x, __y); }; |
| 665 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); | 683 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); |
| 666 | } | 684 | } |
| 667 | 685 | ||
| ... | @@ -774,19 +792,19 @@ private: | ... | @@ -774,19 +792,19 @@ private: |
| 774 | }; | 792 | }; |
| 775 | 793 | ||
| 776 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | 794 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 777 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 795 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 778 | is_invocable_v<const _Compare&, | 796 | is_invocable_v<const _Compare&, |
| 779 | const typename _KeyContainer::value_type&, | 797 | const typename _KeyContainer::value_type&, |
| 780 | const typename _KeyContainer::value_type&>) | 798 | const typename _KeyContainer::value_type&>) |
| 781 | flat_set(_KeyContainer, _Compare = _Compare()) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 799 | flat_set(_KeyContainer, _Compare = _Compare()) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 782 | 800 | ||
| 783 | template <class _KeyContainer, class _Allocator> | 801 | template <class _KeyContainer, class _Allocator> |
| 784 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | 802 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator_v<_KeyContainer>) |
| 785 | flat_set(_KeyContainer, _Allocator) | 803 | flat_set(_KeyContainer, _Allocator) |
| 786 | -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | 804 | -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; |
| 787 | 805 | ||
| 788 | template <class _KeyContainer, class _Compare, class _Allocator> | 806 | template <class _KeyContainer, class _Compare, class _Allocator> |
| 789 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 807 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 790 | uses_allocator_v<_KeyContainer, _Allocator> && | 808 | uses_allocator_v<_KeyContainer, _Allocator> && |
| 791 | is_invocable_v<const _Compare&, | 809 | is_invocable_v<const _Compare&, |
| 792 | const typename _KeyContainer::value_type&, | 810 | const typename _KeyContainer::value_type&, |
| ... | @@ -794,7 +812,7 @@ template <class _KeyContainer, class _Compare, class _Allocator> | ... | @@ -794,7 +812,7 @@ template <class _KeyContainer, class _Compare, class _Allocator> |
| 794 | flat_set(_KeyContainer, _Compare, _Allocator) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 812 | flat_set(_KeyContainer, _Compare, _Allocator) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 795 | 813 | ||
| 796 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | 814 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> |
| 797 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 815 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 798 | is_invocable_v<const _Compare&, | 816 | is_invocable_v<const _Compare&, |
| 799 | const typename _KeyContainer::value_type&, | 817 | const typename _KeyContainer::value_type&, |
| 800 | const typename _KeyContainer::value_type&>) | 818 | const typename _KeyContainer::value_type&>) |
| ... | @@ -802,12 +820,12 @@ flat_set(sorted_unique_t, _KeyContainer, _Compare = _Compare()) | ... | @@ -802,12 +820,12 @@ flat_set(sorted_unique_t, _KeyContainer, _Compare = _Compare()) |
| 802 | -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 820 | -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 803 | 821 | ||
| 804 | template <class _KeyContainer, class _Allocator> | 822 | template <class _KeyContainer, class _Allocator> |
| 805 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | 823 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator_v<_KeyContainer>) |
| 806 | flat_set(sorted_unique_t, _KeyContainer, _Allocator) | 824 | flat_set(sorted_unique_t, _KeyContainer, _Allocator) |
| 807 | -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | 825 | -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; |
| 808 | 826 | ||
| 809 | template <class _KeyContainer, class _Compare, class _Allocator> | 827 | template <class _KeyContainer, class _Compare, class _Allocator> |
| 810 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | 828 | requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && |
| 811 | uses_allocator_v<_KeyContainer, _Allocator> && | 829 | uses_allocator_v<_KeyContainer, _Allocator> && |
| 812 | is_invocable_v<const _Compare&, | 830 | is_invocable_v<const _Compare&, |
| 813 | const typename _KeyContainer::value_type&, | 831 | const typename _KeyContainer::value_type&, |
| ... | @@ -815,37 +833,37 @@ template <class _KeyContainer, class _Compare, class _Allocator> | ... | @@ -815,37 +833,37 @@ template <class _KeyContainer, class _Compare, class _Allocator> |
| 815 | flat_set(sorted_unique_t, _KeyContainer, _Compare, _Allocator) | 833 | flat_set(sorted_unique_t, _KeyContainer, _Compare, _Allocator) |
| 816 | -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | 834 | -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; |
| 817 | 835 | ||
| 818 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | 836 | template <class _InputIterator, class _Compare = less<__iterator_value_type<_InputIterator>>> |
| 819 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 837 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 820 | flat_set(_InputIterator, _InputIterator, _Compare = _Compare()) | 838 | flat_set(_InputIterator, _InputIterator, _Compare = _Compare()) |
| 821 | -> flat_set<__iter_value_type<_InputIterator>, _Compare>; | 839 | -> flat_set<__iterator_value_type<_InputIterator>, _Compare>; |
| 822 | 840 | ||
| 823 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | 841 | template <class _InputIterator, class _Compare = less<__iterator_value_type<_InputIterator>>> |
| 824 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | 842 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>) |
| 825 | flat_set(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare()) | 843 | flat_set(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare()) |
| 826 | -> flat_set<__iter_value_type<_InputIterator>, _Compare>; | 844 | -> flat_set<__iterator_value_type<_InputIterator>, _Compare>; |
| 827 | 845 | ||
| 828 | template <ranges::input_range _Range, | 846 | template <ranges::input_range _Range, |
| 829 | class _Compare = less<ranges::range_value_t<_Range>>, | 847 | class _Compare = less<ranges::range_value_t<_Range>>, |
| 830 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | 848 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 831 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | 849 | class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>> |
| 832 | flat_set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_set< | 850 | flat_set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_set< |
| 833 | ranges::range_value_t<_Range>, | 851 | ranges::range_value_t<_Range>, |
| 834 | _Compare, | 852 | _Compare, |
| 835 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | 853 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; |
| 836 | 854 | ||
| 837 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | 855 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>> |
| 838 | flat_set(from_range_t, _Range&&, _Allocator) -> flat_set< | 856 | flat_set(from_range_t, _Range&&, _Allocator) -> flat_set< |
| 839 | ranges::range_value_t<_Range>, | 857 | ranges::range_value_t<_Range>, |
| 840 | less<ranges::range_value_t<_Range>>, | 858 | less<ranges::range_value_t<_Range>>, |
| 841 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | 859 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; |
| 842 | 860 | ||
| 843 | template <class _Key, class _Compare = less<_Key>> | 861 | template <class _Key, class _Compare = less<_Key>> |
| 844 | requires(!__is_allocator<_Compare>::value) | 862 | requires(!__is_allocator_v<_Compare>) |
| 845 | flat_set(initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>; | 863 | flat_set(initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>; |
| 846 | 864 | ||
| 847 | template <class _Key, class _Compare = less<_Key>> | 865 | template <class _Key, class _Compare = less<_Key>> |
| 848 | requires(!__is_allocator<_Compare>::value) | 866 | requires(!__is_allocator_v<_Compare>) |
| 849 | flat_set(sorted_unique_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>; | 867 | flat_set(sorted_unique_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>; |
| 850 | 868 | ||
| 851 | template <class _Key, class _Compare, class _KeyContainer, class _Allocator> | 869 | template <class _Key, class _Compare, class _KeyContainer, class _Allocator> |
lib/libcxx/include/__format/concepts.h-14| ... | @@ -15,12 +15,8 @@ | ... | @@ -15,12 +15,8 @@ |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__format/format_parse_context.h> | 16 | #include <__format/format_parse_context.h> |
| 17 | #include <__fwd/format.h> | 17 | #include <__fwd/format.h> |
| 18 | #include <__fwd/tuple.h> | ||
| 19 | #include <__tuple/tuple_size.h> | ||
| 20 | #include <__type_traits/is_specialization.h> | ||
| 21 | #include <__type_traits/remove_const.h> | 18 | #include <__type_traits/remove_const.h> |
| 22 | #include <__type_traits/remove_reference.h> | 19 | #include <__type_traits/remove_reference.h> |
| 23 | #include <__utility/pair.h> | ||
| 24 | 20 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -65,16 +61,6 @@ concept __formattable = | ... | @@ -65,16 +61,6 @@ concept __formattable = |
| 65 | # if _LIBCPP_STD_VER >= 23 | 61 | # if _LIBCPP_STD_VER >= 23 |
| 66 | template <class _Tp, class _CharT> | 62 | template <class _Tp, class _CharT> |
| 67 | concept formattable = __formattable<_Tp, _CharT>; | 63 | concept formattable = __formattable<_Tp, _CharT>; |
| 68 | |||
| 69 | // [tuple.like] defines a tuple-like exposition only concept. This concept is | ||
| 70 | // not related to that. Therefore it uses a different name for the concept. | ||
| 71 | // | ||
| 72 | // TODO FMT Add a test to validate we fail when using that concept after P2165 | ||
| 73 | // has been implemented. | ||
| 74 | template <class _Tp> | ||
| 75 | concept __fmt_pair_like = | ||
| 76 | __is_specialization_v<_Tp, pair> || (__is_specialization_v<_Tp, tuple> && tuple_size_v<_Tp> == 2); | ||
| 77 | |||
| 78 | # endif // _LIBCPP_STD_VER >= 23 | 64 | # endif // _LIBCPP_STD_VER >= 23 |
| 79 | #endif // _LIBCPP_STD_VER >= 20 | 65 | #endif // _LIBCPP_STD_VER >= 20 |
| 80 | 66 |
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+3-2| ... | @@ -61,7 +61,7 @@ | ... | @@ -61,7 +61,7 @@ |
| 61 | #ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H | 61 | #ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H |
| 62 | #define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H | 62 | #define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H |
| 63 | 63 | ||
| 64 | #include <__algorithm/ranges_upper_bound.h> | 64 | #include <__algorithm/upper_bound.h> |
| 65 | #include <__config> | 65 | #include <__config> |
| 66 | #include <__cstddef/ptrdiff_t.h> | 66 | #include <__cstddef/ptrdiff_t.h> |
| 67 | #include <__iterator/access.h> | 67 | #include <__iterator/access.h> |
| ... | @@ -1647,7 +1647,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1501] = { | ... | @@ -1647,7 +1647,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1501] = { |
| 1647 | // size. Then the upper bound for code point 3 will return the entry after | 1647 | // size. Then the upper bound for code point 3 will return the entry after |
| 1648 | // 0x1810. After moving to the previous entry the algorithm arrives at the | 1648 | // 0x1810. After moving to the previous entry the algorithm arrives at the |
| 1649 | // correct entry. | 1649 | // correct entry. |
| 1650 | ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries; | 1650 | ptrdiff_t __i = |
| 1651 | std::upper_bound(std::begin(__entries), std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries; | ||
| 1651 | if (__i == 0) | 1652 | if (__i == 0) |
| 1652 | return __property::__none; | 1653 | return __property::__none; |
| 1653 | 1654 |
lib/libcxx/include/__format/fmt_pair_like.h created+42| ... | @@ -0,0 +1,42 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___FORMAT_FMT_PAIR_LIKE_H | ||
| 11 | #define _LIBCPP___FORMAT_FMT_PAIR_LIKE_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__fwd/pair.h> | ||
| 15 | #include <__fwd/tuple.h> | ||
| 16 | #include <__tuple/tuple_size.h> | ||
| 17 | #include <__type_traits/is_specialization.h> | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | #endif | ||
| 22 | |||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 24 | |||
| 25 | #if _LIBCPP_STD_VER >= 23 | ||
| 26 | |||
| 27 | // [tuple.like] defines a tuple-like exposition only concept. This concept is not related to that. Therefore it uses a | ||
| 28 | // different name for the concept. | ||
| 29 | // | ||
| 30 | // TODO FMT Add a test to validate we fail when using that concept after P2165 has been implemented. | ||
| 31 | |||
| 32 | // [format.range.fmtkind]/2.2.1 and [tab:formatter.range.type]: | ||
| 33 | // "U is either a specialization of pair or a specialization of tuple such that tuple_size_v<U> is 2." | ||
| 34 | template <class _Tp> | ||
| 35 | concept __fmt_pair_like = | ||
| 36 | __is_specialization_v<_Tp, pair> || (__is_specialization_v<_Tp, tuple> && tuple_size_v<_Tp> == 2); | ||
| 37 | |||
| 38 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 39 | |||
| 40 | _LIBCPP_END_NAMESPACE_STD | ||
| 41 | |||
| 42 | #endif // _LIBCPP___FORMAT_FMT_PAIR_LIKE_H | ||
lib/libcxx/include/__format/format_arg.h+7-10| ... | @@ -149,7 +149,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ | ... | @@ -149,7 +149,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ |
| 149 | __libcpp_unreachable(); | 149 | __libcpp_unreachable(); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 152 | # if _LIBCPP_STD_VER >= 26 |
| 153 | 153 | ||
| 154 | template <class _Rp, class _Visitor, class _Context> | 154 | template <class _Rp, class _Visitor, class _Context> |
| 155 | _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { | 155 | _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { |
| ... | @@ -200,7 +200,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< | ... | @@ -200,7 +200,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< |
| 200 | __libcpp_unreachable(); | 200 | __libcpp_unreachable(); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 203 | # endif // _LIBCPP_STD_VER >= 26 |
| 204 | 204 | ||
| 205 | /// Contains the values used in basic_format_arg. | 205 | /// Contains the values used in basic_format_arg. |
| 206 | /// | 206 | /// |
| ... | @@ -285,7 +285,7 @@ public: | ... | @@ -285,7 +285,7 @@ public: |
| 285 | 285 | ||
| 286 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; } | 286 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; } |
| 287 | 287 | ||
| 288 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 288 | # if _LIBCPP_STD_VER >= 26 |
| 289 | 289 | ||
| 290 | // This function is user facing, so it must wrap the non-standard types of | 290 | // This function is user facing, so it must wrap the non-standard types of |
| 291 | // the "variant" in a handle to stay conforming. See __arg_t for more details. | 291 | // the "variant" in a handle to stay conforming. See __arg_t for more details. |
| ... | @@ -329,7 +329,7 @@ public: | ... | @@ -329,7 +329,7 @@ public: |
| 329 | } | 329 | } |
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 332 | # endif // _LIBCPP_STD_VER >= 26 |
| 333 | 333 | ||
| 334 | private: | 334 | private: |
| 335 | using char_type = typename _Context::char_type; | 335 | using char_type = typename _Context::char_type; |
| ... | @@ -371,11 +371,8 @@ private: | ... | @@ -371,11 +371,8 @@ private: |
| 371 | // This function is user facing, so it must wrap the non-standard types of | 371 | // This function is user facing, so it must wrap the non-standard types of |
| 372 | // the "variant" in a handle to stay conforming. See __arg_t for more details. | 372 | // the "variant" in a handle to stay conforming. See __arg_t for more details. |
| 373 | template <class _Visitor, class _Context> | 373 | template <class _Visitor, class _Context> |
| 374 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 374 | _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_HIDE_FROM_ABI decltype(auto) |
| 375 | _LIBCPP_DEPRECATED_IN_CXX26 | 375 | visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { |
| 376 | # endif | ||
| 377 | _LIBCPP_HIDE_FROM_ABI decltype(auto) | ||
| 378 | visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { | ||
| 379 | switch (__arg.__type_) { | 376 | switch (__arg.__type_) { |
| 380 | # if _LIBCPP_HAS_INT128 | 377 | # if _LIBCPP_HAS_INT128 |
| 381 | case __format::__arg_t::__i128: { | 378 | case __format::__arg_t::__i128: { |
| ... | @@ -387,7 +384,7 @@ _LIBCPP_DEPRECATED_IN_CXX26 | ... | @@ -387,7 +384,7 @@ _LIBCPP_DEPRECATED_IN_CXX26 |
| 387 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; | 384 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; |
| 388 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); | 385 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); |
| 389 | } | 386 | } |
| 390 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 387 | # endif // _LIBCPP_HAS_INT128 |
| 391 | default: | 388 | default: |
| 392 | return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); | 389 | return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); |
| 393 | } | 390 | } |
lib/libcxx/include/__format/format_args.h+1-1| ... | @@ -40,7 +40,7 @@ public: | ... | @@ -40,7 +40,7 @@ public: |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> get(size_t __id) const noexcept { | 43 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> get(size_t __id) const noexcept { |
| 44 | if (__id >= __size_) | 44 | if (__id >= __size_) |
| 45 | return basic_format_arg<_Context>{}; | 45 | return basic_format_arg<_Context>{}; |
| 46 | 46 |
lib/libcxx/include/__format/format_context.h+5-5| ... | @@ -80,17 +80,17 @@ public: | ... | @@ -80,17 +80,17 @@ public: |
| 80 | template <class _Tp> | 80 | template <class _Tp> |
| 81 | using formatter_type = formatter<_Tp, _CharT>; | 81 | using formatter_type = formatter<_Tp, _CharT>; |
| 82 | 82 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept { | 83 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept { |
| 84 | return __args_.get(__id); | 84 | return __args_.get(__id); |
| 85 | } | 85 | } |
| 86 | # if _LIBCPP_HAS_LOCALIZATION | 86 | # if _LIBCPP_HAS_LOCALIZATION |
| 87 | _LIBCPP_HIDE_FROM_ABI std::locale locale() { | 87 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI std::locale locale() { |
| 88 | if (!__loc_) | 88 | if (!__loc_) |
| 89 | __loc_ = std::locale{}; | 89 | __loc_ = std::locale{}; |
| 90 | return *__loc_; | 90 | return *__loc_; |
| 91 | } | 91 | } |
| 92 | # endif | 92 | # endif |
| 93 | _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); } | 93 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); } |
| 94 | _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); } | 94 | _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); } |
| 95 | 95 | ||
| 96 | private: | 96 | private: |
| ... | @@ -175,13 +175,13 @@ public: | ... | @@ -175,13 +175,13 @@ public: |
| 175 | __format::__determine_arg_t<basic_format_context, decltype(__arg)>(), | 175 | __format::__determine_arg_t<basic_format_context, decltype(__arg)>(), |
| 176 | __basic_format_arg_value<basic_format_context>(__arg)}; | 176 | __basic_format_arg_value<basic_format_context>(__arg)}; |
| 177 | }; | 177 | }; |
| 178 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 178 | # if _LIBCPP_STD_VER >= 26 |
| 179 | return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor)); | 179 | return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor)); |
| 180 | # else | 180 | # else |
| 181 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 181 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 182 | return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id)); | 182 | return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id)); |
| 183 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 183 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 184 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 184 | # endif // _LIBCPP_STD_VER >= 26 |
| 185 | }) { | 185 | }) { |
| 186 | } | 186 | } |
| 187 | 187 |
lib/libcxx/include/__format/format_parse_context.h+2-2| ... | @@ -41,8 +41,8 @@ public: | ... | @@ -41,8 +41,8 @@ public: |
| 41 | basic_format_parse_context(const basic_format_parse_context&) = delete; | 41 | basic_format_parse_context(const basic_format_parse_context&) = delete; |
| 42 | basic_format_parse_context& operator=(const basic_format_parse_context&) = delete; | 42 | basic_format_parse_context& operator=(const basic_format_parse_context&) = delete; |
| 43 | 43 | ||
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept { return __begin_; } | 44 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept { return __begin_; } |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept { return __end_; } | 45 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept { return __end_; } |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(const_iterator __it) { __begin_ = __it; } | 46 | _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(const_iterator __it) { __begin_ = __it; } |
| 47 | 47 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() { | 48 | _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() { |
lib/libcxx/include/__format/formatter_output.h+30-34| ... | @@ -45,7 +45,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -45,7 +45,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 45 | 45 | ||
| 46 | namespace __formatter { | 46 | namespace __formatter { |
| 47 | 47 | ||
| 48 | struct _LIBCPP_EXPORTED_FROM_ABI __padding_size_result { | 48 | struct __padding_size_result { |
| 49 | size_t __before_; | 49 | size_t __before_; |
| 50 | size_t __after_; | 50 | size_t __after_; |
| 51 | }; | 51 | }; |
| ... | @@ -151,45 +151,41 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value) | ... | @@ -151,45 +151,41 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value) |
| 151 | } | 151 | } |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | # if _LIBCPP_HAS_UNICODE | ||
| 155 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> | 154 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> |
| 156 | requires(same_as<_CharT, char>) | ||
| 157 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { | 155 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { |
| 158 | std::size_t __bytes = std::countl_one(static_cast<unsigned char>(__value.__data[0])); | 156 | # if _LIBCPP_HAS_UNICODE |
| 159 | if (__bytes == 0) | 157 | if constexpr (same_as<_CharT, char>) { |
| 160 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); | 158 | std::size_t __bytes = std::countl_one(static_cast<unsigned char>(__value.__data[0])); |
| 161 | 159 | if (__bytes == 0) | |
| 162 | for (size_t __i = 0; __i < __n; ++__i) | 160 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); |
| 163 | __out_it = __formatter::__copy( | 161 | |
| 164 | std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + __bytes, std::move(__out_it)); | 162 | for (size_t __i = 0; __i < __n; ++__i) |
| 165 | return __out_it; | 163 | __out_it = __formatter::__copy( |
| 166 | } | 164 | std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + __bytes, std::move(__out_it)); |
| 167 | 165 | return __out_it; | |
| 168 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 166 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 169 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> | 167 | } else if constexpr (same_as<_CharT, wchar_t>) { |
| 170 | requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) | 168 | if constexpr (sizeof(wchar_t) == 2) { |
| 171 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { | 169 | if (!__unicode::__is_high_surrogate(__value.__data[0])) |
| 172 | if (!__unicode::__is_high_surrogate(__value.__data[0])) | 170 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); |
| 173 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); | 171 | |
| 174 | 172 | for (size_t __i = 0; __i < __n; ++__i) | |
| 175 | for (size_t __i = 0; __i < __n; ++__i) | 173 | __out_it = __formatter::__copy( |
| 176 | __out_it = __formatter::__copy( | 174 | std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + 2, std::move(__out_it)); |
| 177 | std::addressof(__value.__data[0]), std::addressof(__value.__data[0]) + 2, std::move(__out_it)); | 175 | return __out_it; |
| 178 | return __out_it; | 176 | } else if constexpr (sizeof(wchar_t) == 4) { |
| 179 | } | 177 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); |
| 180 | 178 | } else { | |
| 181 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> | 179 | static_assert(false, "expected sizeof(wchar_t) to be 2 or 4"); |
| 182 | requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) | 180 | } |
| 183 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { | ||
| 184 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); | ||
| 185 | } | ||
| 186 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 181 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 187 | # else // _LIBCPP_HAS_UNICODE | 182 | } else { |
| 188 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> | 183 | static_assert(false, "Unexpected CharT"); |
| 189 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { | 184 | } |
| 185 | # else // _LIBCPP_HAS_UNICODE | ||
| 190 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); | 186 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); |
| 187 | # endif // _LIBCPP_HAS_UNICODE | ||
| 191 | } | 188 | } |
| 192 | # endif // _LIBCPP_HAS_UNICODE | ||
| 193 | 189 | ||
| 194 | /// Writes the input to the output with the required padding. | 190 | /// Writes the input to the output with the required padding. |
| 195 | /// | 191 | /// |
lib/libcxx/include/__format/indic_conjunct_break_table.h+3-2| ... | @@ -61,7 +61,7 @@ | ... | @@ -61,7 +61,7 @@ |
| 61 | #ifndef _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H | 61 | #ifndef _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H |
| 62 | #define _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H | 62 | #define _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H |
| 63 | 63 | ||
| 64 | #include <__algorithm/ranges_upper_bound.h> | 64 | #include <__algorithm/upper_bound.h> |
| 65 | #include <__config> | 65 | #include <__config> |
| 66 | #include <__cstddef/ptrdiff_t.h> | 66 | #include <__cstddef/ptrdiff_t.h> |
| 67 | #include <__iterator/access.h> | 67 | #include <__iterator/access.h> |
| ... | @@ -531,7 +531,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[403] = { | ... | @@ -531,7 +531,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[403] = { |
| 531 | // size. Then the upper bound for code point 3 will return the entry after | 531 | // size. Then the upper bound for code point 3 will return the entry after |
| 532 | // 0x1810. After moving to the previous entry the algorithm arrives at the | 532 | // 0x1810. After moving to the previous entry the algorithm arrives at the |
| 533 | // correct entry. | 533 | // correct entry. |
| 534 | ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries; | 534 | ptrdiff_t __i = |
| 535 | std::upper_bound(std::begin(__entries), std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries; | ||
| 535 | if (__i == 0) | 536 | if (__i == 0) |
| 536 | return __property::__none; | 537 | return __property::__none; |
| 537 | 538 |
lib/libcxx/include/__format/range_default_formatter.h+2-41| ... | @@ -16,10 +16,11 @@ | ... | @@ -16,10 +16,11 @@ |
| 16 | 16 | ||
| 17 | #include <__algorithm/ranges_copy.h> | 17 | #include <__algorithm/ranges_copy.h> |
| 18 | #include <__chrono/statically_widen.h> | 18 | #include <__chrono/statically_widen.h> |
| 19 | #include <__concepts/same_as.h> | ||
| 20 | #include <__config> | 19 | #include <__config> |
| 21 | #include <__format/concepts.h> | 20 | #include <__format/concepts.h> |
| 21 | #include <__format/fmt_pair_like.h> | ||
| 22 | #include <__format/formatter.h> | 22 | #include <__format/formatter.h> |
| 23 | #include <__format/range_format.h> | ||
| 23 | #include <__format/range_formatter.h> | 24 | #include <__format/range_formatter.h> |
| 24 | #include <__iterator/back_insert_iterator.h> | 25 | #include <__iterator/back_insert_iterator.h> |
| 25 | #include <__ranges/concepts.h> | 26 | #include <__ranges/concepts.h> |
| ... | @@ -42,51 +43,11 @@ concept __const_formattable_range = | ... | @@ -42,51 +43,11 @@ concept __const_formattable_range = |
| 42 | template <class _Rp, class _CharT> | 43 | template <class _Rp, class _CharT> |
| 43 | using __fmt_maybe_const _LIBCPP_NODEBUG = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>; | 44 | using __fmt_maybe_const _LIBCPP_NODEBUG = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>; |
| 44 | 45 | ||
| 45 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 46 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow") | ||
| 47 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshadow") | ||
| 48 | // This shadows map, set, and string. | ||
| 49 | enum class range_format { disabled, map, set, sequence, string, debug_string }; | ||
| 50 | _LIBCPP_DIAGNOSTIC_POP | ||
| 51 | |||
| 52 | // There is no definition of this struct, it's purely intended to be used to | 46 | // There is no definition of this struct, it's purely intended to be used to |
| 53 | // generate diagnostics. | 47 | // generate diagnostics. |
| 54 | template <class _Rp> | 48 | template <class _Rp> |
| 55 | struct __instantiated_the_primary_template_of_format_kind; | 49 | struct __instantiated_the_primary_template_of_format_kind; |
| 56 | 50 | ||
| 57 | template <class _Rp> | ||
| 58 | constexpr range_format format_kind = [] { | ||
| 59 | // [format.range.fmtkind]/1 | ||
| 60 | // A program that instantiates the primary template of format_kind is ill-formed. | ||
| 61 | static_assert(sizeof(_Rp) != sizeof(_Rp), "create a template specialization of format_kind for your type"); | ||
| 62 | return range_format::disabled; | ||
| 63 | }(); | ||
| 64 | |||
| 65 | template <ranges::input_range _Rp> | ||
| 66 | requires same_as<_Rp, remove_cvref_t<_Rp>> | ||
| 67 | inline constexpr range_format format_kind<_Rp> = [] { | ||
| 68 | // [format.range.fmtkind]/2 | ||
| 69 | |||
| 70 | // 2.1 If same_as<remove_cvref_t<ranges::range_reference_t<R>>, R> is true, | ||
| 71 | // Otherwise format_kind<R> is range_format::disabled. | ||
| 72 | if constexpr (same_as<remove_cvref_t<ranges::range_reference_t<_Rp>>, _Rp>) | ||
| 73 | return range_format::disabled; | ||
| 74 | // 2.2 Otherwise, if the qualified-id R::key_type is valid and denotes a type: | ||
| 75 | else if constexpr (requires { typename _Rp::key_type; }) { | ||
| 76 | // 2.2.1 If the qualified-id R::mapped_type is valid and denotes a type ... | ||
| 77 | if constexpr (requires { typename _Rp::mapped_type; } && | ||
| 78 | // 2.2.1 ... If either U is a specialization of pair or U is a specialization | ||
| 79 | // of tuple and tuple_size_v<U> == 2 | ||
| 80 | __fmt_pair_like<remove_cvref_t<ranges::range_reference_t<_Rp>>>) | ||
| 81 | return range_format::map; | ||
| 82 | else | ||
| 83 | // 2.2.2 Otherwise format_kind<R> is range_format::set. | ||
| 84 | return range_format::set; | ||
| 85 | } else | ||
| 86 | // 2.3 Otherwise, format_kind<R> is range_format::sequence. | ||
| 87 | return range_format::sequence; | ||
| 88 | }(); | ||
| 89 | |||
| 90 | template <range_format _Kp, ranges::input_range _Rp, class _CharT> | 51 | template <range_format _Kp, ranges::input_range _Rp, class _CharT> |
| 91 | struct __range_default_formatter; | 52 | struct __range_default_formatter; |
| 92 | 53 |
lib/libcxx/include/__format/range_format.h created+71| ... | @@ -0,0 +1,71 @@ | ||
| 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_RANGE_FORMAT_H | ||
| 11 | #define _LIBCPP___FORMAT_RANGE_FORMAT_H | ||
| 12 | |||
| 13 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 14 | # pragma GCC system_header | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #include <__concepts/same_as.h> | ||
| 18 | #include <__config> | ||
| 19 | #include <__format/fmt_pair_like.h> | ||
| 20 | #include <__ranges/concepts.h> | ||
| 21 | #include <__type_traits/remove_cvref.h> | ||
| 22 | |||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 24 | |||
| 25 | #if _LIBCPP_STD_VER >= 23 | ||
| 26 | |||
| 27 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 28 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow") | ||
| 29 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshadow") | ||
| 30 | // This shadows map, set, and string. | ||
| 31 | enum class range_format { disabled, map, set, sequence, string, debug_string }; | ||
| 32 | _LIBCPP_DIAGNOSTIC_POP | ||
| 33 | |||
| 34 | template <class _Rp> | ||
| 35 | constexpr range_format format_kind = [] { | ||
| 36 | // [format.range.fmtkind]/1 | ||
| 37 | // A program that instantiates the primary template of format_kind is ill-formed. | ||
| 38 | static_assert(sizeof(_Rp) != sizeof(_Rp), "create a template specialization of format_kind for your type"); | ||
| 39 | return range_format::disabled; | ||
| 40 | }(); | ||
| 41 | |||
| 42 | template <ranges::input_range _Rp> | ||
| 43 | requires same_as<_Rp, remove_cvref_t<_Rp>> | ||
| 44 | inline constexpr range_format format_kind<_Rp> = [] { | ||
| 45 | // [format.range.fmtkind]/2 | ||
| 46 | |||
| 47 | // 2.1 If same_as<remove_cvref_t<ranges::range_reference_t<R>>, R> is true, | ||
| 48 | // Otherwise format_kind<R> is range_format::disabled. | ||
| 49 | if constexpr (same_as<remove_cvref_t<ranges::range_reference_t<_Rp>>, _Rp>) | ||
| 50 | return range_format::disabled; | ||
| 51 | // 2.2 Otherwise, if the qualified-id R::key_type is valid and denotes a type: | ||
| 52 | else if constexpr (requires { typename _Rp::key_type; }) { | ||
| 53 | // 2.2.1 If the qualified-id R::mapped_type is valid and denotes a type ... | ||
| 54 | if constexpr (requires { typename _Rp::mapped_type; } && | ||
| 55 | // 2.2.1 ... If either U is a specialization of pair or U is a specialization | ||
| 56 | // of tuple and tuple_size_v<U> == 2 | ||
| 57 | __fmt_pair_like<remove_cvref_t<ranges::range_reference_t<_Rp>>>) | ||
| 58 | return range_format::map; | ||
| 59 | else | ||
| 60 | // 2.2.2 Otherwise format_kind<R> is range_format::set. | ||
| 61 | return range_format::set; | ||
| 62 | } else | ||
| 63 | // 2.3 Otherwise, format_kind<R> is range_format::sequence. | ||
| 64 | return range_format::sequence; | ||
| 65 | }(); | ||
| 66 | |||
| 67 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 68 | |||
| 69 | _LIBCPP_END_NAMESPACE_STD | ||
| 70 | |||
| 71 | #endif | ||
lib/libcxx/include/__format/range_formatter.h+1| ... | @@ -20,6 +20,7 @@ | ... | @@ -20,6 +20,7 @@ |
| 20 | #include <__config> | 20 | #include <__config> |
| 21 | #include <__format/buffer.h> | 21 | #include <__format/buffer.h> |
| 22 | #include <__format/concepts.h> | 22 | #include <__format/concepts.h> |
| 23 | #include <__format/fmt_pair_like.h> | ||
| 23 | #include <__format/format_context.h> | 24 | #include <__format/format_context.h> |
| 24 | #include <__format/format_error.h> | 25 | #include <__format/format_error.h> |
| 25 | #include <__format/formatter.h> | 26 | #include <__format/formatter.h> |
lib/libcxx/include/__format/width_estimation_table.h+4-2| ... | @@ -61,9 +61,10 @@ | ... | @@ -61,9 +61,10 @@ |
| 61 | #ifndef _LIBCPP___FORMAT_WIDTH_ESTIMATION_TABLE_H | 61 | #ifndef _LIBCPP___FORMAT_WIDTH_ESTIMATION_TABLE_H |
| 62 | #define _LIBCPP___FORMAT_WIDTH_ESTIMATION_TABLE_H | 62 | #define _LIBCPP___FORMAT_WIDTH_ESTIMATION_TABLE_H |
| 63 | 63 | ||
| 64 | #include <__algorithm/ranges_upper_bound.h> | 64 | #include <__algorithm/upper_bound.h> |
| 65 | #include <__config> | 65 | #include <__config> |
| 66 | #include <__cstddef/ptrdiff_t.h> | 66 | #include <__cstddef/ptrdiff_t.h> |
| 67 | #include <__iterator/access.h> | ||
| 67 | #include <cstdint> | 68 | #include <cstdint> |
| 68 | 69 | ||
| 69 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 70 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -255,7 +256,8 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd; | ... | @@ -255,7 +256,8 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd; |
| 255 | if (__code_point < (__entries[0] >> 14)) | 256 | if (__code_point < (__entries[0] >> 14)) |
| 256 | return 1; | 257 | return 1; |
| 257 | 258 | ||
| 258 | ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 14) | 0x3fffu) - __entries; | 259 | ptrdiff_t __i = |
| 260 | std::upper_bound(std::begin(__entries), std::end(__entries), (__code_point << 14) | 0x3fffu) - __entries; | ||
| 259 | if (__i == 0) | 261 | if (__i == 0) |
| 260 | return 1; | 262 | return 1; |
| 261 | 263 |
lib/libcxx/include/__functional/bind.h+10-15| ... | @@ -81,17 +81,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w | ... | @@ -81,17 +81,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w |
| 81 | return __t.get(); | 81 | return __t.get(); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | template <class _Ti, class... _Uj, size_t... _Indx> | ||
| 85 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...> | ||
| 86 | __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) { | ||
| 87 | return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...); | ||
| 88 | } | ||
| 89 | |||
| 90 | template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0> | 84 | template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0> |
| 91 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...> | 85 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...> |
| 92 | __mu(_Ti& __ti, tuple<_Uj...>& __uj) { | 86 | __mu(_Ti& __ti, tuple<_Uj...>& __uj) { |
| 93 | typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; | 87 | return [&]<size_t... _Indices>(__index_sequence<_Indices...>) -> __invoke_result_t<_Ti&, _Uj...> { |
| 94 | return std::__mu_expand(__ti, __uj, __indices()); | 88 | return __ti(std::forward<_Uj>(std::get<_Indices>(__uj))...); |
| 89 | }(__index_sequence_for<_Uj...>{}); | ||
| 95 | } | 90 | } |
| 96 | 91 | ||
| 97 | template <bool _IsPh, class _Ti, class _Uj> | 92 | template <bool _IsPh, class _Ti, class _Uj> |
| ... | @@ -191,7 +186,7 @@ struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> { | ... | @@ -191,7 +186,7 @@ struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> { |
| 191 | 186 | ||
| 192 | template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args> | 187 | template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args> |
| 193 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fp, _BoundArgs, _Args>::type | 188 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fp, _BoundArgs, _Args>::type |
| 194 | __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _Args&& __args) { | 189 | __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __index_sequence<_Indx...>, _Args&& __args) { |
| 195 | return std::__invoke(__f, std::__mu(std::get<_Indx>(__bound_args), __args)...); | 190 | return std::__invoke(__f, std::__mu(std::get<_Indx>(__bound_args), __args)...); |
| 196 | } | 191 | } |
| 197 | 192 | ||
| ... | @@ -205,8 +200,6 @@ private: | ... | @@ -205,8 +200,6 @@ private: |
| 205 | _Fd __f_; | 200 | _Fd __f_; |
| 206 | _Td __bound_args_; | 201 | _Td __bound_args_; |
| 207 | 202 | ||
| 208 | typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; | ||
| 209 | |||
| 210 | public: | 203 | public: |
| 211 | template < | 204 | template < |
| 212 | class _Gp, | 205 | class _Gp, |
| ... | @@ -219,14 +212,16 @@ public: | ... | @@ -219,14 +212,16 @@ public: |
| 219 | template <class... _Args> | 212 | template <class... _Args> |
| 220 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type | 213 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type |
| 221 | operator()(_Args&&... __args) { | 214 | operator()(_Args&&... __args) { |
| 222 | return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); | 215 | return std::__apply_functor( |
| 216 | __f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); | ||
| 223 | } | 217 | } |
| 224 | 218 | ||
| 225 | template <class... _Args> | 219 | template <class... _Args> |
| 226 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 220 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 227 | typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type | 221 | typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type |
| 228 | operator()(_Args&&... __args) const { | 222 | operator()(_Args&&... __args) const { |
| 229 | return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); | 223 | return std::__apply_functor( |
| 224 | __f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); | ||
| 230 | } | 225 | } |
| 231 | }; | 226 | }; |
| 232 | 227 | ||
| ... | @@ -273,14 +268,14 @@ template <class _Rp, class _Fp, class... _BoundArgs> | ... | @@ -273,14 +268,14 @@ template <class _Rp, class _Fp, class... _BoundArgs> |
| 273 | struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; | 268 | struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; |
| 274 | 269 | ||
| 275 | template <class _Fp, class... _BoundArgs> | 270 | template <class _Fp, class... _BoundArgs> |
| 276 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind<_Fp, _BoundArgs...> | 271 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind<_Fp, _BoundArgs...> |
| 277 | bind(_Fp&& __f, _BoundArgs&&... __bound_args) { | 272 | bind(_Fp&& __f, _BoundArgs&&... __bound_args) { |
| 278 | typedef __bind<_Fp, _BoundArgs...> type; | 273 | typedef __bind<_Fp, _BoundArgs...> type; |
| 279 | return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...); | 274 | return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...); |
| 280 | } | 275 | } |
| 281 | 276 | ||
| 282 | template <class _Rp, class _Fp, class... _BoundArgs> | 277 | template <class _Rp, class _Fp, class... _BoundArgs> |
| 283 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind_r<_Rp, _Fp, _BoundArgs...> | 278 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind_r<_Rp, _Fp, _BoundArgs...> |
| 284 | bind(_Fp&& __f, _BoundArgs&&... __bound_args) { | 279 | bind(_Fp&& __f, _BoundArgs&&... __bound_args) { |
| 285 | typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; | 280 | typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; |
| 286 | return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...); | 281 | return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...); |
lib/libcxx/include/__functional/bind_back.h+1-1| ... | @@ -64,7 +64,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) n | ... | @@ -64,7 +64,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) n |
| 64 | 64 | ||
| 65 | # if _LIBCPP_STD_VER >= 23 | 65 | # if _LIBCPP_STD_VER >= 23 |
| 66 | template <class _Fn, class... _Args> | 66 | template <class _Fn, class... _Args> |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr auto bind_back(_Fn&& __f, _Args&&... __args) { | 67 | [[nodiscard]] _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"); | 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"); | 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> && ...), | 70 | static_assert((is_constructible_v<decay_t<_Args>, _Args> && ...), |
lib/libcxx/include/__functional/bind_front.h+1-1| ... | @@ -43,7 +43,7 @@ struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> { | ... | @@ -43,7 +43,7 @@ struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> { |
| 43 | template <class _Fn, class... _Args> | 43 | template <class _Fn, class... _Args> |
| 44 | requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> && | 44 | requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> && |
| 45 | (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...) | 45 | (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...) |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) { | 46 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) { |
| 47 | return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(std::forward<_Fn>(__f), std::forward<_Args>(__args)...); | 47 | return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(std::forward<_Fn>(__f), std::forward<_Args>(__args)...); |
| 48 | } | 48 | } |
| 49 | 49 |
lib/libcxx/include/__functional/function.h+57-75| ... | @@ -15,16 +15,14 @@ | ... | @@ -15,16 +15,14 @@ |
| 15 | #include <__cstddef/nullptr_t.h> | 15 | #include <__cstddef/nullptr_t.h> |
| 16 | #include <__exception/exception.h> | 16 | #include <__exception/exception.h> |
| 17 | #include <__functional/binary_function.h> | 17 | #include <__functional/binary_function.h> |
| 18 | #include <__functional/invoke.h> | ||
| 19 | #include <__functional/unary_function.h> | 18 | #include <__functional/unary_function.h> |
| 20 | #include <__memory/addressof.h> | 19 | #include <__memory/addressof.h> |
| 21 | #include <__type_traits/aligned_storage.h> | 20 | #include <__type_traits/aligned_storage.h> |
| 22 | #include <__type_traits/decay.h> | 21 | #include <__type_traits/decay.h> |
| 23 | #include <__type_traits/is_core_convertible.h> | 22 | #include <__type_traits/invoke.h> |
| 24 | #include <__type_traits/is_scalar.h> | 23 | #include <__type_traits/is_scalar.h> |
| 25 | #include <__type_traits/is_trivially_constructible.h> | 24 | #include <__type_traits/is_trivially_constructible.h> |
| 26 | #include <__type_traits/is_trivially_destructible.h> | 25 | #include <__type_traits/is_trivially_destructible.h> |
| 27 | #include <__type_traits/is_void.h> | ||
| 28 | #include <__type_traits/strip_signature.h> | 26 | #include <__type_traits/strip_signature.h> |
| 29 | #include <__utility/forward.h> | 27 | #include <__utility/forward.h> |
| 30 | #include <__utility/move.h> | 28 | #include <__utility/move.h> |
| ... | @@ -95,29 +93,29 @@ template <class _Rp, class _A1, class _A2> | ... | @@ -95,29 +93,29 @@ template <class _Rp, class _A1, class _A2> |
| 95 | struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {}; | 93 | struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {}; |
| 96 | 94 | ||
| 97 | template <class _Fp> | 95 | template <class _Fp> |
| 98 | _LIBCPP_HIDE_FROM_ABI bool __not_null(_Fp const&) { | 96 | _LIBCPP_HIDE_FROM_ABI bool __is_null(_Fp const&) { |
| 99 | return true; | 97 | return false; |
| 100 | } | 98 | } |
| 101 | 99 | ||
| 102 | template <class _Fp> | 100 | template <class _Fp> |
| 103 | _LIBCPP_HIDE_FROM_ABI bool __not_null(_Fp* __ptr) { | 101 | _LIBCPP_HIDE_FROM_ABI bool __is_null(_Fp* __ptr) { |
| 104 | return __ptr; | 102 | return !__ptr; |
| 105 | } | 103 | } |
| 106 | 104 | ||
| 107 | template <class _Ret, class _Class> | 105 | template <class _Ret, class _Class> |
| 108 | _LIBCPP_HIDE_FROM_ABI bool __not_null(_Ret _Class::*__ptr) { | 106 | _LIBCPP_HIDE_FROM_ABI bool __is_null(_Ret _Class::* __ptr) { |
| 109 | return __ptr; | 107 | return !__ptr; |
| 110 | } | 108 | } |
| 111 | 109 | ||
| 112 | template <class _Fp> | 110 | template <class _Fp> |
| 113 | _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) { | 111 | _LIBCPP_HIDE_FROM_ABI bool __is_null(function<_Fp> const& __f) { |
| 114 | return !!__f; | 112 | return !__f; |
| 115 | } | 113 | } |
| 116 | 114 | ||
| 117 | # if __has_extension(blocks) | 115 | # if __has_extension(blocks) |
| 118 | template <class _Rp, class... _Args> | 116 | template <class _Rp, class... _Args> |
| 119 | _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) { | 117 | _LIBCPP_HIDE_FROM_ABI bool __is_null(_Rp (^__p)(_Args...)) { |
| 120 | return __p; | 118 | return !__p; |
| 121 | } | 119 | } |
| 122 | # endif | 120 | # endif |
| 123 | 121 | ||
| ... | @@ -206,12 +204,13 @@ public: | ... | @@ -206,12 +204,13 @@ public: |
| 206 | _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __f_(nullptr) { | 204 | _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __f_(nullptr) { |
| 207 | typedef __function::__func<_Fp, _Rp(_ArgTypes...)> _Fun; | 205 | typedef __function::__func<_Fp, _Rp(_ArgTypes...)> _Fun; |
| 208 | 206 | ||
| 209 | if (__function::__not_null(__f)) { | 207 | if (__function::__is_null(__f)) |
| 210 | if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) { | 208 | return; |
| 211 | __f_ = ::new (std::addressof(__buf_)) _Fun(std::move(__f)); | 209 | |
| 212 | } else { | 210 | if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) { |
| 213 | __f_ = new _Fun(std::move(__f)); | 211 | __f_ = ::new (std::addressof(__buf_)) _Fun(std::move(__f)); |
| 214 | } | 212 | } else { |
| 213 | __f_ = new _Fun(std::move(__f)); | ||
| 215 | } | 214 | } |
| 216 | } | 215 | } |
| 217 | 216 | ||
| ... | @@ -356,7 +355,31 @@ struct __policy { | ... | @@ -356,7 +355,31 @@ struct __policy { |
| 356 | // type. | 355 | // type. |
| 357 | template <typename _Fun> | 356 | template <typename _Fun> |
| 358 | _LIBCPP_HIDE_FROM_ABI static const __policy* __create() { | 357 | _LIBCPP_HIDE_FROM_ABI static const __policy* __create() { |
| 359 | return __choose_policy<_Fun>(__use_small_storage<_Fun>()); | 358 | if constexpr (__use_small_storage<_Fun>::value) { |
| 359 | static constexpr __policy __policy = { | ||
| 360 | nullptr, | ||
| 361 | nullptr, | ||
| 362 | false, | ||
| 363 | # if _LIBCPP_HAS_RTTI | ||
| 364 | &typeid(_Fun) | ||
| 365 | # else | ||
| 366 | nullptr | ||
| 367 | # endif | ||
| 368 | }; | ||
| 369 | return &__policy; | ||
| 370 | } else { | ||
| 371 | static constexpr __policy __policy = { | ||
| 372 | std::addressof(__large_clone<_Fun>), | ||
| 373 | std::addressof(__large_destroy<_Fun>), | ||
| 374 | false, | ||
| 375 | # if _LIBCPP_HAS_RTTI | ||
| 376 | &typeid(_Fun) | ||
| 377 | # else | ||
| 378 | nullptr | ||
| 379 | # endif | ||
| 380 | }; | ||
| 381 | return &__policy; | ||
| 382 | } | ||
| 360 | } | 383 | } |
| 361 | 384 | ||
| 362 | _LIBCPP_HIDE_FROM_ABI static const __policy* __create_empty() { | 385 | _LIBCPP_HIDE_FROM_ABI static const __policy* __create_empty() { |
| ... | @@ -384,36 +407,6 @@ private: | ... | @@ -384,36 +407,6 @@ private: |
| 384 | _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) { | 407 | _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) { |
| 385 | delete static_cast<_Fun*>(__s); | 408 | delete static_cast<_Fun*>(__s); |
| 386 | } | 409 | } |
| 387 | |||
| 388 | template <typename _Fun> | ||
| 389 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) { | ||
| 390 | static constexpr __policy __policy = { | ||
| 391 | std::addressof(__large_clone<_Fun>), | ||
| 392 | std::addressof(__large_destroy<_Fun>), | ||
| 393 | false, | ||
| 394 | # if _LIBCPP_HAS_RTTI | ||
| 395 | &typeid(_Fun) | ||
| 396 | # else | ||
| 397 | nullptr | ||
| 398 | # endif | ||
| 399 | }; | ||
| 400 | return &__policy; | ||
| 401 | } | ||
| 402 | |||
| 403 | template <typename _Fun> | ||
| 404 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ true_type) { | ||
| 405 | static constexpr __policy __policy = { | ||
| 406 | nullptr, | ||
| 407 | nullptr, | ||
| 408 | false, | ||
| 409 | # if _LIBCPP_HAS_RTTI | ||
| 410 | &typeid(_Fun) | ||
| 411 | # else | ||
| 412 | nullptr | ||
| 413 | # endif | ||
| 414 | }; | ||
| 415 | return &__policy; | ||
| 416 | } | ||
| 417 | }; | 410 | }; |
| 418 | 411 | ||
| 419 | // Used to choose between perfect forwarding or pass-by-value. Pass-by-value is | 412 | // Used to choose between perfect forwarding or pass-by-value. Pass-by-value is |
| ... | @@ -455,14 +448,15 @@ public: | ... | @@ -455,14 +448,15 @@ public: |
| 455 | 448 | ||
| 456 | template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0> | 449 | template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0> |
| 457 | _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) { | 450 | _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) { |
| 458 | if (__function::__not_null(__f)) { | 451 | if (__function::__is_null(__f)) |
| 459 | __func_ = __call_func<_Fp>; | 452 | return; |
| 460 | __policy_ = __policy::__create<_Fp>(); | 453 | |
| 461 | if (__use_small_storage<_Fp>()) { | 454 | __func_ = __call_func<_Fp>; |
| 462 | ::new ((void*)&__buf_.__small) _Fp(std::move(__f)); | 455 | __policy_ = __policy::__create<_Fp>(); |
| 463 | } else { | 456 | if (__use_small_storage<_Fp>()) { |
| 464 | __buf_.__large = ::new _Fp(std::move(__f)); | 457 | ::new ((void*)&__buf_.__small) _Fp(std::move(__f)); |
| 465 | } | 458 | } else { |
| 459 | __buf_.__large = ::new _Fp(std::move(__f)); | ||
| 466 | } | 460 | } |
| 467 | } | 461 | } |
| 468 | 462 | ||
| ... | @@ -615,21 +609,9 @@ class function<_Rp(_ArgTypes...)> | ... | @@ -615,21 +609,9 @@ class function<_Rp(_ArgTypes...)> |
| 615 | 609 | ||
| 616 | __func __f_; | 610 | __func __f_; |
| 617 | 611 | ||
| 618 | template <class _Fp, | ||
| 619 | bool = _And<_IsNotSame<__remove_cvref_t<_Fp>, function>, __is_invocable<_Fp, _ArgTypes...> >::value> | ||
| 620 | struct __callable; | ||
| 621 | template <class _Fp> | ||
| 622 | struct __callable<_Fp, true> { | ||
| 623 | static const bool value = | ||
| 624 | is_void<_Rp>::value || __is_core_convertible<__invoke_result_t<_Fp, _ArgTypes...>, _Rp>::value; | ||
| 625 | }; | ||
| 626 | template <class _Fp> | ||
| 627 | struct __callable<_Fp, false> { | ||
| 628 | static const bool value = false; | ||
| 629 | }; | ||
| 630 | |||
| 631 | template <class _Fp> | 612 | template <class _Fp> |
| 632 | using _EnableIfLValueCallable _LIBCPP_NODEBUG = __enable_if_t<__callable<_Fp&>::value>; | 613 | using _EnableIfLValueCallable _LIBCPP_NODEBUG = __enable_if_t< |
| 614 | _And<_IsNotSame<__remove_cvref_t<_Fp>, function>, __is_invocable_r<_Rp, _Fp&, _ArgTypes...>>::value>; | ||
| 633 | 615 | ||
| 634 | public: | 616 | public: |
| 635 | typedef _Rp result_type; | 617 | typedef _Rp result_type; |
| ... | @@ -690,11 +672,11 @@ public: | ... | @@ -690,11 +672,11 @@ public: |
| 690 | 672 | ||
| 691 | # if _LIBCPP_HAS_RTTI | 673 | # if _LIBCPP_HAS_RTTI |
| 692 | // function target access: | 674 | // function target access: |
| 693 | _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT; | 675 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT; |
| 694 | template <typename _Tp> | 676 | template <typename _Tp> |
| 695 | _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT; | 677 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT; |
| 696 | template <typename _Tp> | 678 | template <typename _Tp> |
| 697 | _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT; | 679 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT; |
| 698 | # endif // _LIBCPP_HAS_RTTI | 680 | # endif // _LIBCPP_HAS_RTTI |
| 699 | }; | 681 | }; |
| 700 | 682 |
lib/libcxx/include/__functional/hash.h+1-10| ... | @@ -433,13 +433,10 @@ struct __hash_impl<long double> : __scalar_hash<long double> { | ... | @@ -433,13 +433,10 @@ struct __hash_impl<long double> : __scalar_hash<long double> { |
| 433 | template <class _Tp> | 433 | template <class _Tp> |
| 434 | struct hash : public __hash_impl<_Tp> {}; | 434 | struct hash : public __hash_impl<_Tp> {}; |
| 435 | 435 | ||
| 436 | #if _LIBCPP_STD_VER >= 17 | ||
| 437 | |||
| 438 | template <> | 436 | template <> |
| 439 | struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> { | 437 | struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> { |
| 440 | _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; } | 438 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; } |
| 441 | }; | 439 | }; |
| 442 | #endif | ||
| 443 | 440 | ||
| 444 | #ifndef _LIBCPP_CXX03_LANG | 441 | #ifndef _LIBCPP_CXX03_LANG |
| 445 | template <class _Key, class _Hash> | 442 | template <class _Key, class _Hash> |
| ... | @@ -452,18 +449,12 @@ template <class _Key, class _Hash = hash<_Key> > | ... | @@ -452,18 +449,12 @@ template <class _Key, class _Hash = hash<_Key> > |
| 452 | using __has_enabled_hash _LIBCPP_NODEBUG = | 449 | using __has_enabled_hash _LIBCPP_NODEBUG = |
| 453 | integral_constant<bool, __check_hash_requirements<_Key, _Hash>::value && is_default_constructible<_Hash>::value >; | 450 | integral_constant<bool, __check_hash_requirements<_Key, _Hash>::value && is_default_constructible<_Hash>::value >; |
| 454 | 451 | ||
| 455 | # if _LIBCPP_STD_VER >= 17 | ||
| 456 | template <class _Type, class> | 452 | template <class _Type, class> |
| 457 | using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; | 453 | using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; |
| 458 | 454 | ||
| 459 | template <class _Type, class... _Keys> | 455 | template <class _Type, class... _Keys> |
| 460 | using __enable_hash_helper _LIBCPP_NODEBUG = | 456 | using __enable_hash_helper _LIBCPP_NODEBUG = |
| 461 | __enable_hash_helper_imp<_Type, __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >; | 457 | __enable_hash_helper_imp<_Type, __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >; |
| 462 | # else | ||
| 463 | template <class _Type, class...> | ||
| 464 | using __enable_hash_helper _LIBCPP_NODEBUG = _Type; | ||
| 465 | # endif | ||
| 466 | |||
| 467 | #endif // !_LIBCPP_CXX03_LANG | 458 | #endif // !_LIBCPP_CXX03_LANG |
| 468 | 459 | ||
| 469 | _LIBCPP_END_NAMESPACE_STD | 460 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__functional/identity.h+1-1| ... | @@ -44,7 +44,7 @@ struct __is_identity<reference_wrapper<const __identity> > : true_type {}; | ... | @@ -44,7 +44,7 @@ struct __is_identity<reference_wrapper<const __identity> > : true_type {}; |
| 44 | 44 | ||
| 45 | struct identity { | 45 | struct identity { |
| 46 | template <class _Tp> | 46 | template <class _Tp> |
| 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept { | 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_LIBCPP_LIFETIMEBOUND _Tp&& __t) const noexcept { |
| 48 | return std::forward<_Tp>(__t); | 48 | return std::forward<_Tp>(__t); |
| 49 | } | 49 | } |
| 50 | 50 |
lib/libcxx/include/__functional/is_transparent.h+8| ... | @@ -29,6 +29,14 @@ inline const bool __is_transparent_v<_Tp, _Key, __void_t<typename _Tp::is_transp | ... | @@ -29,6 +29,14 @@ inline const bool __is_transparent_v<_Tp, _Key, __void_t<typename _Tp::is_transp |
| 29 | 29 | ||
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | // Two types are considered transparently comparable if `comparator(key, arg)` is equivalent to `comparator(key, | ||
| 33 | // <implicit cast to KeyT>(arg))`. | ||
| 34 | // | ||
| 35 | // This is different from `__is_transparent_v`, which is only a property of the comparator and doesn't provide | ||
| 36 | // additional semantic guarantees. | ||
| 37 | template <class _Comparator, class _KeyT, class _Arg, class = void> | ||
| 38 | inline const bool __is_transparently_comparable_v = false; | ||
| 39 | |||
| 32 | _LIBCPP_END_NAMESPACE_STD | 40 | _LIBCPP_END_NAMESPACE_STD |
| 33 | 41 | ||
| 34 | #endif // _LIBCPP___FUNCTIONAL_IS_TRANSPARENT | 42 | #endif // _LIBCPP___FUNCTIONAL_IS_TRANSPARENT |
lib/libcxx/include/__functional/mem_fn.h+2-1| ... | @@ -43,7 +43,8 @@ public: | ... | @@ -43,7 +43,8 @@ public: |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | template <class _Rp, class _Tp> | 45 | template <class _Rp, class _Tp> |
| 46 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::*__pm) _NOEXCEPT { | 46 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn<_Rp _Tp::*> |
| 47 | mem_fn(_Rp _Tp::* __pm) _NOEXCEPT { | ||
| 47 | return __mem_fn<_Rp _Tp::*>(__pm); | 48 | return __mem_fn<_Rp _Tp::*>(__pm); |
| 48 | } | 49 | } |
| 49 | 50 |
lib/libcxx/include/__functional/operations.h+18| ... | @@ -15,7 +15,9 @@ | ... | @@ -15,7 +15,9 @@ |
| 15 | #include <__functional/unary_function.h> | 15 | #include <__functional/unary_function.h> |
| 16 | #include <__fwd/functional.h> | 16 | #include <__fwd/functional.h> |
| 17 | #include <__type_traits/desugars_to.h> | 17 | #include <__type_traits/desugars_to.h> |
| 18 | #include <__type_traits/is_generic_transparent_comparator.h> | ||
| 18 | #include <__type_traits/is_integral.h> | 19 | #include <__type_traits/is_integral.h> |
| 20 | #include <__type_traits/make_transparent.h> | ||
| 19 | #include <__utility/forward.h> | 21 | #include <__utility/forward.h> |
| 20 | 22 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -377,6 +379,14 @@ struct less<void> { | ... | @@ -377,6 +379,14 @@ struct less<void> { |
| 377 | typedef void is_transparent; | 379 | typedef void is_transparent; |
| 378 | }; | 380 | }; |
| 379 | 381 | ||
| 382 | template <class _Tp> | ||
| 383 | struct __make_transparent<_Tp, less<_Tp> > { | ||
| 384 | using type _LIBCPP_NODEBUG = less<>; | ||
| 385 | }; | ||
| 386 | |||
| 387 | template <> | ||
| 388 | inline const bool __is_generic_transparent_comparator_v<less<>> = true; | ||
| 389 | |||
| 380 | template <class _Tp, class _Up> | 390 | template <class _Tp, class _Up> |
| 381 | inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Up> = true; | 391 | inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Up> = true; |
| 382 | 392 | ||
| ... | @@ -466,6 +476,14 @@ struct greater<void> { | ... | @@ -466,6 +476,14 @@ struct greater<void> { |
| 466 | 476 | ||
| 467 | template <class _Tp, class _Up> | 477 | template <class _Tp, class _Up> |
| 468 | inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true; | 478 | inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true; |
| 479 | |||
| 480 | template <class _Tp> | ||
| 481 | struct __make_transparent<_Tp, greater<_Tp>> { | ||
| 482 | using type _LIBCPP_NODEBUG = greater<>; | ||
| 483 | }; | ||
| 484 | |||
| 485 | template <> | ||
| 486 | inline const bool __is_generic_transparent_comparator_v<greater<>> = true; | ||
| 469 | #endif | 487 | #endif |
| 470 | 488 | ||
| 471 | // Logical operations | 489 | // Logical operations |
lib/libcxx/include/__functional/ranges_operations.h+7| ... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
| 14 | #include <__concepts/totally_ordered.h> | 14 | #include <__concepts/totally_ordered.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__type_traits/desugars_to.h> | 16 | #include <__type_traits/desugars_to.h> |
| 17 | #include <__type_traits/is_generic_transparent_comparator.h> | ||
| 17 | #include <__utility/forward.h> | 18 | #include <__utility/forward.h> |
| 18 | 19 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -108,6 +109,12 @@ inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true; | ... | @@ -108,6 +109,12 @@ inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true; |
| 108 | template <class _Tp, class _Up> | 109 | template <class _Tp, class _Up> |
| 109 | inline const bool __desugars_to_v<__greater_tag, ranges::greater, _Tp, _Up> = true; | 110 | inline const bool __desugars_to_v<__greater_tag, ranges::greater, _Tp, _Up> = true; |
| 110 | 111 | ||
| 112 | template <> | ||
| 113 | inline const bool __is_generic_transparent_comparator_v<ranges::less> = true; | ||
| 114 | |||
| 115 | template <> | ||
| 116 | inline const bool __is_generic_transparent_comparator_v<ranges::greater> = true; | ||
| 117 | |||
| 111 | #endif // _LIBCPP_STD_VER >= 20 | 118 | #endif // _LIBCPP_STD_VER >= 20 |
| 112 | 119 | ||
| 113 | _LIBCPP_END_NAMESPACE_STD | 120 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__functional/reference_wrapper.h+7-5| ... | @@ -58,7 +58,7 @@ public: | ... | @@ -58,7 +58,7 @@ public: |
| 58 | 58 | ||
| 59 | // access | 59 | // access |
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator type&() const _NOEXCEPT { return *__f_; } | 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator type&() const _NOEXCEPT { return *__f_; } |
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 type& get() const _NOEXCEPT { return *__f_; } | 61 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 type& get() const _NOEXCEPT { return *__f_; } |
| 62 | 62 | ||
| 63 | // invoke | 63 | // invoke |
| 64 | template <class... _ArgTypes> | 64 | template <class... _ArgTypes> |
| ... | @@ -128,23 +128,25 @@ reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; | ... | @@ -128,23 +128,25 @@ reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; |
| 128 | #endif | 128 | #endif |
| 129 | 129 | ||
| 130 | template <class _Tp> | 130 | template <class _Tp> |
| 131 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<_Tp> ref(_Tp& __t) _NOEXCEPT { | 131 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 132 | _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<_Tp> ref(_Tp& __t) _NOEXCEPT { | ||
| 132 | return reference_wrapper<_Tp>(__t); | 133 | return reference_wrapper<_Tp>(__t); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | template <class _Tp> | 136 | template <class _Tp> |
| 136 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<_Tp> | 137 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<_Tp> |
| 137 | ref(reference_wrapper<_Tp> __t) _NOEXCEPT { | 138 | ref(reference_wrapper<_Tp> __t) _NOEXCEPT { |
| 138 | return __t; | 139 | return __t; |
| 139 | } | 140 | } |
| 140 | 141 | ||
| 141 | template <class _Tp> | 142 | template <class _Tp> |
| 142 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<const _Tp> cref(const _Tp& __t) _NOEXCEPT { | 143 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<const _Tp> |
| 144 | cref(const _Tp& __t) _NOEXCEPT { | ||
| 143 | return reference_wrapper<const _Tp>(__t); | 145 | return reference_wrapper<const _Tp>(__t); |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | template <class _Tp> | 148 | template <class _Tp> |
| 147 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<const _Tp> | 149 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<const _Tp> |
| 148 | cref(reference_wrapper<_Tp> __t) _NOEXCEPT { | 150 | cref(reference_wrapper<_Tp> __t) _NOEXCEPT { |
| 149 | return __t; | 151 | return __t; |
| 150 | } | 152 | } |
lib/libcxx/include/__functional/weak_result_type.h+14-28| ... | @@ -13,9 +13,9 @@ | ... | @@ -13,9 +13,9 @@ |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__functional/binary_function.h> | 14 | #include <__functional/binary_function.h> |
| 15 | #include <__functional/unary_function.h> | 15 | #include <__functional/unary_function.h> |
| 16 | #include <__type_traits/integral_constant.h> | ||
| 17 | #include <__type_traits/invoke.h> | 16 | #include <__type_traits/invoke.h> |
| 18 | #include <__type_traits/is_same.h> | 17 | #include <__type_traits/is_same.h> |
| 18 | #include <__type_traits/void_t.h> | ||
| 19 | #include <__utility/declval.h> | 19 | #include <__utility/declval.h> |
| 20 | 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -24,50 +24,36 @@ | ... | @@ -24,50 +24,36 @@ |
| 24 | 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _Tp> | 27 | template <class _Tp, class = void> |
| 28 | struct __has_result_type { | 28 | inline const bool __has_result_type_v = false; |
| 29 | private: | ||
| 30 | template <class _Up> | ||
| 31 | static false_type __test(...); | ||
| 32 | template <class _Up> | ||
| 33 | static true_type __test(typename _Up::result_type* = 0); | ||
| 34 | 29 | ||
| 35 | public: | 30 | template <class _Tp> |
| 36 | static const bool value = decltype(__test<_Tp>(0))::value; | 31 | inline const bool __has_result_type_v<_Tp, __void_t<typename _Tp::result_type*> > = true; |
| 37 | }; | ||
| 38 | 32 | ||
| 39 | // __weak_result_type | 33 | // __weak_result_type |
| 40 | 34 | ||
| 41 | template <class _Tp> | 35 | template <class _Tp> |
| 42 | struct __derives_from_unary_function { | 36 | struct __derives_from_unary_function { |
| 43 | private: | 37 | private: |
| 44 | struct __two { | 38 | static void __find_base(...); |
| 45 | char __lx; | ||
| 46 | char __lxx; | ||
| 47 | }; | ||
| 48 | static __two __test(...); | ||
| 49 | template <class _Ap, class _Rp> | 39 | template <class _Ap, class _Rp> |
| 50 | static __unary_function<_Ap, _Rp> __test(const volatile __unary_function<_Ap, _Rp>*); | 40 | static __unary_function<_Ap, _Rp> __find_base(const volatile __unary_function<_Ap, _Rp>*); |
| 51 | 41 | ||
| 52 | public: | 42 | public: |
| 53 | static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value; | 43 | using type = decltype(__find_base(static_cast<_Tp*>(nullptr))); |
| 54 | typedef decltype(__test((_Tp*)0)) type; | 44 | static const bool value = !is_same<type, void>::value; |
| 55 | }; | 45 | }; |
| 56 | 46 | ||
| 57 | template <class _Tp> | 47 | template <class _Tp> |
| 58 | struct __derives_from_binary_function { | 48 | struct __derives_from_binary_function { |
| 59 | private: | 49 | private: |
| 60 | struct __two { | 50 | static void __find_base(...); |
| 61 | char __lx; | ||
| 62 | char __lxx; | ||
| 63 | }; | ||
| 64 | static __two __test(...); | ||
| 65 | template <class _A1, class _A2, class _Rp> | 51 | template <class _A1, class _A2, class _Rp> |
| 66 | static __binary_function<_A1, _A2, _Rp> __test(const volatile __binary_function<_A1, _A2, _Rp>*); | 52 | static __binary_function<_A1, _A2, _Rp> __find_base(const volatile __binary_function<_A1, _A2, _Rp>*); |
| 67 | 53 | ||
| 68 | public: | 54 | public: |
| 69 | static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value; | 55 | using type = decltype(__find_base(static_cast<_Tp*>(nullptr))); |
| 70 | typedef decltype(__test((_Tp*)0)) type; | 56 | static const bool value = !is_same<type, void>::value; |
| 71 | }; | 57 | }; |
| 72 | 58 | ||
| 73 | template <class _Tp, bool = __derives_from_unary_function<_Tp>::value> | 59 | template <class _Tp, bool = __derives_from_unary_function<_Tp>::value> |
| ... | @@ -85,7 +71,7 @@ struct __maybe_derive_from_binary_function // bool is true | ... | @@ -85,7 +71,7 @@ struct __maybe_derive_from_binary_function // bool is true |
| 85 | template <class _Tp> | 71 | template <class _Tp> |
| 86 | struct __maybe_derive_from_binary_function<_Tp, false> {}; | 72 | struct __maybe_derive_from_binary_function<_Tp, false> {}; |
| 87 | 73 | ||
| 88 | template <class _Tp, bool = __has_result_type<_Tp>::value> | 74 | template <class _Tp, bool = __has_result_type_v<_Tp> > |
| 89 | struct __weak_result_type_imp // bool is true | 75 | struct __weak_result_type_imp // bool is true |
| 90 | : public __maybe_derive_from_unary_function<_Tp>, | 76 | : public __maybe_derive_from_unary_function<_Tp>, |
| 91 | public __maybe_derive_from_binary_function<_Tp> { | 77 | public __maybe_derive_from_binary_function<_Tp> { |
lib/libcxx/include/__fwd/ios.h+1-1| ... | @@ -31,7 +31,7 @@ using wios = basic_ios<wchar_t>; | ... | @@ -31,7 +31,7 @@ using wios = basic_ios<wchar_t>; |
| 31 | template <class _CharT, class _Traits> | 31 | template <class _CharT, class _Traits> |
| 32 | class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios; | 32 | class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios; |
| 33 | 33 | ||
| 34 | #if defined(_NEWLIB_VERSION) | 34 | #if _LIBCPP_LIBC_NEWLIB |
| 35 | // On newlib, off_t is 'long int' | 35 | // On newlib, off_t is 'long int' |
| 36 | using streamoff = long int; // for char_traits in <string> | 36 | using streamoff = long int; // for char_traits in <string> |
| 37 | #else | 37 | #else |
lib/libcxx/include/__fwd/tuple.h+14| ... | @@ -21,11 +21,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,11 +21,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | template <size_t, class> | 21 | template <size_t, class> |
| 22 | struct tuple_element; | 22 | struct tuple_element; |
| 23 | 23 | ||
| 24 | template <size_t _Np, class _Tp> | ||
| 25 | using __tuple_element_t _LIBCPP_NODEBUG = typename tuple_element<_Np, _Tp>::type; | ||
| 26 | |||
| 24 | #ifndef _LIBCPP_CXX03_LANG | 27 | #ifndef _LIBCPP_CXX03_LANG |
| 25 | 28 | ||
| 26 | template <class...> | 29 | template <class...> |
| 27 | class tuple; | 30 | class tuple; |
| 28 | 31 | ||
| 32 | template <class> | ||
| 33 | inline const bool __is_tuple_v = false; | ||
| 34 | |||
| 35 | template <class... _Tp> | ||
| 36 | inline const bool __is_tuple_v<tuple<_Tp...>> = true; | ||
| 37 | |||
| 38 | template <size_t _Ip, class... _Tp> | ||
| 39 | struct tuple_element<_Ip, tuple<_Tp...> > { | ||
| 40 | using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Tp...>; | ||
| 41 | }; | ||
| 42 | |||
| 29 | template <class> | 43 | template <class> |
| 30 | struct tuple_size; | 44 | struct tuple_size; |
| 31 | 45 |
lib/libcxx/include/__hash_table+371-357| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP___HASH_TABLE | 10 | #ifndef _LIBCPP___HASH_TABLE |
| 11 | #define _LIBCPP___HASH_TABLE | 11 | #define _LIBCPP___HASH_TABLE |
| 12 | 12 | ||
| 13 | #include <__algorithm/fill_n.h> | ||
| 13 | #include <__algorithm/max.h> | 14 | #include <__algorithm/max.h> |
| 14 | #include <__algorithm/min.h> | 15 | #include <__algorithm/min.h> |
| 15 | #include <__assert> | 16 | #include <__assert> |
| ... | @@ -28,7 +29,6 @@ | ... | @@ -28,7 +29,6 @@ |
| 28 | #include <__memory/swap_allocator.h> | 29 | #include <__memory/swap_allocator.h> |
| 29 | #include <__memory/unique_ptr.h> | 30 | #include <__memory/unique_ptr.h> |
| 30 | #include <__new/launder.h> | 31 | #include <__new/launder.h> |
| 31 | #include <__type_traits/can_extract_key.h> | ||
| 32 | #include <__type_traits/copy_cvref.h> | 32 | #include <__type_traits/copy_cvref.h> |
| 33 | #include <__type_traits/enable_if.h> | 33 | #include <__type_traits/enable_if.h> |
| 34 | #include <__type_traits/invoke.h> | 34 | #include <__type_traits/invoke.h> |
| ... | @@ -44,7 +44,9 @@ | ... | @@ -44,7 +44,9 @@ |
| 44 | #include <__utility/forward.h> | 44 | #include <__utility/forward.h> |
| 45 | #include <__utility/move.h> | 45 | #include <__utility/move.h> |
| 46 | #include <__utility/pair.h> | 46 | #include <__utility/pair.h> |
| 47 | #include <__utility/scope_guard.h> | ||
| 47 | #include <__utility/swap.h> | 48 | #include <__utility/swap.h> |
| 49 | #include <__utility/try_key_extraction.h> | ||
| 48 | #include <limits> | 50 | #include <limits> |
| 49 | 51 | ||
| 50 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 52 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -81,18 +83,6 @@ struct __hash_node_base { | ... | @@ -81,18 +83,6 @@ struct __hash_node_base { |
| 81 | typedef _NodePtr __node_pointer; | 83 | typedef _NodePtr __node_pointer; |
| 82 | typedef __node_base_pointer __next_pointer; | 84 | typedef __node_base_pointer __next_pointer; |
| 83 | 85 | ||
| 84 | // TODO(LLVM 22): Remove this check | ||
| 85 | #ifndef _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | ||
| 86 | static_assert(sizeof(__node_base_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == | ||
| 87 | _LIBCPP_ALIGNOF(__node_pointer), | ||
| 88 | "It looks like you are using std::__hash_table (an implementation detail for the unordered containers) " | ||
| 89 | "with a fancy pointer type that thas a different representation depending on whether it points to a " | ||
| 90 | "__hash_table base pointer or a __hash_table node pointer (both of which are implementation details of " | ||
| 91 | "the standard library). This means that your ABI is being broken between LLVM 19 and LLVM 20. If you " | ||
| 92 | "don't care about your ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to " | ||
| 93 | "silence this diagnostic."); | ||
| 94 | #endif | ||
| 95 | |||
| 96 | __next_pointer __next_; | 86 | __next_pointer __next_; |
| 97 | 87 | ||
| 98 | _LIBCPP_HIDE_FROM_ABI __next_pointer __ptr() _NOEXCEPT { | 88 | _LIBCPP_HIDE_FROM_ABI __next_pointer __ptr() _NOEXCEPT { |
| ... | @@ -122,6 +112,19 @@ struct __get_hash_node_value_type<__hash_value_type<_Key, _Tp> > { | ... | @@ -122,6 +112,19 @@ struct __get_hash_node_value_type<__hash_value_type<_Key, _Tp> > { |
| 122 | template <class _Tp> | 112 | template <class _Tp> |
| 123 | using __get_hash_node_value_type_t _LIBCPP_NODEBUG = typename __get_hash_node_value_type<_Tp>::type; | 113 | using __get_hash_node_value_type_t _LIBCPP_NODEBUG = typename __get_hash_node_value_type<_Tp>::type; |
| 124 | 114 | ||
| 115 | template <class _Tp> | ||
| 116 | struct __get_hash_node_key_type { | ||
| 117 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 118 | }; | ||
| 119 | |||
| 120 | template <class _Key, class _Tp> | ||
| 121 | struct __get_hash_node_key_type<__hash_value_type<_Key, _Tp> > { | ||
| 122 | using type _LIBCPP_NODEBUG = _Key; | ||
| 123 | }; | ||
| 124 | |||
| 125 | template <class _Tp> | ||
| 126 | using __get_hash_node_key_type_t _LIBCPP_NODEBUG = typename __get_hash_node_key_type<_Tp>::type; | ||
| 127 | |||
| 125 | template <class _Tp, class _VoidPtr> | 128 | template <class _Tp, class _VoidPtr> |
| 126 | struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > { | 129 | struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > { |
| 127 | using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>; | 130 | using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>; |
| ... | @@ -152,7 +155,12 @@ public: | ... | @@ -152,7 +155,12 @@ public: |
| 152 | } | 155 | } |
| 153 | #endif | 156 | #endif |
| 154 | 157 | ||
| 155 | _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {} | 158 | template <class _Alloc, class... _Args> |
| 159 | _LIBCPP_HIDE_FROM_ABI explicit __hash_node(size_t __hash, _Alloc& __na, _Args&&... __args) | ||
| 160 | : _Base(nullptr), __hash_(__hash) { | ||
| 161 | allocator_traits<_Alloc>::construct(__na, std::addressof(__get_value()), std::forward<_Args>(__args)...); | ||
| 162 | } | ||
| 163 | |||
| 156 | _LIBCPP_HIDE_FROM_ABI ~__hash_node() {} | 164 | _LIBCPP_HIDE_FROM_ABI ~__hash_node() {} |
| 157 | }; | 165 | }; |
| 158 | 166 | ||
| ... | @@ -182,85 +190,16 @@ class __hash_map_iterator; | ... | @@ -182,85 +190,16 @@ class __hash_map_iterator; |
| 182 | template <class _HashIterator> | 190 | template <class _HashIterator> |
| 183 | class __hash_map_const_iterator; | 191 | class __hash_map_const_iterator; |
| 184 | 192 | ||
| 185 | template <class _Tp> | ||
| 186 | struct __hash_key_value_types { | ||
| 187 | static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, ""); | ||
| 188 | typedef _Tp key_type; | ||
| 189 | typedef _Tp __node_value_type; | ||
| 190 | typedef _Tp __container_value_type; | ||
| 191 | static const bool __is_map = false; | ||
| 192 | |||
| 193 | _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Tp const& __v) { return __v; } | ||
| 194 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __v) { return __v; } | ||
| 195 | _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { return std::addressof(__n); } | ||
| 196 | _LIBCPP_HIDE_FROM_ABI static __container_value_type&& __move(__node_value_type& __v) { return std::move(__v); } | ||
| 197 | }; | ||
| 198 | |||
| 199 | template <class _Key, class _Tp> | ||
| 200 | struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { | ||
| 201 | typedef _Key key_type; | ||
| 202 | typedef _Tp mapped_type; | ||
| 203 | typedef __hash_value_type<_Key, _Tp> __node_value_type; | ||
| 204 | typedef pair<const _Key, _Tp> __container_value_type; | ||
| 205 | typedef __container_value_type __map_value_type; | ||
| 206 | static const bool __is_map = true; | ||
| 207 | |||
| 208 | _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__container_value_type const& __v) { return __v.first; } | ||
| 209 | |||
| 210 | template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __node_value_type>::value, int> = 0> | ||
| 211 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { | ||
| 212 | return __t.__get_value(); | ||
| 213 | } | ||
| 214 | |||
| 215 | template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __container_value_type>::value, int> = 0> | ||
| 216 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { | ||
| 217 | return __t; | ||
| 218 | } | ||
| 219 | |||
| 220 | _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__container_value_type& __n) { | ||
| 221 | return std::addressof(__n); | ||
| 222 | } | ||
| 223 | _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); } | ||
| 224 | }; | ||
| 225 | |||
| 226 | template <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>, bool = _KVTypes::__is_map> | ||
| 227 | struct __hash_map_pointer_types {}; | ||
| 228 | |||
| 229 | template <class _Tp, class _AllocPtr, class _KVTypes> | ||
| 230 | struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> { | ||
| 231 | typedef typename _KVTypes::__map_value_type _Mv; | ||
| 232 | typedef __rebind_pointer_t<_AllocPtr, _Mv> __map_value_type_pointer; | ||
| 233 | typedef __rebind_pointer_t<_AllocPtr, const _Mv> __const_map_value_type_pointer; | ||
| 234 | }; | ||
| 235 | |||
| 236 | template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type> | 193 | template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type> |
| 237 | struct __hash_node_types; | 194 | struct __hash_node_types; |
| 238 | 195 | ||
| 239 | template <class _NodePtr, class _Tp, class _VoidPtr> | 196 | template <class _NodePtr, class _Tp, class _VoidPtr> |
| 240 | struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> > | 197 | struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> > { |
| 241 | : public __hash_key_value_types<_Tp>, | ||
| 242 | __hash_map_pointer_types<_Tp, _VoidPtr> | ||
| 243 | |||
| 244 | { | ||
| 245 | typedef __hash_key_value_types<_Tp> __base; | ||
| 246 | |||
| 247 | public: | ||
| 248 | typedef ptrdiff_t difference_type; | ||
| 249 | typedef size_t size_type; | ||
| 250 | |||
| 251 | typedef __rebind_pointer_t<_NodePtr, void> __void_pointer; | ||
| 252 | |||
| 253 | typedef typename pointer_traits<_NodePtr>::element_type __node_type; | 198 | typedef typename pointer_traits<_NodePtr>::element_type __node_type; |
| 254 | typedef _NodePtr __node_pointer; | ||
| 255 | 199 | ||
| 256 | typedef __hash_node_base<__node_pointer> __node_base_type; | 200 | typedef typename __hash_node_base<_NodePtr>::__next_pointer __next_pointer; |
| 257 | typedef __rebind_pointer_t<_NodePtr, __node_base_type> __node_base_pointer; | ||
| 258 | |||
| 259 | typedef typename __node_base_type::__next_pointer __next_pointer; | ||
| 260 | 201 | ||
| 261 | using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>; | 202 | using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>; |
| 262 | typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer; | ||
| 263 | typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer; | ||
| 264 | 203 | ||
| 265 | private: | 204 | private: |
| 266 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); | 205 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); |
| ... | @@ -281,13 +220,6 @@ struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __has | ... | @@ -281,13 +220,6 @@ struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __has |
| 281 | template <class _NodePtr> | 220 | template <class _NodePtr> |
| 282 | struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; | 221 | struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; |
| 283 | 222 | ||
| 284 | template <class _NodeValueTp, class _VoidPtr> | ||
| 285 | struct __make_hash_node_types { | ||
| 286 | typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp; | ||
| 287 | typedef __rebind_pointer_t<_VoidPtr, _NodeTp> _NodePtr; | ||
| 288 | typedef __hash_node_types<_NodePtr> type; | ||
| 289 | }; | ||
| 290 | |||
| 291 | template <class _NodePtr> | 223 | template <class _NodePtr> |
| 292 | class __hash_iterator { | 224 | class __hash_iterator { |
| 293 | typedef __hash_node_types<_NodePtr> _NodeTypes; | 225 | typedef __hash_node_types<_NodePtr> _NodeTypes; |
| ... | @@ -299,9 +231,9 @@ class __hash_iterator { | ... | @@ -299,9 +231,9 @@ class __hash_iterator { |
| 299 | public: | 231 | public: |
| 300 | typedef forward_iterator_tag iterator_category; | 232 | typedef forward_iterator_tag iterator_category; |
| 301 | typedef typename _NodeTypes::__node_value_type value_type; | 233 | typedef typename _NodeTypes::__node_value_type value_type; |
| 302 | typedef typename _NodeTypes::difference_type difference_type; | 234 | using difference_type = ptrdiff_t; |
| 303 | typedef value_type& reference; | 235 | typedef value_type& reference; |
| 304 | typedef typename _NodeTypes::__node_value_type_pointer pointer; | 236 | using pointer = __rebind_pointer_t<_NodePtr, value_type>; |
| 305 | 237 | ||
| 306 | _LIBCPP_HIDE_FROM_ABI __hash_iterator() _NOEXCEPT : __node_(nullptr) {} | 238 | _LIBCPP_HIDE_FROM_ABI __hash_iterator() _NOEXCEPT : __node_(nullptr) {} |
| 307 | 239 | ||
| ... | @@ -366,9 +298,9 @@ public: | ... | @@ -366,9 +298,9 @@ public: |
| 366 | 298 | ||
| 367 | typedef forward_iterator_tag iterator_category; | 299 | typedef forward_iterator_tag iterator_category; |
| 368 | typedef typename _NodeTypes::__node_value_type value_type; | 300 | typedef typename _NodeTypes::__node_value_type value_type; |
| 369 | typedef typename _NodeTypes::difference_type difference_type; | 301 | using difference_type = ptrdiff_t; |
| 370 | typedef const value_type& reference; | 302 | typedef const value_type& reference; |
| 371 | typedef typename _NodeTypes::__const_node_value_type_pointer pointer; | 303 | using pointer = __rebind_pointer_t<_NodePtr, const value_type>; |
| 372 | 304 | ||
| 373 | _LIBCPP_HIDE_FROM_ABI __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {} | 305 | _LIBCPP_HIDE_FROM_ABI __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {} |
| 374 | 306 | ||
| ... | @@ -431,9 +363,9 @@ class __hash_local_iterator { | ... | @@ -431,9 +363,9 @@ class __hash_local_iterator { |
| 431 | public: | 363 | public: |
| 432 | typedef forward_iterator_tag iterator_category; | 364 | typedef forward_iterator_tag iterator_category; |
| 433 | typedef typename _NodeTypes::__node_value_type value_type; | 365 | typedef typename _NodeTypes::__node_value_type value_type; |
| 434 | typedef typename _NodeTypes::difference_type difference_type; | 366 | using difference_type = ptrdiff_t; |
| 435 | typedef value_type& reference; | 367 | typedef value_type& reference; |
| 436 | typedef typename _NodeTypes::__node_value_type_pointer pointer; | 368 | using pointer = __rebind_pointer_t<_NodePtr, value_type>; |
| 437 | 369 | ||
| 438 | _LIBCPP_HIDE_FROM_ABI __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {} | 370 | _LIBCPP_HIDE_FROM_ABI __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {} |
| 439 | 371 | ||
| ... | @@ -509,9 +441,9 @@ public: | ... | @@ -509,9 +441,9 @@ public: |
| 509 | 441 | ||
| 510 | typedef forward_iterator_tag iterator_category; | 442 | typedef forward_iterator_tag iterator_category; |
| 511 | typedef typename _NodeTypes::__node_value_type value_type; | 443 | typedef typename _NodeTypes::__node_value_type value_type; |
| 512 | typedef typename _NodeTypes::difference_type difference_type; | 444 | using difference_type = ptrdiff_t; |
| 513 | typedef const value_type& reference; | 445 | typedef const value_type& reference; |
| 514 | typedef typename _NodeTypes::__const_node_value_type_pointer pointer; | 446 | using pointer = __rebind_pointer_t<_ConstNodePtr, const value_type>; |
| 515 | 447 | ||
| 516 | _LIBCPP_HIDE_FROM_ABI __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {} | 448 | _LIBCPP_HIDE_FROM_ABI __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {} |
| 517 | 449 | ||
| ... | @@ -617,8 +549,6 @@ public: | ... | @@ -617,8 +549,6 @@ public: |
| 617 | typedef typename __alloc_traits::pointer pointer; | 549 | typedef typename __alloc_traits::pointer pointer; |
| 618 | 550 | ||
| 619 | private: | 551 | private: |
| 620 | typedef __hash_node_types<pointer> _NodeTypes; | ||
| 621 | |||
| 622 | allocator_type& __na_; | 552 | allocator_type& __na_; |
| 623 | 553 | ||
| 624 | public: | 554 | public: |
| ... | @@ -633,7 +563,7 @@ public: | ... | @@ -633,7 +563,7 @@ public: |
| 633 | 563 | ||
| 634 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { | 564 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 635 | if (__value_constructed) { | 565 | if (__value_constructed) { |
| 636 | __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__get_value())); | 566 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value())); |
| 637 | std::__destroy_at(std::addressof(*__p)); | 567 | std::__destroy_at(std::addressof(*__p)); |
| 638 | } | 568 | } |
| 639 | if (__p) | 569 | if (__p) |
| ... | @@ -684,18 +614,16 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> | ... | @@ -684,18 +614,16 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 684 | class __hash_table { | 614 | class __hash_table { |
| 685 | public: | 615 | public: |
| 686 | using value_type = __get_hash_node_value_type_t<_Tp>; | 616 | using value_type = __get_hash_node_value_type_t<_Tp>; |
| 617 | using key_type = __get_hash_node_key_type_t<_Tp>; | ||
| 618 | |||
| 687 | typedef _Hash hasher; | 619 | typedef _Hash hasher; |
| 688 | typedef _Equal key_equal; | 620 | typedef _Equal key_equal; |
| 689 | typedef _Alloc allocator_type; | 621 | typedef _Alloc allocator_type; |
| 690 | 622 | ||
| 691 | private: | 623 | private: |
| 692 | typedef allocator_traits<allocator_type> __alloc_traits; | 624 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 693 | typedef typename __make_hash_node_types<_Tp, typename __alloc_traits::void_pointer>::type _NodeTypes; | ||
| 694 | 625 | ||
| 695 | public: | 626 | public: |
| 696 | typedef typename _NodeTypes::__node_value_type __node_value_type; | ||
| 697 | typedef typename _NodeTypes::__container_value_type __container_value_type; | ||
| 698 | typedef typename _NodeTypes::key_type key_type; | ||
| 699 | typedef value_type& reference; | 627 | typedef value_type& reference; |
| 700 | typedef const value_type& const_reference; | 628 | typedef const value_type& const_reference; |
| 701 | typedef typename __alloc_traits::pointer pointer; | 629 | typedef typename __alloc_traits::pointer pointer; |
| ... | @@ -703,22 +631,23 @@ public: | ... | @@ -703,22 +631,23 @@ public: |
| 703 | #ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE | 631 | #ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE |
| 704 | typedef typename __alloc_traits::size_type size_type; | 632 | typedef typename __alloc_traits::size_type size_type; |
| 705 | #else | 633 | #else |
| 706 | typedef typename _NodeTypes::size_type size_type; | 634 | using size_type = size_t; |
| 707 | #endif | 635 | #endif |
| 708 | typedef typename _NodeTypes::difference_type difference_type; | 636 | using difference_type = ptrdiff_t; |
| 709 | 637 | ||
| 710 | public: | 638 | public: |
| 711 | // Create __node | 639 | // Create __node |
| 712 | 640 | ||
| 713 | typedef typename _NodeTypes::__node_type __node; | 641 | using __void_pointer _LIBCPP_NODEBUG = typename __alloc_traits::void_pointer; |
| 714 | typedef __rebind_alloc<__alloc_traits, __node> __node_allocator; | 642 | |
| 715 | typedef allocator_traits<__node_allocator> __node_traits; | 643 | using __node _LIBCPP_NODEBUG = __hash_node<_Tp, __void_pointer>; |
| 716 | typedef typename _NodeTypes::__void_pointer __void_pointer; | 644 | using __node_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, __node>; |
| 717 | typedef typename _NodeTypes::__node_pointer __node_pointer; | 645 | using __node_traits _LIBCPP_NODEBUG = allocator_traits<__node_allocator>; |
| 718 | typedef typename _NodeTypes::__node_pointer __node_const_pointer; | 646 | using __node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __node>; |
| 719 | typedef typename _NodeTypes::__node_base_type __first_node; | 647 | |
| 720 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; | 648 | using __first_node _LIBCPP_NODEBUG = __hash_node_base<__node_pointer>; |
| 721 | typedef typename _NodeTypes::__next_pointer __next_pointer; | 649 | using __node_base_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __first_node>; |
| 650 | using __next_pointer _LIBCPP_NODEBUG = __node_base_pointer; | ||
| 722 | 651 | ||
| 723 | private: | 652 | private: |
| 724 | // check for sane allocator pointer rebinding semantics. Rebinding the | 653 | // check for sane allocator pointer rebinding semantics. Rebinding the |
| ... | @@ -747,6 +676,38 @@ private: | ... | @@ -747,6 +676,38 @@ private: |
| 747 | 676 | ||
| 748 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } | 677 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } |
| 749 | 678 | ||
| 679 | _LIBCPP_HIDE_FROM_ABI void | ||
| 680 | __copy_construct(__next_pointer __other_iter, __next_pointer __own_iter, size_t __current_chash) { | ||
| 681 | auto __bucket_count = bucket_count(); | ||
| 682 | |||
| 683 | for (; __other_iter; __other_iter = __other_iter->__next_) { | ||
| 684 | __node_holder __new_node = __construct_node_hash(__other_iter->__hash(), __other_iter->__upcast()->__get_value()); | ||
| 685 | |||
| 686 | size_t __new_chash = std::__constrain_hash(__new_node->__hash(), __bucket_count); | ||
| 687 | if (__new_chash != __current_chash) { | ||
| 688 | __bucket_list_[__new_chash] = __own_iter; | ||
| 689 | __current_chash = __new_chash; | ||
| 690 | } | ||
| 691 | |||
| 692 | __own_iter->__next_ = static_cast<__next_pointer>(__new_node.release()); | ||
| 693 | __own_iter = __own_iter->__next_; | ||
| 694 | } | ||
| 695 | } | ||
| 696 | |||
| 697 | _LIBCPP_HIDE_FROM_ABI void __copy_construct(__next_pointer __other_iter) { | ||
| 698 | __next_pointer __own_iter = __first_node_.__ptr(); | ||
| 699 | { | ||
| 700 | __node_holder __new_node = __construct_node_hash(__other_iter->__hash(), __other_iter->__upcast()->__get_value()); | ||
| 701 | __own_iter->__next_ = static_cast<__next_pointer>(__new_node.release()); | ||
| 702 | } | ||
| 703 | |||
| 704 | size_t __current_chash = std::__constrain_hash(__own_iter->__next_->__hash(), bucket_count()); | ||
| 705 | __bucket_list_[__current_chash] = __own_iter; | ||
| 706 | __other_iter = __other_iter->__next_; | ||
| 707 | __own_iter = __own_iter->__next_; | ||
| 708 | __copy_construct(__other_iter, __own_iter, __current_chash); | ||
| 709 | } | ||
| 710 | |||
| 750 | public: | 711 | public: |
| 751 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } | 712 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } |
| 752 | 713 | ||
| ... | @@ -811,40 +772,66 @@ public: | ... | @@ -811,40 +772,66 @@ public: |
| 811 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd); | 772 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd); |
| 812 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); | 773 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); |
| 813 | 774 | ||
| 814 | template <class _Key, class... _Args> | ||
| 815 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args); | ||
| 816 | |||
| 817 | template <class... _Args> | ||
| 818 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_impl(_Args&&... __args); | ||
| 819 | |||
| 820 | template <class _Pp> | ||
| 821 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Pp&& __x) { | ||
| 822 | return __emplace_unique_extract_key(std::forward<_Pp>(__x), __can_extract_key<_Pp, key_type>()); | ||
| 823 | } | ||
| 824 | |||
| 825 | template <class _First, | ||
| 826 | class _Second, | ||
| 827 | __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0> | ||
| 828 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) { | ||
| 829 | return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s)); | ||
| 830 | } | ||
| 831 | |||
| 832 | template <class... _Args> | 775 | template <class... _Args> |
| 833 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Args&&... __args) { | 776 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Args&&... __args) { |
| 834 | return __emplace_unique_impl(std::forward<_Args>(__args)...); | 777 | return std::__try_key_extraction<key_type>( |
| 835 | } | 778 | [this](const key_type& __key, _Args&&... __args2) { |
| 836 | 779 | size_t __hash = hash_function()(__key); | |
| 837 | template <class _Pp> | 780 | size_type __bc = bucket_count(); |
| 838 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { | 781 | bool __inserted = false; |
| 839 | return __emplace_unique_impl(std::forward<_Pp>(__x)); | 782 | __next_pointer __nd; |
| 840 | } | 783 | size_t __chash; |
| 841 | template <class _Pp> | 784 | if (__bc != 0) { |
| 842 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { | 785 | __chash = std::__constrain_hash(__hash, __bc); |
| 843 | return __emplace_unique_key_args(__x, std::forward<_Pp>(__x)); | 786 | __nd = __bucket_list_[__chash]; |
| 844 | } | 787 | if (__nd != nullptr) { |
| 845 | template <class _Pp> | 788 | for (__nd = __nd->__next_; |
| 846 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { | 789 | __nd != nullptr && |
| 847 | return __emplace_unique_key_args(__x.first, std::forward<_Pp>(__x)); | 790 | (__nd->__hash() == __hash || std::__constrain_hash(__nd->__hash(), __bc) == __chash); |
| 791 | __nd = __nd->__next_) { | ||
| 792 | if ((__nd->__hash() == __hash) && key_eq()(__nd->__upcast()->__get_value(), __key)) | ||
| 793 | goto __done; | ||
| 794 | } | ||
| 795 | } | ||
| 796 | } | ||
| 797 | { | ||
| 798 | __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args2)...); | ||
| 799 | if (size() + 1 > __bc * max_load_factor()) { | ||
| 800 | __rehash_unique(std::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc), | ||
| 801 | size_type(__math::ceil(float(size() + 1) / max_load_factor())))); | ||
| 802 | __bc = bucket_count(); | ||
| 803 | __chash = std::__constrain_hash(__hash, __bc); | ||
| 804 | } | ||
| 805 | // insert_after __bucket_list_[__chash], or __first_node if bucket is null | ||
| 806 | __next_pointer __pn = __bucket_list_[__chash]; | ||
| 807 | if (__pn == nullptr) { | ||
| 808 | __pn = __first_node_.__ptr(); | ||
| 809 | __h->__next_ = __pn->__next_; | ||
| 810 | __pn->__next_ = __h.get()->__ptr(); | ||
| 811 | // fix up __bucket_list_ | ||
| 812 | __bucket_list_[__chash] = __pn; | ||
| 813 | if (__h->__next_ != nullptr) | ||
| 814 | __bucket_list_[std::__constrain_hash(__h->__next_->__hash(), __bc)] = __h.get()->__ptr(); | ||
| 815 | } else { | ||
| 816 | __h->__next_ = __pn->__next_; | ||
| 817 | __pn->__next_ = static_cast<__next_pointer>(__h.get()); | ||
| 818 | } | ||
| 819 | __nd = static_cast<__next_pointer>(__h.release()); | ||
| 820 | // increment size | ||
| 821 | ++size(); | ||
| 822 | __inserted = true; | ||
| 823 | } | ||
| 824 | __done: | ||
| 825 | return pair<iterator, bool>(iterator(__nd), __inserted); | ||
| 826 | }, | ||
| 827 | [this](_Args&&... __args2) { | ||
| 828 | __node_holder __h = __construct_node(std::forward<_Args>(__args2)...); | ||
| 829 | pair<iterator, bool> __r = __node_insert_unique(__h.get()); | ||
| 830 | if (__r.second) | ||
| 831 | __h.release(); | ||
| 832 | return __r; | ||
| 833 | }, | ||
| 834 | std::forward<_Args>(__args)...); | ||
| 848 | } | 835 | } |
| 849 | 836 | ||
| 850 | template <class... _Args> | 837 | template <class... _Args> |
| ... | @@ -854,9 +841,7 @@ public: | ... | @@ -854,9 +841,7 @@ public: |
| 854 | 841 | ||
| 855 | template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> | 842 | template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> |
| 856 | _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(value_type&& __value) { | 843 | _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(value_type&& __value) { |
| 857 | using __key_type = typename _NodeTypes::key_type; | 844 | __node_holder __h = __construct_node(const_cast<key_type&&>(__value.first), std::move(__value.second)); |
| 858 | |||
| 859 | __node_holder __h = __construct_node(const_cast<__key_type&&>(__value.first), std::move(__value.second)); | ||
| 860 | __node_insert_unique(__h.get()); | 845 | __node_insert_unique(__h.get()); |
| 861 | __h.release(); | 846 | __h.release(); |
| 862 | } | 847 | } |
| ... | @@ -870,9 +855,7 @@ public: | ... | @@ -870,9 +855,7 @@ public: |
| 870 | 855 | ||
| 871 | template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> | 856 | template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> |
| 872 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(value_type&& __value) { | 857 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(value_type&& __value) { |
| 873 | using __key_type = typename _NodeTypes::key_type; | 858 | __node_holder __h = __construct_node(const_cast<key_type&&>(__value.first), std::move(__value.second)); |
| 874 | |||
| 875 | __node_holder __h = __construct_node(const_cast<__key_type&&>(__value.first), std::move(__value.second)); | ||
| 876 | __node_insert_multi(__h.get()); | 859 | __node_insert_multi(__h.get()); |
| 877 | __h.release(); | 860 | __h.release(); |
| 878 | } | 861 | } |
| ... | @@ -1017,8 +1000,8 @@ private: | ... | @@ -1017,8 +1000,8 @@ private: |
| 1017 | template <class... _Args> | 1000 | template <class... _Args> |
| 1018 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args); | 1001 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args); |
| 1019 | 1002 | ||
| 1020 | template <class _First, class... _Rest> | 1003 | template <class... _Args> |
| 1021 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest); | 1004 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_hash(size_t __hash, _Args&&... __args); |
| 1022 | 1005 | ||
| 1023 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __hash_table& __u) { | 1006 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __hash_table& __u) { |
| 1024 | __copy_assign_alloc(__u, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); | 1007 | __copy_assign_alloc(__u, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); |
| ... | @@ -1042,17 +1025,29 @@ private: | ... | @@ -1042,17 +1025,29 @@ private: |
| 1042 | } | 1025 | } |
| 1043 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {} | 1026 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {} |
| 1044 | 1027 | ||
| 1045 | _LIBCPP_HIDE_FROM_ABI void __deallocate_node(__next_pointer __np) _NOEXCEPT; | 1028 | _LIBCPP_HIDE_FROM_ABI void __deallocate_node(__node_pointer __nd) _NOEXCEPT { |
| 1029 | auto& __alloc = __node_alloc(); | ||
| 1030 | __node_traits::destroy(__alloc, std::addressof(__nd->__get_value())); | ||
| 1031 | std::__destroy_at(std::__to_address(__nd)); | ||
| 1032 | __node_traits::deallocate(__alloc, __nd, 1); | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | _LIBCPP_HIDE_FROM_ABI void __deallocate_node_list(__next_pointer __np) _NOEXCEPT { | ||
| 1036 | while (__np != nullptr) { | ||
| 1037 | __next_pointer __next = __np->__next_; | ||
| 1038 | __deallocate_node(__np->__upcast()); | ||
| 1039 | __np = __next; | ||
| 1040 | } | ||
| 1041 | } | ||
| 1042 | |||
| 1046 | _LIBCPP_HIDE_FROM_ABI __next_pointer __detach() _NOEXCEPT; | 1043 | _LIBCPP_HIDE_FROM_ABI __next_pointer __detach() _NOEXCEPT; |
| 1047 | 1044 | ||
| 1048 | template <class _From, class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> | 1045 | template <class _From, class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> |
| 1049 | _LIBCPP_HIDE_FROM_ABI void __assign_value(__get_hash_node_value_type_t<_Tp>& __lhs, _From&& __rhs) { | 1046 | _LIBCPP_HIDE_FROM_ABI void __assign_value(__get_hash_node_value_type_t<_Tp>& __lhs, _From&& __rhs) { |
| 1050 | using __key_type = typename _NodeTypes::key_type; | ||
| 1051 | |||
| 1052 | // This is technically UB, since the object was constructed as `const`. | 1047 | // This is technically UB, since the object was constructed as `const`. |
| 1053 | // Clang doesn't optimize on this currently though. | 1048 | // Clang doesn't optimize on this currently though. |
| 1054 | const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first); | 1049 | const_cast<key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, key_type>&&>(__rhs.first); |
| 1055 | __lhs.second = std::forward<_From>(__rhs).second; | 1050 | __lhs.second = std::forward<_From>(__rhs).second; |
| 1056 | } | 1051 | } |
| 1057 | 1052 | ||
| 1058 | template <class _From, class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0> | 1053 | template <class _From, class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0> |
| ... | @@ -1101,16 +1096,29 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a | ... | @@ -1101,16 +1096,29 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a |
| 1101 | __max_load_factor_(1.0f) {} | 1096 | __max_load_factor_(1.0f) {} |
| 1102 | 1097 | ||
| 1103 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1098 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1104 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) | 1099 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __other) |
| 1105 | : __bucket_list_(nullptr, | 1100 | : __bucket_list_(nullptr, |
| 1106 | __bucket_list_deleter(allocator_traits<__pointer_allocator>::select_on_container_copy_construction( | 1101 | __bucket_list_deleter(__pointer_alloc_traits::select_on_container_copy_construction( |
| 1107 | __u.__bucket_list_.get_deleter().__alloc()), | 1102 | __other.__bucket_list_.get_deleter().__alloc()), |
| 1108 | 0)), | 1103 | 0)), |
| 1109 | __node_alloc_(allocator_traits<__node_allocator>::select_on_container_copy_construction(__u.__node_alloc())), | 1104 | __node_alloc_(__node_traits::select_on_container_copy_construction(__other.__node_alloc())), |
| 1110 | __size_(0), | 1105 | __size_(0), |
| 1111 | __hasher_(__u.hash_function()), | 1106 | __hasher_(__other.hash_function()), |
| 1112 | __max_load_factor_(__u.__max_load_factor_), | 1107 | __max_load_factor_(__other.__max_load_factor_), |
| 1113 | __key_eq_(__u.__key_eq_) {} | 1108 | __key_eq_(__other.__key_eq_) { |
| 1109 | if (__other.size() == 0) | ||
| 1110 | return; | ||
| 1111 | |||
| 1112 | auto& __bucket_list_del = __bucket_list_.get_deleter(); | ||
| 1113 | auto __bucket_count = __other.bucket_count(); | ||
| 1114 | __bucket_list_.reset(__pointer_alloc_traits::allocate(__bucket_list_del.__alloc(), __bucket_count)); | ||
| 1115 | __bucket_list_del.size() = __bucket_count; | ||
| 1116 | |||
| 1117 | std::fill_n(__bucket_list_.get(), __bucket_count, nullptr); | ||
| 1118 | |||
| 1119 | __copy_construct(__other.__first_node_.__next_); | ||
| 1120 | __size_ = __other.size(); | ||
| 1121 | } | ||
| 1114 | 1122 | ||
| 1115 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1123 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1116 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a) | 1124 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a) |
| ... | @@ -1169,7 +1177,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { | ... | @@ -1169,7 +1177,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { |
| 1169 | static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible."); | 1177 | static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible."); |
| 1170 | #endif | 1178 | #endif |
| 1171 | 1179 | ||
| 1172 | __deallocate_node(__first_node_.__next_); | 1180 | __deallocate_node_list(__first_node_.__next_); |
| 1173 | } | 1181 | } |
| 1174 | 1182 | ||
| 1175 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1183 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | @@ -1184,28 +1192,76 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc(const __hash_ | ... | @@ -1184,28 +1192,76 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc(const __hash_ |
| 1184 | } | 1192 | } |
| 1185 | 1193 | ||
| 1186 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1194 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1187 | __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u) { | 1195 | __hash_table<_Tp, _Hash, _Equal, _Alloc>& |
| 1188 | if (this != std::addressof(__u)) { | 1196 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __other) { |
| 1189 | __copy_assign_alloc(__u); | 1197 | if (this == std::addressof(__other)) |
| 1190 | hash_function() = __u.hash_function(); | 1198 | return *this; |
| 1191 | key_eq() = __u.key_eq(); | 1199 | |
| 1192 | max_load_factor() = __u.max_load_factor(); | 1200 | __copy_assign_alloc(__other); |
| 1193 | __assign_multi(__u.begin(), __u.end()); | 1201 | hash_function() = __other.hash_function(); |
| 1202 | key_eq() = __other.key_eq(); | ||
| 1203 | max_load_factor() = __other.max_load_factor(); | ||
| 1204 | |||
| 1205 | if (__other.size() == 0) { | ||
| 1206 | clear(); | ||
| 1207 | return *this; | ||
| 1194 | } | 1208 | } |
| 1195 | return *this; | ||
| 1196 | } | ||
| 1197 | 1209 | ||
| 1198 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1210 | auto __bucket_count = __other.bucket_count(); |
| 1199 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) _NOEXCEPT { | 1211 | if (__bucket_count != bucket_count()) { |
| 1200 | __node_allocator& __na = __node_alloc(); | 1212 | auto& __bucket_list_del = __bucket_list_.get_deleter(); |
| 1201 | while (__np != nullptr) { | 1213 | __bucket_list_.reset(__pointer_alloc_traits::allocate(__bucket_list_del.__alloc(), __bucket_count)); |
| 1202 | __next_pointer __next = __np->__next_; | 1214 | __bucket_list_del.size() = __bucket_count; |
| 1203 | __node_pointer __real_np = __np->__upcast(); | 1215 | } |
| 1204 | __node_traits::destroy(__na, _NodeTypes::__get_ptr(__real_np->__get_value())); | 1216 | std::fill_n(__bucket_list_.get(), __bucket_count, nullptr); |
| 1205 | std::__destroy_at(std::addressof(*__real_np)); | 1217 | |
| 1206 | __node_traits::deallocate(__na, __real_np, 1); | 1218 | if (!__first_node_.__next_) { |
| 1207 | __np = __next; | 1219 | __copy_construct(__other.__first_node_.__next_); |
| 1220 | __size_ = __other.size(); | ||
| 1221 | return *this; | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | __next_pointer __other_iter = __other.__first_node_.__next_; | ||
| 1225 | __next_pointer __own_iter = __first_node_.__ptr(); | ||
| 1226 | { | ||
| 1227 | __node_pointer __next = __own_iter->__next_->__upcast(); | ||
| 1228 | __assign_value(__next->__get_value(), __other_iter->__upcast()->__get_value()); | ||
| 1229 | __next->__hash_ = __other_iter->__hash(); | ||
| 1230 | } | ||
| 1231 | size_t __current_chash = std::__constrain_hash(__own_iter->__next_->__hash(), __bucket_count); | ||
| 1232 | __bucket_list_[__current_chash] = __own_iter; | ||
| 1233 | __other_iter = __other_iter->__next_; | ||
| 1234 | __own_iter = __own_iter->__next_; | ||
| 1235 | |||
| 1236 | // Go through the nodes of the incoming hash table and copy then into the destination hash table, reusing as many | ||
| 1237 | // existing nodes as posssible in the destination. | ||
| 1238 | while (__other_iter && __own_iter->__next_) { | ||
| 1239 | __node_pointer __next = __own_iter->__next_->__upcast(); | ||
| 1240 | __assign_value(__next->__get_value(), __other_iter->__upcast()->__get_value()); | ||
| 1241 | __next->__hash_ = __other_iter->__hash(); | ||
| 1242 | |||
| 1243 | size_t __new_chash = std::__constrain_hash(__next->__hash_, __bucket_count); | ||
| 1244 | if (__new_chash != __current_chash) { | ||
| 1245 | __bucket_list_[__new_chash] = __own_iter; | ||
| 1246 | __current_chash = __new_chash; | ||
| 1247 | } | ||
| 1248 | |||
| 1249 | __other_iter = __other_iter->__next_; | ||
| 1250 | __own_iter = __own_iter->__next_; | ||
| 1208 | } | 1251 | } |
| 1252 | |||
| 1253 | // At this point we either have consumed the whole incoming hash table, or we don't have any more nodes to reuse in | ||
| 1254 | // the destination. Either continue with constructing new nodes, or deallocate the left over nodes. | ||
| 1255 | if (__own_iter->__next_) { | ||
| 1256 | __deallocate_node_list(__own_iter->__next_); | ||
| 1257 | __own_iter->__next_ = nullptr; | ||
| 1258 | } else { | ||
| 1259 | __copy_construct(__other_iter, __own_iter, __current_chash); | ||
| 1260 | } | ||
| 1261 | |||
| 1262 | __size_ = __other.size(); | ||
| 1263 | |||
| 1264 | return *this; | ||
| 1209 | } | 1265 | } |
| 1210 | 1266 | ||
| 1211 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1267 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | @@ -1251,23 +1307,14 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, | ... | @@ -1251,23 +1307,14 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, |
| 1251 | max_load_factor() = __u.max_load_factor(); | 1307 | max_load_factor() = __u.max_load_factor(); |
| 1252 | if (bucket_count() != 0) { | 1308 | if (bucket_count() != 0) { |
| 1253 | __next_pointer __cache = __detach(); | 1309 | __next_pointer __cache = __detach(); |
| 1254 | #if _LIBCPP_HAS_EXCEPTIONS | 1310 | auto __guard = std::__make_scope_guard([&] { __deallocate_node_list(__cache); }); |
| 1255 | try { | 1311 | const_iterator __i = __u.begin(); |
| 1256 | #endif // _LIBCPP_HAS_EXCEPTIONS | 1312 | while (__cache != nullptr && __u.size() != 0) { |
| 1257 | const_iterator __i = __u.begin(); | 1313 | __assign_value(__cache->__upcast()->__get_value(), std::move(__u.remove(__i++)->__get_value())); |
| 1258 | while (__cache != nullptr && __u.size() != 0) { | 1314 | __next_pointer __next = __cache->__next_; |
| 1259 | __assign_value(__cache->__upcast()->__get_value(), std::move(__u.remove(__i++)->__get_value())); | 1315 | __node_insert_multi(__cache->__upcast()); |
| 1260 | __next_pointer __next = __cache->__next_; | 1316 | __cache = __next; |
| 1261 | __node_insert_multi(__cache->__upcast()); | ||
| 1262 | __cache = __next; | ||
| 1263 | } | ||
| 1264 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 1265 | } catch (...) { | ||
| 1266 | __deallocate_node(__cache); | ||
| 1267 | throw; | ||
| 1268 | } | 1317 | } |
| 1269 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1270 | __deallocate_node(__cache); | ||
| 1271 | } | 1318 | } |
| 1272 | const_iterator __i = __u.begin(); | 1319 | const_iterator __i = __u.begin(); |
| 1273 | while (__u.size() != 0) | 1320 | while (__u.size() != 0) |
| ... | @@ -1290,27 +1337,18 @@ template <class _InputIterator> | ... | @@ -1290,27 +1337,18 @@ template <class _InputIterator> |
| 1290 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, _InputIterator __last) { | 1337 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, _InputIterator __last) { |
| 1291 | typedef iterator_traits<_InputIterator> _ITraits; | 1338 | typedef iterator_traits<_InputIterator> _ITraits; |
| 1292 | typedef typename _ITraits::value_type _ItValueType; | 1339 | typedef typename _ITraits::value_type _ItValueType; |
| 1293 | static_assert(is_same<_ItValueType, __container_value_type>::value, | 1340 | static_assert( |
| 1294 | "__assign_unique may only be called with the containers value type"); | 1341 | is_same<_ItValueType, value_type>::value, "__assign_unique may only be called with the containers value type"); |
| 1295 | 1342 | ||
| 1296 | if (bucket_count() != 0) { | 1343 | if (bucket_count() != 0) { |
| 1297 | __next_pointer __cache = __detach(); | 1344 | __next_pointer __cache = __detach(); |
| 1298 | #if _LIBCPP_HAS_EXCEPTIONS | 1345 | auto __guard = std::__make_scope_guard([&] { __deallocate_node_list(__cache); }); |
| 1299 | try { | 1346 | for (; __cache != nullptr && __first != __last; ++__first) { |
| 1300 | #endif // _LIBCPP_HAS_EXCEPTIONS | 1347 | __assign_value(__cache->__upcast()->__get_value(), *__first); |
| 1301 | for (; __cache != nullptr && __first != __last; ++__first) { | 1348 | __next_pointer __next = __cache->__next_; |
| 1302 | __assign_value(__cache->__upcast()->__get_value(), *__first); | 1349 | __node_insert_unique(__cache->__upcast()); |
| 1303 | __next_pointer __next = __cache->__next_; | 1350 | __cache = __next; |
| 1304 | __node_insert_unique(__cache->__upcast()); | ||
| 1305 | __cache = __next; | ||
| 1306 | } | ||
| 1307 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 1308 | } catch (...) { | ||
| 1309 | __deallocate_node(__cache); | ||
| 1310 | throw; | ||
| 1311 | } | 1351 | } |
| 1312 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1313 | __deallocate_node(__cache); | ||
| 1314 | } | 1352 | } |
| 1315 | for (; __first != __last; ++__first) | 1353 | for (; __first != __last; ++__first) |
| 1316 | __emplace_unique(*__first); | 1354 | __emplace_unique(*__first); |
| ... | @@ -1321,31 +1359,20 @@ template <class _InputIterator> | ... | @@ -1321,31 +1359,20 @@ template <class _InputIterator> |
| 1321 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, _InputIterator __last) { | 1359 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, _InputIterator __last) { |
| 1322 | typedef iterator_traits<_InputIterator> _ITraits; | 1360 | typedef iterator_traits<_InputIterator> _ITraits; |
| 1323 | typedef typename _ITraits::value_type _ItValueType; | 1361 | typedef typename _ITraits::value_type _ItValueType; |
| 1324 | static_assert( | 1362 | static_assert(is_same<_ItValueType, value_type>::value, |
| 1325 | (is_same<_ItValueType, __container_value_type>::value || is_same<_ItValueType, __node_value_type>::value), | 1363 | "__assign_multi may only be called with the containers value type or the nodes value type"); |
| 1326 | "__assign_multi may only be called with the containers value type" | ||
| 1327 | " or the nodes value type"); | ||
| 1328 | if (bucket_count() != 0) { | 1364 | if (bucket_count() != 0) { |
| 1329 | __next_pointer __cache = __detach(); | 1365 | __next_pointer __cache = __detach(); |
| 1330 | #if _LIBCPP_HAS_EXCEPTIONS | 1366 | auto __guard = std::__make_scope_guard([&] { __deallocate_node_list(__cache); }); |
| 1331 | try { | 1367 | for (; __cache != nullptr && __first != __last; ++__first) { |
| 1332 | #endif // _LIBCPP_HAS_EXCEPTIONS | 1368 | __assign_value(__cache->__upcast()->__get_value(), *__first); |
| 1333 | for (; __cache != nullptr && __first != __last; ++__first) { | 1369 | __next_pointer __next = __cache->__next_; |
| 1334 | __assign_value(__cache->__upcast()->__get_value(), *__first); | 1370 | __node_insert_multi(__cache->__upcast()); |
| 1335 | __next_pointer __next = __cache->__next_; | 1371 | __cache = __next; |
| 1336 | __node_insert_multi(__cache->__upcast()); | ||
| 1337 | __cache = __next; | ||
| 1338 | } | ||
| 1339 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 1340 | } catch (...) { | ||
| 1341 | __deallocate_node(__cache); | ||
| 1342 | throw; | ||
| 1343 | } | 1372 | } |
| 1344 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1345 | __deallocate_node(__cache); | ||
| 1346 | } | 1373 | } |
| 1347 | for (; __first != __last; ++__first) | 1374 | for (; __first != __last; ++__first) |
| 1348 | __emplace_multi(_NodeTypes::__get_value(*__first)); | 1375 | __emplace_multi(*__first); |
| 1349 | } | 1376 | } |
| 1350 | 1377 | ||
| 1351 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1378 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | @@ -1375,7 +1402,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { | ... | @@ -1375,7 +1402,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { |
| 1375 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1402 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1376 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT { | 1403 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT { |
| 1377 | if (size() > 0) { | 1404 | if (size() > 0) { |
| 1378 | __deallocate_node(__first_node_.__next_); | 1405 | __deallocate_node_list(__first_node_.__next_); |
| 1379 | __first_node_.__next_ = nullptr; | 1406 | __first_node_.__next_ = nullptr; |
| 1380 | size_type __bc = bucket_count(); | 1407 | size_type __bc = bucket_count(); |
| 1381 | for (size_type __i = 0; __i < __bc; ++__i) | 1408 | for (size_type __i = 0; __i < __bc; ++__i) |
| ... | @@ -1561,69 +1588,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p | ... | @@ -1561,69 +1588,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p |
| 1561 | return __node_insert_multi(__cp); | 1588 | return __node_insert_multi(__cp); |
| 1562 | } | 1589 | } |
| 1563 | 1590 | ||
| 1564 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | ||
| 1565 | template <class _Key, class... _Args> | ||
| 1566 | pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool> | ||
| 1567 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) { | ||
| 1568 | size_t __hash = hash_function()(__k); | ||
| 1569 | size_type __bc = bucket_count(); | ||
| 1570 | bool __inserted = false; | ||
| 1571 | __next_pointer __nd; | ||
| 1572 | size_t __chash; | ||
| 1573 | if (__bc != 0) { | ||
| 1574 | __chash = std::__constrain_hash(__hash, __bc); | ||
| 1575 | __nd = __bucket_list_[__chash]; | ||
| 1576 | if (__nd != nullptr) { | ||
| 1577 | for (__nd = __nd->__next_; | ||
| 1578 | __nd != nullptr && (__nd->__hash() == __hash || std::__constrain_hash(__nd->__hash(), __bc) == __chash); | ||
| 1579 | __nd = __nd->__next_) { | ||
| 1580 | if ((__nd->__hash() == __hash) && key_eq()(__nd->__upcast()->__get_value(), __k)) | ||
| 1581 | goto __done; | ||
| 1582 | } | ||
| 1583 | } | ||
| 1584 | } | ||
| 1585 | { | ||
| 1586 | __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...); | ||
| 1587 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) { | ||
| 1588 | __rehash_unique(std::max<size_type>( | ||
| 1589 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); | ||
| 1590 | __bc = bucket_count(); | ||
| 1591 | __chash = std::__constrain_hash(__hash, __bc); | ||
| 1592 | } | ||
| 1593 | // insert_after __bucket_list_[__chash], or __first_node if bucket is null | ||
| 1594 | __next_pointer __pn = __bucket_list_[__chash]; | ||
| 1595 | if (__pn == nullptr) { | ||
| 1596 | __pn = __first_node_.__ptr(); | ||
| 1597 | __h->__next_ = __pn->__next_; | ||
| 1598 | __pn->__next_ = __h.get()->__ptr(); | ||
| 1599 | // fix up __bucket_list_ | ||
| 1600 | __bucket_list_[__chash] = __pn; | ||
| 1601 | if (__h->__next_ != nullptr) | ||
| 1602 | __bucket_list_[std::__constrain_hash(__h->__next_->__hash(), __bc)] = __h.get()->__ptr(); | ||
| 1603 | } else { | ||
| 1604 | __h->__next_ = __pn->__next_; | ||
| 1605 | __pn->__next_ = static_cast<__next_pointer>(__h.get()); | ||
| 1606 | } | ||
| 1607 | __nd = static_cast<__next_pointer>(__h.release()); | ||
| 1608 | // increment size | ||
| 1609 | ++size(); | ||
| 1610 | __inserted = true; | ||
| 1611 | } | ||
| 1612 | __done: | ||
| 1613 | return pair<iterator, bool>(iterator(__nd), __inserted); | ||
| 1614 | } | ||
| 1615 | |||
| 1616 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | ||
| 1617 | template <class... _Args> | ||
| 1618 | pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool> | ||
| 1619 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_impl(_Args&&... __args) { | ||
| 1620 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | ||
| 1621 | pair<iterator, bool> __r = __node_insert_unique(__h.get()); | ||
| 1622 | if (__r.second) | ||
| 1623 | __h.release(); | ||
| 1624 | return __r; | ||
| 1625 | } | ||
| 1626 | |||
| 1627 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1591 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1628 | template <class... _Args> | 1592 | template <class... _Args> |
| 1629 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator | 1593 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| ... | @@ -1764,41 +1728,45 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D | ... | @@ -1764,41 +1728,45 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D |
| 1764 | 1728 | ||
| 1765 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1729 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1766 | template <bool _UniqueKeys> | 1730 | template <bool _UniqueKeys> |
| 1767 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc) { | 1731 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __bucket_count) { |
| 1768 | __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); | 1732 | __pointer_allocator& __ptr_alloc = __bucket_list_.get_deleter().__alloc(); |
| 1769 | __bucket_list_.reset(__nbc > 0 ? __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); | 1733 | __bucket_list_.reset(__bucket_count > 0 ? __pointer_alloc_traits::allocate(__ptr_alloc, __bucket_count) : nullptr); |
| 1770 | __bucket_list_.get_deleter().size() = __nbc; | 1734 | __bucket_list_.get_deleter().size() = __bucket_count; |
| 1771 | if (__nbc > 0) { | 1735 | |
| 1772 | for (size_type __i = 0; __i < __nbc; ++__i) | 1736 | if (__bucket_count == 0) |
| 1773 | __bucket_list_[__i] = nullptr; | 1737 | return; |
| 1774 | __next_pointer __pp = __first_node_.__ptr(); | 1738 | |
| 1775 | __next_pointer __cp = __pp->__next_; | 1739 | for (size_type __i = 0; __i < __bucket_count; ++__i) |
| 1776 | if (__cp != nullptr) { | 1740 | __bucket_list_[__i] = nullptr; |
| 1777 | size_type __chash = std::__constrain_hash(__cp->__hash(), __nbc); | 1741 | __next_pointer __pp = __first_node_.__ptr(); |
| 1778 | __bucket_list_[__chash] = __pp; | 1742 | __next_pointer __cp = __pp->__next_; |
| 1779 | size_type __phash = __chash; | 1743 | |
| 1780 | for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr; __cp = __pp->__next_) { | 1744 | if (!__cp) |
| 1781 | __chash = std::__constrain_hash(__cp->__hash(), __nbc); | 1745 | return; |
| 1782 | if (__chash == __phash) | 1746 | |
| 1783 | __pp = __cp; | 1747 | size_type __chash = std::__constrain_hash(__cp->__hash(), __bucket_count); |
| 1784 | else { | 1748 | __bucket_list_[__chash] = __pp; |
| 1785 | if (__bucket_list_[__chash] == nullptr) { | 1749 | size_type __phash = __chash; |
| 1786 | __bucket_list_[__chash] = __pp; | 1750 | for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr; __cp = __pp->__next_) { |
| 1787 | __pp = __cp; | 1751 | __chash = std::__constrain_hash(__cp->__hash(), __bucket_count); |
| 1788 | __phash = __chash; | 1752 | if (__chash == __phash) |
| 1789 | } else { | 1753 | __pp = __cp; |
| 1790 | __next_pointer __np = __cp; | 1754 | else { |
| 1791 | if _LIBCPP_CONSTEXPR_SINCE_CXX17 (!_UniqueKeys) { | 1755 | if (__bucket_list_[__chash] == nullptr) { |
| 1792 | for (; __np->__next_ != nullptr && | 1756 | __bucket_list_[__chash] = __pp; |
| 1793 | key_eq()(__cp->__upcast()->__get_value(), __np->__next_->__upcast()->__get_value()); | 1757 | __pp = __cp; |
| 1794 | __np = __np->__next_) | 1758 | __phash = __chash; |
| 1795 | ; | 1759 | } else { |
| 1796 | } | 1760 | __next_pointer __np = __cp; |
| 1797 | __pp->__next_ = __np->__next_; | 1761 | if _LIBCPP_CONSTEXPR (!_UniqueKeys) { |
| 1798 | __np->__next_ = __bucket_list_[__chash]->__next_; | 1762 | for (; __np->__next_ != nullptr && |
| 1799 | __bucket_list_[__chash]->__next_ = __cp; | 1763 | key_eq()(__cp->__upcast()->__get_value(), __np->__next_->__upcast()->__get_value()); |
| 1800 | } | 1764 | __np = __np->__next_) |
| 1765 | ; | ||
| 1801 | } | 1766 | } |
| 1767 | __pp->__next_ = __np->__next_; | ||
| 1768 | __np->__next_ = __bucket_list_[__chash]->__next_; | ||
| 1769 | __bucket_list_[__chash]->__next_ = __cp; | ||
| 1802 | } | 1770 | } |
| 1803 | } | 1771 | } |
| 1804 | } | 1772 | } |
| ... | @@ -1854,16 +1822,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&&... __args) { | ... | @@ -1854,16 +1822,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&&... __args) { |
| 1854 | __node_allocator& __na = __node_alloc(); | 1822 | __node_allocator& __na = __node_alloc(); |
| 1855 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1823 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1856 | 1824 | ||
| 1857 | // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value | 1825 | // Begin the lifetime of the node itself and the value_type contained within. |
| 1858 | // held inside the node, since we need to use the allocator's construct() method for that. | ||
| 1859 | // | 1826 | // |
| 1860 | // We don't use the allocator's construct() method to construct the node itself since the | 1827 | // We don't use the allocator's construct() method to construct the node itself since the |
| 1861 | // Cpp17FooInsertable named requirements don't require the allocator's construct() method | 1828 | // Cpp17FooInsertable named requirements don't require the allocator's construct() method |
| 1862 | // to work on anything other than the value_type. | 1829 | // to work on anything other than the value_type. |
| 1863 | std::__construct_at(std::addressof(*__h), /* next = */ nullptr, /* hash = */ 0); | 1830 | std::__construct_at(std::addressof(*__h), /* hash = */ 0, __na, std::forward<_Args>(__args)...); |
| 1864 | 1831 | ||
| 1865 | // Now construct the value_type using the allocator's construct() method. | ||
| 1866 | __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__get_value()), std::forward<_Args>(__args)...); | ||
| 1867 | __h.get_deleter().__value_constructed = true; | 1832 | __h.get_deleter().__value_constructed = true; |
| 1868 | 1833 | ||
| 1869 | __h->__hash_ = hash_function()(__h->__get_value()); | 1834 | __h->__hash_ = hash_function()(__h->__get_value()); |
| ... | @@ -1871,15 +1836,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&&... __args) { | ... | @@ -1871,15 +1836,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&&... __args) { |
| 1871 | } | 1836 | } |
| 1872 | 1837 | ||
| 1873 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1838 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1874 | template <class _First, class... _Rest> | 1839 | template <class... _Args> |
| 1875 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder | 1840 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder |
| 1876 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest) { | 1841 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash, _Args&&... __args) { |
| 1877 | static_assert(!__is_hash_value_type<_First, _Rest...>::value, "Construct cannot be called with a hash value type"); | 1842 | static_assert(!__is_hash_value_type<_Args...>::value, "Construct cannot be called with a hash value type"); |
| 1878 | __node_allocator& __na = __node_alloc(); | 1843 | __node_allocator& __na = __node_alloc(); |
| 1879 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1844 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1880 | std::__construct_at(std::addressof(*__h), /* next = */ nullptr, /* hash = */ __hash); | 1845 | std::__construct_at(std::addressof(*__h), /* hash = */ __hash, __na, std::forward<_Args>(__args)...); |
| 1881 | __node_traits::construct( | ||
| 1882 | __na, _NodeTypes::__get_ptr(__h->__get_value()), std::forward<_First>(__f), std::forward<_Rest>(__rest)...); | ||
| 1883 | __h.get_deleter().__value_constructed = true; | 1846 | __h.get_deleter().__value_constructed = true; |
| 1884 | return __h; | 1847 | return __h; |
| 1885 | } | 1848 | } |
| ... | @@ -1899,12 +1862,63 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) { | ... | @@ -1899,12 +1862,63 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) { |
| 1899 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1862 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1900 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator | 1863 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 1901 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, const_iterator __last) { | 1864 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, const_iterator __last) { |
| 1902 | for (const_iterator __p = __first; __first != __last; __p = __first) { | 1865 | if (__first == __last) |
| 1903 | ++__first; | 1866 | return iterator(__last.__node_); |
| 1904 | erase(__p); | 1867 | |
| 1868 | // current node | ||
| 1869 | __next_pointer __current = __first.__node_; | ||
| 1870 | size_type __bucket_count = bucket_count(); | ||
| 1871 | size_t __chash = std::__constrain_hash(__current->__hash(), __bucket_count); | ||
| 1872 | // find previous node | ||
| 1873 | __next_pointer __before_first = __bucket_list_[__chash]; | ||
| 1874 | for (; __before_first->__next_ != __current; __before_first = __before_first->__next_) | ||
| 1875 | ; | ||
| 1876 | |||
| 1877 | __next_pointer __last_node = __last.__node_; | ||
| 1878 | |||
| 1879 | // If __before_first is in the same bucket (i.e. the first element we erase is not the first in the bucket), clear | ||
| 1880 | // this bucket first without re-linking it | ||
| 1881 | if (__before_first != __first_node_.__ptr() && | ||
| 1882 | std::__constrain_hash(__before_first->__hash(), __bucket_count) == __chash) { | ||
| 1883 | while (__current != __last_node) { | ||
| 1884 | auto __next = __current->__next_; | ||
| 1885 | __deallocate_node(__current->__upcast()); | ||
| 1886 | __current = __next; | ||
| 1887 | --__size_; | ||
| 1888 | |||
| 1889 | if (__next) { | ||
| 1890 | if (auto __next_chash = std::__constrain_hash(__next->__hash(), __bucket_count); __next_chash != __chash) { | ||
| 1891 | __bucket_list_[__next_chash] = __before_first; | ||
| 1892 | __chash = __next_chash; | ||
| 1893 | break; | ||
| 1894 | } | ||
| 1895 | } | ||
| 1896 | } | ||
| 1905 | } | 1897 | } |
| 1906 | __next_pointer __np = __last.__node_; | 1898 | |
| 1907 | return iterator(__np); | 1899 | while (__current != __last_node) { |
| 1900 | auto __next = __current->__next_; | ||
| 1901 | __deallocate_node(__current->__upcast()); | ||
| 1902 | __current = __next; | ||
| 1903 | --__size_; | ||
| 1904 | |||
| 1905 | // When switching buckets, set the old bucket to be empty and update the next bucket to have __before_first as its | ||
| 1906 | // before-first element | ||
| 1907 | if (__next) { | ||
| 1908 | if (auto __next_chash = std::__constrain_hash(__next->__hash(), __bucket_count); __next_chash != __chash) { | ||
| 1909 | __bucket_list_[__chash] = nullptr; | ||
| 1910 | __bucket_list_[__next_chash] = __before_first; | ||
| 1911 | __chash = __next_chash; | ||
| 1912 | } | ||
| 1913 | } else { // When __next is a nullptr we've fully erased the last bucket. Update the bucket list accordingly. | ||
| 1914 | __bucket_list_[__chash] = nullptr; | ||
| 1915 | } | ||
| 1916 | } | ||
| 1917 | |||
| 1918 | // re-link __before_first with __last | ||
| 1919 | __before_first->__next_ = __current; | ||
| 1920 | |||
| 1921 | return iterator(__last.__node_); | ||
| 1908 | } | 1922 | } |
| 1909 | 1923 | ||
| 1910 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1924 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
lib/libcxx/include/__ios/fpos.h+4-4| ... | @@ -30,7 +30,7 @@ public: | ... | @@ -30,7 +30,7 @@ public: |
| 30 | 30 | ||
| 31 | _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; } | 31 | _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; } |
| 32 | 32 | ||
| 33 | _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; } | 33 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; } |
| 34 | _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; } | 34 | _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; } |
| 35 | 35 | ||
| 36 | _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) { | 36 | _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) { |
| ... | @@ -38,7 +38,7 @@ public: | ... | @@ -38,7 +38,7 @@ public: |
| 38 | return *this; | 38 | return *this; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const { | 41 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const { |
| 42 | fpos __t(*this); | 42 | fpos __t(*this); |
| 43 | __t += __off; | 43 | __t += __off; |
| 44 | return __t; | 44 | return __t; |
| ... | @@ -49,7 +49,7 @@ public: | ... | @@ -49,7 +49,7 @@ public: |
| 49 | return *this; | 49 | return *this; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const { | 52 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const { |
| 53 | fpos __t(*this); | 53 | fpos __t(*this); |
| 54 | __t -= __off; | 54 | __t -= __off; |
| 55 | return __t; | 55 | return __t; |
| ... | @@ -57,7 +57,7 @@ public: | ... | @@ -57,7 +57,7 @@ public: |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | template <class _StateT> | 59 | template <class _StateT> |
| 60 | inline _LIBCPP_HIDE_FROM_ABI streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) { | 60 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) { |
| 61 | return streamoff(__x) - streamoff(__y); | 61 | return streamoff(__x) - streamoff(__y); |
| 62 | } | 62 | } |
| 63 | 63 |
lib/libcxx/include/__iterator/back_insert_iterator.h+1-7| ... | @@ -26,15 +26,9 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,15 +26,9 @@ _LIBCPP_PUSH_MACROS |
| 26 | 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 30 | template <class _Container> | 29 | template <class _Container> |
| 31 | class back_insert_iterator | 30 | class back_insert_iterator |
| 32 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 31 | : public __iterator_base<back_insert_iterator<_Container>, output_iterator_tag, void, void, void, void> { |
| 33 | : public iterator<output_iterator_tag, void, void, void, void> | ||
| 34 | #endif | ||
| 35 | { | ||
| 36 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 37 | |||
| 38 | protected: | 32 | protected: |
| 39 | _Container* container; | 33 | _Container* container; |
| 40 | 34 |
lib/libcxx/include/__iterator/bounded_iter.h+7-8| ... | @@ -74,12 +74,12 @@ struct __bounded_iter { | ... | @@ -74,12 +74,12 @@ struct __bounded_iter { |
| 74 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default; | 74 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default; |
| 75 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default; | 75 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default; |
| 76 | 76 | ||
| 77 | template < class _OtherIterator, | 77 | template <class _OtherIterator, |
| 78 | __enable_if_t< | 78 | __enable_if_t< |
| 79 | _And< is_convertible<const _OtherIterator&, _Iterator>, | 79 | _And<is_convertible<const _OtherIterator&, _Iterator>, |
| 80 | _Or<is_same<reference, __iter_reference<_OtherIterator> >, | 80 | _Or<is_same<reference, __iterator_reference<_OtherIterator> >, |
| 81 | is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIterator> > > > >::value, | 81 | is_same<reference, __make_const_lvalue_ref<__iterator_reference<_OtherIterator> > > > >::value, |
| 82 | int> = 0> | 82 | int> = 0> |
| 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT | 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT |
| 84 | : __current_(__other.__current_), | 84 | : __current_(__other.__current_), |
| 85 | __begin_(__other.__begin_), | 85 | __begin_(__other.__begin_), |
| ... | @@ -116,8 +116,7 @@ public: | ... | @@ -116,8 +116,7 @@ public: |
| 116 | // These operations check that the iterator is dereferenceable. Since the class invariant is | 116 | // These operations check that the iterator is dereferenceable. Since the class invariant is |
| 117 | // that the iterator is always within `[begin, end]`, we only need to check it's not pointing to | 117 | // that the iterator is always within `[begin, end]`, we only need to check it's not pointing to |
| 118 | // `end`. This is easier for the optimizer because it aligns with the `iter != container.end()` | 118 | // `end`. This is easier for the optimizer because it aligns with the `iter != container.end()` |
| 119 | // checks that typical callers already use (see | 119 | // checks that typical callers already use (see https://llvm.org/PR78829). |
| 120 | // https://github.com/llvm/llvm-project/issues/78829). | ||
| 121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { | 120 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { |
| 122 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 121 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 123 | __current_ != __end_, "__bounded_iter::operator*: Attempt to dereference an iterator at the end"); | 122 | __current_ != __end_, "__bounded_iter::operator*: Attempt to dereference an iterator at the end"); |
lib/libcxx/include/__iterator/concepts.h+6-9| ... | @@ -117,15 +117,12 @@ template <class _Tp> | ... | @@ -117,15 +117,12 @@ template <class _Tp> |
| 117 | concept __signed_integer_like = signed_integral<_Tp>; | 117 | concept __signed_integer_like = signed_integral<_Tp>; |
| 118 | 118 | ||
| 119 | template <class _Ip> | 119 | template <class _Ip> |
| 120 | concept weakly_incrementable = | 120 | concept weakly_incrementable = movable<_Ip> && requires(_Ip __i) { |
| 121 | // TODO: remove this once the clang bug is fixed (bugs.llvm.org/PR48173). | 121 | typename iter_difference_t<_Ip>; |
| 122 | !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly. | 122 | requires __signed_integer_like<iter_difference_t<_Ip>>; |
| 123 | movable<_Ip> && requires(_Ip __i) { | 123 | { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving |
| 124 | typename iter_difference_t<_Ip>; | 124 | __i++; // not required to be equality-preserving |
| 125 | requires __signed_integer_like<iter_difference_t<_Ip>>; | 125 | }; |
| 126 | { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving | ||
| 127 | __i++; // not required to be equality-preserving | ||
| 128 | }; | ||
| 129 | 126 | ||
| 130 | // [iterator.concept.inc] | 127 | // [iterator.concept.inc] |
| 131 | template <class _Ip> | 128 | template <class _Ip> |
lib/libcxx/include/__iterator/cpp17_iterator_concepts.h+13-12| ... | @@ -68,7 +68,8 @@ concept __cpp17_default_constructible = is_default_constructible_v<_Tp>; | ... | @@ -68,7 +68,8 @@ concept __cpp17_default_constructible = is_default_constructible_v<_Tp>; |
| 68 | template <class _Iter> | 68 | template <class _Iter> |
| 69 | concept __cpp17_iterator = | 69 | concept __cpp17_iterator = |
| 70 | __cpp17_copy_constructible<_Iter> && __cpp17_copy_assignable<_Iter> && __cpp17_destructible<_Iter> && | 70 | __cpp17_copy_constructible<_Iter> && __cpp17_copy_assignable<_Iter> && __cpp17_destructible<_Iter> && |
| 71 | (is_signed_v<__iter_diff_t<_Iter>> || is_void_v<__iter_diff_t<_Iter>>) && requires(_Iter __iter) { | 71 | (is_signed_v<__iterator_difference_type<_Iter>> || is_void_v<__iterator_difference_type<_Iter>>) && |
| 72 | requires(_Iter __iter) { | ||
| 72 | { *__iter }; | 73 | { *__iter }; |
| 73 | { ++__iter } -> same_as<_Iter&>; | 74 | { ++__iter } -> same_as<_Iter&>; |
| 74 | }; | 75 | }; |
| ... | @@ -81,8 +82,8 @@ concept __cpp17_input_iterator = | ... | @@ -81,8 +82,8 @@ concept __cpp17_input_iterator = |
| 81 | { __lhs != std::as_const(__rhs) } -> __boolean_testable; | 82 | { __lhs != std::as_const(__rhs) } -> __boolean_testable; |
| 82 | { std::as_const(__lhs) != std::as_const(__rhs) } -> __boolean_testable; | 83 | { std::as_const(__lhs) != std::as_const(__rhs) } -> __boolean_testable; |
| 83 | 84 | ||
| 84 | { *__lhs } -> same_as<__iter_reference<_Iter>>; | 85 | { *__lhs } -> same_as<__iterator_reference<_Iter>>; |
| 85 | { *std::as_const(__lhs) } -> same_as<__iter_reference<_Iter>>; | 86 | { *std::as_const(__lhs) } -> same_as<__iterator_reference<_Iter>>; |
| 86 | 87 | ||
| 87 | { ++__lhs } -> same_as<_Iter&>; | 88 | { ++__lhs } -> same_as<_Iter&>; |
| 88 | { (void)__lhs++ }; | 89 | { (void)__lhs++ }; |
| ... | @@ -101,19 +102,19 @@ template <class _Iter> | ... | @@ -101,19 +102,19 @@ template <class _Iter> |
| 101 | concept __cpp17_forward_iterator = | 102 | concept __cpp17_forward_iterator = |
| 102 | __cpp17_input_iterator<_Iter> && __cpp17_default_constructible<_Iter> && requires(_Iter __iter) { | 103 | __cpp17_input_iterator<_Iter> && __cpp17_default_constructible<_Iter> && requires(_Iter __iter) { |
| 103 | { __iter++ } -> convertible_to<const _Iter&>; | 104 | { __iter++ } -> convertible_to<const _Iter&>; |
| 104 | { *__iter++ } -> same_as<__iter_reference<_Iter>>; | 105 | { *__iter++ } -> same_as<__iterator_reference<_Iter>>; |
| 105 | }; | 106 | }; |
| 106 | 107 | ||
| 107 | template <class _Iter> | 108 | template <class _Iter> |
| 108 | concept __cpp17_bidirectional_iterator = __cpp17_forward_iterator<_Iter> && requires(_Iter __iter) { | 109 | concept __cpp17_bidirectional_iterator = __cpp17_forward_iterator<_Iter> && requires(_Iter __iter) { |
| 109 | { --__iter } -> same_as<_Iter&>; | 110 | { --__iter } -> same_as<_Iter&>; |
| 110 | { __iter-- } -> convertible_to<const _Iter&>; | 111 | { __iter-- } -> convertible_to<const _Iter&>; |
| 111 | { *__iter-- } -> same_as<__iter_reference<_Iter>>; | 112 | { *__iter-- } -> same_as<__iterator_reference<_Iter>>; |
| 112 | }; | 113 | }; |
| 113 | 114 | ||
| 114 | template <class _Iter> | 115 | template <class _Iter> |
| 115 | concept __cpp17_random_access_iterator = | 116 | concept __cpp17_random_access_iterator = |
| 116 | __cpp17_bidirectional_iterator<_Iter> && requires(_Iter __iter, __iter_diff_t<_Iter> __n) { | 117 | __cpp17_bidirectional_iterator<_Iter> && requires(_Iter __iter, __iterator_difference_type<_Iter> __n) { |
| 117 | { __iter += __n } -> same_as<_Iter&>; | 118 | { __iter += __n } -> same_as<_Iter&>; |
| 118 | 119 | ||
| 119 | { __iter + __n } -> same_as<_Iter>; | 120 | { __iter + __n } -> same_as<_Iter>; |
| ... | @@ -125,13 +126,13 @@ concept __cpp17_random_access_iterator = | ... | @@ -125,13 +126,13 @@ concept __cpp17_random_access_iterator = |
| 125 | { __iter - __n } -> same_as<_Iter>; | 126 | { __iter - __n } -> same_as<_Iter>; |
| 126 | { std::as_const(__iter) - __n } -> same_as<_Iter>; | 127 | { std::as_const(__iter) - __n } -> same_as<_Iter>; |
| 127 | 128 | ||
| 128 | { __iter - __iter } -> same_as<__iter_diff_t<_Iter>>; | 129 | { __iter - __iter } -> same_as<__iterator_difference_type<_Iter>>; |
| 129 | { std::as_const(__iter) - __iter } -> same_as<__iter_diff_t<_Iter>>; | 130 | { std::as_const(__iter) - __iter } -> same_as<__iterator_difference_type<_Iter>>; |
| 130 | { __iter - std::as_const(__iter) } -> same_as<__iter_diff_t<_Iter>>; | 131 | { __iter - std::as_const(__iter) } -> same_as<__iterator_difference_type<_Iter>>; |
| 131 | { std::as_const(__iter) - std::as_const(__iter) } -> same_as<__iter_diff_t<_Iter>>; | 132 | { std::as_const(__iter) - std::as_const(__iter) } -> same_as<__iterator_difference_type<_Iter>>; |
| 132 | 133 | ||
| 133 | { __iter[__n] } -> convertible_to<__iter_reference<_Iter>>; | 134 | { __iter[__n] } -> convertible_to<__iterator_reference<_Iter>>; |
| 134 | { std::as_const(__iter)[__n] } -> convertible_to<__iter_reference<_Iter>>; | 135 | { std::as_const(__iter)[__n] } -> convertible_to<__iterator_reference<_Iter>>; |
| 135 | 136 | ||
| 136 | { __iter < __iter } -> __boolean_testable; | 137 | { __iter < __iter } -> __boolean_testable; |
| 137 | { std::as_const(__iter) < __iter } -> __boolean_testable; | 138 | { std::as_const(__iter) < __iter } -> __boolean_testable; |
lib/libcxx/include/__iterator/distance.h+40-18| ... | @@ -10,41 +10,66 @@ | ... | @@ -10,41 +10,66 @@ |
| 10 | #ifndef _LIBCPP___ITERATOR_DISTANCE_H | 10 | #ifndef _LIBCPP___ITERATOR_DISTANCE_H |
| 11 | #define _LIBCPP___ITERATOR_DISTANCE_H | 11 | #define _LIBCPP___ITERATOR_DISTANCE_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/for_each_segment.h> | ||
| 14 | #include <__concepts/same_as.h> | ||
| 13 | #include <__config> | 15 | #include <__config> |
| 14 | #include <__iterator/concepts.h> | 16 | #include <__iterator/concepts.h> |
| 15 | #include <__iterator/incrementable_traits.h> | 17 | #include <__iterator/incrementable_traits.h> |
| 16 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__iterator/segmented_iterator.h> | ||
| 17 | #include <__ranges/access.h> | 20 | #include <__ranges/access.h> |
| 18 | #include <__ranges/concepts.h> | 21 | #include <__ranges/concepts.h> |
| 19 | #include <__ranges/size.h> | 22 | #include <__ranges/size.h> |
| 20 | #include <__type_traits/decay.h> | 23 | #include <__type_traits/decay.h> |
| 24 | #include <__type_traits/enable_if.h> | ||
| 21 | #include <__type_traits/remove_cvref.h> | 25 | #include <__type_traits/remove_cvref.h> |
| 26 | #include <__utility/move.h> | ||
| 22 | 27 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | # pragma GCC system_header | 29 | # pragma GCC system_header |
| 25 | #endif | 30 | #endif |
| 26 | 31 | ||
| 32 | _LIBCPP_PUSH_MACROS | ||
| 33 | #include <__undef_macros> | ||
| 34 | |||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 36 | ||
| 29 | template <class _InputIter> | 37 | #if _LIBCPP_STD_VER >= 20 |
| 30 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_InputIter>::difference_type | 38 | template <class _Iter> |
| 31 | __distance(_InputIter __first, _InputIter __last, input_iterator_tag) { | 39 | using __iter_distance_t _LIBCPP_NODEBUG = std::iter_difference_t<_Iter>; |
| 32 | typename iterator_traits<_InputIter>::difference_type __r(0); | 40 | #else |
| 33 | for (; __first != __last; ++__first) | 41 | template <class _Iter> |
| 34 | ++__r; | 42 | using __iter_distance_t _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type; |
| 35 | return __r; | 43 | #endif |
| 36 | } | ||
| 37 | 44 | ||
| 38 | template <class _RandIter> | 45 | template <class _RandIter, __enable_if_t<__has_random_access_iterator_category<_RandIter>::value, int> = 0> |
| 39 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_RandIter>::difference_type | 46 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 __iter_distance_t<_RandIter> |
| 40 | __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) { | 47 | __distance(_RandIter __first, _RandIter __last) { |
| 41 | return __last - __first; | 48 | return __last - __first; |
| 42 | } | 49 | } |
| 43 | 50 | ||
| 51 | template <class _InputIter, class _Sent> | ||
| 52 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 __iter_distance_t<_InputIter> | ||
| 53 | __distance(_InputIter __first, _Sent __last) { | ||
| 54 | __iter_distance_t<_InputIter> __r(0); | ||
| 55 | #if _LIBCPP_STD_VER >= 20 | ||
| 56 | if constexpr (same_as<_InputIter, _Sent> && __is_segmented_iterator_v<_InputIter>) { | ||
| 57 | std::__for_each_segment(__first, __last, [&__r](auto __lfirst, auto __llast) { | ||
| 58 | __r += std::__distance(__lfirst, __llast); | ||
| 59 | }); | ||
| 60 | } else | ||
| 61 | #endif | ||
| 62 | { | ||
| 63 | for (; __first != __last; ++__first) | ||
| 64 | ++__r; | ||
| 65 | } | ||
| 66 | return __r; | ||
| 67 | } | ||
| 68 | |||
| 44 | template <class _InputIter> | 69 | template <class _InputIter> |
| 45 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_InputIter>::difference_type | 70 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_InputIter>::difference_type |
| 46 | distance(_InputIter __first, _InputIter __last) { | 71 | distance(_InputIter __first, _InputIter __last) { |
| 47 | return std::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); | 72 | return std::__distance(__first, __last); |
| 48 | } | 73 | } |
| 49 | 74 | ||
| 50 | #if _LIBCPP_STD_VER >= 20 | 75 | #if _LIBCPP_STD_VER >= 20 |
| ... | @@ -56,12 +81,7 @@ struct __distance { | ... | @@ -56,12 +81,7 @@ struct __distance { |
| 56 | template <class _Ip, sentinel_for<_Ip> _Sp> | 81 | template <class _Ip, sentinel_for<_Ip> _Sp> |
| 57 | requires(!sized_sentinel_for<_Sp, _Ip>) | 82 | requires(!sized_sentinel_for<_Sp, _Ip>) |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { | 83 | _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { |
| 59 | iter_difference_t<_Ip> __n = 0; | 84 | return std::__distance(std::move(__first), std::move(__last)); |
| 60 | while (__first != __last) { | ||
| 61 | ++__first; | ||
| 62 | ++__n; | ||
| 63 | } | ||
| 64 | return __n; | ||
| 65 | } | 85 | } |
| 66 | 86 | ||
| 67 | template <class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp> | 87 | template <class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp> |
| ... | @@ -92,4 +112,6 @@ inline constexpr auto distance = __distance{}; | ... | @@ -92,4 +112,6 @@ inline constexpr auto distance = __distance{}; |
| 92 | 112 | ||
| 93 | _LIBCPP_END_NAMESPACE_STD | 113 | _LIBCPP_END_NAMESPACE_STD |
| 94 | 114 | ||
| 115 | _LIBCPP_POP_MACROS | ||
| 116 | |||
| 95 | #endif // _LIBCPP___ITERATOR_DISTANCE_H | 117 | #endif // _LIBCPP___ITERATOR_DISTANCE_H |
lib/libcxx/include/__iterator/front_insert_iterator.h+1-7| ... | @@ -26,15 +26,9 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,15 +26,9 @@ _LIBCPP_PUSH_MACROS |
| 26 | 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 30 | template <class _Container> | 29 | template <class _Container> |
| 31 | class front_insert_iterator | 30 | class front_insert_iterator |
| 32 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 31 | : public __iterator_base<front_insert_iterator<_Container>, output_iterator_tag, void, void, void, void> { |
| 33 | : public iterator<output_iterator_tag, void, void, void, void> | ||
| 34 | #endif | ||
| 35 | { | ||
| 36 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 37 | |||
| 38 | protected: | 32 | protected: |
| 39 | _Container* container; | 33 | _Container* container; |
| 40 | 34 |
lib/libcxx/include/__iterator/insert_iterator.h+1-7| ... | @@ -35,15 +35,9 @@ template <class _Container> | ... | @@ -35,15 +35,9 @@ template <class _Container> |
| 35 | using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator; | 35 | using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator; |
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| 38 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 39 | template <class _Container> | 38 | template <class _Container> |
| 40 | class insert_iterator | 39 | class insert_iterator |
| 41 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 40 | : public __iterator_base<insert_iterator<_Container>, output_iterator_tag, void, void, void, void> { |
| 42 | : public iterator<output_iterator_tag, void, void, void, void> | ||
| 43 | #endif | ||
| 44 | { | ||
| 45 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 46 | |||
| 47 | protected: | 41 | protected: |
| 48 | _Container* container; | 42 | _Container* container; |
| 49 | __insert_iterator_iter_t<_Container> iter; | 43 | __insert_iterator_iter_t<_Container> iter; |
lib/libcxx/include/__iterator/istream_iterator.h+6-7| ... | @@ -25,15 +25,14 @@ | ... | @@ -25,15 +25,14 @@ |
| 25 | 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 29 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> | 28 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> |
| 30 | class istream_iterator | 29 | class istream_iterator |
| 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 30 | : public __iterator_base<istream_iterator<_Tp, _CharT, _Traits, _Distance>, |
| 32 | : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> | 31 | input_iterator_tag, |
| 33 | #endif | 32 | _Tp, |
| 34 | { | 33 | _Distance, |
| 35 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 34 | const _Tp*, |
| 36 | 35 | const _Tp&> { | |
| 37 | public: | 36 | public: |
| 38 | typedef input_iterator_tag iterator_category; | 37 | typedef input_iterator_tag iterator_category; |
| 39 | typedef _Tp value_type; | 38 | typedef _Tp value_type; |
lib/libcxx/include/__iterator/istreambuf_iterator.h+6-7| ... | @@ -25,15 +25,14 @@ | ... | @@ -25,15 +25,14 @@ |
| 25 | 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 29 | template <class _CharT, class _Traits> | 28 | template <class _CharT, class _Traits> |
| 30 | class istreambuf_iterator | 29 | class istreambuf_iterator |
| 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 30 | : public __iterator_base<istreambuf_iterator<_CharT, _Traits>, |
| 32 | : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT> | 31 | input_iterator_tag, |
| 33 | #endif | 32 | _CharT, |
| 34 | { | 33 | typename _Traits::off_type, |
| 35 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 34 | _CharT*, |
| 36 | 35 | _CharT> { | |
| 37 | public: | 36 | public: |
| 38 | typedef input_iterator_tag iterator_category; | 37 | typedef input_iterator_tag iterator_category; |
| 39 | typedef _CharT value_type; | 38 | typedef _CharT value_type; |
lib/libcxx/include/__iterator/iter_move.h+1-1| ... | @@ -40,7 +40,7 @@ void iter_move() = delete; | ... | @@ -40,7 +40,7 @@ void iter_move() = delete; |
| 40 | 40 | ||
| 41 | template <class _Tp> | 41 | template <class _Tp> |
| 42 | concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) { | 42 | concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) { |
| 43 | // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap | 43 | // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_move ADL calls should only be made through ranges::iter_move |
| 44 | iter_move(std::forward<_Tp>(__t)); | 44 | iter_move(std::forward<_Tp>(__t)); |
| 45 | }; | 45 | }; |
| 46 | 46 |
lib/libcxx/include/__iterator/iterator.h+13| ... | @@ -28,6 +28,19 @@ struct _LIBCPP_DEPRECATED_IN_CXX17 iterator { | ... | @@ -28,6 +28,19 @@ struct _LIBCPP_DEPRECATED_IN_CXX17 iterator { |
| 28 | typedef _Category iterator_category; | 28 | typedef _Category iterator_category; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 32 | #ifdef _LIBCPP_ABI_NO_ITERATOR_BASES | ||
| 33 | template <class _Derived> | ||
| 34 | struct __no_iterator_base {}; | ||
| 35 | |||
| 36 | template <class _Derived, class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> | ||
| 37 | using __iterator_base _LIBCPP_NODEBUG = __no_iterator_base<_Derived>; | ||
| 38 | #else | ||
| 39 | template <class _Derived, class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> | ||
| 40 | using __iterator_base _LIBCPP_NODEBUG = iterator<_Category, _Tp, _Distance, _Pointer, _Reference>; | ||
| 41 | #endif | ||
| 42 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 43 | |||
| 31 | _LIBCPP_END_NAMESPACE_STD | 44 | _LIBCPP_END_NAMESPACE_STD |
| 32 | 45 | ||
| 33 | #endif // _LIBCPP___ITERATOR_ITERATOR_H | 46 | #endif // _LIBCPP___ITERATOR_ITERATOR_H |
lib/libcxx/include/__iterator/iterator_traits.h+13-14| ... | @@ -420,44 +420,43 @@ using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG = | ... | @@ -420,44 +420,43 @@ using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG = |
| 420 | !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value>; | 420 | !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value>; |
| 421 | 421 | ||
| 422 | template <class _InputIterator> | 422 | template <class _InputIterator> |
| 423 | using __iter_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type; | 423 | using __iterator_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type; |
| 424 | 424 | ||
| 425 | #if _LIBCPP_STD_VER >= 23 | 425 | #if _LIBCPP_STD_VER >= 23 |
| 426 | template <class _InputIterator> | 426 | template <class _InputIterator> |
| 427 | using __iter_key_type _LIBCPP_NODEBUG = remove_const_t<tuple_element_t<0, __iter_value_type<_InputIterator>>>; | 427 | using __iter_key_type _LIBCPP_NODEBUG = remove_const_t<tuple_element_t<0, __iterator_value_type<_InputIterator>>>; |
| 428 | 428 | ||
| 429 | template <class _InputIterator> | 429 | template <class _InputIterator> |
| 430 | using __iter_mapped_type _LIBCPP_NODEBUG = tuple_element_t<1, __iter_value_type<_InputIterator>>; | 430 | using __iter_mapped_type _LIBCPP_NODEBUG = tuple_element_t<1, __iterator_value_type<_InputIterator>>; |
| 431 | 431 | ||
| 432 | template <class _InputIterator> | 432 | template <class _InputIterator> |
| 433 | using __iter_to_alloc_type _LIBCPP_NODEBUG = | 433 | using __iter_to_alloc_type _LIBCPP_NODEBUG = |
| 434 | pair<const tuple_element_t<0, __iter_value_type<_InputIterator>>, | 434 | pair<const tuple_element_t<0, __iterator_value_type<_InputIterator>>, |
| 435 | tuple_element_t<1, __iter_value_type<_InputIterator>>>; | 435 | tuple_element_t<1, __iterator_value_type<_InputIterator>>>; |
| 436 | #else | 436 | #else |
| 437 | template <class _InputIterator> | 437 | template <class _InputIterator> |
| 438 | using __iter_key_type _LIBCPP_NODEBUG = | 438 | using __iter_key_type _LIBCPP_NODEBUG = __remove_const_t<typename __iterator_value_type<_InputIterator>::first_type>; |
| 439 | __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; | ||
| 440 | 439 | ||
| 441 | template <class _InputIterator> | 440 | template <class _InputIterator> |
| 442 | using __iter_mapped_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type::second_type; | 441 | using __iter_mapped_type _LIBCPP_NODEBUG = typename __iterator_value_type<_InputIterator>::second_type; |
| 443 | 442 | ||
| 444 | template <class _InputIterator> | 443 | template <class _InputIterator> |
| 445 | using __iter_to_alloc_type _LIBCPP_NODEBUG = | 444 | using __iter_to_alloc_type _LIBCPP_NODEBUG = |
| 446 | pair<const typename iterator_traits<_InputIterator>::value_type::first_type, | 445 | pair<const typename __iterator_value_type<_InputIterator>::first_type, |
| 447 | typename iterator_traits<_InputIterator>::value_type::second_type>; | 446 | typename __iterator_value_type<_InputIterator>::second_type>; |
| 448 | #endif // _LIBCPP_STD_VER >= 23 | 447 | #endif // _LIBCPP_STD_VER >= 23 |
| 449 | 448 | ||
| 450 | template <class _Iter> | 449 | template <class _Iter> |
| 451 | using __iterator_category_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category; | 450 | using __iterator_iterator_category _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category; |
| 452 | 451 | ||
| 453 | template <class _Iter> | 452 | template <class _Iter> |
| 454 | using __iterator_pointer_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::pointer; | 453 | using __iterator_pointer _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::pointer; |
| 455 | 454 | ||
| 456 | template <class _Iter> | 455 | template <class _Iter> |
| 457 | using __iter_diff_t _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type; | 456 | using __iterator_difference_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type; |
| 458 | 457 | ||
| 459 | template <class _Iter> | 458 | template <class _Iter> |
| 460 | using __iter_reference _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::reference; | 459 | using __iterator_reference _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::reference; |
| 461 | 460 | ||
| 462 | #if _LIBCPP_STD_VER >= 20 | 461 | #if _LIBCPP_STD_VER >= 20 |
| 463 | 462 |
lib/libcxx/include/__iterator/ostream_iterator.h+1-7| ... | @@ -24,15 +24,9 @@ | ... | @@ -24,15 +24,9 @@ |
| 24 | 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 28 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > | 27 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > |
| 29 | class ostream_iterator | 28 | class ostream_iterator |
| 30 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 29 | : public __iterator_base<ostream_iterator<_Tp, _CharT, _Traits>, output_iterator_tag, void, void, void, void> { |
| 31 | : public iterator<output_iterator_tag, void, void, void, void> | ||
| 32 | #endif | ||
| 33 | { | ||
| 34 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 35 | |||
| 36 | public: | 30 | public: |
| 37 | typedef output_iterator_tag iterator_category; | 31 | typedef output_iterator_tag iterator_category; |
| 38 | typedef void value_type; | 32 | typedef void value_type; |
lib/libcxx/include/__iterator/ostreambuf_iterator.h+1-7| ... | @@ -25,15 +25,9 @@ | ... | @@ -25,15 +25,9 @@ |
| 25 | 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 29 | template <class _CharT, class _Traits> | 28 | template <class _CharT, class _Traits> |
| 30 | class ostreambuf_iterator | 29 | class ostreambuf_iterator |
| 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 30 | : public __iterator_base<ostreambuf_iterator<_CharT, _Traits>, output_iterator_tag, void, void, void, void> { |
| 32 | : public iterator<output_iterator_tag, void, void, void, void> | ||
| 33 | #endif | ||
| 34 | { | ||
| 35 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 36 | |||
| 37 | public: | 31 | public: |
| 38 | typedef output_iterator_tag iterator_category; | 32 | typedef output_iterator_tag iterator_category; |
| 39 | typedef void value_type; | 33 | typedef void value_type; |
lib/libcxx/include/__iterator/reverse_iterator.h+8-13| ... | @@ -46,21 +46,16 @@ | ... | @@ -46,21 +46,16 @@ |
| 46 | 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 48 | ||
| 49 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 50 | template <class _Iter> | 49 | template <class _Iter> |
| 51 | class reverse_iterator | 50 | class reverse_iterator |
| 52 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 51 | : public __iterator_base<reverse_iterator<_Iter>, |
| 53 | : public iterator<typename iterator_traits<_Iter>::iterator_category, | 52 | typename iterator_traits<_Iter>::iterator_category, |
| 54 | typename iterator_traits<_Iter>::value_type, | 53 | typename iterator_traits<_Iter>::value_type, |
| 55 | typename iterator_traits<_Iter>::difference_type, | 54 | typename iterator_traits<_Iter>::difference_type, |
| 56 | typename iterator_traits<_Iter>::pointer, | 55 | typename iterator_traits<_Iter>::pointer, |
| 57 | typename iterator_traits<_Iter>::reference> | 56 | typename iterator_traits<_Iter>::reference> { |
| 58 | #endif | ||
| 59 | { | ||
| 60 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 61 | |||
| 62 | private: | 57 | private: |
| 63 | #ifndef _LIBCPP_ABI_NO_ITERATOR_BASES | 58 | #ifndef _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER |
| 64 | _Iter __t_; // no longer used as of LWG #2360, not removed due to ABI break | 59 | _Iter __t_; // no longer used as of LWG #2360, not removed due to ABI break |
| 65 | #endif | 60 | #endif |
| 66 | 61 | ||
| ... | @@ -91,7 +86,7 @@ public: | ... | @@ -91,7 +86,7 @@ public: |
| 91 | using reference = typename iterator_traits<_Iter>::reference; | 86 | using reference = typename iterator_traits<_Iter>::reference; |
| 92 | #endif | 87 | #endif |
| 93 | 88 | ||
| 94 | #ifndef _LIBCPP_ABI_NO_ITERATOR_BASES | 89 | #ifndef _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER |
| 95 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator() : __t_(), current() {} | 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator() : __t_(), current() {} |
| 96 | 91 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : __t_(__x), current(__x) {} | 92 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : __t_(__x), current(__x) {} |
lib/libcxx/include/__iterator/segmented_iterator.h+3-8| ... | @@ -67,18 +67,13 @@ struct __segmented_iterator_traits; | ... | @@ -67,18 +67,13 @@ struct __segmented_iterator_traits; |
| 67 | */ | 67 | */ |
| 68 | 68 | ||
| 69 | template <class _Tp, size_t = 0> | 69 | template <class _Tp, size_t = 0> |
| 70 | struct __has_specialization : false_type {}; | 70 | inline const bool __has_specialization_v = false; |
| 71 | 71 | ||
| 72 | template <class _Tp> | 72 | template <class _Tp> |
| 73 | struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {}; | 73 | inline const bool __has_specialization_v<_Tp, sizeof(_Tp) * 0> = true; |
| 74 | 74 | ||
| 75 | template <class _Iterator> | 75 | template <class _Iterator> |
| 76 | using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >; | 76 | inline const bool __is_segmented_iterator_v = __has_specialization_v<__segmented_iterator_traits<_Iterator> >; |
| 77 | |||
| 78 | template <class _SegmentedIterator> | ||
| 79 | struct __has_random_access_local_iterator | ||
| 80 | : __has_random_access_iterator_category< | ||
| 81 | typename __segmented_iterator_traits< _SegmentedIterator >::__local_iterator > {}; | ||
| 82 | 77 | ||
| 83 | _LIBCPP_END_NAMESPACE_STD | 78 | _LIBCPP_END_NAMESPACE_STD |
| 84 | 79 |
lib/libcxx/include/__iterator/static_bounded_iter.h+3-3| ... | @@ -99,9 +99,9 @@ struct __static_bounded_iter { | ... | @@ -99,9 +99,9 @@ struct __static_bounded_iter { |
| 99 | 99 | ||
| 100 | template <class _OtherIterator, | 100 | template <class _OtherIterator, |
| 101 | __enable_if_t< | 101 | __enable_if_t< |
| 102 | _And< is_convertible<const _OtherIterator&, _Iterator>, | 102 | _And<is_convertible<const _OtherIterator&, _Iterator>, |
| 103 | _Or<is_same<reference, __iter_reference<_OtherIterator> >, | 103 | _Or<is_same<reference, __iterator_reference<_OtherIterator> >, |
| 104 | is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIterator> > > > >::value, | 104 | is_same<reference, __make_const_lvalue_ref<__iterator_reference<_OtherIterator> > > > >::value, |
| 105 | int> = 0> | 105 | int> = 0> |
| 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR |
| 107 | __static_bounded_iter(__static_bounded_iter<_OtherIterator, _Size> const& __other) _NOEXCEPT | 107 | __static_bounded_iter(__static_bounded_iter<_OtherIterator, _Size> const& __other) _NOEXCEPT |
lib/libcxx/include/__iterator/wrap_iter.h+8-6| ... | @@ -49,12 +49,12 @@ private: | ... | @@ -49,12 +49,12 @@ private: |
| 49 | 49 | ||
| 50 | public: | 50 | public: |
| 51 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {} | 51 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {} |
| 52 | template < | 52 | template <class _OtherIter, |
| 53 | class _OtherIter, | 53 | __enable_if_t< |
| 54 | __enable_if_t< _And< is_convertible<const _OtherIter&, _Iter>, | 54 | _And<is_convertible<const _OtherIter&, _Iter>, |
| 55 | _Or<is_same<reference, __iter_reference<_OtherIter> >, | 55 | _Or<is_same<reference, __iterator_reference<_OtherIter> >, |
| 56 | is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIter> > > > >::value, | 56 | is_same<reference, __make_const_lvalue_ref<__iterator_reference<_OtherIter> > > > >::value, |
| 57 | int> = 0> | 57 | int> = 0> |
| 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_OtherIter>& __u) _NOEXCEPT | 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_OtherIter>& __u) _NOEXCEPT |
| 59 | : __i_(__u.__i_) {} | 59 | : __i_(__u.__i_) {} |
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { return *__i_; } | 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { return *__i_; } |
| ... | @@ -117,6 +117,8 @@ private: | ... | @@ -117,6 +117,8 @@ private: |
| 117 | friend class span; | 117 | friend class span; |
| 118 | template <class _Tp, size_t _Size> | 118 | template <class _Tp, size_t _Size> |
| 119 | friend struct array; | 119 | friend struct array; |
| 120 | template <class _Tp, class> | ||
| 121 | friend struct __optional_iterator; | ||
| 120 | }; | 122 | }; |
| 121 | 123 | ||
| 122 | template <class _Iter1> | 124 | template <class _Iter1> |
lib/libcxx/include/__locale+3-10| ... | @@ -57,9 +57,8 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&); | ... | @@ -57,9 +57,8 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&); |
| 57 | class _LIBCPP_EXPORTED_FROM_ABI locale { | 57 | class _LIBCPP_EXPORTED_FROM_ABI locale { |
| 58 | public: | 58 | public: |
| 59 | // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor, | 59 | // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor, |
| 60 | // so it is trivially relocatable. Like shared_ptr, it is also replaceable. | 60 | // so it is trivially relocatable. |
| 61 | using __trivially_relocatable _LIBCPP_NODEBUG = locale; | 61 | using __trivially_relocatable _LIBCPP_NODEBUG = locale; |
| 62 | using __replaceable _LIBCPP_NODEBUG = locale; | ||
| 63 | 62 | ||
| 64 | // types: | 63 | // types: |
| 65 | class _LIBCPP_EXPORTED_FROM_ABI facet; | 64 | class _LIBCPP_EXPORTED_FROM_ABI facet; |
| ... | @@ -389,7 +388,7 @@ public: | ... | @@ -389,7 +388,7 @@ public: |
| 389 | static const mask xdigit = _ISXDIGIT; | 388 | static const mask xdigit = _ISXDIGIT; |
| 390 | static const mask blank = _ISBLANK; | 389 | static const mask blank = _ISBLANK; |
| 391 | static const mask __regex_word = 0x8000; | 390 | static const mask __regex_word = 0x8000; |
| 392 | # elif defined(_NEWLIB_VERSION) | 391 | # elif _LIBCPP_LIBC_NEWLIB |
| 393 | // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. | 392 | // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. |
| 394 | typedef char mask; | 393 | typedef char mask; |
| 395 | // In case char is signed, static_cast is needed to avoid warning on | 394 | // In case char is signed, static_cast is needed to avoid warning on |
| ... | @@ -585,7 +584,7 @@ public: | ... | @@ -585,7 +584,7 @@ public: |
| 585 | # ifdef _CACHED_RUNES | 584 | # ifdef _CACHED_RUNES |
| 586 | static const size_t table_size = _CACHED_RUNES; | 585 | static const size_t table_size = _CACHED_RUNES; |
| 587 | # else | 586 | # else |
| 588 | static const size_t table_size = 256; // FIXME: Don't hardcode this. | 587 | static const size_t table_size = 256; |
| 589 | # endif | 588 | # endif |
| 590 | _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; } | 589 | _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; } |
| 591 | static const mask* classic_table() _NOEXCEPT; | 590 | static const mask* classic_table() _NOEXCEPT; |
| ... | @@ -1478,9 +1477,6 @@ public: | ... | @@ -1478,9 +1477,6 @@ public: |
| 1478 | 1477 | ||
| 1479 | protected: | 1478 | protected: |
| 1480 | ~numpunct_byname() override; | 1479 | ~numpunct_byname() override; |
| 1481 | |||
| 1482 | private: | ||
| 1483 | void __init(const char*); | ||
| 1484 | }; | 1480 | }; |
| 1485 | 1481 | ||
| 1486 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1482 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| ... | @@ -1495,9 +1491,6 @@ public: | ... | @@ -1495,9 +1491,6 @@ public: |
| 1495 | 1491 | ||
| 1496 | protected: | 1492 | protected: |
| 1497 | ~numpunct_byname() override; | 1493 | ~numpunct_byname() override; |
| 1498 | |||
| 1499 | private: | ||
| 1500 | void __init(const char*); | ||
| 1501 | }; | 1494 | }; |
| 1502 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 1495 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 1503 | 1496 |
lib/libcxx/include/__locale_dir/locale_base_api.h+5-28| ... | @@ -57,15 +57,11 @@ | ... | @@ -57,15 +57,11 @@ |
| 57 | // float __strtof(const char*, char**, __locale_t); | 57 | // float __strtof(const char*, char**, __locale_t); |
| 58 | // double __strtod(const char*, char**, __locale_t); | 58 | // double __strtod(const char*, char**, __locale_t); |
| 59 | // long double __strtold(const char*, char**, __locale_t); | 59 | // long double __strtold(const char*, char**, __locale_t); |
| 60 | // long long __strtoll(const char*, char**, __locale_t); | ||
| 61 | // unsigned long long __strtoull(const char*, char**, __locale_t); | ||
| 62 | // } | 60 | // } |
| 63 | // | 61 | // |
| 64 | // Character manipulation functions | 62 | // Character manipulation functions |
| 65 | // -------------------------------- | 63 | // -------------------------------- |
| 66 | // namespace __locale { | 64 | // namespace __locale { |
| 67 | // int __isdigit(int, __locale_t); // required by the headers | ||
| 68 | // int __isxdigit(int, __locale_t); // required by the headers | ||
| 69 | // int __toupper(int, __locale_t); | 65 | // int __toupper(int, __locale_t); |
| 70 | // int __tolower(int, __locale_t); | 66 | // int __tolower(int, __locale_t); |
| 71 | // int __strcoll(const char*, const char*, __locale_t); | 67 | // int __strcoll(const char*, const char*, __locale_t); |
| ... | @@ -106,7 +102,6 @@ | ... | @@ -106,7 +102,6 @@ |
| 106 | // | 102 | // |
| 107 | // int __snprintf(char*, size_t, __locale_t, const char*, ...); // required by the headers | 103 | // int __snprintf(char*, size_t, __locale_t, const char*, ...); // required by the headers |
| 108 | // int __asprintf(char**, __locale_t, const char*, ...); // required by the headers | 104 | // int __asprintf(char**, __locale_t, const char*, ...); // required by the headers |
| 109 | // int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers | ||
| 110 | // } | 105 | // } |
| 111 | 106 | ||
| 112 | #if _LIBCPP_HAS_LOCALIZATION | 107 | #if _LIBCPP_HAS_LOCALIZATION |
| ... | @@ -115,7 +110,6 @@ | ... | @@ -115,7 +110,6 @@ |
| 115 | # include <__locale_dir/support/apple.h> | 110 | # include <__locale_dir/support/apple.h> |
| 116 | # elif defined(__FreeBSD__) | 111 | # elif defined(__FreeBSD__) |
| 117 | # include <__locale_dir/support/freebsd.h> | 112 | # include <__locale_dir/support/freebsd.h> |
| 118 | /* zig patch: https://github.com/llvm/llvm-project/pull/143055 */ | ||
| 119 | # elif defined(__NetBSD__) | 113 | # elif defined(__NetBSD__) |
| 120 | # include <__locale_dir/support/netbsd.h> | 114 | # include <__locale_dir/support/netbsd.h> |
| 121 | # elif defined(_LIBCPP_MSVCRT_LIKE) | 115 | # elif defined(_LIBCPP_MSVCRT_LIKE) |
| ... | @@ -124,20 +118,20 @@ | ... | @@ -124,20 +118,20 @@ |
| 124 | # include <__locale_dir/support/fuchsia.h> | 118 | # include <__locale_dir/support/fuchsia.h> |
| 125 | # elif defined(__linux__) | 119 | # elif defined(__linux__) |
| 126 | # include <__locale_dir/support/linux.h> | 120 | # include <__locale_dir/support/linux.h> |
| 121 | # elif _LIBCPP_LIBC_NEWLIB | ||
| 122 | # include <__locale_dir/support/newlib.h> | ||
| 123 | # elif defined(_AIX) | ||
| 124 | # include <__locale_dir/support/aix.h> | ||
| 127 | # else | 125 | # else |
| 128 | 126 | ||
| 129 | // TODO: This is a temporary definition to bridge between the old way we defined the locale base API | 127 | // TODO: This is a temporary definition to bridge between the old way we defined the locale base API |
| 130 | // (by providing global non-reserved names) and the new API. As we move individual platforms | 128 | // (by providing global non-reserved names) and the new API. As we move individual platforms |
| 131 | // towards the new way of defining the locale base API, this should disappear since each platform | 129 | // towards the new way of defining the locale base API, this should disappear since each platform |
| 132 | // will define those directly. | 130 | // will define those directly. |
| 133 | # if defined(_AIX) || defined(__MVS__) | 131 | # if defined(__MVS__) |
| 134 | # include <__locale_dir/locale_base_api/ibm.h> | 132 | # include <__locale_dir/locale_base_api/ibm.h> |
| 135 | # elif defined(__ANDROID__) | ||
| 136 | # include <__locale_dir/locale_base_api/android.h> | ||
| 137 | # elif defined(__OpenBSD__) | 133 | # elif defined(__OpenBSD__) |
| 138 | # include <__locale_dir/locale_base_api/openbsd.h> | 134 | # include <__locale_dir/locale_base_api/openbsd.h> |
| 139 | # elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC | ||
| 140 | # include <__locale_dir/locale_base_api/musl.h> | ||
| 141 | # endif | 135 | # endif |
| 142 | 136 | ||
| 143 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> | 137 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> |
| ... | @@ -197,21 +191,9 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ | ... | @@ -197,21 +191,9 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ |
| 197 | return strtold_l(__nptr, __endptr, __loc); | 191 | return strtold_l(__nptr, __endptr, __loc); |
| 198 | } | 192 | } |
| 199 | 193 | ||
| 200 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 201 | return strtoll_l(__nptr, __endptr, __base, __loc); | ||
| 202 | } | ||
| 203 | |||
| 204 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | ||
| 205 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 206 | return strtoull_l(__nptr, __endptr, __base, __loc); | ||
| 207 | } | ||
| 208 | |||
| 209 | // | 194 | // |
| 210 | // Character manipulation functions | 195 | // Character manipulation functions |
| 211 | // | 196 | // |
| 212 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); } | ||
| 213 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); } | ||
| 214 | |||
| 215 | # if defined(_LIBCPP_BUILDING_LIBRARY) | 197 | # if defined(_LIBCPP_BUILDING_LIBRARY) |
| 216 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { | 198 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { |
| 217 | return strcoll_l(__s1, __s2, __loc); | 199 | return strcoll_l(__s1, __s2, __loc); |
| ... | @@ -307,11 +289,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __ | ... | @@ -307,11 +289,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __ |
| 307 | char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { | 289 | char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { |
| 308 | return std::__libcpp_asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); | 290 | return std::__libcpp_asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); |
| 309 | } | 291 | } |
| 310 | template <class... _Args> | ||
| 311 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | ||
| 312 | const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) { | ||
| 313 | return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); | ||
| 314 | } | ||
| 315 | _LIBCPP_DIAGNOSTIC_POP | 292 | _LIBCPP_DIAGNOSTIC_POP |
| 316 | # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | 293 | # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT |
| 317 | 294 |
lib/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h-10| ... | @@ -125,16 +125,6 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l( | ... | @@ -125,16 +125,6 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l( |
| 125 | return __res; | 125 | return __res; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l( | ||
| 129 | const char* __s, locale_t __l, const char* __format, ...) { | ||
| 130 | va_list __va; | ||
| 131 | va_start(__va, __format); | ||
| 132 | __locale_guard __current(__l); | ||
| 133 | int __res = vsscanf(__s, __format, __va); | ||
| 134 | va_end(__va); | ||
| 135 | return __res; | ||
| 136 | } | ||
| 137 | |||
| 138 | _LIBCPP_END_NAMESPACE_STD | 128 | _LIBCPP_END_NAMESPACE_STD |
| 139 | 129 | ||
| 140 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H | 130 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H |
lib/libcxx/include/__locale_dir/messages.h+1-1| ... | @@ -22,7 +22,7 @@ | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | ||
| 23 | # if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) | 23 | # if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
| 24 | // Most unix variants have catopen. These are the specific ones that don't. | 24 | // Most unix variants have catopen. These are the specific ones that don't. |
| 25 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) | 25 | # if !defined(__BIONIC__) && !_LIBCPP_LIBC_NEWLIB && !defined(__EMSCRIPTEN__) |
| 26 | # define _LIBCPP_HAS_CATOPEN 1 | 26 | # define _LIBCPP_HAS_CATOPEN 1 |
| 27 | # include <nl_types.h> | 27 | # include <nl_types.h> |
| 28 | # else | 28 | # else |
lib/libcxx/include/__locale_dir/money.h+2-2| ... | @@ -433,7 +433,7 @@ bool money_get<_CharT, _InputIterator>::__do_get( | ... | @@ -433,7 +433,7 @@ bool money_get<_CharT, _InputIterator>::__do_get( |
| 433 | __err |= ios_base::failbit; | 433 | __err |= ios_base::failbit; |
| 434 | return false; | 434 | return false; |
| 435 | } | 435 | } |
| 436 | for (++__b; __fd > 0; --__fd, ++__b) { | 436 | for (++__b; __fd > 0; --__fd, (void)++__b) { |
| 437 | if (__b == __e || !__ct.is(ctype_base::digit, *__b)) { | 437 | if (__b == __e || !__ct.is(ctype_base::digit, *__b)) { |
| 438 | __err |= ios_base::failbit; | 438 | __err |= ios_base::failbit; |
| 439 | return false; | 439 | return false; |
| ... | @@ -451,7 +451,7 @@ bool money_get<_CharT, _InputIterator>::__do_get( | ... | @@ -451,7 +451,7 @@ bool money_get<_CharT, _InputIterator>::__do_get( |
| 451 | } | 451 | } |
| 452 | } | 452 | } |
| 453 | if (__trailing_sign) { | 453 | if (__trailing_sign) { |
| 454 | for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b) { | 454 | for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, (void)++__b) { |
| 455 | if (__b == __e || *__b != (*__trailing_sign)[__i]) { | 455 | if (__b == __e || *__b != (*__trailing_sign)[__i]) { |
| 456 | __err |= ios_base::failbit; | 456 | __err |= ios_base::failbit; |
| 457 | return false; | 457 | return false; |
lib/libcxx/include/__locale_dir/num.h+190-243| ... | @@ -9,8 +9,10 @@ | ... | @@ -9,8 +9,10 @@ |
| 9 | #ifndef _LIBCPP___LOCALE_DIR_NUM_H | 9 | #ifndef _LIBCPP___LOCALE_DIR_NUM_H |
| 10 | #define _LIBCPP___LOCALE_DIR_NUM_H | 10 | #define _LIBCPP___LOCALE_DIR_NUM_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy.h> | ||
| 12 | #include <__algorithm/find.h> | 13 | #include <__algorithm/find.h> |
| 13 | #include <__algorithm/reverse.h> | 14 | #include <__algorithm/reverse.h> |
| 15 | #include <__algorithm/simd_utils.h> | ||
| 14 | #include <__charconv/to_chars_integral.h> | 16 | #include <__charconv/to_chars_integral.h> |
| 15 | #include <__charconv/traits.h> | 17 | #include <__charconv/traits.h> |
| 16 | #include <__config> | 18 | #include <__config> |
| ... | @@ -22,6 +24,7 @@ | ... | @@ -22,6 +24,7 @@ |
| 22 | #include <__locale_dir/scan_keyword.h> | 24 | #include <__locale_dir/scan_keyword.h> |
| 23 | #include <__memory/unique_ptr.h> | 25 | #include <__memory/unique_ptr.h> |
| 24 | #include <__system_error/errc.h> | 26 | #include <__system_error/errc.h> |
| 27 | #include <__type_traits/is_signed.h> | ||
| 25 | #include <cerrno> | 28 | #include <cerrno> |
| 26 | #include <ios> | 29 | #include <ios> |
| 27 | #include <streambuf> | 30 | #include <streambuf> |
| ... | @@ -46,9 +49,9 @@ struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base { | ... | @@ -46,9 +49,9 @@ struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base { |
| 46 | static int __get_base(ios_base&); | 49 | static int __get_base(ios_base&); |
| 47 | static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN" | 50 | static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN" |
| 48 | // count of leading characters in __src used for parsing integers ("012..X+-") | 51 | // count of leading characters in __src used for parsing integers ("012..X+-") |
| 49 | static const size_t __int_chr_cnt = 26; | 52 | static inline const size_t __int_chr_cnt = 26; |
| 50 | // count of leading characters in __src used for parsing floating-point values ("012..-pP") | 53 | // count of leading characters in __src used for parsing floating-point values ("012..-pP") |
| 51 | static const size_t __fp_chr_cnt = 28; | 54 | static inline const size_t __fp_chr_cnt = 28; |
| 52 | }; | 55 | }; |
| 53 | 56 | ||
| 54 | template <class _CharT> | 57 | template <class _CharT> |
| ... | @@ -71,7 +74,8 @@ struct __num_get : protected __num_get_base { | ... | @@ -71,7 +74,8 @@ struct __num_get : protected __num_get_base { |
| 71 | 74 | ||
| 72 | [[__deprecated__("This exists only for ABI compatibility")]] static string | 75 | [[__deprecated__("This exists only for ABI compatibility")]] static string |
| 73 | __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); | 76 | __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); |
| 74 | static int __stage2_int_loop( | 77 | |
| 78 | [[__deprecated__("This exists only for ABI compatibility")]] static int __stage2_int_loop( | ||
| 75 | _CharT __ct, | 79 | _CharT __ct, |
| 76 | int __base, | 80 | int __base, |
| 77 | char* __a, | 81 | char* __a, |
| ... | @@ -83,11 +87,24 @@ struct __num_get : protected __num_get_base { | ... | @@ -83,11 +87,24 @@ struct __num_get : protected __num_get_base { |
| 83 | unsigned*& __g_end, | 87 | unsigned*& __g_end, |
| 84 | _CharT* __atoms); | 88 | _CharT* __atoms); |
| 85 | 89 | ||
| 86 | _LIBCPP_HIDE_FROM_ABI static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { | 90 | _LIBCPP_HIDE_FROM_ABI static ptrdiff_t __atoms_offset(const _CharT* __atoms, _CharT __val) { |
| 87 | locale __loc = __iob.getloc(); | 91 | // TODO: Remove the manual vectorization once https://llvm.org/PR168551 is resolved |
| 88 | const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); | 92 | # if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS |
| 89 | __thousands_sep = __np.thousands_sep(); | 93 | if constexpr (is_same<_CharT, char>::value) { |
| 90 | return __np.grouping(); | 94 | // TODO(LLVM 24): This can be removed, since -Wpsabi doesn't warn on [[gnu::always_inline]] functions anymore. |
| 95 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 96 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpsabi") | ||
| 97 | using __vec = __simd_vector<char, 32>; | ||
| 98 | __vec __chars = std::__broadcast<__vec>(__val); | ||
| 99 | __vec __cmp = std::__partial_load<__vec, __int_chr_cnt>(__atoms); | ||
| 100 | auto __res = __chars == __cmp; | ||
| 101 | if (std::__none_of(__res)) | ||
| 102 | return __int_chr_cnt; | ||
| 103 | return std::min(__int_chr_cnt, std::__find_first_set(__res)); | ||
| 104 | _LIBCPP_DIAGNOSTIC_POP | ||
| 105 | } | ||
| 106 | # endif | ||
| 107 | return std::find(__atoms, __atoms + __int_chr_cnt, __val) - __atoms; | ||
| 91 | } | 108 | } |
| 92 | 109 | ||
| 93 | _LIBCPP_HIDE_FROM_ABI const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const { | 110 | _LIBCPP_HIDE_FROM_ABI const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const { |
| ... | @@ -120,54 +137,6 @@ string __num_get<_CharT>::__stage2_float_prep( | ... | @@ -120,54 +137,6 @@ string __num_get<_CharT>::__stage2_float_prep( |
| 120 | return __np.grouping(); | 137 | return __np.grouping(); |
| 121 | } | 138 | } |
| 122 | 139 | ||
| 123 | template <class _CharT> | ||
| 124 | int __num_get<_CharT>::__stage2_int_loop( | ||
| 125 | _CharT __ct, | ||
| 126 | int __base, | ||
| 127 | char* __a, | ||
| 128 | char*& __a_end, | ||
| 129 | unsigned& __dc, | ||
| 130 | _CharT __thousands_sep, | ||
| 131 | const string& __grouping, | ||
| 132 | unsigned* __g, | ||
| 133 | unsigned*& __g_end, | ||
| 134 | _CharT* __atoms) { | ||
| 135 | if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { | ||
| 136 | *__a_end++ = __ct == __atoms[24] ? '+' : '-'; | ||
| 137 | __dc = 0; | ||
| 138 | return 0; | ||
| 139 | } | ||
| 140 | if (__grouping.size() != 0 && __ct == __thousands_sep) { | ||
| 141 | if (__g_end - __g < __num_get_buf_sz) { | ||
| 142 | *__g_end++ = __dc; | ||
| 143 | __dc = 0; | ||
| 144 | } | ||
| 145 | return 0; | ||
| 146 | } | ||
| 147 | ptrdiff_t __f = std::find(__atoms, __atoms + __int_chr_cnt, __ct) - __atoms; | ||
| 148 | if (__f >= 24) | ||
| 149 | return -1; | ||
| 150 | switch (__base) { | ||
| 151 | case 8: | ||
| 152 | case 10: | ||
| 153 | if (__f >= __base) | ||
| 154 | return -1; | ||
| 155 | break; | ||
| 156 | case 16: | ||
| 157 | if (__f < 22) | ||
| 158 | break; | ||
| 159 | if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0') { | ||
| 160 | __dc = 0; | ||
| 161 | *__a_end++ = __src[__f]; | ||
| 162 | return 0; | ||
| 163 | } | ||
| 164 | return -1; | ||
| 165 | } | ||
| 166 | *__a_end++ = __src[__f]; | ||
| 167 | ++__dc; | ||
| 168 | return 0; | ||
| 169 | } | ||
| 170 | |||
| 171 | template <class _CharT> | 140 | template <class _CharT> |
| 172 | int __num_get<_CharT>::__stage2_float_loop( | 141 | int __num_get<_CharT>::__stage2_float_loop( |
| 173 | _CharT __ct, | 142 | _CharT __ct, |
| ... | @@ -272,65 +241,6 @@ _LIBCPP_HIDE_FROM_ABI _Tp __num_get_float(const char* __a, const char* __a_end, | ... | @@ -272,65 +241,6 @@ _LIBCPP_HIDE_FROM_ABI _Tp __num_get_float(const char* __a, const char* __a_end, |
| 272 | return 0; | 241 | return 0; |
| 273 | } | 242 | } |
| 274 | 243 | ||
| 275 | template <class _Tp> | ||
| 276 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 277 | __num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) { | ||
| 278 | if (__a != __a_end) { | ||
| 279 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; | ||
| 280 | errno = 0; | ||
| 281 | char* __p2; | ||
| 282 | long long __ll = __locale::__strtoll(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | ||
| 283 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; | ||
| 284 | if (__current_errno == 0) | ||
| 285 | errno = __save_errno; | ||
| 286 | if (__p2 != __a_end) { | ||
| 287 | __err = ios_base::failbit; | ||
| 288 | return 0; | ||
| 289 | } else if (__current_errno == ERANGE || __ll < numeric_limits<_Tp>::min() || numeric_limits<_Tp>::max() < __ll) { | ||
| 290 | __err = ios_base::failbit; | ||
| 291 | if (__ll > 0) | ||
| 292 | return numeric_limits<_Tp>::max(); | ||
| 293 | else | ||
| 294 | return numeric_limits<_Tp>::min(); | ||
| 295 | } | ||
| 296 | return static_cast<_Tp>(__ll); | ||
| 297 | } | ||
| 298 | __err = ios_base::failbit; | ||
| 299 | return 0; | ||
| 300 | } | ||
| 301 | |||
| 302 | template <class _Tp> | ||
| 303 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 304 | __num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) { | ||
| 305 | if (__a != __a_end) { | ||
| 306 | const bool __negate = *__a == '-'; | ||
| 307 | if (__negate && ++__a == __a_end) { | ||
| 308 | __err = ios_base::failbit; | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; | ||
| 312 | errno = 0; | ||
| 313 | char* __p2; | ||
| 314 | unsigned long long __ll = __locale::__strtoull(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | ||
| 315 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; | ||
| 316 | if (__current_errno == 0) | ||
| 317 | errno = __save_errno; | ||
| 318 | if (__p2 != __a_end) { | ||
| 319 | __err = ios_base::failbit; | ||
| 320 | return 0; | ||
| 321 | } else if (__current_errno == ERANGE || numeric_limits<_Tp>::max() < __ll) { | ||
| 322 | __err = ios_base::failbit; | ||
| 323 | return numeric_limits<_Tp>::max(); | ||
| 324 | } | ||
| 325 | _Tp __res = static_cast<_Tp>(__ll); | ||
| 326 | if (__negate) | ||
| 327 | __res = -__res; | ||
| 328 | return __res; | ||
| 329 | } | ||
| 330 | __err = ios_base::failbit; | ||
| 331 | return 0; | ||
| 332 | } | ||
| 333 | |||
| 334 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | 244 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 335 | class num_get : public locale::facet, private __num_get<_CharT> { | 245 | class num_get : public locale::facet, private __num_get<_CharT> { |
| 336 | public: | 246 | public: |
| ... | @@ -468,137 +378,196 @@ protected: | ... | @@ -468,137 +378,196 @@ protected: |
| 468 | return __b; | 378 | return __b; |
| 469 | } | 379 | } |
| 470 | 380 | ||
| 471 | template <class _Signed> | 381 | template <class _MaybeSigned> |
| 472 | _LIBCPP_HIDE_FROM_ABI iter_type | 382 | iter_type __do_get_integral( |
| 473 | __do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const { | 383 | iter_type __first, iter_type __last, ios_base& __iob, ios_base::iostate& __err, _MaybeSigned& __v) const { |
| 384 | using _Unsigned = __make_unsigned_t<_MaybeSigned>; | ||
| 385 | |||
| 474 | // Stage 1 | 386 | // Stage 1 |
| 475 | int __base = this->__get_base(__iob); | 387 | int __base = this->__get_base(__iob); |
| 476 | // Stage 2 | 388 | |
| 477 | char_type __thousands_sep; | 389 | // Stages 2 & 3 |
| 478 | const int __atoms_size = __num_get_base::__int_chr_cnt; | 390 | // These are combined into a single step where we parse the characters and calculate the value in one go instead of |
| 479 | char_type __atoms1[__atoms_size]; | 391 | // storing the relevant characters first (in an allocated buffer) and parse the characters after we extracted them. |
| 480 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | 392 | // This makes the whole process significantly faster, since we avoid potential allocations and copies. |
| 481 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | 393 | |
| 482 | string __buf; | 394 | const auto& __numpunct = use_facet<numpunct<_CharT> >(__iob.getloc()); |
| 483 | __buf.resize(__buf.capacity()); | 395 | char_type __thousands_sep = __numpunct.thousands_sep(); |
| 484 | char* __a = &__buf[0]; | 396 | string __grouping = __numpunct.grouping(); |
| 485 | char* __a_end = __a; | 397 | |
| 398 | char_type __atoms_buffer[__num_get_base::__int_chr_cnt]; | ||
| 399 | const char_type* __atoms = this->__do_widen(__iob, __atoms_buffer); | ||
| 486 | unsigned __g[__num_get_base::__num_get_buf_sz]; | 400 | unsigned __g[__num_get_base::__num_get_buf_sz]; |
| 487 | unsigned* __g_end = __g; | 401 | unsigned* __g_end = __g; |
| 488 | unsigned __dc = 0; | 402 | unsigned __dc = 0; |
| 489 | for (; __b != __e; ++__b) { | 403 | |
| 490 | if (__a_end == __a + __buf.size()) { | 404 | if (__first == __last) { |
| 491 | size_t __tmp = __buf.size(); | 405 | __err |= ios_base::eofbit | ios_base::failbit; |
| 492 | __buf.resize(2 * __buf.size()); | 406 | __v = 0; |
| 493 | __buf.resize(__buf.capacity()); | 407 | return __first; |
| 494 | __a = &__buf[0]; | 408 | } |
| 495 | __a_end = __a + __tmp; | 409 | |
| 410 | while (!__grouping.empty() && *__first == __thousands_sep) { | ||
| 411 | ++__first; | ||
| 412 | if (__g_end - __g < this->__num_get_buf_sz) | ||
| 413 | *__g_end++ = 0; | ||
| 414 | } | ||
| 415 | |||
| 416 | bool __negate = false; | ||
| 417 | // __c == '+' || __c == '-' | ||
| 418 | if (auto __c = *__first; __c == __atoms[24] || __c == __atoms[25]) { | ||
| 419 | __negate = __c == __atoms[25]; | ||
| 420 | ++__first; | ||
| 421 | } | ||
| 422 | |||
| 423 | if (__first == __last) { | ||
| 424 | __err |= ios_base::eofbit | ios_base::failbit; | ||
| 425 | __v = 0; | ||
| 426 | return __first; | ||
| 427 | } | ||
| 428 | |||
| 429 | bool __parsed_num = false; | ||
| 430 | |||
| 431 | // If we don't have a pre-set base, figure it out and swallow any prefix | ||
| 432 | if (__base == 0) { | ||
| 433 | auto __c = *__first; | ||
| 434 | // __c == '0' | ||
| 435 | if (__c == __atoms[0]) { | ||
| 436 | ++__first; | ||
| 437 | if (__first == __last) { | ||
| 438 | __err |= ios_base::eofbit; | ||
| 439 | __v = 0; | ||
| 440 | return __first; | ||
| 441 | } | ||
| 442 | // __c2 == 'x' || __c2 == 'X' | ||
| 443 | if (auto __c2 = *__first; __c2 == __atoms[22] || __c2 == __atoms[23]) { | ||
| 444 | __base = 16; | ||
| 445 | ++__first; | ||
| 446 | } else { | ||
| 447 | __base = 8; | ||
| 448 | __parsed_num = true; // We only swallowed '0', so we've started to parse a number | ||
| 449 | } | ||
| 450 | } else { | ||
| 451 | __base = 10; | ||
| 452 | } | ||
| 453 | |||
| 454 | // If the base has been specified explicitly, try to swallow the appropriate prefix. We only need to do something | ||
| 455 | // special for hex, since decimal has no prefix and octal's prefix is '0', which doesn't change the value that | ||
| 456 | // we'll parse if we don't swallow it. | ||
| 457 | } else if (__base == 16) { | ||
| 458 | // Try to swallow '0x' | ||
| 459 | |||
| 460 | // *__first == '0' | ||
| 461 | if (*__first == __atoms[0]) { | ||
| 462 | ++__first; | ||
| 463 | if (__first == __last) { | ||
| 464 | __err |= ios_base::eofbit; | ||
| 465 | __v = 0; | ||
| 466 | return __first; | ||
| 467 | } | ||
| 468 | // __c == 'x' || __c == 'X' | ||
| 469 | if (auto __c = *__first; __c == __atoms[22] || __c == __atoms[23]) | ||
| 470 | ++__first; | ||
| 471 | else | ||
| 472 | __parsed_num = true; // We only swallowed '0', so we've started to parse a number | ||
| 496 | } | 473 | } |
| 497 | if (this->__stage2_int_loop( | ||
| 498 | *__b, | ||
| 499 | __base, | ||
| 500 | __a, | ||
| 501 | __a_end, | ||
| 502 | __dc, | ||
| 503 | __thousands_sep, | ||
| 504 | __grouping, | ||
| 505 | __g, | ||
| 506 | __g_end, | ||
| 507 | const_cast<char_type*>(__atoms))) | ||
| 508 | break; | ||
| 509 | } | 474 | } |
| 510 | if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz) | ||
| 511 | *__g_end++ = __dc; | ||
| 512 | // Stage 3 | ||
| 513 | __v = std::__num_get_signed_integral<_Signed>(__a, __a_end, __err, __base); | ||
| 514 | // Digit grouping checked | ||
| 515 | __check_grouping(__grouping, __g, __g_end, __err); | ||
| 516 | // EOF checked | ||
| 517 | if (__b == __e) | ||
| 518 | __err |= ios_base::eofbit; | ||
| 519 | return __b; | ||
| 520 | } | ||
| 521 | 475 | ||
| 522 | template <class _Unsigned> | 476 | // Calculate the actual number |
| 523 | _LIBCPP_HIDE_FROM_ABI iter_type | 477 | _Unsigned __val = 0; |
| 524 | __do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const { | 478 | bool __overflowed = false; |
| 525 | // Stage 1 | 479 | for (; __first != __last; ++__first) { |
| 526 | int __base = this->__get_base(__iob); | 480 | auto __c = *__first; |
| 527 | // Stage 2 | 481 | if (!__grouping.empty() && __c == __thousands_sep) { |
| 528 | char_type __thousands_sep; | 482 | if (__g_end - __g < this->__num_get_buf_sz) { |
| 529 | const int __atoms_size = __num_get_base::__int_chr_cnt; | 483 | *__g_end++ = __dc; |
| 530 | char_type __atoms1[__atoms_size]; | 484 | __dc = 0; |
| 531 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | 485 | } |
| 532 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | 486 | continue; |
| 533 | string __buf; | ||
| 534 | __buf.resize(__buf.capacity()); | ||
| 535 | char* __a = &__buf[0]; | ||
| 536 | char* __a_end = __a; | ||
| 537 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 538 | unsigned* __g_end = __g; | ||
| 539 | unsigned __dc = 0; | ||
| 540 | for (; __b != __e; ++__b) { | ||
| 541 | if (__a_end == __a + __buf.size()) { | ||
| 542 | size_t __tmp = __buf.size(); | ||
| 543 | __buf.resize(2 * __buf.size()); | ||
| 544 | __buf.resize(__buf.capacity()); | ||
| 545 | __a = &__buf[0]; | ||
| 546 | __a_end = __a + __tmp; | ||
| 547 | } | 487 | } |
| 548 | if (this->__stage2_int_loop( | 488 | auto __offset = this->__atoms_offset(__atoms, __c); |
| 549 | *__b, | 489 | if (__offset >= 22) // Not a valid integer character |
| 550 | __base, | 490 | break; |
| 551 | __a, | 491 | |
| 552 | __a_end, | 492 | if (__base == 16 && __offset >= 16) |
| 553 | __dc, | 493 | __offset -= 6; |
| 554 | __thousands_sep, | 494 | if (__offset >= __base) |
| 555 | __grouping, | ||
| 556 | __g, | ||
| 557 | __g_end, | ||
| 558 | const_cast<char_type*>(__atoms))) | ||
| 559 | break; | 495 | break; |
| 496 | // __val = (__val * __base) + __offset | ||
| 497 | __overflowed |= __builtin_mul_overflow(__val, __base, std::addressof(__val)) || | ||
| 498 | __builtin_add_overflow(__val, __offset, std::addressof(__val)); | ||
| 499 | __parsed_num = true; | ||
| 500 | ++__dc; | ||
| 501 | } | ||
| 502 | |||
| 503 | if (!__parsed_num) { | ||
| 504 | __err |= ios_base::failbit; | ||
| 505 | __v = 0; | ||
| 506 | } else if (__overflowed) { | ||
| 507 | __err |= ios_base::failbit; | ||
| 508 | __v = is_signed<_MaybeSigned>::value && __negate | ||
| 509 | ? numeric_limits<_MaybeSigned>::min() | ||
| 510 | : numeric_limits<_MaybeSigned>::max(); | ||
| 511 | } else if (!__negate) { | ||
| 512 | if (__val > static_cast<_Unsigned>(numeric_limits<_MaybeSigned>::max())) { | ||
| 513 | __err |= ios_base::failbit; | ||
| 514 | __v = numeric_limits<_MaybeSigned>::max(); | ||
| 515 | } else { | ||
| 516 | __v = __val; | ||
| 517 | } | ||
| 518 | } else if (is_signed<_MaybeSigned>::value) { | ||
| 519 | if (__val > static_cast<_Unsigned>(numeric_limits<_MaybeSigned>::max()) + 1) { | ||
| 520 | __err |= ios_base::failbit; | ||
| 521 | __v = numeric_limits<_MaybeSigned>::min(); | ||
| 522 | } else if (__val == static_cast<_Unsigned>(numeric_limits<_MaybeSigned>::max()) + 1) { | ||
| 523 | __v = numeric_limits<_MaybeSigned>::min(); | ||
| 524 | } else { | ||
| 525 | __v = -__val; | ||
| 526 | } | ||
| 527 | } else { | ||
| 528 | __v = -__val; | ||
| 560 | } | 529 | } |
| 530 | |||
| 561 | if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz) | 531 | if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz) |
| 562 | *__g_end++ = __dc; | 532 | *__g_end++ = __dc; |
| 563 | // Stage 3 | 533 | |
| 564 | __v = std::__num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base); | ||
| 565 | // Digit grouping checked | 534 | // Digit grouping checked |
| 566 | __check_grouping(__grouping, __g, __g_end, __err); | 535 | __check_grouping(__grouping, __g, __g_end, __err); |
| 567 | // EOF checked | 536 | // EOF checked |
| 568 | if (__b == __e) | 537 | if (__first == __last) |
| 569 | __err |= ios_base::eofbit; | 538 | __err |= ios_base::eofbit; |
| 570 | return __b; | 539 | return __first; |
| 571 | } | 540 | } |
| 572 | 541 | ||
| 573 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; | 542 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; |
| 574 | 543 | ||
| 575 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { | 544 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { |
| 576 | return this->__do_get_signed(__b, __e, __iob, __err, __v); | 545 | return this->__do_get_integral(__b, __e, __iob, __err, __v); |
| 577 | } | 546 | } |
| 578 | 547 | ||
| 579 | virtual iter_type | 548 | virtual iter_type |
| 580 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { | 549 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { |
| 581 | return this->__do_get_signed(__b, __e, __iob, __err, __v); | 550 | return this->__do_get_integral(__b, __e, __iob, __err, __v); |
| 582 | } | 551 | } |
| 583 | 552 | ||
| 584 | virtual iter_type | 553 | virtual iter_type |
| 585 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { | 554 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { |
| 586 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | 555 | return this->__do_get_integral(__b, __e, __iob, __err, __v); |
| 587 | } | 556 | } |
| 588 | 557 | ||
| 589 | virtual iter_type | 558 | virtual iter_type |
| 590 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { | 559 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { |
| 591 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | 560 | return this->__do_get_integral(__b, __e, __iob, __err, __v); |
| 592 | } | 561 | } |
| 593 | 562 | ||
| 594 | virtual iter_type | 563 | virtual iter_type |
| 595 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { | 564 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { |
| 596 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | 565 | return this->__do_get_integral(__b, __e, __iob, __err, __v); |
| 597 | } | 566 | } |
| 598 | 567 | ||
| 599 | virtual iter_type | 568 | virtual iter_type |
| 600 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { | 569 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { |
| 601 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | 570 | return this->__do_get_integral(__b, __e, __iob, __err, __v); |
| 602 | } | 571 | } |
| 603 | 572 | ||
| 604 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { | 573 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { |
| ... | @@ -652,40 +621,13 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( | ... | @@ -652,40 +621,13 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( |
| 652 | template <class _CharT, class _InputIterator> | 621 | template <class _CharT, class _InputIterator> |
| 653 | _InputIterator num_get<_CharT, _InputIterator>::do_get( | 622 | _InputIterator num_get<_CharT, _InputIterator>::do_get( |
| 654 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { | 623 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { |
| 655 | // Stage 1 | 624 | auto __flags = __iob.flags(); |
| 656 | int __base = 16; | 625 | __iob.flags((__flags & ~ios_base::basefield & ~ios_base::uppercase) | ios_base::hex); |
| 657 | // Stage 2 | 626 | uintptr_t __ptr; |
| 658 | char_type __atoms[__num_get_base::__int_chr_cnt]; | 627 | auto __res = __do_get_integral(__b, __e, __iob, __err, __ptr); |
| 659 | char_type __thousands_sep = char_type(); | 628 | __iob.flags(__flags); |
| 660 | string __grouping; | 629 | __v = reinterpret_cast<void*>(__ptr); |
| 661 | std::use_facet<ctype<_CharT> >(__iob.getloc()) | 630 | return __res; |
| 662 | .widen(__num_get_base::__src, __num_get_base::__src + __num_get_base::__int_chr_cnt, __atoms); | ||
| 663 | string __buf; | ||
| 664 | __buf.resize(__buf.capacity()); | ||
| 665 | char* __a = &__buf[0]; | ||
| 666 | char* __a_end = __a; | ||
| 667 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 668 | unsigned* __g_end = __g; | ||
| 669 | unsigned __dc = 0; | ||
| 670 | for (; __b != __e; ++__b) { | ||
| 671 | if (__a_end == __a + __buf.size()) { | ||
| 672 | size_t __tmp = __buf.size(); | ||
| 673 | __buf.resize(2 * __buf.size()); | ||
| 674 | __buf.resize(__buf.capacity()); | ||
| 675 | __a = &__buf[0]; | ||
| 676 | __a_end = __a + __tmp; | ||
| 677 | } | ||
| 678 | if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) | ||
| 679 | break; | ||
| 680 | } | ||
| 681 | // Stage 3 | ||
| 682 | __buf.resize(__a_end - __a); | ||
| 683 | if (__locale::__sscanf(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) | ||
| 684 | __err = ios_base::failbit; | ||
| 685 | // EOF checked | ||
| 686 | if (__b == __e) | ||
| 687 | __err |= ios_base::eofbit; | ||
| 688 | return __b; | ||
| 689 | } | 631 | } |
| 690 | 632 | ||
| 691 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; | 633 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; |
| ... | @@ -748,6 +690,13 @@ void __num_put<_CharT>::__widen_and_group_int( | ... | @@ -748,6 +690,13 @@ void __num_put<_CharT>::__widen_and_group_int( |
| 748 | __op = __ob + (__np - __nb); | 690 | __op = __ob + (__np - __nb); |
| 749 | } | 691 | } |
| 750 | 692 | ||
| 693 | _LIBCPP_HIDE_FROM_ABI inline bool __isdigit(char __c) { return __c >= '0' && __c <= '9'; } | ||
| 694 | |||
| 695 | _LIBCPP_HIDE_FROM_ABI inline bool __isxdigit(char __c) { | ||
| 696 | auto __lower = __c | 0x20; | ||
| 697 | return std::__isdigit(__c) || (__lower >= 'a' && __lower <= 'f'); | ||
| 698 | } | ||
| 699 | |||
| 751 | template <class _CharT> | 700 | template <class _CharT> |
| 752 | void __num_put<_CharT>::__widen_and_group_float( | 701 | void __num_put<_CharT>::__widen_and_group_float( |
| 753 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { | 702 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { |
| ... | @@ -763,11 +712,11 @@ void __num_put<_CharT>::__widen_and_group_float( | ... | @@ -763,11 +712,11 @@ void __num_put<_CharT>::__widen_and_group_float( |
| 763 | *__oe++ = __ct.widen(*__nf++); | 712 | *__oe++ = __ct.widen(*__nf++); |
| 764 | *__oe++ = __ct.widen(*__nf++); | 713 | *__oe++ = __ct.widen(*__nf++); |
| 765 | for (__ns = __nf; __ns < __ne; ++__ns) | 714 | for (__ns = __nf; __ns < __ne; ++__ns) |
| 766 | if (!__locale::__isxdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | 715 | if (!std::__isxdigit(*__ns)) |
| 767 | break; | 716 | break; |
| 768 | } else { | 717 | } else { |
| 769 | for (__ns = __nf; __ns < __ne; ++__ns) | 718 | for (__ns = __nf; __ns < __ne; ++__ns) |
| 770 | if (!__locale::__isdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | 719 | if (!std::__isdigit(*__ns)) |
| 771 | break; | 720 | break; |
| 772 | } | 721 | } |
| 773 | if (__grouping.empty()) { | 722 | if (__grouping.empty()) { |
| ... | @@ -885,9 +834,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty | ... | @@ -885,9 +834,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty |
| 885 | const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc()); | 834 | const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc()); |
| 886 | typedef typename numpunct<char_type>::string_type string_type; | 835 | typedef typename numpunct<char_type>::string_type string_type; |
| 887 | string_type __nm = __v ? __np.truename() : __np.falsename(); | 836 | string_type __nm = __v ? __np.truename() : __np.falsename(); |
| 888 | for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s) | 837 | return std::copy(__nm.begin(), __nm.end(), __s); |
| 889 | *__s = *__i; | ||
| 890 | return __s; | ||
| 891 | } | 838 | } |
| 892 | 839 | ||
| 893 | template <class _CharT, class _OutputIterator> | 840 | template <class _CharT, class _OutputIterator> |
lib/libcxx/include/__locale_dir/pad_and_output.h+5-6| ... | @@ -13,6 +13,8 @@ | ... | @@ -13,6 +13,8 @@ |
| 13 | 13 | ||
| 14 | #if _LIBCPP_HAS_LOCALIZATION | 14 | #if _LIBCPP_HAS_LOCALIZATION |
| 15 | 15 | ||
| 16 | # include <__algorithm/copy.h> | ||
| 17 | # include <__algorithm/fill_n.h> | ||
| 16 | # include <ios> | 18 | # include <ios> |
| 17 | 19 | ||
| 18 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -30,12 +32,9 @@ _LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output( | ... | @@ -30,12 +32,9 @@ _LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output( |
| 30 | __ns -= __sz; | 32 | __ns -= __sz; |
| 31 | else | 33 | else |
| 32 | __ns = 0; | 34 | __ns = 0; |
| 33 | for (; __ob < __op; ++__ob, ++__s) | 35 | __s = std::copy(__ob, __op, __s); |
| 34 | *__s = *__ob; | 36 | __s = std::fill_n(__s, __ns, __fl); |
| 35 | for (; __ns; --__ns, ++__s) | 37 | __s = std::copy(__op, __oe, __s); |
| 36 | *__s = __fl; | ||
| 37 | for (; __ob < __oe; ++__ob, ++__s) | ||
| 38 | *__s = *__ob; | ||
| 39 | __iob.width(0); | 38 | __iob.width(0); |
| 40 | return __s; | 39 | return __s; |
| 41 | } | 40 | } |
lib/libcxx/include/__locale_dir/support/bsd_like.h-20| ... | @@ -24,7 +24,6 @@ | ... | @@ -24,7 +24,6 @@ |
| 24 | # include <wctype.h> | 24 | # include <wctype.h> |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | /* zig patch: https://github.com/llvm/llvm-project/pull/143055 */ | ||
| 28 | #if __has_include(<xlocale.h>) | 27 | #if __has_include(<xlocale.h>) |
| 29 | # include <xlocale.h> | 28 | # include <xlocale.h> |
| 30 | #endif | 29 | #endif |
| ... | @@ -80,22 +79,9 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ | ... | @@ -80,22 +79,9 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ |
| 80 | return ::strtold_l(__nptr, __endptr, __loc); | 79 | return ::strtold_l(__nptr, __endptr, __loc); |
| 81 | } | 80 | } |
| 82 | 81 | ||
| 83 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 84 | return ::strtoll_l(__nptr, __endptr, __base, __loc); | ||
| 85 | } | ||
| 86 | |||
| 87 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | ||
| 88 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 89 | return ::strtoull_l(__nptr, __endptr, __base, __loc); | ||
| 90 | } | ||
| 91 | |||
| 92 | // | 82 | // |
| 93 | // Character manipulation functions | 83 | // Character manipulation functions |
| 94 | // | 84 | // |
| 95 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); } | ||
| 96 | |||
| 97 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); } | ||
| 98 | |||
| 99 | #if defined(_LIBCPP_BUILDING_LIBRARY) | 85 | #if defined(_LIBCPP_BUILDING_LIBRARY) |
| 100 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::toupper_l(__c, __loc); } | 86 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::toupper_l(__c, __loc); } |
| 101 | 87 | ||
| ... | @@ -216,12 +202,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __ | ... | @@ -216,12 +202,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __ |
| 216 | char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { | 202 | char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { |
| 217 | return ::asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); // non-standard | 203 | return ::asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); // non-standard |
| 218 | } | 204 | } |
| 219 | |||
| 220 | template <class... _Args> | ||
| 221 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | ||
| 222 | const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) { | ||
| 223 | return ::sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); | ||
| 224 | } | ||
| 225 | _LIBCPP_DIAGNOSTIC_POP | 205 | _LIBCPP_DIAGNOSTIC_POP |
| 226 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | 206 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT |
| 227 | 207 |
lib/libcxx/include/__locale_dir/support/fuchsia.h-7| ... | @@ -141,13 +141,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __ | ... | @@ -141,13 +141,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __ |
| 141 | __locale_guard __current(__loc); | 141 | __locale_guard __current(__loc); |
| 142 | return ::asprintf(__s, __format, std::forward<_Args>(__args)...); // non-standard | 142 | return ::asprintf(__s, __format, std::forward<_Args>(__args)...); // non-standard |
| 143 | } | 143 | } |
| 144 | template <class... _Args> | ||
| 145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | ||
| 146 | const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) { | ||
| 147 | __locale_guard __current(__loc); | ||
| 148 | return std::sscanf(__s, __format, std::forward<_Args>(__args)...); | ||
| 149 | } | ||
| 150 | |||
| 151 | _LIBCPP_DIAGNOSTIC_POP | 144 | _LIBCPP_DIAGNOSTIC_POP |
| 152 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | 145 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT |
| 153 | 146 |
lib/libcxx/include/__locale_dir/support/linux.h-37| ... | @@ -94,32 +94,9 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ | ... | @@ -94,32 +94,9 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ |
| 94 | return ::strtold_l(__nptr, __endptr, __loc); | 94 | return ::strtold_l(__nptr, __endptr, __loc); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 98 | #if !_LIBCPP_HAS_MUSL_LIBC | ||
| 99 | return ::strtoll_l(__nptr, __endptr, __base, __loc); | ||
| 100 | #else | ||
| 101 | (void)__loc; | ||
| 102 | return ::strtoll(__nptr, __endptr, __base); | ||
| 103 | #endif | ||
| 104 | } | ||
| 105 | |||
| 106 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | ||
| 107 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 108 | #if !_LIBCPP_HAS_MUSL_LIBC | ||
| 109 | return ::strtoull_l(__nptr, __endptr, __base, __loc); | ||
| 110 | #else | ||
| 111 | (void)__loc; | ||
| 112 | return ::strtoull(__nptr, __endptr, __base); | ||
| 113 | #endif | ||
| 114 | } | ||
| 115 | |||
| 116 | // | 97 | // |
| 117 | // Character manipulation functions | 98 | // Character manipulation functions |
| 118 | // | 99 | // |
| 119 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return isdigit_l(__c, __loc); } | ||
| 120 | |||
| 121 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return isxdigit_l(__c, __loc); } | ||
| 122 | |||
| 123 | #if defined(_LIBCPP_BUILDING_LIBRARY) | 100 | #if defined(_LIBCPP_BUILDING_LIBRARY) |
| 124 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return toupper_l(__c, __loc); } | 101 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return toupper_l(__c, __loc); } |
| 125 | 102 | ||
| ... | @@ -261,20 +238,6 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( | ... | @@ -261,20 +238,6 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( |
| 261 | va_end(__va); | 238 | va_end(__va); |
| 262 | return __res; | 239 | return __res; |
| 263 | } | 240 | } |
| 264 | |||
| 265 | #ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs | ||
| 266 | _LIBCPP_HIDE_FROM_ABI | ||
| 267 | #endif | ||
| 268 | inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | ||
| 269 | const char* __s, __locale_t __loc, const char* __format, ...) { | ||
| 270 | va_list __va; | ||
| 271 | va_start(__va, __format); | ||
| 272 | __locale_guard __current(__loc); | ||
| 273 | int __res = std::vsscanf(__s, __format, __va); | ||
| 274 | va_end(__va); | ||
| 275 | return __res; | ||
| 276 | } | ||
| 277 | |||
| 278 | } // namespace __locale | 241 | } // namespace __locale |
| 279 | _LIBCPP_END_NAMESPACE_STD | 242 | _LIBCPP_END_NAMESPACE_STD |
| 280 | 243 |
lib/libcxx/include/__locale_dir/support/netbsd.h-2| ... | @@ -6,8 +6,6 @@ | ... | @@ -6,8 +6,6 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | /* zig patch: https://github.com/llvm/llvm-project/pull/143055 */ | ||
| 10 | |||
| 11 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H | 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H |
| 12 | #define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H | 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H |
| 13 | 11 |
lib/libcxx/include/__locale_dir/support/newlib.h created+243| ... | @@ -0,0 +1,243 @@ | ||
| 1 | //===-----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NEWLIB_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_NEWLIB_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__cstddef/size_t.h> | ||
| 14 | #include <__std_mbstate_t.h> | ||
| 15 | #include <clocale> // std::lconv | ||
| 16 | #include <cstdio> | ||
| 17 | #include <cstdlib> | ||
| 18 | #include <ctype.h> | ||
| 19 | #include <stdarg.h> | ||
| 20 | #include <string.h> | ||
| 21 | #include <time.h> | ||
| 22 | #if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 23 | # include <cwchar> | ||
| 24 | # include <wctype.h> | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 28 | # pragma GCC system_header | ||
| 29 | #endif | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | namespace __locale { | ||
| 33 | |||
| 34 | struct __locale_guard { | ||
| 35 | _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {} | ||
| 36 | |||
| 37 | _LIBCPP_HIDE_FROM_ABI ~__locale_guard() { | ||
| 38 | if (__old_loc_) | ||
| 39 | ::uselocale(__old_loc_); | ||
| 40 | } | ||
| 41 | |||
| 42 | locale_t __old_loc_; | ||
| 43 | |||
| 44 | __locale_guard(__locale_guard const&) = delete; | ||
| 45 | __locale_guard& operator=(__locale_guard const&) = delete; | ||
| 46 | }; | ||
| 47 | |||
| 48 | // | ||
| 49 | // Locale management | ||
| 50 | // | ||
| 51 | #define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK | ||
| 52 | #define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK | ||
| 53 | #define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK | ||
| 54 | #define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK | ||
| 55 | #define _LIBCPP_TIME_MASK LC_TIME_MASK | ||
| 56 | #define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK | ||
| 57 | #define _LIBCPP_ALL_MASK LC_ALL_MASK | ||
| 58 | #define _LIBCPP_LC_ALL LC_ALL | ||
| 59 | |||
| 60 | using __locale_t _LIBCPP_NODEBUG = ::locale_t; | ||
| 61 | |||
| 62 | #if defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 63 | using __lconv_t _LIBCPP_NODEBUG = std::lconv; | ||
| 64 | |||
| 65 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) { | ||
| 66 | return ::newlocale(__category_mask, __locale, __base); | ||
| 67 | } | ||
| 68 | |||
| 69 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); } | ||
| 70 | |||
| 71 | inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) { | ||
| 72 | return ::setlocale(__category, __locale); | ||
| 73 | } | ||
| 74 | |||
| 75 | inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { | ||
| 76 | __locale_guard __current(__loc); | ||
| 77 | return std::localeconv(); | ||
| 78 | } | ||
| 79 | #endif // _LIBCPP_BUILDING_LIBRARY | ||
| 80 | |||
| 81 | // | ||
| 82 | // Strtonum functions | ||
| 83 | // | ||
| 84 | inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) { | ||
| 85 | return ::strtof_l(__nptr, __endptr, __loc); | ||
| 86 | } | ||
| 87 | |||
| 88 | inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) { | ||
| 89 | return ::strtod_l(__nptr, __endptr, __loc); | ||
| 90 | } | ||
| 91 | |||
| 92 | inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) { | ||
| 93 | return ::strtold_l(__nptr, __endptr, __loc); | ||
| 94 | } | ||
| 95 | |||
| 96 | // | ||
| 97 | // Character manipulation functions | ||
| 98 | // | ||
| 99 | #if defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 100 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return toupper_l(__c, __loc); } | ||
| 101 | |||
| 102 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return tolower_l(__c, __loc); } | ||
| 103 | |||
| 104 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { | ||
| 105 | return strcoll_l(__s1, __s2, __loc); | ||
| 106 | } | ||
| 107 | |||
| 108 | inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) { | ||
| 109 | return strxfrm_l(__dest, __src, __n, __loc); | ||
| 110 | } | ||
| 111 | |||
| 112 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 113 | inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) { | ||
| 114 | return iswctype_l(__c, __type, __loc); | ||
| 115 | } | ||
| 116 | |||
| 117 | inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return iswspace_l(__c, __loc); } | ||
| 118 | |||
| 119 | inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return iswprint_l(__c, __loc); } | ||
| 120 | |||
| 121 | inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return iswcntrl_l(__c, __loc); } | ||
| 122 | |||
| 123 | inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return iswupper_l(__c, __loc); } | ||
| 124 | |||
| 125 | inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return iswlower_l(__c, __loc); } | ||
| 126 | |||
| 127 | inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return iswalpha_l(__c, __loc); } | ||
| 128 | |||
| 129 | inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t __loc) { return iswblank_l(__c, __loc); } | ||
| 130 | |||
| 131 | inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return iswdigit_l(__c, __loc); } | ||
| 132 | |||
| 133 | inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return iswpunct_l(__c, __loc); } | ||
| 134 | |||
| 135 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return iswxdigit_l(__c, __loc); } | ||
| 136 | |||
| 137 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return towupper_l(__c, __loc); } | ||
| 138 | |||
| 139 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return towlower_l(__c, __loc); } | ||
| 140 | |||
| 141 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) { | ||
| 142 | return wcscoll_l(__ws1, __ws2, __loc); | ||
| 143 | } | ||
| 144 | |||
| 145 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) { | ||
| 146 | return wcsxfrm_l(__dest, __src, __n, __loc); | ||
| 147 | } | ||
| 148 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 149 | |||
| 150 | inline _LIBCPP_HIDE_FROM_ABI | ||
| 151 | size_t __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) { | ||
| 152 | return strftime_l(__s, __max, __format, __tm, __loc); | ||
| 153 | } | ||
| 154 | |||
| 155 | // | ||
| 156 | // Other functions | ||
| 157 | // | ||
| 158 | inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) { | ||
| 159 | __locale_guard __current(__loc); | ||
| 160 | return MB_CUR_MAX; | ||
| 161 | } | ||
| 162 | |||
| 163 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 164 | inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t __loc) { | ||
| 165 | __locale_guard __current(__loc); | ||
| 166 | return std::btowc(__c); | ||
| 167 | } | ||
| 168 | |||
| 169 | inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t __loc) { | ||
| 170 | __locale_guard __current(__loc); | ||
| 171 | return std::wctob(__c); | ||
| 172 | } | ||
| 173 | |||
| 174 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 175 | __wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) { | ||
| 176 | __locale_guard __current(__loc); | ||
| 177 | return ::wcsnrtombs(__dest, __src, __nwc, __len, __ps); // non-standard | ||
| 178 | } | ||
| 179 | |||
| 180 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t __loc) { | ||
| 181 | __locale_guard __current(__loc); | ||
| 182 | return std::wcrtomb(__s, __wc, __ps); | ||
| 183 | } | ||
| 184 | |||
| 185 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 186 | __mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) { | ||
| 187 | __locale_guard __current(__loc); | ||
| 188 | return ::mbsnrtowcs(__dest, __src, __nms, __len, __ps); // non-standard | ||
| 189 | } | ||
| 190 | |||
| 191 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 192 | __mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | ||
| 193 | __locale_guard __current(__loc); | ||
| 194 | return std::mbrtowc(__pwc, __s, __n, __ps); | ||
| 195 | } | ||
| 196 | |||
| 197 | inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) { | ||
| 198 | __locale_guard __current(__loc); | ||
| 199 | return std::mbtowc(__pwc, __pmb, __max); | ||
| 200 | } | ||
| 201 | |||
| 202 | inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | ||
| 203 | __locale_guard __current(__loc); | ||
| 204 | return std::mbrlen(__s, __n, __ps); | ||
| 205 | } | ||
| 206 | |||
| 207 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 208 | __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) { | ||
| 209 | __locale_guard __current(__loc); | ||
| 210 | return std::mbsrtowcs(__dest, __src, __len, __ps); | ||
| 211 | } | ||
| 212 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 213 | #endif // _LIBCPP_BUILDING_LIBRARY | ||
| 214 | |||
| 215 | #ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs | ||
| 216 | _LIBCPP_HIDE_FROM_ABI | ||
| 217 | #endif | ||
| 218 | inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( | ||
| 219 | char* __s, size_t __n, __locale_t __loc, const char* __format, ...) { | ||
| 220 | va_list __va; | ||
| 221 | va_start(__va, __format); | ||
| 222 | __locale_guard __current(__loc); | ||
| 223 | int __res = std::vsnprintf(__s, __n, __format, __va); | ||
| 224 | va_end(__va); | ||
| 225 | return __res; | ||
| 226 | } | ||
| 227 | |||
| 228 | #ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs | ||
| 229 | _LIBCPP_HIDE_FROM_ABI | ||
| 230 | #endif | ||
| 231 | inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( | ||
| 232 | char** __s, __locale_t __loc, const char* __format, ...) { | ||
| 233 | va_list __va; | ||
| 234 | va_start(__va, __format); | ||
| 235 | __locale_guard __current(__loc); | ||
| 236 | int __res = ::vasprintf(__s, __format, __va); // non-standard | ||
| 237 | va_end(__va); | ||
| 238 | return __res; | ||
| 239 | } | ||
| 240 | } // namespace __locale | ||
| 241 | _LIBCPP_END_NAMESPACE_STD | ||
| 242 | |||
| 243 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_NEWLIB_H | ||
lib/libcxx/include/__locale_dir/support/no_locale/characters.h-4| ... | @@ -29,10 +29,6 @@ namespace __locale { | ... | @@ -29,10 +29,6 @@ namespace __locale { |
| 29 | // | 29 | // |
| 30 | // Character manipulation functions | 30 | // Character manipulation functions |
| 31 | // | 31 | // |
| 32 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t) { return std::isdigit(__c); } | ||
| 33 | |||
| 34 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t) { return std::isxdigit(__c); } | ||
| 35 | |||
| 36 | #if defined(_LIBCPP_BUILDING_LIBRARY) | 32 | #if defined(_LIBCPP_BUILDING_LIBRARY) |
| 37 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t) { return std::toupper(__c); } | 33 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t) { return std::toupper(__c); } |
| 38 | 34 |
lib/libcxx/include/__locale_dir/support/no_locale/strtonum.h-9| ... | @@ -34,15 +34,6 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ | ... | @@ -34,15 +34,6 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __ |
| 34 | return std::strtold(__nptr, __endptr); | 34 | return std::strtold(__nptr, __endptr); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t) { | ||
| 38 | return std::strtoll(__nptr, __endptr, __base); | ||
| 39 | } | ||
| 40 | |||
| 41 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | ||
| 42 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t) { | ||
| 43 | return std::strtoull(__nptr, __endptr, __base); | ||
| 44 | } | ||
| 45 | |||
| 46 | } // namespace __locale | 37 | } // namespace __locale |
| 47 | _LIBCPP_END_NAMESPACE_STD | 38 | _LIBCPP_END_NAMESPACE_STD |
| 48 | 39 |
lib/libcxx/include/__locale_dir/support/windows.h-29| ... | @@ -186,21 +186,9 @@ inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr | ... | @@ -186,21 +186,9 @@ inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr |
| 186 | return ::_strtod_l(__nptr, __endptr, __loc); | 186 | return ::_strtod_l(__nptr, __endptr, __loc); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 190 | return ::_strtoi64_l(__nptr, __endptr, __base, __loc); | ||
| 191 | } | ||
| 192 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | ||
| 193 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ||
| 194 | return ::_strtoui64_l(__nptr, __endptr, __base, __loc); | ||
| 195 | } | ||
| 196 | |||
| 197 | // | 189 | // |
| 198 | // Character manipulation functions | 190 | // Character manipulation functions |
| 199 | // | 191 | // |
| 200 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return _isdigit_l(__c, __loc); } | ||
| 201 | |||
| 202 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return _isxdigit_l(__c, __loc); } | ||
| 203 | |||
| 204 | #if defined(_LIBCPP_BUILDING_LIBRARY) | 192 | #if defined(_LIBCPP_BUILDING_LIBRARY) |
| 205 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::_toupper_l(__c, __loc); } | 193 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::_toupper_l(__c, __loc); } |
| 206 | 194 | ||
| ... | @@ -280,23 +268,6 @@ _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snpri | ... | @@ -280,23 +268,6 @@ _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snpri |
| 280 | _LIBCPP_EXPORTED_FROM_ABI | 268 | _LIBCPP_EXPORTED_FROM_ABI |
| 281 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(char** __ret, __locale_t __loc, const char* __format, ...); | 269 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(char** __ret, __locale_t __loc, const char* __format, ...); |
| 282 | 270 | ||
| 283 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 284 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat") | ||
| 285 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates | ||
| 286 | #ifdef _LIBCPP_COMPILER_CLANG_BASED | ||
| 287 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__) | ||
| 288 | #else | ||
| 289 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */ | ||
| 290 | #endif | ||
| 291 | |||
| 292 | template <class... _Args> | ||
| 293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | ||
| 294 | const char* __dest, __locale_t __loc, const char* __format, _Args&&... __args) { | ||
| 295 | return ::_sscanf_l(__dest, __format, __loc, std::forward<_Args>(__args)...); | ||
| 296 | } | ||
| 297 | _LIBCPP_DIAGNOSTIC_POP | ||
| 298 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | ||
| 299 | |||
| 300 | #if defined(_LIBCPP_BUILDING_LIBRARY) | 271 | #if defined(_LIBCPP_BUILDING_LIBRARY) |
| 301 | struct __locale_guard { | 272 | struct __locale_guard { |
| 302 | _LIBCPP_HIDE_FROM_ABI __locale_guard(__locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) { | 273 | _LIBCPP_HIDE_FROM_ABI __locale_guard(__locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) { |
lib/libcxx/include/__locale_dir/time.h+3-7| ... | @@ -601,17 +601,13 @@ private: | ... | @@ -601,17 +601,13 @@ private: |
| 601 | template <> \ | 601 | template <> \ |
| 602 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | 602 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ |
| 603 | template <> \ | 603 | template <> \ |
| 604 | _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | 604 | void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ |
| 605 | template <> \ | 605 | template <> \ |
| 606 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ | 606 | __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ |
| 607 | char, const ctype<_CharT>&); \ | ||
| 608 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ | 607 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ |
| 609 | const; \ | 608 | const; \ |
| 610 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | 609 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ |
| 611 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | 610 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); |
| 612 | extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | ||
| 613 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ | ||
| 614 | __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); | ||
| 615 | 611 | ||
| 616 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) | 612 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) |
| 617 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 613 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
lib/libcxx/include/__math/hypot.h+1-1| ... | @@ -53,7 +53,7 @@ inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> hypot(_A1 __x, _A2 __y) _NOEX | ... | @@ -53,7 +53,7 @@ inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> hypot(_A1 __x, _A2 __y) _NOEX |
| 53 | // Computes the three-dimensional hypotenuse: `std::hypot(x,y,z)`. | 53 | // Computes the three-dimensional hypotenuse: `std::hypot(x,y,z)`. |
| 54 | // The naive implementation might over-/underflow which is why this implementation is more involved: | 54 | // The naive implementation might over-/underflow which is why this implementation is more involved: |
| 55 | // If the square of an argument might run into issues, we scale the arguments appropriately. | 55 | // If the square of an argument might run into issues, we scale the arguments appropriately. |
| 56 | // See https://github.com/llvm/llvm-project/issues/92782 for a detailed discussion and summary. | 56 | // See https://llvm.org/PR92782 for a detailed discussion and summary. |
| 57 | template <class _Real> | 57 | template <class _Real> |
| 58 | _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) { | 58 | _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) { |
| 59 | // Factors needed to determine if over-/underflow might happen | 59 | // Factors needed to determine if over-/underflow might happen |
lib/libcxx/include/__math/logarithms.h+1-1| ... | @@ -58,7 +58,7 @@ inline _LIBCPP_HIDE_FROM_ABI double log10(_A1 __x) _NOEXCEPT { | ... | @@ -58,7 +58,7 @@ inline _LIBCPP_HIDE_FROM_ABI double log10(_A1 __x) _NOEXCEPT { |
| 58 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT { return __builtin_ilogbf(__x); } | 58 | inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT { return __builtin_ilogbf(__x); } |
| 59 | 59 | ||
| 60 | template <class = int> | 60 | template <class = int> |
| 61 | _LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT { | 61 | _LIBCPP_HIDE_FROM_ABI int ilogb(double __x) _NOEXCEPT { |
| 62 | return __builtin_ilogb(__x); | 62 | return __builtin_ilogb(__x); |
| 63 | } | 63 | } |
| 64 | 64 |
lib/libcxx/include/__math/traits.h+80-11| ... | @@ -25,33 +25,26 @@ namespace __math { | ... | @@ -25,33 +25,26 @@ namespace __math { |
| 25 | 25 | ||
| 26 | // signbit | 26 | // signbit |
| 27 | 27 | ||
| 28 | // TODO(LLVM 22): Remove conditional once support for Clang 19 is dropped. | ||
| 29 | #if defined(_LIBCPP_COMPILER_GCC) || __has_constexpr_builtin(__builtin_signbit) | ||
| 30 | # define _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_CONSTEXPR_SINCE_CXX23 | ||
| 31 | #else | ||
| 32 | # define _LIBCPP_SIGNBIT_CONSTEXPR | ||
| 33 | #endif | ||
| 34 | |||
| 35 | // The universal C runtime (UCRT) in the WinSDK provides floating point overloads | 28 | // The universal C runtime (UCRT) in the WinSDK provides floating point overloads |
| 36 | // for std::signbit(). By defining our overloads as templates, we can work around | 29 | // for std::signbit(). By defining our overloads as templates, we can work around |
| 37 | // this issue as templates are less preferred than non-template functions. | 30 | // this issue as templates are less preferred than non-template functions. |
| 38 | template <class = void> | 31 | template <class = void> |
| 39 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT { | 32 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT { |
| 40 | return __builtin_signbit(__x); | 33 | return __builtin_signbit(__x); |
| 41 | } | 34 | } |
| 42 | 35 | ||
| 43 | template <class = void> | 36 | template <class = void> |
| 44 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT { | 37 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT { |
| 45 | return __builtin_signbit(__x); | 38 | return __builtin_signbit(__x); |
| 46 | } | 39 | } |
| 47 | 40 | ||
| 48 | template <class = void> | 41 | template <class = void> |
| 49 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT { | 42 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT { |
| 50 | return __builtin_signbit(__x); | 43 | return __builtin_signbit(__x); |
| 51 | } | 44 | } |
| 52 | 45 | ||
| 53 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 46 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 54 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { | 47 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { |
| 55 | return __x < 0; | 48 | return __x < 0; |
| 56 | } | 49 | } |
| 57 | 50 | ||
| ... | @@ -189,6 +182,82 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar | ... | @@ -189,6 +182,82 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar |
| 189 | return __builtin_isunordered((type)__x, (type)__y); | 182 | return __builtin_isunordered((type)__x, (type)__y); |
| 190 | } | 183 | } |
| 191 | 184 | ||
| 185 | // MS UCRT incorrectly defines some functions in a way not working with integer types. Until C++20, this was worked | ||
| 186 | // around by -fdelayed-template-parsing. Since C++20, we can use standard feature "requires" instead. | ||
| 187 | |||
| 188 | // TODO: Remove the workaround once UCRT fixes these functions. Note that this doesn't seem planned as of 2025-07 per | ||
| 189 | // https://developercommunity.visualstudio.com/t/10294165. | ||
| 190 | |||
| 191 | #if defined(_LIBCPP_MSVCRT) && _LIBCPP_STD_VER >= 20 | ||
| 192 | namespace __ucrt { | ||
| 193 | template <class _A1> | ||
| 194 | requires is_integral_v<_A1> | ||
| 195 | [[nodiscard]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) noexcept { | ||
| 196 | return true; | ||
| 197 | } | ||
| 198 | |||
| 199 | template <class _A1> | ||
| 200 | requires is_integral_v<_A1> | ||
| 201 | [[nodiscard]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) noexcept { | ||
| 202 | return false; | ||
| 203 | } | ||
| 204 | |||
| 205 | template <class _A1> | ||
| 206 | requires is_integral_v<_A1> | ||
| 207 | [[nodiscard]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) noexcept { | ||
| 208 | return false; | ||
| 209 | } | ||
| 210 | |||
| 211 | template <class _A1> | ||
| 212 | requires is_integral_v<_A1> | ||
| 213 | [[nodiscard]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) noexcept { | ||
| 214 | return __x != 0; | ||
| 215 | } | ||
| 216 | |||
| 217 | template <class _A1, class _A2> | ||
| 218 | requires is_arithmetic_v<_A1> && is_arithmetic_v<_A2> | ||
| 219 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) noexcept { | ||
| 220 | using type = __promote_t<_A1, _A2>; | ||
| 221 | return __builtin_isgreater((type)__x, (type)__y); | ||
| 222 | } | ||
| 223 | |||
| 224 | template <class _A1, class _A2> | ||
| 225 | requires is_arithmetic_v<_A1> && is_arithmetic_v<_A2> | ||
| 226 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) noexcept { | ||
| 227 | using type = __promote_t<_A1, _A2>; | ||
| 228 | return __builtin_isgreaterequal((type)__x, (type)__y); | ||
| 229 | } | ||
| 230 | |||
| 231 | template <class _A1, class _A2> | ||
| 232 | requires is_arithmetic_v<_A1> && is_arithmetic_v<_A2> | ||
| 233 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) noexcept { | ||
| 234 | using type = __promote_t<_A1, _A2>; | ||
| 235 | return __builtin_isless((type)__x, (type)__y); | ||
| 236 | } | ||
| 237 | |||
| 238 | template <class _A1, class _A2> | ||
| 239 | requires is_arithmetic_v<_A1> && is_arithmetic_v<_A2> | ||
| 240 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) noexcept { | ||
| 241 | using type = __promote_t<_A1, _A2>; | ||
| 242 | return __builtin_islessequal((type)__x, (type)__y); | ||
| 243 | } | ||
| 244 | |||
| 245 | template <class _A1, class _A2> | ||
| 246 | requires is_arithmetic_v<_A1> && is_arithmetic_v<_A2> | ||
| 247 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) noexcept { | ||
| 248 | using type = __promote_t<_A1, _A2>; | ||
| 249 | return __builtin_islessgreater((type)__x, (type)__y); | ||
| 250 | } | ||
| 251 | |||
| 252 | template <class _A1, class _A2> | ||
| 253 | requires is_arithmetic_v<_A1> && is_arithmetic_v<_A2> | ||
| 254 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) noexcept { | ||
| 255 | using type = __promote_t<_A1, _A2>; | ||
| 256 | return __builtin_isunordered((type)__x, (type)__y); | ||
| 257 | } | ||
| 258 | } // namespace __ucrt | ||
| 259 | #endif | ||
| 260 | |||
| 192 | } // namespace __math | 261 | } // namespace __math |
| 193 | 262 | ||
| 194 | _LIBCPP_END_NAMESPACE_STD | 263 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__mdspan/extents.h+7-4| ... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
| 25 | #include <__type_traits/integer_traits.h> | 25 | #include <__type_traits/integer_traits.h> |
| 26 | #include <__type_traits/is_convertible.h> | 26 | #include <__type_traits/is_convertible.h> |
| 27 | #include <__type_traits/is_nothrow_constructible.h> | 27 | #include <__type_traits/is_nothrow_constructible.h> |
| 28 | #include <__type_traits/is_signed.h> | ||
| 28 | #include <__type_traits/make_unsigned.h> | 29 | #include <__type_traits/make_unsigned.h> |
| 29 | #include <__utility/integer_sequence.h> | 30 | #include <__utility/integer_sequence.h> |
| 30 | #include <__utility/unreachable.h> | 31 | #include <__utility/unreachable.h> |
| ... | @@ -298,11 +299,13 @@ private: | ... | @@ -298,11 +299,13 @@ private: |
| 298 | 299 | ||
| 299 | public: | 300 | public: |
| 300 | // [mdspan.extents.obs], observers of multidimensional index space | 301 | // [mdspan.extents.obs], observers of multidimensional index space |
| 301 | _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank() noexcept { return __rank_; } | 302 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank() noexcept { return __rank_; } |
| 302 | _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank_dynamic() noexcept { return __rank_dynamic_; } | 303 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank_dynamic() noexcept { return __rank_dynamic_; } |
| 303 | 304 | ||
| 304 | _LIBCPP_HIDE_FROM_ABI constexpr index_type extent(rank_type __r) const noexcept { return __vals_.__value(__r); } | 305 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type extent(rank_type __r) const noexcept { |
| 305 | _LIBCPP_HIDE_FROM_ABI static constexpr size_t static_extent(rank_type __r) noexcept { | 306 | return __vals_.__value(__r); |
| 307 | } | ||
| 308 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr size_t static_extent(rank_type __r) noexcept { | ||
| 306 | return _Values::__static_value(__r); | 309 | return _Values::__static_value(__r); |
| 307 | } | 310 | } |
| 308 | 311 |
lib/libcxx/include/__mdspan/layout_stride.h+4-5| ... | @@ -272,11 +272,10 @@ public: | ... | @@ -272,11 +272,10 @@ public: |
| 272 | return [&]<size_t... _Pos>(index_sequence<_Pos...>) { | 272 | return [&]<size_t... _Pos>(index_sequence<_Pos...>) { |
| 273 | if ((__extents_.extent(_Pos) * ... * 1) == 0) | 273 | if ((__extents_.extent(_Pos) * ... * 1) == 0) |
| 274 | return static_cast<index_type>(0); | 274 | return static_cast<index_type>(0); |
| 275 | else | 275 | |
| 276 | return static_cast<index_type>( | 276 | return static_cast<index_type>( |
| 277 | static_cast<index_type>(1) + | 277 | static_cast<index_type>(1) + (((__extents_.extent(_Pos) - static_cast<index_type>(1)) * __strides_[_Pos]) + |
| 278 | (((__extents_.extent(_Pos) - static_cast<index_type>(1)) * __strides_[_Pos]) + ... + | 278 | ... + static_cast<index_type>(0))); |
| 279 | static_cast<index_type>(0))); | ||
| 280 | }(make_index_sequence<__rank_>()); | 279 | }(make_index_sequence<__rank_>()); |
| 281 | } | 280 | } |
| 282 | } | 281 | } |
lib/libcxx/include/__mdspan/mdspan.h+29-23| ... | @@ -87,16 +87,17 @@ public: | ... | @@ -87,16 +87,17 @@ public: |
| 87 | using data_handle_type = typename accessor_type::data_handle_type; | 87 | using data_handle_type = typename accessor_type::data_handle_type; |
| 88 | using reference = typename accessor_type::reference; | 88 | using reference = typename accessor_type::reference; |
| 89 | 89 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank() noexcept { return extents_type::rank(); } | 90 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank() noexcept { return extents_type::rank(); } |
| 91 | _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank_dynamic() noexcept { return extents_type::rank_dynamic(); } | 91 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank_dynamic() noexcept { |
| 92 | _LIBCPP_HIDE_FROM_ABI static constexpr size_t static_extent(rank_type __r) noexcept { | 92 | return extents_type::rank_dynamic(); |
| 93 | } | ||
| 94 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr size_t static_extent(rank_type __r) noexcept { | ||
| 93 | return extents_type::static_extent(__r); | 95 | return extents_type::static_extent(__r); |
| 94 | } | 96 | } |
| 95 | _LIBCPP_HIDE_FROM_ABI constexpr index_type extent(rank_type __r) const noexcept { | 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type extent(rank_type __r) const noexcept { |
| 96 | return __map_.extents().extent(__r); | 98 | return __map_.extents().extent(__r); |
| 97 | }; | 99 | } |
| 98 | 100 | ||
| 99 | public: | ||
| 100 | //-------------------------------------------------------------------------------- | 101 | //-------------------------------------------------------------------------------- |
| 101 | // [mdspan.mdspan.cons], mdspan constructors, assignment, and destructor | 102 | // [mdspan.mdspan.cons], mdspan constructors, assignment, and destructor |
| 102 | 103 | ||
| ... | @@ -185,7 +186,7 @@ public: | ... | @@ -185,7 +186,7 @@ public: |
| 185 | requires((is_convertible_v<_OtherIndexTypes, index_type> && ...) && | 186 | requires((is_convertible_v<_OtherIndexTypes, index_type> && ...) && |
| 186 | (is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) && | 187 | (is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) && |
| 187 | (sizeof...(_OtherIndexTypes) == rank())) | 188 | (sizeof...(_OtherIndexTypes) == rank())) |
| 188 | _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](_OtherIndexTypes... __indices) const { | 189 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](_OtherIndexTypes... __indices) const { |
| 189 | // Note the standard layouts would also check this, but user provided ones may not, so we | 190 | // Note the standard layouts would also check this, but user provided ones may not, so we |
| 190 | // check the precondition here | 191 | // check the precondition here |
| 191 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__is_multidimensional_index_in(extents(), __indices...), | 192 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__is_multidimensional_index_in(extents(), __indices...), |
| ... | @@ -196,7 +197,8 @@ public: | ... | @@ -196,7 +197,8 @@ public: |
| 196 | template <class _OtherIndexType> | 197 | template <class _OtherIndexType> |
| 197 | requires(is_convertible_v<const _OtherIndexType&, index_type> && | 198 | requires(is_convertible_v<const _OtherIndexType&, index_type> && |
| 198 | is_nothrow_constructible_v<index_type, const _OtherIndexType&>) | 199 | is_nothrow_constructible_v<index_type, const _OtherIndexType&>) |
| 199 | _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](const array< _OtherIndexType, rank()>& __indices) const { | 200 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference |
| 201 | operator[](const array< _OtherIndexType, rank()>& __indices) const { | ||
| 200 | return __acc_.access(__ptr_, [&]<size_t... _Idxs>(index_sequence<_Idxs...>) { | 202 | return __acc_.access(__ptr_, [&]<size_t... _Idxs>(index_sequence<_Idxs...>) { |
| 201 | return __map_(__indices[_Idxs]...); | 203 | return __map_(__indices[_Idxs]...); |
| 202 | }(make_index_sequence<rank()>())); | 204 | }(make_index_sequence<rank()>())); |
| ... | @@ -205,13 +207,13 @@ public: | ... | @@ -205,13 +207,13 @@ public: |
| 205 | template <class _OtherIndexType> | 207 | template <class _OtherIndexType> |
| 206 | requires(is_convertible_v<const _OtherIndexType&, index_type> && | 208 | requires(is_convertible_v<const _OtherIndexType&, index_type> && |
| 207 | is_nothrow_constructible_v<index_type, const _OtherIndexType&>) | 209 | is_nothrow_constructible_v<index_type, const _OtherIndexType&>) |
| 208 | _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](span<_OtherIndexType, rank()> __indices) const { | 210 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](span<_OtherIndexType, rank()> __indices) const { |
| 209 | return __acc_.access(__ptr_, [&]<size_t... _Idxs>(index_sequence<_Idxs...>) { | 211 | return __acc_.access(__ptr_, [&]<size_t... _Idxs>(index_sequence<_Idxs...>) { |
| 210 | return __map_(__indices[_Idxs]...); | 212 | return __map_(__indices[_Idxs]...); |
| 211 | }(make_index_sequence<rank()>())); | 213 | }(make_index_sequence<rank()>())); |
| 212 | } | 214 | } |
| 213 | 215 | ||
| 214 | _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept { | 216 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept { |
| 215 | // Could leave this as only checked in debug mode: semantically size() is never | 217 | // Could leave this as only checked in debug mode: semantically size() is never |
| 216 | // guaranteed to be related to any accessible range | 218 | // guaranteed to be related to any accessible range |
| 217 | _LIBCPP_ASSERT_UNCATEGORIZED( | 219 | _LIBCPP_ASSERT_UNCATEGORIZED( |
| ... | @@ -237,24 +239,28 @@ public: | ... | @@ -237,24 +239,28 @@ public: |
| 237 | swap(__x.__acc_, __y.__acc_); | 239 | swap(__x.__acc_, __y.__acc_); |
| 238 | } | 240 | } |
| 239 | 241 | ||
| 240 | _LIBCPP_HIDE_FROM_ABI constexpr const extents_type& extents() const noexcept { return __map_.extents(); }; | 242 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const extents_type& extents() const noexcept { |
| 241 | _LIBCPP_HIDE_FROM_ABI constexpr const data_handle_type& data_handle() const noexcept { return __ptr_; }; | 243 | return __map_.extents(); |
| 242 | _LIBCPP_HIDE_FROM_ABI constexpr const mapping_type& mapping() const noexcept { return __map_; }; | 244 | } |
| 243 | _LIBCPP_HIDE_FROM_ABI constexpr const accessor_type& accessor() const noexcept { return __acc_; }; | 245 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const data_handle_type& data_handle() const noexcept { return __ptr_; } |
| 246 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const mapping_type& mapping() const noexcept { return __map_; } | ||
| 247 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const accessor_type& accessor() const noexcept { return __acc_; } | ||
| 244 | 248 | ||
| 245 | // per LWG-4021 "mdspan::is_always_meow() should be noexcept" | 249 | // per LWG-4021 "mdspan::is_always_meow() should be noexcept" |
| 246 | _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_unique() noexcept { return mapping_type::is_always_unique(); }; | 250 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_unique() noexcept { |
| 247 | _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_exhaustive() noexcept { | 251 | return mapping_type::is_always_unique(); |
| 252 | } | ||
| 253 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_exhaustive() noexcept { | ||
| 248 | return mapping_type::is_always_exhaustive(); | 254 | return mapping_type::is_always_exhaustive(); |
| 249 | }; | 255 | } |
| 250 | _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_strided() noexcept { | 256 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_strided() noexcept { |
| 251 | return mapping_type::is_always_strided(); | 257 | return mapping_type::is_always_strided(); |
| 252 | }; | 258 | } |
| 253 | 259 | ||
| 254 | _LIBCPP_HIDE_FROM_ABI constexpr bool is_unique() const { return __map_.is_unique(); }; | 260 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_unique() const { return __map_.is_unique(); } |
| 255 | _LIBCPP_HIDE_FROM_ABI constexpr bool is_exhaustive() const { return __map_.is_exhaustive(); }; | 261 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_exhaustive() const { return __map_.is_exhaustive(); } |
| 256 | _LIBCPP_HIDE_FROM_ABI constexpr bool is_strided() const { return __map_.is_strided(); }; | 262 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_strided() const { return __map_.is_strided(); } |
| 257 | _LIBCPP_HIDE_FROM_ABI constexpr index_type stride(rank_type __r) const { return __map_.stride(__r); }; | 263 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr index_type stride(rank_type __r) const { return __map_.stride(__r); } |
| 258 | 264 | ||
| 259 | private: | 265 | private: |
| 260 | _LIBCPP_NO_UNIQUE_ADDRESS data_handle_type __ptr_{}; | 266 | _LIBCPP_NO_UNIQUE_ADDRESS data_handle_type __ptr_{}; |
lib/libcxx/include/__memory/addressof.h+7-5| ... | @@ -19,7 +19,8 @@ | ... | @@ -19,7 +19,8 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* addressof(_Tp& __x) _NOEXCEPT { | 22 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* |
| 23 | addressof(_Tp& __x) _NOEXCEPT { | ||
| 23 | return __builtin_addressof(__x); | 24 | return __builtin_addressof(__x); |
| 24 | } | 25 | } |
| 25 | 26 | ||
| ... | @@ -27,24 +28,25 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a | ... | @@ -27,24 +28,25 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a |
| 27 | // Objective-C++ Automatic Reference Counting uses qualified pointers | 28 | // Objective-C++ Automatic Reference Counting uses qualified pointers |
| 28 | // that require special addressof() signatures. | 29 | // that require special addressof() signatures. |
| 29 | template <class _Tp> | 30 | template <class _Tp> |
| 30 | inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEPT { | 31 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEPT { |
| 31 | return &__x; | 32 | return &__x; |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | # if __has_feature(objc_arc_weak) | 35 | # if __has_feature(objc_arc_weak) |
| 35 | template <class _Tp> | 36 | template <class _Tp> |
| 36 | inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT { | 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT { |
| 37 | return &__x; | 38 | return &__x; |
| 38 | } | 39 | } |
| 39 | # endif | 40 | # endif |
| 40 | 41 | ||
| 41 | template <class _Tp> | 42 | template <class _Tp> |
| 42 | inline _LIBCPP_HIDE_FROM_ABI __autoreleasing _Tp* addressof(__autoreleasing _Tp& __x) _NOEXCEPT { | 43 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __autoreleasing _Tp* addressof(__autoreleasing _Tp& __x) _NOEXCEPT { |
| 43 | return &__x; | 44 | return &__x; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | template <class _Tp> | 47 | template <class _Tp> |
| 47 | inline _LIBCPP_HIDE_FROM_ABI __unsafe_unretained _Tp* addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT { | 48 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __unsafe_unretained _Tp* |
| 49 | addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT { | ||
| 48 | return &__x; | 50 | return &__x; |
| 49 | } | 51 | } |
| 50 | #endif | 52 | #endif |
lib/libcxx/include/__memory/align.h+18-1| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <cstdint> | ||
| 14 | 15 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| ... | @@ -18,7 +19,23 @@ | ... | @@ -18,7 +19,23 @@ |
| 18 | 19 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 21 | ||
| 21 | _LIBCPP_EXPORTED_FROM_ABI void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); | 22 | inline namespace __align_inline { |
| 23 | _LIBCPP_HIDE_FROM_ABI inline void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space) { | ||
| 24 | void* __r = nullptr; | ||
| 25 | if (__sz <= __space) { | ||
| 26 | char* __p1 = static_cast<char*>(__ptr); | ||
| 27 | char* __p2 = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(__p1 + (__align - 1)) & -__align); | ||
| 28 | size_t __d = static_cast<size_t>(__p2 - __p1); | ||
| 29 | if (__d <= __space - __sz) { | ||
| 30 | __r = __p2; | ||
| 31 | __ptr = __r; | ||
| 32 | __space -= __d; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | return __r; | ||
| 36 | } | ||
| 37 | |||
| 38 | } // namespace __align_inline | ||
| 22 | 39 | ||
| 23 | _LIBCPP_END_NAMESPACE_STD | 40 | _LIBCPP_END_NAMESPACE_STD |
| 24 | 41 |
lib/libcxx/include/__memory/allocate_at_least.h+15-10| ... | @@ -19,26 +19,31 @@ | ... | @@ -19,26 +19,31 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _Pointer, class _SizeT = size_t> | ||
| 23 | struct __allocation_result { | ||
| 24 | _Pointer ptr; | ||
| 25 | _SizeT count; | ||
| 26 | |||
| 27 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __allocation_result(_Pointer __ptr, _SizeT __count) | ||
| 28 | : ptr(__ptr), count(__count) {} | ||
| 29 | }; | ||
| 30 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__allocation_result); | ||
| 31 | |||
| 22 | #if _LIBCPP_STD_VER >= 23 | 32 | #if _LIBCPP_STD_VER >= 23 |
| 23 | 33 | ||
| 24 | template <class _Alloc> | 34 | template <class _Alloc> |
| 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) { | 35 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) { |
| 26 | return std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n); | 36 | auto __res = std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n); |
| 37 | return __allocation_result{__res.ptr, __res.count}; | ||
| 27 | } | 38 | } |
| 28 | 39 | ||
| 29 | #else | 40 | #else |
| 30 | 41 | ||
| 31 | template <class _Pointer> | 42 | template <class _Alloc, class _Traits = allocator_traits<_Alloc> > |
| 32 | struct __allocation_result { | ||
| 33 | _Pointer ptr; | ||
| 34 | size_t count; | ||
| 35 | }; | ||
| 36 | |||
| 37 | template <class _Alloc> | ||
| 38 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI | 43 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI |
| 39 | _LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer> | 44 | _LIBCPP_CONSTEXPR __allocation_result<typename _Traits::pointer, typename _Traits::size_type> |
| 40 | __allocate_at_least(_Alloc& __alloc, size_t __n) { | 45 | __allocate_at_least(_Alloc& __alloc, size_t __n) { |
| 41 | return {__alloc.allocate(__n), __n}; | 46 | return __allocation_result<typename _Traits::pointer, typename _Traits::size_type>(__alloc.allocate(__n), __n); |
| 42 | } | 47 | } |
| 43 | 48 | ||
| 44 | #endif // _LIBCPP_STD_VER >= 23 | 49 | #endif // _LIBCPP_STD_VER >= 23 |
lib/libcxx/include/__memory/allocator.h+14-26| ... | @@ -14,7 +14,6 @@ | ... | @@ -14,7 +14,6 @@ |
| 14 | #include <__cstddef/ptrdiff_t.h> | 14 | #include <__cstddef/ptrdiff_t.h> |
| 15 | #include <__cstddef/size_t.h> | 15 | #include <__cstddef/size_t.h> |
| 16 | #include <__memory/addressof.h> | 16 | #include <__memory/addressof.h> |
| 17 | #include <__memory/allocate_at_least.h> | ||
| 18 | #include <__memory/allocator_traits.h> | 17 | #include <__memory/allocator_traits.h> |
| 19 | #include <__new/allocate.h> | 18 | #include <__new/allocate.h> |
| 20 | #include <__new/exceptions.h> | 19 | #include <__new/exceptions.h> |
| ... | @@ -51,33 +50,21 @@ public: | ... | @@ -51,33 +50,21 @@ public: |
| 51 | }; | 50 | }; |
| 52 | #endif // _LIBCPP_STD_VER <= 17 | 51 | #endif // _LIBCPP_STD_VER <= 17 |
| 53 | 52 | ||
| 54 | // This class provides a non-trivial default constructor to the class that derives from it | 53 | template <bool, class _Unique> |
| 55 | // if the condition is satisfied. | 54 | struct __non_trivially_default_constructible_if {}; |
| 56 | // | ||
| 57 | // The second template parameter exists to allow giving a unique type to __non_trivial_if, | ||
| 58 | // which makes it possible to avoid breaking the ABI when making this a base class of an | ||
| 59 | // existing class. Without that, imagine we have classes D1 and D2, both of which used to | ||
| 60 | // have no base classes, but which now derive from __non_trivial_if. The layout of a class | ||
| 61 | // that inherits from both D1 and D2 will change because the two __non_trivial_if base | ||
| 62 | // classes are not allowed to share the same address. | ||
| 63 | // | ||
| 64 | // By making those __non_trivial_if base classes unique, we work around this problem and | ||
| 65 | // it is safe to start deriving from __non_trivial_if in existing classes. | ||
| 66 | template <bool _Cond, class _Unique> | ||
| 67 | struct __non_trivial_if {}; | ||
| 68 | 55 | ||
| 69 | template <class _Unique> | 56 | template <class _Unique> |
| 70 | struct __non_trivial_if<true, _Unique> { | 57 | struct __non_trivially_default_constructible_if<true, _Unique> { |
| 71 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __non_trivial_if() _NOEXCEPT {} | 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __non_trivially_default_constructible_if() {} |
| 72 | }; | 59 | }; |
| 73 | 60 | ||
| 74 | // allocator | ||
| 75 | // | ||
| 76 | // Note: For ABI compatibility between C++20 and previous standards, we make | ||
| 77 | // allocator<void> trivial in C++20. | ||
| 78 | |||
| 79 | template <class _Tp> | 61 | template <class _Tp> |
| 80 | class allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > { | 62 | class allocator |
| 63 | // TODO(LLVM 24): Remove the opt-out | ||
| 64 | #ifdef _LIBCPP_DEPRECATED_ABI_NON_TRIVIAL_ALLOCATOR | ||
| 65 | : __non_trivially_default_constructible_if<!is_void<_Tp>::value, allocator<_Tp> > | ||
| 66 | #endif | ||
| 67 | { | ||
| 81 | static_assert(!is_const<_Tp>::value, "std::allocator does not support const types"); | 68 | static_assert(!is_const<_Tp>::value, "std::allocator does not support const types"); |
| 82 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); | 69 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); |
| 83 | 70 | ||
| ... | @@ -133,10 +120,11 @@ public: | ... | @@ -133,10 +120,11 @@ public: |
| 133 | typedef allocator<_Up> other; | 120 | typedef allocator<_Up> other; |
| 134 | }; | 121 | }; |
| 135 | 122 | ||
| 136 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI pointer address(reference __x) const _NOEXCEPT { | 123 | [[__nodiscard__]] _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI pointer address(reference __x) const _NOEXCEPT { |
| 137 | return std::addressof(__x); | 124 | return std::addressof(__x); |
| 138 | } | 125 | } |
| 139 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI const_pointer address(const_reference __x) const _NOEXCEPT { | 126 | [[__nodiscard__]] _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI const_pointer |
| 127 | address(const_reference __x) const _NOEXCEPT { | ||
| 140 | return std::addressof(__x); | 128 | return std::addressof(__x); |
| 141 | } | 129 | } |
| 142 | 130 | ||
| ... | @@ -144,7 +132,7 @@ public: | ... | @@ -144,7 +132,7 @@ public: |
| 144 | return allocate(__n); | 132 | return allocate(__n); |
| 145 | } | 133 | } |
| 146 | 134 | ||
| 147 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 135 | [[__nodiscard__]] _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 148 | return size_type(~0) / sizeof(_Tp); | 136 | return size_type(~0) / sizeof(_Tp); |
| 149 | } | 137 | } |
| 150 | 138 |
lib/libcxx/include/__memory/allocator_traits.h+6-4| ... | @@ -314,23 +314,25 @@ struct allocator_traits { | ... | @@ -314,23 +314,25 @@ struct allocator_traits { |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | template <class _Ap = _Alloc, __enable_if_t<__has_max_size_v<const _Ap>, int> = 0> | 316 | template <class _Ap = _Alloc, __enable_if_t<__has_max_size_v<const _Ap>, int> = 0> |
| 317 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT { | 317 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type |
| 318 | max_size(const allocator_type& __a) _NOEXCEPT { | ||
| 318 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 319 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 319 | return __a.max_size(); | 320 | return __a.max_size(); |
| 320 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 321 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 321 | } | 322 | } |
| 322 | template <class _Ap = _Alloc, __enable_if_t<!__has_max_size_v<const _Ap>, int> = 0> | 323 | template <class _Ap = _Alloc, __enable_if_t<!__has_max_size_v<const _Ap>, int> = 0> |
| 323 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT { | 324 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type |
| 325 | max_size(const allocator_type&) _NOEXCEPT { | ||
| 324 | return numeric_limits<size_type>::max() / sizeof(value_type); | 326 | return numeric_limits<size_type>::max() / sizeof(value_type); |
| 325 | } | 327 | } |
| 326 | 328 | ||
| 327 | template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction_v<const _Ap>, int> = 0> | 329 | template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction_v<const _Ap>, int> = 0> |
| 328 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type | 330 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type |
| 329 | select_on_container_copy_construction(const allocator_type& __a) { | 331 | select_on_container_copy_construction(const allocator_type& __a) { |
| 330 | return __a.select_on_container_copy_construction(); | 332 | return __a.select_on_container_copy_construction(); |
| 331 | } | 333 | } |
| 332 | template <class _Ap = _Alloc, __enable_if_t<!__has_select_on_container_copy_construction_v<const _Ap>, int> = 0> | 334 | template <class _Ap = _Alloc, __enable_if_t<!__has_select_on_container_copy_construction_v<const _Ap>, int> = 0> |
| 333 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type | 335 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type |
| 334 | select_on_container_copy_construction(const allocator_type& __a) { | 336 | select_on_container_copy_construction(const allocator_type& __a) { |
| 335 | return __a; | 337 | return __a; |
| 336 | } | 338 | } |
lib/libcxx/include/__memory/compressed_pair.h+15-9| ... | @@ -28,8 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,8 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | // understand how it works). // | 28 | // understand how it works). // |
| 29 | // ================================================================================================================== // | 29 | // ================================================================================================================== // |
| 30 | 30 | ||
| 31 | // The first member is aligned to the alignment of the second member to force padding in front of the compressed pair | 31 | // On GCC, the first member is aligned to the alignment of the second member to force padding in front of the compressed |
| 32 | // in case there are members before it. | 32 | // pair in case there are members before it. |
| 33 | // | 33 | // |
| 34 | // For example: | 34 | // For example: |
| 35 | // (assuming x86-64 linux) | 35 | // (assuming x86-64 linux) |
| ... | @@ -52,7 +52,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -52,7 +52,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 52 | // | 52 | // |
| 53 | // Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must | 53 | // Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must |
| 54 | // handle reference types specially since alignof(T&) == alignof(T). | 54 | // handle reference types specially since alignof(T&) == alignof(T). |
| 55 | // See https://github.com/llvm/llvm-project/issues/118559. | 55 | // See https://llvm.org/PR118559. |
| 56 | // | ||
| 57 | // On Clang, this is unnecessary, since we use anonymous structs instead, which automatically handle the alignment | ||
| 58 | // correctly. | ||
| 56 | 59 | ||
| 57 | #ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | 60 | #ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING |
| 58 | 61 | ||
| ... | @@ -64,7 +67,7 @@ inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*); | ... | @@ -64,7 +67,7 @@ inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*); |
| 64 | 67 | ||
| 65 | template <class _ToPad> | 68 | template <class _ToPad> |
| 66 | inline const bool __is_reference_or_unpadded_object = | 69 | inline const bool __is_reference_or_unpadded_object = |
| 67 | (is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || sizeof(_ToPad) == __datasizeof_v<_ToPad>; | 70 | (is_empty<_ToPad>::value && !__is_final_v<_ToPad>) || sizeof(_ToPad) == __datasizeof_v<_ToPad>; |
| 68 | 71 | ||
| 69 | template <class _Tp> | 72 | template <class _Tp> |
| 70 | inline const bool __is_reference_or_unpadded_object<_Tp&> = true; | 73 | inline const bool __is_reference_or_unpadded_object<_Tp&> = true; |
| ... | @@ -80,6 +83,10 @@ class __compressed_pair_padding { | ... | @@ -80,6 +83,10 @@ class __compressed_pair_padding { |
| 80 | template <class _ToPad> | 83 | template <class _ToPad> |
| 81 | class __compressed_pair_padding<_ToPad, true> {}; | 84 | class __compressed_pair_padding<_ToPad, true> {}; |
| 82 | 85 | ||
| 86 | # define _LIBCPP_COMPRESSED_ELEMENT(T1, Initializer1) \ | ||
| 87 | _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \ | ||
| 88 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding_, __LINE__, _) | ||
| 89 | |||
| 83 | // TODO: Fix the ABI for GCC as well once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121637 is fixed | 90 | // TODO: Fix the ABI for GCC as well once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121637 is fixed |
| 84 | # ifdef _LIBCPP_COMPILER_GCC | 91 | # ifdef _LIBCPP_COMPILER_GCC |
| 85 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ | 92 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ |
| ... | @@ -100,8 +107,7 @@ class __compressed_pair_padding<_ToPad, true> {}; | ... | @@ -100,8 +107,7 @@ class __compressed_pair_padding<_ToPad, true> {}; |
| 100 | # else | 107 | # else |
| 101 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ | 108 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ |
| 102 | struct { \ | 109 | struct { \ |
| 103 | _LIBCPP_NO_UNIQUE_ADDRESS \ | 110 | _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \ |
| 104 | __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \ | ||
| 105 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | 111 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ |
| 106 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | 112 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ |
| 107 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ | 113 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ |
| ... | @@ -109,9 +115,7 @@ class __compressed_pair_padding<_ToPad, true> {}; | ... | @@ -109,9 +115,7 @@ class __compressed_pair_padding<_ToPad, true> {}; |
| 109 | 115 | ||
| 110 | # define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \ | 116 | # define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \ |
| 111 | struct { \ | 117 | struct { \ |
| 112 | _LIBCPP_NO_UNIQUE_ADDRESS \ | 118 | _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \ |
| 113 | __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \ | ||
| 114 | __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \ | ||
| 115 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | 119 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ |
| 116 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | 120 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ |
| 117 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ | 121 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ |
| ... | @@ -121,6 +125,8 @@ class __compressed_pair_padding<_ToPad, true> {}; | ... | @@ -121,6 +125,8 @@ class __compressed_pair_padding<_ToPad, true> {}; |
| 121 | # endif | 125 | # endif |
| 122 | 126 | ||
| 123 | #else | 127 | #else |
| 128 | # define _LIBCPP_COMPRESSED_ELEMENT(T1, Initializer1) _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1 | ||
| 129 | |||
| 124 | # define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ | 130 | # define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ |
| 125 | _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \ | 131 | _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \ |
| 126 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2 | 132 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2 |
lib/libcxx/include/__memory/construct_at.h+12-23| ... | @@ -14,7 +14,6 @@ | ... | @@ -14,7 +14,6 @@ |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__memory/addressof.h> | 15 | #include <__memory/addressof.h> |
| 16 | #include <__new/placement_new_delete.h> | 16 | #include <__new/placement_new_delete.h> |
| 17 | #include <__type_traits/enable_if.h> | ||
| 18 | #include <__type_traits/is_array.h> | 17 | #include <__type_traits/is_array.h> |
| 19 | #include <__utility/declval.h> | 18 | #include <__utility/declval.h> |
| 20 | #include <__utility/forward.h> | 19 | #include <__utility/forward.h> |
| ... | @@ -33,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -33,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | #if _LIBCPP_STD_VER >= 20 | 32 | #if _LIBCPP_STD_VER >= 20 |
| 34 | 33 | ||
| 35 | template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> | 34 | template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) { | 35 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* _LIBCPP_DIAGNOSE_NULLPTR __location, _Args&&... __args) { |
| 37 | _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"); | 36 | _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"); |
| 38 | return ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...); | 37 | return ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...); |
| 39 | } | 38 | } |
| ... | @@ -55,35 +54,25 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l | ... | @@ -55,35 +54,25 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l |
| 55 | // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` | 54 | // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` |
| 56 | // taking an array). | 55 | // taking an array). |
| 57 | 56 | ||
| 58 | template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> | 57 | template <class _Tp> |
| 59 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { | 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { |
| 60 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); | 59 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); |
| 61 | __loc->~_Tp(); | ||
| 62 | } | ||
| 63 | |||
| 64 | #if _LIBCPP_STD_VER >= 20 | 60 | #if _LIBCPP_STD_VER >= 20 |
| 65 | template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0> | 61 | if constexpr (is_array_v<_Tp>) { |
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr void __destroy_at(_Tp* __loc) { | 62 | for (auto&& __val : *__loc) |
| 67 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); | 63 | std::__destroy_at(std::addressof(__val)); |
| 68 | for (auto&& __val : *__loc) | 64 | } else |
| 69 | std::__destroy_at(std::addressof(__val)); | ||
| 70 | } | ||
| 71 | #endif | 65 | #endif |
| 72 | 66 | { | |
| 73 | #if _LIBCPP_STD_VER >= 17 | 67 | __loc->~_Tp(); |
| 74 | 68 | } | |
| 75 | template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> | ||
| 76 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) { | ||
| 77 | std::__destroy_at(__loc); | ||
| 78 | } | 69 | } |
| 79 | 70 | ||
| 80 | # if _LIBCPP_STD_VER >= 20 | 71 | #if _LIBCPP_STD_VER >= 17 |
| 81 | template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0> | 72 | template <class _Tp> |
| 82 | _LIBCPP_HIDE_FROM_ABI constexpr void destroy_at(_Tp* __loc) { | 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* _LIBCPP_DIAGNOSE_NULLPTR __loc) { |
| 83 | std::__destroy_at(__loc); | 74 | std::__destroy_at(__loc); |
| 84 | } | 75 | } |
| 85 | # endif | ||
| 86 | |||
| 87 | #endif // _LIBCPP_STD_VER >= 17 | 76 | #endif // _LIBCPP_STD_VER >= 17 |
| 88 | 77 | ||
| 89 | _LIBCPP_END_NAMESPACE_STD | 78 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__memory/inout_ptr.h+1-1| ... | @@ -96,7 +96,7 @@ private: | ... | @@ -96,7 +96,7 @@ private: |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | template <class _Pointer = void, class _Smart, class... _Args> | 98 | template <class _Pointer = void, class _Smart, class... _Args> |
| 99 | _LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) { | 99 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) { |
| 100 | using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; | 100 | using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; |
| 101 | return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); | 101 | return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); |
| 102 | } | 102 | } |
lib/libcxx/include/__memory/is_sufficiently_aligned.h+1-1| ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if _LIBCPP_STD_VER >= 26 | 23 | #if _LIBCPP_STD_VER >= 26 |
| 24 | 24 | ||
| 25 | template <size_t _Alignment, class _Tp> | 25 | template <size_t _Alignment, class _Tp> |
| 26 | _LIBCPP_HIDE_FROM_ABI bool is_sufficiently_aligned(_Tp* __ptr) { | 26 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_sufficiently_aligned(_Tp* __ptr) { |
| 27 | return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0; | 27 | return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0; |
| 28 | } | 28 | } |
| 29 | 29 |
lib/libcxx/include/__memory/out_ptr.h+1-1| ... | @@ -88,7 +88,7 @@ private: | ... | @@ -88,7 +88,7 @@ private: |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | template <class _Pointer = void, class _Smart, class... _Args> | 90 | template <class _Pointer = void, class _Smart, class... _Args> |
| 91 | _LIBCPP_HIDE_FROM_ABI auto out_ptr(_Smart& __s, _Args&&... __args) { | 91 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto out_ptr(_Smart& __s, _Args&&... __args) { |
| 92 | using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; | 92 | using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>; |
| 93 | return std::out_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); | 93 | return std::out_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...); |
| 94 | } | 94 | } |
lib/libcxx/include/__memory/pointer_traits.h+1-1| ... | @@ -255,7 +255,7 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p | ... | @@ -255,7 +255,7 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p |
| 255 | // This function ensures safe conversions between fancy pointers at compile-time, where we avoid casts from/to | 255 | // This function ensures safe conversions between fancy pointers at compile-time, where we avoid casts from/to |
| 256 | // `__void_pointer` by obtaining the underlying raw pointer from the fancy pointer using `std::to_address`, | 256 | // `__void_pointer` by obtaining the underlying raw pointer from the fancy pointer using `std::to_address`, |
| 257 | // then dereferencing it to retrieve the pointed-to object, and finally constructing the target fancy pointer | 257 | // then dereferencing it to retrieve the pointed-to object, and finally constructing the target fancy pointer |
| 258 | // to that object using the `std::pointer_traits<>::pinter_to` function. | 258 | // to that object using the `std::pointer_traits<>::pointer_to` function. |
| 259 | template <class _PtrTo, class _PtrFrom> | 259 | template <class _PtrTo, class _PtrFrom> |
| 260 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) { | 260 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) { |
| 261 | using __ptr_traits = pointer_traits<_PtrTo>; | 261 | using __ptr_traits = pointer_traits<_PtrTo>; |
lib/libcxx/include/__memory/raw_storage_iterator.h+3-9| ... | @@ -28,15 +28,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,15 +28,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR) | 29 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR) |
| 30 | 30 | ||
| 31 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 32 | template <class _OutputIterator, class _Tp> | 31 | template <class _OutputIterator, class _Tp> |
| 33 | class _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator | 32 | class _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator |
| 34 | # if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 33 | : public __iterator_base<raw_storage_iterator<_OutputIterator, _Tp>, output_iterator_tag, void, void, void, void> { |
| 35 | : public iterator<output_iterator_tag, void, void, void, void> | ||
| 36 | # endif | ||
| 37 | { | ||
| 38 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 39 | |||
| 40 | private: | 34 | private: |
| 41 | _OutputIterator __x_; | 35 | _OutputIterator __x_; |
| 42 | 36 | ||
| ... | @@ -52,7 +46,7 @@ public: | ... | @@ -52,7 +46,7 @@ public: |
| 52 | typedef void reference; | 46 | typedef void reference; |
| 53 | 47 | ||
| 54 | _LIBCPP_HIDE_FROM_ABI explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} | 48 | _LIBCPP_HIDE_FROM_ABI explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} |
| 55 | _LIBCPP_HIDE_FROM_ABI raw_storage_iterator& operator*() { return *this; } | 49 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI raw_storage_iterator& operator*() { return *this; } |
| 56 | _LIBCPP_HIDE_FROM_ABI raw_storage_iterator& operator=(const _Tp& __element) { | 50 | _LIBCPP_HIDE_FROM_ABI raw_storage_iterator& operator=(const _Tp& __element) { |
| 57 | ::new ((void*)std::addressof(*__x_)) _Tp(__element); | 51 | ::new ((void*)std::addressof(*__x_)) _Tp(__element); |
| 58 | return *this; | 52 | return *this; |
| ... | @@ -73,7 +67,7 @@ public: | ... | @@ -73,7 +67,7 @@ public: |
| 73 | return __t; | 67 | return __t; |
| 74 | } | 68 | } |
| 75 | # if _LIBCPP_STD_VER >= 14 | 69 | # if _LIBCPP_STD_VER >= 14 |
| 76 | _LIBCPP_HIDE_FROM_ABI _OutputIterator base() const { return __x_; } | 70 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _OutputIterator base() const { return __x_; } |
| 77 | # endif | 71 | # endif |
| 78 | }; | 72 | }; |
| 79 | 73 |
lib/libcxx/include/__memory/shared_count.h+9-30| ... | @@ -22,37 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,37 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) | 22 | // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) |
| 23 | // should be sufficient for thread safety. | 23 | // should be sufficient for thread safety. |
| 24 | // See https://llvm.org/PR22803 | 24 | // See https://llvm.org/PR22803 |
| 25 | #if (defined(__clang__) && __has_builtin(__atomic_add_fetch) && defined(__ATOMIC_RELAXED) && \ | ||
| 26 | defined(__ATOMIC_ACQ_REL)) || \ | ||
| 27 | defined(_LIBCPP_COMPILER_GCC) | ||
| 28 | # define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 1 | ||
| 29 | #else | ||
| 30 | # define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 0 | ||
| 31 | #endif | ||
| 32 | |||
| 33 | template <class _ValueType> | ||
| 34 | inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_relaxed_load(_ValueType const* __value) { | ||
| 35 | #if _LIBCPP_HAS_THREADS && defined(__ATOMIC_RELAXED) && \ | ||
| 36 | (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) | ||
| 37 | return __atomic_load_n(__value, __ATOMIC_RELAXED); | ||
| 38 | #else | ||
| 39 | return *__value; | ||
| 40 | #endif | ||
| 41 | } | ||
| 42 | |||
| 43 | template <class _ValueType> | ||
| 44 | inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* __value) { | ||
| 45 | #if _LIBCPP_HAS_THREADS && defined(__ATOMIC_ACQUIRE) && \ | ||
| 46 | (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) | ||
| 47 | return __atomic_load_n(__value, __ATOMIC_ACQUIRE); | ||
| 48 | #else | ||
| 49 | return *__value; | ||
| 50 | #endif | ||
| 51 | } | ||
| 52 | 25 | ||
| 53 | template <class _Tp> | 26 | template <class _Tp> |
| 54 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT { | 27 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT { |
| 55 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS | 28 | #if _LIBCPP_HAS_THREADS |
| 56 | return __atomic_add_fetch(std::addressof(__t), 1, __ATOMIC_RELAXED); | 29 | return __atomic_add_fetch(std::addressof(__t), 1, __ATOMIC_RELAXED); |
| 57 | #else | 30 | #else |
| 58 | return __t += 1; | 31 | return __t += 1; |
| ... | @@ -61,7 +34,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _N | ... | @@ -61,7 +34,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _N |
| 61 | 34 | ||
| 62 | template <class _Tp> | 35 | template <class _Tp> |
| 63 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { | 36 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { |
| 64 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS | 37 | #if _LIBCPP_HAS_THREADS |
| 65 | return __atomic_add_fetch(std::addressof(__t), -1, __ATOMIC_ACQ_REL); | 38 | return __atomic_add_fetch(std::addressof(__t), -1, __ATOMIC_ACQ_REL); |
| 66 | #else | 39 | #else |
| 67 | return __t -= 1; | 40 | return __t -= 1; |
| ... | @@ -95,7 +68,13 @@ public: | ... | @@ -95,7 +68,13 @@ public: |
| 95 | return false; | 68 | return false; |
| 96 | } | 69 | } |
| 97 | #endif | 70 | #endif |
| 98 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __libcpp_relaxed_load(&__shared_owners_) + 1; } | 71 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { |
| 72 | #if _LIBCPP_HAS_THREADS | ||
| 73 | return __atomic_load_n(&__shared_owners_, __ATOMIC_RELAXED) + 1; | ||
| 74 | #else | ||
| 75 | return __shared_owners_ + 1; | ||
| 76 | #endif | ||
| 77 | } | ||
| 99 | }; | 78 | }; |
| 100 | 79 | ||
| 101 | class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count { | 80 | class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count { |
lib/libcxx/include/__memory/shared_ptr.h+100-145| ... | @@ -41,19 +41,18 @@ | ... | @@ -41,19 +41,18 @@ |
| 41 | #include <__type_traits/enable_if.h> | 41 | #include <__type_traits/enable_if.h> |
| 42 | #include <__type_traits/integral_constant.h> | 42 | #include <__type_traits/integral_constant.h> |
| 43 | #include <__type_traits/is_array.h> | 43 | #include <__type_traits/is_array.h> |
| 44 | #include <__type_traits/is_bounded_array.h> | ||
| 45 | #include <__type_traits/is_constructible.h> | 44 | #include <__type_traits/is_constructible.h> |
| 46 | #include <__type_traits/is_convertible.h> | 45 | #include <__type_traits/is_convertible.h> |
| 47 | #include <__type_traits/is_function.h> | 46 | #include <__type_traits/is_function.h> |
| 48 | #include <__type_traits/is_reference.h> | 47 | #include <__type_traits/is_reference.h> |
| 49 | #include <__type_traits/is_same.h> | 48 | #include <__type_traits/is_same.h> |
| 50 | #include <__type_traits/is_unbounded_array.h> | ||
| 51 | #include <__type_traits/nat.h> | 49 | #include <__type_traits/nat.h> |
| 52 | #include <__type_traits/negation.h> | 50 | #include <__type_traits/negation.h> |
| 53 | #include <__type_traits/remove_cv.h> | 51 | #include <__type_traits/remove_cv.h> |
| 54 | #include <__type_traits/remove_extent.h> | 52 | #include <__type_traits/remove_extent.h> |
| 55 | #include <__type_traits/remove_reference.h> | 53 | #include <__type_traits/remove_reference.h> |
| 56 | #include <__utility/declval.h> | 54 | #include <__utility/declval.h> |
| 55 | #include <__utility/exception_guard.h> | ||
| 57 | #include <__utility/forward.h> | 56 | #include <__utility/forward.h> |
| 58 | #include <__utility/move.h> | 57 | #include <__utility/move.h> |
| 59 | #include <__utility/swap.h> | 58 | #include <__utility/swap.h> |
| ... | @@ -78,7 +77,7 @@ public: | ... | @@ -78,7 +77,7 @@ public: |
| 78 | _LIBCPP_HIDE_FROM_ABI bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; | 77 | _LIBCPP_HIDE_FROM_ABI bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; |
| 79 | _LIBCPP_HIDE_FROM_ABI bad_weak_ptr& operator=(const bad_weak_ptr&) _NOEXCEPT = default; | 78 | _LIBCPP_HIDE_FROM_ABI bad_weak_ptr& operator=(const bad_weak_ptr&) _NOEXCEPT = default; |
| 80 | ~bad_weak_ptr() _NOEXCEPT override; | 79 | ~bad_weak_ptr() _NOEXCEPT override; |
| 81 | const char* what() const _NOEXCEPT override; | 80 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 82 | }; | 81 | }; |
| 83 | 82 | ||
| 84 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { | 83 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { |
| ... | @@ -316,10 +315,8 @@ public: | ... | @@ -316,10 +315,8 @@ public: |
| 316 | #endif | 315 | #endif |
| 317 | 316 | ||
| 318 | // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require | 317 | // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require |
| 319 | // any bookkeeping, so it's always trivially relocatable. It is also replaceable because assignment just rebinds the | 318 | // any bookkeeping, so it's always trivially relocatable. |
| 320 | // shared_ptr to manage a different object. | ||
| 321 | using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr; | 319 | using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr; |
| 322 | using __replaceable _LIBCPP_NODEBUG = shared_ptr; | ||
| 323 | 320 | ||
| 324 | private: | 321 | private: |
| 325 | element_type* __ptr_; | 322 | element_type* __ptr_; |
| ... | @@ -352,23 +349,16 @@ public: | ... | @@ -352,23 +349,16 @@ public: |
| 352 | 349 | ||
| 353 | template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> | 350 | template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 354 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) { | 351 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) { |
| 355 | #if _LIBCPP_HAS_EXCEPTIONS | 352 | auto __guard = std::__make_exception_guard([&] { __d(__p); }); |
| 356 | try { | 353 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; |
| 357 | #endif // _LIBCPP_HAS_EXCEPTIONS | 354 | typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk; |
| 358 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | ||
| 359 | typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk; | ||
| 360 | #ifndef _LIBCPP_CXX03_LANG | 355 | #ifndef _LIBCPP_CXX03_LANG |
| 361 | __cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT()); | 356 | __cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT()); |
| 362 | #else | 357 | #else |
| 363 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); | 358 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); |
| 364 | #endif // not _LIBCPP_CXX03_LANG | 359 | #endif // not _LIBCPP_CXX03_LANG |
| 365 | __enable_weak_this(__p, __p); | 360 | __enable_weak_this(__p, __p); |
| 366 | #if _LIBCPP_HAS_EXCEPTIONS | 361 | __guard.__complete(); |
| 367 | } catch (...) { | ||
| 368 | __d(__p); | ||
| 369 | throw; | ||
| 370 | } | ||
| 371 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 372 | } | 362 | } |
| 373 | 363 | ||
| 374 | template <class _Yp, | 364 | template <class _Yp, |
| ... | @@ -376,28 +366,21 @@ public: | ... | @@ -376,28 +366,21 @@ public: |
| 376 | class _Alloc, | 366 | class _Alloc, |
| 377 | __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> | 367 | __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 378 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) { | 368 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) { |
| 379 | #if _LIBCPP_HAS_EXCEPTIONS | 369 | auto __guard = std::__make_exception_guard([&] { __d(__p); }); |
| 380 | try { | 370 | typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; |
| 381 | #endif // _LIBCPP_HAS_EXCEPTIONS | 371 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; |
| 382 | typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; | 372 | typedef __allocator_destructor<_A2> _D2; |
| 383 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | 373 | _A2 __a2(__a); |
| 384 | typedef __allocator_destructor<_A2> _D2; | 374 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); |
| 385 | _A2 __a2(__a); | 375 | ::new ((void*)std::addressof(*__hold2.get())) |
| 386 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | ||
| 387 | ::new ((void*)std::addressof(*__hold2.get())) | ||
| 388 | #ifndef _LIBCPP_CXX03_LANG | 376 | #ifndef _LIBCPP_CXX03_LANG |
| 389 | _CntrlBlk(__p, std::move(__d), __a); | 377 | _CntrlBlk(__p, std::move(__d), __a); |
| 390 | #else | 378 | #else |
| 391 | _CntrlBlk(__p, __d, __a); | 379 | _CntrlBlk(__p, __d, __a); |
| 392 | #endif // not _LIBCPP_CXX03_LANG | 380 | #endif // not _LIBCPP_CXX03_LANG |
| 393 | __cntrl_ = std::addressof(*__hold2.release()); | 381 | __cntrl_ = std::addressof(*__hold2.release()); |
| 394 | __enable_weak_this(__p, __p); | 382 | __enable_weak_this(__p, __p); |
| 395 | #if _LIBCPP_HAS_EXCEPTIONS | 383 | __guard.__complete(); |
| 396 | } catch (...) { | ||
| 397 | __d(__p); | ||
| 398 | throw; | ||
| 399 | } | ||
| 400 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 401 | } | 384 | } |
| 402 | 385 | ||
| 403 | template <class _Dp> | 386 | template <class _Dp> |
| ... | @@ -406,22 +389,15 @@ public: | ... | @@ -406,22 +389,15 @@ public: |
| 406 | _Dp __d, | 389 | _Dp __d, |
| 407 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) | 390 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) |
| 408 | : __ptr_(nullptr) { | 391 | : __ptr_(nullptr) { |
| 409 | #if _LIBCPP_HAS_EXCEPTIONS | 392 | auto __guard = std::__make_exception_guard([&] { __d(__p); }); |
| 410 | try { | 393 | typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; |
| 411 | #endif // _LIBCPP_HAS_EXCEPTIONS | 394 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk; |
| 412 | typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; | ||
| 413 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk; | ||
| 414 | #ifndef _LIBCPP_CXX03_LANG | 395 | #ifndef _LIBCPP_CXX03_LANG |
| 415 | __cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT()); | 396 | __cntrl_ = new _CntrlBlk(__p, std::move(__d), _AllocT()); |
| 416 | #else | 397 | #else |
| 417 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); | 398 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); |
| 418 | #endif // not _LIBCPP_CXX03_LANG | 399 | #endif // not _LIBCPP_CXX03_LANG |
| 419 | #if _LIBCPP_HAS_EXCEPTIONS | 400 | __guard.__complete(); |
| 420 | } catch (...) { | ||
| 421 | __d(__p); | ||
| 422 | throw; | ||
| 423 | } | ||
| 424 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 425 | } | 401 | } |
| 426 | 402 | ||
| 427 | template <class _Dp, class _Alloc> | 403 | template <class _Dp, class _Alloc> |
| ... | @@ -431,27 +407,20 @@ public: | ... | @@ -431,27 +407,20 @@ public: |
| 431 | _Alloc __a, | 407 | _Alloc __a, |
| 432 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) | 408 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) |
| 433 | : __ptr_(nullptr) { | 409 | : __ptr_(nullptr) { |
| 434 | #if _LIBCPP_HAS_EXCEPTIONS | 410 | auto __guard = std::__make_exception_guard([&] { __d(__p); }); |
| 435 | try { | 411 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; |
| 436 | #endif // _LIBCPP_HAS_EXCEPTIONS | 412 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; |
| 437 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; | 413 | typedef __allocator_destructor<_A2> _D2; |
| 438 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | 414 | _A2 __a2(__a); |
| 439 | typedef __allocator_destructor<_A2> _D2; | 415 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); |
| 440 | _A2 __a2(__a); | 416 | ::new ((void*)std::addressof(*__hold2.get())) |
| 441 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | ||
| 442 | ::new ((void*)std::addressof(*__hold2.get())) | ||
| 443 | #ifndef _LIBCPP_CXX03_LANG | 417 | #ifndef _LIBCPP_CXX03_LANG |
| 444 | _CntrlBlk(__p, std::move(__d), __a); | 418 | _CntrlBlk(__p, std::move(__d), __a); |
| 445 | #else | 419 | #else |
| 446 | _CntrlBlk(__p, __d, __a); | 420 | _CntrlBlk(__p, __d, __a); |
| 447 | #endif // not _LIBCPP_CXX03_LANG | 421 | #endif // not _LIBCPP_CXX03_LANG |
| 448 | __cntrl_ = std::addressof(*__hold2.release()); | 422 | __cntrl_ = std::addressof(*__hold2.release()); |
| 449 | #if _LIBCPP_HAS_EXCEPTIONS | 423 | __guard.__complete(); |
| 450 | } catch (...) { | ||
| 451 | __d(__p); | ||
| 452 | throw; | ||
| 453 | } | ||
| 454 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 455 | } | 424 | } |
| 456 | 425 | ||
| 457 | template <class _Yp> | 426 | template <class _Yp> |
| ... | @@ -514,45 +483,16 @@ public: | ... | @@ -514,45 +483,16 @@ public: |
| 514 | 483 | ||
| 515 | template <class _Yp, | 484 | template <class _Yp, |
| 516 | class _Dp, | 485 | class _Dp, |
| 517 | __enable_if_t<!is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value && | 486 | __enable_if_t<__compatible_with<_Yp, _Tp>::value && |
| 518 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | 487 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, |
| 519 | int> = 0> | 488 | int> = 0> |
| 520 | _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { | 489 | _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { |
| 521 | #if _LIBCPP_STD_VER >= 14 | 490 | using _AllocT = typename __shared_ptr_default_allocator<_Yp>::type; |
| 522 | if (__ptr_ == nullptr) | 491 | using _Deleter = _If<is_lvalue_reference<_Dp>::value, reference_wrapper<__libcpp_remove_reference_t<_Dp> >, _Dp>; |
| 523 | __cntrl_ = nullptr; | 492 | using _CntrlBlk = __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Deleter, _AllocT>; |
| 524 | else | ||
| 525 | #endif | ||
| 526 | { | ||
| 527 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | ||
| 528 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT> _CntrlBlk; | ||
| 529 | __cntrl_ = new _CntrlBlk(__r.get(), std::move(__r.get_deleter()), _AllocT()); | ||
| 530 | __enable_weak_this(__r.get(), __r.get()); | ||
| 531 | } | ||
| 532 | __r.release(); | ||
| 533 | } | ||
| 534 | 493 | ||
| 535 | template <class _Yp, | 494 | __cntrl_ = __ptr_ ? new _CntrlBlk(__r.get(), std::forward<_Dp>(__r.get_deleter()), _AllocT()) : nullptr; |
| 536 | class _Dp, | 495 | __enable_weak_this(__r.get(), __r.get()); |
| 537 | class = void, | ||
| 538 | __enable_if_t<is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value && | ||
| 539 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | ||
| 540 | int> = 0> | ||
| 541 | _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { | ||
| 542 | #if _LIBCPP_STD_VER >= 14 | ||
| 543 | if (__ptr_ == nullptr) | ||
| 544 | __cntrl_ = nullptr; | ||
| 545 | else | ||
| 546 | #endif | ||
| 547 | { | ||
| 548 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | ||
| 549 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, | ||
| 550 | reference_wrapper<__libcpp_remove_reference_t<_Dp> >, | ||
| 551 | _AllocT> | ||
| 552 | _CntrlBlk; | ||
| 553 | __cntrl_ = new _CntrlBlk(__r.get(), std::ref(__r.get_deleter()), _AllocT()); | ||
| 554 | __enable_weak_this(__r.get(), __r.get()); | ||
| 555 | } | ||
| 556 | __r.release(); | 496 | __r.release(); |
| 557 | } | 497 | } |
| 558 | 498 | ||
| ... | @@ -628,37 +568,43 @@ public: | ... | @@ -628,37 +568,43 @@ public: |
| 628 | shared_ptr(__p, __d, __a).swap(*this); | 568 | shared_ptr(__p, __d, __a).swap(*this); |
| 629 | } | 569 | } |
| 630 | 570 | ||
| 631 | _LIBCPP_HIDE_FROM_ABI element_type* get() const _NOEXCEPT { return __ptr_; } | 571 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI element_type* get() const _NOEXCEPT { return __ptr_; } |
| 632 | 572 | ||
| 633 | _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<element_type> operator*() const _NOEXCEPT { return *__ptr_; } | 573 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<element_type> operator*() const _NOEXCEPT { |
| 574 | return *__ptr_; | ||
| 575 | } | ||
| 634 | 576 | ||
| 635 | _LIBCPP_HIDE_FROM_ABI element_type* operator->() const _NOEXCEPT { | 577 | _LIBCPP_HIDE_FROM_ABI element_type* operator->() const _NOEXCEPT { |
| 636 | static_assert(!is_array<_Tp>::value, "std::shared_ptr<T>::operator-> is only valid when T is not an array type."); | 578 | static_assert(!is_array<_Tp>::value, "std::shared_ptr<T>::operator-> is only valid when T is not an array type."); |
| 637 | return __ptr_; | 579 | return __ptr_; |
| 638 | } | 580 | } |
| 639 | 581 | ||
| 640 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __cntrl_ ? __cntrl_->use_count() : 0; } | 582 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { |
| 583 | return __cntrl_ ? __cntrl_->use_count() : 0; | ||
| 584 | } | ||
| 641 | 585 | ||
| 642 | #if _LIBCPP_STD_VER < 20 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE) | 586 | #if _LIBCPP_STD_VER < 20 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE) |
| 643 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI bool unique() const _NOEXCEPT { return use_count() == 1; } | 587 | [[__nodiscard__]] _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI bool unique() const _NOEXCEPT { |
| 588 | return use_count() == 1; | ||
| 589 | } | ||
| 644 | #endif | 590 | #endif |
| 645 | 591 | ||
| 646 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return get() != nullptr; } | 592 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return get() != nullptr; } |
| 647 | 593 | ||
| 648 | template <class _Up> | 594 | template <class _Up> |
| 649 | _LIBCPP_HIDE_FROM_ABI bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT { | 595 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT { |
| 650 | return __cntrl_ < __p.__cntrl_; | 596 | return __cntrl_ < __p.__cntrl_; |
| 651 | } | 597 | } |
| 652 | 598 | ||
| 653 | template <class _Up> | 599 | template <class _Up> |
| 654 | _LIBCPP_HIDE_FROM_ABI bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT { | 600 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT { |
| 655 | return __cntrl_ < __p.__cntrl_; | 601 | return __cntrl_ < __p.__cntrl_; |
| 656 | } | 602 | } |
| 657 | 603 | ||
| 658 | _LIBCPP_HIDE_FROM_ABI bool __owner_equivalent(const shared_ptr& __p) const { return __cntrl_ == __p.__cntrl_; } | 604 | _LIBCPP_HIDE_FROM_ABI bool __owner_equivalent(const shared_ptr& __p) const { return __cntrl_ == __p.__cntrl_; } |
| 659 | 605 | ||
| 660 | #if _LIBCPP_STD_VER >= 17 | 606 | #if _LIBCPP_STD_VER >= 17 |
| 661 | _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<element_type> operator[](ptrdiff_t __i) const { | 607 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<element_type> operator[](ptrdiff_t __i) const { |
| 662 | static_assert(is_array<_Tp>::value, "std::shared_ptr<T>::operator[] is only valid when T is an array type."); | 608 | static_assert(is_array<_Tp>::value, "std::shared_ptr<T>::operator[] is only valid when T is an array type."); |
| 663 | return __ptr_[__i]; | 609 | return __ptr_[__i]; |
| 664 | } | 610 | } |
| ... | @@ -729,7 +675,7 @@ shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; | ... | @@ -729,7 +675,7 @@ shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; |
| 729 | // std::allocate_shared and std::make_shared | 675 | // std::allocate_shared and std::make_shared |
| 730 | // | 676 | // |
| 731 | template <class _Tp, class _Alloc, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0> | 677 | template <class _Tp, class _Alloc, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 732 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) { | 678 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) { |
| 733 | using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>; | 679 | using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>; |
| 734 | using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type; | 680 | using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type; |
| 735 | __allocation_guard<_ControlBlockAllocator> __guard(__a, 1); | 681 | __allocation_guard<_ControlBlockAllocator> __guard(__a, 1); |
| ... | @@ -740,21 +686,21 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& | ... | @@ -740,21 +686,21 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& |
| 740 | } | 686 | } |
| 741 | 687 | ||
| 742 | template <class _Tp, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0> | 688 | template <class _Tp, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 743 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(_Args&&... __args) { | 689 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(_Args&&... __args) { |
| 744 | return std::allocate_shared<_Tp>(allocator<__remove_cv_t<_Tp> >(), std::forward<_Args>(__args)...); | 690 | return std::allocate_shared<_Tp>(allocator<__remove_cv_t<_Tp> >(), std::forward<_Args>(__args)...); |
| 745 | } | 691 | } |
| 746 | 692 | ||
| 747 | #if _LIBCPP_STD_VER >= 20 | 693 | #if _LIBCPP_STD_VER >= 20 |
| 748 | 694 | ||
| 749 | template <class _Tp, class _Alloc, __enable_if_t<!is_array<_Tp>::value, int> = 0> | 695 | template <class _Tp, class _Alloc, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 750 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a) { | 696 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a) { |
| 751 | using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>; | 697 | using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>; |
| 752 | _ForOverwriteAllocator __alloc(__a); | 698 | _ForOverwriteAllocator __alloc(__a); |
| 753 | return std::allocate_shared<_Tp>(__alloc); | 699 | return std::allocate_shared<_Tp>(__alloc); |
| 754 | } | 700 | } |
| 755 | 701 | ||
| 756 | template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> | 702 | template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 757 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { | 703 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { |
| 758 | return std::allocate_shared_for_overwrite<_Tp>(allocator<__remove_cv_t<_Tp>>()); | 704 | return std::allocate_shared_for_overwrite<_Tp>(allocator<__remove_cv_t<_Tp>>()); |
| 759 | } | 705 | } |
| 760 | 706 | ||
| ... | @@ -946,67 +892,69 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _ | ... | @@ -946,67 +892,69 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _ |
| 946 | 892 | ||
| 947 | // bounded array variants | 893 | // bounded array variants |
| 948 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> | 894 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 949 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a) { | 895 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a) { |
| 950 | return std::__allocate_shared_bounded_array<_Tp>(__a); | 896 | return std::__allocate_shared_bounded_array<_Tp>(__a); |
| 951 | } | 897 | } |
| 952 | 898 | ||
| 953 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> | 899 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 954 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) { | 900 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> |
| 901 | allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) { | ||
| 955 | return std::__allocate_shared_bounded_array<_Tp>(__a, __u); | 902 | return std::__allocate_shared_bounded_array<_Tp>(__a, __u); |
| 956 | } | 903 | } |
| 957 | 904 | ||
| 958 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> | 905 | template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 959 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a) { | 906 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a) { |
| 960 | using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>; | 907 | using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>; |
| 961 | _ForOverwriteAllocator __alloc(__a); | 908 | _ForOverwriteAllocator __alloc(__a); |
| 962 | return std::__allocate_shared_bounded_array<_Tp>(__alloc); | 909 | return std::__allocate_shared_bounded_array<_Tp>(__alloc); |
| 963 | } | 910 | } |
| 964 | 911 | ||
| 965 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> | 912 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 966 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared() { | 913 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared() { |
| 967 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>()); | 914 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>()); |
| 968 | } | 915 | } |
| 969 | 916 | ||
| 970 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> | 917 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 971 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u) { | 918 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u) { |
| 972 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u); | 919 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u); |
| 973 | } | 920 | } |
| 974 | 921 | ||
| 975 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> | 922 | template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0> |
| 976 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { | 923 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() { |
| 977 | return std::__allocate_shared_bounded_array<_Tp>(allocator<__for_overwrite_tag>()); | 924 | return std::__allocate_shared_bounded_array<_Tp>(allocator<__for_overwrite_tag>()); |
| 978 | } | 925 | } |
| 979 | 926 | ||
| 980 | // unbounded array variants | 927 | // unbounded array variants |
| 981 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> | 928 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 982 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n) { | 929 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n) { |
| 983 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n); | 930 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n); |
| 984 | } | 931 | } |
| 985 | 932 | ||
| 986 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> | 933 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 987 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u) { | 934 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> |
| 935 | allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u) { | ||
| 988 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u); | 936 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u); |
| 989 | } | 937 | } |
| 990 | 938 | ||
| 991 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> | 939 | template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 992 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a, size_t __n) { | 940 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a, size_t __n) { |
| 993 | using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>; | 941 | using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>; |
| 994 | _ForOverwriteAllocator __alloc(__a); | 942 | _ForOverwriteAllocator __alloc(__a); |
| 995 | return std::__allocate_shared_unbounded_array<_Tp>(__alloc, __n); | 943 | return std::__allocate_shared_unbounded_array<_Tp>(__alloc, __n); |
| 996 | } | 944 | } |
| 997 | 945 | ||
| 998 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> | 946 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 999 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n) { | 947 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n) { |
| 1000 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n); | 948 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n); |
| 1001 | } | 949 | } |
| 1002 | 950 | ||
| 1003 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> | 951 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 1004 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u) { | 952 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u) { |
| 1005 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u); | 953 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u); |
| 1006 | } | 954 | } |
| 1007 | 955 | ||
| 1008 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> | 956 | template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0> |
| 1009 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite(size_t __n) { | 957 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite(size_t __n) { |
| 1010 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<__for_overwrite_tag>(), __n); | 958 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<__for_overwrite_tag>(), __n); |
| 1011 | } | 959 | } |
| 1012 | 960 | ||
| ... | @@ -1135,7 +1083,8 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __ | ... | @@ -1135,7 +1083,8 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __ |
| 1135 | } | 1083 | } |
| 1136 | 1084 | ||
| 1137 | template <class _Tp, class _Up> | 1085 | template <class _Tp, class _Up> |
| 1138 | inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { | 1086 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> |
| 1087 | static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { | ||
| 1139 | return shared_ptr<_Tp>(__r, static_cast< typename shared_ptr<_Tp>::element_type*>(__r.get())); | 1088 | return shared_ptr<_Tp>(__r, static_cast< typename shared_ptr<_Tp>::element_type*>(__r.get())); |
| 1140 | } | 1089 | } |
| 1141 | 1090 | ||
| ... | @@ -1143,13 +1092,14 @@ inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(const shared_pt | ... | @@ -1143,13 +1092,14 @@ inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(const shared_pt |
| 1143 | // We don't backport because it is an evolutionary change. | 1092 | // We don't backport because it is an evolutionary change. |
| 1144 | #if _LIBCPP_STD_VER >= 20 | 1093 | #if _LIBCPP_STD_VER >= 20 |
| 1145 | template <class _Tp, class _Up> | 1094 | template <class _Tp, class _Up> |
| 1146 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(shared_ptr<_Up>&& __r) noexcept { | 1095 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(shared_ptr<_Up>&& __r) noexcept { |
| 1147 | return shared_ptr<_Tp>(std::move(__r), static_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); | 1096 | return shared_ptr<_Tp>(std::move(__r), static_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); |
| 1148 | } | 1097 | } |
| 1149 | #endif | 1098 | #endif |
| 1150 | 1099 | ||
| 1151 | template <class _Tp, class _Up> | 1100 | template <class _Tp, class _Up> |
| 1152 | inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { | 1101 | [[__nodiscard__]] inline |
| 1102 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { | ||
| 1153 | typedef typename shared_ptr<_Tp>::element_type _ET; | 1103 | typedef typename shared_ptr<_Tp>::element_type _ET; |
| 1154 | _ET* __p = dynamic_cast<_ET*>(__r.get()); | 1104 | _ET* __p = dynamic_cast<_ET*>(__r.get()); |
| 1155 | return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); | 1105 | return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); |
| ... | @@ -1159,14 +1109,14 @@ inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(const shared_p | ... | @@ -1159,14 +1109,14 @@ inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(const shared_p |
| 1159 | // We don't backport because it is an evolutionary change. | 1109 | // We don't backport because it is an evolutionary change. |
| 1160 | #if _LIBCPP_STD_VER >= 20 | 1110 | #if _LIBCPP_STD_VER >= 20 |
| 1161 | template <class _Tp, class _Up> | 1111 | template <class _Tp, class _Up> |
| 1162 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(shared_ptr<_Up>&& __r) noexcept { | 1112 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(shared_ptr<_Up>&& __r) noexcept { |
| 1163 | auto* __p = dynamic_cast<typename shared_ptr<_Tp>::element_type*>(__r.get()); | 1113 | auto* __p = dynamic_cast<typename shared_ptr<_Tp>::element_type*>(__r.get()); |
| 1164 | return __p ? shared_ptr<_Tp>(std::move(__r), __p) : shared_ptr<_Tp>(); | 1114 | return __p ? shared_ptr<_Tp>(std::move(__r), __p) : shared_ptr<_Tp>(); |
| 1165 | } | 1115 | } |
| 1166 | #endif | 1116 | #endif |
| 1167 | 1117 | ||
| 1168 | template <class _Tp, class _Up> | 1118 | template <class _Tp, class _Up> |
| 1169 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { | 1119 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { |
| 1170 | typedef typename shared_ptr<_Tp>::element_type _RTp; | 1120 | typedef typename shared_ptr<_Tp>::element_type _RTp; |
| 1171 | return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); | 1121 | return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); |
| 1172 | } | 1122 | } |
| ... | @@ -1175,13 +1125,13 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(const shared_ptr<_Up>& | ... | @@ -1175,13 +1125,13 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(const shared_ptr<_Up>& |
| 1175 | // We don't backport because it is an evolutionary change. | 1125 | // We don't backport because it is an evolutionary change. |
| 1176 | #if _LIBCPP_STD_VER >= 20 | 1126 | #if _LIBCPP_STD_VER >= 20 |
| 1177 | template <class _Tp, class _Up> | 1127 | template <class _Tp, class _Up> |
| 1178 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(shared_ptr<_Up>&& __r) noexcept { | 1128 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(shared_ptr<_Up>&& __r) noexcept { |
| 1179 | return shared_ptr<_Tp>(std::move(__r), const_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); | 1129 | return shared_ptr<_Tp>(std::move(__r), const_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); |
| 1180 | } | 1130 | } |
| 1181 | #endif | 1131 | #endif |
| 1182 | 1132 | ||
| 1183 | template <class _Tp, class _Up> | 1133 | template <class _Tp, class _Up> |
| 1184 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { | 1134 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT { |
| 1185 | return shared_ptr<_Tp>(__r, reinterpret_cast< typename shared_ptr<_Tp>::element_type*>(__r.get())); | 1135 | return shared_ptr<_Tp>(__r, reinterpret_cast< typename shared_ptr<_Tp>::element_type*>(__r.get())); |
| 1186 | } | 1136 | } |
| 1187 | 1137 | ||
| ... | @@ -1189,7 +1139,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(const shared_ptr< | ... | @@ -1189,7 +1139,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(const shared_ptr< |
| 1189 | // We don't backport because it is an evolutionary change. | 1139 | // We don't backport because it is an evolutionary change. |
| 1190 | #if _LIBCPP_STD_VER >= 20 | 1140 | #if _LIBCPP_STD_VER >= 20 |
| 1191 | template <class _Tp, class _Up> | 1141 | template <class _Tp, class _Up> |
| 1192 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& __r) noexcept { | 1142 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& __r) noexcept { |
| 1193 | return shared_ptr<_Tp>(std::move(__r), reinterpret_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); | 1143 | return shared_ptr<_Tp>(std::move(__r), reinterpret_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); |
| 1194 | } | 1144 | } |
| 1195 | #endif | 1145 | #endif |
| ... | @@ -1197,7 +1147,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& | ... | @@ -1197,7 +1147,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& |
| 1197 | #if _LIBCPP_HAS_RTTI | 1147 | #if _LIBCPP_HAS_RTTI |
| 1198 | 1148 | ||
| 1199 | template <class _Dp, class _Tp> | 1149 | template <class _Dp, class _Tp> |
| 1200 | inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT { | 1150 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT { |
| 1201 | return __p.template __get_deleter<_Dp>(); | 1151 | return __p.template __get_deleter<_Dp>(); |
| 1202 | } | 1152 | } |
| 1203 | 1153 | ||
| ... | @@ -1213,9 +1163,8 @@ public: | ... | @@ -1213,9 +1163,8 @@ public: |
| 1213 | #endif | 1163 | #endif |
| 1214 | 1164 | ||
| 1215 | // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require | 1165 | // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require |
| 1216 | // any bookkeeping, so it's always trivially relocatable. It's also replaceable for the same reason. | 1166 | // any bookkeeping, so it's always trivially relocatable. |
| 1217 | using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr; | 1167 | using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr; |
| 1218 | using __replaceable _LIBCPP_NODEBUG = weak_ptr; | ||
| 1219 | 1168 | ||
| 1220 | private: | 1169 | private: |
| 1221 | element_type* __ptr_; | 1170 | element_type* __ptr_; |
| ... | @@ -1253,15 +1202,19 @@ public: | ... | @@ -1253,15 +1202,19 @@ public: |
| 1253 | _LIBCPP_HIDE_FROM_ABI void swap(weak_ptr& __r) _NOEXCEPT; | 1202 | _LIBCPP_HIDE_FROM_ABI void swap(weak_ptr& __r) _NOEXCEPT; |
| 1254 | _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT; | 1203 | _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT; |
| 1255 | 1204 | ||
| 1256 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __cntrl_ ? __cntrl_->use_count() : 0; } | 1205 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { |
| 1257 | _LIBCPP_HIDE_FROM_ABI bool expired() const _NOEXCEPT { return __cntrl_ == nullptr || __cntrl_->use_count() == 0; } | 1206 | return __cntrl_ ? __cntrl_->use_count() : 0; |
| 1258 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> lock() const _NOEXCEPT; | 1207 | } |
| 1208 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool expired() const _NOEXCEPT { | ||
| 1209 | return __cntrl_ == nullptr || __cntrl_->use_count() == 0; | ||
| 1210 | } | ||
| 1211 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> lock() const _NOEXCEPT; | ||
| 1259 | template <class _Up> | 1212 | template <class _Up> |
| 1260 | _LIBCPP_HIDE_FROM_ABI bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT { | 1213 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT { |
| 1261 | return __cntrl_ < __r.__cntrl_; | 1214 | return __cntrl_ < __r.__cntrl_; |
| 1262 | } | 1215 | } |
| 1263 | template <class _Up> | 1216 | template <class _Up> |
| 1264 | _LIBCPP_HIDE_FROM_ABI bool owner_before(const weak_ptr<_Up>& __r) const _NOEXCEPT { | 1217 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool owner_before(const weak_ptr<_Up>& __r) const _NOEXCEPT { |
| 1265 | return __cntrl_ < __r.__cntrl_; | 1218 | return __cntrl_ < __r.__cntrl_; |
| 1266 | } | 1219 | } |
| 1267 | 1220 | ||
| ... | @@ -1445,13 +1398,15 @@ protected: | ... | @@ -1445,13 +1398,15 @@ protected: |
| 1445 | _LIBCPP_HIDE_FROM_ABI ~enable_shared_from_this() {} | 1398 | _LIBCPP_HIDE_FROM_ABI ~enable_shared_from_this() {} |
| 1446 | 1399 | ||
| 1447 | public: | 1400 | public: |
| 1448 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> shared_from_this() { return shared_ptr<_Tp>(__weak_this_); } | 1401 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> shared_from_this() { return shared_ptr<_Tp>(__weak_this_); } |
| 1449 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp const> shared_from_this() const { return shared_ptr<const _Tp>(__weak_this_); } | 1402 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp const> shared_from_this() const { |
| 1403 | return shared_ptr<const _Tp>(__weak_this_); | ||
| 1404 | } | ||
| 1450 | 1405 | ||
| 1451 | #if _LIBCPP_STD_VER >= 17 | 1406 | #if _LIBCPP_STD_VER >= 17 |
| 1452 | _LIBCPP_HIDE_FROM_ABI weak_ptr<_Tp> weak_from_this() _NOEXCEPT { return __weak_this_; } | 1407 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI weak_ptr<_Tp> weak_from_this() _NOEXCEPT { return __weak_this_; } |
| 1453 | 1408 | ||
| 1454 | _LIBCPP_HIDE_FROM_ABI weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT { return __weak_this_; } | 1409 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT { return __weak_this_; } |
| 1455 | #endif // _LIBCPP_STD_VER >= 17 | 1410 | #endif // _LIBCPP_STD_VER >= 17 |
| 1456 | 1411 | ||
| 1457 | template <class _Up> | 1412 | template <class _Up> |
| ... | @@ -1468,7 +1423,7 @@ struct hash<shared_ptr<_Tp> > { | ... | @@ -1468,7 +1423,7 @@ struct hash<shared_ptr<_Tp> > { |
| 1468 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | 1423 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; |
| 1469 | #endif | 1424 | #endif |
| 1470 | 1425 | ||
| 1471 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const shared_ptr<_Tp>& __ptr) const _NOEXCEPT { | 1426 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t operator()(const shared_ptr<_Tp>& __ptr) const _NOEXCEPT { |
| 1472 | return hash<typename shared_ptr<_Tp>::element_type*>()(__ptr.get()); | 1427 | return hash<typename shared_ptr<_Tp>::element_type*>()(__ptr.get()); |
| 1473 | } | 1428 | } |
| 1474 | }; | 1429 | }; |
lib/libcxx/include/__memory/temp_value.h+1-2| ... | @@ -12,7 +12,6 @@ | ... | @@ -12,7 +12,6 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__memory/addressof.h> | 13 | #include <__memory/addressof.h> |
| 14 | #include <__memory/allocator_traits.h> | 14 | #include <__memory/allocator_traits.h> |
| 15 | #include <__type_traits/aligned_storage.h> | ||
| 16 | #include <__utility/forward.h> | 15 | #include <__utility/forward.h> |
| 17 | 16 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -26,7 +25,7 @@ struct __temp_value { | ... | @@ -26,7 +25,7 @@ struct __temp_value { |
| 26 | typedef allocator_traits<_Alloc> _Traits; | 25 | typedef allocator_traits<_Alloc> _Traits; |
| 27 | 26 | ||
| 28 | #ifdef _LIBCPP_CXX03_LANG | 27 | #ifdef _LIBCPP_CXX03_LANG |
| 29 | typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v; | 28 | _ALIGNAS_TYPE(_Tp) char __v[sizeof(_Tp)]; |
| 30 | #else | 29 | #else |
| 31 | union { | 30 | union { |
| 32 | _Tp __v; | 31 | _Tp __v; |
lib/libcxx/include/__memory/uninitialized_algorithms.h+44-115| ... | @@ -32,7 +32,6 @@ | ... | @@ -32,7 +32,6 @@ |
| 32 | #include <__type_traits/is_trivially_assignable.h> | 32 | #include <__type_traits/is_trivially_assignable.h> |
| 33 | #include <__type_traits/is_trivially_constructible.h> | 33 | #include <__type_traits/is_trivially_constructible.h> |
| 34 | #include <__type_traits/is_trivially_relocatable.h> | 34 | #include <__type_traits/is_trivially_relocatable.h> |
| 35 | #include <__type_traits/is_unbounded_array.h> | ||
| 36 | #include <__type_traits/remove_const.h> | 35 | #include <__type_traits/remove_const.h> |
| 37 | #include <__type_traits/remove_extent.h> | 36 | #include <__type_traits/remove_extent.h> |
| 38 | #include <__utility/exception_guard.h> | 37 | #include <__utility/exception_guard.h> |
| ... | @@ -61,17 +60,10 @@ template <class _ValueType, class _InputIterator, class _Sentinel1, class _Forwa | ... | @@ -61,17 +60,10 @@ template <class _ValueType, class _InputIterator, class _Sentinel1, class _Forwa |
| 61 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy( | 60 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy( |
| 62 | _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { | 61 | _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { |
| 63 | _ForwardIterator __idx = __ofirst; | 62 | _ForwardIterator __idx = __ofirst; |
| 64 | #if _LIBCPP_HAS_EXCEPTIONS | 63 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); }); |
| 65 | try { | 64 | for (; __ifirst != __ilast && !__stop_copying(__idx); ++__ifirst, (void)++__idx) |
| 66 | #endif | 65 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst); |
| 67 | for (; __ifirst != __ilast && !__stop_copying(__idx); ++__ifirst, (void)++__idx) | 66 | __guard.__complete(); |
| 68 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst); | ||
| 69 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 70 | } catch (...) { | ||
| 71 | std::__destroy(__ofirst, __idx); | ||
| 72 | throw; | ||
| 73 | } | ||
| 74 | #endif | ||
| 75 | 67 | ||
| 76 | return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx)); | 68 | return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx)); |
| 77 | } | 69 | } |
| ... | @@ -91,17 +83,10 @@ template <class _ValueType, class _InputIterator, class _Size, class _ForwardIte | ... | @@ -91,17 +83,10 @@ template <class _ValueType, class _InputIterator, class _Size, class _ForwardIte |
| 91 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> | 83 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> |
| 92 | __uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { | 84 | __uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { |
| 93 | _ForwardIterator __idx = __ofirst; | 85 | _ForwardIterator __idx = __ofirst; |
| 94 | #if _LIBCPP_HAS_EXCEPTIONS | 86 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); }); |
| 95 | try { | 87 | for (; __n > 0 && !__stop_copying(__idx); ++__ifirst, (void)++__idx, (void)--__n) |
| 96 | #endif | 88 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst); |
| 97 | for (; __n > 0 && !__stop_copying(__idx); ++__ifirst, (void)++__idx, (void)--__n) | 89 | __guard.__complete(); |
| 98 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst); | ||
| 99 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 100 | } catch (...) { | ||
| 101 | std::__destroy(__ofirst, __idx); | ||
| 102 | throw; | ||
| 103 | } | ||
| 104 | #endif | ||
| 105 | 90 | ||
| 106 | return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx)); | 91 | return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx)); |
| 107 | } | 92 | } |
| ... | @@ -121,17 +106,10 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp> | ... | @@ -121,17 +106,10 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp> |
| 121 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 106 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 122 | __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) { | 107 | __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) { |
| 123 | _ForwardIterator __idx = __first; | 108 | _ForwardIterator __idx = __first; |
| 124 | #if _LIBCPP_HAS_EXCEPTIONS | 109 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); }); |
| 125 | try { | 110 | for (; __idx != __last; ++__idx) |
| 126 | #endif | 111 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x); |
| 127 | for (; __idx != __last; ++__idx) | 112 | __guard.__complete(); |
| 128 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x); | ||
| 129 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 130 | } catch (...) { | ||
| 131 | std::__destroy(__first, __idx); | ||
| 132 | throw; | ||
| 133 | } | ||
| 134 | #endif | ||
| 135 | 113 | ||
| 136 | return __idx; | 114 | return __idx; |
| 137 | } | 115 | } |
| ... | @@ -149,17 +127,10 @@ template <class _ValueType, class _ForwardIterator, class _Size, class _Tp> | ... | @@ -149,17 +127,10 @@ template <class _ValueType, class _ForwardIterator, class _Size, class _Tp> |
| 149 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 127 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 150 | __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { | 128 | __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { |
| 151 | _ForwardIterator __idx = __first; | 129 | _ForwardIterator __idx = __first; |
| 152 | #if _LIBCPP_HAS_EXCEPTIONS | 130 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); }); |
| 153 | try { | 131 | for (; __n > 0; ++__idx, (void)--__n) |
| 154 | #endif | 132 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x); |
| 155 | for (; __n > 0; ++__idx, (void)--__n) | 133 | __guard.__complete(); |
| 156 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x); | ||
| 157 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 158 | } catch (...) { | ||
| 159 | std::__destroy(__first, __idx); | ||
| 160 | throw; | ||
| 161 | } | ||
| 162 | #endif | ||
| 163 | 134 | ||
| 164 | return __idx; | 135 | return __idx; |
| 165 | } | 136 | } |
| ... | @@ -178,18 +149,11 @@ uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { | ... | @@ -178,18 +149,11 @@ uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { |
| 178 | template <class _ValueType, class _ForwardIterator, class _Sentinel> | 149 | template <class _ValueType, class _ForwardIterator, class _Sentinel> |
| 179 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 150 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 180 | __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) { | 151 | __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) { |
| 181 | auto __idx = __first; | 152 | auto __idx = __first; |
| 182 | # if _LIBCPP_HAS_EXCEPTIONS | 153 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); }); |
| 183 | try { | 154 | for (; __idx != __last; ++__idx) |
| 184 | # endif | 155 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType; |
| 185 | for (; __idx != __last; ++__idx) | 156 | __guard.__complete(); |
| 186 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType; | ||
| 187 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 188 | } catch (...) { | ||
| 189 | std::__destroy(__first, __idx); | ||
| 190 | throw; | ||
| 191 | } | ||
| 192 | # endif | ||
| 193 | 157 | ||
| 194 | return __idx; | 158 | return __idx; |
| 195 | } | 159 | } |
| ... | @@ -205,17 +169,10 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat | ... | @@ -205,17 +169,10 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat |
| 205 | template <class _ValueType, class _ForwardIterator, class _Size> | 169 | template <class _ValueType, class _ForwardIterator, class _Size> |
| 206 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { | 170 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { |
| 207 | auto __idx = __first; | 171 | auto __idx = __first; |
| 208 | # if _LIBCPP_HAS_EXCEPTIONS | 172 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); }); |
| 209 | try { | 173 | for (; __n > 0; ++__idx, (void)--__n) |
| 210 | # endif | 174 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType; |
| 211 | for (; __n > 0; ++__idx, (void)--__n) | 175 | __guard.__complete(); |
| 212 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType; | ||
| 213 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 214 | } catch (...) { | ||
| 215 | std::__destroy(__first, __idx); | ||
| 216 | throw; | ||
| 217 | } | ||
| 218 | # endif | ||
| 219 | 176 | ||
| 220 | return __idx; | 177 | return __idx; |
| 221 | } | 178 | } |
| ... | @@ -231,18 +188,11 @@ inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_default_construct_n( | ... | @@ -231,18 +188,11 @@ inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_default_construct_n( |
| 231 | template <class _ValueType, class _ForwardIterator, class _Sentinel> | 188 | template <class _ValueType, class _ForwardIterator, class _Sentinel> |
| 232 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 189 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 233 | __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) { | 190 | __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) { |
| 234 | auto __idx = __first; | 191 | auto __idx = __first; |
| 235 | # if _LIBCPP_HAS_EXCEPTIONS | 192 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); }); |
| 236 | try { | 193 | for (; __idx != __last; ++__idx) |
| 237 | # endif | 194 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(); |
| 238 | for (; __idx != __last; ++__idx) | 195 | __guard.__complete(); |
| 239 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(); | ||
| 240 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 241 | } catch (...) { | ||
| 242 | std::__destroy(__first, __idx); | ||
| 243 | throw; | ||
| 244 | } | ||
| 245 | # endif | ||
| 246 | 196 | ||
| 247 | return __idx; | 197 | return __idx; |
| 248 | } | 198 | } |
| ... | @@ -258,17 +208,10 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator | ... | @@ -258,17 +208,10 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator |
| 258 | template <class _ValueType, class _ForwardIterator, class _Size> | 208 | template <class _ValueType, class _ForwardIterator, class _Size> |
| 259 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { | 209 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { |
| 260 | auto __idx = __first; | 210 | auto __idx = __first; |
| 261 | # if _LIBCPP_HAS_EXCEPTIONS | 211 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); }); |
| 262 | try { | 212 | for (; __n > 0; ++__idx, (void)--__n) |
| 263 | # endif | 213 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(); |
| 264 | for (; __n > 0; ++__idx, (void)--__n) | 214 | __guard.__complete(); |
| 265 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(); | ||
| 266 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 267 | } catch (...) { | ||
| 268 | std::__destroy(__first, __idx); | ||
| 269 | throw; | ||
| 270 | } | ||
| 271 | # endif | ||
| 272 | 215 | ||
| 273 | return __idx; | 216 | return __idx; |
| 274 | } | 217 | } |
| ... | @@ -293,19 +236,12 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali | ... | @@ -293,19 +236,12 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali |
| 293 | _ForwardIterator __ofirst, | 236 | _ForwardIterator __ofirst, |
| 294 | _EndPredicate __stop_moving, | 237 | _EndPredicate __stop_moving, |
| 295 | _IterMove __iter_move) { | 238 | _IterMove __iter_move) { |
| 296 | auto __idx = __ofirst; | 239 | auto __idx = __ofirst; |
| 297 | # if _LIBCPP_HAS_EXCEPTIONS | 240 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); }); |
| 298 | try { | 241 | for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) { |
| 299 | # endif | 242 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); |
| 300 | for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) { | ||
| 301 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); | ||
| 302 | } | ||
| 303 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 304 | } catch (...) { | ||
| 305 | std::__destroy(__ofirst, __idx); | ||
| 306 | throw; | ||
| 307 | } | 243 | } |
| 308 | # endif | 244 | __guard.__complete(); |
| 309 | 245 | ||
| 310 | return {std::move(__ifirst), std::move(__idx)}; | 246 | return {std::move(__ifirst), std::move(__idx)}; |
| 311 | } | 247 | } |
| ... | @@ -331,18 +267,11 @@ template <class _ValueType, | ... | @@ -331,18 +267,11 @@ template <class _ValueType, |
| 331 | class _IterMove> | 267 | class _IterMove> |
| 332 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n( | 268 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n( |
| 333 | _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) { | 269 | _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) { |
| 334 | auto __idx = __ofirst; | 270 | auto __idx = __ofirst; |
| 335 | # if _LIBCPP_HAS_EXCEPTIONS | 271 | auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); }); |
| 336 | try { | 272 | for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n) |
| 337 | # endif | 273 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); |
| 338 | for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n) | 274 | __guard.__complete(); |
| 339 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); | ||
| 340 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 341 | } catch (...) { | ||
| 342 | std::__destroy(__ofirst, __idx); | ||
| 343 | throw; | ||
| 344 | } | ||
| 345 | # endif | ||
| 346 | 275 | ||
| 347 | return {std::move(__ifirst), std::move(__idx)}; | 276 | return {std::move(__ifirst), std::move(__idx)}; |
| 348 | } | 277 | } |
lib/libcxx/include/__memory/unique_ptr.h+14-16| ... | @@ -32,18 +32,15 @@ | ... | @@ -32,18 +32,15 @@ |
| 32 | #include <__type_traits/integral_constant.h> | 32 | #include <__type_traits/integral_constant.h> |
| 33 | #include <__type_traits/is_array.h> | 33 | #include <__type_traits/is_array.h> |
| 34 | #include <__type_traits/is_assignable.h> | 34 | #include <__type_traits/is_assignable.h> |
| 35 | #include <__type_traits/is_bounded_array.h> | ||
| 36 | #include <__type_traits/is_constant_evaluated.h> | 35 | #include <__type_traits/is_constant_evaluated.h> |
| 37 | #include <__type_traits/is_constructible.h> | 36 | #include <__type_traits/is_constructible.h> |
| 38 | #include <__type_traits/is_convertible.h> | 37 | #include <__type_traits/is_convertible.h> |
| 39 | #include <__type_traits/is_function.h> | 38 | #include <__type_traits/is_function.h> |
| 40 | #include <__type_traits/is_pointer.h> | 39 | #include <__type_traits/is_pointer.h> |
| 41 | #include <__type_traits/is_reference.h> | 40 | #include <__type_traits/is_reference.h> |
| 42 | #include <__type_traits/is_replaceable.h> | ||
| 43 | #include <__type_traits/is_same.h> | 41 | #include <__type_traits/is_same.h> |
| 44 | #include <__type_traits/is_swappable.h> | 42 | #include <__type_traits/is_swappable.h> |
| 45 | #include <__type_traits/is_trivially_relocatable.h> | 43 | #include <__type_traits/is_trivially_relocatable.h> |
| 46 | #include <__type_traits/is_unbounded_array.h> | ||
| 47 | #include <__type_traits/is_void.h> | 44 | #include <__type_traits/is_void.h> |
| 48 | #include <__type_traits/remove_extent.h> | 45 | #include <__type_traits/remove_extent.h> |
| 49 | #include <__type_traits/type_identity.h> | 46 | #include <__type_traits/type_identity.h> |
| ... | @@ -145,8 +142,6 @@ public: | ... | @@ -145,8 +142,6 @@ public: |
| 145 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, | 142 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, |
| 146 | unique_ptr, | 143 | unique_ptr, |
| 147 | void>; | 144 | void>; |
| 148 | using __replaceable _LIBCPP_NODEBUG = | ||
| 149 | __conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>; | ||
| 150 | 145 | ||
| 151 | private: | 146 | private: |
| 152 | _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); | 147 | _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); |
| ... | @@ -263,14 +258,17 @@ public: | ... | @@ -263,14 +258,17 @@ public: |
| 263 | return *this; | 258 | return *this; |
| 264 | } | 259 | } |
| 265 | 260 | ||
| 266 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const | 261 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const |
| 267 | _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) { | 262 | _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) { |
| 268 | return *__ptr_; | 263 | return *__ptr_; |
| 269 | } | 264 | } |
| 270 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_; } | 265 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_; } |
| 271 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; } | 266 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; } |
| 272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; } | 267 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { |
| 273 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT { | 268 | return __deleter_; |
| 269 | } | ||
| 270 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& | ||
| 271 | get_deleter() const _NOEXCEPT { | ||
| 274 | return __deleter_; | 272 | return __deleter_; |
| 275 | } | 273 | } |
| 276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT { | 274 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT { |
| ... | @@ -413,8 +411,6 @@ public: | ... | @@ -413,8 +411,6 @@ public: |
| 413 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, | 411 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, |
| 414 | unique_ptr, | 412 | unique_ptr, |
| 415 | void>; | 413 | void>; |
| 416 | using __replaceable _LIBCPP_NODEBUG = | ||
| 417 | __conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>; | ||
| 418 | 414 | ||
| 419 | private: | 415 | private: |
| 420 | template <class _Up, class _OtherDeleter> | 416 | template <class _Up, class _OtherDeleter> |
| ... | @@ -755,12 +751,13 @@ operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) { | ... | @@ -755,12 +751,13 @@ operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) { |
| 755 | #if _LIBCPP_STD_VER >= 14 | 751 | #if _LIBCPP_STD_VER >= 14 |
| 756 | 752 | ||
| 757 | template <class _Tp, class... _Args, enable_if_t<!is_array<_Tp>::value, int> = 0> | 753 | template <class _Tp, class... _Args, enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 758 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(_Args&&... __args) { | 754 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 755 | _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(_Args&&... __args) { | ||
| 759 | return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); | 756 | return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); |
| 760 | } | 757 | } |
| 761 | 758 | ||
| 762 | template <class _Tp, enable_if_t<__is_unbounded_array_v<_Tp>, int> = 0> | 759 | template <class _Tp, enable_if_t<__is_unbounded_array_v<_Tp>, int> = 0> |
| 763 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(size_t __n) { | 760 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(size_t __n) { |
| 764 | typedef __remove_extent_t<_Tp> _Up; | 761 | typedef __remove_extent_t<_Tp> _Up; |
| 765 | return unique_ptr<_Tp>(__private_constructor_tag(), new _Up[__n](), __n); | 762 | return unique_ptr<_Tp>(__private_constructor_tag(), new _Up[__n](), __n); |
| 766 | } | 763 | } |
| ... | @@ -773,12 +770,13 @@ void make_unique(_Args&&...) = delete; | ... | @@ -773,12 +770,13 @@ void make_unique(_Args&&...) = delete; |
| 773 | #if _LIBCPP_STD_VER >= 20 | 770 | #if _LIBCPP_STD_VER >= 20 |
| 774 | 771 | ||
| 775 | template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> | 772 | template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> |
| 776 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite() { | 773 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite() { |
| 777 | return unique_ptr<_Tp>(new _Tp); | 774 | return unique_ptr<_Tp>(new _Tp); |
| 778 | } | 775 | } |
| 779 | 776 | ||
| 780 | template <class _Tp, enable_if_t<is_unbounded_array_v<_Tp>, int> = 0> | 777 | template <class _Tp, enable_if_t<is_unbounded_array_v<_Tp>, int> = 0> |
| 781 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite(size_t __n) { | 778 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> |
| 779 | make_unique_for_overwrite(size_t __n) { | ||
| 782 | return unique_ptr<_Tp>(__private_constructor_tag(), new __remove_extent_t<_Tp>[__n], __n); | 780 | return unique_ptr<_Tp>(__private_constructor_tag(), new __remove_extent_t<_Tp>[__n], __n); |
| 783 | } | 781 | } |
| 784 | 782 | ||
| ... | @@ -802,7 +800,7 @@ struct hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, | ... | @@ -802,7 +800,7 @@ struct hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, |
| 802 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | 800 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; |
| 803 | #endif | 801 | #endif |
| 804 | 802 | ||
| 805 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const unique_ptr<_Tp, _Dp>& __ptr) const { | 803 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t operator()(const unique_ptr<_Tp, _Dp>& __ptr) const { |
| 806 | typedef typename unique_ptr<_Tp, _Dp>::pointer pointer; | 804 | typedef typename unique_ptr<_Tp, _Dp>::pointer pointer; |
| 807 | return hash<pointer>()(__ptr.get()); | 805 | return hash<pointer>()(__ptr.get()); |
| 808 | } | 806 | } |
lib/libcxx/include/__memory/uses_allocator_construction.h+1| ... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
| 17 | #include <__type_traits/remove_cv.h> | 17 | #include <__type_traits/remove_cv.h> |
| 18 | #include <__utility/declval.h> | 18 | #include <__utility/declval.h> |
| 19 | #include <__utility/pair.h> | 19 | #include <__utility/pair.h> |
| 20 | #include <__utility/piecewise_construct.h> | ||
| 20 | #include <tuple> | 21 | #include <tuple> |
| 21 | 22 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__memory_resource/memory_resource.h+4-2| ... | @@ -42,7 +42,9 @@ public: | ... | @@ -42,7 +42,9 @@ public: |
| 42 | do_deallocate(__p, __bytes, __align); | 42 | do_deallocate(__p, __bytes, __align); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI bool is_equal(const memory_resource& __other) const noexcept { return do_is_equal(__other); } | 45 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_equal(const memory_resource& __other) const noexcept { |
| 46 | return do_is_equal(__other); | ||
| 47 | } | ||
| 46 | 48 | ||
| 47 | private: | 49 | private: |
| 48 | virtual void* do_allocate(size_t, size_t) = 0; | 50 | virtual void* do_allocate(size_t, size_t) = 0; |
| ... | @@ -68,7 +70,7 @@ operator!=(const memory_resource& __lhs, const memory_resource& __rhs) noexcept | ... | @@ -68,7 +70,7 @@ operator!=(const memory_resource& __lhs, const memory_resource& __rhs) noexcept |
| 68 | 70 | ||
| 69 | // [mem.res.global] | 71 | // [mem.res.global] |
| 70 | 72 | ||
| 71 | [[__gnu__::__returns_nonnull__]] _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI memory_resource* | 73 | [[nodiscard, __gnu__::__returns_nonnull__]] _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI memory_resource* |
| 72 | get_default_resource() noexcept; | 74 | get_default_resource() noexcept; |
| 73 | 75 | ||
| 74 | [[__gnu__::__returns_nonnull__]] _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI memory_resource* | 76 | [[__gnu__::__returns_nonnull__]] _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI memory_resource* |
lib/libcxx/include/__memory_resource/monotonic_buffer_resource.h+1-1| ... | @@ -93,7 +93,7 @@ public: | ... | @@ -93,7 +93,7 @@ public: |
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; } | 96 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; } |
| 97 | 97 | ||
| 98 | protected: | 98 | protected: |
| 99 | void* do_allocate(size_t __bytes, size_t __alignment) override; // key function | 99 | void* do_allocate(size_t __bytes, size_t __alignment) override; // key function |
lib/libcxx/include/__memory_resource/polymorphic_allocator.h+13-8| ... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
| 18 | #include <__new/exceptions.h> | 18 | #include <__new/exceptions.h> |
| 19 | #include <__new/placement_new_delete.h> | 19 | #include <__new/placement_new_delete.h> |
| 20 | #include <__utility/exception_guard.h> | 20 | #include <__utility/exception_guard.h> |
| 21 | #include <__utility/piecewise_construct.h> | ||
| 21 | #include <limits> | 22 | #include <limits> |
| 22 | #include <tuple> | 23 | #include <tuple> |
| 23 | 24 | ||
| ... | @@ -50,7 +51,9 @@ public: | ... | @@ -50,7 +51,9 @@ public: |
| 50 | 51 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI polymorphic_allocator() noexcept : __res_(std::pmr::get_default_resource()) {} | 52 | _LIBCPP_HIDE_FROM_ABI polymorphic_allocator() noexcept : __res_(std::pmr::get_default_resource()) {} |
| 52 | 53 | ||
| 53 | _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(memory_resource* __r) noexcept : __res_(__r) {} | 54 | _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(memory_resource* _LIBCPP_DIAGNOSE_NULLPTR __r) noexcept : __res_(__r) { |
| 55 | _LIBCPP_ASSERT_NON_NULL(__r, "Attempted to pass a nullptr resource to polymorphic_alloator"); | ||
| 56 | } | ||
| 54 | 57 | ||
| 55 | _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(const polymorphic_allocator&) = default; | 58 | _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(const polymorphic_allocator&) = default; |
| 56 | 59 | ||
| ... | @@ -133,10 +136,10 @@ public: | ... | @@ -133,10 +136,10 @@ public: |
| 133 | piecewise_construct, | 136 | piecewise_construct, |
| 134 | __transform_tuple(typename __uses_alloc_ctor< _T1, polymorphic_allocator&, _Args1... >::type(), | 137 | __transform_tuple(typename __uses_alloc_ctor< _T1, polymorphic_allocator&, _Args1... >::type(), |
| 135 | std::move(__x), | 138 | std::move(__x), |
| 136 | typename __make_tuple_indices<sizeof...(_Args1)>::type{}), | 139 | make_index_sequence<sizeof...(_Args1)>()), |
| 137 | __transform_tuple(typename __uses_alloc_ctor< _T2, polymorphic_allocator&, _Args2... >::type(), | 140 | __transform_tuple(typename __uses_alloc_ctor< _T2, polymorphic_allocator&, _Args2... >::type(), |
| 138 | std::move(__y), | 141 | std::move(__y), |
| 139 | typename __make_tuple_indices<sizeof...(_Args2)>::type{})); | 142 | make_index_sequence<sizeof...(_Args2)>())); |
| 140 | } | 143 | } |
| 141 | 144 | ||
| 142 | template <class _T1, class _T2> | 145 | template <class _T1, class _T2> |
| ... | @@ -170,11 +173,13 @@ public: | ... | @@ -170,11 +173,13 @@ public: |
| 170 | __p->~_Tp(); | 173 | __p->~_Tp(); |
| 171 | } | 174 | } |
| 172 | 175 | ||
| 173 | _LIBCPP_HIDE_FROM_ABI polymorphic_allocator select_on_container_copy_construction() const noexcept { | 176 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI polymorphic_allocator select_on_container_copy_construction() const noexcept { |
| 174 | return polymorphic_allocator(); | 177 | return polymorphic_allocator(); |
| 175 | } | 178 | } |
| 176 | 179 | ||
| 177 | _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; } | 180 | [[nodiscard, __gnu__::__returns_nonnull__]] _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { |
| 181 | return __res_; | ||
| 182 | } | ||
| 178 | 183 | ||
| 179 | _LIBCPP_HIDE_FROM_ABI friend bool | 184 | _LIBCPP_HIDE_FROM_ABI friend bool |
| 180 | operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept { | 185 | operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept { |
| ... | @@ -192,20 +197,20 @@ public: | ... | @@ -192,20 +197,20 @@ public: |
| 192 | private: | 197 | private: |
| 193 | template <class... _Args, size_t... _Is> | 198 | template <class... _Args, size_t... _Is> |
| 194 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...> | 199 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...> |
| 195 | __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) { | 200 | __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, index_sequence<_Is...>) { |
| 196 | return std::forward_as_tuple(std::get<_Is>(std::move(__t))...); | 201 | return std::forward_as_tuple(std::get<_Is>(std::move(__t))...); |
| 197 | } | 202 | } |
| 198 | 203 | ||
| 199 | template <class... _Args, size_t... _Is> | 204 | template <class... _Args, size_t... _Is> |
| 200 | _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...> | 205 | _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...> |
| 201 | __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) { | 206 | __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, index_sequence<_Is...>) { |
| 202 | using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>; | 207 | using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>; |
| 203 | return _Tup(allocator_arg, *this, std::get<_Is>(std::move(__t))...); | 208 | return _Tup(allocator_arg, *this, std::get<_Is>(std::move(__t))...); |
| 204 | } | 209 | } |
| 205 | 210 | ||
| 206 | template <class... _Args, size_t... _Is> | 211 | template <class... _Args, size_t... _Is> |
| 207 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., polymorphic_allocator&> | 212 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., polymorphic_allocator&> |
| 208 | __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) { | 213 | __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, index_sequence<_Is...>) { |
| 209 | using _Tup = tuple<_Args&&..., polymorphic_allocator&>; | 214 | using _Tup = tuple<_Args&&..., polymorphic_allocator&>; |
| 210 | return _Tup(std::get<_Is>(std::move(__t))..., *this); | 215 | return _Tup(std::get<_Is>(std::move(__t))..., *this); |
| 211 | } | 216 | } |
lib/libcxx/include/__memory_resource/pool_options.h+1-1| ... | @@ -24,7 +24,7 @@ namespace pmr { | ... | @@ -24,7 +24,7 @@ namespace pmr { |
| 24 | 24 | ||
| 25 | // [mem.res.pool.options] | 25 | // [mem.res.pool.options] |
| 26 | 26 | ||
| 27 | struct _LIBCPP_EXPORTED_FROM_ABI pool_options { | 27 | struct pool_options { |
| 28 | size_t max_blocks_per_chunk = 0; | 28 | size_t max_blocks_per_chunk = 0; |
| 29 | size_t largest_required_pool_block = 0; | 29 | size_t largest_required_pool_block = 0; |
| 30 | }; | 30 | }; |
lib/libcxx/include/__memory_resource/synchronized_pool_resource.h+4-2| ... | @@ -56,9 +56,11 @@ public: | ... | @@ -56,9 +56,11 @@ public: |
| 56 | __unsync_.release(); | 56 | __unsync_.release(); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __unsync_.upstream_resource(); } | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { |
| 60 | return __unsync_.upstream_resource(); | ||
| 61 | } | ||
| 60 | 62 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI pool_options options() const { return __unsync_.options(); } | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI pool_options options() const { return __unsync_.options(); } |
| 62 | 64 | ||
| 63 | protected: | 65 | protected: |
| 64 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __bytes, size_t __align) override { | 66 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __bytes, size_t __align) override { |
lib/libcxx/include/__memory_resource/unsynchronized_pool_resource.h+1-1| ... | @@ -76,7 +76,7 @@ public: | ... | @@ -76,7 +76,7 @@ public: |
| 76 | 76 | ||
| 77 | void release(); | 77 | void release(); |
| 78 | 78 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; } | 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; } |
| 80 | 80 | ||
| 81 | [[__gnu__::__pure__]] pool_options options() const; | 81 | [[__gnu__::__pure__]] pool_options options() const; |
| 82 | 82 |
lib/libcxx/include/__mutex/mutex.h+2-2| ... | @@ -37,11 +37,11 @@ public: | ... | @@ -37,11 +37,11 @@ public: |
| 37 | # endif | 37 | # endif |
| 38 | 38 | ||
| 39 | _LIBCPP_ACQUIRE_CAPABILITY() void lock(); | 39 | _LIBCPP_ACQUIRE_CAPABILITY() void lock(); |
| 40 | _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock() _NOEXCEPT; | 40 | [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock() _NOEXCEPT; |
| 41 | _LIBCPP_RELEASE_CAPABILITY void unlock() _NOEXCEPT; | 41 | _LIBCPP_RELEASE_CAPABILITY void unlock() _NOEXCEPT; |
| 42 | 42 | ||
| 43 | typedef __libcpp_mutex_t* native_handle_type; | 43 | typedef __libcpp_mutex_t* native_handle_type; |
| 44 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; } | 44 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; } |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | static_assert(is_nothrow_default_constructible<mutex>::value, "the default constructor for std::mutex must be nothrow"); | 47 | static_assert(is_nothrow_default_constructible<mutex>::value, "the default constructor for std::mutex must be nothrow"); |
lib/libcxx/include/__mutex/once_flag.h+14-11| ... | @@ -10,12 +10,11 @@ | ... | @@ -10,12 +10,11 @@ |
| 10 | #define _LIBCPP___MUTEX_ONCE_FLAG_H | 10 | #define _LIBCPP___MUTEX_ONCE_FLAG_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__functional/invoke.h> | ||
| 14 | #include <__memory/addressof.h> | 13 | #include <__memory/addressof.h> |
| 15 | #include <__memory/shared_count.h> // __libcpp_acquire_load | ||
| 16 | #include <__tuple/tuple_indices.h> | ||
| 17 | #include <__tuple/tuple_size.h> | 14 | #include <__tuple/tuple_size.h> |
| 15 | #include <__type_traits/invoke.h> | ||
| 18 | #include <__utility/forward.h> | 16 | #include <__utility/forward.h> |
| 17 | #include <__utility/integer_sequence.h> | ||
| 19 | #include <__utility/move.h> | 18 | #include <__utility/move.h> |
| 20 | #include <cstdint> | 19 | #include <cstdint> |
| 21 | #ifndef _LIBCPP_CXX03_LANG | 20 | #ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -88,14 +87,9 @@ public: | ... | @@ -88,14 +87,9 @@ public: |
| 88 | _LIBCPP_HIDE_FROM_ABI explicit __call_once_param(_Fp& __f) : __f_(__f) {} | 87 | _LIBCPP_HIDE_FROM_ABI explicit __call_once_param(_Fp& __f) : __f_(__f) {} |
| 89 | 88 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI void operator()() { | 89 | _LIBCPP_HIDE_FROM_ABI void operator()() { |
| 91 | typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index; | 90 | [&]<size_t... _Indices>(__index_sequence<_Indices...>) -> void { |
| 92 | __execute(_Index()); | 91 | std::__invoke(std::get<_Indices>(std::move(__f_))...); |
| 93 | } | 92 | }(__make_index_sequence<tuple_size<_Fp>::value>()); |
| 94 | |||
| 95 | private: | ||
| 96 | template <size_t... _Indices> | ||
| 97 | _LIBCPP_HIDE_FROM_ABI void __execute(__tuple_indices<_Indices...>) { | ||
| 98 | std::__invoke(std::get<0>(std::move(__f_)), std::get<_Indices>(std::move(__f_))...); | ||
| 99 | } | 93 | } |
| 100 | }; | 94 | }; |
| 101 | 95 | ||
| ... | @@ -121,6 +115,15 @@ void _LIBCPP_HIDE_FROM_ABI __call_once_proxy(void* __vp) { | ... | @@ -121,6 +115,15 @@ void _LIBCPP_HIDE_FROM_ABI __call_once_proxy(void* __vp) { |
| 121 | 115 | ||
| 122 | _LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile once_flag::_State_type&, void*, void (*)(void*)); | 116 | _LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile once_flag::_State_type&, void*, void (*)(void*)); |
| 123 | 117 | ||
| 118 | template <class _ValueType> | ||
| 119 | inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* __value) { | ||
| 120 | #if _LIBCPP_HAS_THREADS | ||
| 121 | return __atomic_load_n(__value, __ATOMIC_ACQUIRE); | ||
| 122 | #else | ||
| 123 | return *__value; | ||
| 124 | #endif | ||
| 125 | } | ||
| 126 | |||
| 124 | #ifndef _LIBCPP_CXX03_LANG | 127 | #ifndef _LIBCPP_CXX03_LANG |
| 125 | 128 | ||
| 126 | template <class _Callable, class... _Args> | 129 | template <class _Callable, class... _Args> |
lib/libcxx/include/__mutex/tag_types.h+3-3| ... | @@ -17,15 +17,15 @@ | ... | @@ -17,15 +17,15 @@ |
| 17 | 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | struct _LIBCPP_EXPORTED_FROM_ABI defer_lock_t { | 20 | struct defer_lock_t { |
| 21 | explicit defer_lock_t() = default; | 21 | explicit defer_lock_t() = default; |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | struct _LIBCPP_EXPORTED_FROM_ABI try_to_lock_t { | 24 | struct try_to_lock_t { |
| 25 | explicit try_to_lock_t() = default; | 25 | explicit try_to_lock_t() = default; |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | struct _LIBCPP_EXPORTED_FROM_ABI adopt_lock_t { | 28 | struct adopt_lock_t { |
| 29 | explicit adopt_lock_t() = default; | 29 | explicit adopt_lock_t() = default; |
| 30 | }; | 30 | }; |
| 31 | 31 |
lib/libcxx/include/__mutex/unique_lock.h+8-7| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | #include <__memory/addressof.h> | 15 | #include <__memory/addressof.h> |
| 16 | #include <__mutex/tag_types.h> | 16 | #include <__mutex/tag_types.h> |
| 17 | #include <__system_error/throw_system_error.h> | 17 | #include <__system_error/throw_system_error.h> |
| 18 | #include <__utility/move.h> | ||
| 18 | #include <__utility/swap.h> | 19 | #include <__utility/swap.h> |
| 19 | #include <cerrno> | 20 | #include <cerrno> |
| 20 | 21 | ||
| ... | @@ -22,6 +23,9 @@ | ... | @@ -22,6 +23,9 @@ |
| 22 | # pragma GCC system_header | 23 | # pragma GCC system_header |
| 23 | #endif | 24 | #endif |
| 24 | 25 | ||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | #include <__undef_macros> | ||
| 28 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 30 | ||
| 27 | template <class _Mutex> | 31 | template <class _Mutex> |
| ... | @@ -74,13 +78,8 @@ public: | ... | @@ -74,13 +78,8 @@ public: |
| 74 | } | 78 | } |
| 75 | 79 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI unique_lock& operator=(unique_lock&& __u) _NOEXCEPT { | 80 | _LIBCPP_HIDE_FROM_ABI unique_lock& operator=(unique_lock&& __u) _NOEXCEPT { |
| 77 | if (__owns_) | 81 | if (this != std::addressof(__u)) |
| 78 | __m_->unlock(); | 82 | unique_lock(std::move(__u)).swap(*this); |
| 79 | |||
| 80 | __m_ = __u.__m_; | ||
| 81 | __owns_ = __u.__owns_; | ||
| 82 | __u.__m_ = nullptr; | ||
| 83 | __u.__owns_ = false; | ||
| 84 | return *this; | 83 | return *this; |
| 85 | } | 84 | } |
| 86 | 85 | ||
| ... | @@ -170,4 +169,6 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(unique_lock<_Mutex>& __x, unique_lock<_Mu | ... | @@ -170,4 +169,6 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(unique_lock<_Mutex>& __x, unique_lock<_Mu |
| 170 | 169 | ||
| 171 | _LIBCPP_END_NAMESPACE_STD | 170 | _LIBCPP_END_NAMESPACE_STD |
| 172 | 171 | ||
| 172 | _LIBCPP_POP_MACROS | ||
| 173 | |||
| 173 | #endif // _LIBCPP___MUTEX_UNIQUE_LOCK_H | 174 | #endif // _LIBCPP___MUTEX_UNIQUE_LOCK_H |
lib/libcxx/include/__new/align_val_t.h+6| ... | @@ -16,6 +16,12 @@ | ... | @@ -16,6 +16,12 @@ |
| 16 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | // <vcruntime_exception.h> defines its own std::align_val_t type, | ||
| 20 | // which we use in order to be ABI-compatible with other STLs on Windows. | ||
| 21 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && defined(_LIBCPP_ABI_VCRUNTIME) | ||
| 22 | # include <vcruntime_new.h> | ||
| 23 | #endif | ||
| 24 | |||
| 19 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 20 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) | 26 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) |
| 21 | # ifndef _LIBCPP_CXX03_LANG | 27 | # ifndef _LIBCPP_CXX03_LANG |
lib/libcxx/include/__new/allocate.h+1-2| ... | @@ -13,7 +13,6 @@ | ... | @@ -13,7 +13,6 @@ |
| 13 | #include <__cstddef/max_align_t.h> | 13 | #include <__cstddef/max_align_t.h> |
| 14 | #include <__cstddef/size_t.h> | 14 | #include <__cstddef/size_t.h> |
| 15 | #include <__new/align_val_t.h> | 15 | #include <__new/align_val_t.h> |
| 16 | #include <__new/global_new_delete.h> // for _LIBCPP_HAS_SIZED_DEALLOCATION | ||
| 17 | #include <__type_traits/type_identity.h> | 16 | #include <__type_traits/type_identity.h> |
| 18 | #include <__utility/element_count.h> | 17 | #include <__utility/element_count.h> |
| 19 | 18 | ||
| ... | @@ -43,7 +42,7 @@ __libcpp_allocate(__element_count __n, [[__maybe_unused__]] size_t __align = _LI | ... | @@ -43,7 +42,7 @@ __libcpp_allocate(__element_count __n, [[__maybe_unused__]] size_t __align = _LI |
| 43 | return static_cast<_Tp*>(__builtin_operator_new(__size)); | 42 | return static_cast<_Tp*>(__builtin_operator_new(__size)); |
| 44 | } | 43 | } |
| 45 | 44 | ||
| 46 | #if _LIBCPP_HAS_SIZED_DEALLOCATION | 45 | #if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L |
| 47 | # define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) __VA_ARGS__ | 46 | # define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) __VA_ARGS__ |
| 48 | #else | 47 | #else |
| 49 | # define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) /* nothing */ | 48 | # define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) /* nothing */ |
lib/libcxx/include/__new/exceptions.h+8-2| ... | @@ -17,6 +17,12 @@ | ... | @@ -17,6 +17,12 @@ |
| 17 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | // <vcruntime_exception.h> defines its own std::bad_alloc type, | ||
| 21 | // which we use in order to be ABI-compatible with other STLs on Windows. | ||
| 22 | #if defined(_LIBCPP_ABI_VCRUNTIME) | ||
| 23 | # include <vcruntime_exception.h> | ||
| 24 | #endif | ||
| 25 | |||
| 20 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 21 | #if !defined(_LIBCPP_ABI_VCRUNTIME) | 27 | #if !defined(_LIBCPP_ABI_VCRUNTIME) |
| 22 | 28 | ||
| ... | @@ -26,7 +32,7 @@ public: | ... | @@ -26,7 +32,7 @@ public: |
| 26 | _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default; | 32 | _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default; |
| 27 | _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default; | 33 | _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default; |
| 28 | ~bad_alloc() _NOEXCEPT override; | 34 | ~bad_alloc() _NOEXCEPT override; |
| 29 | const char* what() const _NOEXCEPT override; | 35 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 30 | }; | 36 | }; |
| 31 | 37 | ||
| 32 | class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc { | 38 | class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc { |
| ... | @@ -35,7 +41,7 @@ public: | ... | @@ -35,7 +41,7 @@ public: |
| 35 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default; | 41 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default; |
| 36 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default; | 42 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default; |
| 37 | ~bad_array_new_length() _NOEXCEPT override; | 43 | ~bad_array_new_length() _NOEXCEPT override; |
| 38 | const char* what() const _NOEXCEPT override; | 44 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 39 | }; | 45 | }; |
| 40 | 46 | ||
| 41 | #elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME | 47 | #elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME |
lib/libcxx/include/__new/global_new_delete.h+4-11| ... | @@ -12,7 +12,6 @@ | ... | @@ -12,7 +12,6 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__new/align_val_t.h> | 14 | #include <__new/align_val_t.h> |
| 15 | #include <__new/exceptions.h> | ||
| 16 | #include <__new/nothrow_t.h> | 15 | #include <__new/nothrow_t.h> |
| 17 | 16 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -25,12 +24,6 @@ | ... | @@ -25,12 +24,6 @@ |
| 25 | # define _THROW_BAD_ALLOC | 24 | # define _THROW_BAD_ALLOC |
| 26 | #endif | 25 | #endif |
| 27 | 26 | ||
| 28 | #if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L | ||
| 29 | # define _LIBCPP_HAS_SIZED_DEALLOCATION 1 | ||
| 30 | #else | ||
| 31 | # define _LIBCPP_HAS_SIZED_DEALLOCATION 0 | ||
| 32 | #endif | ||
| 33 | |||
| 34 | #if defined(_LIBCPP_ABI_VCRUNTIME) | 27 | #if defined(_LIBCPP_ABI_VCRUNTIME) |
| 35 | # include <new.h> | 28 | # include <new.h> |
| 36 | #else | 29 | #else |
| ... | @@ -39,7 +32,7 @@ | ... | @@ -39,7 +32,7 @@ |
| 39 | _LIBCPP_NOALIAS; | 32 | _LIBCPP_NOALIAS; |
| 40 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; | 33 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; |
| 41 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; | 34 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; |
| 42 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | 35 | # if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L |
| 43 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; | 36 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; |
| 44 | # endif | 37 | # endif |
| 45 | 38 | ||
| ... | @@ -48,7 +41,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _ | ... | @@ -48,7 +41,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _ |
| 48 | _LIBCPP_NOALIAS; | 41 | _LIBCPP_NOALIAS; |
| 49 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; | 42 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; |
| 50 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; | 43 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; |
| 51 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | 44 | # if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L |
| 52 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; | 45 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; |
| 53 | # endif | 46 | # endif |
| 54 | 47 | ||
| ... | @@ -58,7 +51,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) | ... | @@ -58,7 +51,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) |
| 58 | operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | 51 | operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; |
| 59 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; | 52 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; |
| 60 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | 53 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; |
| 61 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | 54 | # if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L |
| 62 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; | 55 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; |
| 63 | # endif | 56 | # endif |
| 64 | 57 | ||
| ... | @@ -68,7 +61,7 @@ operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; | ... | @@ -68,7 +61,7 @@ operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; |
| 68 | operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | 61 | operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; |
| 69 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; | 62 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; |
| 70 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | 63 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; |
| 71 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | 64 | # if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L |
| 72 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; | 65 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; |
| 73 | # endif | 66 | # endif |
| 74 | # endif | 67 | # endif |
lib/libcxx/include/__new/interference_size.h-4| ... | @@ -20,13 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,13 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 17 | 21 | #if _LIBCPP_STD_VER >= 17 |
| 22 | 22 | ||
| 23 | # if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | ||
| 24 | |||
| 25 | inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; | 23 | inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; |
| 26 | inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; | 24 | inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; |
| 27 | 25 | ||
| 28 | # endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | ||
| 29 | |||
| 30 | #endif // _LIBCPP_STD_VER >= 17 | 26 | #endif // _LIBCPP_STD_VER >= 17 |
| 31 | 27 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | 28 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__new/launder.h+3-5| ... | @@ -10,8 +10,6 @@ | ... | @@ -10,8 +10,6 @@ |
| 10 | #define _LIBCPP___NEW_LAUNDER_H | 10 | #define _LIBCPP___NEW_LAUNDER_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/is_function.h> | ||
| 14 | #include <__type_traits/is_void.h> | ||
| 15 | 13 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -20,15 +18,15 @@ | ... | @@ -20,15 +18,15 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | template <class _Tp> | 19 | template <class _Tp> |
| 22 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { | 20 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { |
| 23 | static_assert(!(is_function<_Tp>::value), "can't launder functions"); | 21 | // The compiler diagnoses misuses of __builtin_launder, so we don't need to add any static_asserts |
| 24 | static_assert(!is_void<_Tp>::value, "can't launder cv-void"); | 22 | // to implement the Mandates. |
| 25 | return __builtin_launder(__p); | 23 | return __builtin_launder(__p); |
| 26 | } | 24 | } |
| 27 | 25 | ||
| 28 | #if _LIBCPP_STD_VER >= 17 | 26 | #if _LIBCPP_STD_VER >= 17 |
| 29 | template <class _Tp> | 27 | template <class _Tp> |
| 30 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { | 28 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { |
| 31 | return std::__launder(__p); | 29 | return __builtin_launder(__p); |
| 32 | } | 30 | } |
| 33 | #endif | 31 | #endif |
| 34 | _LIBCPP_END_NAMESPACE_STD | 32 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__new/nothrow_t.h+1-1| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | # include <new.h> | 19 | # include <new.h> |
| 20 | #else | 20 | #else |
| 21 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 22 | struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t { | 22 | struct nothrow_t { |
| 23 | explicit nothrow_t() = default; | 23 | explicit nothrow_t() = default; |
| 24 | }; | 24 | }; |
| 25 | extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow; | 25 | extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow; |
lib/libcxx/include/__numeric/gcd_lcm.h+24-34| ... | @@ -33,28 +33,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -33,28 +33,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | ||
| 34 | #if _LIBCPP_STD_VER >= 17 | 34 | #if _LIBCPP_STD_VER >= 17 |
| 35 | 35 | ||
| 36 | template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> | 36 | template <class _Result, class _Source> |
| 37 | struct __ct_abs; | 37 | constexpr _LIBCPP_HIDE_FROM_ABI _Result __abs_in_type(_Source __t) noexcept { |
| 38 | 38 | if constexpr (is_signed_v<_Source>) { | |
| 39 | template <typename _Result, typename _Source> | ||
| 40 | struct __ct_abs<_Result, _Source, true> { | ||
| 41 | constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { | ||
| 42 | if (__t >= 0) | 39 | if (__t >= 0) |
| 43 | return __t; | 40 | return __t; |
| 44 | if (__t == numeric_limits<_Source>::min()) | 41 | if (__t == numeric_limits<_Source>::min()) |
| 45 | return -static_cast<_Result>(__t); | 42 | return -static_cast<_Result>(__t); |
| 46 | return -__t; | 43 | return -__t; |
| 44 | } else { | ||
| 45 | return __t; | ||
| 47 | } | 46 | } |
| 48 | }; | 47 | } |
| 49 | |||
| 50 | template <typename _Result, typename _Source> | ||
| 51 | struct __ct_abs<_Result, _Source, false> { | ||
| 52 | constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { return __t; } | ||
| 53 | }; | ||
| 54 | 48 | ||
| 55 | template <class _Tp> | 49 | template <class _Tp, class _Up> |
| 56 | constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { | 50 | constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) { |
| 57 | static_assert(!is_signed<_Tp>::value, ""); | 51 | static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to gcd must be integer types"); |
| 52 | static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to gcd cannot be bool"); | ||
| 53 | static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to gcd cannot be bool"); | ||
| 54 | using _Rp = common_type_t<_Tp, _Up>; | ||
| 55 | using _Wp = make_unsigned_t<_Rp>; | ||
| 58 | 56 | ||
| 59 | // Using Binary GCD algorithm https://en.wikipedia.org/wiki/Binary_GCD_algorithm, based on an implementation | 57 | // Using Binary GCD algorithm https://en.wikipedia.org/wiki/Binary_GCD_algorithm, based on an implementation |
| 60 | // from https://lemire.me/blog/2024/04/13/greatest-common-divisor-the-extended-euclidean-algorithm-and-speed/ | 58 | // from https://lemire.me/blog/2024/04/13/greatest-common-divisor-the-extended-euclidean-algorithm-and-speed/ |
| ... | @@ -67,22 +65,25 @@ constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { | ... | @@ -67,22 +65,25 @@ constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { |
| 67 | // | 65 | // |
| 68 | // And standard gcd algorithm where instead of modulo, minus is used. | 66 | // And standard gcd algorithm where instead of modulo, minus is used. |
| 69 | 67 | ||
| 68 | auto __a = static_cast<_Wp>(std::__abs_in_type<_Rp>(__m)); | ||
| 69 | auto __b = static_cast<_Wp>(std::__abs_in_type<_Rp>(__n)); | ||
| 70 | |||
| 70 | if (__a < __b) { | 71 | if (__a < __b) { |
| 71 | _Tp __tmp = __b; | 72 | _Wp __tmp = __b; |
| 72 | __b = __a; | 73 | __b = __a; |
| 73 | __a = __tmp; | 74 | __a = __tmp; |
| 74 | } | 75 | } |
| 75 | if (__b == 0) | 76 | if (__b == 0) |
| 76 | return __a; | 77 | return static_cast<_Rp>(__a); |
| 77 | __a %= __b; // Make both argument of the same size, and early result in the easy case. | 78 | __a %= __b; // Make both argument of the same size, and early result in the easy case. |
| 78 | if (__a == 0) | 79 | if (__a == 0) |
| 79 | return __b; | 80 | return static_cast<_Rp>(__b); |
| 80 | 81 | ||
| 81 | _Tp __c = __a | __b; | 82 | _Wp __c = __a | __b; |
| 82 | int __shift = std::__countr_zero(__c); | 83 | int __shift = std::__countr_zero(__c); |
| 83 | __a >>= std::__countr_zero(__a); | 84 | __a >>= std::__countr_zero(__a); |
| 84 | do { | 85 | do { |
| 85 | _Tp __t = __b >> std::__countr_zero(__b); | 86 | _Wp __t = __b >> std::__countr_zero(__b); |
| 86 | if (__a > __t) { | 87 | if (__a > __t) { |
| 87 | __b = __a - __t; | 88 | __b = __a - __t; |
| 88 | __a = __t; | 89 | __a = __t; |
| ... | @@ -90,18 +91,7 @@ constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { | ... | @@ -90,18 +91,7 @@ constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { |
| 90 | __b = __t - __a; | 91 | __b = __t - __a; |
| 91 | } | 92 | } |
| 92 | } while (__b != 0); | 93 | } while (__b != 0); |
| 93 | return __a << __shift; | 94 | return static_cast<_Rp>(__a << __shift); |
| 94 | } | ||
| 95 | |||
| 96 | template <class _Tp, class _Up> | ||
| 97 | constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) { | ||
| 98 | static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to gcd must be integer types"); | ||
| 99 | static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to gcd cannot be bool"); | ||
| 100 | static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to gcd cannot be bool"); | ||
| 101 | using _Rp = common_type_t<_Tp, _Up>; | ||
| 102 | using _Wp = make_unsigned_t<_Rp>; | ||
| 103 | return static_cast<_Rp>( | ||
| 104 | std::__gcd(static_cast<_Wp>(__ct_abs<_Rp, _Tp>()(__m)), static_cast<_Wp>(__ct_abs<_Rp, _Up>()(__n)))); | ||
| 105 | } | 95 | } |
| 106 | 96 | ||
| 107 | template <class _Tp, class _Up> | 97 | template <class _Tp, class _Up> |
| ... | @@ -113,8 +103,8 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) { | ... | @@ -113,8 +103,8 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) { |
| 113 | return 0; | 103 | return 0; |
| 114 | 104 | ||
| 115 | using _Rp = common_type_t<_Tp, _Up>; | 105 | using _Rp = common_type_t<_Tp, _Up>; |
| 116 | _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n); | 106 | _Rp __val1 = std::__abs_in_type<_Rp>(__m) / std::gcd(__m, __n); |
| 117 | _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); | 107 | _Rp __val2 = std::__abs_in_type<_Rp>(__n); |
| 118 | _Rp __res; | 108 | _Rp __res; |
| 119 | [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, std::addressof(__res)); | 109 | [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, std::addressof(__res)); |
| 120 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm"); | 110 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm"); |
lib/libcxx/include/__numeric/midpoint.h+9-14| ... | @@ -12,16 +12,13 @@ | ... | @@ -12,16 +12,13 @@ |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | 14 | #include <__cstddef/ptrdiff_t.h> |
| 15 | #include <__type_traits/enable_if.h> | ||
| 16 | #include <__type_traits/is_floating_point.h> | 15 | #include <__type_traits/is_floating_point.h> |
| 17 | #include <__type_traits/is_integral.h> | 16 | #include <__type_traits/is_integral.h> |
| 18 | #include <__type_traits/is_null_pointer.h> | ||
| 19 | #include <__type_traits/is_object.h> | 17 | #include <__type_traits/is_object.h> |
| 20 | #include <__type_traits/is_pointer.h> | ||
| 21 | #include <__type_traits/is_same.h> | 18 | #include <__type_traits/is_same.h> |
| 22 | #include <__type_traits/is_void.h> | 19 | #include <__type_traits/is_void.h> |
| 23 | #include <__type_traits/make_unsigned.h> | 20 | #include <__type_traits/make_unsigned.h> |
| 24 | #include <__type_traits/remove_pointer.h> | 21 | #include <__type_traits/remove_cv.h> |
| 25 | #include <limits> | 22 | #include <limits> |
| 26 | 23 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -35,8 +32,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -35,8 +32,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 32 | ||
| 36 | #if _LIBCPP_STD_VER >= 20 | 33 | #if _LIBCPP_STD_VER >= 20 |
| 37 | template <class _Tp> | 34 | template <class _Tp> |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp> | 35 | requires(is_integral_v<_Tp> && !is_same_v<remove_cv_t<_Tp>, bool>) |
| 39 | midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { | 36 | [[nodiscard]] |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { | ||
| 40 | using _Up = make_unsigned_t<_Tp>; | 38 | using _Up = make_unsigned_t<_Tp>; |
| 41 | constexpr _Up __bitshift = numeric_limits<_Up>::digits - 1; | 39 | constexpr _Up __bitshift = numeric_limits<_Up>::digits - 1; |
| 42 | 40 | ||
| ... | @@ -48,23 +46,20 @@ midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | ... | @@ -48,23 +46,20 @@ midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 48 | return __a + __half_diff; | 46 | return __a + __half_diff; |
| 49 | } | 47 | } |
| 50 | 48 | ||
| 51 | template <class _Tp, enable_if_t<is_object_v<_Tp> && !is_void_v<_Tp> && (sizeof(_Tp) > 0), int> = 0> | 49 | template <class _Tp> |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* midpoint(_Tp* __a, _Tp* __b) noexcept { | 50 | requires(is_object_v<_Tp> && (sizeof(_Tp) > 0)) |
| 51 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* midpoint(_Tp* __a, _Tp* __b) noexcept { | ||
| 53 | return __a + std::midpoint(ptrdiff_t(0), __b - __a); | 52 | return __a + std::midpoint(ptrdiff_t(0), __b - __a); |
| 54 | } | 53 | } |
| 55 | 54 | ||
| 56 | template <typename _Tp> | ||
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr int __sign(_Tp __val) { | ||
| 58 | return (_Tp(0) < __val) - (__val < _Tp(0)); | ||
| 59 | } | ||
| 60 | |||
| 61 | template <typename _Fp> | 55 | template <typename _Fp> |
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr _Fp __fp_abs(_Fp __f) { | 56 | _LIBCPP_HIDE_FROM_ABI constexpr _Fp __fp_abs(_Fp __f) { |
| 63 | return __f >= 0 ? __f : -__f; | 57 | return __f >= 0 ? __f : -__f; |
| 64 | } | 58 | } |
| 65 | 59 | ||
| 66 | template <class _Fp> | 60 | template <class _Fp> |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_floating_point_v<_Fp>, _Fp> midpoint(_Fp __a, _Fp __b) noexcept { | 61 | requires(is_floating_point_v<_Fp>) |
| 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Fp midpoint(_Fp __a, _Fp __b) noexcept { | ||
| 68 | constexpr _Fp __lo = numeric_limits<_Fp>::min() * 2; | 63 | constexpr _Fp __lo = numeric_limits<_Fp>::min() * 2; |
| 69 | constexpr _Fp __hi = numeric_limits<_Fp>::max() / 2; | 64 | constexpr _Fp __hi = numeric_limits<_Fp>::max() / 2; |
| 70 | 65 |
lib/libcxx/include/__numeric/pstl.h+2-2| ... | @@ -70,7 +70,7 @@ template <class _ExecutionPolicy, | ... | @@ -70,7 +70,7 @@ template <class _ExecutionPolicy, |
| 70 | class _ForwardIterator, | 70 | class _ForwardIterator, |
| 71 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, | 71 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 72 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> | 72 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 73 | _LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> | 73 | _LIBCPP_HIDE_FROM_ABI __iterator_value_type<_ForwardIterator> |
| 74 | reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { | 74 | reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { |
| 75 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators"); | 75 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators"); |
| 76 | using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>; | 76 | using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>; |
| ... | @@ -78,7 +78,7 @@ reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator _ | ... | @@ -78,7 +78,7 @@ reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator _ |
| 78 | std::forward<_ExecutionPolicy>(__policy), | 78 | std::forward<_ExecutionPolicy>(__policy), |
| 79 | std::move(__first), | 79 | std::move(__first), |
| 80 | std::move(__last), | 80 | std::move(__last), |
| 81 | __iter_value_type<_ForwardIterator>(), | 81 | __iterator_value_type<_ForwardIterator>(), |
| 82 | plus{}); | 82 | plus{}); |
| 83 | } | 83 | } |
| 84 | 84 |
lib/libcxx/include/__numeric/saturation_arithmetic.h+13-5| ... | @@ -30,6 +30,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -30,6 +30,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | ||
| 31 | template <__signed_or_unsigned_integer _Tp> | 31 | template <__signed_or_unsigned_integer _Tp> |
| 32 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { | 32 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { |
| 33 | # if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101 | ||
| 34 | return __builtin_elementwise_add_sat(__x, __y); | ||
| 35 | # else | ||
| 33 | if (_Tp __sum; !__builtin_add_overflow(__x, __y, std::addressof(__sum))) | 36 | if (_Tp __sum; !__builtin_add_overflow(__x, __y, std::addressof(__sum))) |
| 34 | return __sum; | 37 | return __sum; |
| 35 | // Handle overflow | 38 | // Handle overflow |
| ... | @@ -44,10 +47,14 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -44,10 +47,14 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { |
| 44 | // Overflows if (x < 0 && y < 0) | 47 | // Overflows if (x < 0 && y < 0) |
| 45 | return std::numeric_limits<_Tp>::min(); | 48 | return std::numeric_limits<_Tp>::min(); |
| 46 | } | 49 | } |
| 50 | # endif | ||
| 47 | } | 51 | } |
| 48 | 52 | ||
| 49 | template <__signed_or_unsigned_integer _Tp> | 53 | template <__signed_or_unsigned_integer _Tp> |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { | 54 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { |
| 55 | # if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101 | ||
| 56 | return __builtin_elementwise_sub_sat(__x, __y); | ||
| 57 | # else | ||
| 51 | if (_Tp __sub; !__builtin_sub_overflow(__x, __y, std::addressof(__sub))) | 58 | if (_Tp __sub; !__builtin_sub_overflow(__x, __y, std::addressof(__sub))) |
| 52 | return __sub; | 59 | return __sub; |
| 53 | // Handle overflow | 60 | // Handle overflow |
| ... | @@ -63,6 +70,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -63,6 +70,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { |
| 63 | // Overflows if (x < 0 && y > 0) | 70 | // Overflows if (x < 0 && y > 0) |
| 64 | return std::numeric_limits<_Tp>::min(); | 71 | return std::numeric_limits<_Tp>::min(); |
| 65 | } | 72 | } |
| 73 | # endif | ||
| 66 | } | 74 | } |
| 67 | 75 | ||
| 68 | template <__signed_or_unsigned_integer _Tp> | 76 | template <__signed_or_unsigned_integer _Tp> |
| ... | @@ -113,27 +121,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { | ... | @@ -113,27 +121,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { |
| 113 | #if _LIBCPP_STD_VER >= 26 | 121 | #if _LIBCPP_STD_VER >= 26 |
| 114 | 122 | ||
| 115 | template <__signed_or_unsigned_integer _Tp> | 123 | template <__signed_or_unsigned_integer _Tp> |
| 116 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { | 124 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { |
| 117 | return std::__add_sat(__x, __y); | 125 | return std::__add_sat(__x, __y); |
| 118 | } | 126 | } |
| 119 | 127 | ||
| 120 | template <__signed_or_unsigned_integer _Tp> | 128 | template <__signed_or_unsigned_integer _Tp> |
| 121 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { | 129 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { |
| 122 | return std::__sub_sat(__x, __y); | 130 | return std::__sub_sat(__x, __y); |
| 123 | } | 131 | } |
| 124 | 132 | ||
| 125 | template <__signed_or_unsigned_integer _Tp> | 133 | template <__signed_or_unsigned_integer _Tp> |
| 126 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { | 134 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { |
| 127 | return std::__mul_sat(__x, __y); | 135 | return std::__mul_sat(__x, __y); |
| 128 | } | 136 | } |
| 129 | 137 | ||
| 130 | template <__signed_or_unsigned_integer _Tp> | 138 | template <__signed_or_unsigned_integer _Tp> |
| 131 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { | 139 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { |
| 132 | return std::__div_sat(__x, __y); | 140 | return std::__div_sat(__x, __y); |
| 133 | } | 141 | } |
| 134 | 142 | ||
| 135 | template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp> | 143 | template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp> |
| 136 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { | 144 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { |
| 137 | return std::__saturate_cast<_Rp>(__x); | 145 | return std::__saturate_cast<_Rp>(__x); |
| 138 | } | 146 | } |
| 139 | 147 |
lib/libcxx/include/__ostream/basic_ostream.h+8-8| ... | @@ -53,7 +53,7 @@ public: | ... | @@ -53,7 +53,7 @@ public: |
| 53 | typedef typename traits_type::off_type off_type; | 53 | typedef typename traits_type::off_type off_type; |
| 54 | 54 | ||
| 55 | // 27.7.2.2 Constructor/destructor: | 55 | // 27.7.2.2 Constructor/destructor: |
| 56 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) { | 56 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) { |
| 57 | this->init(__sb); | 57 | this->init(__sb); |
| 58 | } | 58 | } |
| 59 | ~basic_ostream() override; | 59 | ~basic_ostream() override; |
| ... | @@ -67,7 +67,7 @@ protected: | ... | @@ -67,7 +67,7 @@ protected: |
| 67 | // 27.7.2.3 Assign/swap | 67 | // 27.7.2.3 Assign/swap |
| 68 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream& operator=(basic_ostream&& __rhs); | 68 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream& operator=(basic_ostream&& __rhs); |
| 69 | 69 | ||
| 70 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_ostream& __rhs) { | 70 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 void swap(basic_ostream& __rhs) { |
| 71 | basic_ios<char_type, traits_type>::swap(__rhs); | 71 | basic_ios<char_type, traits_type>::swap(__rhs); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| ... | @@ -76,17 +76,17 @@ public: | ... | @@ -76,17 +76,17 @@ public: |
| 76 | class sentry; | 76 | class sentry; |
| 77 | 77 | ||
| 78 | // 27.7.2.6 Formatted output: | 78 | // 27.7.2.6 Formatted output: |
| 79 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) { | 79 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) { |
| 80 | return __pf(*this); | 80 | return __pf(*this); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& | 83 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_ostream& |
| 84 | operator<<(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) { | 84 | operator<<(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) { |
| 85 | __pf(*this); | 85 | __pf(*this); |
| 86 | return *this; | 86 | return *this; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) { | 89 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) { |
| 90 | __pf(*this); | 90 | __pf(*this); |
| 91 | return *this; | 91 | return *this; |
| 92 | } | 92 | } |
| ... | @@ -174,9 +174,9 @@ public: | ... | @@ -174,9 +174,9 @@ public: |
| 174 | basic_ostream& flush(); | 174 | basic_ostream& flush(); |
| 175 | 175 | ||
| 176 | // 27.7.2.5 seeks: | 176 | // 27.7.2.5 seeks: |
| 177 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type tellp(); | 177 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 pos_type tellp(); |
| 178 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(pos_type __pos); | 178 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_ostream& seekp(pos_type __pos); |
| 179 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(off_type __off, ios_base::seekdir __dir); | 179 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_ostream& seekp(off_type __off, ios_base::seekdir __dir); |
| 180 | 180 | ||
| 181 | protected: | 181 | protected: |
| 182 | _LIBCPP_HIDE_FROM_ABI basic_ostream() {} // extension, intentially does not initialize | 182 | _LIBCPP_HIDE_FROM_ABI basic_ostream() {} // extension, intentially does not initialize |
lib/libcxx/include/__pstl/backends/default.h+14-14| ... | @@ -102,7 +102,7 @@ struct __find<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -102,7 +102,7 @@ struct __find<__default_backend_tag, _ExecutionPolicy> { |
| 102 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept { | 102 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept { |
| 103 | using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>; | 103 | using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>; |
| 104 | return _FindIf()( | 104 | return _FindIf()( |
| 105 | __policy, std::move(__first), std::move(__last), [&](__iter_reference<_ForwardIterator> __element) { | 105 | __policy, std::move(__first), std::move(__last), [&](__iterator_reference<_ForwardIterator> __element) { |
| 106 | return __element == __value; | 106 | return __element == __value; |
| 107 | }); | 107 | }); |
| 108 | } | 108 | } |
| ... | @@ -137,7 +137,7 @@ struct __all_of<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -137,7 +137,7 @@ struct __all_of<__default_backend_tag, _ExecutionPolicy> { |
| 137 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> | 137 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> |
| 138 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { | 138 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { |
| 139 | using _AnyOf = __dispatch<__any_of, __current_configuration, _ExecutionPolicy>; | 139 | using _AnyOf = __dispatch<__any_of, __current_configuration, _ExecutionPolicy>; |
| 140 | auto __res = _AnyOf()(__policy, __first, __last, [&](__iter_reference<_ForwardIterator> __value) { | 140 | auto __res = _AnyOf()(__policy, __first, __last, [&](__iterator_reference<_ForwardIterator> __value) { |
| 141 | return !__pred(__value); | 141 | return !__pred(__value); |
| 142 | }); | 142 | }); |
| 143 | if (!__res) | 143 | if (!__res) |
| ... | @@ -204,7 +204,7 @@ struct __fill<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -204,7 +204,7 @@ struct __fill<__default_backend_tag, _ExecutionPolicy> { |
| 204 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | 204 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> |
| 205 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept { | 205 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept { |
| 206 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; | 206 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; |
| 207 | using _Ref = __iter_reference<_ForwardIterator>; | 207 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 208 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __value; }); | 208 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __value; }); |
| 209 | } | 209 | } |
| 210 | }; | 210 | }; |
| ... | @@ -233,7 +233,7 @@ struct __replace<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -233,7 +233,7 @@ struct __replace<__default_backend_tag, _ExecutionPolicy> { |
| 233 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __old, _Tp const& __new) | 233 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __old, _Tp const& __new) |
| 234 | const noexcept { | 234 | const noexcept { |
| 235 | using _ReplaceIf = __dispatch<__replace_if, __current_configuration, _ExecutionPolicy>; | 235 | using _ReplaceIf = __dispatch<__replace_if, __current_configuration, _ExecutionPolicy>; |
| 236 | using _Ref = __iter_reference<_ForwardIterator>; | 236 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 237 | return _ReplaceIf()( | 237 | return _ReplaceIf()( |
| 238 | __policy, std::move(__first), std::move(__last), [&](_Ref __element) { return __element == __old; }, __new); | 238 | __policy, std::move(__first), std::move(__last), [&](_Ref __element) { return __element == __old; }, __new); |
| 239 | } | 239 | } |
| ... | @@ -246,7 +246,7 @@ struct __replace_if<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -246,7 +246,7 @@ struct __replace_if<__default_backend_tag, _ExecutionPolicy> { |
| 246 | _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred, _Tp const& __new_value) | 246 | _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred, _Tp const& __new_value) |
| 247 | const noexcept { | 247 | const noexcept { |
| 248 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; | 248 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; |
| 249 | using _Ref = __iter_reference<_ForwardIterator>; | 249 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 250 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { | 250 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { |
| 251 | if (__pred(__element)) | 251 | if (__pred(__element)) |
| 252 | __element = __new_value; | 252 | __element = __new_value; |
| ... | @@ -260,7 +260,7 @@ struct __generate<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -260,7 +260,7 @@ struct __generate<__default_backend_tag, _ExecutionPolicy> { |
| 260 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | 260 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> |
| 261 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator&& __gen) const noexcept { | 261 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator&& __gen) const noexcept { |
| 262 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; | 262 | using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>; |
| 263 | using _Ref = __iter_reference<_ForwardIterator>; | 263 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 264 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __gen(); }); | 264 | return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __gen(); }); |
| 265 | } | 265 | } |
| 266 | }; | 266 | }; |
| ... | @@ -271,7 +271,7 @@ struct __generate_n<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -271,7 +271,7 @@ struct __generate_n<__default_backend_tag, _ExecutionPolicy> { |
| 271 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> | 271 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> |
| 272 | operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _Generator&& __gen) const noexcept { | 272 | operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _Generator&& __gen) const noexcept { |
| 273 | using _ForEachN = __dispatch<__for_each_n, __current_configuration, _ExecutionPolicy>; | 273 | using _ForEachN = __dispatch<__for_each_n, __current_configuration, _ExecutionPolicy>; |
| 274 | using _Ref = __iter_reference<_ForwardIterator>; | 274 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 275 | return _ForEachN()(__policy, std::move(__first), __n, [&](_Ref __element) { __element = __gen(); }); | 275 | return _ForEachN()(__policy, std::move(__first), __n, [&](_Ref __element) { __element = __gen(); }); |
| 276 | } | 276 | } |
| 277 | }; | 277 | }; |
| ... | @@ -295,11 +295,11 @@ struct __sort<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -295,11 +295,11 @@ struct __sort<__default_backend_tag, _ExecutionPolicy> { |
| 295 | template <class _ExecutionPolicy> | 295 | template <class _ExecutionPolicy> |
| 296 | struct __count_if<__default_backend_tag, _ExecutionPolicy> { | 296 | struct __count_if<__default_backend_tag, _ExecutionPolicy> { |
| 297 | template <class _Policy, class _ForwardIterator, class _Predicate> | 297 | template <class _Policy, class _ForwardIterator, class _Predicate> |
| 298 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> operator()( | 298 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iterator_difference_type<_ForwardIterator>> operator()( |
| 299 | _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred) const noexcept { | 299 | _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred) const noexcept { |
| 300 | using _TransformReduce = __dispatch<__transform_reduce, __current_configuration, _ExecutionPolicy>; | 300 | using _TransformReduce = __dispatch<__transform_reduce, __current_configuration, _ExecutionPolicy>; |
| 301 | using _DiffT = __iter_diff_t<_ForwardIterator>; | 301 | using _DiffT = __iterator_difference_type<_ForwardIterator>; |
| 302 | using _Ref = __iter_reference<_ForwardIterator>; | 302 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 303 | return _TransformReduce()( | 303 | return _TransformReduce()( |
| 304 | __policy, std::move(__first), std::move(__last), _DiffT{}, std::plus{}, [&](_Ref __element) -> _DiffT { | 304 | __policy, std::move(__first), std::move(__last), _DiffT{}, std::plus{}, [&](_Ref __element) -> _DiffT { |
| 305 | return __pred(__element) ? _DiffT(1) : _DiffT(0); | 305 | return __pred(__element) ? _DiffT(1) : _DiffT(0); |
| ... | @@ -310,10 +310,10 @@ struct __count_if<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -310,10 +310,10 @@ struct __count_if<__default_backend_tag, _ExecutionPolicy> { |
| 310 | template <class _ExecutionPolicy> | 310 | template <class _ExecutionPolicy> |
| 311 | struct __count<__default_backend_tag, _ExecutionPolicy> { | 311 | struct __count<__default_backend_tag, _ExecutionPolicy> { |
| 312 | template <class _Policy, class _ForwardIterator, class _Tp> | 312 | template <class _Policy, class _ForwardIterator, class _Tp> |
| 313 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> | 313 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iterator_difference_type<_ForwardIterator>> |
| 314 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept { | 314 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept { |
| 315 | using _CountIf = __dispatch<__count_if, __current_configuration, _ExecutionPolicy>; | 315 | using _CountIf = __dispatch<__count_if, __current_configuration, _ExecutionPolicy>; |
| 316 | using _Ref = __iter_reference<_ForwardIterator>; | 316 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 317 | return _CountIf()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) -> bool { | 317 | return _CountIf()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) -> bool { |
| 318 | return __element == __value; | 318 | return __element == __value; |
| 319 | }); | 319 | }); |
| ... | @@ -402,7 +402,7 @@ struct __replace_copy_if<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -402,7 +402,7 @@ struct __replace_copy_if<__default_backend_tag, _ExecutionPolicy> { |
| 402 | _Pred&& __pred, | 402 | _Pred&& __pred, |
| 403 | _Tp const& __new_value) const noexcept { | 403 | _Tp const& __new_value) const noexcept { |
| 404 | using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>; | 404 | using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>; |
| 405 | using _Ref = __iter_reference<_ForwardIterator>; | 405 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 406 | auto __res = | 406 | auto __res = |
| 407 | _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), [&](_Ref __element) { | 407 | _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), [&](_Ref __element) { |
| 408 | return __pred(__element) ? __new_value : __element; | 408 | return __pred(__element) ? __new_value : __element; |
| ... | @@ -424,7 +424,7 @@ struct __replace_copy<__default_backend_tag, _ExecutionPolicy> { | ... | @@ -424,7 +424,7 @@ struct __replace_copy<__default_backend_tag, _ExecutionPolicy> { |
| 424 | _Tp const& __old_value, | 424 | _Tp const& __old_value, |
| 425 | _Tp const& __new_value) const noexcept { | 425 | _Tp const& __new_value) const noexcept { |
| 426 | using _ReplaceCopyIf = __dispatch<__replace_copy_if, __current_configuration, _ExecutionPolicy>; | 426 | using _ReplaceCopyIf = __dispatch<__replace_copy_if, __current_configuration, _ExecutionPolicy>; |
| 427 | using _Ref = __iter_reference<_ForwardIterator>; | 427 | using _Ref = __iterator_reference<_ForwardIterator>; |
| 428 | return _ReplaceCopyIf()( | 428 | return _ReplaceCopyIf()( |
| 429 | __policy, | 429 | __policy, |
| 430 | std::move(__first), | 430 | std::move(__first), |
lib/libcxx/include/__pstl/backends/libdispatch.h+2-2| ... | @@ -269,7 +269,7 @@ struct __cpu_traits<__libdispatch_backend_tag> { | ... | @@ -269,7 +269,7 @@ struct __cpu_traits<__libdispatch_backend_tag> { |
| 269 | return __empty{}; | 269 | return __empty{}; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | using _Value = __iter_value_type<_RandomAccessIterator>; | 272 | using _Value = __iterator_value_type<_RandomAccessIterator>; |
| 273 | 273 | ||
| 274 | auto __destroy = [__size](_Value* __ptr) { | 274 | auto __destroy = [__size](_Value* __ptr) { |
| 275 | std::destroy_n(__ptr, __size); | 275 | std::destroy_n(__ptr, __size); |
| ... | @@ -282,7 +282,7 @@ struct __cpu_traits<__libdispatch_backend_tag> { | ... | @@ -282,7 +282,7 @@ struct __cpu_traits<__libdispatch_backend_tag> { |
| 282 | // Initialize all elements to a moved-from state | 282 | // Initialize all elements to a moved-from state |
| 283 | // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928 | 283 | // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928 |
| 284 | std::__construct_at(__values.get(), std::move(*__first)); | 284 | std::__construct_at(__values.get(), std::move(*__first)); |
| 285 | for (__iter_diff_t<_RandomAccessIterator> __i = 1; __i != __size; ++__i) { | 285 | for (__iterator_difference_type<_RandomAccessIterator> __i = 1; __i != __size; ++__i) { |
| 286 | std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1])); | 286 | std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1])); |
| 287 | } | 287 | } |
| 288 | *__first = std::move(__values.get()[__size - 1]); | 288 | *__first = std::move(__values.get()[__size - 1]); |
lib/libcxx/include/__pstl/cpu_algos/find_if.h+1-1| ... | @@ -119,7 +119,7 @@ struct __cpu_parallel_find_if { | ... | @@ -119,7 +119,7 @@ struct __cpu_parallel_find_if { |
| 119 | true); | 119 | true); |
| 120 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && | 120 | } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> && |
| 121 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { | 121 | __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { |
| 122 | using __diff_t = __iter_diff_t<_ForwardIterator>; | 122 | using __diff_t = __iterator_difference_type<_ForwardIterator>; |
| 123 | return __pstl::__simd_first<_Backend>( | 123 | return __pstl::__simd_first<_Backend>( |
| 124 | __first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) { | 124 | __first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) { |
| 125 | return __pred(__iter[__i]); | 125 | return __pred(__iter[__i]); |
lib/libcxx/include/__pstl/cpu_algos/transform.h+5-6| ... | @@ -84,9 +84,8 @@ struct __cpu_parallel_transform { | ... | @@ -84,9 +84,8 @@ struct __cpu_parallel_transform { |
| 84 | __first, | 84 | __first, |
| 85 | __last - __first, | 85 | __last - __first, |
| 86 | __result, | 86 | __result, |
| 87 | [&](__iter_reference<_ForwardIterator> __in_value, __iter_reference<_ForwardOutIterator> __out_value) { | 87 | [&](__iterator_reference<_ForwardIterator> __in_value, |
| 88 | __out_value = __op(__in_value); | 88 | __iterator_reference<_ForwardOutIterator> __out_value) { __out_value = __op(__in_value); }); |
| 89 | }); | ||
| 90 | } else { | 89 | } else { |
| 91 | return std::transform(__first, __last, __result, __op); | 90 | return std::transform(__first, __last, __result, __op); |
| 92 | } | 91 | } |
| ... | @@ -138,9 +137,9 @@ struct __cpu_parallel_transform_binary { | ... | @@ -138,9 +137,9 @@ struct __cpu_parallel_transform_binary { |
| 138 | __last1 - __first1, | 137 | __last1 - __first1, |
| 139 | __first2, | 138 | __first2, |
| 140 | __result, | 139 | __result, |
| 141 | [&](__iter_reference<_ForwardIterator1> __in1, | 140 | [&](__iterator_reference<_ForwardIterator1> __in1, |
| 142 | __iter_reference<_ForwardIterator2> __in2, | 141 | __iterator_reference<_ForwardIterator2> __in2, |
| 143 | __iter_reference<_ForwardOutIterator> __out_value) { __out_value = __op(__in1, __in2); }); | 142 | __iterator_reference<_ForwardOutIterator> __out_value) { __out_value = __op(__in1, __in2); }); |
| 144 | } else { | 143 | } else { |
| 145 | return std::transform(__first1, __last1, __first2, __result, __op); | 144 | return std::transform(__first1, __last1, __first2, __result, __op); |
| 146 | } | 145 | } |
lib/libcxx/include/__pstl/cpu_algos/transform_reduce.h+5-4| ... | @@ -148,9 +148,10 @@ struct __cpu_parallel_transform_reduce_binary { | ... | @@ -148,9 +148,10 @@ struct __cpu_parallel_transform_reduce_binary { |
| 148 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && | 148 | __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && |
| 149 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { | 149 | __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { |
| 150 | return __pstl::__simd_transform_reduce<_Backend>( | 150 | return __pstl::__simd_transform_reduce<_Backend>( |
| 151 | __last1 - __first1, std::move(__init), std::move(__reduce), [&](__iter_diff_t<_ForwardIterator1> __i) { | 151 | __last1 - __first1, |
| 152 | return __transform(__first1[__i], __first2[__i]); | 152 | std::move(__init), |
| 153 | }); | 153 | std::move(__reduce), |
| 154 | [&](__iterator_difference_type<_ForwardIterator1> __i) { return __transform(__first1[__i], __first2[__i]); }); | ||
| 154 | } else { | 155 | } else { |
| 155 | return std::transform_reduce( | 156 | return std::transform_reduce( |
| 156 | std::move(__first1), | 157 | std::move(__first1), |
| ... | @@ -200,7 +201,7 @@ struct __cpu_parallel_transform_reduce { | ... | @@ -200,7 +201,7 @@ struct __cpu_parallel_transform_reduce { |
| 200 | __last - __first, | 201 | __last - __first, |
| 201 | std::move(__init), | 202 | std::move(__init), |
| 202 | std::move(__reduce), | 203 | std::move(__reduce), |
| 203 | [=, &__transform](__iter_diff_t<_ForwardIterator> __i) { return __transform(__first[__i]); }); | 204 | [=, &__transform](__iterator_difference_type<_ForwardIterator> __i) { return __transform(__first[__i]); }); |
| 204 | } else { | 205 | } else { |
| 205 | return std::transform_reduce( | 206 | return std::transform_reduce( |
| 206 | std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform)); | 207 | std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform)); |
lib/libcxx/include/__random/binomial_distribution.h+10-4| ... | @@ -97,13 +97,19 @@ public: | ... | @@ -97,13 +97,19 @@ public: |
| 97 | } | 97 | } |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | // The LLVM C library provides this with conflicting `noexcept` attributes. | 100 | // Some libc declares the math functions to be `noexcept`. |
| 101 | #if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__) | 101 | #if _LIBCPP_GLIBC_PREREQ(2, 8) || defined(__LLVM_LIBC__) |
| 102 | extern "C" double lgamma_r(double, int*); | 102 | # define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT |
| 103 | #else | ||
| 104 | # define _LIBCPP_LGAMMA_R_NOEXCEPT | ||
| 105 | #endif | ||
| 106 | |||
| 107 | #if !defined(_LIBCPP_MSVCRT_LIKE) | ||
| 108 | extern "C" double lgamma_r(double, int*) _LIBCPP_LGAMMA_R_NOEXCEPT; | ||
| 103 | #endif | 109 | #endif |
| 104 | 110 | ||
| 105 | inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) { | 111 | inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) { |
| 106 | #if defined(_LIBCPP_MSVCRT_LIKE) || defined(__LLVM_LIBC__) | 112 | #if defined(_LIBCPP_MSVCRT_LIKE) |
| 107 | return lgamma(__d); | 113 | return lgamma(__d); |
| 108 | #else | 114 | #else |
| 109 | int __sign; | 115 | int __sign; |
lib/libcxx/include/__random/mersenne_twister_engine.h+50-154| ... | @@ -62,24 +62,6 @@ _LIBCPP_HIDE_FROM_ABI bool | ... | @@ -62,24 +62,6 @@ _LIBCPP_HIDE_FROM_ABI bool |
| 62 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | 62 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, |
| 63 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | 63 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); |
| 64 | 64 | ||
| 65 | template <class _UInt, | ||
| 66 | size_t _Wp, | ||
| 67 | size_t _Np, | ||
| 68 | size_t _Mp, | ||
| 69 | size_t _Rp, | ||
| 70 | _UInt _Ap, | ||
| 71 | size_t _Up, | ||
| 72 | _UInt _Dp, | ||
| 73 | size_t _Sp, | ||
| 74 | _UInt _Bp, | ||
| 75 | size_t _Tp, | ||
| 76 | _UInt _Cp, | ||
| 77 | size_t _Lp, | ||
| 78 | _UInt _Fp> | ||
| 79 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 80 | operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | ||
| 81 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | ||
| 82 | |||
| 83 | template <class _CharT, | 65 | template <class _CharT, |
| 84 | class _Traits, | 66 | class _Traits, |
| 85 | class _UInt, | 67 | class _UInt, |
| ... | @@ -194,14 +176,31 @@ public: | ... | @@ -194,14 +176,31 @@ public: |
| 194 | _LIBCPP_HIDE_FROM_ABI explicit mersenne_twister_engine(_Sseq& __q) { | 176 | _LIBCPP_HIDE_FROM_ABI explicit mersenne_twister_engine(_Sseq& __q) { |
| 195 | seed(__q); | 177 | seed(__q); |
| 196 | } | 178 | } |
| 197 | _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd = default_seed); | 179 | _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd = default_seed) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { |
| 180 | __x_[0] = __sd & _Max; | ||
| 181 | for (size_t __i = 1; __i < __n; ++__i) | ||
| 182 | __x_[__i] = (__f * (__x_[__i - 1] ^ __rshift<__w - 2>(__x_[__i - 1])) + __i) & _Max; | ||
| 183 | __i_ = 0; | ||
| 184 | } | ||
| 198 | template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0> | 185 | template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0> |
| 199 | _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) { | 186 | _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) { |
| 200 | __seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>()); | 187 | __seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>()); |
| 201 | } | 188 | } |
| 202 | 189 | ||
| 203 | // generating functions | 190 | // generating functions |
| 204 | _LIBCPP_HIDE_FROM_ABI result_type operator()(); | 191 | _LIBCPP_HIDE_FROM_ABI result_type operator()() { |
| 192 | const size_t __j = (__i_ + 1) % __n; | ||
| 193 | const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); | ||
| 194 | const result_type __yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask); | ||
| 195 | const size_t __k = (__i_ + __m) % __n; | ||
| 196 | __x_[__i_] = __x_[__k] ^ __rshift<1>(__yp) ^ (__a * (__yp & 1)); | ||
| 197 | result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d); | ||
| 198 | __i_ = __j; | ||
| 199 | __z ^= __lshift<__s>(__z) & __b; | ||
| 200 | __z ^= __lshift<__t>(__z) & __c; | ||
| 201 | return __z ^ __rshift<__l>(__z); | ||
| 202 | } | ||
| 203 | |||
| 205 | _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) { | 204 | _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) { |
| 206 | for (; __z; --__z) | 205 | for (; __z; --__z) |
| 207 | operator()(); | 206 | operator()(); |
| ... | @@ -225,24 +224,6 @@ public: | ... | @@ -225,24 +224,6 @@ public: |
| 225 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | 224 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, |
| 226 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | 225 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); |
| 227 | 226 | ||
| 228 | template <class _UInt, | ||
| 229 | size_t _Wp, | ||
| 230 | size_t _Np, | ||
| 231 | size_t _Mp, | ||
| 232 | size_t _Rp, | ||
| 233 | _UInt _Ap, | ||
| 234 | size_t _Up, | ||
| 235 | _UInt _Dp, | ||
| 236 | size_t _Sp, | ||
| 237 | _UInt _Bp, | ||
| 238 | size_t _Tp, | ||
| 239 | _UInt _Cp, | ||
| 240 | size_t _Lp, | ||
| 241 | _UInt _Fp> | ||
| 242 | friend bool operator!=( | ||
| 243 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | ||
| 244 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | ||
| 245 | |||
| 246 | template <class _CharT, | 227 | template <class _CharT, |
| 247 | class _Traits, | 228 | class _Traits, |
| 248 | class _UInt, | 229 | class _UInt, |
| ... | @@ -285,9 +266,38 @@ public: | ... | @@ -285,9 +266,38 @@ public: |
| 285 | 266 | ||
| 286 | private: | 267 | private: |
| 287 | template <class _Sseq> | 268 | template <class _Sseq> |
| 288 | _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 1>); | 269 | _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 1>) { |
| 270 | const unsigned __k = 1; | ||
| 271 | uint32_t __ar[__n * __k]; | ||
| 272 | __q.generate(__ar, __ar + __n * __k); | ||
| 273 | for (size_t __i = 0; __i < __n; ++__i) | ||
| 274 | __x_[__i] = static_cast<result_type>(__ar[__i] & _Max); | ||
| 275 | const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); | ||
| 276 | __i_ = 0; | ||
| 277 | if ((__x_[0] & ~__mask) == 0) { | ||
| 278 | for (size_t __i = 1; __i < __n; ++__i) | ||
| 279 | if (__x_[__i] != 0) | ||
| 280 | return; | ||
| 281 | __x_[0] = result_type(1) << (__w - 1); | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 289 | template <class _Sseq> | 285 | template <class _Sseq> |
| 290 | _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>); | 286 | _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>) { |
| 287 | const unsigned __k = 2; | ||
| 288 | uint32_t __ar[__n * __k]; | ||
| 289 | __q.generate(__ar, __ar + __n * __k); | ||
| 290 | for (size_t __i = 0; __i < __n; ++__i) | ||
| 291 | __x_[__i] = static_cast<result_type>((__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); | ||
| 292 | const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); | ||
| 293 | __i_ = 0; | ||
| 294 | if ((__x_[0] & ~__mask) == 0) { | ||
| 295 | for (size_t __i = 1; __i < __n; ++__i) | ||
| 296 | if (__x_[__i] != 0) | ||
| 297 | return; | ||
| 298 | __x_[0] = result_type(1) << (__w - 1); | ||
| 299 | } | ||
| 300 | } | ||
| 291 | 301 | ||
| 292 | template <size_t __count, | 302 | template <size_t __count, |
| 293 | __enable_if_t<__count< __w, int> = 0> _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type __x) { | 303 | __enable_if_t<__count< __w, int> = 0> _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type __x) { |
| ... | @@ -310,120 +320,6 @@ private: | ... | @@ -310,120 +320,6 @@ private: |
| 310 | } | 320 | } |
| 311 | }; | 321 | }; |
| 312 | 322 | ||
| 313 | template <class _UIntType, | ||
| 314 | size_t __w, | ||
| 315 | size_t __n, | ||
| 316 | size_t __m, | ||
| 317 | size_t __r, | ||
| 318 | _UIntType __a, | ||
| 319 | size_t __u, | ||
| 320 | _UIntType __d, | ||
| 321 | size_t __s, | ||
| 322 | _UIntType __b, | ||
| 323 | size_t __t, | ||
| 324 | _UIntType __c, | ||
| 325 | size_t __l, | ||
| 326 | _UIntType __f> | ||
| 327 | void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::seed( | ||
| 328 | result_type __sd) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { // __w >= 2 | ||
| 329 | __x_[0] = __sd & _Max; | ||
| 330 | for (size_t __i = 1; __i < __n; ++__i) | ||
| 331 | __x_[__i] = (__f * (__x_[__i - 1] ^ __rshift<__w - 2>(__x_[__i - 1])) + __i) & _Max; | ||
| 332 | __i_ = 0; | ||
| 333 | } | ||
| 334 | |||
| 335 | template <class _UIntType, | ||
| 336 | size_t __w, | ||
| 337 | size_t __n, | ||
| 338 | size_t __m, | ||
| 339 | size_t __r, | ||
| 340 | _UIntType __a, | ||
| 341 | size_t __u, | ||
| 342 | _UIntType __d, | ||
| 343 | size_t __s, | ||
| 344 | _UIntType __b, | ||
| 345 | size_t __t, | ||
| 346 | _UIntType __c, | ||
| 347 | size_t __l, | ||
| 348 | _UIntType __f> | ||
| 349 | template <class _Sseq> | ||
| 350 | void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::__seed( | ||
| 351 | _Sseq& __q, integral_constant<unsigned, 1>) { | ||
| 352 | const unsigned __k = 1; | ||
| 353 | uint32_t __ar[__n * __k]; | ||
| 354 | __q.generate(__ar, __ar + __n * __k); | ||
| 355 | for (size_t __i = 0; __i < __n; ++__i) | ||
| 356 | __x_[__i] = static_cast<result_type>(__ar[__i] & _Max); | ||
| 357 | const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); | ||
| 358 | __i_ = 0; | ||
| 359 | if ((__x_[0] & ~__mask) == 0) { | ||
| 360 | for (size_t __i = 1; __i < __n; ++__i) | ||
| 361 | if (__x_[__i] != 0) | ||
| 362 | return; | ||
| 363 | __x_[0] = result_type(1) << (__w - 1); | ||
| 364 | } | ||
| 365 | } | ||
| 366 | |||
| 367 | template <class _UIntType, | ||
| 368 | size_t __w, | ||
| 369 | size_t __n, | ||
| 370 | size_t __m, | ||
| 371 | size_t __r, | ||
| 372 | _UIntType __a, | ||
| 373 | size_t __u, | ||
| 374 | _UIntType __d, | ||
| 375 | size_t __s, | ||
| 376 | _UIntType __b, | ||
| 377 | size_t __t, | ||
| 378 | _UIntType __c, | ||
| 379 | size_t __l, | ||
| 380 | _UIntType __f> | ||
| 381 | template <class _Sseq> | ||
| 382 | void mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::__seed( | ||
| 383 | _Sseq& __q, integral_constant<unsigned, 2>) { | ||
| 384 | const unsigned __k = 2; | ||
| 385 | uint32_t __ar[__n * __k]; | ||
| 386 | __q.generate(__ar, __ar + __n * __k); | ||
| 387 | for (size_t __i = 0; __i < __n; ++__i) | ||
| 388 | __x_[__i] = static_cast<result_type>((__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); | ||
| 389 | const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); | ||
| 390 | __i_ = 0; | ||
| 391 | if ((__x_[0] & ~__mask) == 0) { | ||
| 392 | for (size_t __i = 1; __i < __n; ++__i) | ||
| 393 | if (__x_[__i] != 0) | ||
| 394 | return; | ||
| 395 | __x_[0] = result_type(1) << (__w - 1); | ||
| 396 | } | ||
| 397 | } | ||
| 398 | |||
| 399 | template <class _UIntType, | ||
| 400 | size_t __w, | ||
| 401 | size_t __n, | ||
| 402 | size_t __m, | ||
| 403 | size_t __r, | ||
| 404 | _UIntType __a, | ||
| 405 | size_t __u, | ||
| 406 | _UIntType __d, | ||
| 407 | size_t __s, | ||
| 408 | _UIntType __b, | ||
| 409 | size_t __t, | ||
| 410 | _UIntType __c, | ||
| 411 | size_t __l, | ||
| 412 | _UIntType __f> | ||
| 413 | _UIntType | ||
| 414 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() { | ||
| 415 | const size_t __j = (__i_ + 1) % __n; | ||
| 416 | const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1); | ||
| 417 | const result_type __yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask); | ||
| 418 | const size_t __k = (__i_ + __m) % __n; | ||
| 419 | __x_[__i_] = __x_[__k] ^ __rshift<1>(__yp) ^ (__a * (__yp & 1)); | ||
| 420 | result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d); | ||
| 421 | __i_ = __j; | ||
| 422 | __z ^= __lshift<__s>(__z) & __b; | ||
| 423 | __z ^= __lshift<__t>(__z) & __c; | ||
| 424 | return __z ^ __rshift<__l>(__z); | ||
| 425 | } | ||
| 426 | |||
| 427 | template <class _UInt, | 323 | template <class _UInt, |
| 428 | size_t _Wp, | 324 | size_t _Wp, |
| 429 | size_t _Np, | 325 | size_t _Np, |
lib/libcxx/include/__random/piecewise_constant_distribution.h+3-2| ... | @@ -9,9 +9,11 @@ | ... | @@ -9,9 +9,11 @@ |
| 9 | #ifndef _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H | 9 | #ifndef _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H |
| 10 | #define _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H | 10 | #define _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy_n.h> | ||
| 12 | #include <__algorithm/upper_bound.h> | 13 | #include <__algorithm/upper_bound.h> |
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | 15 | #include <__cstddef/ptrdiff_t.h> |
| 16 | #include <__iterator/back_insert_iterator.h> | ||
| 15 | #include <__random/is_valid.h> | 17 | #include <__random/is_valid.h> |
| 16 | #include <__random/uniform_real_distribution.h> | 18 | #include <__random/uniform_real_distribution.h> |
| 17 | #include <__vector/vector.h> | 19 | #include <__vector/vector.h> |
| ... | @@ -190,8 +192,7 @@ piecewise_constant_distribution<_RealType>::param_type::param_type( | ... | @@ -190,8 +192,7 @@ piecewise_constant_distribution<_RealType>::param_type::param_type( |
| 190 | __areas_.assign(1, 0.0); | 192 | __areas_.assign(1, 0.0); |
| 191 | } else { | 193 | } else { |
| 192 | __densities_.reserve(__b_.size() - 1); | 194 | __densities_.reserve(__b_.size() - 1); |
| 193 | for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__f_w) | 195 | std::copy_n(__f_w, __b_.size() - 1, std::back_inserter(__densities_)); |
| 194 | __densities_.push_back(*__f_w); | ||
| 195 | __init(); | 196 | __init(); |
| 196 | } | 197 | } |
| 197 | } | 198 | } |
lib/libcxx/include/__random/piecewise_linear_distribution.h+3-2| ... | @@ -9,9 +9,11 @@ | ... | @@ -9,9 +9,11 @@ |
| 9 | #ifndef _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H | 9 | #ifndef _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H |
| 10 | #define _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H | 10 | #define _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy_n.h> | ||
| 12 | #include <__algorithm/upper_bound.h> | 13 | #include <__algorithm/upper_bound.h> |
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | 15 | #include <__cstddef/ptrdiff_t.h> |
| 16 | #include <__iterator/back_insert_iterator.h> | ||
| 15 | #include <__random/is_valid.h> | 17 | #include <__random/is_valid.h> |
| 16 | #include <__random/uniform_real_distribution.h> | 18 | #include <__random/uniform_real_distribution.h> |
| 17 | #include <__vector/comparison.h> | 19 | #include <__vector/comparison.h> |
| ... | @@ -194,8 +196,7 @@ piecewise_linear_distribution<_RealType>::param_type::param_type( | ... | @@ -194,8 +196,7 @@ piecewise_linear_distribution<_RealType>::param_type::param_type( |
| 194 | __areas_.assign(1, 0.0); | 196 | __areas_.assign(1, 0.0); |
| 195 | } else { | 197 | } else { |
| 196 | __densities_.reserve(__b_.size()); | 198 | __densities_.reserve(__b_.size()); |
| 197 | for (size_t __i = 0; __i < __b_.size(); ++__i, ++__f_w) | 199 | std::copy_n(__f_w, __b_.size(), std::back_inserter(__densities_)); |
| 198 | __densities_.push_back(*__f_w); | ||
| 199 | __init(); | 200 | __init(); |
| 200 | } | 201 | } |
| 201 | } | 202 | } |
lib/libcxx/include/__ranges/adjacent_transform_view.h created+406| ... | @@ -0,0 +1,406 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___RANGES_ADJACENT_TRANSFORM_VIEW_H | ||
| 11 | #define _LIBCPP___RANGES_ADJACENT_TRANSFORM_VIEW_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #include <__algorithm/min.h> | ||
| 16 | #include <__compare/three_way_comparable.h> | ||
| 17 | #include <__concepts/constructible.h> | ||
| 18 | #include <__concepts/convertible_to.h> | ||
| 19 | #include <__concepts/derived_from.h> | ||
| 20 | #include <__concepts/equality_comparable.h> | ||
| 21 | #include <__concepts/invocable.h> | ||
| 22 | #include <__cstddef/size_t.h> | ||
| 23 | #include <__functional/bind_back.h> | ||
| 24 | #include <__functional/invoke.h> | ||
| 25 | #include <__functional/operations.h> | ||
| 26 | #include <__iterator/concepts.h> | ||
| 27 | #include <__iterator/incrementable_traits.h> | ||
| 28 | #include <__iterator/iter_move.h> | ||
| 29 | #include <__iterator/iter_swap.h> | ||
| 30 | #include <__iterator/iterator_traits.h> | ||
| 31 | #include <__iterator/next.h> | ||
| 32 | #include <__iterator/prev.h> | ||
| 33 | #include <__memory/addressof.h> | ||
| 34 | #include <__ranges/access.h> | ||
| 35 | #include <__ranges/adjacent_view.h> | ||
| 36 | #include <__ranges/all.h> | ||
| 37 | #include <__ranges/concepts.h> | ||
| 38 | #include <__ranges/empty_view.h> | ||
| 39 | #include <__ranges/movable_box.h> | ||
| 40 | #include <__ranges/range_adaptor.h> | ||
| 41 | #include <__ranges/size.h> | ||
| 42 | #include <__ranges/view_interface.h> | ||
| 43 | #include <__ranges/zip_transform_view.h> | ||
| 44 | #include <__type_traits/common_type.h> | ||
| 45 | #include <__type_traits/decay.h> | ||
| 46 | #include <__type_traits/is_nothrow_constructible.h> | ||
| 47 | #include <__type_traits/is_object.h> | ||
| 48 | #include <__type_traits/is_referenceable.h> | ||
| 49 | #include <__type_traits/make_unsigned.h> | ||
| 50 | #include <__type_traits/maybe_const.h> | ||
| 51 | #include <__utility/declval.h> | ||
| 52 | #include <__utility/forward.h> | ||
| 53 | #include <__utility/in_place.h> | ||
| 54 | #include <__utility/integer_sequence.h> | ||
| 55 | #include <__utility/move.h> | ||
| 56 | |||
| 57 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 58 | # pragma GCC system_header | ||
| 59 | #endif | ||
| 60 | |||
| 61 | _LIBCPP_PUSH_MACROS | ||
| 62 | #include <__undef_macros> | ||
| 63 | |||
| 64 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 65 | |||
| 66 | #if _LIBCPP_STD_VER >= 23 | ||
| 67 | |||
| 68 | namespace ranges { | ||
| 69 | |||
| 70 | template <class _Fn, size_t _Np> | ||
| 71 | struct __apply_n { | ||
| 72 | template <class _Tp, size_t... _Is> | ||
| 73 | static auto __apply(index_sequence<_Is...>) -> invoke_result_t<_Fn, decltype((void)_Is, std::declval<_Tp>())...>; | ||
| 74 | |||
| 75 | template <class _Tp> | ||
| 76 | static auto operator()(_Tp&&) -> decltype(__apply<_Tp>(make_index_sequence<_Np>{})); | ||
| 77 | }; | ||
| 78 | |||
| 79 | template <forward_range _View, move_constructible _Fn, size_t _Np> | ||
| 80 | requires view<_View> && (_Np > 0) && is_object_v<_Fn> && | ||
| 81 | regular_invocable<__apply_n<_Fn&, _Np>, range_reference_t<_View>> && | ||
| 82 | __referenceable<invoke_result_t<__apply_n<_Fn&, _Np>, range_reference_t<_View>>> | ||
| 83 | class adjacent_transform_view : public view_interface<adjacent_transform_view<_View, _Fn, _Np>> { | ||
| 84 | private: | ||
| 85 | _LIBCPP_NO_UNIQUE_ADDRESS adjacent_view<_View, _Np> __inner_; | ||
| 86 | _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Fn> __fun_; | ||
| 87 | |||
| 88 | using _InnerView _LIBCPP_NODEBUG = adjacent_view<_View, _Np>; | ||
| 89 | |||
| 90 | template <bool _Const> | ||
| 91 | using __inner_iterator _LIBCPP_NODEBUG = iterator_t<__maybe_const<_Const, _InnerView>>; | ||
| 92 | |||
| 93 | template <bool _Const> | ||
| 94 | using __inner_sentinel _LIBCPP_NODEBUG = sentinel_t<__maybe_const<_Const, _InnerView>>; | ||
| 95 | |||
| 96 | template <bool> | ||
| 97 | class __iterator; | ||
| 98 | |||
| 99 | template <bool> | ||
| 100 | class __sentinel; | ||
| 101 | |||
| 102 | public: | ||
| 103 | _LIBCPP_HIDE_FROM_ABI adjacent_transform_view() = default; | ||
| 104 | |||
| 105 | _LIBCPP_HIDE_FROM_ABI constexpr explicit adjacent_transform_view(_View __base, _Fn __fun) | ||
| 106 | : __inner_(std::move(__base)), __fun_(std::in_place, std::move(__fun)) {} | ||
| 107 | |||
| 108 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | ||
| 109 | requires copy_constructible<_View> | ||
| 110 | { | ||
| 111 | return __inner_.base(); | ||
| 112 | } | ||
| 113 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__inner_).base(); } | ||
| 114 | |||
| 115 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { return __iterator<false>(*this, __inner_.begin()); } | ||
| 116 | |||
| 117 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | ||
| 118 | requires range<const _InnerView> && regular_invocable<__apply_n<const _Fn&, _Np>, range_reference_t<const _View>> | ||
| 119 | { | ||
| 120 | return __iterator<true>(*this, __inner_.begin()); | ||
| 121 | } | ||
| 122 | |||
| 123 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() { | ||
| 124 | if constexpr (common_range<_InnerView>) { | ||
| 125 | return __iterator<false>(*this, __inner_.end()); | ||
| 126 | } else { | ||
| 127 | return __sentinel<false>(__inner_.end()); | ||
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | ||
| 132 | requires range<const _InnerView> && regular_invocable<__apply_n<const _Fn&, _Np>, range_reference_t<const _View>> | ||
| 133 | { | ||
| 134 | if constexpr (common_range<const _InnerView>) { | ||
| 135 | return __iterator<true>(*this, __inner_.end()); | ||
| 136 | } else { | ||
| 137 | return __sentinel<true>(__inner_.end()); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | ||
| 142 | requires sized_range<_InnerView> | ||
| 143 | { | ||
| 144 | return __inner_.size(); | ||
| 145 | } | ||
| 146 | |||
| 147 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | ||
| 148 | requires sized_range<const _InnerView> | ||
| 149 | { | ||
| 150 | return __inner_.size(); | ||
| 151 | } | ||
| 152 | }; | ||
| 153 | |||
| 154 | template <forward_range _View, move_constructible _Fn, size_t _Np> | ||
| 155 | requires view<_View> && (_Np > 0) && is_object_v<_Fn> && | ||
| 156 | regular_invocable<__apply_n<_Fn&, _Np>, range_reference_t<_View>> && | ||
| 157 | __referenceable<invoke_result_t<__apply_n<_Fn&, _Np>, range_reference_t<_View>>> | ||
| 158 | template <bool _Const> | ||
| 159 | class adjacent_transform_view<_View, _Fn, _Np>::__iterator { | ||
| 160 | friend adjacent_transform_view; | ||
| 161 | |||
| 162 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, adjacent_transform_view>; | ||
| 163 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | ||
| 164 | |||
| 165 | _Parent* __parent_ = nullptr; | ||
| 166 | __inner_iterator<_Const> __inner_; | ||
| 167 | |||
| 168 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(_Parent& __parent, __inner_iterator<_Const> __inner) | ||
| 169 | : __parent_(std::addressof(__parent)), __inner_(std::move(__inner)) {} | ||
| 170 | |||
| 171 | static consteval auto __get_iterator_category() { | ||
| 172 | using _Cat = iterator_traits<iterator_t<_Base>>::iterator_category; | ||
| 173 | if constexpr (!is_reference_v< | ||
| 174 | invoke_result_t<__apply_n<__maybe_const<_Const, _Fn>&, _Np>, range_reference_t<_Base>>>) | ||
| 175 | return input_iterator_tag{}; | ||
| 176 | else if constexpr (derived_from<_Cat, random_access_iterator_tag>) | ||
| 177 | return random_access_iterator_tag{}; | ||
| 178 | else if constexpr (derived_from<_Cat, bidirectional_iterator_tag>) | ||
| 179 | return bidirectional_iterator_tag{}; | ||
| 180 | else if constexpr (derived_from<_Cat, forward_iterator_tag>) | ||
| 181 | return forward_iterator_tag{}; | ||
| 182 | else | ||
| 183 | return input_iterator_tag{}; | ||
| 184 | } | ||
| 185 | |||
| 186 | template <size_t... _Is> | ||
| 187 | static consteval bool __noexcept_dereference(index_sequence<_Is...>) { | ||
| 188 | return noexcept(std::invoke( | ||
| 189 | std::declval<__maybe_const<_Const, _Fn>&>(), ((void)_Is, *std::declval<iterator_t<_Base> const&>())...)); | ||
| 190 | } | ||
| 191 | |||
| 192 | public: | ||
| 193 | using iterator_category = decltype(__get_iterator_category()); | ||
| 194 | using iterator_concept = typename __inner_iterator<_Const>::iterator_concept; | ||
| 195 | using value_type = | ||
| 196 | remove_cvref_t<invoke_result_t<__apply_n<__maybe_const<_Const, _Fn>&, _Np>, range_reference_t<_Base>>>; | ||
| 197 | using difference_type = range_difference_t<_Base>; | ||
| 198 | |||
| 199 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | ||
| 200 | |||
| 201 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i) | ||
| 202 | requires _Const && convertible_to<__inner_iterator<false>, __inner_iterator<true>> | ||
| 203 | : __parent_(__i.__parent_), __inner_(std::move(__i.__inner_)) {} | ||
| 204 | |||
| 205 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const | ||
| 206 | noexcept(__noexcept_dereference(make_index_sequence<_Np>{})) { | ||
| 207 | return std::apply( | ||
| 208 | [&](const auto&... __iters) -> decltype(auto) { return std::invoke(*__parent_->__fun_, *__iters...); }, | ||
| 209 | __adjacent_view_iter_access::__get_current(__inner_)); | ||
| 210 | } | ||
| 211 | |||
| 212 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { | ||
| 213 | ++__inner_; | ||
| 214 | return *this; | ||
| 215 | } | ||
| 216 | |||
| 217 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) { | ||
| 218 | auto __tmp = *this; | ||
| 219 | ++*this; | ||
| 220 | return __tmp; | ||
| 221 | } | ||
| 222 | |||
| 223 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() | ||
| 224 | requires bidirectional_range<_Base> | ||
| 225 | { | ||
| 226 | --__inner_; | ||
| 227 | return *this; | ||
| 228 | } | ||
| 229 | |||
| 230 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int) | ||
| 231 | requires bidirectional_range<_Base> | ||
| 232 | { | ||
| 233 | auto __tmp = *this; | ||
| 234 | --*this; | ||
| 235 | return __tmp; | ||
| 236 | } | ||
| 237 | |||
| 238 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __x) | ||
| 239 | requires random_access_range<_Base> | ||
| 240 | { | ||
| 241 | __inner_ += __x; | ||
| 242 | return *this; | ||
| 243 | } | ||
| 244 | |||
| 245 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __x) | ||
| 246 | requires random_access_range<_Base> | ||
| 247 | { | ||
| 248 | __inner_ -= __x; | ||
| 249 | return *this; | ||
| 250 | } | ||
| 251 | |||
| 252 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const | ||
| 253 | requires random_access_range<_Base> | ||
| 254 | { | ||
| 255 | return std::apply( | ||
| 256 | [&](const auto&... __iters) -> decltype(auto) { return std::invoke(*__parent_->__fun_, __iters[__n]...); }, | ||
| 257 | __adjacent_view_iter_access::__get_current(__inner_)); | ||
| 258 | } | ||
| 259 | |||
| 260 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) { | ||
| 261 | return __x.__inner_ == __y.__inner_; | ||
| 262 | } | ||
| 263 | |||
| 264 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __iterator& __x, const __iterator& __y) | ||
| 265 | requires random_access_range<_Base> | ||
| 266 | { | ||
| 267 | return __x.__inner_ < __y.__inner_; | ||
| 268 | } | ||
| 269 | |||
| 270 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __iterator& __x, const __iterator& __y) | ||
| 271 | requires random_access_range<_Base> | ||
| 272 | { | ||
| 273 | return __x.__inner_ > __y.__inner_; | ||
| 274 | } | ||
| 275 | |||
| 276 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y) | ||
| 277 | requires random_access_range<_Base> | ||
| 278 | { | ||
| 279 | return __x.__inner_ <= __y.__inner_; | ||
| 280 | } | ||
| 281 | |||
| 282 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y) | ||
| 283 | requires random_access_range<_Base> | ||
| 284 | { | ||
| 285 | return __x.__inner_ >= __y.__inner_; | ||
| 286 | } | ||
| 287 | |||
| 288 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) | ||
| 289 | requires random_access_range<_Base> && three_way_comparable<__inner_iterator<_Const>> | ||
| 290 | { | ||
| 291 | return __x.__inner_ <=> __y.__inner_; | ||
| 292 | } | ||
| 293 | |||
| 294 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n) | ||
| 295 | requires random_access_range<_Base> | ||
| 296 | { | ||
| 297 | return __iterator(*__i.__parent_, __i.__inner_ + __n); | ||
| 298 | } | ||
| 299 | |||
| 300 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i) | ||
| 301 | requires random_access_range<_Base> | ||
| 302 | { | ||
| 303 | return __iterator(*__i.__parent_, __i.__inner_ + __n); | ||
| 304 | } | ||
| 305 | |||
| 306 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n) | ||
| 307 | requires random_access_range<_Base> | ||
| 308 | { | ||
| 309 | return __iterator(*__i.__parent_, __i.__inner_ - __n); | ||
| 310 | } | ||
| 311 | |||
| 312 | _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) | ||
| 313 | requires sized_sentinel_for<__inner_iterator<_Const>, __inner_iterator<_Const>> | ||
| 314 | { | ||
| 315 | return __x.__inner_ - __y.__inner_; | ||
| 316 | } | ||
| 317 | }; | ||
| 318 | |||
| 319 | template <forward_range _View, move_constructible _Fn, size_t _Np> | ||
| 320 | requires view<_View> && (_Np > 0) && is_object_v<_Fn> && | ||
| 321 | regular_invocable<__apply_n<_Fn&, _Np>, range_reference_t<_View>> && | ||
| 322 | __referenceable<invoke_result_t<__apply_n<_Fn&, _Np>, range_reference_t<_View>>> | ||
| 323 | template <bool _Const> | ||
| 324 | class adjacent_transform_view<_View, _Fn, _Np>::__sentinel { | ||
| 325 | friend adjacent_transform_view; | ||
| 326 | |||
| 327 | __inner_sentinel<_Const> __inner_; | ||
| 328 | |||
| 329 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(__inner_sentinel<_Const> __inner) | ||
| 330 | : __inner_(std::move(__inner)) {} | ||
| 331 | |||
| 332 | public: | ||
| 333 | _LIBCPP_HIDE_FROM_ABI __sentinel() = default; | ||
| 334 | |||
| 335 | _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __i) | ||
| 336 | requires _Const && convertible_to<__inner_sentinel<false>, __inner_sentinel<_Const>> | ||
| 337 | : __inner_(std::move(__i.__inner_)) {} | ||
| 338 | |||
| 339 | template <bool _OtherConst> | ||
| 340 | requires sentinel_for<__inner_sentinel<_Const>, __inner_iterator<_OtherConst>> | ||
| 341 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | ||
| 342 | return __x.__inner_ == __y.__inner_; | ||
| 343 | } | ||
| 344 | |||
| 345 | template <bool _OtherConst> | ||
| 346 | requires sized_sentinel_for<__inner_sentinel<_Const>, __inner_iterator<_OtherConst>> | ||
| 347 | _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>> | ||
| 348 | operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | ||
| 349 | return __x.__inner_ - __y.__inner_; | ||
| 350 | } | ||
| 351 | |||
| 352 | template <bool _OtherConst> | ||
| 353 | requires sized_sentinel_for<__inner_sentinel<_Const>, __inner_iterator<_OtherConst>> | ||
| 354 | _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>> | ||
| 355 | operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) { | ||
| 356 | return __x.__inner_ - __y.__inner_; | ||
| 357 | } | ||
| 358 | }; | ||
| 359 | |||
| 360 | namespace views { | ||
| 361 | namespace __adjacent_transform { | ||
| 362 | |||
| 363 | template <size_t _Np> | ||
| 364 | struct __fn : __range_adaptor_closure<__fn<_Np>> { | ||
| 365 | template <class _Range, class _Fn> | ||
| 366 | requires(_Np == 0 && forward_range<_Range &&>) | ||
| 367 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | ||
| 368 | operator()(_Range&&, _Fn&& __fn) noexcept(noexcept(views::zip_transform(std::forward<_Fn>(__fn)))) | ||
| 369 | -> decltype(views::zip_transform(std::forward<_Fn>(__fn))) { | ||
| 370 | return views::zip_transform(std::forward<_Fn>(__fn)); | ||
| 371 | } | ||
| 372 | |||
| 373 | template <class _Range, class _Fn> | ||
| 374 | _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range, _Fn&& __fn) noexcept( | ||
| 375 | noexcept(adjacent_transform_view<views::all_t<_Range&&>, decay_t<_Fn>, _Np>( | ||
| 376 | std::forward<_Range>(__range), std::forward<_Fn>(__fn)))) | ||
| 377 | -> decltype(adjacent_transform_view<views::all_t<_Range&&>, decay_t<_Fn>, _Np>( | ||
| 378 | std::forward<_Range>(__range), std::forward<_Fn>(__fn))) { | ||
| 379 | return adjacent_transform_view<views::all_t<_Range&&>, decay_t<_Fn>, _Np>( | ||
| 380 | std::forward<_Range>(__range), std::forward<_Fn>(__fn)); | ||
| 381 | } | ||
| 382 | |||
| 383 | template <class _Fn> | ||
| 384 | requires constructible_from<decay_t<_Fn>, _Fn> | ||
| 385 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f) const | ||
| 386 | noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) { | ||
| 387 | return __pipeable(std::__bind_back(*this, std::forward<_Fn>(__f))); | ||
| 388 | } | ||
| 389 | }; | ||
| 390 | |||
| 391 | } // namespace __adjacent_transform | ||
| 392 | inline namespace __cpo { | ||
| 393 | template <size_t _Np> | ||
| 394 | inline constexpr auto adjacent_transform = __adjacent_transform::__fn<_Np>{}; | ||
| 395 | inline constexpr auto pairwise_transform = adjacent_transform<2>; | ||
| 396 | } // namespace __cpo | ||
| 397 | } // namespace views | ||
| 398 | } // namespace ranges | ||
| 399 | |||
| 400 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 401 | |||
| 402 | _LIBCPP_END_NAMESPACE_STD | ||
| 403 | |||
| 404 | _LIBCPP_POP_MACROS | ||
| 405 | |||
| 406 | #endif // _LIBCPP___RANGES_ADJACENT_TRANSFORM_VIEW_H | ||
lib/libcxx/include/__ranges/adjacent_view.h created+419| ... | @@ -0,0 +1,419 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___RANGES_ADJACENT_VIEW_H | ||
| 11 | #define _LIBCPP___RANGES_ADJACENT_VIEW_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #include <__algorithm/min.h> | ||
| 16 | #include <__compare/three_way_comparable.h> | ||
| 17 | #include <__concepts/constructible.h> | ||
| 18 | #include <__concepts/convertible_to.h> | ||
| 19 | #include <__concepts/equality_comparable.h> | ||
| 20 | #include <__cstddef/size_t.h> | ||
| 21 | #include <__functional/invoke.h> | ||
| 22 | #include <__functional/operations.h> | ||
| 23 | #include <__iterator/concepts.h> | ||
| 24 | #include <__iterator/incrementable_traits.h> | ||
| 25 | #include <__iterator/iter_move.h> | ||
| 26 | #include <__iterator/iter_swap.h> | ||
| 27 | #include <__iterator/iterator_traits.h> | ||
| 28 | #include <__iterator/next.h> | ||
| 29 | #include <__iterator/prev.h> | ||
| 30 | #include <__ranges/access.h> | ||
| 31 | #include <__ranges/all.h> | ||
| 32 | #include <__ranges/concepts.h> | ||
| 33 | #include <__ranges/empty_view.h> | ||
| 34 | #include <__ranges/enable_borrowed_range.h> | ||
| 35 | #include <__ranges/range_adaptor.h> | ||
| 36 | #include <__ranges/size.h> | ||
| 37 | #include <__ranges/view_interface.h> | ||
| 38 | #include <__tuple/tuple_transform.h> | ||
| 39 | #include <__type_traits/common_type.h> | ||
| 40 | #include <__type_traits/is_nothrow_constructible.h> | ||
| 41 | #include <__type_traits/make_unsigned.h> | ||
| 42 | #include <__type_traits/maybe_const.h> | ||
| 43 | #include <__utility/declval.h> | ||
| 44 | #include <__utility/forward.h> | ||
| 45 | #include <__utility/integer_sequence.h> | ||
| 46 | #include <__utility/move.h> | ||
| 47 | #include <array> | ||
| 48 | #include <tuple> | ||
| 49 | |||
| 50 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 51 | # pragma GCC system_header | ||
| 52 | #endif | ||
| 53 | |||
| 54 | _LIBCPP_PUSH_MACROS | ||
| 55 | #include <__undef_macros> | ||
| 56 | |||
| 57 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 58 | |||
| 59 | #if _LIBCPP_STD_VER >= 23 | ||
| 60 | |||
| 61 | namespace ranges { | ||
| 62 | |||
| 63 | template <forward_range _View, size_t _Np> | ||
| 64 | requires view<_View> && (_Np > 0) | ||
| 65 | class adjacent_view : public view_interface<adjacent_view<_View, _Np>> { | ||
| 66 | private: | ||
| 67 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | ||
| 68 | |||
| 69 | template <bool> | ||
| 70 | class __iterator; | ||
| 71 | |||
| 72 | template <bool> | ||
| 73 | class __sentinel; | ||
| 74 | |||
| 75 | struct __as_sentinel {}; | ||
| 76 | |||
| 77 | public: | ||
| 78 | _LIBCPP_HIDE_FROM_ABI adjacent_view() | ||
| 79 | requires default_initializable<_View> | ||
| 80 | = default; | ||
| 81 | |||
| 82 | _LIBCPP_HIDE_FROM_ABI constexpr explicit adjacent_view(_View __base) : __base_(std::move(__base)) {} | ||
| 83 | |||
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | ||
| 85 | requires copy_constructible<_View> | ||
| 86 | { | ||
| 87 | return __base_; | ||
| 88 | } | ||
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | ||
| 90 | |||
| 91 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() | ||
| 92 | requires(!__simple_view<_View>) | ||
| 93 | { | ||
| 94 | return __iterator<false>(ranges::begin(__base_), ranges::end(__base_)); | ||
| 95 | } | ||
| 96 | |||
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | ||
| 98 | requires range<const _View> // LWG4482 This is under-constrained. | ||
| 99 | { | ||
| 100 | return __iterator<true>(ranges::begin(__base_), ranges::end(__base_)); | ||
| 101 | } | ||
| 102 | |||
| 103 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() | ||
| 104 | requires(!__simple_view<_View>) | ||
| 105 | { | ||
| 106 | if constexpr (common_range<_View>) { | ||
| 107 | return __iterator<false>(__as_sentinel{}, ranges::begin(__base_), ranges::end(__base_)); | ||
| 108 | } else { | ||
| 109 | return __sentinel<false>(ranges::end(__base_)); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | ||
| 114 | requires range<const _View> // LWG4482 This is under-constrained. | ||
| 115 | { | ||
| 116 | if constexpr (common_range<const _View>) { | ||
| 117 | return __iterator<true>(__as_sentinel{}, ranges::begin(__base_), ranges::end(__base_)); | ||
| 118 | } else { | ||
| 119 | return __sentinel<true>(ranges::end(__base_)); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | ||
| 124 | requires sized_range<_View> | ||
| 125 | { | ||
| 126 | using _ST = decltype(ranges::size(__base_)); | ||
| 127 | using _CT = common_type_t<_ST, size_t>; | ||
| 128 | auto __sz = static_cast<_CT>(ranges::size(__base_)); | ||
| 129 | __sz -= std::min<_CT>(__sz, _Np - 1); | ||
| 130 | return static_cast<_ST>(__sz); | ||
| 131 | } | ||
| 132 | |||
| 133 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | ||
| 134 | requires sized_range<const _View> | ||
| 135 | { | ||
| 136 | using _ST = decltype(ranges::size(__base_)); | ||
| 137 | using _CT = common_type_t<_ST, size_t>; | ||
| 138 | auto __sz = static_cast<_CT>(ranges::size(__base_)); | ||
| 139 | __sz -= std::min<_CT>(__sz, _Np - 1); | ||
| 140 | return static_cast<_ST>(__sz); | ||
| 141 | } | ||
| 142 | }; | ||
| 143 | |||
| 144 | struct __adjacent_view_iter_access { | ||
| 145 | template <class _Iter> | ||
| 146 | _LIBCPP_HIDE_FROM_ABI constexpr static auto& __get_current(_Iter& __it) noexcept { | ||
| 147 | return __it.__current_; | ||
| 148 | } | ||
| 149 | }; | ||
| 150 | |||
| 151 | template <forward_range _View, size_t _Np> | ||
| 152 | requires view<_View> && (_Np > 0) | ||
| 153 | template <bool _Const> | ||
| 154 | class adjacent_view<_View, _Np>::__iterator { | ||
| 155 | friend __adjacent_view_iter_access; | ||
| 156 | friend adjacent_view; | ||
| 157 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | ||
| 158 | array<iterator_t<_Base>, _Np> __current_ = array<iterator_t<_Base>, _Np>(); | ||
| 159 | |||
| 160 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(iterator_t<_Base> __first, sentinel_t<_Base> __last) { | ||
| 161 | __current_[0] = __first; | ||
| 162 | for (size_t __i = 1; __i < _Np; ++__i) { | ||
| 163 | __current_[__i] = ranges::next(__current_[__i - 1], 1, __last); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__as_sentinel, iterator_t<_Base> __first, iterator_t<_Base> __last) { | ||
| 168 | if constexpr (!bidirectional_range<_Base>) { | ||
| 169 | __current_.fill(__last); | ||
| 170 | } else { | ||
| 171 | __current_[_Np - 1] = __last; | ||
| 172 | for (int __i = static_cast<int>(_Np) - 2; __i >= 0; --__i) { | ||
| 173 | __current_[__i] = ranges::prev(__current_[__i + 1], 1, __first); | ||
| 174 | } | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | template <class _Iter, size_t... _Is> | ||
| 179 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __iterator(_Iter&& __i, index_sequence<_Is...>) | ||
| 180 | : __current_{std::move(__i.__current_[_Is])...} {} | ||
| 181 | |||
| 182 | static consteval auto __get_iterator_concept() { | ||
| 183 | if constexpr (random_access_range<_Base>) | ||
| 184 | return random_access_iterator_tag{}; | ||
| 185 | else if constexpr (bidirectional_range<_Base>) | ||
| 186 | return bidirectional_iterator_tag{}; | ||
| 187 | else | ||
| 188 | return forward_iterator_tag{}; | ||
| 189 | } | ||
| 190 | |||
| 191 | template <class _Tp, size_t _Index> | ||
| 192 | using __always _LIBCPP_NODEBUG = _Tp; | ||
| 193 | |||
| 194 | template <class _Tp, size_t... _Is> | ||
| 195 | static auto __repeat_tuple_helper(index_sequence<_Is...>) -> tuple<__always<_Tp, _Is>...>; | ||
| 196 | |||
| 197 | public: | ||
| 198 | using iterator_category = input_iterator_tag; | ||
| 199 | using iterator_concept = decltype(__get_iterator_concept()); | ||
| 200 | using value_type = decltype(__repeat_tuple_helper<range_value_t<_Base>>(make_index_sequence<_Np>{})); | ||
| 201 | using difference_type = range_difference_t<_Base>; | ||
| 202 | |||
| 203 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | ||
| 204 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i) | ||
| 205 | requires _Const && convertible_to<iterator_t<_View>, iterator_t<const _View>> | ||
| 206 | : __iterator(std::move(__i), make_index_sequence<_Np>{}) {} | ||
| 207 | |||
| 208 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const { | ||
| 209 | return std::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_); | ||
| 210 | } | ||
| 211 | |||
| 212 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { | ||
| 213 | for (auto& __i : __current_) { | ||
| 214 | ++__i; | ||
| 215 | } | ||
| 216 | return *this; | ||
| 217 | } | ||
| 218 | |||
| 219 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) { | ||
| 220 | auto __tmp = *this; | ||
| 221 | ++*this; | ||
| 222 | return __tmp; | ||
| 223 | } | ||
| 224 | |||
| 225 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() | ||
| 226 | requires bidirectional_range<_Base> | ||
| 227 | { | ||
| 228 | for (auto& __i : __current_) { | ||
| 229 | --__i; | ||
| 230 | } | ||
| 231 | return *this; | ||
| 232 | } | ||
| 233 | |||
| 234 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int) | ||
| 235 | requires bidirectional_range<_Base> | ||
| 236 | { | ||
| 237 | auto __tmp = *this; | ||
| 238 | --*this; | ||
| 239 | return __tmp; | ||
| 240 | } | ||
| 241 | |||
| 242 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __x) | ||
| 243 | requires random_access_range<_Base> | ||
| 244 | { | ||
| 245 | for (auto& __i : __current_) { | ||
| 246 | __i += __x; | ||
| 247 | } | ||
| 248 | return *this; | ||
| 249 | } | ||
| 250 | |||
| 251 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __x) | ||
| 252 | requires random_access_range<_Base> | ||
| 253 | { | ||
| 254 | for (auto& __i : __current_) { | ||
| 255 | __i -= __x; | ||
| 256 | } | ||
| 257 | return *this; | ||
| 258 | } | ||
| 259 | |||
| 260 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const | ||
| 261 | requires random_access_range<_Base> | ||
| 262 | { | ||
| 263 | return std::__tuple_transform([&](auto& __i) -> decltype(auto) { return __i[__n]; }, __current_); | ||
| 264 | } | ||
| 265 | |||
| 266 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) { | ||
| 267 | return __x.__current_.back() == __y.__current_.back(); | ||
| 268 | } | ||
| 269 | |||
| 270 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __iterator& __x, const __iterator& __y) | ||
| 271 | requires random_access_range<_Base> | ||
| 272 | { | ||
| 273 | return __x.__current_.back() < __y.__current_.back(); | ||
| 274 | } | ||
| 275 | |||
| 276 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __iterator& __x, const __iterator& __y) | ||
| 277 | requires random_access_range<_Base> | ||
| 278 | { | ||
| 279 | return __y < __x; | ||
| 280 | } | ||
| 281 | |||
| 282 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y) | ||
| 283 | requires random_access_range<_Base> | ||
| 284 | { | ||
| 285 | return !(__y < __x); | ||
| 286 | } | ||
| 287 | |||
| 288 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y) | ||
| 289 | requires random_access_range<_Base> | ||
| 290 | { | ||
| 291 | return !(__x < __y); | ||
| 292 | } | ||
| 293 | |||
| 294 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) | ||
| 295 | requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>> | ||
| 296 | { | ||
| 297 | return __x.__current_.back() <=> __y.__current_.back(); | ||
| 298 | } | ||
| 299 | |||
| 300 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n) | ||
| 301 | requires random_access_range<_Base> | ||
| 302 | { | ||
| 303 | auto __r = __i; | ||
| 304 | __r += __n; | ||
| 305 | return __r; | ||
| 306 | } | ||
| 307 | |||
| 308 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i) | ||
| 309 | requires random_access_range<_Base> | ||
| 310 | { | ||
| 311 | return __i + __n; | ||
| 312 | } | ||
| 313 | |||
| 314 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n) | ||
| 315 | requires random_access_range<_Base> | ||
| 316 | { | ||
| 317 | auto __r = __i; | ||
| 318 | __r -= __n; | ||
| 319 | return __r; | ||
| 320 | } | ||
| 321 | |||
| 322 | _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) | ||
| 323 | requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>> | ||
| 324 | { | ||
| 325 | return __x.__current_.back() - __y.__current_.back(); | ||
| 326 | } | ||
| 327 | |||
| 328 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept( | ||
| 329 | noexcept(ranges::iter_move(std::declval<const iterator_t<_Base>&>())) && | ||
| 330 | is_nothrow_move_constructible_v<range_rvalue_reference_t<_Base>>) { | ||
| 331 | return std::__tuple_transform(ranges::iter_move, __i.__current_); | ||
| 332 | } | ||
| 333 | |||
| 334 | _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept( | ||
| 335 | noexcept(ranges::iter_swap(std::declval<iterator_t<_Base>>(), std::declval<iterator_t<_Base>>()))) | ||
| 336 | requires indirectly_swappable<iterator_t<_Base>> | ||
| 337 | { | ||
| 338 | for (size_t __i = 0; __i < _Np; ++__i) { | ||
| 339 | ranges::iter_swap(__l.__current_[__i], __r.__current_[__i]); | ||
| 340 | } | ||
| 341 | } | ||
| 342 | }; | ||
| 343 | |||
| 344 | template <forward_range _View, size_t _Np> | ||
| 345 | requires view<_View> && (_Np > 0) | ||
| 346 | template <bool _Const> | ||
| 347 | class adjacent_view<_View, _Np>::__sentinel { | ||
| 348 | friend adjacent_view; | ||
| 349 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | ||
| 350 | sentinel_t<_Base> __end_ = sentinel_t<_Base>(); | ||
| 351 | |||
| 352 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(sentinel_t<_Base> __end) { __end_ = std::move(__end); } | ||
| 353 | |||
| 354 | public: | ||
| 355 | _LIBCPP_HIDE_FROM_ABI __sentinel() = default; | ||
| 356 | |||
| 357 | _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __i) | ||
| 358 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> | ||
| 359 | : __end_(std::move(__i.__end_)) {} | ||
| 360 | |||
| 361 | template <bool _OtherConst> | ||
| 362 | requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> | ||
| 363 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | ||
| 364 | return __x.__current_.back() == __y.__end_; | ||
| 365 | } | ||
| 366 | |||
| 367 | template <bool _OtherConst> | ||
| 368 | requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> | ||
| 369 | _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>> | ||
| 370 | operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | ||
| 371 | return __x.__current_.back() - __y.__end_; | ||
| 372 | } | ||
| 373 | |||
| 374 | template <bool _OtherConst> | ||
| 375 | requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> | ||
| 376 | _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>> | ||
| 377 | operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) { | ||
| 378 | return __y.__end_ - __x.__current_.back(); | ||
| 379 | } | ||
| 380 | }; | ||
| 381 | |||
| 382 | template <class _View, size_t _Np> | ||
| 383 | constexpr bool enable_borrowed_range<adjacent_view<_View, _Np>> = enable_borrowed_range<_View>; | ||
| 384 | |||
| 385 | namespace views { | ||
| 386 | namespace __adjacent { | ||
| 387 | |||
| 388 | template <size_t _Np> | ||
| 389 | struct __fn : __range_adaptor_closure<__fn<_Np>> { | ||
| 390 | template <class _Range> | ||
| 391 | requires(_Np == 0 && forward_range<_Range &&>) | ||
| 392 | _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&&) noexcept { | ||
| 393 | return empty_view<tuple<>>{}; | ||
| 394 | } | ||
| 395 | |||
| 396 | template <class _Ranges> | ||
| 397 | _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ranges&& __range) noexcept( | ||
| 398 | noexcept(adjacent_view<views::all_t<_Ranges&&>, _Np>(std::forward<_Ranges>(__range)))) | ||
| 399 | -> decltype(adjacent_view<views::all_t<_Ranges&&>, _Np>(std::forward<_Ranges>(__range))) { | ||
| 400 | return adjacent_view<views::all_t<_Ranges&&>, _Np>(std::forward<_Ranges>(__range)); | ||
| 401 | } | ||
| 402 | }; | ||
| 403 | |||
| 404 | } // namespace __adjacent | ||
| 405 | inline namespace __cpo { | ||
| 406 | template <size_t _Np> | ||
| 407 | inline constexpr auto adjacent = __adjacent::__fn<_Np>{}; | ||
| 408 | inline constexpr auto pairwise = adjacent<2>; | ||
| 409 | } // namespace __cpo | ||
| 410 | } // namespace views | ||
| 411 | } // namespace ranges | ||
| 412 | |||
| 413 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 414 | |||
| 415 | _LIBCPP_END_NAMESPACE_STD | ||
| 416 | |||
| 417 | _LIBCPP_POP_MACROS | ||
| 418 | |||
| 419 | #endif // _LIBCPP___RANGES_ADJACENT_VIEW_H | ||
lib/libcxx/include/__ranges/as_rvalue_view.h+9-9| ... | @@ -48,27 +48,27 @@ public: | ... | @@ -48,27 +48,27 @@ public: |
| 48 | 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr explicit as_rvalue_view(_View __base) : __base_(std::move(__base)) {} | 49 | _LIBCPP_HIDE_FROM_ABI constexpr explicit as_rvalue_view(_View __base) : __base_(std::move(__base)) {} |
| 50 | 50 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | 51 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& |
| 52 | requires copy_constructible<_View> | 52 | requires copy_constructible<_View> |
| 53 | { | 53 | { |
| 54 | return __base_; | 54 | return __base_; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | 57 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } |
| 58 | 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() |
| 60 | requires(!__simple_view<_View>) | 60 | requires(!__simple_view<_View>) |
| 61 | { | 61 | { |
| 62 | return move_iterator(ranges::begin(__base_)); | 62 | return move_iterator(ranges::begin(__base_)); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const |
| 66 | requires range<const _View> | 66 | requires range<const _View> |
| 67 | { | 67 | { |
| 68 | return move_iterator(ranges::begin(__base_)); | 68 | return move_iterator(ranges::begin(__base_)); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() | 71 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() |
| 72 | requires(!__simple_view<_View>) | 72 | requires(!__simple_view<_View>) |
| 73 | { | 73 | { |
| 74 | if constexpr (common_range<_View>) { | 74 | if constexpr (common_range<_View>) { |
| ... | @@ -78,7 +78,7 @@ public: | ... | @@ -78,7 +78,7 @@ public: |
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const |
| 82 | requires range<const _View> | 82 | requires range<const _View> |
| 83 | { | 83 | { |
| 84 | if constexpr (common_range<const _View>) { | 84 | if constexpr (common_range<const _View>) { |
| ... | @@ -88,13 +88,13 @@ public: | ... | @@ -88,13 +88,13 @@ public: |
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | 91 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() |
| 92 | requires sized_range<_View> | 92 | requires sized_range<_View> |
| 93 | { | 93 | { |
| 94 | return ranges::size(__base_); | 94 | return ranges::size(__base_); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 98 | requires sized_range<const _View> | 98 | requires sized_range<const _View> |
| 99 | { | 99 | { |
| 100 | return ranges::size(__base_); | 100 | return ranges::size(__base_); |
| ... | @@ -117,7 +117,7 @@ struct __fn : __range_adaptor_closure<__fn> { | ... | @@ -117,7 +117,7 @@ struct __fn : __range_adaptor_closure<__fn> { |
| 117 | return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range)); | 117 | return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range)); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | template <class _Range> | 120 | template <input_range _Range> |
| 121 | requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>> | 121 | requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>> |
| 122 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto | 122 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto |
| 123 | operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range)))) | 123 | operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range)))) |
lib/libcxx/include/__ranges/chunk_by_view.h+6-6| ... | @@ -100,17 +100,17 @@ public: | ... | @@ -100,17 +100,17 @@ public: |
| 100 | _LIBCPP_HIDE_FROM_ABI constexpr explicit chunk_by_view(_View __base, _Pred __pred) | 100 | _LIBCPP_HIDE_FROM_ABI constexpr explicit chunk_by_view(_View __base, _Pred __pred) |
| 101 | : __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) {} | 101 | : __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) {} |
| 102 | 102 | ||
| 103 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | 103 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& |
| 104 | requires copy_constructible<_View> | 104 | requires copy_constructible<_View> |
| 105 | { | 105 | { |
| 106 | return __base_; | 106 | return __base_; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | 109 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } |
| 110 | 110 | ||
| 111 | _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; } | 111 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; } |
| 112 | 112 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() { | 113 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() { |
| 114 | // Note: this duplicates a check in `optional` but provides a better error message. | 114 | // Note: this duplicates a check in `optional` but provides a better error message. |
| 115 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 115 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 116 | __pred_.__has_value(), "Trying to call begin() on a chunk_by_view that does not have a valid predicate."); | 116 | __pred_.__has_value(), "Trying to call begin() on a chunk_by_view that does not have a valid predicate."); |
| ... | @@ -122,7 +122,7 @@ public: | ... | @@ -122,7 +122,7 @@ public: |
| 122 | return {*this, std::move(__first), *__cached_begin_}; | 122 | return {*this, std::move(__first), *__cached_begin_}; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() { | 125 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() { |
| 126 | if constexpr (common_range<_View>) { | 126 | if constexpr (common_range<_View>) { |
| 127 | return __iterator{*this, ranges::end(__base_), ranges::end(__base_)}; | 127 | return __iterator{*this, ranges::end(__base_), ranges::end(__base_)}; |
| 128 | } else { | 128 | } else { |
| ... | @@ -155,7 +155,7 @@ public: | ... | @@ -155,7 +155,7 @@ public: |
| 155 | 155 | ||
| 156 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | 156 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; |
| 157 | 157 | ||
| 158 | _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { | 158 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { |
| 159 | // If the iterator is at end, this would return an empty range which can be checked by the calling code and doesn't | 159 | // If the iterator is at end, this would return an empty range which can be checked by the calling code and doesn't |
| 160 | // necessarily lead to a bad access. | 160 | // necessarily lead to a bad access. |
| 161 | _LIBCPP_ASSERT_PEDANTIC(__current_ != __next_, "Trying to dereference past-the-end chunk_by_view iterator."); | 161 | _LIBCPP_ASSERT_PEDANTIC(__current_ != __next_, "Trying to dereference past-the-end chunk_by_view iterator."); |
lib/libcxx/include/__ranges/common_view.h+7-7| ... | @@ -56,16 +56,16 @@ public: | ... | @@ -56,16 +56,16 @@ public: |
| 56 | return __base_; | 56 | return __base_; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } |
| 60 | 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { | 61 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { |
| 62 | if constexpr (random_access_range<_View> && sized_range<_View>) | 62 | if constexpr (random_access_range<_View> && sized_range<_View>) |
| 63 | return ranges::begin(__base_); | 63 | return ranges::begin(__base_); |
| 64 | else | 64 | else |
| 65 | return common_iterator<iterator_t<_View>, sentinel_t<_View>>(ranges::begin(__base_)); | 65 | return common_iterator<iterator_t<_View>, sentinel_t<_View>>(ranges::begin(__base_)); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const |
| 69 | requires range<const _View> | 69 | requires range<const _View> |
| 70 | { | 70 | { |
| 71 | if constexpr (random_access_range<const _View> && sized_range<const _View>) | 71 | if constexpr (random_access_range<const _View> && sized_range<const _View>) |
| ... | @@ -74,14 +74,14 @@ public: | ... | @@ -74,14 +74,14 @@ public: |
| 74 | return common_iterator<iterator_t<const _View>, sentinel_t<const _View>>(ranges::begin(__base_)); | 74 | return common_iterator<iterator_t<const _View>, sentinel_t<const _View>>(ranges::begin(__base_)); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() { | 77 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() { |
| 78 | if constexpr (random_access_range<_View> && sized_range<_View>) | 78 | if constexpr (random_access_range<_View> && sized_range<_View>) |
| 79 | return ranges::begin(__base_) + ranges::size(__base_); | 79 | return ranges::begin(__base_) + ranges::size(__base_); |
| 80 | else | 80 | else |
| 81 | return common_iterator<iterator_t<_View>, sentinel_t<_View>>(ranges::end(__base_)); | 81 | return common_iterator<iterator_t<_View>, sentinel_t<_View>>(ranges::end(__base_)); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | 84 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const |
| 85 | requires range<const _View> | 85 | requires range<const _View> |
| 86 | { | 86 | { |
| 87 | if constexpr (random_access_range<const _View> && sized_range<const _View>) | 87 | if constexpr (random_access_range<const _View> && sized_range<const _View>) |
| ... | @@ -90,13 +90,13 @@ public: | ... | @@ -90,13 +90,13 @@ public: |
| 90 | return common_iterator<iterator_t<const _View>, sentinel_t<const _View>>(ranges::end(__base_)); | 90 | return common_iterator<iterator_t<const _View>, sentinel_t<const _View>>(ranges::end(__base_)); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | 93 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() |
| 94 | requires sized_range<_View> | 94 | requires sized_range<_View> |
| 95 | { | 95 | { |
| 96 | return ranges::size(__base_); | 96 | return ranges::size(__base_); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 99 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 100 | requires sized_range<const _View> | 100 | requires sized_range<const _View> |
| 101 | { | 101 | { |
| 102 | return ranges::size(__base_); | 102 | return ranges::size(__base_); |
lib/libcxx/include/__ranges/drop_view.h+8-8| ... | @@ -80,14 +80,14 @@ public: | ... | @@ -80,14 +80,14 @@ public: |
| 80 | _LIBCPP_ASSERT_UNCATEGORIZED(__count_ >= 0, "count must be greater than or equal to zero."); | 80 | _LIBCPP_ASSERT_UNCATEGORIZED(__count_ >= 0, "count must be greater than or equal to zero."); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | 83 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& |
| 84 | requires copy_constructible<_View> | 84 | requires copy_constructible<_View> |
| 85 | { | 85 | { |
| 86 | return __base_; | 86 | return __base_; |
| 87 | } | 87 | } |
| 88 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | 88 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } |
| 89 | 89 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() | 90 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() |
| 91 | requires(!(__simple_view<_View> && random_access_range<const _View> && sized_range<const _View>)) | 91 | requires(!(__simple_view<_View> && random_access_range<const _View> && sized_range<const _View>)) |
| 92 | { | 92 | { |
| 93 | if constexpr (random_access_range<_View> && sized_range<_View>) { | 93 | if constexpr (random_access_range<_View> && sized_range<_View>) { |
| ... | @@ -104,20 +104,20 @@ public: | ... | @@ -104,20 +104,20 @@ public: |
| 104 | return __tmp; | 104 | return __tmp; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | 107 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const |
| 108 | requires random_access_range<const _View> && sized_range<const _View> | 108 | requires random_access_range<const _View> && sized_range<const _View> |
| 109 | { | 109 | { |
| 110 | const auto __dist = std::min(ranges::distance(__base_), __count_); | 110 | const auto __dist = std::min(ranges::distance(__base_), __count_); |
| 111 | return ranges::begin(__base_) + __dist; | 111 | return ranges::begin(__base_) + __dist; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() | 114 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() |
| 115 | requires(!__simple_view<_View>) | 115 | requires(!__simple_view<_View>) |
| 116 | { | 116 | { |
| 117 | return ranges::end(__base_); | 117 | return ranges::end(__base_); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | 120 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const |
| 121 | requires range<const _View> | 121 | requires range<const _View> |
| 122 | { | 122 | { |
| 123 | return ranges::end(__base_); | 123 | return ranges::end(__base_); |
| ... | @@ -129,13 +129,13 @@ public: | ... | @@ -129,13 +129,13 @@ public: |
| 129 | return __s < __c ? 0 : __s - __c; | 129 | return __s < __c ? 0 : __s - __c; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | 132 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() |
| 133 | requires sized_range<_View> | 133 | requires sized_range<_View> |
| 134 | { | 134 | { |
| 135 | return __size(*this); | 135 | return __size(*this); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 138 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 139 | requires sized_range<const _View> | 139 | requires sized_range<const _View> |
| 140 | { | 140 | { |
| 141 | return __size(*this); | 141 | return __size(*this); |
lib/libcxx/include/__ranges/drop_while_view.h+5-5| ... | @@ -57,17 +57,17 @@ public: | ... | @@ -57,17 +57,17 @@ public: |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 drop_while_view(_View __base, _Pred __pred) | 57 | _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 drop_while_view(_View __base, _Pred __pred) |
| 58 | : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {} | 58 | : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {} |
| 59 | 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& |
| 61 | requires copy_constructible<_View> | 61 | requires copy_constructible<_View> |
| 62 | { | 62 | { |
| 63 | return __base_; | 63 | return __base_; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | 66 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } |
| 67 | 67 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; } | 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; } |
| 69 | 69 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { | 70 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { |
| 71 | // Note: this duplicates a check in `optional` but provides a better error message. | 71 | // Note: this duplicates a check in `optional` but provides a better error message. |
| 72 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 72 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 73 | __pred_.__has_value(), | 73 | __pred_.__has_value(), |
| ... | @@ -83,7 +83,7 @@ public: | ... | @@ -83,7 +83,7 @@ public: |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() { return ranges::end(__base_); } | 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() { return ranges::end(__base_); } |
| 87 | 87 | ||
| 88 | private: | 88 | private: |
| 89 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | 89 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); |
lib/libcxx/include/__ranges/elements_of.h created+49| ... | @@ -0,0 +1,49 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___RANGES_ELEMENTS_OF_H | ||
| 11 | #define _LIBCPP___RANGES_ELEMENTS_OF_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__cstddef/byte.h> | ||
| 15 | #include <__memory/allocator.h> | ||
| 16 | #include <__ranges/concepts.h> | ||
| 17 | #include <__utility/forward.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 | ||
| 27 | |||
| 28 | #if _LIBCPP_STD_VER >= 23 | ||
| 29 | |||
| 30 | namespace ranges { | ||
| 31 | |||
| 32 | template <range _Range, class _Allocator = allocator<byte>> | ||
| 33 | struct elements_of { | ||
| 34 | _LIBCPP_NO_UNIQUE_ADDRESS _Range range; | ||
| 35 | _LIBCPP_NO_UNIQUE_ADDRESS _Allocator allocator = _Allocator(); | ||
| 36 | }; | ||
| 37 | |||
| 38 | template <class _Range, class _Allocator = allocator<byte>> | ||
| 39 | elements_of(_Range&&, _Allocator = _Allocator()) -> elements_of<_Range&&, _Allocator>; | ||
| 40 | |||
| 41 | } // namespace ranges | ||
| 42 | |||
| 43 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 44 | |||
| 45 | _LIBCPP_END_NAMESPACE_STD | ||
| 46 | |||
| 47 | _LIBCPP_POP_MACROS | ||
| 48 | |||
| 49 | #endif // _LIBCPP___RANGES_ELEMENTS_OF_H | ||
lib/libcxx/include/__ranges/empty_view.h+5-5| ... | @@ -29,11 +29,11 @@ template <class _Tp> | ... | @@ -29,11 +29,11 @@ template <class _Tp> |
| 29 | requires is_object_v<_Tp> | 29 | requires is_object_v<_Tp> |
| 30 | class empty_view : public view_interface<empty_view<_Tp>> { | 30 | class empty_view : public view_interface<empty_view<_Tp>> { |
| 31 | public: | 31 | public: |
| 32 | _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* begin() noexcept { return nullptr; } | 32 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* begin() noexcept { return nullptr; } |
| 33 | _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* end() noexcept { return nullptr; } | 33 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* end() noexcept { return nullptr; } |
| 34 | _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* data() noexcept { return nullptr; } | 34 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* data() noexcept { return nullptr; } |
| 35 | _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 0; } | 35 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 0; } |
| 36 | _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return true; } | 36 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return true; } |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | template <class _Tp> | 39 | template <class _Tp> |
lib/libcxx/include/__ranges/filter_view.h+10-10| ... | @@ -76,16 +76,16 @@ public: | ... | @@ -76,16 +76,16 @@ public: |
| 76 | : __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) {} | 76 | : __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) {} |
| 77 | 77 | ||
| 78 | template <class _Vp = _View> | 78 | template <class _Vp = _View> |
| 79 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& |
| 80 | requires copy_constructible<_Vp> | 80 | requires copy_constructible<_Vp> |
| 81 | { | 81 | { |
| 82 | return __base_; | 82 | return __base_; |
| 83 | } | 83 | } |
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | 84 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } |
| 85 | 85 | ||
| 86 | _LIBCPP_HIDE_FROM_ABI constexpr _Pred const& pred() const { return *__pred_; } | 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Pred const& pred() const { return *__pred_; } |
| 87 | 87 | ||
| 88 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() { | 88 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() { |
| 89 | // Note: this duplicates a check in `optional` but provides a better error message. | 89 | // Note: this duplicates a check in `optional` but provides a better error message. |
| 90 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 90 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 91 | __pred_.__has_value(), "Trying to call begin() on a filter_view that does not have a valid predicate."); | 91 | __pred_.__has_value(), "Trying to call begin() on a filter_view that does not have a valid predicate."); |
| ... | @@ -99,7 +99,7 @@ public: | ... | @@ -99,7 +99,7 @@ public: |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() { | 102 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() { |
| 103 | if constexpr (common_range<_View>) | 103 | if constexpr (common_range<_View>) |
| 104 | return __iterator{*this, ranges::end(__base_)}; | 104 | return __iterator{*this, ranges::end(__base_)}; |
| 105 | else | 105 | else |
| ... | @@ -148,10 +148,10 @@ public: | ... | @@ -148,10 +148,10 @@ public: |
| 148 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(filter_view& __parent, iterator_t<_View> __current) | 148 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(filter_view& __parent, iterator_t<_View> __current) |
| 149 | : __current_(std::move(__current)), __parent_(std::addressof(__parent)) {} | 149 | : __current_(std::move(__current)), __parent_(std::addressof(__parent)) {} |
| 150 | 150 | ||
| 151 | _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> const& base() const& noexcept { return __current_; } | 151 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> const& base() const& noexcept { return __current_; } |
| 152 | _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> base() && { return std::move(__current_); } | 152 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> base() && { return std::move(__current_); } |
| 153 | 153 | ||
| 154 | _LIBCPP_HIDE_FROM_ABI constexpr range_reference_t<_View> operator*() const { return *__current_; } | 154 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_reference_t<_View> operator*() const { return *__current_; } |
| 155 | _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> operator->() const | 155 | _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> operator->() const |
| 156 | requires __has_arrow<iterator_t<_View>> && copyable<iterator_t<_View>> | 156 | requires __has_arrow<iterator_t<_View>> && copyable<iterator_t<_View>> |
| 157 | { | 157 | { |
| ... | @@ -194,7 +194,7 @@ public: | ... | @@ -194,7 +194,7 @@ public: |
| 194 | return __x.__current_ == __y.__current_; | 194 | return __x.__current_ == __y.__current_; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | _LIBCPP_HIDE_FROM_ABI friend constexpr range_rvalue_reference_t<_View> | 197 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_rvalue_reference_t<_View> |
| 198 | iter_move(__iterator const& __it) noexcept(noexcept(ranges::iter_move(__it.__current_))) { | 198 | iter_move(__iterator const& __it) noexcept(noexcept(ranges::iter_move(__it.__current_))) { |
| 199 | return ranges::iter_move(__it.__current_); | 199 | return ranges::iter_move(__it.__current_); |
| 200 | } | 200 | } |
| ... | @@ -218,7 +218,7 @@ public: | ... | @@ -218,7 +218,7 @@ public: |
| 218 | 218 | ||
| 219 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(filter_view& __parent) : __end_(ranges::end(__parent.__base_)) {} | 219 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(filter_view& __parent) : __end_(ranges::end(__parent.__base_)) {} |
| 220 | 220 | ||
| 221 | _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_View> base() const { return __end_; } | 221 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_View> base() const { return __end_; } |
| 222 | 222 | ||
| 223 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) { | 223 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) { |
| 224 | return __x.__current_ == __y.__end_; | 224 | return __x.__current_ == __y.__end_; |
lib/libcxx/include/__ranges/iota_view.h+41-22| ... | @@ -30,6 +30,7 @@ | ... | @@ -30,6 +30,7 @@ |
| 30 | #include <__ranges/movable_box.h> | 30 | #include <__ranges/movable_box.h> |
| 31 | #include <__ranges/view_interface.h> | 31 | #include <__ranges/view_interface.h> |
| 32 | #include <__type_traits/conditional.h> | 32 | #include <__type_traits/conditional.h> |
| 33 | #include <__type_traits/decay.h> | ||
| 33 | #include <__type_traits/is_nothrow_constructible.h> | 34 | #include <__type_traits/is_nothrow_constructible.h> |
| 34 | #include <__type_traits/make_unsigned.h> | 35 | #include <__type_traits/make_unsigned.h> |
| 35 | #include <__type_traits/type_identity.h> | 36 | #include <__type_traits/type_identity.h> |
| ... | @@ -57,11 +58,17 @@ struct __get_wider_signed { | ... | @@ -57,11 +58,17 @@ struct __get_wider_signed { |
| 57 | return type_identity<int>{}; | 58 | return type_identity<int>{}; |
| 58 | else if constexpr (sizeof(_Int) < sizeof(long)) | 59 | else if constexpr (sizeof(_Int) < sizeof(long)) |
| 59 | return type_identity<long>{}; | 60 | return type_identity<long>{}; |
| 60 | else | 61 | else if constexpr (sizeof(_Int) < sizeof(long long)) |
| 61 | return type_identity<long long>{}; | 62 | return type_identity<long long>{}; |
| 62 | 63 | # if _LIBCPP_HAS_INT128 | |
| 63 | static_assert( | 64 | else if constexpr (sizeof(_Int) <= sizeof(__int128)) |
| 64 | sizeof(_Int) <= sizeof(long long), "Found integer-like type that is bigger than largest integer like type."); | 65 | return type_identity<__int128>{}; |
| 66 | # else | ||
| 67 | else if constexpr (sizeof(_Int) <= sizeof(long long)) | ||
| 68 | return type_identity<long long>{}; | ||
| 69 | # endif | ||
| 70 | else | ||
| 71 | static_assert(false, "Found integer-like type that is bigger than the largest integer like type."); | ||
| 65 | } | 72 | } |
| 66 | 73 | ||
| 67 | using type = typename decltype(__call())::type; | 74 | using type = typename decltype(__call())::type; |
| ... | @@ -125,7 +132,8 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { | ... | @@ -125,7 +132,8 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { |
| 125 | 132 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(_Start __value) : __value_(std::move(__value)) {} | 133 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(_Start __value) : __value_(std::move(__value)) {} |
| 127 | 134 | ||
| 128 | _LIBCPP_HIDE_FROM_ABI constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) { | 135 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Start operator*() const |
| 136 | noexcept(is_nothrow_copy_constructible_v<_Start>) { | ||
| 129 | return __value_; | 137 | return __value_; |
| 130 | } | 138 | } |
| 131 | 139 | ||
| ... | @@ -189,7 +197,7 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { | ... | @@ -189,7 +197,7 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { |
| 189 | return *this; | 197 | return *this; |
| 190 | } | 198 | } |
| 191 | 199 | ||
| 192 | _LIBCPP_HIDE_FROM_ABI constexpr _Start operator[](difference_type __n) const | 200 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Start operator[](difference_type __n) const |
| 193 | requires __advanceable<_Start> | 201 | requires __advanceable<_Start> |
| 194 | { | 202 | { |
| 195 | return _Start(__value_ + __n); | 203 | return _Start(__value_ + __n); |
| ... | @@ -231,27 +239,28 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { | ... | @@ -231,27 +239,28 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { |
| 231 | return __x.__value_ <=> __y.__value_; | 239 | return __x.__value_ <=> __y.__value_; |
| 232 | } | 240 | } |
| 233 | 241 | ||
| 234 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(__iterator __i, difference_type __n) | 242 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(__iterator __i, difference_type __n) |
| 235 | requires __advanceable<_Start> | 243 | requires __advanceable<_Start> |
| 236 | { | 244 | { |
| 237 | __i += __n; | 245 | __i += __n; |
| 238 | return __i; | 246 | return __i; |
| 239 | } | 247 | } |
| 240 | 248 | ||
| 241 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, __iterator __i) | 249 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, __iterator __i) |
| 242 | requires __advanceable<_Start> | 250 | requires __advanceable<_Start> |
| 243 | { | 251 | { |
| 244 | return __i + __n; | 252 | return __i + __n; |
| 245 | } | 253 | } |
| 246 | 254 | ||
| 247 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(__iterator __i, difference_type __n) | 255 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(__iterator __i, difference_type __n) |
| 248 | requires __advanceable<_Start> | 256 | requires __advanceable<_Start> |
| 249 | { | 257 | { |
| 250 | __i -= __n; | 258 | __i -= __n; |
| 251 | return __i; | 259 | return __i; |
| 252 | } | 260 | } |
| 253 | 261 | ||
| 254 | _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) | 262 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type |
| 263 | operator-(const __iterator& __x, const __iterator& __y) | ||
| 255 | requires __advanceable<_Start> | 264 | requires __advanceable<_Start> |
| 256 | { | 265 | { |
| 257 | if constexpr (__integer_like<_Start>) { | 266 | if constexpr (__integer_like<_Start>) { |
| ... | @@ -282,14 +291,14 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { | ... | @@ -282,14 +291,14 @@ class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { |
| 282 | return __x.__value_ == __y.__bound_sentinel_; | 291 | return __x.__value_ == __y.__bound_sentinel_; |
| 283 | } | 292 | } |
| 284 | 293 | ||
| 285 | _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Start> | 294 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Start> |
| 286 | operator-(const __iterator& __x, const __sentinel& __y) | 295 | operator-(const __iterator& __x, const __sentinel& __y) |
| 287 | requires sized_sentinel_for<_BoundSentinel, _Start> | 296 | requires sized_sentinel_for<_BoundSentinel, _Start> |
| 288 | { | 297 | { |
| 289 | return __x.__value_ - __y.__bound_sentinel_; | 298 | return __x.__value_ - __y.__bound_sentinel_; |
| 290 | } | 299 | } |
| 291 | 300 | ||
| 292 | _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Start> | 301 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Start> |
| 293 | operator-(const __sentinel& __x, const __iterator& __y) | 302 | operator-(const __sentinel& __x, const __iterator& __y) |
| 294 | requires sized_sentinel_for<_BoundSentinel, _Start> | 303 | requires sized_sentinel_for<_BoundSentinel, _Start> |
| 295 | { | 304 | { |
| ... | @@ -329,24 +338,24 @@ public: | ... | @@ -329,24 +338,24 @@ public: |
| 329 | requires(!same_as<_Start, _BoundSentinel> && !same_as<_BoundSentinel, unreachable_sentinel_t>) | 338 | requires(!same_as<_Start, _BoundSentinel> && !same_as<_BoundSentinel, unreachable_sentinel_t>) |
| 330 | : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {} | 339 | : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {} |
| 331 | 340 | ||
| 332 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() const { return __iterator{__value_}; } | 341 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() const { return __iterator{__value_}; } |
| 333 | 342 | ||
| 334 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const { | 343 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const { |
| 335 | if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>) | 344 | if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>) |
| 336 | return unreachable_sentinel; | 345 | return unreachable_sentinel; |
| 337 | else | 346 | else |
| 338 | return __sentinel{__bound_sentinel_}; | 347 | return __sentinel{__bound_sentinel_}; |
| 339 | } | 348 | } |
| 340 | 349 | ||
| 341 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator end() const | 350 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator end() const |
| 342 | requires same_as<_Start, _BoundSentinel> | 351 | requires same_as<_Start, _BoundSentinel> |
| 343 | { | 352 | { |
| 344 | return __iterator{__bound_sentinel_}; | 353 | return __iterator{__bound_sentinel_}; |
| 345 | } | 354 | } |
| 346 | 355 | ||
| 347 | _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return __value_ == __bound_sentinel_; } | 356 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return __value_ == __bound_sentinel_; } |
| 348 | 357 | ||
| 349 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 358 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 350 | requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) || | 359 | requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) || |
| 351 | (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> | 360 | (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> |
| 352 | { | 361 | { |
| ... | @@ -374,14 +383,15 @@ namespace views { | ... | @@ -374,14 +383,15 @@ namespace views { |
| 374 | namespace __iota { | 383 | namespace __iota { |
| 375 | struct __fn { | 384 | struct __fn { |
| 376 | template <class _Start> | 385 | template <class _Start> |
| 377 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start) const | 386 | requires(requires(_Start __s) { ranges::iota_view<decay_t<_Start>>(std::forward<_Start>(__s)); }) |
| 378 | noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start)))) | 387 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start) const |
| 379 | -> decltype(ranges::iota_view(std::forward<_Start>(__start))) { | 388 | noexcept(noexcept(ranges::iota_view<decay_t<_Start>>(std::forward<_Start>(__start)))) { |
| 380 | return ranges::iota_view(std::forward<_Start>(__start)); | 389 | return ranges::iota_view<decay_t<_Start>>(std::forward<_Start>(__start)); |
| 381 | } | 390 | } |
| 382 | 391 | ||
| 383 | template <class _Start, class _BoundSentinel> | 392 | template <class _Start, class _BoundSentinel> |
| 384 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const noexcept( | 393 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto |
| 394 | operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const noexcept( | ||
| 385 | noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)))) | 395 | noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)))) |
| 386 | -> decltype(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))) { | 396 | -> decltype(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))) { |
| 387 | return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)); | 397 | return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)); |
| ... | @@ -392,6 +402,15 @@ struct __fn { | ... | @@ -392,6 +402,15 @@ struct __fn { |
| 392 | inline namespace __cpo { | 402 | inline namespace __cpo { |
| 393 | inline constexpr auto iota = __iota::__fn{}; | 403 | inline constexpr auto iota = __iota::__fn{}; |
| 394 | } // namespace __cpo | 404 | } // namespace __cpo |
| 405 | |||
| 406 | # if _LIBCPP_STD_VER >= 26 | ||
| 407 | |||
| 408 | inline constexpr auto indices = [] [[nodiscard]] (__integer_like auto __size) static { | ||
| 409 | return ranges::views::iota(decltype(__size){}, __size); | ||
| 410 | }; | ||
| 411 | |||
| 412 | # endif | ||
| 413 | |||
| 395 | } // namespace views | 414 | } // namespace views |
| 396 | } // namespace ranges | 415 | } // namespace ranges |
| 397 | 416 |
lib/libcxx/include/__ranges/owning_view.h+15-15| ... | @@ -49,52 +49,52 @@ public: | ... | @@ -49,52 +49,52 @@ public: |
| 49 | _LIBCPP_HIDE_FROM_ABI owning_view(owning_view&&) = default; | 49 | _LIBCPP_HIDE_FROM_ABI owning_view(owning_view&&) = default; |
| 50 | _LIBCPP_HIDE_FROM_ABI owning_view& operator=(owning_view&&) = default; | 50 | _LIBCPP_HIDE_FROM_ABI owning_view& operator=(owning_view&&) = default; |
| 51 | 51 | ||
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & noexcept { return __r_; } | 52 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & noexcept { return __r_; } |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr const _Rp& base() const& noexcept { return __r_; } | 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Rp& base() const& noexcept { return __r_; } |
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return std::move(__r_); } | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return std::move(__r_); } |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return std::move(__r_); } | 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return std::move(__r_); } |
| 56 | 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Rp> begin() { return ranges::begin(__r_); } | 57 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Rp> begin() { return ranges::begin(__r_); } |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Rp> end() { return ranges::end(__r_); } | 58 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Rp> end() { return ranges::end(__r_); } |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const |
| 60 | requires range<const _Rp> | 60 | requires range<const _Rp> |
| 61 | { | 61 | { |
| 62 | return ranges::begin(__r_); | 62 | return ranges::begin(__r_); |
| 63 | } | 63 | } |
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | 64 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const |
| 65 | requires range<const _Rp> | 65 | requires range<const _Rp> |
| 66 | { | 66 | { |
| 67 | return ranges::end(__r_); | 67 | return ranges::end(__r_); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr bool empty() | 70 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() |
| 71 | requires requires { ranges::empty(__r_); } | 71 | requires requires { ranges::empty(__r_); } |
| 72 | { | 72 | { |
| 73 | return ranges::empty(__r_); | 73 | return ranges::empty(__r_); |
| 74 | } | 74 | } |
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const | 75 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const |
| 76 | requires requires { ranges::empty(__r_); } | 76 | requires requires { ranges::empty(__r_); } |
| 77 | { | 77 | { |
| 78 | return ranges::empty(__r_); | 78 | return ranges::empty(__r_); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() |
| 82 | requires sized_range<_Rp> | 82 | requires sized_range<_Rp> |
| 83 | { | 83 | { |
| 84 | return ranges::size(__r_); | 84 | return ranges::size(__r_); |
| 85 | } | 85 | } |
| 86 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 87 | requires sized_range<const _Rp> | 87 | requires sized_range<const _Rp> |
| 88 | { | 88 | { |
| 89 | return ranges::size(__r_); | 89 | return ranges::size(__r_); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr auto data() | 92 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto data() |
| 93 | requires contiguous_range<_Rp> | 93 | requires contiguous_range<_Rp> |
| 94 | { | 94 | { |
| 95 | return ranges::data(__r_); | 95 | return ranges::data(__r_); |
| 96 | } | 96 | } |
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr auto data() const | 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto data() const |
| 98 | requires contiguous_range<const _Rp> | 98 | requires contiguous_range<const _Rp> |
| 99 | { | 99 | { |
| 100 | return ranges::data(__r_); | 100 | return ranges::data(__r_); |
lib/libcxx/include/__ranges/ref_view.h+6-6| ... | @@ -51,24 +51,24 @@ public: | ... | @@ -51,24 +51,24 @@ public: |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr ref_view(_Tp&& __t) | 51 | _LIBCPP_HIDE_FROM_ABI constexpr ref_view(_Tp&& __t) |
| 52 | : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t)))) {} | 52 | : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t)))) {} |
| 53 | 53 | ||
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr _Range& base() const { return *__range_; } | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Range& base() const { return *__range_; } |
| 55 | 55 | ||
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Range> begin() const { return ranges::begin(*__range_); } | 56 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Range> begin() const { return ranges::begin(*__range_); } |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Range> end() const { return ranges::end(*__range_); } | 57 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Range> end() const { return ranges::end(*__range_); } |
| 58 | 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const |
| 60 | requires requires { ranges::empty(*__range_); } | 60 | requires requires { ranges::empty(*__range_); } |
| 61 | { | 61 | { |
| 62 | return ranges::empty(*__range_); | 62 | return ranges::empty(*__range_); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 66 | requires sized_range<_Range> | 66 | requires sized_range<_Range> |
| 67 | { | 67 | { |
| 68 | return ranges::size(*__range_); | 68 | return ranges::size(*__range_); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr auto data() const | 71 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto data() const |
| 72 | requires contiguous_range<_Range> | 72 | requires contiguous_range<_Range> |
| 73 | { | 73 | { |
| 74 | return ranges::data(*__range_); | 74 | return ranges::data(*__range_); |
lib/libcxx/include/__ranges/repeat_view.h+17-10| ... | @@ -108,17 +108,21 @@ public: | ... | @@ -108,17 +108,21 @@ public: |
| 108 | __bound_ >= 0, "The behavior is undefined if Bound is not unreachable_sentinel_t and bound is negative"); | 108 | __bound_ >= 0, "The behavior is undefined if Bound is not unreachable_sentinel_t and bound is negative"); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() const { return __iterator(std::addressof(*__value_)); } | 111 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() const { |
| 112 | return __iterator(std::addressof(*__value_)); | ||
| 113 | } | ||
| 112 | 114 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator end() const | 115 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator end() const |
| 114 | requires(!same_as<_Bound, unreachable_sentinel_t>) | 116 | requires(!same_as<_Bound, unreachable_sentinel_t>) |
| 115 | { | 117 | { |
| 116 | return __iterator(std::addressof(*__value_), __bound_); | 118 | return __iterator(std::addressof(*__value_), __bound_); |
| 117 | } | 119 | } |
| 118 | 120 | ||
| 119 | _LIBCPP_HIDE_FROM_ABI constexpr unreachable_sentinel_t end() const noexcept { return unreachable_sentinel; } | 121 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr unreachable_sentinel_t end() const noexcept { |
| 122 | return unreachable_sentinel; | ||
| 123 | } | ||
| 120 | 124 | ||
| 121 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 125 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 122 | requires(!same_as<_Bound, unreachable_sentinel_t>) | 126 | requires(!same_as<_Bound, unreachable_sentinel_t>) |
| 123 | { | 127 | { |
| 124 | return std::__to_unsigned_like(__bound_); | 128 | return std::__to_unsigned_like(__bound_); |
| ... | @@ -152,7 +156,7 @@ public: | ... | @@ -152,7 +156,7 @@ public: |
| 152 | 156 | ||
| 153 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | 157 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; |
| 154 | 158 | ||
| 155 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const noexcept { return *__value_; } | 159 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const noexcept { return *__value_; } |
| 156 | 160 | ||
| 157 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { | 161 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { |
| 158 | ++__current_; | 162 | ++__current_; |
| ... | @@ -192,7 +196,9 @@ public: | ... | @@ -192,7 +196,9 @@ public: |
| 192 | return *this; | 196 | return *this; |
| 193 | } | 197 | } |
| 194 | 198 | ||
| 195 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](difference_type __n) const noexcept { return *(*this + __n); } | 199 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](difference_type __n) const noexcept { |
| 200 | return *(*this + __n); | ||
| 201 | } | ||
| 196 | 202 | ||
| 197 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) { | 203 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) { |
| 198 | return __x.__current_ == __y.__current_; | 204 | return __x.__current_ == __y.__current_; |
| ... | @@ -202,22 +208,23 @@ public: | ... | @@ -202,22 +208,23 @@ public: |
| 202 | return __x.__current_ <=> __y.__current_; | 208 | return __x.__current_ <=> __y.__current_; |
| 203 | } | 209 | } |
| 204 | 210 | ||
| 205 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(__iterator __i, difference_type __n) { | 211 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(__iterator __i, difference_type __n) { |
| 206 | __i += __n; | 212 | __i += __n; |
| 207 | return __i; | 213 | return __i; |
| 208 | } | 214 | } |
| 209 | 215 | ||
| 210 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, __iterator __i) { | 216 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, __iterator __i) { |
| 211 | __i += __n; | 217 | __i += __n; |
| 212 | return __i; | 218 | return __i; |
| 213 | } | 219 | } |
| 214 | 220 | ||
| 215 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(__iterator __i, difference_type __n) { | 221 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(__iterator __i, difference_type __n) { |
| 216 | __i -= __n; | 222 | __i -= __n; |
| 217 | return __i; | 223 | return __i; |
| 218 | } | 224 | } |
| 219 | 225 | ||
| 220 | _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) { | 226 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type |
| 227 | operator-(const __iterator& __x, const __iterator& __y) { | ||
| 221 | return static_cast<difference_type>(__x.__current_) - static_cast<difference_type>(__y.__current_); | 228 | return static_cast<difference_type>(__x.__current_) - static_cast<difference_type>(__y.__current_); |
| 222 | } | 229 | } |
| 223 | 230 |
lib/libcxx/include/__ranges/single_view.h+8-8| ... | @@ -63,21 +63,21 @@ public: | ... | @@ -63,21 +63,21 @@ public: |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr explicit single_view(in_place_t, _Args&&... __args) | 63 | _LIBCPP_HIDE_FROM_ABI constexpr explicit single_view(in_place_t, _Args&&... __args) |
| 64 | : __value_{in_place, std::forward<_Args>(__args)...} {} | 64 | : __value_{in_place, std::forward<_Args>(__args)...} {} |
| 65 | 65 | ||
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* begin() noexcept { return data(); } | 66 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* begin() noexcept { return data(); } |
| 67 | 67 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* begin() const noexcept { return data(); } | 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* begin() const noexcept { return data(); } |
| 69 | 69 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* end() noexcept { return data() + 1; } | 70 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* end() noexcept { return data() + 1; } |
| 71 | 71 | ||
| 72 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* end() const noexcept { return data() + 1; } | 72 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* end() const noexcept { return data() + 1; } |
| 73 | 73 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return false; } | 74 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return false; } |
| 75 | 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 1; } | 76 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 1; } |
| 77 | 77 | ||
| 78 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* data() noexcept { return __value_.operator->(); } | 78 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* data() noexcept { return __value_.operator->(); } |
| 79 | 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* data() const noexcept { return __value_.operator->(); } | 80 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* data() const noexcept { return __value_.operator->(); } |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | template <class _Tp> | 83 | template <class _Tp> |
lib/libcxx/include/__ranges/take_view.h+9-9| ... | @@ -75,15 +75,15 @@ public: | ... | @@ -75,15 +75,15 @@ public: |
| 75 | _LIBCPP_ASSERT_UNCATEGORIZED(__count >= 0, "count has to be greater than or equal to zero"); | 75 | _LIBCPP_ASSERT_UNCATEGORIZED(__count >= 0, "count has to be greater than or equal to zero"); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | 78 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& |
| 79 | requires copy_constructible<_View> | 79 | requires copy_constructible<_View> |
| 80 | { | 80 | { |
| 81 | return __base_; | 81 | return __base_; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | 84 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } |
| 85 | 85 | ||
| 86 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() | 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() |
| 87 | requires(!__simple_view<_View>) | 87 | requires(!__simple_view<_View>) |
| 88 | { | 88 | { |
| 89 | if constexpr (sized_range<_View>) { | 89 | if constexpr (sized_range<_View>) { |
| ... | @@ -99,7 +99,7 @@ public: | ... | @@ -99,7 +99,7 @@ public: |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | 102 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const |
| 103 | requires range<const _View> | 103 | requires range<const _View> |
| 104 | { | 104 | { |
| 105 | if constexpr (sized_range<const _View>) { | 105 | if constexpr (sized_range<const _View>) { |
| ... | @@ -115,7 +115,7 @@ public: | ... | @@ -115,7 +115,7 @@ public: |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() | 118 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() |
| 119 | requires(!__simple_view<_View>) | 119 | requires(!__simple_view<_View>) |
| 120 | { | 120 | { |
| 121 | if constexpr (sized_range<_View>) { | 121 | if constexpr (sized_range<_View>) { |
| ... | @@ -129,7 +129,7 @@ public: | ... | @@ -129,7 +129,7 @@ public: |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | 132 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const |
| 133 | requires range<const _View> | 133 | requires range<const _View> |
| 134 | { | 134 | { |
| 135 | if constexpr (sized_range<const _View>) { | 135 | if constexpr (sized_range<const _View>) { |
| ... | @@ -143,14 +143,14 @@ public: | ... | @@ -143,14 +143,14 @@ public: |
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | 146 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() |
| 147 | requires sized_range<_View> | 147 | requires sized_range<_View> |
| 148 | { | 148 | { |
| 149 | auto __n = ranges::size(__base_); | 149 | auto __n = ranges::size(__base_); |
| 150 | return ranges::min(__n, static_cast<decltype(__n)>(__count_)); | 150 | return ranges::min(__n, static_cast<decltype(__n)>(__count_)); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 153 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 154 | requires sized_range<const _View> | 154 | requires sized_range<const _View> |
| 155 | { | 155 | { |
| 156 | auto __n = ranges::size(__base_); | 156 | auto __n = ranges::size(__base_); |
| ... | @@ -178,7 +178,7 @@ public: | ... | @@ -178,7 +178,7 @@ public: |
| 178 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> | 178 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> |
| 179 | : __end_(std::move(__s.__end_)) {} | 179 | : __end_(std::move(__s.__end_)) {} |
| 180 | 180 | ||
| 181 | _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; } | 181 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; } |
| 182 | 182 | ||
| 183 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) { | 183 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) { |
| 184 | return __lhs.count() == 0 || __lhs.base() == __rhs.__end_; | 184 | return __lhs.count() == 0 || __lhs.base() == __rhs.__end_; |
lib/libcxx/include/__ranges/transform_view.h+1-2| ... | @@ -13,7 +13,6 @@ | ... | @@ -13,7 +13,6 @@ |
| 13 | #include <__compare/three_way_comparable.h> | 13 | #include <__compare/three_way_comparable.h> |
| 14 | #include <__concepts/constructible.h> | 14 | #include <__concepts/constructible.h> |
| 15 | #include <__concepts/convertible_to.h> | 15 | #include <__concepts/convertible_to.h> |
| 16 | #include <__concepts/copyable.h> | ||
| 17 | #include <__concepts/derived_from.h> | 16 | #include <__concepts/derived_from.h> |
| 18 | #include <__concepts/equality_comparable.h> | 17 | #include <__concepts/equality_comparable.h> |
| 19 | #include <__concepts/invocable.h> | 18 | #include <__concepts/invocable.h> |
| ... | @@ -64,7 +63,7 @@ concept __regular_invocable_with_range_ref = regular_invocable<_Fn, range_refere | ... | @@ -64,7 +63,7 @@ concept __regular_invocable_with_range_ref = regular_invocable<_Fn, range_refere |
| 64 | template <class _View, class _Fn> | 63 | template <class _View, class _Fn> |
| 65 | concept __transform_view_constraints = | 64 | concept __transform_view_constraints = |
| 66 | view<_View> && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_View>> && | 65 | view<_View> && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_View>> && |
| 67 | __is_referenceable_v<invoke_result_t<_Fn&, range_reference_t<_View>>>; | 66 | __referenceable<invoke_result_t<_Fn&, range_reference_t<_View>>>; |
| 68 | 67 | ||
| 69 | # if _LIBCPP_STD_VER >= 23 | 68 | # if _LIBCPP_STD_VER >= 23 |
| 70 | template <input_range _View, move_constructible _Fn> | 69 | template <input_range _View, move_constructible _Fn> |
lib/libcxx/include/__ranges/view_interface.h+10-10| ... | @@ -87,35 +87,35 @@ public: | ... | @@ -87,35 +87,35 @@ public: |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | template <class _D2 = _Derived> | 89 | template <class _D2 = _Derived> |
| 90 | _LIBCPP_HIDE_FROM_ABI constexpr auto data() | 90 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto data() |
| 91 | requires contiguous_iterator<iterator_t<_D2>> | 91 | requires contiguous_iterator<iterator_t<_D2>> |
| 92 | { | 92 | { |
| 93 | return std::to_address(ranges::begin(__derived())); | 93 | return std::to_address(ranges::begin(__derived())); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | template <class _D2 = _Derived> | 96 | template <class _D2 = _Derived> |
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr auto data() const | 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto data() const |
| 98 | requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>> | 98 | requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>> |
| 99 | { | 99 | { |
| 100 | return std::to_address(ranges::begin(__derived())); | 100 | return std::to_address(ranges::begin(__derived())); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | template <class _D2 = _Derived> | 103 | template <class _D2 = _Derived> |
| 104 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | 104 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() |
| 105 | requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>> | 105 | requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>> |
| 106 | { | 106 | { |
| 107 | return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived())); | 107 | return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived())); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | template <class _D2 = _Derived> | 110 | template <class _D2 = _Derived> |
| 111 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 111 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| 112 | requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>> | 112 | requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>> |
| 113 | { | 113 | { |
| 114 | return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived())); | 114 | return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived())); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | template <class _D2 = _Derived> | 117 | template <class _D2 = _Derived> |
| 118 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() | 118 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() |
| 119 | requires forward_range<_D2> | 119 | requires forward_range<_D2> |
| 120 | { | 120 | { |
| 121 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 121 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| ... | @@ -124,7 +124,7 @@ public: | ... | @@ -124,7 +124,7 @@ public: |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | template <class _D2 = _Derived> | 126 | template <class _D2 = _Derived> |
| 127 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() const | 127 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() const |
| 128 | requires forward_range<const _D2> | 128 | requires forward_range<const _D2> |
| 129 | { | 129 | { |
| 130 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 130 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| ... | @@ -133,7 +133,7 @@ public: | ... | @@ -133,7 +133,7 @@ public: |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | template <class _D2 = _Derived> | 135 | template <class _D2 = _Derived> |
| 136 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() | 136 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() |
| 137 | requires bidirectional_range<_D2> && common_range<_D2> | 137 | requires bidirectional_range<_D2> && common_range<_D2> |
| 138 | { | 138 | { |
| 139 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 139 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| ... | @@ -142,7 +142,7 @@ public: | ... | @@ -142,7 +142,7 @@ public: |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | template <class _D2 = _Derived> | 144 | template <class _D2 = _Derived> |
| 145 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() const | 145 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() const |
| 146 | requires bidirectional_range<const _D2> && common_range<const _D2> | 146 | requires bidirectional_range<const _D2> && common_range<const _D2> |
| 147 | { | 147 | { |
| 148 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 148 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| ... | @@ -151,12 +151,12 @@ public: | ... | @@ -151,12 +151,12 @@ public: |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | template <random_access_range _RARange = _Derived> | 153 | template <random_access_range _RARange = _Derived> |
| 154 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) { | 154 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) { |
| 155 | return ranges::begin(__derived())[__index]; | 155 | return ranges::begin(__derived())[__index]; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | template <random_access_range _RARange = const _Derived> | 158 | template <random_access_range _RARange = const _Derived> |
| 159 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const { | 159 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const { |
| 160 | return ranges::begin(__derived())[__index]; | 160 | return ranges::begin(__derived())[__index]; |
| 161 | } | 161 | } |
| 162 | }; | 162 | }; |
lib/libcxx/include/__ranges/zip_transform_view.h created+357| ... | @@ -0,0 +1,357 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___RANGES_ZIP_TRANSFORM_VIEW_H | ||
| 11 | #define _LIBCPP___RANGES_ZIP_TRANSFORM_VIEW_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #include <__concepts/constructible.h> | ||
| 16 | #include <__concepts/convertible_to.h> | ||
| 17 | #include <__concepts/derived_from.h> | ||
| 18 | #include <__concepts/equality_comparable.h> | ||
| 19 | #include <__concepts/invocable.h> | ||
| 20 | #include <__functional/invoke.h> | ||
| 21 | #include <__iterator/concepts.h> | ||
| 22 | #include <__iterator/incrementable_traits.h> | ||
| 23 | #include <__iterator/iterator_traits.h> | ||
| 24 | #include <__memory/addressof.h> | ||
| 25 | #include <__ranges/access.h> | ||
| 26 | #include <__ranges/all.h> | ||
| 27 | #include <__ranges/concepts.h> | ||
| 28 | #include <__ranges/empty_view.h> | ||
| 29 | #include <__ranges/movable_box.h> | ||
| 30 | #include <__ranges/view_interface.h> | ||
| 31 | #include <__ranges/zip_view.h> | ||
| 32 | #include <__type_traits/decay.h> | ||
| 33 | #include <__type_traits/invoke.h> | ||
| 34 | #include <__type_traits/is_object.h> | ||
| 35 | #include <__type_traits/is_reference.h> | ||
| 36 | #include <__type_traits/is_referenceable.h> | ||
| 37 | #include <__type_traits/maybe_const.h> | ||
| 38 | #include <__type_traits/remove_cvref.h> | ||
| 39 | #include <__utility/forward.h> | ||
| 40 | #include <__utility/in_place.h> | ||
| 41 | #include <__utility/move.h> | ||
| 42 | #include <tuple> // for std::apply | ||
| 43 | |||
| 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 45 | # pragma GCC system_header | ||
| 46 | #endif | ||
| 47 | |||
| 48 | _LIBCPP_PUSH_MACROS | ||
| 49 | #include <__undef_macros> | ||
| 50 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 51 | |||
| 52 | #if _LIBCPP_STD_VER >= 23 | ||
| 53 | |||
| 54 | namespace ranges { | ||
| 55 | |||
| 56 | template <move_constructible _Fn, input_range... _Views> | ||
| 57 | requires(view<_Views> && ...) && | ||
| 58 | (sizeof...(_Views) > 0) && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_Views>...> && | ||
| 59 | __referenceable<invoke_result_t<_Fn&, range_reference_t<_Views>...>> | ||
| 60 | class zip_transform_view : public view_interface<zip_transform_view<_Fn, _Views...>> { | ||
| 61 | _LIBCPP_NO_UNIQUE_ADDRESS zip_view<_Views...> __zip_; | ||
| 62 | _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Fn> __fun_; | ||
| 63 | |||
| 64 | using _InnerView _LIBCPP_NODEBUG = zip_view<_Views...>; | ||
| 65 | template <bool _Const> | ||
| 66 | using __ziperator _LIBCPP_NODEBUG = iterator_t<__maybe_const<_Const, _InnerView>>; | ||
| 67 | template <bool _Const> | ||
| 68 | using __zentinel _LIBCPP_NODEBUG = sentinel_t<__maybe_const<_Const, _InnerView>>; | ||
| 69 | |||
| 70 | template <bool> | ||
| 71 | class __iterator; | ||
| 72 | |||
| 73 | template <bool> | ||
| 74 | class __sentinel; | ||
| 75 | |||
| 76 | public: | ||
| 77 | _LIBCPP_HIDE_FROM_ABI zip_transform_view() = default; | ||
| 78 | |||
| 79 | _LIBCPP_HIDE_FROM_ABI constexpr explicit zip_transform_view(_Fn __fun, _Views... __views) | ||
| 80 | : __zip_(std::move(__views)...), __fun_(in_place, std::move(__fun)) {} | ||
| 81 | |||
| 82 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { return __iterator<false>(*this, __zip_.begin()); } | ||
| 83 | |||
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | ||
| 85 | requires range<const _InnerView> && regular_invocable<const _Fn&, range_reference_t<const _Views>...> | ||
| 86 | { | ||
| 87 | return __iterator<true>(*this, __zip_.begin()); | ||
| 88 | } | ||
| 89 | |||
| 90 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() { | ||
| 91 | if constexpr (common_range<_InnerView>) { | ||
| 92 | return __iterator<false>(*this, __zip_.end()); | ||
| 93 | } else { | ||
| 94 | return __sentinel<false>(__zip_.end()); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | ||
| 99 | requires range<const _InnerView> && regular_invocable<const _Fn&, range_reference_t<const _Views>...> | ||
| 100 | { | ||
| 101 | if constexpr (common_range<const _InnerView>) { | ||
| 102 | return __iterator<true>(*this, __zip_.end()); | ||
| 103 | } else { | ||
| 104 | return __sentinel<true>(__zip_.end()); | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() | ||
| 109 | requires sized_range<_InnerView> | ||
| 110 | { | ||
| 111 | return __zip_.size(); | ||
| 112 | } | ||
| 113 | |||
| 114 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | ||
| 115 | requires sized_range<const _InnerView> | ||
| 116 | { | ||
| 117 | return __zip_.size(); | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 121 | template <class _Fn, class... _Ranges> | ||
| 122 | zip_transform_view(_Fn, _Ranges&&...) -> zip_transform_view<_Fn, views::all_t<_Ranges>...>; | ||
| 123 | |||
| 124 | template <bool _Const, class _Fn, class... _Views> | ||
| 125 | struct __zip_transform_iterator_category_base {}; | ||
| 126 | |||
| 127 | template <bool _Const, class _Fn, class... _Views> | ||
| 128 | requires forward_range<__maybe_const<_Const, zip_view<_Views...>>> | ||
| 129 | struct __zip_transform_iterator_category_base<_Const, _Fn, _Views...> { | ||
| 130 | private: | ||
| 131 | template <class _View> | ||
| 132 | using __tag _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<__maybe_const<_Const, _View>>>::iterator_category; | ||
| 133 | |||
| 134 | static consteval auto __get_iterator_category() { | ||
| 135 | if constexpr (!is_reference_v<invoke_result_t<__maybe_const<_Const, _Fn>&, | ||
| 136 | range_reference_t<__maybe_const<_Const, _Views>>...>>) { | ||
| 137 | return input_iterator_tag(); | ||
| 138 | } else if constexpr ((derived_from<__tag<_Views>, random_access_iterator_tag> && ...)) { | ||
| 139 | return random_access_iterator_tag(); | ||
| 140 | } else if constexpr ((derived_from<__tag<_Views>, bidirectional_iterator_tag> && ...)) { | ||
| 141 | return bidirectional_iterator_tag(); | ||
| 142 | } else if constexpr ((derived_from<__tag<_Views>, forward_iterator_tag> && ...)) { | ||
| 143 | return forward_iterator_tag(); | ||
| 144 | } else { | ||
| 145 | return input_iterator_tag(); | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | public: | ||
| 150 | using iterator_category = decltype(__get_iterator_category()); | ||
| 151 | }; | ||
| 152 | |||
| 153 | template <move_constructible _Fn, input_range... _Views> | ||
| 154 | requires(view<_Views> && ...) && | ||
| 155 | (sizeof...(_Views) > 0) && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_Views>...> && | ||
| 156 | __referenceable<invoke_result_t<_Fn&, range_reference_t<_Views>...>> | ||
| 157 | template <bool _Const> | ||
| 158 | class zip_transform_view<_Fn, _Views...>::__iterator | ||
| 159 | : public __zip_transform_iterator_category_base<_Const, _Fn, _Views...> { | ||
| 160 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, zip_transform_view>; | ||
| 161 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _InnerView>; | ||
| 162 | |||
| 163 | friend zip_transform_view<_Fn, _Views...>; | ||
| 164 | |||
| 165 | _Parent* __parent_ = nullptr; | ||
| 166 | __ziperator<_Const> __inner_; | ||
| 167 | |||
| 168 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(_Parent& __parent, __ziperator<_Const> __inner) | ||
| 169 | : __parent_(std::addressof(__parent)), __inner_(std::move(__inner)) {} | ||
| 170 | |||
| 171 | _LIBCPP_HIDE_FROM_ABI constexpr auto __get_deref_and_invoke() const noexcept { | ||
| 172 | return [&__fun = *__parent_->__fun_](const auto&... __iters) noexcept(noexcept(std::invoke( | ||
| 173 | *__parent_->__fun_, *__iters...))) -> decltype(auto) { return std::invoke(__fun, *__iters...); }; | ||
| 174 | } | ||
| 175 | |||
| 176 | public: | ||
| 177 | using iterator_concept = typename __ziperator<_Const>::iterator_concept; | ||
| 178 | using value_type = | ||
| 179 | remove_cvref_t<invoke_result_t<__maybe_const<_Const, _Fn>&, range_reference_t<__maybe_const<_Const, _Views>>...>>; | ||
| 180 | using difference_type = range_difference_t<_Base>; | ||
| 181 | |||
| 182 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | ||
| 183 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i) | ||
| 184 | requires _Const && convertible_to<__ziperator<false>, __ziperator<_Const>> | ||
| 185 | : __parent_(__i.__parent_), __inner_(std::move(__i.__inner_)) {} | ||
| 186 | |||
| 187 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const | ||
| 188 | noexcept(noexcept(std::apply(__get_deref_and_invoke(), __zip_view_iterator_access::__get_underlying(__inner_)))) { | ||
| 189 | return std::apply(__get_deref_and_invoke(), __zip_view_iterator_access::__get_underlying(__inner_)); | ||
| 190 | } | ||
| 191 | |||
| 192 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { | ||
| 193 | ++__inner_; | ||
| 194 | return *this; | ||
| 195 | } | ||
| 196 | |||
| 197 | _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { ++*this; } | ||
| 198 | |||
| 199 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) | ||
| 200 | requires forward_range<_Base> | ||
| 201 | { | ||
| 202 | auto __tmp = *this; | ||
| 203 | ++*this; | ||
| 204 | return __tmp; | ||
| 205 | } | ||
| 206 | |||
| 207 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() | ||
| 208 | requires bidirectional_range<_Base> | ||
| 209 | { | ||
| 210 | --__inner_; | ||
| 211 | return *this; | ||
| 212 | } | ||
| 213 | |||
| 214 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int) | ||
| 215 | requires bidirectional_range<_Base> | ||
| 216 | { | ||
| 217 | auto __tmp = *this; | ||
| 218 | --*this; | ||
| 219 | return __tmp; | ||
| 220 | } | ||
| 221 | |||
| 222 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __x) | ||
| 223 | requires random_access_range<_Base> | ||
| 224 | { | ||
| 225 | __inner_ += __x; | ||
| 226 | return *this; | ||
| 227 | } | ||
| 228 | |||
| 229 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __x) | ||
| 230 | requires random_access_range<_Base> | ||
| 231 | { | ||
| 232 | __inner_ -= __x; | ||
| 233 | return *this; | ||
| 234 | } | ||
| 235 | |||
| 236 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const | ||
| 237 | requires random_access_range<_Base> | ||
| 238 | { | ||
| 239 | return std::apply( | ||
| 240 | [&]<class... _Is>(const _Is&... __iters) -> decltype(auto) { | ||
| 241 | return std::invoke(*__parent_->__fun_, __iters[iter_difference_t<_Is>(__n)]...); | ||
| 242 | }, | ||
| 243 | __zip_view_iterator_access::__get_underlying(__inner_)); | ||
| 244 | } | ||
| 245 | |||
| 246 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) | ||
| 247 | requires equality_comparable<__ziperator<_Const>> | ||
| 248 | { | ||
| 249 | return __x.__inner_ == __y.__inner_; | ||
| 250 | } | ||
| 251 | |||
| 252 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) | ||
| 253 | requires random_access_range<_Base> | ||
| 254 | { | ||
| 255 | return __x.__inner_ <=> __y.__inner_; | ||
| 256 | } | ||
| 257 | |||
| 258 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n) | ||
| 259 | requires random_access_range<_Base> | ||
| 260 | { | ||
| 261 | return __iterator(*__i.__parent_, __i.__inner_ + __n); | ||
| 262 | } | ||
| 263 | |||
| 264 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i) | ||
| 265 | requires random_access_range<_Base> | ||
| 266 | { | ||
| 267 | return __iterator(*__i.__parent_, __i.__inner_ + __n); | ||
| 268 | } | ||
| 269 | |||
| 270 | _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n) | ||
| 271 | requires random_access_range<_Base> | ||
| 272 | { | ||
| 273 | return __iterator(*__i.__parent_, __i.__inner_ - __n); | ||
| 274 | } | ||
| 275 | |||
| 276 | _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) | ||
| 277 | requires sized_sentinel_for<__ziperator<_Const>, __ziperator<_Const>> | ||
| 278 | { | ||
| 279 | return __x.__inner_ - __y.__inner_; | ||
| 280 | } | ||
| 281 | }; | ||
| 282 | |||
| 283 | template <move_constructible _Fn, input_range... _Views> | ||
| 284 | requires(view<_Views> && ...) && | ||
| 285 | (sizeof...(_Views) > 0) && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_Views>...> && | ||
| 286 | __referenceable<invoke_result_t<_Fn&, range_reference_t<_Views>...>> | ||
| 287 | template <bool _Const> | ||
| 288 | class zip_transform_view<_Fn, _Views...>::__sentinel { | ||
| 289 | __zentinel<_Const> __inner_; | ||
| 290 | |||
| 291 | friend zip_transform_view<_Fn, _Views...>; | ||
| 292 | |||
| 293 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(__zentinel<_Const> __inner) : __inner_(__inner) {} | ||
| 294 | |||
| 295 | public: | ||
| 296 | _LIBCPP_HIDE_FROM_ABI __sentinel() = default; | ||
| 297 | |||
| 298 | _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __i) | ||
| 299 | requires _Const && convertible_to<__zentinel<false>, __zentinel<_Const>> | ||
| 300 | : __inner_(__i.__inner_) {} | ||
| 301 | |||
| 302 | template <bool _OtherConst> | ||
| 303 | requires sentinel_for<__zentinel<_Const>, __ziperator<_OtherConst>> | ||
| 304 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | ||
| 305 | return __x.__inner_ == __y.__inner_; | ||
| 306 | } | ||
| 307 | |||
| 308 | template <bool _OtherConst> | ||
| 309 | requires sized_sentinel_for<__zentinel<_Const>, __ziperator<_OtherConst>> | ||
| 310 | _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>> | ||
| 311 | operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | ||
| 312 | return __x.__inner_ - __y.__inner_; | ||
| 313 | } | ||
| 314 | |||
| 315 | template <bool _OtherConst> | ||
| 316 | requires sized_sentinel_for<__zentinel<_Const>, __ziperator<_OtherConst>> | ||
| 317 | _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>> | ||
| 318 | operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) { | ||
| 319 | return __x.__inner_ - __y.__inner_; | ||
| 320 | } | ||
| 321 | }; | ||
| 322 | |||
| 323 | namespace views { | ||
| 324 | namespace __zip_transform { | ||
| 325 | |||
| 326 | struct __fn { | ||
| 327 | template <class _Fn> | ||
| 328 | requires(move_constructible<decay_t<_Fn>> && regular_invocable<decay_t<_Fn>&> && | ||
| 329 | is_object_v<invoke_result_t<decay_t<_Fn>&>>) | ||
| 330 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&&) const | ||
| 331 | noexcept(noexcept(auto(views::empty<decay_t<invoke_result_t<decay_t<_Fn>&>>>))) { | ||
| 332 | return views::empty<decay_t<invoke_result_t<decay_t<_Fn>&>>>; | ||
| 333 | } | ||
| 334 | |||
| 335 | template <class _Fn, class... _Ranges> | ||
| 336 | requires(sizeof...(_Ranges) > 0) | ||
| 337 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __fun, _Ranges&&... __rs) const | ||
| 338 | noexcept(noexcept(zip_transform_view(std::forward<_Fn>(__fun), std::forward<_Ranges>(__rs)...))) | ||
| 339 | -> decltype(zip_transform_view(std::forward<_Fn>(__fun), std::forward<_Ranges>(__rs)...)) { | ||
| 340 | return zip_transform_view(std::forward<_Fn>(__fun), std::forward<_Ranges>(__rs)...); | ||
| 341 | } | ||
| 342 | }; | ||
| 343 | |||
| 344 | } // namespace __zip_transform | ||
| 345 | inline namespace __cpo { | ||
| 346 | inline constexpr auto zip_transform = __zip_transform::__fn{}; | ||
| 347 | } // namespace __cpo | ||
| 348 | } // namespace views | ||
| 349 | } // namespace ranges | ||
| 350 | |||
| 351 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 352 | |||
| 353 | _LIBCPP_END_NAMESPACE_STD | ||
| 354 | |||
| 355 | _LIBCPP_POP_MACROS | ||
| 356 | |||
| 357 | #endif // _LIBCPP___RANGES_ZIP_TRANSFORM_VIEW_H | ||
lib/libcxx/include/__ranges/zip_view.h+20-20| ... | @@ -31,6 +31,7 @@ | ... | @@ -31,6 +31,7 @@ |
| 31 | #include <__ranges/enable_borrowed_range.h> | 31 | #include <__ranges/enable_borrowed_range.h> |
| 32 | #include <__ranges/size.h> | 32 | #include <__ranges/size.h> |
| 33 | #include <__ranges/view_interface.h> | 33 | #include <__ranges/view_interface.h> |
| 34 | #include <__tuple/tuple_transform.h> | ||
| 34 | #include <__type_traits/is_nothrow_constructible.h> | 35 | #include <__type_traits/is_nothrow_constructible.h> |
| 35 | #include <__type_traits/make_unsigned.h> | 36 | #include <__type_traits/make_unsigned.h> |
| 36 | #include <__utility/declval.h> | 37 | #include <__utility/declval.h> |
| ... | @@ -58,15 +59,6 @@ concept __zip_is_common = | ... | @@ -58,15 +59,6 @@ concept __zip_is_common = |
| 58 | (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) || | 59 | (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) || |
| 59 | ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...)); | 60 | ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...)); |
| 60 | 61 | ||
| 61 | template <class _Fun, class _Tuple> | ||
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) { | ||
| 63 | return std::apply( | ||
| 64 | [&]<class... _Types>(_Types&&... __elements) { | ||
| 65 | return tuple<invoke_result_t<_Fun&, _Types>...>(std::invoke(__f, std::forward<_Types>(__elements))...); | ||
| 66 | }, | ||
| 67 | std::forward<_Tuple>(__tuple)); | ||
| 68 | } | ||
| 69 | |||
| 70 | template <class _Fun, class _Tuple> | 62 | template <class _Fun, class _Tuple> |
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tuple) { | 63 | _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tuple) { |
| 72 | std::apply( | 64 | std::apply( |
| ... | @@ -145,24 +137,24 @@ public: | ... | @@ -145,24 +137,24 @@ public: |
| 145 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() | 137 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() |
| 146 | requires(!(__simple_view<_Views> && ...)) | 138 | requires(!(__simple_view<_Views> && ...)) |
| 147 | { | 139 | { |
| 148 | return __iterator<false>(ranges::__tuple_transform(ranges::begin, __views_)); | 140 | return __iterator<false>(std::__tuple_transform(ranges::begin, __views_)); |
| 149 | } | 141 | } |
| 150 | 142 | ||
| 151 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | 143 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const |
| 152 | requires(range<const _Views> && ...) | 144 | requires(range<const _Views> && ...) |
| 153 | { | 145 | { |
| 154 | return __iterator<true>(ranges::__tuple_transform(ranges::begin, __views_)); | 146 | return __iterator<true>(std::__tuple_transform(ranges::begin, __views_)); |
| 155 | } | 147 | } |
| 156 | 148 | ||
| 157 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() | 149 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() |
| 158 | requires(!(__simple_view<_Views> && ...)) | 150 | requires(!(__simple_view<_Views> && ...)) |
| 159 | { | 151 | { |
| 160 | if constexpr (!__zip_is_common<_Views...>) { | 152 | if constexpr (!__zip_is_common<_Views...>) { |
| 161 | return __sentinel<false>(ranges::__tuple_transform(ranges::end, __views_)); | 153 | return __sentinel<false>(std::__tuple_transform(ranges::end, __views_)); |
| 162 | } else if constexpr ((random_access_range<_Views> && ...)) { | 154 | } else if constexpr ((random_access_range<_Views> && ...)) { |
| 163 | return begin() + iter_difference_t<__iterator<false>>(size()); | 155 | return begin() + iter_difference_t<__iterator<false>>(size()); |
| 164 | } else { | 156 | } else { |
| 165 | return __iterator<false>(ranges::__tuple_transform(ranges::end, __views_)); | 157 | return __iterator<false>(std::__tuple_transform(ranges::end, __views_)); |
| 166 | } | 158 | } |
| 167 | } | 159 | } |
| 168 | 160 | ||
| ... | @@ -170,11 +162,11 @@ public: | ... | @@ -170,11 +162,11 @@ public: |
| 170 | requires(range<const _Views> && ...) | 162 | requires(range<const _Views> && ...) |
| 171 | { | 163 | { |
| 172 | if constexpr (!__zip_is_common<const _Views...>) { | 164 | if constexpr (!__zip_is_common<const _Views...>) { |
| 173 | return __sentinel<true>(ranges::__tuple_transform(ranges::end, __views_)); | 165 | return __sentinel<true>(std::__tuple_transform(ranges::end, __views_)); |
| 174 | } else if constexpr ((random_access_range<const _Views> && ...)) { | 166 | } else if constexpr ((random_access_range<const _Views> && ...)) { |
| 175 | return begin() + iter_difference_t<__iterator<true>>(size()); | 167 | return begin() + iter_difference_t<__iterator<true>>(size()); |
| 176 | } else { | 168 | } else { |
| 177 | return __iterator<true>(ranges::__tuple_transform(ranges::end, __views_)); | 169 | return __iterator<true>(std::__tuple_transform(ranges::end, __views_)); |
| 178 | } | 170 | } |
| 179 | } | 171 | } |
| 180 | 172 | ||
| ... | @@ -186,7 +178,7 @@ public: | ... | @@ -186,7 +178,7 @@ public: |
| 186 | using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>; | 178 | using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>; |
| 187 | return ranges::min({_CT(__sizes)...}); | 179 | return ranges::min({_CT(__sizes)...}); |
| 188 | }, | 180 | }, |
| 189 | ranges::__tuple_transform(ranges::size, __views_)); | 181 | std::__tuple_transform(ranges::size, __views_)); |
| 190 | } | 182 | } |
| 191 | 183 | ||
| 192 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const | 184 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const |
| ... | @@ -197,7 +189,7 @@ public: | ... | @@ -197,7 +189,7 @@ public: |
| 197 | using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>; | 189 | using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>; |
| 198 | return ranges::min({_CT(__sizes)...}); | 190 | return ranges::min({_CT(__sizes)...}); |
| 199 | }, | 191 | }, |
| 200 | ranges::__tuple_transform(ranges::size, __views_)); | 192 | std::__tuple_transform(ranges::size, __views_)); |
| 201 | } | 193 | } |
| 202 | }; | 194 | }; |
| 203 | 195 | ||
| ... | @@ -235,6 +227,13 @@ struct __zip_view_iterator_category_base<_Const, _Views...> { | ... | @@ -235,6 +227,13 @@ struct __zip_view_iterator_category_base<_Const, _Views...> { |
| 235 | using iterator_category = input_iterator_tag; | 227 | using iterator_category = input_iterator_tag; |
| 236 | }; | 228 | }; |
| 237 | 229 | ||
| 230 | struct __zip_view_iterator_access { | ||
| 231 | template <class _Iter> | ||
| 232 | _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_underlying(_Iter& __iter) noexcept { | ||
| 233 | return (__iter.__current_); | ||
| 234 | } | ||
| 235 | }; | ||
| 236 | |||
| 238 | template <input_range... _Views> | 237 | template <input_range... _Views> |
| 239 | requires(view<_Views> && ...) && (sizeof...(_Views) > 0) | 238 | requires(view<_Views> && ...) && (sizeof...(_Views) > 0) |
| 240 | template <bool _Const> | 239 | template <bool _Const> |
| ... | @@ -255,6 +254,7 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base | ... | @@ -255,6 +254,7 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base |
| 255 | static constexpr bool __is_zip_view_iterator = true; | 254 | static constexpr bool __is_zip_view_iterator = true; |
| 256 | 255 | ||
| 257 | friend struct __product_iterator_traits<__iterator>; | 256 | friend struct __product_iterator_traits<__iterator>; |
| 257 | friend __zip_view_iterator_access; | ||
| 258 | 258 | ||
| 259 | public: | 259 | public: |
| 260 | using iterator_concept = decltype(ranges::__get_zip_view_iterator_tag<_Const, _Views...>()); | 260 | using iterator_concept = decltype(ranges::__get_zip_view_iterator_tag<_Const, _Views...>()); |
| ... | @@ -268,7 +268,7 @@ public: | ... | @@ -268,7 +268,7 @@ public: |
| 268 | : __current_(std::move(__i.__current_)) {} | 268 | : __current_(std::move(__i.__current_)) {} |
| 269 | 269 | ||
| 270 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const { | 270 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const { |
| 271 | return ranges::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_); | 271 | return std::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_); |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { | 274 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { |
| ... | @@ -318,7 +318,7 @@ public: | ... | @@ -318,7 +318,7 @@ public: |
| 318 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const | 318 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const |
| 319 | requires __zip_all_random_access<_Const, _Views...> | 319 | requires __zip_all_random_access<_Const, _Views...> |
| 320 | { | 320 | { |
| 321 | return ranges::__tuple_transform( | 321 | return std::__tuple_transform( |
| 322 | [&]<class _Iter>(_Iter& __i) -> decltype(auto) { return __i[iter_difference_t<_Iter>(__n)]; }, __current_); | 322 | [&]<class _Iter>(_Iter& __i) -> decltype(auto) { return __i[iter_difference_t<_Iter>(__n)]; }, __current_); |
| 323 | } | 323 | } |
| 324 | 324 | ||
| ... | @@ -377,7 +377,7 @@ public: | ... | @@ -377,7 +377,7 @@ public: |
| 377 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept( | 377 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept( |
| 378 | (noexcept(ranges::iter_move(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) && | 378 | (noexcept(ranges::iter_move(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) && |
| 379 | (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) { | 379 | (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) { |
| 380 | return ranges::__tuple_transform(ranges::iter_move, __i.__current_); | 380 | return std::__tuple_transform(ranges::iter_move, __i.__current_); |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept( | 383 | _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept( |
lib/libcxx/include/__split_buffer+612-240| ... | @@ -13,10 +13,12 @@ | ... | @@ -13,10 +13,12 @@ |
| 13 | #include <__algorithm/max.h> | 13 | #include <__algorithm/max.h> |
| 14 | #include <__algorithm/move.h> | 14 | #include <__algorithm/move.h> |
| 15 | #include <__algorithm/move_backward.h> | 15 | #include <__algorithm/move_backward.h> |
| 16 | #include <__assert> | ||
| 16 | #include <__config> | 17 | #include <__config> |
| 17 | #include <__iterator/distance.h> | 18 | #include <__iterator/distance.h> |
| 18 | #include <__iterator/iterator_traits.h> | 19 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__iterator/move_iterator.h> | 20 | #include <__iterator/move_iterator.h> |
| 21 | #include <__memory/addressof.h> | ||
| 20 | #include <__memory/allocate_at_least.h> | 22 | #include <__memory/allocate_at_least.h> |
| 21 | #include <__memory/allocator.h> | 23 | #include <__memory/allocator.h> |
| 22 | #include <__memory/allocator_traits.h> | 24 | #include <__memory/allocator_traits.h> |
| ... | @@ -28,11 +30,9 @@ | ... | @@ -28,11 +30,9 @@ |
| 28 | #include <__type_traits/integral_constant.h> | 30 | #include <__type_traits/integral_constant.h> |
| 29 | #include <__type_traits/is_nothrow_assignable.h> | 31 | #include <__type_traits/is_nothrow_assignable.h> |
| 30 | #include <__type_traits/is_nothrow_constructible.h> | 32 | #include <__type_traits/is_nothrow_constructible.h> |
| 31 | #include <__type_traits/is_replaceable.h> | ||
| 32 | #include <__type_traits/is_swappable.h> | 33 | #include <__type_traits/is_swappable.h> |
| 33 | #include <__type_traits/is_trivially_destructible.h> | 34 | #include <__type_traits/is_trivially_destructible.h> |
| 34 | #include <__type_traits/is_trivially_relocatable.h> | 35 | #include <__type_traits/is_trivially_relocatable.h> |
| 35 | #include <__type_traits/remove_reference.h> | ||
| 36 | #include <__utility/forward.h> | 36 | #include <__utility/forward.h> |
| 37 | #include <__utility/move.h> | 37 | #include <__utility/move.h> |
| 38 | 38 | ||
| ... | @@ -45,25 +45,430 @@ _LIBCPP_PUSH_MACROS | ... | @@ -45,25 +45,430 @@ _LIBCPP_PUSH_MACROS |
| 45 | 45 | ||
| 46 | _LIBCPP_BEGIN_NAMESPACE_STD | 46 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 47 | 47 | ||
| 48 | // __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_). | 48 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 49 | // It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __cap_). That allows | 49 | class __split_buffer; |
| 50 | // it to grow both in the front and back without having to move the data. | 50 | |
| 51 | template <class _SplitBuffer, class _Tp, class _Allocator> | ||
| 52 | class __split_buffer_pointer_layout { | ||
| 53 | protected: | ||
| 54 | using value_type = _Tp; | ||
| 55 | using allocator_type = _Allocator; | ||
| 56 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; | ||
| 57 | using reference = value_type&; | ||
| 58 | using const_reference = const value_type&; | ||
| 59 | using size_type = typename __alloc_traits::size_type; | ||
| 60 | using difference_type = typename __alloc_traits::difference_type; | ||
| 61 | using pointer = typename __alloc_traits::pointer; | ||
| 62 | using const_pointer = typename __alloc_traits::const_pointer; | ||
| 63 | using iterator = pointer; | ||
| 64 | using const_iterator = const_pointer; | ||
| 65 | using __sentinel_type _LIBCPP_NODEBUG = pointer; | ||
| 51 | 66 | ||
| 52 | template <class _Tp, class _Allocator = allocator<_Tp> > | ||
| 53 | struct __split_buffer { | ||
| 54 | public: | 67 | public: |
| 55 | using value_type = _Tp; | 68 | // Can't be defaulted due to _LIBCPP_COMPRESSED_PAIR not being an aggregate in C++03 and C++11. |
| 56 | using allocator_type = _Allocator; | 69 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer_pointer_layout() : __back_cap_(nullptr) {} |
| 57 | using __alloc_rr _LIBCPP_NODEBUG = __libcpp_remove_reference_t<allocator_type>; | 70 | |
| 58 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<__alloc_rr>; | 71 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 59 | using reference = value_type&; | 72 | _LIBCPP_HIDE_FROM_ABI explicit __split_buffer_pointer_layout(const allocator_type& __alloc) |
| 60 | using const_reference = const value_type&; | 73 | : __back_cap_(nullptr), __alloc_(__alloc) {} |
| 61 | using size_type = typename __alloc_traits::size_type; | 74 | |
| 62 | using difference_type = typename __alloc_traits::difference_type; | 75 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __front_cap() _NOEXCEPT { return __front_cap_; } |
| 63 | using pointer = typename __alloc_traits::pointer; | 76 | |
| 64 | using const_pointer = typename __alloc_traits::const_pointer; | 77 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer __front_cap() const _NOEXCEPT { |
| 65 | using iterator = pointer; | 78 | return __front_cap_; |
| 66 | using const_iterator = const_pointer; | 79 | } |
| 80 | |||
| 81 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer begin() _NOEXCEPT { return __begin_; } | ||
| 82 | |||
| 83 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer begin() const _NOEXCEPT { return __begin_; } | ||
| 84 | |||
| 85 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer end() _NOEXCEPT { return __end_; } | ||
| 86 | |||
| 87 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer end() const _NOEXCEPT { return __end_; } | ||
| 88 | |||
| 89 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { | ||
| 90 | return static_cast<size_type>(__end_ - __begin_); | ||
| 91 | } | ||
| 92 | |||
| 93 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __begin_ == __end_; } | ||
| 94 | |||
| 95 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { | ||
| 96 | return static_cast<size_type>(__back_cap_ - __front_cap_); | ||
| 97 | } | ||
| 98 | |||
| 99 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __get_allocator() _NOEXCEPT { return __alloc_; } | ||
| 100 | |||
| 101 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type const& __get_allocator() const _NOEXCEPT { | ||
| 102 | return __alloc_; | ||
| 103 | } | ||
| 104 | |||
| 105 | // Returns the sentinel object directly. Should be used in conjunction with automatic type deduction, | ||
| 106 | // not explicit types. | ||
| 107 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __sentinel_type __raw_sentinel() const _NOEXCEPT { | ||
| 108 | return __end_; | ||
| 109 | } | ||
| 110 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __sentinel_type __raw_capacity() const _NOEXCEPT { | ||
| 111 | return __back_cap_; | ||
| 112 | } | ||
| 113 | |||
| 114 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_data(pointer __new_first) _NOEXCEPT { | ||
| 115 | __front_cap_ = __new_first; | ||
| 116 | } | ||
| 117 | |||
| 118 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 119 | __set_valid_range(pointer __new_begin, pointer __new_end) _NOEXCEPT { | ||
| 120 | __begin_ = __new_begin; | ||
| 121 | __end_ = __new_end; | ||
| 122 | } | ||
| 123 | |||
| 124 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 125 | __set_valid_range(pointer __new_begin, size_type __new_size) _NOEXCEPT { | ||
| 126 | __begin_ = __new_begin; | ||
| 127 | __end_ = __begin_ + __new_size; | ||
| 128 | } | ||
| 129 | |||
| 130 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_sentinel(pointer __new_end) _NOEXCEPT { | ||
| 131 | _LIBCPP_ASSERT_INTERNAL(__front_cap_ <= __new_end, "__new_end cannot precede __front_cap_"); | ||
| 132 | __end_ = __new_end; | ||
| 133 | } | ||
| 134 | |||
| 135 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_sentinel(size_type __new_size) _NOEXCEPT { | ||
| 136 | __end_ = __begin_ + __new_size; | ||
| 137 | } | ||
| 138 | |||
| 139 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_capacity(size_type __new_capacity) _NOEXCEPT { | ||
| 140 | __back_cap_ = __front_cap_ + __new_capacity; | ||
| 141 | } | ||
| 142 | |||
| 143 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_capacity(pointer __new_capacity) _NOEXCEPT { | ||
| 144 | __back_cap_ = __new_capacity; | ||
| 145 | } | ||
| 146 | |||
| 147 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const _NOEXCEPT { | ||
| 148 | return static_cast<size_type>(__begin_ - __front_cap_); | ||
| 149 | } | ||
| 150 | |||
| 151 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const _NOEXCEPT { | ||
| 152 | return static_cast<size_type>(__back_cap_ - __end_); | ||
| 153 | } | ||
| 154 | |||
| 155 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { return *(__end_ - 1); } | ||
| 156 | |||
| 157 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { return *(__end_ - 1); } | ||
| 158 | |||
| 159 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_without_allocator( | ||
| 160 | __split_buffer_pointer_layout<__split_buffer<value_type, allocator_type, __split_buffer_pointer_layout>, | ||
| 161 | value_type, | ||
| 162 | allocator_type>& __other) _NOEXCEPT { | ||
| 163 | std::swap(__front_cap_, __other.__front_cap_); | ||
| 164 | std::swap(__begin_, __other.__begin_); | ||
| 165 | std::swap(__back_cap_, __other.__back_cap_); | ||
| 166 | std::swap(__end_, __other.__end_); | ||
| 167 | } | ||
| 168 | |||
| 169 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer_pointer_layout& __other) _NOEXCEPT { | ||
| 170 | std::swap(__front_cap_, __other.__front_cap_); | ||
| 171 | std::swap(__begin_, __other.__begin_); | ||
| 172 | std::swap(__back_cap_, __other.__back_cap_); | ||
| 173 | std::swap(__end_, __other.__end_); | ||
| 174 | std::__swap_allocator(__alloc_, __other.__alloc_); | ||
| 175 | } | ||
| 176 | |||
| 177 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __reset() _NOEXCEPT { | ||
| 178 | __front_cap_ = nullptr; | ||
| 179 | __begin_ = nullptr; | ||
| 180 | __end_ = nullptr; | ||
| 181 | __back_cap_ = nullptr; | ||
| 182 | } | ||
| 183 | |||
| 184 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 185 | __copy_without_alloc(__split_buffer_pointer_layout const& __other) | ||
| 186 | _NOEXCEPT_(is_nothrow_copy_assignable<pointer>::value) { | ||
| 187 | __front_cap_ = __other.__front_cap_; | ||
| 188 | __begin_ = __other.__begin_; | ||
| 189 | __end_ = __other.__end_; | ||
| 190 | __back_cap_ = __other.__back_cap_; | ||
| 191 | } | ||
| 192 | |||
| 193 | private: | ||
| 194 | pointer __front_cap_ = nullptr; | ||
| 195 | pointer __begin_ = nullptr; | ||
| 196 | pointer __end_ = nullptr; | ||
| 197 | _LIBCPP_COMPRESSED_PAIR(pointer, __back_cap_, allocator_type, __alloc_); | ||
| 198 | |||
| 199 | template <class, class, class> | ||
| 200 | friend class __split_buffer_pointer_layout; | ||
| 201 | }; | ||
| 202 | |||
| 203 | template <class _SplitBuffer, class _Tp, class _Allocator> | ||
| 204 | class __split_buffer_size_layout { | ||
| 205 | protected: | ||
| 206 | using value_type = _Tp; | ||
| 207 | using allocator_type = _Allocator; | ||
| 208 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; | ||
| 209 | using reference = value_type&; | ||
| 210 | using const_reference = const value_type&; | ||
| 211 | using size_type = typename __alloc_traits::size_type; | ||
| 212 | using difference_type = typename __alloc_traits::difference_type; | ||
| 213 | using pointer = typename __alloc_traits::pointer; | ||
| 214 | using const_pointer = typename __alloc_traits::const_pointer; | ||
| 215 | using iterator = pointer; | ||
| 216 | using const_iterator = const_pointer; | ||
| 217 | using __sentinel_type _LIBCPP_NODEBUG = size_type; | ||
| 218 | |||
| 219 | public: | ||
| 220 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer_size_layout() = default; | ||
| 221 | |||
| 222 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer_size_layout(const allocator_type& __alloc) | ||
| 223 | : __alloc_(__alloc) {} | ||
| 224 | |||
| 225 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __front_cap() _NOEXCEPT { return __front_cap_; } | ||
| 226 | |||
| 227 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer __front_cap() const _NOEXCEPT { | ||
| 228 | return __front_cap_; | ||
| 229 | } | ||
| 230 | |||
| 231 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer begin() _NOEXCEPT { return __begin_; } | ||
| 232 | |||
| 233 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer begin() const _NOEXCEPT { return __begin_; } | ||
| 234 | |||
| 235 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer end() _NOEXCEPT { return __begin_ + __size_; } | ||
| 236 | |||
| 237 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer end() const _NOEXCEPT { return __begin_ + __size_; } | ||
| 238 | |||
| 239 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } | ||
| 240 | |||
| 241 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; } | ||
| 242 | |||
| 243 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { return __cap_; } | ||
| 244 | |||
| 245 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __get_allocator() _NOEXCEPT { return __alloc_; } | ||
| 246 | |||
| 247 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type const& __get_allocator() const _NOEXCEPT { | ||
| 248 | return __alloc_; | ||
| 249 | } | ||
| 250 | |||
| 251 | // Returns the sentinel object directly. Should be used in conjunction with automatic type deduction, | ||
| 252 | // not explicit types. | ||
| 253 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __sentinel_type __raw_sentinel() const _NOEXCEPT { | ||
| 254 | return __size_; | ||
| 255 | } | ||
| 256 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __sentinel_type __raw_capacity() const _NOEXCEPT { | ||
| 257 | return __cap_; | ||
| 258 | } | ||
| 259 | |||
| 260 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_data(pointer __new_first) _NOEXCEPT { | ||
| 261 | __front_cap_ = __new_first; | ||
| 262 | } | ||
| 263 | |||
| 264 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 265 | __set_valid_range(pointer __new_begin, pointer __new_end) _NOEXCEPT { | ||
| 266 | // Size-based __split_buffers track their size directly: we need to explicitly update the size | ||
| 267 | // when the front is adjusted. | ||
| 268 | __size_ -= __new_begin - __begin_; | ||
| 269 | __begin_ = __new_begin; | ||
| 270 | __set_sentinel(__new_end); | ||
| 271 | } | ||
| 272 | |||
| 273 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 274 | __set_valid_range(pointer __new_begin, size_type __new_size) _NOEXCEPT { | ||
| 275 | // Size-based __split_buffers track their size directly: we need to explicitly update the size | ||
| 276 | // when the front is adjusted. | ||
| 277 | __size_ -= __new_begin - __begin_; | ||
| 278 | __begin_ = __new_begin; | ||
| 279 | __set_sentinel(__new_size); | ||
| 280 | } | ||
| 281 | |||
| 282 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_sentinel(pointer __new_end) _NOEXCEPT { | ||
| 283 | _LIBCPP_ASSERT_INTERNAL(__front_cap_ <= __new_end, "__new_end cannot precede __front_cap_"); | ||
| 284 | __size_ += __new_end - end(); | ||
| 285 | } | ||
| 286 | |||
| 287 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_sentinel(size_type __new_size) _NOEXCEPT { | ||
| 288 | __size_ = __new_size; | ||
| 289 | } | ||
| 290 | |||
| 291 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_capacity(size_type __new_capacity) _NOEXCEPT { | ||
| 292 | __cap_ = __new_capacity; | ||
| 293 | } | ||
| 294 | |||
| 295 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_capacity(pointer __new_capacity) _NOEXCEPT { | ||
| 296 | __cap_ = __new_capacity - __begin_; | ||
| 297 | } | ||
| 298 | |||
| 299 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const _NOEXCEPT { | ||
| 300 | return static_cast<size_type>(__begin_ - __front_cap_); | ||
| 301 | } | ||
| 302 | |||
| 303 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const _NOEXCEPT { | ||
| 304 | // `__cap_ - __end_` tells us the total number of spares when in size-mode. We need to remove | ||
| 305 | // the __front_spare from the count. | ||
| 306 | return __cap_ - __size_ - __front_spare(); | ||
| 307 | } | ||
| 308 | |||
| 309 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { return __begin_[__size_ - 1]; } | ||
| 310 | |||
| 311 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { | ||
| 312 | return __begin_[__size_ - 1]; | ||
| 313 | } | ||
| 314 | |||
| 315 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_without_allocator( | ||
| 316 | __split_buffer_pointer_layout<__split_buffer<value_type, allocator_type, __split_buffer_pointer_layout>, | ||
| 317 | value_type, | ||
| 318 | allocator_type>& __other) _NOEXCEPT { | ||
| 319 | std::swap(__front_cap_, __other.__front_cap_); | ||
| 320 | std::swap(__begin_, __other.__begin_); | ||
| 321 | std::swap(__cap_, __other.__cap_); | ||
| 322 | std::swap(__size_, __other.__size_); | ||
| 323 | } | ||
| 324 | |||
| 325 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer_size_layout& __other) _NOEXCEPT { | ||
| 326 | std::swap(__front_cap_, __other.__front_cap_); | ||
| 327 | std::swap(__begin_, __other.__begin_); | ||
| 328 | std::swap(__cap_, __other.__cap_); | ||
| 329 | std::swap(__size_, __other.__size_); | ||
| 330 | std::__swap_allocator(__alloc_, __other.__alloc_); | ||
| 331 | } | ||
| 332 | |||
| 333 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __reset() _NOEXCEPT { | ||
| 334 | __front_cap_ = nullptr; | ||
| 335 | __begin_ = nullptr; | ||
| 336 | __size_ = 0; | ||
| 337 | __cap_ = 0; | ||
| 338 | } | ||
| 339 | |||
| 340 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 341 | __copy_without_alloc(__split_buffer_size_layout const& __other) | ||
| 342 | _NOEXCEPT_(is_nothrow_copy_assignable<pointer>::value) { | ||
| 343 | __front_cap_ = __other.__front_cap_; | ||
| 344 | __begin_ = __other.__begin_; | ||
| 345 | __cap_ = __other.__cap_; | ||
| 346 | __size_ = __other.__size_; | ||
| 347 | } | ||
| 348 | |||
| 349 | private: | ||
| 350 | pointer __front_cap_ = nullptr; | ||
| 351 | pointer __begin_ = nullptr; | ||
| 352 | size_type __size_ = 0; | ||
| 353 | size_type __cap_ = 0; | ||
| 354 | _LIBCPP_NO_UNIQUE_ADDRESS allocator_type __alloc_; | ||
| 355 | |||
| 356 | template <class, class, class> | ||
| 357 | friend class __split_buffer_size_layout; | ||
| 358 | }; | ||
| 359 | |||
| 360 | // `__split_buffer` is a contiguous array data structure. It may hold spare capacity at both ends of | ||
| 361 | // the sequence. This allows for a `__split_buffer` to grow from both the front and the back without | ||
| 362 | // relocating its contents until it runs out of room. This characteristic sets it apart from | ||
| 363 | // `std::vector`, which only holds spare capacity at its end. As such, `__split_buffer` is useful | ||
| 364 | // for implementing both `std::vector` and `std::deque`. | ||
| 365 | // | ||
| 366 | // The sequence is stored as a contiguous chunk of memory delimited by the following "pointers" (`o` denotes | ||
| 367 | // uninitialized memory and `x` denotes a valid object): | ||
| 368 | // | ||
| 369 | // |oooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoooooooooooooooooooooooo| | ||
| 370 | // ^ ^ ^ ^ | ||
| 371 | // __front_cap_ __begin_ __end_ __back_cap_ | ||
| 372 | // | ||
| 373 | // The range [__front_cap_, __begin_) contains uninitialized memory. It is referred to as the "front spare capacity". | ||
| 374 | // The range [__begin_, __end_) contains valid objects. It is referred to as the "valid range". | ||
| 375 | // The range [__end_, __back_cap_) contains uninitialized memory. It is referred to as the "back spare capacity". | ||
| 376 | // | ||
| 377 | // The layout of `__split_buffer` is determined by the `_Layout` template template parameter. This | ||
| 378 | // `_Layout` allows the above pointers to be stored as different representations, such as integer | ||
| 379 | // offsets. A layout class template must provide the following interface: | ||
| 380 | // | ||
| 381 | // template<class _Tp, class _Allocator, class _Layout> | ||
| 382 | // class __layout { | ||
| 383 | // protected: | ||
| 384 | // using value_type = _Tp; | ||
| 385 | // using allocator_type = _Allocator; | ||
| 386 | // using __alloc_traits = allocator_traits<allocator_type>; | ||
| 387 | // using reference = value_type&; | ||
| 388 | // using const_reference = const value_type&; | ||
| 389 | // using size_type = typename __alloc_traits::size_type; | ||
| 390 | // using difference_type = typename __alloc_traits::difference_type; | ||
| 391 | // using pointer = typename __alloc_traits::pointer; | ||
| 392 | // using const_pointer = typename __alloc_traits::const_pointer; | ||
| 393 | // using iterator = pointer; | ||
| 394 | // using const_iterator = const_pointer; | ||
| 395 | // using __sentinel_type = /* type that represents the layout's sentinel */; | ||
| 396 | // | ||
| 397 | // public: | ||
| 398 | // __layout() = default; | ||
| 399 | // explicit __layout(const allocator_type&); | ||
| 400 | // | ||
| 401 | // pointer __front_cap(); | ||
| 402 | // const_pointer __front_cap() const; | ||
| 403 | // | ||
| 404 | // pointer begin(); | ||
| 405 | // const_pointer begin() const; | ||
| 406 | // | ||
| 407 | // pointer end(); | ||
| 408 | // pointer end() const; | ||
| 409 | // | ||
| 410 | // size_type size() const; | ||
| 411 | // bool empty() const; | ||
| 412 | // size_type capacity() const; | ||
| 413 | // | ||
| 414 | // allocator_type& __get_allocator(); | ||
| 415 | // allocator_type const& __get_allocator() const; | ||
| 416 | // | ||
| 417 | // __sentinel_type __raw_sentinel() const; | ||
| 418 | // __sentinel_type __raw_capacity() const; | ||
| 419 | // | ||
| 420 | // void __set_data(pointer); | ||
| 421 | // void __set_valid_range(pointer __begin, pointer __end); | ||
| 422 | // void __set_valid_range(pointer __begin, size_type __size); | ||
| 423 | // void __set_sentinel(pointer __end); | ||
| 424 | // void __set_sentinel(size_type __size); | ||
| 425 | // | ||
| 426 | // void __set_capacity(size_type __capacity); | ||
| 427 | // void __set_capacity(pointer __capacity); | ||
| 428 | // | ||
| 429 | // size_type __front_spare() const; | ||
| 430 | // size_type __back_spare() const; | ||
| 431 | // | ||
| 432 | // reference back(); | ||
| 433 | // const_reference back() const; | ||
| 434 | // | ||
| 435 | // template<class _OtherLayout> | ||
| 436 | // void __swap_without_allocator(_OtherLayout&); | ||
| 437 | // void swap(__layout&); | ||
| 438 | // | ||
| 439 | // void __reset(); | ||
| 440 | // void __copy_without_alloc(__layout const&); | ||
| 441 | // }; | ||
| 442 | // | ||
| 443 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> | ||
| 444 | class __split_buffer : _Layout<__split_buffer<_Tp, _Allocator, _Layout>, _Tp, _Allocator> { | ||
| 445 | using __base_type _LIBCPP_NODEBUG = _Layout<__split_buffer<_Tp, _Allocator, _Layout>, _Tp, _Allocator>; | ||
| 446 | |||
| 447 | public: | ||
| 448 | using __base_type::__back_spare; | ||
| 449 | using __base_type::__copy_without_alloc; | ||
| 450 | using __base_type::__front_cap; | ||
| 451 | using __base_type::__front_spare; | ||
| 452 | using __base_type::__get_allocator; | ||
| 453 | using __base_type::__raw_capacity; | ||
| 454 | using __base_type::__raw_sentinel; | ||
| 455 | using __base_type::__reset; | ||
| 456 | using __base_type::__set_capacity; | ||
| 457 | using __base_type::__set_data; | ||
| 458 | using __base_type::__set_sentinel; | ||
| 459 | using __base_type::__set_valid_range; | ||
| 460 | |||
| 461 | using typename __base_type::__alloc_traits; | ||
| 462 | using typename __base_type::allocator_type; | ||
| 463 | using typename __base_type::const_iterator; | ||
| 464 | using typename __base_type::const_pointer; | ||
| 465 | using typename __base_type::const_reference; | ||
| 466 | using typename __base_type::difference_type; | ||
| 467 | using typename __base_type::iterator; | ||
| 468 | using typename __base_type::pointer; | ||
| 469 | using typename __base_type::reference; | ||
| 470 | using typename __base_type::size_type; | ||
| 471 | using typename __base_type::value_type; | ||
| 67 | 472 | ||
| 68 | // A __split_buffer contains the following members which may be trivially relocatable: | 473 | // A __split_buffer contains the following members which may be trivially relocatable: |
| 69 | // - pointer: may be trivially relocatable, so it's checked | 474 | // - pointer: may be trivially relocatable, so it's checked |
| ... | @@ -73,36 +478,24 @@ public: | ... | @@ -73,36 +478,24 @@ public: |
| 73 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | 478 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 74 | __split_buffer, | 479 | __split_buffer, |
| 75 | void>; | 480 | void>; |
| 76 | using __replaceable _LIBCPP_NODEBUG = | ||
| 77 | __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value, | ||
| 78 | __split_buffer, | ||
| 79 | void>; | ||
| 80 | |||
| 81 | pointer __first_; | ||
| 82 | pointer __begin_; | ||
| 83 | pointer __end_; | ||
| 84 | _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_); | ||
| 85 | 481 | ||
| 86 | __split_buffer(const __split_buffer&) = delete; | 482 | __split_buffer(const __split_buffer&) = delete; |
| 87 | __split_buffer& operator=(const __split_buffer&) = delete; | 483 | __split_buffer& operator=(const __split_buffer&) = delete; |
| 88 | 484 | ||
| 89 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer() | 485 | _LIBCPP_HIDE_FROM_ABI __split_buffer() = default; |
| 90 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | ||
| 91 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) {} | ||
| 92 | 486 | ||
| 93 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a) | 487 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(allocator_type& __a) : __base_type(__a) {} |
| 94 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {} | ||
| 95 | 488 | ||
| 96 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a) | 489 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const allocator_type& __a) |
| 97 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {} | 490 | : __base_type(__a) {} |
| 98 | 491 | ||
| 99 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | 492 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
| 100 | __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); | 493 | __split_buffer(size_type __cap, size_type __start, allocator_type& __a); |
| 101 | 494 | ||
| 102 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c) | 495 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c) |
| 103 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | 496 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
| 104 | 497 | ||
| 105 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); | 498 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const allocator_type& __a); |
| 106 | 499 | ||
| 107 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c) | 500 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c) |
| 108 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && | 501 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && |
| ... | @@ -111,36 +504,16 @@ public: | ... | @@ -111,36 +504,16 @@ public: |
| 111 | 504 | ||
| 112 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer(); | 505 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer(); |
| 113 | 506 | ||
| 114 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; } | 507 | using __base_type::back; |
| 115 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; } | 508 | using __base_type::begin; |
| 116 | 509 | using __base_type::capacity; | |
| 117 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __end_; } | 510 | using __base_type::empty; |
| 118 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __end_; } | 511 | using __base_type::end; |
| 119 | 512 | using __base_type::size; | |
| 120 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __destruct_at_end(__begin_); } | ||
| 121 | 513 | ||
| 122 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const { | 514 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __destruct_at_end(begin()); } |
| 123 | return static_cast<size_type>(__end_ - __begin_); | 515 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *begin(); } |
| 124 | } | 516 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const { return *begin(); } |
| 125 | |||
| 126 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; } | ||
| 127 | |||
| 128 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const { | ||
| 129 | return static_cast<size_type>(__cap_ - __first_); | ||
| 130 | } | ||
| 131 | |||
| 132 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const { | ||
| 133 | return static_cast<size_type>(__begin_ - __first_); | ||
| 134 | } | ||
| 135 | |||
| 136 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const { | ||
| 137 | return static_cast<size_type>(__cap_ - __end_); | ||
| 138 | } | ||
| 139 | |||
| 140 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; } | ||
| 141 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const { return *__begin_; } | ||
| 142 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); } | ||
| 143 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); } | ||
| 144 | 517 | ||
| 145 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; | 518 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; |
| 146 | 519 | ||
| ... | @@ -149,8 +522,8 @@ public: | ... | @@ -149,8 +522,8 @@ public: |
| 149 | template <class... _Args> | 522 | template <class... _Args> |
| 150 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); | 523 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); |
| 151 | 524 | ||
| 152 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() { __destruct_at_begin(__begin_ + 1); } | 525 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() { __destruct_at_begin(begin() + 1); } |
| 153 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() { __destruct_at_end(__end_ - 1); } | 526 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() { __destruct_at_end(end() - 1); } |
| 154 | 527 | ||
| 155 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); | 528 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); |
| 156 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); | 529 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); |
| ... | @@ -182,244 +555,242 @@ public: | ... | @@ -182,244 +555,242 @@ public: |
| 182 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; | 555 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; |
| 183 | 556 | ||
| 184 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x) | 557 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x) |
| 185 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>); | 558 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 559 | |||
| 560 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const { | ||
| 561 | if (__front_cap() == nullptr) { | ||
| 562 | if (begin() != nullptr) | ||
| 563 | return false; | ||
| 564 | |||
| 565 | if (!empty()) | ||
| 566 | return false; | ||
| 567 | |||
| 568 | if (capacity() != 0) | ||
| 569 | return false; | ||
| 570 | |||
| 571 | return true; | ||
| 572 | } else { | ||
| 573 | if (begin() < __front_cap()) | ||
| 574 | return false; | ||
| 186 | 575 | ||
| 187 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | 576 | if (capacity() < size()) |
| 577 | return false; | ||
| 578 | |||
| 579 | if (end() < begin()) | ||
| 580 | return false; | ||
| 581 | |||
| 582 | return true; | ||
| 583 | } | ||
| 584 | } | ||
| 585 | |||
| 586 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 587 | __swap_without_allocator(__split_buffer<value_type, allocator_type, _Layout>& __other) _NOEXCEPT { | ||
| 588 | __base_type::__swap_without_allocator(__other); | ||
| 589 | } | ||
| 188 | 590 | ||
| 189 | private: | 591 | private: |
| 190 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type) | 592 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type) |
| 191 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | 593 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { |
| 192 | __alloc_ = std::move(__c.__alloc_); | 594 | __get_allocator() = std::move(__c.__get_allocator()); |
| 193 | } | 595 | } |
| 194 | 596 | ||
| 195 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} | 597 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} |
| 196 | 598 | ||
| 197 | struct _ConstructTransaction { | 599 | struct _ConstructTransaction { |
| 198 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | 600 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 199 | _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT | 601 | _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(__split_buffer* __parent, pointer __p, size_type __n) _NOEXCEPT |
| 200 | : __pos_(*__p), | 602 | : __pos_(__p), |
| 201 | __end_(*__p + __n), | 603 | __end_(__p + __n), |
| 202 | __dest_(__p) {} | 604 | __parent_(__parent) {} |
| 203 | 605 | ||
| 204 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { *__dest_ = __pos_; } | 606 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { __parent_->__set_sentinel(__pos_); } |
| 205 | 607 | ||
| 206 | pointer __pos_; | 608 | pointer __pos_; |
| 207 | const pointer __end_; | 609 | const pointer __end_; |
| 208 | 610 | ||
| 209 | private: | 611 | private: |
| 210 | pointer* __dest_; | 612 | __split_buffer* __parent_; |
| 211 | }; | 613 | }; |
| 212 | }; | ||
| 213 | 614 | ||
| 214 | template <class _Tp, class _Allocator> | 615 | template <class _T2, class _A2, template <class, class, class> class _L2> |
| 215 | _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants() const { | 616 | friend class __split_buffer; |
| 216 | if (__first_ == nullptr) { | 617 | }; |
| 217 | if (__begin_ != nullptr) | ||
| 218 | return false; | ||
| 219 | if (__end_ != nullptr) | ||
| 220 | return false; | ||
| 221 | if (__cap_ != nullptr) | ||
| 222 | return false; | ||
| 223 | } else { | ||
| 224 | if (__begin_ < __first_) | ||
| 225 | return false; | ||
| 226 | if (__end_ < __begin_) | ||
| 227 | return false; | ||
| 228 | if (__cap_ < __end_) | ||
| 229 | return false; | ||
| 230 | } | ||
| 231 | return true; | ||
| 232 | } | ||
| 233 | 618 | ||
| 234 | // Default constructs __n objects starting at __end_ | 619 | // Default constructs __n objects starting at `end()` |
| 235 | // throws if construction throws | 620 | // throws if construction throws |
| 236 | // Precondition: __n > 0 | 621 | // Precondition: __n > 0 |
| 237 | // Precondition: size() + __n <= capacity() | 622 | // Precondition: size() + __n <= capacity() |
| 238 | // Postcondition: size() == size() + __n | 623 | // Postcondition: size() == size() + __n |
| 239 | template <class _Tp, class _Allocator> | 624 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 240 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) { | 625 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::__construct_at_end(size_type __n) { |
| 241 | _ConstructTransaction __tx(std::addressof(this->__end_), __n); | 626 | _ConstructTransaction __tx(this, end(), __n); |
| 242 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { | 627 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { |
| 243 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_)); | 628 | __alloc_traits::construct(__get_allocator(), std::__to_address(__tx.__pos_)); |
| 244 | } | 629 | } |
| 245 | } | 630 | } |
| 246 | 631 | ||
| 247 | // Copy constructs __n objects starting at __end_ from __x | 632 | // Copy constructs __n objects starting at `end()` from __x |
| 248 | // throws if construction throws | 633 | // throws if construction throws |
| 249 | // Precondition: __n > 0 | 634 | // Precondition: __n > 0 |
| 250 | // Precondition: size() + __n <= capacity() | 635 | // Precondition: size() + __n <= capacity() |
| 251 | // Postcondition: size() == old size() + __n | 636 | // Postcondition: size() == old size() + __n |
| 252 | // Postcondition: [i] == __x for all i in [size() - __n, __n) | 637 | // Postcondition: [i] == __x for all i in [size() - __n, __n) |
| 253 | template <class _Tp, class _Allocator> | 638 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 254 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 639 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 255 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { | 640 | __split_buffer<_Tp, _Allocator, _Layout>::__construct_at_end(size_type __n, const_reference __x) { |
| 256 | _ConstructTransaction __tx(std::addressof(this->__end_), __n); | 641 | _ConstructTransaction __tx(this, end(), __n); |
| 257 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { | 642 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { |
| 258 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x); | 643 | __alloc_traits::construct(__get_allocator(), std::__to_address(__tx.__pos_), __x); |
| 259 | } | 644 | } |
| 260 | } | 645 | } |
| 261 | 646 | ||
| 262 | template <class _Tp, class _Allocator> | 647 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 263 | template <class _Iterator, class _Sentinel> | 648 | template <class _Iterator, class _Sentinel> |
| 264 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 649 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 265 | __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) { | 650 | __split_buffer<_Tp, _Allocator, _Layout>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) { |
| 266 | __alloc_rr& __a = __alloc_; | 651 | allocator_type& __a = __get_allocator(); |
| 267 | for (; __first != __last; ++__first) { | 652 | for (; __first != __last; ++__first) { |
| 268 | if (__end_ == __cap_) { | 653 | if (__back_spare() == 0) { |
| 269 | size_type __old_cap = __cap_ - __first_; | 654 | size_type __old_cap = capacity(); |
| 270 | size_type __new_cap = std::max<size_type>(2 * __old_cap, 8); | 655 | size_type __new_cap = std::max<size_type>(2 * __old_cap, 8); |
| 271 | __split_buffer __buf(__new_cap, 0, __a); | 656 | __split_buffer __buf(__new_cap, 0, __a); |
| 272 | for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_) | 657 | pointer __buf_end = __buf.end(); |
| 273 | __alloc_traits::construct(__buf.__alloc_, std::__to_address(__buf.__end_), std::move(*__p)); | 658 | pointer __end = end(); |
| 659 | for (pointer __p = begin(); __p != __end; ++__p) { | ||
| 660 | __alloc_traits::construct(__buf.__get_allocator(), std::__to_address(__buf_end), std::move(*__p)); | ||
| 661 | __buf.__set_sentinel(++__buf_end); | ||
| 662 | } | ||
| 274 | swap(__buf); | 663 | swap(__buf); |
| 275 | } | 664 | } |
| 276 | __alloc_traits::construct(__a, std::__to_address(this->__end_), *__first); | 665 | |
| 277 | ++this->__end_; | 666 | __alloc_traits::construct(__a, std::__to_address(end()), *__first); |
| 667 | __set_sentinel(size() + 1); | ||
| 278 | } | 668 | } |
| 279 | } | 669 | } |
| 280 | template <class _Tp, class _Allocator> | 670 | |
| 671 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> | ||
| 281 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | 672 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > |
| 282 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 673 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 283 | __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) { | 674 | __split_buffer<_Tp, _Allocator, _Layout>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) { |
| 284 | __construct_at_end_with_size(__first, std::distance(__first, __last)); | 675 | __construct_at_end_with_size(__first, std::distance(__first, __last)); |
| 285 | } | 676 | } |
| 286 | 677 | ||
| 287 | template <class _Tp, class _Allocator> | 678 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 288 | template <class _ForwardIterator> | 679 | template <class _ForwardIterator> |
| 289 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 680 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 290 | __split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) { | 681 | __split_buffer<_Tp, _Allocator, _Layout>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) { |
| 291 | _ConstructTransaction __tx(std::addressof(this->__end_), __n); | 682 | _ConstructTransaction __tx(this, end(), __n); |
| 292 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) { | 683 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) { |
| 293 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first); | 684 | __alloc_traits::construct(__get_allocator(), std::__to_address(__tx.__pos_), *__first); |
| 294 | } | 685 | } |
| 295 | } | 686 | } |
| 296 | 687 | ||
| 297 | template <class _Tp, class _Allocator> | 688 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 298 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void | 689 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void |
| 299 | __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { | 690 | __split_buffer<_Tp, _Allocator, _Layout>::__destruct_at_begin(pointer __new_begin, false_type) { |
| 300 | while (__begin_ != __new_begin) | 691 | pointer __begin = begin(); |
| 301 | __alloc_traits::destroy(__alloc_, std::__to_address(__begin_++)); | 692 | // Updating begin at every iteration is unnecessary because destruction can't throw. |
| 693 | while (__begin != __new_begin) | ||
| 694 | __alloc_traits::destroy(__get_allocator(), std::__to_address(__begin++)); | ||
| 695 | __set_valid_range(__begin, end()); | ||
| 302 | } | 696 | } |
| 303 | 697 | ||
| 304 | template <class _Tp, class _Allocator> | 698 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 305 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void | 699 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void |
| 306 | __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) { | 700 | __split_buffer<_Tp, _Allocator, _Layout>::__destruct_at_begin(pointer __new_begin, true_type) { |
| 307 | __begin_ = __new_begin; | 701 | __set_valid_range(__new_begin, end()); |
| 308 | } | ||
| 309 | |||
| 310 | template <class _Tp, class _Allocator> | ||
| 311 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void | ||
| 312 | __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { | ||
| 313 | while (__new_last != __end_) | ||
| 314 | __alloc_traits::destroy(__alloc_, std::__to_address(--__end_)); | ||
| 315 | } | 702 | } |
| 316 | 703 | ||
| 317 | template <class _Tp, class _Allocator> | 704 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 318 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void | 705 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void |
| 319 | __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT { | 706 | __split_buffer<_Tp, _Allocator, _Layout>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { |
| 320 | __end_ = __new_last; | 707 | pointer __end = end(); |
| 708 | // Updating begin at every iteration is unnecessary because destruction can't throw. | ||
| 709 | while (__new_last != __end) | ||
| 710 | __alloc_traits::destroy(__get_allocator(), std::__to_address(--__end)); | ||
| 711 | __set_sentinel(__end); | ||
| 321 | } | 712 | } |
| 322 | 713 | ||
| 323 | template <class _Tp, class _Allocator> | 714 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 324 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | 715 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 325 | __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) | 716 | __split_buffer<_Tp, _Allocator, _Layout>::__split_buffer(size_type __cap, size_type __start, allocator_type& __a) |
| 326 | : __cap_(nullptr), __alloc_(__a) { | 717 | : __base_type(__a) { |
| 327 | if (__cap == 0) { | 718 | _LIBCPP_ASSERT_INTERNAL(__cap >= __start, "can't have a start point outside the capacity"); |
| 328 | __first_ = nullptr; | 719 | if (__cap > 0) { |
| 329 | } else { | 720 | auto __allocation = std::__allocate_at_least(__get_allocator(), __cap); |
| 330 | auto __allocation = std::__allocate_at_least(__alloc_, __cap); | 721 | __set_data(__allocation.ptr); |
| 331 | __first_ = __allocation.ptr; | 722 | __cap = __allocation.count; |
| 332 | __cap = __allocation.count; | ||
| 333 | } | 723 | } |
| 334 | __begin_ = __end_ = __first_ + __start; | 724 | |
| 335 | __cap_ = __first_ + __cap; | 725 | pointer __begin = __front_cap() + __start; |
| 726 | __set_valid_range(__begin, __begin); | ||
| 727 | __set_capacity(__cap); | ||
| 336 | } | 728 | } |
| 337 | 729 | ||
| 338 | template <class _Tp, class _Allocator> | 730 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 339 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::~__split_buffer() { | 731 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator, _Layout>::~__split_buffer() { |
| 340 | clear(); | 732 | clear(); |
| 341 | if (__first_) | 733 | if (__front_cap()) |
| 342 | __alloc_traits::deallocate(__alloc_, __first_, capacity()); | 734 | __alloc_traits::deallocate(__get_allocator(), __front_cap(), capacity()); |
| 343 | } | 735 | } |
| 344 | 736 | ||
| 345 | template <class _Tp, class _Allocator> | 737 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 346 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) | 738 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator, _Layout>::__split_buffer(__split_buffer&& __c) |
| 347 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | 739 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
| 348 | : __first_(std::move(__c.__first_)), | 740 | : __base_type(std::move(__c)) { |
| 349 | __begin_(std::move(__c.__begin_)), | 741 | __c.__reset(); |
| 350 | __end_(std::move(__c.__end_)), | ||
| 351 | __cap_(std::move(__c.__cap_)), | ||
| 352 | __alloc_(std::move(__c.__alloc_)) { | ||
| 353 | __c.__first_ = nullptr; | ||
| 354 | __c.__begin_ = nullptr; | ||
| 355 | __c.__end_ = nullptr; | ||
| 356 | __c.__cap_ = nullptr; | ||
| 357 | } | 742 | } |
| 358 | 743 | ||
| 359 | template <class _Tp, class _Allocator> | 744 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 360 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | 745 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 361 | __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) | 746 | __split_buffer<_Tp, _Allocator, _Layout>::__split_buffer(__split_buffer&& __c, const allocator_type& __a) |
| 362 | : __cap_(nullptr), __alloc_(__a) { | 747 | : __base_type(__a) { |
| 363 | if (__a == __c.__alloc_) { | 748 | if (__a == __c.__get_allocator()) { |
| 364 | __first_ = __c.__first_; | 749 | __set_data(__c.__front_cap()); |
| 365 | __begin_ = __c.__begin_; | 750 | __set_valid_range(__c.begin(), __c.end()); |
| 366 | __end_ = __c.__end_; | 751 | __set_capacity(__c.capacity()); |
| 367 | __cap_ = __c.__cap_; | 752 | __c.__reset(); |
| 368 | __c.__first_ = nullptr; | ||
| 369 | __c.__begin_ = nullptr; | ||
| 370 | __c.__end_ = nullptr; | ||
| 371 | __c.__cap_ = nullptr; | ||
| 372 | } else { | 753 | } else { |
| 373 | auto __allocation = std::__allocate_at_least(__alloc_, __c.size()); | 754 | auto __allocation = std::__allocate_at_least(__get_allocator(), __c.size()); |
| 374 | __first_ = __allocation.ptr; | 755 | __set_data(__allocation.ptr); |
| 375 | __begin_ = __end_ = __first_; | 756 | __set_valid_range(__front_cap(), __front_cap()); |
| 376 | __cap_ = __first_ + __allocation.count; | 757 | __set_capacity(__allocation.count); |
| 377 | typedef move_iterator<iterator> _Ip; | 758 | typedef move_iterator<iterator> _Ip; |
| 378 | __construct_at_end(_Ip(__c.begin()), _Ip(__c.end())); | 759 | __construct_at_end(_Ip(__c.begin()), _Ip(__c.end())); |
| 379 | } | 760 | } |
| 380 | } | 761 | } |
| 381 | 762 | ||
| 382 | template <class _Tp, class _Allocator> | 763 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 383 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>& | 764 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator, _Layout>& |
| 384 | __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) | 765 | __split_buffer<_Tp, _Allocator, _Layout>::operator=(__split_buffer&& __c) |
| 385 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && | 766 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && |
| 386 | is_nothrow_move_assignable<allocator_type>::value) || | 767 | is_nothrow_move_assignable<allocator_type>::value) || |
| 387 | !__alloc_traits::propagate_on_container_move_assignment::value) { | 768 | !__alloc_traits::propagate_on_container_move_assignment::value) { |
| 388 | clear(); | 769 | clear(); |
| 389 | shrink_to_fit(); | 770 | shrink_to_fit(); |
| 390 | __first_ = __c.__first_; | 771 | __copy_without_alloc(__c); |
| 391 | __begin_ = __c.__begin_; | ||
| 392 | __end_ = __c.__end_; | ||
| 393 | __cap_ = __c.__cap_; | ||
| 394 | __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | 772 | __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); |
| 395 | __c.__first_ = __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr; | 773 | __c.__reset(); |
| 396 | return *this; | 774 | return *this; |
| 397 | } | 775 | } |
| 398 | 776 | ||
| 399 | template <class _Tp, class _Allocator> | 777 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 400 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) | 778 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::swap(__split_buffer& __x) |
| 401 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>) { | 779 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) { |
| 402 | std::swap(__first_, __x.__first_); | 780 | __base_type::swap(__x); |
| 403 | std::swap(__begin_, __x.__begin_); | ||
| 404 | std::swap(__end_, __x.__end_); | ||
| 405 | std::swap(__cap_, __x.__cap_); | ||
| 406 | std::__swap_allocator(__alloc_, __x.__alloc_); | ||
| 407 | } | 781 | } |
| 408 | 782 | ||
| 409 | template <class _Tp, class _Allocator> | 783 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 410 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { | 784 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::shrink_to_fit() _NOEXCEPT { |
| 411 | if (capacity() > size()) { | 785 | if (capacity() > size()) { |
| 412 | #if _LIBCPP_HAS_EXCEPTIONS | 786 | #if _LIBCPP_HAS_EXCEPTIONS |
| 413 | try { | 787 | try { |
| 414 | #endif // _LIBCPP_HAS_EXCEPTIONS | 788 | #endif // _LIBCPP_HAS_EXCEPTIONS |
| 415 | __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc_); | 789 | __split_buffer<value_type, allocator_type, _Layout> __t(size(), 0, __get_allocator()); |
| 416 | if (__t.capacity() < capacity()) { | 790 | if (__t.capacity() < capacity()) { |
| 417 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | 791 | __t.__construct_at_end(move_iterator<pointer>(begin()), move_iterator<pointer>(end())); |
| 418 | __t.__end_ = __t.__begin_ + (__end_ - __begin_); | 792 | __t.__set_sentinel(size()); |
| 419 | std::swap(__first_, __t.__first_); | 793 | __swap_without_allocator(__t); |
| 420 | std::swap(__begin_, __t.__begin_); | ||
| 421 | std::swap(__end_, __t.__end_); | ||
| 422 | std::swap(__cap_, __t.__cap_); | ||
| 423 | } | 794 | } |
| 424 | #if _LIBCPP_HAS_EXCEPTIONS | 795 | #if _LIBCPP_HAS_EXCEPTIONS |
| 425 | } catch (...) { | 796 | } catch (...) { |
| ... | @@ -428,55 +799,56 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fi | ... | @@ -428,55 +799,56 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fi |
| 428 | } | 799 | } |
| 429 | } | 800 | } |
| 430 | 801 | ||
| 431 | template <class _Tp, class _Allocator> | 802 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 432 | template <class... _Args> | 803 | template <class... _Args> |
| 433 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front(_Args&&... __args) { | 804 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::emplace_front(_Args&&... __args) { |
| 434 | if (__begin_ == __first_) { | 805 | if (__front_spare() == 0) { |
| 435 | if (__end_ < __cap_) { | 806 | pointer __end = end(); |
| 436 | difference_type __d = __cap_ - __end_; | 807 | if (__back_spare() > 0) { |
| 808 | // The elements are pressed up against the front of the buffer: we need to move them back a | ||
| 809 | // little bit to make `emplace_front` have amortised O(1) complexity. | ||
| 810 | difference_type __d = __back_spare(); | ||
| 437 | __d = (__d + 1) / 2; | 811 | __d = (__d + 1) / 2; |
| 438 | __begin_ = std::move_backward(__begin_, __end_, __end_ + __d); | 812 | auto __new_end = __end + __d; |
| 439 | __end_ += __d; | 813 | __set_valid_range(std::move_backward(begin(), __end, __new_end), __new_end); |
| 440 | } else { | 814 | } else { |
| 441 | size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1); | 815 | size_type __c = std::max<size_type>(2 * capacity(), 1); |
| 442 | __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc_); | 816 | __split_buffer<value_type, allocator_type, _Layout> __t(__c, (__c + 3) / 4, __get_allocator()); |
| 443 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | 817 | __t.__construct_at_end(move_iterator<pointer>(begin()), move_iterator<pointer>(__end)); |
| 444 | std::swap(__first_, __t.__first_); | 818 | __base_type::__swap_without_allocator(__t); |
| 445 | std::swap(__begin_, __t.__begin_); | ||
| 446 | std::swap(__end_, __t.__end_); | ||
| 447 | std::swap(__cap_, __t.__cap_); | ||
| 448 | } | 819 | } |
| 449 | } | 820 | } |
| 450 | __alloc_traits::construct(__alloc_, std::__to_address(__begin_ - 1), std::forward<_Args>(__args)...); | 821 | |
| 451 | --__begin_; | 822 | __alloc_traits::construct(__get_allocator(), std::__to_address(begin() - 1), std::forward<_Args>(__args)...); |
| 823 | __set_valid_range(begin() - 1, size() + 1); | ||
| 452 | } | 824 | } |
| 453 | 825 | ||
| 454 | template <class _Tp, class _Allocator> | 826 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 455 | template <class... _Args> | 827 | template <class... _Args> |
| 456 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) { | 828 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator, _Layout>::emplace_back(_Args&&... __args) { |
| 457 | if (__end_ == __cap_) { | 829 | pointer __end = end(); |
| 458 | if (__begin_ > __first_) { | 830 | if (__back_spare() == 0) { |
| 459 | difference_type __d = __begin_ - __first_; | 831 | if (__front_spare() > 0) { |
| 832 | difference_type __d = __front_spare(); | ||
| 460 | __d = (__d + 1) / 2; | 833 | __d = (__d + 1) / 2; |
| 461 | __end_ = std::move(__begin_, __end_, __begin_ - __d); | 834 | __end = std::move(begin(), __end, begin() - __d); |
| 462 | __begin_ -= __d; | 835 | __set_valid_range(begin() - __d, __end); |
| 463 | } else { | 836 | } else { |
| 464 | size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1); | 837 | size_type __c = std::max<size_type>(2 * capacity(), 1); |
| 465 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc_); | 838 | __split_buffer<value_type, allocator_type, _Layout> __t(__c, __c / 4, __get_allocator()); |
| 466 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | 839 | __t.__construct_at_end(move_iterator<pointer>(begin()), move_iterator<pointer>(__end)); |
| 467 | std::swap(__first_, __t.__first_); | 840 | __base_type::__swap_without_allocator(__t); |
| 468 | std::swap(__begin_, __t.__begin_); | ||
| 469 | std::swap(__end_, __t.__end_); | ||
| 470 | std::swap(__cap_, __t.__cap_); | ||
| 471 | } | 841 | } |
| 472 | } | 842 | } |
| 473 | __alloc_traits::construct(__alloc_, std::__to_address(__end_), std::forward<_Args>(__args)...); | 843 | |
| 474 | ++__end_; | 844 | __alloc_traits::construct(__get_allocator(), std::__to_address(__end), std::forward<_Args>(__args)...); |
| 845 | __set_sentinel(++__end); | ||
| 475 | } | 846 | } |
| 476 | 847 | ||
| 477 | template <class _Tp, class _Allocator> | 848 | template <class _Tp, class _Allocator, template <class, class, class> class _Layout> |
| 478 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void | 849 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void |
| 479 | swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 850 | swap(__split_buffer<_Tp, _Allocator, _Layout>& __x, __split_buffer<_Tp, _Allocator, _Layout>& __y) |
| 851 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | ||
| 480 | __x.swap(__y); | 852 | __x.swap(__y); |
| 481 | } | 853 | } |
| 482 | 854 |
lib/libcxx/include/__stop_token/atomic_unique_lock.h+1-1| ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | // where State contains a lock bit and might contain other data, | 27 | // where State contains a lock bit and might contain other data, |
| 28 | // and LockedBit is the value of State when the lock bit is set, e.g 1 << 2 | 28 | // and LockedBit is the value of State when the lock bit is set, e.g 1 << 2 |
| 29 | template <class _State, _State _LockedBit> | 29 | template <class _State, _State _LockedBit> |
| 30 | class _LIBCPP_AVAILABILITY_SYNC __atomic_unique_lock { | 30 | class __atomic_unique_lock { |
| 31 | static_assert(std::__popcount(static_cast<unsigned long long>(_LockedBit)) == 1, | 31 | static_assert(std::__popcount(static_cast<unsigned long long>(_LockedBit)) == 1, |
| 32 | "LockedBit must be an integer where only one bit is set"); | 32 | "LockedBit must be an integer where only one bit is set"); |
| 33 | 33 |
lib/libcxx/include/__stop_token/stop_callback.h+2-2| ... | @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | 34 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS |
| 35 | 35 | ||
| 36 | template <class _Callback> | 36 | template <class _Callback> |
| 37 | class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base { | 37 | class stop_callback : private __stop_callback_base { |
| 38 | static_assert(invocable<_Callback>, | 38 | static_assert(invocable<_Callback>, |
| 39 | "Mandates: stop_callback is instantiated with an argument for the template parameter Callback that " | 39 | "Mandates: stop_callback is instantiated with an argument for the template parameter Callback that " |
| 40 | "satisfies invocable."); | 40 | "satisfies invocable."); |
| ... | @@ -91,7 +91,7 @@ private: | ... | @@ -91,7 +91,7 @@ private: |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | template <class _Callback> | 93 | template <class _Callback> |
| 94 | _LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, _Callback) -> stop_callback<_Callback>; | 94 | stop_callback(stop_token, _Callback) -> stop_callback<_Callback>; |
| 95 | 95 | ||
| 96 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | 96 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS |
| 97 | 97 |
lib/libcxx/include/__stop_token/stop_source.h+1-1| ... | @@ -30,7 +30,7 @@ struct nostopstate_t { | ... | @@ -30,7 +30,7 @@ struct nostopstate_t { |
| 30 | 30 | ||
| 31 | inline constexpr nostopstate_t nostopstate{}; | 31 | inline constexpr nostopstate_t nostopstate{}; |
| 32 | 32 | ||
| 33 | class _LIBCPP_AVAILABILITY_SYNC stop_source { | 33 | class stop_source { |
| 34 | public: | 34 | public: |
| 35 | _LIBCPP_HIDE_FROM_ABI stop_source() : __state_(new __stop_state()) { __state_->__increment_stop_source_counter(); } | 35 | _LIBCPP_HIDE_FROM_ABI stop_source() : __state_(new __stop_state()) { __state_->__increment_stop_source_counter(); } |
| 36 | 36 |
lib/libcxx/include/__stop_token/stop_state.h+4-4| ... | @@ -100,7 +100,7 @@ public: | ... | @@ -100,7 +100,7 @@ public: |
| 100 | return ((__curent_state & __stop_requested_bit) != 0) || ((__curent_state >> __stop_source_counter_shift) != 0); | 100 | return ((__curent_state & __stop_requested_bit) != 0) || ((__curent_state >> __stop_source_counter_shift) != 0); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __request_stop() noexcept { | 103 | _LIBCPP_HIDE_FROM_ABI bool __request_stop() noexcept { |
| 104 | auto __cb_list_lock = __try_lock_for_request_stop(); | 104 | auto __cb_list_lock = __try_lock_for_request_stop(); |
| 105 | if (!__cb_list_lock.__owns_lock()) { | 105 | if (!__cb_list_lock.__owns_lock()) { |
| 106 | return false; | 106 | return false; |
| ... | @@ -137,7 +137,7 @@ public: | ... | @@ -137,7 +137,7 @@ public: |
| 137 | return true; | 137 | return true; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __add_callback(__stop_callback_base* __cb) noexcept { | 140 | _LIBCPP_HIDE_FROM_ABI bool __add_callback(__stop_callback_base* __cb) noexcept { |
| 141 | // If it is already stop_requested. Do not try to request it again. | 141 | // If it is already stop_requested. Do not try to request it again. |
| 142 | const auto __give_up_trying_to_lock_condition = [__cb](__state_t __state) { | 142 | const auto __give_up_trying_to_lock_condition = [__cb](__state_t __state) { |
| 143 | if ((__state & __stop_requested_bit) != 0) { | 143 | if ((__state & __stop_requested_bit) != 0) { |
| ... | @@ -164,7 +164,7 @@ public: | ... | @@ -164,7 +164,7 @@ public: |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | // called by the destructor of stop_callback | 166 | // called by the destructor of stop_callback |
| 167 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __remove_callback(__stop_callback_base* __cb) noexcept { | 167 | _LIBCPP_HIDE_FROM_ABI void __remove_callback(__stop_callback_base* __cb) noexcept { |
| 168 | __callback_list_lock __cb_list_lock(__state_); | 168 | __callback_list_lock __cb_list_lock(__state_); |
| 169 | 169 | ||
| 170 | // under below condition, the request_stop call just popped __cb from the list and could execute it now | 170 | // under below condition, the request_stop call just popped __cb from the list and could execute it now |
| ... | @@ -192,7 +192,7 @@ public: | ... | @@ -192,7 +192,7 @@ public: |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | private: | 194 | private: |
| 195 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI __callback_list_lock __try_lock_for_request_stop() noexcept { | 195 | _LIBCPP_HIDE_FROM_ABI __callback_list_lock __try_lock_for_request_stop() noexcept { |
| 196 | // If it is already stop_requested, do not try to request stop or lock the list again. | 196 | // If it is already stop_requested, do not try to request stop or lock the list again. |
| 197 | const auto __lock_fail_condition = [](__state_t __state) { return (__state & __stop_requested_bit) != 0; }; | 197 | const auto __lock_fail_condition = [](__state_t __state) { return (__state & __stop_requested_bit) != 0; }; |
| 198 | 198 |
lib/libcxx/include/__stop_token/stop_token.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | 23 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS |
| 24 | 24 | ||
| 25 | class _LIBCPP_AVAILABILITY_SYNC stop_token { | 25 | class stop_token { |
| 26 | public: | 26 | public: |
| 27 | _LIBCPP_HIDE_FROM_ABI stop_token() noexcept = default; | 27 | _LIBCPP_HIDE_FROM_ABI stop_token() noexcept = default; |
| 28 | 28 |
lib/libcxx/include/__string/char_traits.h+51-31| ... | @@ -94,16 +94,17 @@ struct char_traits<char> { | ... | @@ -94,16 +94,17 @@ struct char_traits<char> { |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI | 96 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI |
| 97 | static inline _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT { | 97 | [[__nodiscard__]] static inline _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT { |
| 98 | return __c1 == __c2; | 98 | return __c1 == __c2; |
| 99 | } | 99 | } |
| 100 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT { | 100 | [[__nodiscard__]] static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool |
| 101 | lt(char_type __c1, char_type __c2) _NOEXCEPT { | ||
| 101 | return (unsigned char)__c1 < (unsigned char)__c2; | 102 | return (unsigned char)__c1 < (unsigned char)__c2; |
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | // __constexpr_memcmp requires a trivially lexicographically comparable type, but char is not when char is a signed | 105 | // __constexpr_memcmp requires a trivially lexicographically comparable type, but char is not when char is a signed |
| 105 | // type | 106 | // type |
| 106 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 107 | [[__nodiscard__]] static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 107 | compare(const char_type* __lhs, const char_type* __rhs, size_t __count) _NOEXCEPT { | 108 | compare(const char_type* __lhs, const char_type* __rhs, size_t __count) _NOEXCEPT { |
| 108 | if (__libcpp_is_constant_evaluated()) { | 109 | if (__libcpp_is_constant_evaluated()) { |
| 109 | #ifdef _LIBCPP_COMPILER_CLANG_BASED | 110 | #ifdef _LIBCPP_COMPILER_CLANG_BASED |
| ... | @@ -126,11 +127,12 @@ struct char_traits<char> { | ... | @@ -126,11 +127,12 @@ struct char_traits<char> { |
| 126 | } | 127 | } |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | static inline _LIBCPP_HIDE_FROM_ABI size_t _LIBCPP_CONSTEXPR_SINCE_CXX17 length(const char_type* __s) _NOEXCEPT { | 130 | [[__nodiscard__]] static inline _LIBCPP_HIDE_FROM_ABI size_t _LIBCPP_CONSTEXPR_SINCE_CXX17 |
| 131 | length(const char_type* __s) _NOEXCEPT { | ||
| 130 | return std::__constexpr_strlen(__s); | 132 | return std::__constexpr_strlen(__s); |
| 131 | } | 133 | } |
| 132 | 134 | ||
| 133 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | 135 | [[__nodiscard__]] static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 134 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | 136 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 135 | return std::__constexpr_memchr(__s, __a, __n); | 137 | return std::__constexpr_memchr(__s, __a, __n); |
| 136 | } | 138 | } |
| ... | @@ -154,19 +156,24 @@ struct char_traits<char> { | ... | @@ -154,19 +156,24 @@ struct char_traits<char> { |
| 154 | return __s; | 156 | return __s; |
| 155 | } | 157 | } |
| 156 | 158 | ||
| 157 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { | 159 | [[__nodiscard__]] static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { |
| 158 | return eq_int_type(__c, eof()) ? ~eof() : __c; | 160 | return eq_int_type(__c, eof()) ? ~eof() : __c; |
| 159 | } | 161 | } |
| 160 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { | 162 | [[__nodiscard__]] static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type |
| 163 | to_char_type(int_type __c) _NOEXCEPT { | ||
| 161 | return char_type(__c); | 164 | return char_type(__c); |
| 162 | } | 165 | } |
| 163 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { | 166 | [[__nodiscard__]] static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type |
| 167 | to_int_type(char_type __c) _NOEXCEPT { | ||
| 164 | return int_type((unsigned char)__c); | 168 | return int_type((unsigned char)__c); |
| 165 | } | 169 | } |
| 166 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT { | 170 | [[__nodiscard__]] static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool |
| 171 | eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT { | ||
| 167 | return __c1 == __c2; | 172 | return __c1 == __c2; |
| 168 | } | 173 | } |
| 169 | static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); } | 174 | [[__nodiscard__]] static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { |
| 175 | return int_type(EOF); | ||
| 176 | } | ||
| 170 | }; | 177 | }; |
| 171 | 178 | ||
| 172 | template <class _CharT, class _IntT, _IntT _EOFVal> | 179 | template <class _CharT, class _IntT, _IntT _EOFVal> |
| ... | @@ -187,11 +194,11 @@ struct __char_traits_base { | ... | @@ -187,11 +194,11 @@ struct __char_traits_base { |
| 187 | __lhs = __rhs; | 194 | __lhs = __rhs; |
| 188 | } | 195 | } |
| 189 | 196 | ||
| 190 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq(char_type __lhs, char_type __rhs) _NOEXCEPT { | 197 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq(char_type __lhs, char_type __rhs) _NOEXCEPT { |
| 191 | return __lhs == __rhs; | 198 | return __lhs == __rhs; |
| 192 | } | 199 | } |
| 193 | 200 | ||
| 194 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool lt(char_type __lhs, char_type __rhs) _NOEXCEPT { | 201 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool lt(char_type __lhs, char_type __rhs) _NOEXCEPT { |
| 195 | return __lhs < __rhs; | 202 | return __lhs < __rhs; |
| 196 | } | 203 | } |
| 197 | 204 | ||
| ... | @@ -213,19 +220,22 @@ struct __char_traits_base { | ... | @@ -213,19 +220,22 @@ struct __char_traits_base { |
| 213 | return __str; | 220 | return __str; |
| 214 | } | 221 | } |
| 215 | 222 | ||
| 216 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { | 223 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT { |
| 217 | return char_type(__c); | 224 | return char_type(__c); |
| 218 | } | 225 | } |
| 219 | 226 | ||
| 220 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { return int_type(__c); } | 227 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { |
| 228 | return int_type(__c); | ||
| 229 | } | ||
| 221 | 230 | ||
| 222 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __lhs, int_type __rhs) _NOEXCEPT { | 231 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool |
| 232 | eq_int_type(int_type __lhs, int_type __rhs) _NOEXCEPT { | ||
| 223 | return __lhs == __rhs; | 233 | return __lhs == __rhs; |
| 224 | } | 234 | } |
| 225 | 235 | ||
| 226 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return _EOFVal; } | 236 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return _EOFVal; } |
| 227 | 237 | ||
| 228 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { | 238 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT { |
| 229 | return eq_int_type(__c, eof()) ? static_cast<int_type>(~eof()) : __c; | 239 | return eq_int_type(__c, eof()) ? static_cast<int_type>(~eof()) : __c; |
| 230 | } | 240 | } |
| 231 | }; | 241 | }; |
| ... | @@ -235,18 +245,19 @@ struct __char_traits_base { | ... | @@ -235,18 +245,19 @@ struct __char_traits_base { |
| 235 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 245 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 236 | template <> | 246 | template <> |
| 237 | struct char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> { | 247 | struct char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> { |
| 238 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 248 | [[__nodiscard__]] static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 239 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 249 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
| 240 | if (__n == 0) | 250 | if (__n == 0) |
| 241 | return 0; | 251 | return 0; |
| 242 | return std::__constexpr_wmemcmp(__s1, __s2, __n); | 252 | return std::__constexpr_wmemcmp(__s1, __s2, __n); |
| 243 | } | 253 | } |
| 244 | 254 | ||
| 245 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT { | 255 | [[__nodiscard__]] static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t |
| 256 | length(const char_type* __s) _NOEXCEPT { | ||
| 246 | return std::__constexpr_wcslen(__s); | 257 | return std::__constexpr_wcslen(__s); |
| 247 | } | 258 | } |
| 248 | 259 | ||
| 249 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | 260 | [[__nodiscard__]] static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 250 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | 261 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 251 | return std::__constexpr_wmemchr(__s, __a, __n); | 262 | return std::__constexpr_wmemchr(__s, __a, __n); |
| 252 | } | 263 | } |
| ... | @@ -257,16 +268,16 @@ struct char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wi | ... | @@ -257,16 +268,16 @@ struct char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wi |
| 257 | 268 | ||
| 258 | template <> | 269 | template <> |
| 259 | struct char_traits<char8_t> : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> { | 270 | struct char_traits<char8_t> : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> { |
| 260 | static _LIBCPP_HIDE_FROM_ABI constexpr int | 271 | [[nodiscard]] static _LIBCPP_HIDE_FROM_ABI constexpr int |
| 261 | compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept { | 272 | compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept { |
| 262 | return std::__constexpr_memcmp(__s1, __s2, __element_count(__n)); | 273 | return std::__constexpr_memcmp(__s1, __s2, __element_count(__n)); |
| 263 | } | 274 | } |
| 264 | 275 | ||
| 265 | static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __str) noexcept { | 276 | [[nodiscard]] static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __str) noexcept { |
| 266 | return std::__constexpr_strlen(__str); | 277 | return std::__constexpr_strlen(__str); |
| 267 | } | 278 | } |
| 268 | 279 | ||
| 269 | _LIBCPP_HIDE_FROM_ABI static constexpr const char_type* | 280 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr const char_type* |
| 270 | find(const char_type* __s, size_t __n, const char_type& __a) noexcept { | 281 | find(const char_type* __s, size_t __n, const char_type& __a) noexcept { |
| 271 | return std::__constexpr_memchr(__s, __a, __n); | 282 | return std::__constexpr_memchr(__s, __a, __n); |
| 272 | } | 283 | } |
| ... | @@ -276,11 +287,11 @@ struct char_traits<char8_t> : __char_traits_base<char8_t, unsigned int, static_c | ... | @@ -276,11 +287,11 @@ struct char_traits<char8_t> : __char_traits_base<char8_t, unsigned int, static_c |
| 276 | 287 | ||
| 277 | template <> | 288 | template <> |
| 278 | struct char_traits<char16_t> : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> { | 289 | struct char_traits<char16_t> : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> { |
| 279 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 290 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 280 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | 291 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; |
| 281 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; | 292 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; |
| 282 | 293 | ||
| 283 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | 294 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 284 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | 295 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 285 | __identity __proj; | 296 | __identity __proj; |
| 286 | const char_type* __match = std::__find(__s, __s + __n, __a, __proj); | 297 | const char_type* __match = std::__find(__s, __s + __n, __a, __proj); |
| ... | @@ -290,7 +301,7 @@ struct char_traits<char16_t> : __char_traits_base<char16_t, uint_least16_t, stat | ... | @@ -290,7 +301,7 @@ struct char_traits<char16_t> : __char_traits_base<char16_t, uint_least16_t, stat |
| 290 | } | 301 | } |
| 291 | }; | 302 | }; |
| 292 | 303 | ||
| 293 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 304 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 294 | char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 305 | char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
| 295 | for (; __n; --__n, ++__s1, ++__s2) { | 306 | for (; __n; --__n, ++__s1, ++__s2) { |
| 296 | if (lt(*__s1, *__s2)) | 307 | if (lt(*__s1, *__s2)) |
| ... | @@ -301,7 +312,8 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz | ... | @@ -301,7 +312,8 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz |
| 301 | return 0; | 312 | return 0; |
| 302 | } | 313 | } |
| 303 | 314 | ||
| 304 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT { | 315 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t |
| 316 | char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT { | ||
| 305 | size_t __len = 0; | 317 | size_t __len = 0; |
| 306 | for (; !eq(*__s, char_type(0)); ++__s) | 318 | for (; !eq(*__s, char_type(0)); ++__s) |
| 307 | ++__len; | 319 | ++__len; |
| ... | @@ -310,11 +322,11 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const | ... | @@ -310,11 +322,11 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const |
| 310 | 322 | ||
| 311 | template <> | 323 | template <> |
| 312 | struct char_traits<char32_t> : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> { | 324 | struct char_traits<char32_t> : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> { |
| 313 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 325 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 314 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | 326 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; |
| 315 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; | 327 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; |
| 316 | 328 | ||
| 317 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | 329 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 318 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | 330 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 319 | __identity __proj; | 331 | __identity __proj; |
| 320 | const char_type* __match = std::__find(__s, __s + __n, __a, __proj); | 332 | const char_type* __match = std::__find(__s, __s + __n, __a, __proj); |
| ... | @@ -324,7 +336,7 @@ struct char_traits<char32_t> : __char_traits_base<char32_t, uint_least32_t, stat | ... | @@ -324,7 +336,7 @@ struct char_traits<char32_t> : __char_traits_base<char32_t, uint_least32_t, stat |
| 324 | } | 336 | } |
| 325 | }; | 337 | }; |
| 326 | 338 | ||
| 327 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 339 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 328 | char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 340 | char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
| 329 | for (; __n; --__n, ++__s1, ++__s2) { | 341 | for (; __n; --__n, ++__s1, ++__s2) { |
| 330 | if (lt(*__s1, *__s2)) | 342 | if (lt(*__s1, *__s2)) |
| ... | @@ -335,7 +347,8 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz | ... | @@ -335,7 +347,8 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz |
| 335 | return 0; | 347 | return 0; |
| 336 | } | 348 | } |
| 337 | 349 | ||
| 338 | inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT { | 350 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t |
| 351 | char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT { | ||
| 339 | size_t __len = 0; | 352 | size_t __len = 0; |
| 340 | for (; !eq(*__s, char_type(0)); ++__s) | 353 | for (; !eq(*__s, char_type(0)); ++__s) |
| 341 | ++__len; | 354 | ++__len; |
| ... | @@ -369,6 +382,13 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const _CharT* __searc | ... | @@ -369,6 +382,13 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const _CharT* __searc |
| 369 | if (__len1 < __len2) | 382 | if (__len1 < __len2) |
| 370 | return __last1; | 383 | return __last1; |
| 371 | 384 | ||
| 385 | if (__builtin_constant_p(__len2 == 1) && __len2 == 1) { | ||
| 386 | auto __res = _Traits::find(__first1, __len1, *__first2); | ||
| 387 | if (__res == nullptr) | ||
| 388 | return __last1; | ||
| 389 | return __res; | ||
| 390 | } | ||
| 391 | |||
| 372 | // First element of __first2 is loop invariant. | 392 | // First element of __first2 is loop invariant. |
| 373 | _CharT __f2 = *__first2; | 393 | _CharT __f2 = *__first2; |
| 374 | while (true) { | 394 | while (true) { |
lib/libcxx/include/__string/constexpr_c_functions.h+5-5| ... | @@ -22,7 +22,6 @@ | ... | @@ -22,7 +22,6 @@ |
| 22 | #include <__type_traits/is_equality_comparable.h> | 22 | #include <__type_traits/is_equality_comparable.h> |
| 23 | #include <__type_traits/is_integral.h> | 23 | #include <__type_traits/is_integral.h> |
| 24 | #include <__type_traits/is_same.h> | 24 | #include <__type_traits/is_same.h> |
| 25 | #include <__type_traits/is_trivially_copyable.h> | ||
| 26 | #include <__type_traits/is_trivially_lexicographically_comparable.h> | 25 | #include <__type_traits/is_trivially_lexicographically_comparable.h> |
| 27 | #include <__type_traits/remove_cv.h> | 26 | #include <__type_traits/remove_cv.h> |
| 28 | #include <__utility/element_count.h> | 27 | #include <__utility/element_count.h> |
| ... | @@ -96,14 +95,13 @@ __constexpr_memcmp(const _Tp* __lhs, const _Up* __rhs, __element_count __n) { | ... | @@ -96,14 +95,13 @@ __constexpr_memcmp(const _Tp* __lhs, const _Up* __rhs, __element_count __n) { |
| 96 | } | 95 | } |
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | // Because of __libcpp_is_trivially_equality_comparable we know that comparing the object representations is equivalent | 98 | // Because of __is_trivially_equality_comparable_v we know that comparing the object representations is equivalent |
| 100 | // to a std::memcmp(...) == 0. Since we have multiple objects contiguously in memory, we can call memcmp once instead | 99 | // to a std::memcmp(...) == 0. Since we have multiple objects contiguously in memory, we can call memcmp once instead |
| 101 | // of invoking it on every object individually. | 100 | // of invoking it on every object individually. |
| 102 | template <class _Tp, class _Up> | 101 | template <class _Tp, class _Up> |
| 103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | 102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool |
| 104 | __constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n) { | 103 | __constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n) { |
| 105 | static_assert(__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, | 104 | static_assert(__is_trivially_equality_comparable_v<_Tp, _Up>, "_Tp and _Up have to be trivially equality comparable"); |
| 106 | "_Tp and _Up have to be trivially equality comparable"); | ||
| 107 | 105 | ||
| 108 | auto __count = static_cast<size_t>(__n); | 106 | auto __count = static_cast<size_t>(__n); |
| 109 | 107 | ||
| ... | @@ -128,7 +126,7 @@ __constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n | ... | @@ -128,7 +126,7 @@ __constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n |
| 128 | 126 | ||
| 129 | template <class _Tp, class _Up> | 127 | template <class _Tp, class _Up> |
| 130 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_memchr(_Tp* __str, _Up __value, size_t __count) { | 128 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_memchr(_Tp* __str, _Up __value, size_t __count) { |
| 131 | static_assert(sizeof(_Tp) == 1 && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, | 129 | static_assert(sizeof(_Tp) == 1 && __is_trivially_equality_comparable_v<_Tp, _Up>, |
| 132 | "Calling memchr on non-trivially equality comparable types is unsafe."); | 130 | "Calling memchr on non-trivially equality comparable types is unsafe."); |
| 133 | 131 | ||
| 134 | if (__libcpp_is_constant_evaluated()) { | 132 | if (__libcpp_is_constant_evaluated()) { |
| ... | @@ -225,6 +223,8 @@ __constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) { | ... | @@ -225,6 +223,8 @@ __constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) { |
| 225 | std::__assign_trivially_copyable(__dest[__i], __src[__i]); | 223 | std::__assign_trivially_copyable(__dest[__i], __src[__i]); |
| 226 | } | 224 | } |
| 227 | } | 225 | } |
| 226 | } else if _LIBCPP_CONSTEXPR (sizeof(_Tp) == __datasizeof_v<_Tp>) { | ||
| 227 | ::__builtin_memmove(__dest, __src, __count * sizeof(_Tp)); | ||
| 228 | } else if (__count > 0) { | 228 | } else if (__count > 0) { |
| 229 | ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>); | 229 | ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>); |
| 230 | } | 230 | } |
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h-8| ... | @@ -34,12 +34,4 @@ inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __ | ... | @@ -34,12 +34,4 @@ inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __ |
| 34 | return ::strtold(__nptr, __endptr); | 34 | return ::strtold(__nptr, __endptr); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 38 | return ::strtoll(__nptr, __endptr, __base); | ||
| 39 | } | ||
| 40 | |||
| 41 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) { | ||
| 42 | return ::strtoull(__nptr, __endptr, __base); | ||
| 43 | } | ||
| 44 | |||
| 45 | #endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H | 37 | #endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H |
lib/libcxx/include/__system_error/error_category.h+8-8| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | class _LIBCPP_EXPORTED_FROM_ABI error_condition; | 23 | class error_condition; |
| 24 | class _LIBCPP_EXPORTED_FROM_ABI error_code; | 24 | class _LIBCPP_EXPORTED_FROM_ABI error_code; |
| 25 | 25 | ||
| 26 | class _LIBCPP_HIDDEN __do_message; | 26 | class _LIBCPP_HIDDEN __do_message; |
| ... | @@ -37,11 +37,11 @@ public: | ... | @@ -37,11 +37,11 @@ public: |
| 37 | error_category(const error_category&) = delete; | 37 | error_category(const error_category&) = delete; |
| 38 | error_category& operator=(const error_category&) = delete; | 38 | error_category& operator=(const error_category&) = delete; |
| 39 | 39 | ||
| 40 | virtual const char* name() const _NOEXCEPT = 0; | 40 | [[__nodiscard__]] virtual const char* name() const _NOEXCEPT = 0; |
| 41 | virtual error_condition default_error_condition(int __ev) const _NOEXCEPT; | 41 | [[__nodiscard__]] virtual error_condition default_error_condition(int __ev) const _NOEXCEPT; |
| 42 | virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT; | 42 | [[__nodiscard__]] virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT; |
| 43 | virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT; | 43 | [[__nodiscard__]] virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT; |
| 44 | virtual string message(int __ev) const = 0; | 44 | [[__nodiscard__]] virtual string message(int __ev) const = 0; |
| 45 | 45 | ||
| 46 | _LIBCPP_HIDE_FROM_ABI bool operator==(const error_category& __rhs) const _NOEXCEPT { return this == &__rhs; } | 46 | _LIBCPP_HIDE_FROM_ABI bool operator==(const error_category& __rhs) const _NOEXCEPT { return this == &__rhs; } |
| 47 | 47 | ||
| ... | @@ -67,8 +67,8 @@ public: | ... | @@ -67,8 +67,8 @@ public: |
| 67 | string message(int __ev) const override; | 67 | string message(int __ev) const override; |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | [[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT; | 70 | [[__gnu__::__const__]] [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT; |
| 71 | [[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT; | 71 | [[__gnu__::__const__]] [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT; |
| 72 | 72 | ||
| 73 | _LIBCPP_END_NAMESPACE_STD | 73 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 74 |
lib/libcxx/include/__system_error/error_code.h+5-5| ... | @@ -71,20 +71,20 @@ public: | ... | @@ -71,20 +71,20 @@ public: |
| 71 | __cat_ = &system_category(); | 71 | __cat_ = &system_category(); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __val_; } | 74 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __val_; } |
| 75 | 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI const error_category& category() const _NOEXCEPT { return *__cat_; } | 76 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const error_category& category() const _NOEXCEPT { return *__cat_; } |
| 77 | 77 | ||
| 78 | _LIBCPP_HIDE_FROM_ABI error_condition default_error_condition() const _NOEXCEPT { | 78 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI error_condition default_error_condition() const _NOEXCEPT { |
| 79 | return __cat_->default_error_condition(__val_); | 79 | return __cat_->default_error_condition(__val_); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | string message() const; | 82 | [[__nodiscard__]] string message() const; |
| 83 | 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __val_ != 0; } | 84 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __val_ != 0; } |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(errc __e) _NOEXCEPT { | 87 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(errc __e) _NOEXCEPT { |
| 88 | return error_code(static_cast<int>(__e), generic_category()); | 88 | return error_code(static_cast<int>(__e), generic_category()); |
| 89 | } | 89 | } |
| 90 | 90 |
lib/libcxx/include/__system_error/error_condition.h+4-4| ... | @@ -80,15 +80,15 @@ public: | ... | @@ -80,15 +80,15 @@ public: |
| 80 | __cat_ = &generic_category(); | 80 | __cat_ = &generic_category(); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __val_; } | 83 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __val_; } |
| 84 | 84 | ||
| 85 | _LIBCPP_HIDE_FROM_ABI const error_category& category() const _NOEXCEPT { return *__cat_; } | 85 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const error_category& category() const _NOEXCEPT { return *__cat_; } |
| 86 | string message() const; | 86 | [[__nodiscard__]] string message() const; |
| 87 | 87 | ||
| 88 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __val_ != 0; } | 88 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __val_ != 0; } |
| 89 | }; | 89 | }; |
| 90 | 90 | ||
| 91 | inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(errc __e) _NOEXCEPT { | 91 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(errc __e) _NOEXCEPT { |
| 92 | return error_condition(static_cast<int>(__e), generic_category()); | 92 | return error_condition(static_cast<int>(__e), generic_category()); |
| 93 | } | 93 | } |
| 94 | 94 |
lib/libcxx/include/__system_error/system_error.h+1-1| ... | @@ -36,7 +36,7 @@ public: | ... | @@ -36,7 +36,7 @@ public: |
| 36 | _LIBCPP_HIDE_FROM_ABI system_error(const system_error&) _NOEXCEPT = default; | 36 | _LIBCPP_HIDE_FROM_ABI system_error(const system_error&) _NOEXCEPT = default; |
| 37 | ~system_error() _NOEXCEPT override; | 37 | ~system_error() _NOEXCEPT override; |
| 38 | 38 | ||
| 39 | _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } | 39 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | // __ev is expected to be an error in the generic_category domain (e.g. from | 42 | // __ev is expected to be an error in the generic_category domain (e.g. from |
lib/libcxx/include/__thread/id.h+1-1| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | ||
| 25 | #if _LIBCPP_HAS_THREADS | 25 | #if _LIBCPP_HAS_THREADS |
| 26 | class _LIBCPP_EXPORTED_FROM_ABI __thread_id; | 26 | class __thread_id; |
| 27 | 27 | ||
| 28 | namespace this_thread { | 28 | namespace this_thread { |
| 29 | 29 |
lib/libcxx/include/__thread/jthread.h+1-1| ... | @@ -36,7 +36,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -36,7 +36,7 @@ _LIBCPP_PUSH_MACROS |
| 36 | 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 38 | 38 | ||
| 39 | class _LIBCPP_AVAILABILITY_SYNC jthread { | 39 | class jthread { |
| 40 | public: | 40 | public: |
| 41 | // types | 41 | // types |
| 42 | using id = thread::id; | 42 | using id = thread::id; |
lib/libcxx/include/__thread/poll_with_backoff.h+27-8| ... | @@ -22,33 +22,50 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,33 +22,50 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64; | 23 | static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64; |
| 24 | 24 | ||
| 25 | enum class __backoff_results : unsigned char { | ||
| 26 | __continue_poll = 1, | ||
| 27 | __poll_success = 2, | ||
| 28 | __timeout = 3, | ||
| 29 | __backoff_failure = 4, | ||
| 30 | }; | ||
| 31 | |||
| 32 | enum class __poll_with_backoff_results : unsigned char { | ||
| 33 | __poll_success = static_cast<unsigned char>(__backoff_results::__poll_success), | ||
| 34 | __timeout = static_cast<unsigned char>(__backoff_results::__timeout), | ||
| 35 | __backoff_failure = static_cast<unsigned char>(__backoff_results::__backoff_failure), | ||
| 36 | }; | ||
| 37 | |||
| 25 | // Polls a thread for a condition given by a predicate, and backs off based on a backoff policy | 38 | // Polls a thread for a condition given by a predicate, and backs off based on a backoff policy |
| 26 | // before polling again. | 39 | // before polling again. |
| 27 | // | 40 | // |
| 28 | // - __poll is the "test function" that should return true if polling succeeded, and false if it failed. | 41 | // - __poll is the "test function" that should return true if polling succeeded, and false if it failed. |
| 29 | // | 42 | // |
| 30 | // - __backoff is the "backoff policy", which is called with the duration since we started polling. It should | 43 | // - __backoff is the "backoff policy", which is called with the duration since we started polling. It should |
| 31 | // return false in order to resume polling, and true if polling should stop entirely for some reason. | 44 | // return __backoff_results::__continue_poll in order to resume polling, and other appropriate __backoff_results |
| 45 | // if polling should stop entirely for some reason. | ||
| 32 | // In general, backoff policies sleep for some time before returning control to the polling loop. | 46 | // In general, backoff policies sleep for some time before returning control to the polling loop. |
| 33 | // | 47 | // |
| 34 | // - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded, | 48 | // - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded, |
| 35 | // the polling loop will return false to report a timeout. | 49 | // the polling loop will return __poll_with_backoff_results::__timeout to report a timeout. |
| 50 | |||
| 36 | template <class _Poll, class _Backoff> | 51 | template <class _Poll, class _Backoff> |
| 37 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_backoff( | 52 | _LIBCPP_HIDE_FROM_ABI __poll_with_backoff_results __libcpp_thread_poll_with_backoff( |
| 38 | _Poll&& __poll, _Backoff&& __backoff, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) { | 53 | _Poll&& __poll, _Backoff&& __backoff, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) { |
| 39 | auto const __start = chrono::high_resolution_clock::now(); | 54 | auto const __start = chrono::high_resolution_clock::now(); |
| 40 | for (int __count = 0;;) { | 55 | for (int __count = 0;;) { |
| 41 | if (__poll()) | 56 | if (__poll()) |
| 42 | return true; // __poll completion means success | 57 | return __poll_with_backoff_results::__poll_success; |
| 43 | if (__count < __libcpp_polling_count) { | 58 | if (__count < __libcpp_polling_count) { |
| 44 | __count += 1; | 59 | __count += 1; |
| 45 | continue; | 60 | continue; |
| 46 | } | 61 | } |
| 47 | chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start; | 62 | chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start; |
| 48 | if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed) | 63 | if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed) |
| 49 | return false; // timeout failure | 64 | return __poll_with_backoff_results::__timeout; |
| 50 | if (__backoff(__elapsed)) | 65 | if (auto __backoff_res = __backoff(__elapsed); __backoff_res == __backoff_results::__continue_poll) |
| 51 | return false; // __backoff completion means failure | 66 | continue; |
| 67 | else | ||
| 68 | return static_cast<__poll_with_backoff_results>(__backoff_res); | ||
| 52 | } | 69 | } |
| 53 | } | 70 | } |
| 54 | 71 | ||
| ... | @@ -59,7 +76,9 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_b | ... | @@ -59,7 +76,9 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_b |
| 59 | // so this should most likely only be used on single-threaded systems where there | 76 | // so this should most likely only be used on single-threaded systems where there |
| 60 | // are no other threads to compete with. | 77 | // are no other threads to compete with. |
| 61 | struct __spinning_backoff_policy { | 78 | struct __spinning_backoff_policy { |
| 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(chrono::nanoseconds const&) const { return false; } | 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __backoff_results operator()(chrono::nanoseconds const&) const { |
| 80 | return __backoff_results::__continue_poll; | ||
| 81 | } | ||
| 63 | }; | 82 | }; |
| 64 | 83 | ||
| 65 | _LIBCPP_END_NAMESPACE_STD | 84 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__thread/support/c11.h+8-8| ... | @@ -39,17 +39,17 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursiv | ... | @@ -39,17 +39,17 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursiv |
| 39 | return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL; | 39 | return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 42 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 43 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { | 43 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { |
| 44 | return mtx_lock(__m) == thrd_success ? 0 : EINVAL; | 44 | return mtx_lock(__m) == thrd_success ? 0 : EINVAL; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool | 47 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI bool |
| 48 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { | 48 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { |
| 49 | return mtx_trylock(__m) == thrd_success; | 49 | return mtx_trylock(__m) == thrd_success; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 52 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 53 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { | 53 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { |
| 54 | return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; | 54 | return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; |
| 55 | } | 55 | } |
| ... | @@ -59,15 +59,15 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recur | ... | @@ -59,15 +59,15 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recur |
| 59 | return 0; | 59 | return 0; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { | 62 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { |
| 63 | return mtx_lock(__m) == thrd_success ? 0 : EINVAL; | 63 | return mtx_lock(__m) == thrd_success ? 0 : EINVAL; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { | 66 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { |
| 67 | return mtx_trylock(__m) == thrd_success; | 67 | return mtx_trylock(__m) == thrd_success; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { | 70 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { |
| 71 | return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; | 71 | return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| ... | @@ -92,12 +92,12 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* | ... | @@ -92,12 +92,12 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* |
| 92 | return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL; | 92 | return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 95 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 96 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { | 96 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { |
| 97 | return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL; | 97 | return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 100 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 101 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) { | 101 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) { |
| 102 | int __ec = cnd_timedwait(__cv, __m, __ts); | 102 | int __ec = cnd_timedwait(__cv, __m, __ts); |
| 103 | return __ec == thrd_timedout ? ETIMEDOUT : __ec; | 103 | return __ec == thrd_timedout ? ETIMEDOUT : __ec; |
lib/libcxx/include/__thread/support/pthread.h+8-8| ... | @@ -72,17 +72,17 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursiv | ... | @@ -72,17 +72,17 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursiv |
| 72 | return 0; | 72 | return 0; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 75 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 76 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { | 76 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { |
| 77 | return pthread_mutex_lock(__m); | 77 | return pthread_mutex_lock(__m); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool | 80 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI bool |
| 81 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { | 81 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { |
| 82 | return pthread_mutex_trylock(__m) == 0; | 82 | return pthread_mutex_trylock(__m) == 0; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 85 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 86 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { | 86 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { |
| 87 | return pthread_mutex_unlock(__m); | 87 | return pthread_mutex_unlock(__m); |
| 88 | } | 88 | } |
| ... | @@ -91,15 +91,15 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recur | ... | @@ -91,15 +91,15 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recur |
| 91 | return pthread_mutex_destroy(__m); | 91 | return pthread_mutex_destroy(__m); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { | 94 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { |
| 95 | return pthread_mutex_lock(__m); | 95 | return pthread_mutex_lock(__m); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { | 98 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { |
| 99 | return pthread_mutex_trylock(__m) == 0; | 99 | return pthread_mutex_trylock(__m) == 0; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { | 102 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { |
| 103 | return pthread_mutex_unlock(__m); | 103 | return pthread_mutex_unlock(__m); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| ... | @@ -117,12 +117,12 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* | ... | @@ -117,12 +117,12 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* |
| 117 | return pthread_cond_broadcast(__cv); | 117 | return pthread_cond_broadcast(__cv); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 120 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 121 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { | 121 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { |
| 122 | return pthread_cond_wait(__cv, __m); | 122 | return pthread_cond_wait(__cv, __m); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 125 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI int |
| 126 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts) { | 126 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts) { |
| 127 | return pthread_cond_timedwait(__cv, __m, __ts); | 127 | return pthread_cond_timedwait(__cv, __m, __ts); |
| 128 | } | 128 | } |
lib/libcxx/include/__thread/support/windows.h+8-8| ... | @@ -36,22 +36,22 @@ typedef void* __libcpp_recursive_mutex_t[6]; | ... | @@ -36,22 +36,22 @@ typedef void* __libcpp_recursive_mutex_t[6]; |
| 36 | 36 | ||
| 37 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m); | 37 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m); |
| 38 | 38 | ||
| 39 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 39 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI int |
| 40 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m); | 40 | __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m); |
| 41 | 41 | ||
| 42 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool | 42 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI bool |
| 43 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m); | 43 | __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m); |
| 44 | 44 | ||
| 45 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 45 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI int |
| 46 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m); | 46 | __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m); |
| 47 | 47 | ||
| 48 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m); | 48 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m); |
| 49 | 49 | ||
| 50 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m); | 50 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI int __libcpp_mutex_lock(__libcpp_mutex_t* __m); |
| 51 | 51 | ||
| 52 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m); | 52 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m); |
| 53 | 53 | ||
| 54 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); | 54 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); |
| 55 | 55 | ||
| 56 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); | 56 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); |
| 57 | 57 | ||
| ... | @@ -65,10 +65,10 @@ _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); | ... | @@ -65,10 +65,10 @@ _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); |
| 65 | 65 | ||
| 66 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); | 66 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); |
| 67 | 67 | ||
| 68 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 68 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI int |
| 69 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); | 69 | __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); |
| 70 | 70 | ||
| 71 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int | 71 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_EXPORTED_FROM_ABI int |
| 72 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts); | 72 | __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts); |
| 73 | 73 | ||
| 74 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); | 74 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); |
lib/libcxx/include/__thread/thread.h+13-8| ... | @@ -25,6 +25,8 @@ | ... | @@ -25,6 +25,8 @@ |
| 25 | #include <__thread/support.h> | 25 | #include <__thread/support.h> |
| 26 | #include <__type_traits/decay.h> | 26 | #include <__type_traits/decay.h> |
| 27 | #include <__type_traits/enable_if.h> | 27 | #include <__type_traits/enable_if.h> |
| 28 | #include <__type_traits/invoke.h> | ||
| 29 | #include <__type_traits/is_constructible.h> | ||
| 28 | #include <__type_traits/is_same.h> | 30 | #include <__type_traits/is_same.h> |
| 29 | #include <__type_traits/remove_cvref.h> | 31 | #include <__type_traits/remove_cvref.h> |
| 30 | #include <__utility/forward.h> | 32 | #include <__utility/forward.h> |
| ... | @@ -155,8 +157,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { | ... | @@ -155,8 +157,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { |
| 155 | # ifndef _LIBCPP_CXX03_LANG | 157 | # ifndef _LIBCPP_CXX03_LANG |
| 156 | 158 | ||
| 157 | template <class _TSp, class _Fp, class... _Args, size_t... _Indices> | 159 | template <class _TSp, class _Fp, class... _Args, size_t... _Indices> |
| 158 | inline _LIBCPP_HIDE_FROM_ABI void __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>) { | 160 | inline _LIBCPP_HIDE_FROM_ABI void __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __index_sequence<_Indices...>) { |
| 159 | std::__invoke(std::move(std::get<1>(__t)), std::move(std::get<_Indices>(__t))...); | 161 | std::__invoke(std::move(std::get<_Indices + 1>(__t))...); |
| 160 | } | 162 | } |
| 161 | 163 | ||
| 162 | template <class _Fp> | 164 | template <class _Fp> |
| ... | @@ -164,8 +166,7 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) { | ... | @@ -164,8 +166,7 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) { |
| 164 | // _Fp = tuple< unique_ptr<__thread_struct>, Functor, Args...> | 166 | // _Fp = tuple< unique_ptr<__thread_struct>, Functor, Args...> |
| 165 | unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp)); | 167 | unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp)); |
| 166 | __thread_local_data().set_pointer(std::get<0>(*__p.get()).release()); | 168 | __thread_local_data().set_pointer(std::get<0>(*__p.get()).release()); |
| 167 | typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 2>::type _Index; | 169 | std::__thread_execute(*__p.get(), __make_index_sequence<tuple_size<_Fp>::value - 1>()); |
| 168 | std::__thread_execute(*__p.get(), _Index()); | ||
| 169 | return nullptr; | 170 | return nullptr; |
| 170 | } | 171 | } |
| 171 | 172 | ||
| ... | @@ -206,6 +207,10 @@ public: | ... | @@ -206,6 +207,10 @@ public: |
| 206 | # ifndef _LIBCPP_CXX03_LANG | 207 | # ifndef _LIBCPP_CXX03_LANG |
| 207 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0> | 208 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0> |
| 208 | _LIBCPP_HIDE_FROM_ABI explicit thread(_Fp&& __f, _Args&&... __args) { | 209 | _LIBCPP_HIDE_FROM_ABI explicit thread(_Fp&& __f, _Args&&... __args) { |
| 210 | static_assert(is_constructible<__decay_t<_Fp>, _Fp>::value, ""); | ||
| 211 | static_assert(_And<is_constructible<__decay_t<_Args>, _Args>...>::value, ""); | ||
| 212 | static_assert(__is_invocable_v<__decay_t<_Fp>, __decay_t<_Args>...>, ""); | ||
| 213 | |||
| 209 | typedef unique_ptr<__thread_struct> _TSPtr; | 214 | typedef unique_ptr<__thread_struct> _TSPtr; |
| 210 | _TSPtr __tsp(new __thread_struct); | 215 | _TSPtr __tsp(new __thread_struct); |
| 211 | typedef tuple<_TSPtr, __decay_t<_Fp>, __decay_t<_Args>...> _Gp; | 216 | typedef tuple<_TSPtr, __decay_t<_Fp>, __decay_t<_Args>...> _Gp; |
| ... | @@ -243,13 +248,13 @@ public: | ... | @@ -243,13 +248,13 @@ public: |
| 243 | 248 | ||
| 244 | _LIBCPP_HIDE_FROM_ABI void swap(thread& __t) _NOEXCEPT { std::swap(__t_, __t.__t_); } | 249 | _LIBCPP_HIDE_FROM_ABI void swap(thread& __t) _NOEXCEPT { std::swap(__t_, __t.__t_); } |
| 245 | 250 | ||
| 246 | _LIBCPP_HIDE_FROM_ABI bool joinable() const _NOEXCEPT { return !__libcpp_thread_isnull(&__t_); } | 251 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool joinable() const _NOEXCEPT { return !__libcpp_thread_isnull(&__t_); } |
| 247 | void join(); | 252 | void join(); |
| 248 | void detach(); | 253 | void detach(); |
| 249 | _LIBCPP_HIDE_FROM_ABI id get_id() const _NOEXCEPT { return __libcpp_thread_get_id(&__t_); } | 254 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI id get_id() const _NOEXCEPT { return __libcpp_thread_get_id(&__t_); } |
| 250 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() _NOEXCEPT { return __t_; } | 255 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() _NOEXCEPT { return __t_; } |
| 251 | 256 | ||
| 252 | static unsigned hardware_concurrency() _NOEXCEPT; | 257 | [[__nodiscard__]] static unsigned hardware_concurrency() _NOEXCEPT; |
| 253 | }; | 258 | }; |
| 254 | 259 | ||
| 255 | inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); } | 260 | inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); } |
lib/libcxx/include/__thread/timed_backoff_policy.h+3-2| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | #define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H | 11 | #define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__thread/poll_with_backoff.h> | ||
| 14 | 15 | ||
| 15 | #if _LIBCPP_HAS_THREADS | 16 | #if _LIBCPP_HAS_THREADS |
| 16 | 17 | ||
| ... | @@ -24,7 +25,7 @@ | ... | @@ -24,7 +25,7 @@ |
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 26 | ||
| 26 | struct __libcpp_timed_backoff_policy { | 27 | struct __libcpp_timed_backoff_policy { |
| 27 | _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const { | 28 | _LIBCPP_HIDE_FROM_ABI __backoff_results operator()(chrono::nanoseconds __elapsed) const { |
| 28 | if (__elapsed > chrono::milliseconds(128)) | 29 | if (__elapsed > chrono::milliseconds(128)) |
| 29 | __libcpp_thread_sleep_for(chrono::milliseconds(8)); | 30 | __libcpp_thread_sleep_for(chrono::milliseconds(8)); |
| 30 | else if (__elapsed > chrono::microseconds(64)) | 31 | else if (__elapsed > chrono::microseconds(64)) |
| ... | @@ -33,7 +34,7 @@ struct __libcpp_timed_backoff_policy { | ... | @@ -33,7 +34,7 @@ struct __libcpp_timed_backoff_policy { |
| 33 | __libcpp_thread_yield(); | 34 | __libcpp_thread_yield(); |
| 34 | else { | 35 | else { |
| 35 | } // poll | 36 | } // poll |
| 36 | return false; | 37 | return __backoff_results::__continue_poll; |
| 37 | } | 38 | } |
| 38 | }; | 39 | }; |
| 39 | 40 |
lib/libcxx/include/__tree+849-701| ... | @@ -11,37 +11,39 @@ | ... | @@ -11,37 +11,39 @@ |
| 11 | #define _LIBCPP___TREE | 11 | #define _LIBCPP___TREE |
| 12 | 12 | ||
| 13 | #include <__algorithm/min.h> | 13 | #include <__algorithm/min.h> |
| 14 | #include <__algorithm/specialized_algorithms.h> | ||
| 14 | #include <__assert> | 15 | #include <__assert> |
| 15 | #include <__config> | 16 | #include <__config> |
| 16 | #include <__fwd/map.h> | ||
| 17 | #include <__fwd/pair.h> | 17 | #include <__fwd/pair.h> |
| 18 | #include <__fwd/set.h> | ||
| 19 | #include <__iterator/distance.h> | 18 | #include <__iterator/distance.h> |
| 20 | #include <__iterator/iterator_traits.h> | 19 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__iterator/next.h> | 20 | #include <__iterator/next.h> |
| 22 | #include <__memory/addressof.h> | 21 | #include <__memory/addressof.h> |
| 23 | #include <__memory/allocator_traits.h> | 22 | #include <__memory/allocator_traits.h> |
| 24 | #include <__memory/compressed_pair.h> | 23 | #include <__memory/compressed_pair.h> |
| 24 | #include <__memory/construct_at.h> | ||
| 25 | #include <__memory/pointer_traits.h> | 25 | #include <__memory/pointer_traits.h> |
| 26 | #include <__memory/swap_allocator.h> | 26 | #include <__memory/swap_allocator.h> |
| 27 | #include <__memory/unique_ptr.h> | 27 | #include <__memory/unique_ptr.h> |
| 28 | #include <__type_traits/can_extract_key.h> | 28 | #include <__new/launder.h> |
| 29 | #include <__type_traits/copy_cvref.h> | 29 | #include <__type_traits/copy_cvref.h> |
| 30 | #include <__type_traits/enable_if.h> | 30 | #include <__type_traits/enable_if.h> |
| 31 | #include <__type_traits/invoke.h> | 31 | #include <__type_traits/invoke.h> |
| 32 | #include <__type_traits/is_const.h> | ||
| 33 | #include <__type_traits/is_constructible.h> | 32 | #include <__type_traits/is_constructible.h> |
| 34 | #include <__type_traits/is_nothrow_assignable.h> | 33 | #include <__type_traits/is_nothrow_assignable.h> |
| 35 | #include <__type_traits/is_nothrow_constructible.h> | 34 | #include <__type_traits/is_nothrow_constructible.h> |
| 36 | #include <__type_traits/is_same.h> | 35 | #include <__type_traits/is_same.h> |
| 36 | #include <__type_traits/is_specialization.h> | ||
| 37 | #include <__type_traits/is_swappable.h> | 37 | #include <__type_traits/is_swappable.h> |
| 38 | #include <__type_traits/make_transparent.h> | ||
| 38 | #include <__type_traits/remove_const.h> | 39 | #include <__type_traits/remove_const.h> |
| 39 | #include <__type_traits/remove_const_ref.h> | ||
| 40 | #include <__type_traits/remove_cvref.h> | 40 | #include <__type_traits/remove_cvref.h> |
| 41 | #include <__utility/forward.h> | 41 | #include <__utility/forward.h> |
| 42 | #include <__utility/lazy_synth_three_way_comparator.h> | ||
| 42 | #include <__utility/move.h> | 43 | #include <__utility/move.h> |
| 43 | #include <__utility/pair.h> | 44 | #include <__utility/pair.h> |
| 44 | #include <__utility/swap.h> | 45 | #include <__utility/swap.h> |
| 46 | #include <__utility/try_key_extraction.h> | ||
| 45 | #include <limits> | 47 | #include <limits> |
| 46 | 48 | ||
| 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -51,14 +53,31 @@ | ... | @@ -51,14 +53,31 @@ |
| 51 | _LIBCPP_PUSH_MACROS | 53 | _LIBCPP_PUSH_MACROS |
| 52 | #include <__undef_macros> | 54 | #include <__undef_macros> |
| 53 | 55 | ||
| 54 | _LIBCPP_BEGIN_NAMESPACE_STD | 56 | _LIBCPP_DIAGNOSTIC_PUSH |
| 57 | // GCC complains about the backslashes at the end, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121528 | ||
| 58 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wcomment") | ||
| 59 | // __tree is a red-black-tree implementation used for the associative containers (i.e. (multi)map/set). It stores | ||
| 60 | // - (1) a pointer to the node with the smallest (i.e. leftmost) element, namely __begin_node_ | ||
| 61 | // - (2) the number of nodes in the tree, namely __size_ | ||
| 62 | // - (3) a pointer to the root of the tree, namely __end_node_ | ||
| 63 | // | ||
| 64 | // Storing (1) and (2) is required to allow for constant time lookups. A tree looks like this in memory: | ||
| 65 | // | ||
| 66 | // __end_node_ | ||
| 67 | // | | ||
| 68 | // root | ||
| 69 | // / \ | ||
| 70 | // l1 r1 | ||
| 71 | // / \ / \ | ||
| 72 | // ... ... ... ... | ||
| 73 | // | ||
| 74 | // All nodes except __end_node_ have a __left_ and __right_ pointer as well as a __parent_ pointer. | ||
| 75 | // __end_node_ only contains a __left_ pointer, which points to the root of the tree. | ||
| 76 | // This layout allows for iteration through the tree without a need for special handling of the end node. See | ||
| 77 | // __tree_next_iter and __tree_prev_iter for more details. | ||
| 78 | _LIBCPP_DIAGNOSTIC_POP | ||
| 55 | 79 | ||
| 56 | template <class _Tp, class _Compare, class _Allocator> | 80 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 57 | class __tree; | ||
| 58 | template <class _Tp, class _NodePtr, class _DiffType> | ||
| 59 | class __tree_iterator; | ||
| 60 | template <class _Tp, class _ConstNodePtr, class _DiffType> | ||
| 61 | class __tree_const_iterator; | ||
| 62 | 81 | ||
| 63 | template <class _Pointer> | 82 | template <class _Pointer> |
| 64 | class __tree_end_node; | 83 | class __tree_end_node; |
| ... | @@ -70,13 +89,6 @@ class __tree_node; | ... | @@ -70,13 +89,6 @@ class __tree_node; |
| 70 | template <class _Key, class _Value> | 89 | template <class _Key, class _Value> |
| 71 | struct __value_type; | 90 | struct __value_type; |
| 72 | 91 | ||
| 73 | template <class _Allocator> | ||
| 74 | class __map_node_destructor; | ||
| 75 | template <class _TreeIterator> | ||
| 76 | class __map_iterator; | ||
| 77 | template <class _TreeIterator> | ||
| 78 | class __map_const_iterator; | ||
| 79 | |||
| 80 | /* | 92 | /* |
| 81 | 93 | ||
| 82 | _NodePtr algorithms | 94 | _NodePtr algorithms |
| ... | @@ -185,6 +197,11 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT { | ... | @@ -185,6 +197,11 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT { |
| 185 | return __x->__parent_unsafe(); | 197 | return __x->__parent_unsafe(); |
| 186 | } | 198 | } |
| 187 | 199 | ||
| 200 | // __tree_next_iter and __tree_prev_iter implement iteration through the tree. The order is as follows: | ||
| 201 | // left sub-tree -> node -> right sub-tree. When the right-most node of a sub-tree is reached, we walk up the tree until | ||
| 202 | // we find a node where we were in the left sub-tree. We are _always_ in a left sub-tree, since the __end_node_ points | ||
| 203 | // to the actual root of the tree through a __left_ pointer. Incrementing the end() pointer is UB, so we can assume that | ||
| 204 | // never happens. | ||
| 188 | template <class _EndNodePtr, class _NodePtr> | 205 | template <class _EndNodePtr, class _NodePtr> |
| 189 | inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT { | 206 | inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT { |
| 190 | _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null"); | 207 | _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null"); |
| ... | @@ -494,16 +511,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEP | ... | @@ -494,16 +511,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEP |
| 494 | // node traits | 511 | // node traits |
| 495 | 512 | ||
| 496 | template <class _Tp> | 513 | template <class _Tp> |
| 497 | struct __is_tree_value_type_imp : false_type {}; | 514 | inline const bool __is_tree_value_type_v = __is_specialization_v<_Tp, __value_type>; |
| 498 | |||
| 499 | template <class _Key, class _Value> | ||
| 500 | struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {}; | ||
| 501 | |||
| 502 | template <class... _Args> | ||
| 503 | struct __is_tree_value_type : false_type {}; | ||
| 504 | |||
| 505 | template <class _One> | ||
| 506 | struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {}; | ||
| 507 | 515 | ||
| 508 | template <class _Tp> | 516 | template <class _Tp> |
| 509 | struct __get_tree_key_type { | 517 | struct __get_tree_key_type { |
| ... | @@ -549,15 +557,14 @@ private: | ... | @@ -549,15 +557,14 @@ private: |
| 549 | template <class _Pointer> | 557 | template <class _Pointer> |
| 550 | class __tree_end_node { | 558 | class __tree_end_node { |
| 551 | public: | 559 | public: |
| 552 | typedef _Pointer pointer; | 560 | using pointer = _Pointer; |
| 553 | pointer __left_; | 561 | pointer __left_; |
| 554 | 562 | ||
| 555 | _LIBCPP_HIDE_FROM_ABI __tree_end_node() _NOEXCEPT : __left_() {} | 563 | _LIBCPP_HIDE_FROM_ABI __tree_end_node() _NOEXCEPT : __left_() {} |
| 556 | }; | 564 | }; |
| 557 | 565 | ||
| 558 | template <class _VoidPtr> | 566 | template <class _VoidPtr> |
| 559 | class _LIBCPP_STANDALONE_DEBUG | 567 | class __tree_node_base : public __tree_end_node<__rebind_pointer_t<_VoidPtr, __tree_node_base<_VoidPtr> > > { |
| 560 | __tree_node_base : public __tree_end_node<__rebind_pointer_t<_VoidPtr, __tree_node_base<_VoidPtr> > > { | ||
| 561 | public: | 568 | public: |
| 562 | using pointer = __rebind_pointer_t<_VoidPtr, __tree_node_base>; | 569 | using pointer = __rebind_pointer_t<_VoidPtr, __tree_node_base>; |
| 563 | using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_end_node<pointer> >; | 570 | using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_end_node<pointer> >; |
| ... | @@ -570,20 +577,41 @@ public: | ... | @@ -570,20 +577,41 @@ public: |
| 570 | 577 | ||
| 571 | _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__end_node_pointer>(__p); } | 578 | _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__end_node_pointer>(__p); } |
| 572 | 579 | ||
| 573 | ~__tree_node_base() = delete; | 580 | _LIBCPP_HIDE_FROM_ABI __tree_node_base() = default; |
| 574 | __tree_node_base(__tree_node_base const&) = delete; | 581 | __tree_node_base(__tree_node_base const&) = delete; |
| 575 | __tree_node_base& operator=(__tree_node_base const&) = delete; | 582 | __tree_node_base& operator=(__tree_node_base const&) = delete; |
| 576 | }; | 583 | }; |
| 577 | 584 | ||
| 578 | template <class _Tp, class _VoidPtr> | 585 | template <class _Tp, class _VoidPtr> |
| 579 | class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> { | 586 | class __tree_node : public __tree_node_base<_VoidPtr> { |
| 580 | public: | 587 | public: |
| 581 | using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>; | 588 | using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>; |
| 582 | 589 | ||
| 583 | __node_value_type __value_; | 590 | // We use a union to avoid initialization during member initialization, which allows us |
| 591 | // to use the allocator from the container to construct the `__node_value_type` in the | ||
| 592 | // memory provided by the union member | ||
| 593 | #ifndef _LIBCPP_CXX03_LANG | ||
| 594 | |||
| 595 | private: | ||
| 596 | union { | ||
| 597 | __node_value_type __value_; | ||
| 598 | }; | ||
| 584 | 599 | ||
| 600 | public: | ||
| 585 | _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; } | 601 | _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; } |
| 602 | #else | ||
| 603 | |||
| 604 | private: | ||
| 605 | _ALIGNAS_TYPE(__node_value_type) unsigned char __buffer_[sizeof(__node_value_type)]; | ||
| 606 | |||
| 607 | public: | ||
| 608 | _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return *reinterpret_cast<__node_value_type*>(__buffer_); } | ||
| 609 | #endif | ||
| 586 | 610 | ||
| 611 | template <class _Alloc, class... _Args> | ||
| 612 | _LIBCPP_HIDE_FROM_ABI explicit __tree_node(_Alloc& __na, _Args&&... __args) { | ||
| 613 | allocator_traits<_Alloc>::construct(__na, std::addressof(__get_value()), std::forward<_Args>(__args)...); | ||
| 614 | } | ||
| 587 | ~__tree_node() = delete; | 615 | ~__tree_node() = delete; |
| 588 | __tree_node(__tree_node const&) = delete; | 616 | __tree_node(__tree_node const&) = delete; |
| 589 | __tree_node& operator=(__tree_node const&) = delete; | 617 | __tree_node& operator=(__tree_node const&) = delete; |
| ... | @@ -591,11 +619,11 @@ public: | ... | @@ -591,11 +619,11 @@ public: |
| 591 | 619 | ||
| 592 | template <class _Allocator> | 620 | template <class _Allocator> |
| 593 | class __tree_node_destructor { | 621 | class __tree_node_destructor { |
| 594 | typedef _Allocator allocator_type; | 622 | using allocator_type = _Allocator; |
| 595 | typedef allocator_traits<allocator_type> __alloc_traits; | 623 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; |
| 596 | 624 | ||
| 597 | public: | 625 | public: |
| 598 | typedef typename __alloc_traits::pointer pointer; | 626 | using pointer = typename __alloc_traits::pointer; |
| 599 | 627 | ||
| 600 | private: | 628 | private: |
| 601 | allocator_type& __na_; | 629 | allocator_type& __na_; |
| ... | @@ -612,7 +640,7 @@ public: | ... | @@ -612,7 +640,7 @@ public: |
| 612 | 640 | ||
| 613 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { | 641 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 614 | if (__value_constructed) | 642 | if (__value_constructed) |
| 615 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_)); | 643 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value())); |
| 616 | if (__p) | 644 | if (__p) |
| 617 | __alloc_traits::deallocate(__na_, __p, 1); | 645 | __alloc_traits::deallocate(__na_, __p, 1); |
| 618 | } | 646 | } |
| ... | @@ -630,12 +658,60 @@ struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> : | ... | @@ -630,12 +658,60 @@ struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> : |
| 630 | }; | 658 | }; |
| 631 | #endif | 659 | #endif |
| 632 | 660 | ||
| 661 | // Do an in-order traversal of the tree until `__break` returns true. Takes the root node of the tree. | ||
| 662 | template <class _Reference, class _Break, class _NodePtr, class _Func, class _Proj> | ||
| 663 | #ifndef _LIBCPP_COMPILER_GCC // This function is recursive, so GCC complains about always_inline. | ||
| 664 | _LIBCPP_HIDE_FROM_ABI | ||
| 665 | #endif | ||
| 666 | bool __tree_iterate_from_root(_Break __break, _NodePtr __root, _Func& __func, _Proj& __proj) { | ||
| 667 | if (__root->__left_) { | ||
| 668 | if (std::__tree_iterate_from_root<_Reference>(__break, static_cast<_NodePtr>(__root->__left_), __func, __proj)) | ||
| 669 | return true; | ||
| 670 | } | ||
| 671 | if (__break(__root)) | ||
| 672 | return true; | ||
| 673 | std::__invoke(__func, std::__invoke(__proj, static_cast<_Reference>(__root->__get_value()))); | ||
| 674 | if (__root->__right_) | ||
| 675 | return std::__tree_iterate_from_root<_Reference>(__break, static_cast<_NodePtr>(__root->__right_), __func, __proj); | ||
| 676 | return false; | ||
| 677 | } | ||
| 678 | |||
| 679 | // Do an in-order traversal of the tree from __first to __last. | ||
| 680 | template <class _NodeIter, class _Func, class _Proj> | ||
| 681 | _LIBCPP_HIDE_FROM_ABI void | ||
| 682 | __tree_iterate_subrange(_NodeIter __first_it, _NodeIter __last_it, _Func& __func, _Proj& __proj) { | ||
| 683 | using _NodePtr = typename _NodeIter::__node_pointer; | ||
| 684 | using _Reference = typename _NodeIter::reference; | ||
| 685 | |||
| 686 | auto __first = __first_it.__ptr_; | ||
| 687 | auto __last = __last_it.__ptr_; | ||
| 688 | |||
| 689 | while (true) { | ||
| 690 | if (__first == __last) | ||
| 691 | return; | ||
| 692 | const auto __nfirst = static_cast<_NodePtr>(__first); | ||
| 693 | std::__invoke(__func, std::__invoke(__proj, static_cast<_Reference>(__nfirst->__get_value()))); | ||
| 694 | if (__nfirst->__right_) { | ||
| 695 | if (std::__tree_iterate_from_root<_Reference>( | ||
| 696 | [&](_NodePtr __node) -> bool { return __node == __last; }, | ||
| 697 | static_cast<_NodePtr>(__nfirst->__right_), | ||
| 698 | __func, | ||
| 699 | __proj)) | ||
| 700 | return; | ||
| 701 | } | ||
| 702 | while (!std::__tree_is_left_child(static_cast<_NodePtr>(__first))) | ||
| 703 | __first = static_cast<_NodePtr>(__first)->__parent_; | ||
| 704 | __first = static_cast<_NodePtr>(__first)->__parent_; | ||
| 705 | } | ||
| 706 | } | ||
| 707 | |||
| 633 | template <class _Tp, class _NodePtr, class _DiffType> | 708 | template <class _Tp, class _NodePtr, class _DiffType> |
| 634 | class __tree_iterator { | 709 | class __tree_iterator { |
| 635 | typedef __tree_node_types<_NodePtr> _NodeTypes; | 710 | using _NodeTypes _LIBCPP_NODEBUG = __tree_node_types<_NodePtr>; |
| 636 | typedef _NodePtr __node_pointer; | 711 | // NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing |
| 637 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; | 712 | using __node_pointer = _NodePtr; |
| 638 | typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; | 713 | using __node_base_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__node_base_pointer; |
| 714 | using __end_node_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__end_node_pointer; | ||
| 639 | 715 | ||
| 640 | __end_node_pointer __ptr_; | 716 | __end_node_pointer __ptr_; |
| 641 | 717 | ||
| ... | @@ -646,15 +722,12 @@ public: | ... | @@ -646,15 +722,12 @@ public: |
| 646 | using reference = value_type&; | 722 | using reference = value_type&; |
| 647 | using pointer = __rebind_pointer_t<_NodePtr, value_type>; | 723 | using pointer = __rebind_pointer_t<_NodePtr, value_type>; |
| 648 | 724 | ||
| 649 | _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT | 725 | _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT : __ptr_(nullptr) {} |
| 650 | #if _LIBCPP_STD_VER >= 14 | ||
| 651 | : __ptr_(nullptr) | ||
| 652 | #endif | ||
| 653 | { | ||
| 654 | } | ||
| 655 | 726 | ||
| 656 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__value_; } | 727 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__get_value(); } |
| 657 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); } | 728 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { |
| 729 | return pointer_traits<pointer>::pointer_to(__get_np()->__get_value()); | ||
| 730 | } | ||
| 658 | 731 | ||
| 659 | _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() { | 732 | _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() { |
| 660 | __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)); | 733 | __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)); |
| ... | @@ -691,50 +764,54 @@ private: | ... | @@ -691,50 +764,54 @@ private: |
| 691 | friend class __tree; | 764 | friend class __tree; |
| 692 | template <class, class, class> | 765 | template <class, class, class> |
| 693 | friend class __tree_const_iterator; | 766 | friend class __tree_const_iterator; |
| 694 | template <class> | 767 | |
| 695 | friend class __map_iterator; | 768 | template <class _NodeIter, class _Func, class _Proj> |
| 696 | template <class, class, class, class> | 769 | friend void __tree_iterate_subrange(_NodeIter, _NodeIter, _Func&, _Proj&); |
| 697 | friend class map; | 770 | }; |
| 698 | template <class, class, class, class> | 771 | |
| 699 | friend class multimap; | 772 | #ifndef _LIBCPP_CXX03_LANG |
| 700 | template <class, class, class> | 773 | // This also handles {multi,}set::iterator, since they're just aliases to __tree::iterator |
| 701 | friend class set; | 774 | template <class _Tp, class _NodePtr, class _DiffType> |
| 702 | template <class, class, class> | 775 | struct __specialized_algorithm< |
| 703 | friend class multiset; | 776 | _Algorithm::__for_each, |
| 777 | __iterator_pair<__tree_iterator<_Tp, _NodePtr, _DiffType>, __tree_iterator<_Tp, _NodePtr, _DiffType>>> { | ||
| 778 | static const bool __has_algorithm = true; | ||
| 779 | |||
| 780 | using __iterator _LIBCPP_NODEBUG = __tree_iterator<_Tp, _NodePtr, _DiffType>; | ||
| 781 | |||
| 782 | template <class _Func, class _Proj> | ||
| 783 | _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Func& __func, _Proj& __proj) { | ||
| 784 | std::__tree_iterate_subrange(__first, __last, __func, __proj); | ||
| 785 | } | ||
| 704 | }; | 786 | }; |
| 787 | #endif | ||
| 705 | 788 | ||
| 706 | template <class _Tp, class _NodePtr, class _DiffType> | 789 | template <class _Tp, class _NodePtr, class _DiffType> |
| 707 | class __tree_const_iterator { | 790 | class __tree_const_iterator { |
| 708 | typedef __tree_node_types<_NodePtr> _NodeTypes; | 791 | using _NodeTypes _LIBCPP_NODEBUG = __tree_node_types<_NodePtr>; |
| 709 | // NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing | 792 | // NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing |
| 710 | using __node_pointer = _NodePtr; | 793 | using __node_pointer = _NodePtr; |
| 711 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; | 794 | using __node_base_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__node_base_pointer; |
| 712 | typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; | 795 | using __end_node_pointer _LIBCPP_NODEBUG = typename _NodeTypes::__end_node_pointer; |
| 713 | 796 | ||
| 714 | __end_node_pointer __ptr_; | 797 | __end_node_pointer __ptr_; |
| 715 | 798 | ||
| 716 | public: | 799 | public: |
| 717 | using iterator_category = bidirectional_iterator_tag; | 800 | using iterator_category = bidirectional_iterator_tag; |
| 718 | using value_type = __get_node_value_type_t<_Tp>; | 801 | using value_type = __get_node_value_type_t<_Tp>; |
| 719 | using difference_type = _DiffType; | 802 | using difference_type = _DiffType; |
| 720 | using reference = const value_type&; | 803 | using reference = const value_type&; |
| 721 | using pointer = __rebind_pointer_t<_NodePtr, const value_type>; | 804 | using pointer = __rebind_pointer_t<_NodePtr, const value_type>; |
| 805 | using __non_const_iterator _LIBCPP_NODEBUG = __tree_iterator<_Tp, __node_pointer, difference_type>; | ||
| 722 | 806 | ||
| 723 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT | 807 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} |
| 724 | #if _LIBCPP_STD_VER >= 14 | ||
| 725 | : __ptr_(nullptr) | ||
| 726 | #endif | ||
| 727 | { | ||
| 728 | } | ||
| 729 | |||
| 730 | private: | ||
| 731 | typedef __tree_iterator<_Tp, __node_pointer, difference_type> __non_const_iterator; | ||
| 732 | 808 | ||
| 733 | public: | ||
| 734 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} | 809 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} |
| 735 | 810 | ||
| 736 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__value_; } | 811 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__get_value(); } |
| 737 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); } | 812 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { |
| 813 | return pointer_traits<pointer>::pointer_to(__get_np()->__get_value()); | ||
| 814 | } | ||
| 738 | 815 | ||
| 739 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() { | 816 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() { |
| 740 | __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)); | 817 | __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)); |
| ... | @@ -772,18 +849,28 @@ private: | ... | @@ -772,18 +849,28 @@ private: |
| 772 | 849 | ||
| 773 | template <class, class, class> | 850 | template <class, class, class> |
| 774 | friend class __tree; | 851 | friend class __tree; |
| 775 | template <class, class, class, class> | 852 | |
| 776 | friend class map; | 853 | template <class _NodeIter, class _Func, class _Proj> |
| 777 | template <class, class, class, class> | 854 | friend void __tree_iterate_subrange(_NodeIter, _NodeIter, _Func&, _Proj&); |
| 778 | friend class multimap; | ||
| 779 | template <class, class, class> | ||
| 780 | friend class set; | ||
| 781 | template <class, class, class> | ||
| 782 | friend class multiset; | ||
| 783 | template <class> | ||
| 784 | friend class __map_const_iterator; | ||
| 785 | }; | 855 | }; |
| 786 | 856 | ||
| 857 | #ifndef _LIBCPP_CXX03_LANG | ||
| 858 | // This also handles {multi,}set::const_iterator, since they're just aliases to __tree::iterator | ||
| 859 | template <class _Tp, class _NodePtr, class _DiffType> | ||
| 860 | struct __specialized_algorithm< | ||
| 861 | _Algorithm::__for_each, | ||
| 862 | __iterator_pair<__tree_const_iterator<_Tp, _NodePtr, _DiffType>, __tree_const_iterator<_Tp, _NodePtr, _DiffType>>> { | ||
| 863 | static const bool __has_algorithm = true; | ||
| 864 | |||
| 865 | using __iterator _LIBCPP_NODEBUG = __tree_const_iterator<_Tp, _NodePtr, _DiffType>; | ||
| 866 | |||
| 867 | template <class _Func, class _Proj> | ||
| 868 | _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Func& __func, _Proj& __proj) { | ||
| 869 | std::__tree_iterate_subrange(__first, __last, __func, __proj); | ||
| 870 | } | ||
| 871 | }; | ||
| 872 | #endif | ||
| 873 | |||
| 787 | template <class _Tp, class _Compare> | 874 | template <class _Tp, class _Compare> |
| 788 | #ifndef _LIBCPP_CXX03_LANG | 875 | #ifndef _LIBCPP_CXX03_LANG |
| 789 | _LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Compare const&, _Tp const&, _Tp const&>, | 876 | _LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Compare const&, _Tp const&, _Tp const&>, |
| ... | @@ -794,21 +881,20 @@ int __diagnose_non_const_comparator(); | ... | @@ -794,21 +881,20 @@ int __diagnose_non_const_comparator(); |
| 794 | template <class _Tp, class _Compare, class _Allocator> | 881 | template <class _Tp, class _Compare, class _Allocator> |
| 795 | class __tree { | 882 | class __tree { |
| 796 | public: | 883 | public: |
| 797 | using value_type = __get_node_value_type_t<_Tp>; | 884 | using value_type = __get_node_value_type_t<_Tp>; |
| 798 | typedef _Compare value_compare; | 885 | using value_compare = _Compare; |
| 799 | typedef _Allocator allocator_type; | 886 | using allocator_type = _Allocator; |
| 800 | 887 | ||
| 801 | private: | 888 | private: |
| 802 | typedef allocator_traits<allocator_type> __alloc_traits; | 889 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; |
| 803 | using key_type = __get_tree_key_type_t<_Tp>; | 890 | using key_type = __get_tree_key_type_t<_Tp>; |
| 804 | 891 | ||
| 805 | public: | 892 | public: |
| 806 | typedef typename __alloc_traits::pointer pointer; | 893 | using pointer = typename __alloc_traits::pointer; |
| 807 | typedef typename __alloc_traits::const_pointer const_pointer; | 894 | using const_pointer = typename __alloc_traits::const_pointer; |
| 808 | typedef typename __alloc_traits::size_type size_type; | 895 | using size_type = typename __alloc_traits::size_type; |
| 809 | typedef typename __alloc_traits::difference_type difference_type; | 896 | using difference_type = typename __alloc_traits::difference_type; |
| 810 | 897 | ||
| 811 | public: | ||
| 812 | using __void_pointer _LIBCPP_NODEBUG = typename __alloc_traits::void_pointer; | 898 | using __void_pointer _LIBCPP_NODEBUG = typename __alloc_traits::void_pointer; |
| 813 | 899 | ||
| 814 | using __node _LIBCPP_NODEBUG = __tree_node<_Tp, __void_pointer>; | 900 | using __node _LIBCPP_NODEBUG = __tree_node<_Tp, __void_pointer>; |
| ... | @@ -821,22 +907,8 @@ public: | ... | @@ -821,22 +907,8 @@ public: |
| 821 | using __end_node_t _LIBCPP_NODEBUG = __tree_end_node<__node_base_pointer>; | 907 | using __end_node_t _LIBCPP_NODEBUG = __tree_end_node<__node_base_pointer>; |
| 822 | using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __end_node_t>; | 908 | using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __end_node_t>; |
| 823 | 909 | ||
| 824 | using __parent_pointer _LIBCPP_NODEBUG = __end_node_pointer; // TODO: Remove this once the uses in <map> are removed | 910 | using __node_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, __node>; |
| 825 | 911 | using __node_traits _LIBCPP_NODEBUG = allocator_traits<__node_allocator>; | |
| 826 | typedef __rebind_alloc<__alloc_traits, __node> __node_allocator; | ||
| 827 | typedef allocator_traits<__node_allocator> __node_traits; | ||
| 828 | |||
| 829 | // TODO(LLVM 22): Remove this check | ||
| 830 | #ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | ||
| 831 | static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == | ||
| 832 | _LIBCPP_ALIGNOF(__end_node_pointer), | ||
| 833 | "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy " | ||
| 834 | "pointer type that thas a different representation depending on whether it points to a __tree base " | ||
| 835 | "pointer or a __tree node pointer (both of which are implementation details of the standard library). " | ||
| 836 | "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your " | ||
| 837 | "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this " | ||
| 838 | "diagnostic."); | ||
| 839 | #endif | ||
| 840 | 912 | ||
| 841 | private: | 913 | private: |
| 842 | // check for sane allocator pointer rebinding semantics. Rebinding the | 914 | // check for sane allocator pointer rebinding semantics. Rebinding the |
| ... | @@ -844,8 +916,8 @@ private: | ... | @@ -844,8 +916,8 @@ private: |
| 844 | // the pointer using 'pointer_traits'. | 916 | // the pointer using 'pointer_traits'. |
| 845 | static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value, | 917 | static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value, |
| 846 | "Allocator does not rebind pointers in a sane manner."); | 918 | "Allocator does not rebind pointers in a sane manner."); |
| 847 | typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator; | 919 | using __node_base_allocator _LIBCPP_NODEBUG = __rebind_alloc<__node_traits, __node_base>; |
| 848 | typedef allocator_traits<__node_base_allocator> __node_base_traits; | 920 | using __node_base_traits _LIBCPP_NODEBUG = allocator_traits<__node_base_allocator>; |
| 849 | static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value, | 921 | static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value, |
| 850 | "Allocator does not rebind pointers in a sane manner."); | 922 | "Allocator does not rebind pointers in a sane manner."); |
| 851 | 923 | ||
| ... | @@ -865,17 +937,11 @@ public: | ... | @@ -865,17 +937,11 @@ public: |
| 865 | 937 | ||
| 866 | private: | 938 | private: |
| 867 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } | 939 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } |
| 868 | _LIBCPP_HIDE_FROM_ABI __end_node_pointer& __begin_node() _NOEXCEPT { return __begin_node_; } | ||
| 869 | _LIBCPP_HIDE_FROM_ABI const __end_node_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } | ||
| 870 | 940 | ||
| 871 | public: | 941 | public: |
| 872 | _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } | 942 | _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } |
| 873 | 943 | ||
| 874 | private: | 944 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } |
| 875 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } | ||
| 876 | |||
| 877 | public: | ||
| 878 | _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __size_; } | ||
| 879 | _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; } | 945 | _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; } |
| 880 | _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; } | 946 | _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; } |
| 881 | 947 | ||
| ... | @@ -888,32 +954,61 @@ public: | ... | @@ -888,32 +954,61 @@ public: |
| 888 | return std::addressof(__end_node()->__left_); | 954 | return std::addressof(__end_node()->__left_); |
| 889 | } | 955 | } |
| 890 | 956 | ||
| 891 | typedef __tree_iterator<_Tp, __node_pointer, difference_type> iterator; | 957 | using iterator = __tree_iterator<_Tp, __node_pointer, difference_type>; |
| 892 | typedef __tree_const_iterator<_Tp, __node_pointer, difference_type> const_iterator; | 958 | using const_iterator = __tree_const_iterator<_Tp, __node_pointer, difference_type>; |
| 893 | 959 | ||
| 894 | _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_( | 960 | _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_( |
| 895 | is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value); | 961 | is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value) |
| 896 | _LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a); | 962 | : __size_(0), __value_comp_(__comp) { |
| 897 | _LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a); | 963 | __begin_node_ = __end_node(); |
| 964 | } | ||
| 965 | |||
| 966 | _LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a) | ||
| 967 | : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) { | ||
| 968 | __begin_node_ = __end_node(); | ||
| 969 | } | ||
| 970 | |||
| 971 | _LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a) | ||
| 972 | : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) { | ||
| 973 | __begin_node_ = __end_node(); | ||
| 974 | } | ||
| 975 | |||
| 898 | _LIBCPP_HIDE_FROM_ABI __tree(const __tree& __t); | 976 | _LIBCPP_HIDE_FROM_ABI __tree(const __tree& __t); |
| 977 | |||
| 978 | _LIBCPP_HIDE_FROM_ABI __tree(const __tree& __other, const allocator_type& __alloc) | ||
| 979 | : __begin_node_(__end_node()), __node_alloc_(__alloc), __size_(0), __value_comp_(__other.value_comp()) { | ||
| 980 | if (__other.size() == 0) | ||
| 981 | return; | ||
| 982 | |||
| 983 | *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__other.__root())); | ||
| 984 | __root()->__parent_ = __end_node(); | ||
| 985 | __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)); | ||
| 986 | __size_ = __other.size(); | ||
| 987 | } | ||
| 988 | |||
| 899 | _LIBCPP_HIDE_FROM_ABI __tree& operator=(const __tree& __t); | 989 | _LIBCPP_HIDE_FROM_ABI __tree& operator=(const __tree& __t); |
| 900 | template <class _ForwardIterator> | 990 | template <class _ForwardIterator> |
| 901 | _LIBCPP_HIDE_FROM_ABI void __assign_unique(_ForwardIterator __first, _ForwardIterator __last); | 991 | _LIBCPP_HIDE_FROM_ABI void __assign_unique(_ForwardIterator __first, _ForwardIterator __last); |
| 902 | template <class _InputIterator> | ||
| 903 | _LIBCPP_HIDE_FROM_ABI void __assign_multi(_InputIterator __first, _InputIterator __last); | ||
| 904 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_( | 992 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_( |
| 905 | is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value); | 993 | is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value); |
| 906 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a); | 994 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a); |
| 995 | |||
| 907 | _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t) | 996 | _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t) |
| 908 | _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value && | 997 | _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value && |
| 909 | ((__node_traits::propagate_on_container_move_assignment::value && | 998 | ((__node_traits::propagate_on_container_move_assignment::value && |
| 910 | is_nothrow_move_assignable<__node_allocator>::value) || | 999 | is_nothrow_move_assignable<__node_allocator>::value) || |
| 911 | allocator_traits<__node_allocator>::is_always_equal::value)); | 1000 | allocator_traits<__node_allocator>::is_always_equal::value)) { |
| 1001 | __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); | ||
| 1002 | return *this; | ||
| 1003 | } | ||
| 912 | 1004 | ||
| 913 | _LIBCPP_HIDE_FROM_ABI ~__tree(); | 1005 | _LIBCPP_HIDE_FROM_ABI ~__tree() { |
| 1006 | static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible."); | ||
| 1007 | destroy(__root()); | ||
| 1008 | } | ||
| 914 | 1009 | ||
| 915 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node()); } | 1010 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node_); } |
| 916 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__begin_node()); } | 1011 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__begin_node_); } |
| 917 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_node()); } | 1012 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_node()); } |
| 918 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_node()); } | 1013 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_node()); } |
| 919 | 1014 | ||
| ... | @@ -931,116 +1026,151 @@ public: | ... | @@ -931,116 +1026,151 @@ public: |
| 931 | _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>); | 1026 | _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>); |
| 932 | #endif | 1027 | #endif |
| 933 | 1028 | ||
| 934 | template <class _Key, class... _Args> | ||
| 935 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args&&... __args); | ||
| 936 | template <class _Key, class... _Args> | ||
| 937 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...); | ||
| 938 | |||
| 939 | template <class... _Args> | ||
| 940 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_impl(_Args&&... __args); | ||
| 941 | |||
| 942 | template <class... _Args> | ||
| 943 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args); | ||
| 944 | |||
| 945 | template <class... _Args> | 1029 | template <class... _Args> |
| 946 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_multi(_Args&&... __args); | 1030 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_multi(_Args&&... __args); |
| 947 | 1031 | ||
| 948 | template <class... _Args> | 1032 | template <class... _Args> |
| 949 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); | 1033 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); |
| 950 | 1034 | ||
| 951 | template <class _Pp> | ||
| 952 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Pp&& __x) { | ||
| 953 | return __emplace_unique_extract_key(std::forward<_Pp>(__x), __can_extract_key<_Pp, key_type>()); | ||
| 954 | } | ||
| 955 | |||
| 956 | template <class _First, | ||
| 957 | class _Second, | ||
| 958 | __enable_if_t<__can_extract_map_key<_First, key_type, value_type>::value, int> = 0> | ||
| 959 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) { | ||
| 960 | return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s)); | ||
| 961 | } | ||
| 962 | |||
| 963 | template <class... _Args> | 1035 | template <class... _Args> |
| 964 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Args&&... __args) { | 1036 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Args&&... __args) { |
| 965 | return __emplace_unique_impl(std::forward<_Args>(__args)...); | 1037 | return std::__try_key_extraction<key_type>( |
| 966 | } | 1038 | [this](const key_type& __key, _Args&&... __args2) { |
| 967 | 1039 | auto [__parent, __child] = __find_equal(__key); | |
| 968 | template <class _Pp> | 1040 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 969 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { | 1041 | bool __inserted = false; |
| 970 | return __emplace_unique_impl(std::forward<_Pp>(__x)); | 1042 | if (__child == nullptr) { |
| 971 | } | 1043 | __node_holder __h = __construct_node(std::forward<_Args>(__args2)...); |
| 972 | 1044 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | |
| 973 | template <class _Pp> | 1045 | __r = __h.release(); |
| 974 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { | 1046 | __inserted = true; |
| 975 | return __emplace_unique_key_args(__x, std::forward<_Pp>(__x)); | 1047 | } |
| 976 | } | 1048 | return pair<iterator, bool>(iterator(__r), __inserted); |
| 977 | 1049 | }, | |
| 978 | template <class _Pp> | 1050 | [this](_Args&&... __args2) { |
| 979 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { | 1051 | __node_holder __h = __construct_node(std::forward<_Args>(__args2)...); |
| 980 | return __emplace_unique_key_args(__x.first, std::forward<_Pp>(__x)); | 1052 | auto [__parent, __child] = __find_equal(__h->__get_value()); |
| 981 | } | 1053 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 982 | 1054 | bool __inserted = false; | |
| 983 | template <class _Pp> | 1055 | if (__child == nullptr) { |
| 984 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) { | 1056 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
| 985 | return __emplace_hint_unique_extract_key(__p, std::forward<_Pp>(__x), __can_extract_key<_Pp, key_type>()); | 1057 | __r = __h.release(); |
| 986 | } | 1058 | __inserted = true; |
| 987 | 1059 | } | |
| 988 | template <class _First, | 1060 | return pair<iterator, bool>(iterator(__r), __inserted); |
| 989 | class _Second, | 1061 | }, |
| 990 | __enable_if_t<__can_extract_map_key<_First, key_type, value_type>::value, int> = 0> | 1062 | std::forward<_Args>(__args)...); |
| 991 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { | ||
| 992 | return __emplace_hint_unique_key_args(__p, __f, std::forward<_First>(__f), std::forward<_Second>(__s)).first; | ||
| 993 | } | 1063 | } |
| 994 | 1064 | ||
| 995 | template <class... _Args> | 1065 | template <class... _Args> |
| 996 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) { | 1066 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_hint_unique(const_iterator __p, _Args&&... __args) { |
| 997 | return __emplace_hint_unique_impl(__p, std::forward<_Args>(__args)...); | 1067 | return std::__try_key_extraction<key_type>( |
| 1068 | [this, __p](const key_type& __key, _Args&&... __args2) { | ||
| 1069 | __node_base_pointer __dummy; | ||
| 1070 | auto [__parent, __child] = __find_equal(__p, __dummy, __key); | ||
| 1071 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1072 | bool __inserted = false; | ||
| 1073 | if (__child == nullptr) { | ||
| 1074 | __node_holder __h = __construct_node(std::forward<_Args>(__args2)...); | ||
| 1075 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | ||
| 1076 | __r = __h.release(); | ||
| 1077 | __inserted = true; | ||
| 1078 | } | ||
| 1079 | return pair<iterator, bool>(iterator(__r), __inserted); | ||
| 1080 | }, | ||
| 1081 | [this, __p](_Args&&... __args2) { | ||
| 1082 | __node_holder __h = __construct_node(std::forward<_Args>(__args2)...); | ||
| 1083 | __node_base_pointer __dummy; | ||
| 1084 | auto [__parent, __child] = __find_equal(__p, __dummy, __h->__get_value()); | ||
| 1085 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1086 | if (__child == nullptr) { | ||
| 1087 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | ||
| 1088 | __r = __h.release(); | ||
| 1089 | } | ||
| 1090 | return pair<iterator, bool>(iterator(__r), __child == nullptr); | ||
| 1091 | }, | ||
| 1092 | std::forward<_Args>(__args)...); | ||
| 998 | } | 1093 | } |
| 999 | 1094 | ||
| 1000 | template <class _Pp> | 1095 | template <class _InIter, class _Sent> |
| 1001 | _LIBCPP_HIDE_FROM_ABI iterator | 1096 | _LIBCPP_HIDE_FROM_ABI void __insert_range_multi(_InIter __first, _Sent __last) { |
| 1002 | __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_fail_tag) { | 1097 | if (__first == __last) |
| 1003 | return __emplace_hint_unique_impl(__p, std::forward<_Pp>(__x)); | 1098 | return; |
| 1004 | } | ||
| 1005 | 1099 | ||
| 1006 | template <class _Pp> | 1100 | if (__root() == nullptr) { // Make sure we always have a root node |
| 1007 | _LIBCPP_HIDE_FROM_ABI iterator | 1101 | __insert_node_at( |
| 1008 | __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) { | 1102 | __end_node(), __end_node()->__left_, static_cast<__node_base_pointer>(__construct_node(*__first).release())); |
| 1009 | return __emplace_hint_unique_key_args(__p, __x, std::forward<_Pp>(__x)).first; | 1103 | ++__first; |
| 1010 | } | 1104 | } |
| 1011 | 1105 | ||
| 1012 | template <class _Pp> | 1106 | auto __max_node = static_cast<__node_pointer>(std::__tree_max(static_cast<__node_base_pointer>(__root()))); |
| 1013 | _LIBCPP_HIDE_FROM_ABI iterator | ||
| 1014 | __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) { | ||
| 1015 | return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first; | ||
| 1016 | } | ||
| 1017 | 1107 | ||
| 1018 | template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0> | 1108 | for (; __first != __last; ++__first) { |
| 1019 | _LIBCPP_HIDE_FROM_ABI void | 1109 | __node_holder __nd = __construct_node(*__first); |
| 1020 | __insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) { | 1110 | // Always check the max node first. This optimizes for sorted ranges inserted at the end. |
| 1021 | __emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second)); | 1111 | if (!value_comp()(__nd->__get_value(), __max_node->__get_value())) { // __node >= __max_val |
| 1112 | __insert_node_at(static_cast<__end_node_pointer>(__max_node), | ||
| 1113 | __max_node->__right_, | ||
| 1114 | static_cast<__node_base_pointer>(__nd.get())); | ||
| 1115 | __max_node = __nd.release(); | ||
| 1116 | } else { | ||
| 1117 | __end_node_pointer __parent; | ||
| 1118 | __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__get_value()); | ||
| 1119 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release())); | ||
| 1120 | } | ||
| 1121 | } | ||
| 1022 | } | 1122 | } |
| 1023 | 1123 | ||
| 1024 | template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0> | 1124 | template <class _InIter, class _Sent> |
| 1025 | _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) { | 1125 | _LIBCPP_HIDE_FROM_ABI void __insert_range_unique(_InIter __first, _Sent __last) { |
| 1026 | __emplace_hint_unique(__p, std::move(__value)); | 1126 | if (__first == __last) |
| 1027 | } | 1127 | return; |
| 1028 | 1128 | ||
| 1029 | template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0> | 1129 | if (__root() == nullptr) { |
| 1030 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) { | 1130 | __insert_node_at( |
| 1031 | __emplace_hint_multi(__p, const_cast<key_type&&>(__value.first), std::move(__value.second)); | 1131 | __end_node(), __end_node()->__left_, static_cast<__node_base_pointer>(__construct_node(*__first).release())); |
| 1032 | } | 1132 | ++__first; |
| 1133 | } | ||
| 1033 | 1134 | ||
| 1034 | template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0> | 1135 | auto __max_node = static_cast<__node_pointer>(std::__tree_max(static_cast<__node_base_pointer>(__root()))); |
| 1035 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) { | 1136 | |
| 1036 | __emplace_hint_multi(__p, std::move(__value)); | 1137 | using __reference = decltype(*__first); |
| 1138 | |||
| 1139 | for (; __first != __last; ++__first) { | ||
| 1140 | std::__try_key_extraction<key_type>( | ||
| 1141 | [this, &__max_node](const key_type& __key, __reference&& __val) { | ||
| 1142 | if (value_comp()(__max_node->__get_value(), __key)) { // __key > __max_node | ||
| 1143 | __node_holder __nd = __construct_node(std::forward<__reference>(__val)); | ||
| 1144 | __insert_node_at(static_cast<__end_node_pointer>(__max_node), | ||
| 1145 | __max_node->__right_, | ||
| 1146 | static_cast<__node_base_pointer>(__nd.get())); | ||
| 1147 | __max_node = __nd.release(); | ||
| 1148 | } else { | ||
| 1149 | auto [__parent, __child] = __find_equal(__key); | ||
| 1150 | if (__child == nullptr) { | ||
| 1151 | __node_holder __nd = __construct_node(std::forward<__reference>(__val)); | ||
| 1152 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release())); | ||
| 1153 | } | ||
| 1154 | } | ||
| 1155 | }, | ||
| 1156 | [this, &__max_node](__reference&& __val) { | ||
| 1157 | __node_holder __nd = __construct_node(std::forward<__reference>(__val)); | ||
| 1158 | if (value_comp()(__max_node->__get_value(), __nd->__get_value())) { // __node > __max_node | ||
| 1159 | __insert_node_at(static_cast<__end_node_pointer>(__max_node), | ||
| 1160 | __max_node->__right_, | ||
| 1161 | static_cast<__node_base_pointer>(__nd.get())); | ||
| 1162 | __max_node = __nd.release(); | ||
| 1163 | } else { | ||
| 1164 | auto [__parent, __child] = __find_equal(__nd->__get_value()); | ||
| 1165 | if (__child == nullptr) { | ||
| 1166 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release())); | ||
| 1167 | } | ||
| 1168 | } | ||
| 1169 | }, | ||
| 1170 | *__first); | ||
| 1171 | } | ||
| 1037 | } | 1172 | } |
| 1038 | 1173 | ||
| 1039 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __node_assign_unique(const value_type& __v, __node_pointer __dest); | ||
| 1040 | |||
| 1041 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd); | ||
| 1042 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); | ||
| 1043 | |||
| 1044 | _LIBCPP_HIDE_FROM_ABI iterator __remove_node_pointer(__node_pointer) _NOEXCEPT; | 1174 | _LIBCPP_HIDE_FROM_ABI iterator __remove_node_pointer(__node_pointer) _NOEXCEPT; |
| 1045 | 1175 | ||
| 1046 | #if _LIBCPP_STD_VER >= 17 | 1176 | #if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1048,15 +1178,15 @@ public: | ... | @@ -1048,15 +1178,15 @@ public: |
| 1048 | _LIBCPP_HIDE_FROM_ABI _InsertReturnType __node_handle_insert_unique(_NodeHandle&&); | 1178 | _LIBCPP_HIDE_FROM_ABI _InsertReturnType __node_handle_insert_unique(_NodeHandle&&); |
| 1049 | template <class _NodeHandle> | 1179 | template <class _NodeHandle> |
| 1050 | _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&); | 1180 | _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&); |
| 1051 | template <class _Tree> | 1181 | template <class _Comp2> |
| 1052 | _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(_Tree& __source); | 1182 | _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source); |
| 1053 | 1183 | ||
| 1054 | template <class _NodeHandle> | 1184 | template <class _NodeHandle> |
| 1055 | _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(_NodeHandle&&); | 1185 | _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(_NodeHandle&&); |
| 1056 | template <class _NodeHandle> | 1186 | template <class _NodeHandle> |
| 1057 | _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&); | 1187 | _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&); |
| 1058 | template <class _Tree> | 1188 | template <class _Comp2> |
| 1059 | _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(_Tree& __source); | 1189 | _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source); |
| 1060 | 1190 | ||
| 1061 | template <class _NodeHandle> | 1191 | template <class _NodeHandle> |
| 1062 | _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(key_type const&); | 1192 | _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(key_type const&); |
| ... | @@ -1075,41 +1205,157 @@ public: | ... | @@ -1075,41 +1205,157 @@ public: |
| 1075 | __insert_node_at(__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT; | 1205 | __insert_node_at(__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT; |
| 1076 | 1206 | ||
| 1077 | template <class _Key> | 1207 | template <class _Key> |
| 1078 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __v); | 1208 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __key) { |
| 1209 | auto [__, __match] = __find_equal(__key); | ||
| 1210 | if (__match == nullptr) | ||
| 1211 | return end(); | ||
| 1212 | return iterator(static_cast<__node_pointer>(__match)); | ||
| 1213 | } | ||
| 1214 | |||
| 1079 | template <class _Key> | 1215 | template <class _Key> |
| 1080 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Key& __v) const; | 1216 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Key& __key) const { |
| 1217 | auto [__, __match] = __find_equal(__key); | ||
| 1218 | if (__match == nullptr) | ||
| 1219 | return end(); | ||
| 1220 | return const_iterator(static_cast<__node_pointer>(__match)); | ||
| 1221 | } | ||
| 1081 | 1222 | ||
| 1082 | template <class _Key> | 1223 | template <class _Key> |
| 1083 | _LIBCPP_HIDE_FROM_ABI size_type __count_unique(const _Key& __k) const; | 1224 | _LIBCPP_HIDE_FROM_ABI size_type __count_unique(const _Key& __k) const; |
| 1084 | template <class _Key> | 1225 | template <class _Key> |
| 1085 | _LIBCPP_HIDE_FROM_ABI size_type __count_multi(const _Key& __k) const; | 1226 | _LIBCPP_HIDE_FROM_ABI size_type __count_multi(const _Key& __k) const; |
| 1086 | 1227 | ||
| 1228 | template <bool _LowerBound, class _Key> | ||
| 1229 | _LIBCPP_HIDE_FROM_ABI __end_node_pointer __lower_upper_bound_unique_impl(const _Key& __v) const { | ||
| 1230 | auto __rt = __root(); | ||
| 1231 | auto __result = __end_node(); | ||
| 1232 | auto __comp = __lazy_synth_three_way_comparator<_Compare, _Key, value_type>(value_comp()); | ||
| 1233 | while (__rt != nullptr) { | ||
| 1234 | auto __comp_res = __comp(__v, __rt->__get_value()); | ||
| 1235 | |||
| 1236 | if (__comp_res.__less()) { | ||
| 1237 | __result = static_cast<__end_node_pointer>(__rt); | ||
| 1238 | __rt = static_cast<__node_pointer>(__rt->__left_); | ||
| 1239 | } else if (__comp_res.__greater()) { | ||
| 1240 | __rt = static_cast<__node_pointer>(__rt->__right_); | ||
| 1241 | } else if _LIBCPP_CONSTEXPR (_LowerBound) { | ||
| 1242 | return static_cast<__end_node_pointer>(__rt); | ||
| 1243 | } else { | ||
| 1244 | return __rt->__right_ ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) : __result; | ||
| 1245 | } | ||
| 1246 | } | ||
| 1247 | return __result; | ||
| 1248 | } | ||
| 1249 | |||
| 1250 | // Compatibility escape hatch for comparators that are not strict weak orderings. This | ||
| 1251 | // can be removed for the LLVM 23 release. | ||
| 1252 | #if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND) | ||
| 1087 | template <class _Key> | 1253 | template <class _Key> |
| 1088 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Key& __v) { | 1254 | _LIBCPP_HIDE_FROM_ABI __end_node_pointer __lower_bound_unique_compat_impl(const _Key& __v) const { |
| 1089 | return __lower_bound(__v, __root(), __end_node()); | 1255 | auto __rt = __root(); |
| 1256 | auto __result = __end_node(); | ||
| 1257 | while (__rt != nullptr) { | ||
| 1258 | if (!value_comp()(__rt->__get_value(), __v)) { | ||
| 1259 | __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt); | ||
| 1260 | __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_); | ||
| 1261 | } else { | ||
| 1262 | __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_); | ||
| 1263 | } | ||
| 1264 | } | ||
| 1265 | return __result; | ||
| 1090 | } | 1266 | } |
| 1267 | |||
| 1091 | template <class _Key> | 1268 | template <class _Key> |
| 1092 | _LIBCPP_HIDE_FROM_ABI iterator __lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result); | 1269 | _LIBCPP_HIDE_FROM_ABI __end_node_pointer __upper_bound_unique_compat_impl(const _Key& __v) const { |
| 1270 | auto __rt = __root(); | ||
| 1271 | auto __result = __end_node(); | ||
| 1272 | while (__rt != nullptr) { | ||
| 1273 | if (value_comp()(__v, __rt->__get_value())) { | ||
| 1274 | __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt); | ||
| 1275 | __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_); | ||
| 1276 | } else { | ||
| 1277 | __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_); | ||
| 1278 | } | ||
| 1279 | } | ||
| 1280 | return __result; | ||
| 1281 | } | ||
| 1282 | #endif // _LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND | ||
| 1283 | |||
| 1093 | template <class _Key> | 1284 | template <class _Key> |
| 1094 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Key& __v) const { | 1285 | _LIBCPP_HIDE_FROM_ABI iterator __lower_bound_unique(const _Key& __v) { |
| 1095 | return __lower_bound(__v, __root(), __end_node()); | 1286 | #if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND) |
| 1287 | return iterator(__lower_bound_unique_compat_impl(__v)); | ||
| 1288 | #else | ||
| 1289 | return iterator(__lower_upper_bound_unique_impl<true>(__v)); | ||
| 1290 | #endif | ||
| 1096 | } | 1291 | } |
| 1292 | |||
| 1293 | template <class _Key> | ||
| 1294 | _LIBCPP_HIDE_FROM_ABI const_iterator __lower_bound_unique(const _Key& __v) const { | ||
| 1295 | #if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND) | ||
| 1296 | return const_iterator(__lower_bound_unique_compat_impl(__v)); | ||
| 1297 | #else | ||
| 1298 | return const_iterator(__lower_upper_bound_unique_impl<true>(__v)); | ||
| 1299 | #endif | ||
| 1300 | } | ||
| 1301 | |||
| 1302 | template <class _Key> | ||
| 1303 | _LIBCPP_HIDE_FROM_ABI iterator __upper_bound_unique(const _Key& __v) { | ||
| 1304 | #if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND) | ||
| 1305 | return iterator(__upper_bound_unique_compat_impl(__v)); | ||
| 1306 | #else | ||
| 1307 | return iterator(__lower_upper_bound_unique_impl<false>(__v)); | ||
| 1308 | #endif | ||
| 1309 | } | ||
| 1310 | |||
| 1311 | template <class _Key> | ||
| 1312 | _LIBCPP_HIDE_FROM_ABI const_iterator __upper_bound_unique(const _Key& __v) const { | ||
| 1313 | #if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND) | ||
| 1314 | return iterator(__upper_bound_unique_compat_impl(__v)); | ||
| 1315 | #else | ||
| 1316 | return iterator(__lower_upper_bound_unique_impl<false>(__v)); | ||
| 1317 | #endif | ||
| 1318 | } | ||
| 1319 | |||
| 1320 | private: | ||
| 1321 | template <class _Key> | ||
| 1322 | _LIBCPP_HIDE_FROM_ABI iterator | ||
| 1323 | __lower_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result); | ||
| 1324 | |||
| 1097 | template <class _Key> | 1325 | template <class _Key> |
| 1098 | _LIBCPP_HIDE_FROM_ABI const_iterator | 1326 | _LIBCPP_HIDE_FROM_ABI const_iterator |
| 1099 | __lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const; | 1327 | __lower_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const; |
| 1328 | |||
| 1329 | public: | ||
| 1100 | template <class _Key> | 1330 | template <class _Key> |
| 1101 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Key& __v) { | 1331 | _LIBCPP_HIDE_FROM_ABI iterator __lower_bound_multi(const _Key& __v) { |
| 1102 | return __upper_bound(__v, __root(), __end_node()); | 1332 | return __lower_bound_multi(__v, __root(), __end_node()); |
| 1103 | } | 1333 | } |
| 1104 | template <class _Key> | 1334 | template <class _Key> |
| 1105 | _LIBCPP_HIDE_FROM_ABI iterator __upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result); | 1335 | _LIBCPP_HIDE_FROM_ABI const_iterator __lower_bound_multi(const _Key& __v) const { |
| 1336 | return __lower_bound_multi(__v, __root(), __end_node()); | ||
| 1337 | } | ||
| 1338 | |||
| 1339 | template <class _Key> | ||
| 1340 | _LIBCPP_HIDE_FROM_ABI iterator __upper_bound_multi(const _Key& __v) { | ||
| 1341 | return __upper_bound_multi(__v, __root(), __end_node()); | ||
| 1342 | } | ||
| 1343 | |||
| 1106 | template <class _Key> | 1344 | template <class _Key> |
| 1107 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Key& __v) const { | 1345 | _LIBCPP_HIDE_FROM_ABI const_iterator __upper_bound_multi(const _Key& __v) const { |
| 1108 | return __upper_bound(__v, __root(), __end_node()); | 1346 | return __upper_bound_multi(__v, __root(), __end_node()); |
| 1109 | } | 1347 | } |
| 1348 | |||
| 1349 | private: | ||
| 1350 | template <class _Key> | ||
| 1351 | _LIBCPP_HIDE_FROM_ABI iterator | ||
| 1352 | __upper_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result); | ||
| 1353 | |||
| 1110 | template <class _Key> | 1354 | template <class _Key> |
| 1111 | _LIBCPP_HIDE_FROM_ABI const_iterator | 1355 | _LIBCPP_HIDE_FROM_ABI const_iterator |
| 1112 | __upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const; | 1356 | __upper_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const; |
| 1357 | |||
| 1358 | public: | ||
| 1113 | template <class _Key> | 1359 | template <class _Key> |
| 1114 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k); | 1360 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k); |
| 1115 | template <class _Key> | 1361 | template <class _Key> |
| ... | @@ -1120,22 +1366,24 @@ public: | ... | @@ -1120,22 +1366,24 @@ public: |
| 1120 | template <class _Key> | 1366 | template <class _Key> |
| 1121 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const; | 1367 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const; |
| 1122 | 1368 | ||
| 1123 | typedef __tree_node_destructor<__node_allocator> _Dp; | 1369 | using _Dp _LIBCPP_NODEBUG = __tree_node_destructor<__node_allocator>; |
| 1124 | typedef unique_ptr<__node, _Dp> __node_holder; | 1370 | using __node_holder _LIBCPP_NODEBUG = unique_ptr<__node, _Dp>; |
| 1125 | 1371 | ||
| 1126 | _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT; | 1372 | _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT; |
| 1127 | 1373 | ||
| 1128 | // FIXME: Make this function const qualified. Unfortunately doing so | 1374 | // FIXME: Make this function const qualified. Unfortunately doing so |
| 1129 | // breaks existing code which uses non-const callable comparators. | 1375 | // breaks existing code which uses non-const callable comparators. |
| 1130 | template <class _Key> | 1376 | template <class _Key> |
| 1131 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__end_node_pointer& __parent, const _Key& __v); | 1377 | _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&> __find_equal(const _Key& __v); |
| 1378 | |||
| 1132 | template <class _Key> | 1379 | template <class _Key> |
| 1133 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__end_node_pointer& __parent, const _Key& __v) const { | 1380 | _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&> __find_equal(const _Key& __v) const { |
| 1134 | return const_cast<__tree*>(this)->__find_equal(__parent, __v); | 1381 | return const_cast<__tree*>(this)->__find_equal(__v); |
| 1135 | } | 1382 | } |
| 1383 | |||
| 1136 | template <class _Key> | 1384 | template <class _Key> |
| 1137 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& | 1385 | _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&> |
| 1138 | __find_equal(const_iterator __hint, __end_node_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v); | 1386 | __find_equal(const_iterator __hint, __node_base_pointer& __dummy, const _Key& __v); |
| 1139 | 1387 | ||
| 1140 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) { | 1388 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) { |
| 1141 | __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); | 1389 | __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); |
| ... | @@ -1160,7 +1408,7 @@ private: | ... | @@ -1160,7 +1408,7 @@ private: |
| 1160 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args); | 1408 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args); |
| 1161 | 1409 | ||
| 1162 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI | 1410 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI |
| 1163 | _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT; | 1411 | _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT { (__tree_deleter(__node_alloc_))(__nd); } |
| 1164 | 1412 | ||
| 1165 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type); | 1413 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type); |
| 1166 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_( | 1414 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_( |
| ... | @@ -1178,7 +1426,7 @@ private: | ... | @@ -1178,7 +1426,7 @@ private: |
| 1178 | } | 1426 | } |
| 1179 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} | 1427 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} |
| 1180 | 1428 | ||
| 1181 | template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0> | 1429 | template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0> |
| 1182 | _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) { | 1430 | _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) { |
| 1183 | using __key_type = __remove_const_t<typename value_type::first_type>; | 1431 | using __key_type = __remove_const_t<typename value_type::first_type>; |
| 1184 | 1432 | ||
| ... | @@ -1188,166 +1436,203 @@ private: | ... | @@ -1188,166 +1436,203 @@ private: |
| 1188 | __lhs.second = std::forward<_From>(__rhs).second; | 1436 | __lhs.second = std::forward<_From>(__rhs).second; |
| 1189 | } | 1437 | } |
| 1190 | 1438 | ||
| 1191 | template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0> | 1439 | template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0> |
| 1192 | _LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) { | 1440 | _LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) { |
| 1193 | __lhs = std::forward<_From>(__rhs); | 1441 | __lhs = std::forward<_From>(__rhs); |
| 1194 | } | 1442 | } |
| 1195 | 1443 | ||
| 1196 | struct _DetachedTreeCache { | 1444 | class __tree_deleter { |
| 1197 | _LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT | 1445 | __node_allocator& __alloc_; |
| 1198 | : __t_(__t), | 1446 | |
| 1199 | __cache_root_(__detach_from_tree(__t)) { | 1447 | public: |
| 1200 | __advance(); | 1448 | using pointer = __node_pointer; |
| 1449 | |||
| 1450 | _LIBCPP_HIDE_FROM_ABI __tree_deleter(__node_allocator& __alloc) : __alloc_(__alloc) {} | ||
| 1451 | |||
| 1452 | #ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function | ||
| 1453 | _LIBCPP_HIDE_FROM_ABI | ||
| 1454 | #endif | ||
| 1455 | void | ||
| 1456 | operator()(__node_pointer __ptr) { | ||
| 1457 | if (!__ptr) | ||
| 1458 | return; | ||
| 1459 | |||
| 1460 | (*this)(static_cast<__node_pointer>(__ptr->__left_)); | ||
| 1461 | |||
| 1462 | auto __right = __ptr->__right_; | ||
| 1463 | |||
| 1464 | __node_traits::destroy(__alloc_, std::addressof(__ptr->__get_value())); | ||
| 1465 | __node_traits::deallocate(__alloc_, __ptr, 1); | ||
| 1466 | |||
| 1467 | (*this)(static_cast<__node_pointer>(__right)); | ||
| 1201 | } | 1468 | } |
| 1469 | }; | ||
| 1470 | |||
| 1471 | // This copy construction will always produce a correct red-black-tree assuming the incoming tree is correct, since we | ||
| 1472 | // copy the exact structure 1:1. Since this is for copy construction _only_ we know that we get a correct tree. If we | ||
| 1473 | // didn't get a correct tree, the invariants of __tree are broken and we have a much bigger problem than an improperly | ||
| 1474 | // balanced tree. | ||
| 1475 | template <class _NodeConstructor> | ||
| 1476 | #ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function | ||
| 1477 | _LIBCPP_HIDE_FROM_ABI | ||
| 1478 | #endif | ||
| 1479 | __node_pointer __construct_from_tree(__node_pointer __src, _NodeConstructor __construct) { | ||
| 1480 | if (!__src) | ||
| 1481 | return nullptr; | ||
| 1202 | 1482 | ||
| 1203 | _LIBCPP_HIDE_FROM_ABI __node_pointer __get() const _NOEXCEPT { return __cache_elem_; } | 1483 | __node_holder __new_node = __construct(__src->__get_value()); |
| 1204 | 1484 | ||
| 1205 | _LIBCPP_HIDE_FROM_ABI void __advance() _NOEXCEPT { | 1485 | unique_ptr<__node, __tree_deleter> __left( |
| 1206 | __cache_elem_ = __cache_root_; | 1486 | __construct_from_tree(static_cast<__node_pointer>(__src->__left_), __construct), __node_alloc_); |
| 1207 | if (__cache_root_) { | 1487 | __node_pointer __right = __construct_from_tree(static_cast<__node_pointer>(__src->__right_), __construct); |
| 1208 | __cache_root_ = __detach_next(__cache_root_); | 1488 | |
| 1209 | } | 1489 | __node_pointer __new_node_ptr = __new_node.release(); |
| 1490 | |||
| 1491 | __new_node_ptr->__is_black_ = __src->__is_black_; | ||
| 1492 | __new_node_ptr->__left_ = static_cast<__node_base_pointer>(__left.release()); | ||
| 1493 | __new_node_ptr->__right_ = static_cast<__node_base_pointer>(__right); | ||
| 1494 | if (__new_node_ptr->__left_) | ||
| 1495 | __new_node_ptr->__left_->__parent_ = static_cast<__end_node_pointer>(__new_node_ptr); | ||
| 1496 | if (__new_node_ptr->__right_) | ||
| 1497 | __new_node_ptr->__right_->__parent_ = static_cast<__end_node_pointer>(__new_node_ptr); | ||
| 1498 | return __new_node_ptr; | ||
| 1499 | } | ||
| 1500 | |||
| 1501 | _LIBCPP_HIDE_FROM_ABI __node_pointer __copy_construct_tree(__node_pointer __src) { | ||
| 1502 | return __construct_from_tree(__src, [this](const value_type& __val) { return __construct_node(__val); }); | ||
| 1503 | } | ||
| 1504 | |||
| 1505 | template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0> | ||
| 1506 | _LIBCPP_HIDE_FROM_ABI __node_pointer __move_construct_tree(__node_pointer __src) { | ||
| 1507 | return __construct_from_tree(__src, [this](value_type& __val) { | ||
| 1508 | return __construct_node(const_cast<key_type&&>(__val.first), std::move(__val.second)); | ||
| 1509 | }); | ||
| 1510 | } | ||
| 1511 | |||
| 1512 | template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0> | ||
| 1513 | _LIBCPP_HIDE_FROM_ABI __node_pointer __move_construct_tree(__node_pointer __src) { | ||
| 1514 | return __construct_from_tree(__src, [this](value_type& __val) { return __construct_node(std::move(__val)); }); | ||
| 1515 | } | ||
| 1516 | |||
| 1517 | template <class _Assignment, class _ConstructionAlg> | ||
| 1518 | // This copy assignment will always produce a correct red-black-tree assuming the incoming tree is correct, since our | ||
| 1519 | // own tree is a red-black-tree and the incoming tree is a red-black-tree. The invariants of a red-black-tree are | ||
| 1520 | // temporarily not met until all of the incoming red-black tree is copied. | ||
| 1521 | #ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function | ||
| 1522 | _LIBCPP_HIDE_FROM_ABI | ||
| 1523 | #endif | ||
| 1524 | __node_pointer __assign_from_tree( | ||
| 1525 | __node_pointer __dest, __node_pointer __src, _Assignment __assign, _ConstructionAlg __construct_subtree) { | ||
| 1526 | if (!__src) { | ||
| 1527 | destroy(__dest); | ||
| 1528 | return nullptr; | ||
| 1210 | } | 1529 | } |
| 1211 | 1530 | ||
| 1212 | _LIBCPP_HIDE_FROM_ABI ~_DetachedTreeCache() { | 1531 | __assign(__dest->__get_value(), __src->__get_value()); |
| 1213 | __t_->destroy(__cache_elem_); | 1532 | __dest->__is_black_ = __src->__is_black_; |
| 1214 | if (__cache_root_) { | 1533 | |
| 1215 | while (__cache_root_->__parent_ != nullptr) | 1534 | // If we already have a left node in the destination tree, reuse it and copy-assign recursively |
| 1216 | __cache_root_ = static_cast<__node_pointer>(__cache_root_->__parent_); | 1535 | if (__dest->__left_) { |
| 1217 | __t_->destroy(__cache_root_); | 1536 | __dest->__left_ = static_cast<__node_base_pointer>(__assign_from_tree( |
| 1218 | } | 1537 | static_cast<__node_pointer>(__dest->__left_), |
| 1538 | static_cast<__node_pointer>(__src->__left_), | ||
| 1539 | __assign, | ||
| 1540 | __construct_subtree)); | ||
| 1541 | |||
| 1542 | // Otherwise, we must create new nodes; copy-construct from here on | ||
| 1543 | } else if (__src->__left_) { | ||
| 1544 | auto __new_left = __construct_subtree(static_cast<__node_pointer>(__src->__left_)); | ||
| 1545 | __dest->__left_ = static_cast<__node_base_pointer>(__new_left); | ||
| 1546 | __new_left->__parent_ = static_cast<__end_node_pointer>(__dest); | ||
| 1219 | } | 1547 | } |
| 1220 | 1548 | ||
| 1221 | _DetachedTreeCache(_DetachedTreeCache const&) = delete; | 1549 | // Identical to the left case above, just for the right nodes |
| 1222 | _DetachedTreeCache& operator=(_DetachedTreeCache const&) = delete; | 1550 | if (__dest->__right_) { |
| 1551 | __dest->__right_ = static_cast<__node_base_pointer>(__assign_from_tree( | ||
| 1552 | static_cast<__node_pointer>(__dest->__right_), | ||
| 1553 | static_cast<__node_pointer>(__src->__right_), | ||
| 1554 | __assign, | ||
| 1555 | __construct_subtree)); | ||
| 1556 | } else if (__src->__right_) { | ||
| 1557 | auto __new_right = __construct_subtree(static_cast<__node_pointer>(__src->__right_)); | ||
| 1558 | __dest->__right_ = static_cast<__node_base_pointer>(__new_right); | ||
| 1559 | __new_right->__parent_ = static_cast<__end_node_pointer>(__dest); | ||
| 1560 | } | ||
| 1223 | 1561 | ||
| 1224 | private: | 1562 | return __dest; |
| 1225 | _LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_from_tree(__tree* __t) _NOEXCEPT; | 1563 | } |
| 1226 | _LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_next(__node_pointer) _NOEXCEPT; | ||
| 1227 | 1564 | ||
| 1228 | __tree* __t_; | 1565 | _LIBCPP_HIDE_FROM_ABI __node_pointer __copy_assign_tree(__node_pointer __dest, __node_pointer __src) { |
| 1229 | __node_pointer __cache_root_; | 1566 | return __assign_from_tree( |
| 1230 | __node_pointer __cache_elem_; | 1567 | __dest, |
| 1231 | }; | 1568 | __src, |
| 1232 | }; | 1569 | [](value_type& __lhs, const value_type& __rhs) { __assign_value(__lhs, __rhs); }, |
| 1570 | [this](__node_pointer __nd) { return __copy_construct_tree(__nd); }); | ||
| 1571 | } | ||
| 1233 | 1572 | ||
| 1234 | template <class _Tp, class _Compare, class _Allocator> | 1573 | _LIBCPP_HIDE_FROM_ABI __node_pointer __move_assign_tree(__node_pointer __dest, __node_pointer __src) { |
| 1235 | __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_( | 1574 | return __assign_from_tree( |
| 1236 | is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value) | 1575 | __dest, |
| 1237 | : __size_(0), __value_comp_(__comp) { | 1576 | __src, |
| 1238 | __begin_node() = __end_node(); | 1577 | [](value_type& __lhs, value_type& __rhs) { __assign_value(__lhs, std::move(__rhs)); }, |
| 1239 | } | 1578 | [this](__node_pointer __nd) { return __move_construct_tree(__nd); }); |
| 1579 | } | ||
| 1240 | 1580 | ||
| 1241 | template <class _Tp, class _Compare, class _Allocator> | 1581 | friend struct __specialized_algorithm<_Algorithm::__for_each, __single_range<__tree> >; |
| 1242 | __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) | 1582 | }; |
| 1243 | : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) { | ||
| 1244 | __begin_node() = __end_node(); | ||
| 1245 | } | ||
| 1246 | 1583 | ||
| 1584 | #if _LIBCPP_STD_VER >= 14 | ||
| 1247 | template <class _Tp, class _Compare, class _Allocator> | 1585 | template <class _Tp, class _Compare, class _Allocator> |
| 1248 | __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) | 1586 | struct __specialized_algorithm<_Algorithm::__for_each, __single_range<__tree<_Tp, _Compare, _Allocator> > > { |
| 1249 | : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) { | 1587 | static const bool __has_algorithm = true; |
| 1250 | __begin_node() = __end_node(); | ||
| 1251 | } | ||
| 1252 | 1588 | ||
| 1253 | // Precondition: size() != 0 | 1589 | using __node_pointer _LIBCPP_NODEBUG = typename __tree<_Tp, _Compare, _Allocator>::__node_pointer; |
| 1254 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1255 | typename __tree<_Tp, _Compare, _Allocator>::__node_pointer | ||
| 1256 | __tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree* __t) _NOEXCEPT { | ||
| 1257 | __node_pointer __cache = static_cast<__node_pointer>(__t->__begin_node()); | ||
| 1258 | __t->__begin_node() = __t->__end_node(); | ||
| 1259 | __t->__end_node()->__left_->__parent_ = nullptr; | ||
| 1260 | __t->__end_node()->__left_ = nullptr; | ||
| 1261 | __t->size() = 0; | ||
| 1262 | // __cache->__left_ == nullptr | ||
| 1263 | if (__cache->__right_ != nullptr) | ||
| 1264 | __cache = static_cast<__node_pointer>(__cache->__right_); | ||
| 1265 | // __cache->__left_ == nullptr | ||
| 1266 | // __cache->__right_ == nullptr | ||
| 1267 | return __cache; | ||
| 1268 | } | ||
| 1269 | 1590 | ||
| 1270 | // Precondition: __cache != nullptr | 1591 | template <class _Tree, class _Func, class _Proj> |
| 1271 | // __cache->left_ == nullptr | 1592 | _LIBCPP_HIDE_FROM_ABI static auto operator()(_Tree&& __range, _Func __func, _Proj __proj) { |
| 1272 | // __cache->right_ == nullptr | 1593 | if (__range.size() != 0) |
| 1273 | // This is no longer a red-black tree | 1594 | std::__tree_iterate_from_root<__copy_cvref_t<_Tree, typename __remove_cvref_t<_Tree>::value_type>>( |
| 1274 | template <class _Tp, class _Compare, class _Allocator> | 1595 | [](__node_pointer) { return false; }, __range.__root(), __func, __proj); |
| 1275 | typename __tree<_Tp, _Compare, _Allocator>::__node_pointer | 1596 | return std::make_pair(__range.end(), std::move(__func)); |
| 1276 | __tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_pointer __cache) _NOEXCEPT { | 1597 | } |
| 1277 | if (__cache->__parent_ == nullptr) | 1598 | }; |
| 1278 | return nullptr; | 1599 | #endif |
| 1279 | if (std::__tree_is_left_child(static_cast<__node_base_pointer>(__cache))) { | ||
| 1280 | __cache->__parent_->__left_ = nullptr; | ||
| 1281 | __cache = static_cast<__node_pointer>(__cache->__parent_); | ||
| 1282 | if (__cache->__right_ == nullptr) | ||
| 1283 | return __cache; | ||
| 1284 | return static_cast<__node_pointer>(std::__tree_leaf(__cache->__right_)); | ||
| 1285 | } | ||
| 1286 | // __cache is right child | ||
| 1287 | __cache->__parent_unsafe()->__right_ = nullptr; | ||
| 1288 | __cache = static_cast<__node_pointer>(__cache->__parent_); | ||
| 1289 | if (__cache->__left_ == nullptr) | ||
| 1290 | return __cache; | ||
| 1291 | return static_cast<__node_pointer>(std::__tree_leaf(__cache->__left_)); | ||
| 1292 | } | ||
| 1293 | 1600 | ||
| 1294 | template <class _Tp, class _Compare, class _Allocator> | 1601 | template <class _Tp, class _Compare, class _Allocator> |
| 1295 | __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) { | 1602 | __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) { |
| 1296 | if (this != std::addressof(__t)) { | 1603 | if (this == std::addressof(__t)) |
| 1297 | value_comp() = __t.value_comp(); | 1604 | return *this; |
| 1298 | __copy_assign_alloc(__t); | ||
| 1299 | __assign_multi(__t.begin(), __t.end()); | ||
| 1300 | } | ||
| 1301 | return *this; | ||
| 1302 | } | ||
| 1303 | 1605 | ||
| 1304 | template <class _Tp, class _Compare, class _Allocator> | 1606 | value_comp() = __t.value_comp(); |
| 1305 | template <class _ForwardIterator> | 1607 | __copy_assign_alloc(__t); |
| 1306 | void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 1307 | typedef iterator_traits<_ForwardIterator> _ITraits; | ||
| 1308 | typedef typename _ITraits::value_type _ItValueType; | ||
| 1309 | static_assert( | ||
| 1310 | is_same<_ItValueType, value_type>::value, "__assign_unique may only be called with the containers value type"); | ||
| 1311 | static_assert( | ||
| 1312 | __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator"); | ||
| 1313 | if (size() != 0) { | ||
| 1314 | _DetachedTreeCache __cache(this); | ||
| 1315 | for (; __cache.__get() != nullptr && __first != __last; ++__first) { | ||
| 1316 | if (__node_assign_unique(*__first, __cache.__get()).second) | ||
| 1317 | __cache.__advance(); | ||
| 1318 | } | ||
| 1319 | } | ||
| 1320 | for (; __first != __last; ++__first) | ||
| 1321 | __emplace_unique(*__first); | ||
| 1322 | } | ||
| 1323 | 1608 | ||
| 1324 | template <class _Tp, class _Compare, class _Allocator> | 1609 | if (__size_ != 0) { |
| 1325 | template <class _InputIterator> | 1610 | *__root_ptr() = static_cast<__node_base_pointer>(__copy_assign_tree(__root(), __t.__root())); |
| 1326 | void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) { | 1611 | } else { |
| 1327 | typedef iterator_traits<_InputIterator> _ITraits; | 1612 | *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__t.__root())); |
| 1328 | typedef typename _ITraits::value_type _ItValueType; | 1613 | if (__root()) |
| 1329 | static_assert( | 1614 | __root()->__parent_ = __end_node(); |
| 1330 | is_same<_ItValueType, value_type>::value, "__assign_multi may only be called with the containers value_type"); | ||
| 1331 | if (size() != 0) { | ||
| 1332 | _DetachedTreeCache __cache(this); | ||
| 1333 | for (; __cache.__get() && __first != __last; ++__first) { | ||
| 1334 | __assign_value(__cache.__get()->__value_, *__first); | ||
| 1335 | __node_insert_multi(__cache.__get()); | ||
| 1336 | __cache.__advance(); | ||
| 1337 | } | ||
| 1338 | } | 1615 | } |
| 1339 | const_iterator __e = end(); | 1616 | __begin_node_ = |
| 1340 | for (; __first != __last; ++__first) | 1617 | __end_node()->__left_ ? static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)) : __end_node(); |
| 1341 | __emplace_hint_multi(__e, *__first); | 1618 | __size_ = __t.size(); |
| 1619 | |||
| 1620 | return *this; | ||
| 1342 | } | 1621 | } |
| 1343 | 1622 | ||
| 1344 | template <class _Tp, class _Compare, class _Allocator> | 1623 | template <class _Tp, class _Compare, class _Allocator> |
| 1345 | __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) | 1624 | __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) |
| 1346 | : __begin_node_(), | 1625 | : __begin_node_(__end_node()), |
| 1347 | __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), | 1626 | __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), |
| 1348 | __size_(0), | 1627 | __size_(0), |
| 1349 | __value_comp_(__t.value_comp()) { | 1628 | __value_comp_(__t.value_comp()) { |
| 1350 | __begin_node() = __end_node(); | 1629 | if (__t.size() == 0) |
| 1630 | return; | ||
| 1631 | |||
| 1632 | *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__t.__root())); | ||
| 1633 | __root()->__parent_ = __end_node(); | ||
| 1634 | __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)); | ||
| 1635 | __size_ = __t.size(); | ||
| 1351 | } | 1636 | } |
| 1352 | 1637 | ||
| 1353 | template <class _Tp, class _Compare, class _Allocator> | 1638 | template <class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1358,33 +1643,38 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( | ... | @@ -1358,33 +1643,38 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( |
| 1358 | __node_alloc_(std::move(__t.__node_alloc_)), | 1643 | __node_alloc_(std::move(__t.__node_alloc_)), |
| 1359 | __size_(__t.__size_), | 1644 | __size_(__t.__size_), |
| 1360 | __value_comp_(std::move(__t.__value_comp_)) { | 1645 | __value_comp_(std::move(__t.__value_comp_)) { |
| 1361 | if (size() == 0) | 1646 | if (__size_ == 0) |
| 1362 | __begin_node() = __end_node(); | 1647 | __begin_node_ = __end_node(); |
| 1363 | else { | 1648 | else { |
| 1364 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); | 1649 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); |
| 1365 | __t.__begin_node() = __t.__end_node(); | 1650 | __t.__begin_node_ = __t.__end_node(); |
| 1366 | __t.__end_node()->__left_ = nullptr; | 1651 | __t.__end_node()->__left_ = nullptr; |
| 1367 | __t.size() = 0; | 1652 | __t.__size_ = 0; |
| 1368 | } | 1653 | } |
| 1369 | } | 1654 | } |
| 1370 | 1655 | ||
| 1371 | template <class _Tp, class _Compare, class _Allocator> | 1656 | template <class _Tp, class _Compare, class _Allocator> |
| 1372 | __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) | 1657 | __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) |
| 1373 | : __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(std::move(__t.value_comp())) { | 1658 | : __begin_node_(__end_node()), |
| 1659 | __node_alloc_(__node_allocator(__a)), | ||
| 1660 | __size_(0), | ||
| 1661 | __value_comp_(std::move(__t.value_comp())) { | ||
| 1662 | if (__t.size() == 0) | ||
| 1663 | return; | ||
| 1374 | if (__a == __t.__alloc()) { | 1664 | if (__a == __t.__alloc()) { |
| 1375 | if (__t.size() == 0) | 1665 | __begin_node_ = __t.__begin_node_; |
| 1376 | __begin_node() = __end_node(); | 1666 | __end_node()->__left_ = __t.__end_node()->__left_; |
| 1377 | else { | 1667 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); |
| 1378 | __begin_node() = __t.__begin_node(); | 1668 | __size_ = __t.__size_; |
| 1379 | __end_node()->__left_ = __t.__end_node()->__left_; | 1669 | __t.__begin_node_ = __t.__end_node(); |
| 1380 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); | 1670 | __t.__end_node()->__left_ = nullptr; |
| 1381 | size() = __t.size(); | 1671 | __t.__size_ = 0; |
| 1382 | __t.__begin_node() = __t.__end_node(); | ||
| 1383 | __t.__end_node()->__left_ = nullptr; | ||
| 1384 | __t.size() = 0; | ||
| 1385 | } | ||
| 1386 | } else { | 1672 | } else { |
| 1387 | __begin_node() = __end_node(); | 1673 | *__root_ptr() = static_cast<__node_base_pointer>(__move_construct_tree(__t.__root())); |
| 1674 | __root()->__parent_ = __end_node(); | ||
| 1675 | __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)); | ||
| 1676 | __size_ = __t.size(); | ||
| 1677 | __t.clear(); // Ensure that __t is in a valid state after moving out the keys | ||
| 1388 | } | 1678 | } |
| 1389 | } | 1679 | } |
| 1390 | 1680 | ||
| ... | @@ -1397,61 +1687,33 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) | ... | @@ -1397,61 +1687,33 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) |
| 1397 | __move_assign_alloc(__t); | 1687 | __move_assign_alloc(__t); |
| 1398 | __size_ = __t.__size_; | 1688 | __size_ = __t.__size_; |
| 1399 | __value_comp_ = std::move(__t.__value_comp_); | 1689 | __value_comp_ = std::move(__t.__value_comp_); |
| 1400 | if (size() == 0) | 1690 | if (__size_ == 0) |
| 1401 | __begin_node() = __end_node(); | 1691 | __begin_node_ = __end_node(); |
| 1402 | else { | 1692 | else { |
| 1403 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); | 1693 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); |
| 1404 | __t.__begin_node() = __t.__end_node(); | 1694 | __t.__begin_node_ = __t.__end_node(); |
| 1405 | __t.__end_node()->__left_ = nullptr; | 1695 | __t.__end_node()->__left_ = nullptr; |
| 1406 | __t.size() = 0; | 1696 | __t.__size_ = 0; |
| 1407 | } | 1697 | } |
| 1408 | } | 1698 | } |
| 1409 | 1699 | ||
| 1410 | template <class _Tp, class _Compare, class _Allocator> | 1700 | template <class _Tp, class _Compare, class _Allocator> |
| 1411 | void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) { | 1701 | void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) { |
| 1412 | if (__node_alloc() == __t.__node_alloc()) | 1702 | if (__node_alloc() == __t.__node_alloc()) { |
| 1413 | __move_assign(__t, true_type()); | 1703 | __move_assign(__t, true_type()); |
| 1414 | else { | 1704 | } else { |
| 1415 | value_comp() = std::move(__t.value_comp()); | 1705 | value_comp() = std::move(__t.value_comp()); |
| 1416 | const_iterator __e = end(); | 1706 | if (__size_ != 0) { |
| 1417 | if (size() != 0) { | 1707 | *__root_ptr() = static_cast<__node_base_pointer>(__move_assign_tree(__root(), __t.__root())); |
| 1418 | _DetachedTreeCache __cache(this); | 1708 | } else { |
| 1419 | while (__cache.__get() != nullptr && __t.size() != 0) { | 1709 | *__root_ptr() = static_cast<__node_base_pointer>(__move_construct_tree(__t.__root())); |
| 1420 | __assign_value(__cache.__get()->__value_, std::move(__t.remove(__t.begin())->__value_)); | 1710 | if (__root()) |
| 1421 | __node_insert_multi(__cache.__get()); | 1711 | __root()->__parent_ = __end_node(); |
| 1422 | __cache.__advance(); | ||
| 1423 | } | ||
| 1424 | } | ||
| 1425 | while (__t.size() != 0) { | ||
| 1426 | __insert_multi_from_orphaned_node(__e, std::move(__t.remove(__t.begin())->__value_)); | ||
| 1427 | } | 1712 | } |
| 1428 | } | 1713 | __begin_node_ = |
| 1429 | } | 1714 | __end_node()->__left_ ? static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)) : __end_node(); |
| 1430 | 1715 | __size_ = __t.size(); | |
| 1431 | template <class _Tp, class _Compare, class _Allocator> | 1716 | __t.clear(); // Ensure that __t is in a valid state after moving out the keys |
| 1432 | __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) | ||
| 1433 | _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value && | ||
| 1434 | ((__node_traits::propagate_on_container_move_assignment::value && | ||
| 1435 | is_nothrow_move_assignable<__node_allocator>::value) || | ||
| 1436 | allocator_traits<__node_allocator>::is_always_equal::value)) { | ||
| 1437 | __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); | ||
| 1438 | return *this; | ||
| 1439 | } | ||
| 1440 | |||
| 1441 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1442 | __tree<_Tp, _Compare, _Allocator>::~__tree() { | ||
| 1443 | static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible."); | ||
| 1444 | destroy(__root()); | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1448 | void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { | ||
| 1449 | if (__nd != nullptr) { | ||
| 1450 | destroy(static_cast<__node_pointer>(__nd->__left_)); | ||
| 1451 | destroy(static_cast<__node_pointer>(__nd->__right_)); | ||
| 1452 | __node_allocator& __na = __node_alloc(); | ||
| 1453 | __node_traits::destroy(__na, std::addressof(__nd->__value_)); | ||
| 1454 | __node_traits::deallocate(__na, __nd, 1); | ||
| 1455 | } | 1717 | } |
| 1456 | } | 1718 | } |
| 1457 | 1719 | ||
| ... | @@ -1470,12 +1732,12 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) | ... | @@ -1470,12 +1732,12 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) |
| 1470 | std::__swap_allocator(__node_alloc(), __t.__node_alloc()); | 1732 | std::__swap_allocator(__node_alloc(), __t.__node_alloc()); |
| 1471 | swap(__size_, __t.__size_); | 1733 | swap(__size_, __t.__size_); |
| 1472 | swap(__value_comp_, __t.__value_comp_); | 1734 | swap(__value_comp_, __t.__value_comp_); |
| 1473 | if (size() == 0) | 1735 | if (__size_ == 0) |
| 1474 | __begin_node() = __end_node(); | 1736 | __begin_node_ = __end_node(); |
| 1475 | else | 1737 | else |
| 1476 | __end_node()->__left_->__parent_ = __end_node(); | 1738 | __end_node()->__left_->__parent_ = __end_node(); |
| 1477 | if (__t.size() == 0) | 1739 | if (__t.__size_ == 0) |
| 1478 | __t.__begin_node() = __t.__end_node(); | 1740 | __t.__begin_node_ = __t.__end_node(); |
| 1479 | else | 1741 | else |
| 1480 | __t.__end_node()->__left_->__parent_ = __t.__end_node(); | 1742 | __t.__end_node()->__left_->__parent_ = __t.__end_node(); |
| 1481 | } | 1743 | } |
| ... | @@ -1483,8 +1745,8 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) | ... | @@ -1483,8 +1745,8 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) |
| 1483 | template <class _Tp, class _Compare, class _Allocator> | 1745 | template <class _Tp, class _Compare, class _Allocator> |
| 1484 | void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT { | 1746 | void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT { |
| 1485 | destroy(__root()); | 1747 | destroy(__root()); |
| 1486 | size() = 0; | 1748 | __size_ = 0; |
| 1487 | __begin_node() = __end_node(); | 1749 | __begin_node_ = __end_node(); |
| 1488 | __end_node()->__left_ = nullptr; | 1750 | __end_node()->__left_ = nullptr; |
| 1489 | } | 1751 | } |
| 1490 | 1752 | ||
| ... | @@ -1497,7 +1759,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent, | ... | @@ -1497,7 +1759,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent, |
| 1497 | __node_pointer __nd = __root(); | 1759 | __node_pointer __nd = __root(); |
| 1498 | if (__nd != nullptr) { | 1760 | if (__nd != nullptr) { |
| 1499 | while (true) { | 1761 | while (true) { |
| 1500 | if (value_comp()(__nd->__value_, __v)) { | 1762 | if (value_comp()(__nd->__get_value(), __v)) { |
| 1501 | if (__nd->__right_ != nullptr) | 1763 | if (__nd->__right_ != nullptr) |
| 1502 | __nd = static_cast<__node_pointer>(__nd->__right_); | 1764 | __nd = static_cast<__node_pointer>(__nd->__right_); |
| 1503 | else { | 1765 | else { |
| ... | @@ -1527,7 +1789,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent | ... | @@ -1527,7 +1789,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent |
| 1527 | __node_pointer __nd = __root(); | 1789 | __node_pointer __nd = __root(); |
| 1528 | if (__nd != nullptr) { | 1790 | if (__nd != nullptr) { |
| 1529 | while (true) { | 1791 | while (true) { |
| 1530 | if (value_comp()(__v, __nd->__value_)) { | 1792 | if (value_comp()(__v, __nd->__get_value())) { |
| 1531 | if (__nd->__left_ != nullptr) | 1793 | if (__nd->__left_ != nullptr) |
| 1532 | __nd = static_cast<__node_pointer>(__nd->__left_); | 1794 | __nd = static_cast<__node_pointer>(__nd->__left_); |
| 1533 | else { | 1795 | else { |
| ... | @@ -1578,92 +1840,91 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co | ... | @@ -1578,92 +1840,91 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co |
| 1578 | return __find_leaf_low(__parent, __v); | 1840 | return __find_leaf_low(__parent, __v); |
| 1579 | } | 1841 | } |
| 1580 | 1842 | ||
| 1581 | // Find place to insert if __v doesn't exist | 1843 | // Find __v |
| 1582 | // Set __parent to parent of null leaf | 1844 | // If __v exists, return the parent of the node of __v and a reference to the pointer to the node of __v. |
| 1583 | // Return reference to null leaf | 1845 | // If __v doesn't exist, return the parent of the null leaf and a reference to the pointer to the null leaf. |
| 1584 | // If __v exists, set parent to node of __v and return reference to node of __v | ||
| 1585 | template <class _Tp, class _Compare, class _Allocator> | 1846 | template <class _Tp, class _Compare, class _Allocator> |
| 1586 | template <class _Key> | 1847 | template <class _Key> |
| 1587 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& | 1848 | _LIBCPP_HIDE_FROM_ABI pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer, |
| 1588 | __tree<_Tp, _Compare, _Allocator>::__find_equal(__end_node_pointer& __parent, const _Key& __v) { | 1849 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&> |
| 1589 | __node_pointer __nd = __root(); | 1850 | __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) { |
| 1590 | __node_base_pointer* __nd_ptr = __root_ptr(); | 1851 | using _Pair = pair<__end_node_pointer, __node_base_pointer&>; |
| 1591 | if (__nd != nullptr) { | 1852 | |
| 1592 | while (true) { | 1853 | __node_pointer __nd = __root(); |
| 1593 | if (value_comp()(__v, __nd->__value_)) { | 1854 | |
| 1594 | if (__nd->__left_ != nullptr) { | 1855 | if (__nd == nullptr) { |
| 1595 | __nd_ptr = std::addressof(__nd->__left_); | 1856 | auto __end = __end_node(); |
| 1596 | __nd = static_cast<__node_pointer>(__nd->__left_); | 1857 | return _Pair(__end, __end->__left_); |
| 1597 | } else { | 1858 | } |
| 1598 | __parent = static_cast<__end_node_pointer>(__nd); | 1859 | |
| 1599 | return __parent->__left_; | 1860 | __node_base_pointer* __node_ptr = __root_ptr(); |
| 1600 | } | 1861 | auto&& __transparent = std::__as_transparent<_Key>(value_comp()); |
| 1601 | } else if (value_comp()(__nd->__value_, __v)) { | 1862 | auto __comp = |
| 1602 | if (__nd->__right_ != nullptr) { | 1863 | __lazy_synth_three_way_comparator<__make_transparent_t<_Key, _Compare>, _Key, value_type>(__transparent); |
| 1603 | __nd_ptr = std::addressof(__nd->__right_); | 1864 | |
| 1604 | __nd = static_cast<__node_pointer>(__nd->__right_); | 1865 | while (true) { |
| 1605 | } else { | 1866 | auto __comp_res = __comp(__v, __nd->__get_value()); |
| 1606 | __parent = static_cast<__end_node_pointer>(__nd); | 1867 | |
| 1607 | return __nd->__right_; | 1868 | if (__comp_res.__less()) { |
| 1608 | } | 1869 | if (__nd->__left_ == nullptr) |
| 1609 | } else { | 1870 | return _Pair(static_cast<__end_node_pointer>(__nd), __nd->__left_); |
| 1610 | __parent = static_cast<__end_node_pointer>(__nd); | 1871 | |
| 1611 | return *__nd_ptr; | 1872 | __node_ptr = std::addressof(__nd->__left_); |
| 1612 | } | 1873 | __nd = static_cast<__node_pointer>(__nd->__left_); |
| 1874 | } else if (__comp_res.__greater()) { | ||
| 1875 | if (__nd->__right_ == nullptr) | ||
| 1876 | return _Pair(static_cast<__end_node_pointer>(__nd), __nd->__right_); | ||
| 1877 | |||
| 1878 | __node_ptr = std::addressof(__nd->__right_); | ||
| 1879 | __nd = static_cast<__node_pointer>(__nd->__right_); | ||
| 1880 | } else { | ||
| 1881 | return _Pair(static_cast<__end_node_pointer>(__nd), *__node_ptr); | ||
| 1613 | } | 1882 | } |
| 1614 | } | 1883 | } |
| 1615 | __parent = __end_node(); | ||
| 1616 | return __parent->__left_; | ||
| 1617 | } | 1884 | } |
| 1618 | 1885 | ||
| 1619 | // Find place to insert if __v doesn't exist | 1886 | // Find __v |
| 1620 | // First check prior to __hint. | 1887 | // First check prior to __hint. |
| 1621 | // Next check after __hint. | 1888 | // Next check after __hint. |
| 1622 | // Next do O(log N) search. | 1889 | // Next do O(log N) search. |
| 1623 | // Set __parent to parent of null leaf | 1890 | // If __v exists, return the parent of the node of __v and a reference to the pointer to the node of __v. |
| 1624 | // Return reference to null leaf | 1891 | // If __v doesn't exist, return the parent of the null leaf and a reference to the pointer to the null leaf. |
| 1625 | // If __v exists, set parent to node of __v and return reference to node of __v | ||
| 1626 | template <class _Tp, class _Compare, class _Allocator> | 1892 | template <class _Tp, class _Compare, class _Allocator> |
| 1627 | template <class _Key> | 1893 | template <class _Key> |
| 1628 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal( | 1894 | _LIBCPP_HIDE_FROM_ABI pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer, |
| 1629 | const_iterator __hint, __end_node_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v) { | 1895 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&> |
| 1630 | if (__hint == end() || value_comp()(__v, *__hint)) // check before | 1896 | __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_base_pointer& __dummy, const _Key& __v) { |
| 1631 | { | 1897 | using _Pair = pair<__end_node_pointer, __node_base_pointer&>; |
| 1898 | |||
| 1899 | if (__hint == end() || value_comp()(__v, *__hint)) { // check before | ||
| 1632 | // __v < *__hint | 1900 | // __v < *__hint |
| 1633 | const_iterator __prior = __hint; | 1901 | const_iterator __prior = __hint; |
| 1634 | if (__prior == begin() || value_comp()(*--__prior, __v)) { | 1902 | if (__prior == begin() || value_comp()(*--__prior, __v)) { |
| 1635 | // *prev(__hint) < __v < *__hint | 1903 | // *prev(__hint) < __v < *__hint |
| 1636 | if (__hint.__ptr_->__left_ == nullptr) { | 1904 | if (__hint.__ptr_->__left_ == nullptr) |
| 1637 | __parent = __hint.__ptr_; | 1905 | return _Pair(__hint.__ptr_, __hint.__ptr_->__left_); |
| 1638 | return __parent->__left_; | 1906 | return _Pair(__prior.__ptr_, static_cast<__node_pointer>(__prior.__ptr_)->__right_); |
| 1639 | } else { | ||
| 1640 | __parent = __prior.__ptr_; | ||
| 1641 | return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; | ||
| 1642 | } | ||
| 1643 | } | 1907 | } |
| 1644 | // __v <= *prev(__hint) | 1908 | // __v <= *prev(__hint) |
| 1645 | return __find_equal(__parent, __v); | 1909 | return __find_equal(__v); |
| 1646 | } else if (value_comp()(*__hint, __v)) // check after | 1910 | } |
| 1647 | { | 1911 | |
| 1912 | if (value_comp()(*__hint, __v)) { // check after | ||
| 1648 | // *__hint < __v | 1913 | // *__hint < __v |
| 1649 | const_iterator __next = std::next(__hint); | 1914 | const_iterator __next = std::next(__hint); |
| 1650 | if (__next == end() || value_comp()(__v, *__next)) { | 1915 | if (__next == end() || value_comp()(__v, *__next)) { |
| 1651 | // *__hint < __v < *std::next(__hint) | 1916 | // *__hint < __v < *std::next(__hint) |
| 1652 | if (__hint.__get_np()->__right_ == nullptr) { | 1917 | if (__hint.__get_np()->__right_ == nullptr) |
| 1653 | __parent = __hint.__ptr_; | 1918 | return _Pair(__hint.__ptr_, static_cast<__node_pointer>(__hint.__ptr_)->__right_); |
| 1654 | return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_; | 1919 | return _Pair(__next.__ptr_, __next.__ptr_->__left_); |
| 1655 | } else { | ||
| 1656 | __parent = __next.__ptr_; | ||
| 1657 | return __parent->__left_; | ||
| 1658 | } | ||
| 1659 | } | 1920 | } |
| 1660 | // *next(__hint) <= __v | 1921 | // *next(__hint) <= __v |
| 1661 | return __find_equal(__parent, __v); | 1922 | return __find_equal(__v); |
| 1662 | } | 1923 | } |
| 1924 | |||
| 1663 | // else __v == *__hint | 1925 | // else __v == *__hint |
| 1664 | __parent = __hint.__ptr_; | 1926 | __dummy = static_cast<__node_base_pointer>(__hint.__ptr_); |
| 1665 | __dummy = static_cast<__node_base_pointer>(__hint.__ptr_); | 1927 | return _Pair(__hint.__ptr_, __dummy); |
| 1666 | return __dummy; | ||
| 1667 | } | 1928 | } |
| 1668 | 1929 | ||
| 1669 | template <class _Tp, class _Compare, class _Allocator> | 1930 | template <class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1674,46 +1935,10 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( | ... | @@ -1674,46 +1935,10 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( |
| 1674 | __new_node->__parent_ = __parent; | 1935 | __new_node->__parent_ = __parent; |
| 1675 | // __new_node->__is_black_ is initialized in __tree_balance_after_insert | 1936 | // __new_node->__is_black_ is initialized in __tree_balance_after_insert |
| 1676 | __child = __new_node; | 1937 | __child = __new_node; |
| 1677 | if (__begin_node()->__left_ != nullptr) | 1938 | if (__begin_node_->__left_ != nullptr) |
| 1678 | __begin_node() = static_cast<__end_node_pointer>(__begin_node()->__left_); | 1939 | __begin_node_ = static_cast<__end_node_pointer>(__begin_node_->__left_); |
| 1679 | std::__tree_balance_after_insert(__end_node()->__left_, __child); | 1940 | std::__tree_balance_after_insert(__end_node()->__left_, __child); |
| 1680 | ++size(); | 1941 | ++__size_; |
| 1681 | } | ||
| 1682 | |||
| 1683 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1684 | template <class _Key, class... _Args> | ||
| 1685 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | ||
| 1686 | __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) { | ||
| 1687 | __end_node_pointer __parent; | ||
| 1688 | __node_base_pointer& __child = __find_equal(__parent, __k); | ||
| 1689 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1690 | bool __inserted = false; | ||
| 1691 | if (__child == nullptr) { | ||
| 1692 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | ||
| 1693 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | ||
| 1694 | __r = __h.release(); | ||
| 1695 | __inserted = true; | ||
| 1696 | } | ||
| 1697 | return pair<iterator, bool>(iterator(__r), __inserted); | ||
| 1698 | } | ||
| 1699 | |||
| 1700 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1701 | template <class _Key, class... _Args> | ||
| 1702 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | ||
| 1703 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( | ||
| 1704 | const_iterator __p, _Key const& __k, _Args&&... __args) { | ||
| 1705 | __end_node_pointer __parent; | ||
| 1706 | __node_base_pointer __dummy; | ||
| 1707 | __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k); | ||
| 1708 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1709 | bool __inserted = false; | ||
| 1710 | if (__child == nullptr) { | ||
| 1711 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | ||
| 1712 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | ||
| 1713 | __r = __h.release(); | ||
| 1714 | __inserted = true; | ||
| 1715 | } | ||
| 1716 | return pair<iterator, bool>(iterator(__r), __inserted); | ||
| 1717 | } | 1942 | } |
| 1718 | 1943 | ||
| 1719 | template <class _Tp, class _Compare, class _Allocator> | 1944 | template <class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1722,51 +1947,18 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_holder | ... | @@ -1722,51 +1947,18 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_holder |
| 1722 | __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { | 1947 | __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { |
| 1723 | __node_allocator& __na = __node_alloc(); | 1948 | __node_allocator& __na = __node_alloc(); |
| 1724 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1949 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1725 | __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...); | 1950 | std::__construct_at(std::addressof(*__h), __na, std::forward<_Args>(__args)...); |
| 1726 | __h.get_deleter().__value_constructed = true; | 1951 | __h.get_deleter().__value_constructed = true; |
| 1727 | return __h; | 1952 | return __h; |
| 1728 | } | 1953 | } |
| 1729 | 1954 | ||
| 1730 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1731 | template <class... _Args> | ||
| 1732 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | ||
| 1733 | __tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { | ||
| 1734 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | ||
| 1735 | __end_node_pointer __parent; | ||
| 1736 | __node_base_pointer& __child = __find_equal(__parent, __h->__value_); | ||
| 1737 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1738 | bool __inserted = false; | ||
| 1739 | if (__child == nullptr) { | ||
| 1740 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | ||
| 1741 | __r = __h.release(); | ||
| 1742 | __inserted = true; | ||
| 1743 | } | ||
| 1744 | return pair<iterator, bool>(iterator(__r), __inserted); | ||
| 1745 | } | ||
| 1746 | |||
| 1747 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1748 | template <class... _Args> | ||
| 1749 | typename __tree<_Tp, _Compare, _Allocator>::iterator | ||
| 1750 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) { | ||
| 1751 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | ||
| 1752 | __end_node_pointer __parent; | ||
| 1753 | __node_base_pointer __dummy; | ||
| 1754 | __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_); | ||
| 1755 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1756 | if (__child == nullptr) { | ||
| 1757 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | ||
| 1758 | __r = __h.release(); | ||
| 1759 | } | ||
| 1760 | return iterator(__r); | ||
| 1761 | } | ||
| 1762 | |||
| 1763 | template <class _Tp, class _Compare, class _Allocator> | 1955 | template <class _Tp, class _Compare, class _Allocator> |
| 1764 | template <class... _Args> | 1956 | template <class... _Args> |
| 1765 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 1957 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1766 | __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { | 1958 | __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { |
| 1767 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | 1959 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); |
| 1768 | __end_node_pointer __parent; | 1960 | __end_node_pointer __parent; |
| 1769 | __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_); | 1961 | __node_base_pointer& __child = __find_leaf_high(__parent, __h->__get_value()); |
| 1770 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | 1962 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
| 1771 | return iterator(static_cast<__node_pointer>(__h.release())); | 1963 | return iterator(static_cast<__node_pointer>(__h.release())); |
| 1772 | } | 1964 | } |
| ... | @@ -1777,53 +1969,19 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator | ... | @@ -1777,53 +1969,19 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1777 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) { | 1969 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) { |
| 1778 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | 1970 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); |
| 1779 | __end_node_pointer __parent; | 1971 | __end_node_pointer __parent; |
| 1780 | __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_); | 1972 | __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__get_value()); |
| 1781 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | 1973 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
| 1782 | return iterator(static_cast<__node_pointer>(__h.release())); | 1974 | return iterator(static_cast<__node_pointer>(__h.release())); |
| 1783 | } | 1975 | } |
| 1784 | 1976 | ||
| 1785 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1786 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | ||
| 1787 | __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const value_type& __v, __node_pointer __nd) { | ||
| 1788 | __end_node_pointer __parent; | ||
| 1789 | __node_base_pointer& __child = __find_equal(__parent, __v); | ||
| 1790 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1791 | bool __inserted = false; | ||
| 1792 | if (__child == nullptr) { | ||
| 1793 | __assign_value(__nd->__value_, __v); | ||
| 1794 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); | ||
| 1795 | __r = __nd; | ||
| 1796 | __inserted = true; | ||
| 1797 | } | ||
| 1798 | return pair<iterator, bool>(iterator(__r), __inserted); | ||
| 1799 | } | ||
| 1800 | |||
| 1801 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1802 | typename __tree<_Tp, _Compare, _Allocator>::iterator | ||
| 1803 | __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { | ||
| 1804 | __end_node_pointer __parent; | ||
| 1805 | __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__value_); | ||
| 1806 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); | ||
| 1807 | return iterator(__nd); | ||
| 1808 | } | ||
| 1809 | |||
| 1810 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1811 | typename __tree<_Tp, _Compare, _Allocator>::iterator | ||
| 1812 | __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) { | ||
| 1813 | __end_node_pointer __parent; | ||
| 1814 | __node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__value_); | ||
| 1815 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); | ||
| 1816 | return iterator(__nd); | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | template <class _Tp, class _Compare, class _Allocator> | 1977 | template <class _Tp, class _Compare, class _Allocator> |
| 1820 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 1978 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1821 | __tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _NOEXCEPT { | 1979 | __tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _NOEXCEPT { |
| 1822 | iterator __r(__ptr); | 1980 | iterator __r(__ptr); |
| 1823 | ++__r; | 1981 | ++__r; |
| 1824 | if (__begin_node() == __ptr) | 1982 | if (__begin_node_ == __ptr) |
| 1825 | __begin_node() = __r.__ptr_; | 1983 | __begin_node_ = __r.__ptr_; |
| 1826 | --size(); | 1984 | --__size_; |
| 1827 | std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__ptr)); | 1985 | std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__ptr)); |
| 1828 | return __r; | 1986 | return __r; |
| 1829 | } | 1987 | } |
| ... | @@ -1837,8 +1995,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n | ... | @@ -1837,8 +1995,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n |
| 1837 | return _InsertReturnType{end(), false, _NodeHandle()}; | 1995 | return _InsertReturnType{end(), false, _NodeHandle()}; |
| 1838 | 1996 | ||
| 1839 | __node_pointer __ptr = __nh.__ptr_; | 1997 | __node_pointer __ptr = __nh.__ptr_; |
| 1840 | __end_node_pointer __parent; | 1998 | auto [__parent, __child] = __find_equal(__ptr->__get_value()); |
| 1841 | __node_base_pointer& __child = __find_equal(__parent, __ptr->__value_); | ||
| 1842 | if (__child != nullptr) | 1999 | if (__child != nullptr) |
| 1843 | return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)}; | 2000 | return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)}; |
| 1844 | 2001 | ||
| ... | @@ -1855,10 +2012,9 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __ | ... | @@ -1855,10 +2012,9 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __ |
| 1855 | return end(); | 2012 | return end(); |
| 1856 | 2013 | ||
| 1857 | __node_pointer __ptr = __nh.__ptr_; | 2014 | __node_pointer __ptr = __nh.__ptr_; |
| 1858 | __end_node_pointer __parent; | ||
| 1859 | __node_base_pointer __dummy; | 2015 | __node_base_pointer __dummy; |
| 1860 | __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, __ptr->__value_); | 2016 | auto [__parent, __child] = __find_equal(__hint, __dummy, __ptr->__get_value()); |
| 1861 | __node_pointer __r = static_cast<__node_pointer>(__child); | 2017 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 1862 | if (__child == nullptr) { | 2018 | if (__child == nullptr) { |
| 1863 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); | 2019 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); |
| 1864 | __r = __ptr; | 2020 | __r = __ptr; |
| ... | @@ -1885,14 +2041,12 @@ _LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_hand | ... | @@ -1885,14 +2041,12 @@ _LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_hand |
| 1885 | } | 2041 | } |
| 1886 | 2042 | ||
| 1887 | template <class _Tp, class _Compare, class _Allocator> | 2043 | template <class _Tp, class _Compare, class _Allocator> |
| 1888 | template <class _Tree> | 2044 | template <class _Comp2> |
| 1889 | _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(_Tree& __source) { | 2045 | _LIBCPP_HIDE_FROM_ABI void |
| 1890 | static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, ""); | 2046 | __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source) { |
| 1891 | 2047 | for (iterator __i = __source.begin(); __i != __source.end();) { | |
| 1892 | for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) { | ||
| 1893 | __node_pointer __src_ptr = __i.__get_np(); | 2048 | __node_pointer __src_ptr = __i.__get_np(); |
| 1894 | __end_node_pointer __parent; | 2049 | auto [__parent, __child] = __find_equal(__src_ptr->__get_value()); |
| 1895 | __node_base_pointer& __child = __find_equal(__parent, __src_ptr->__value_); | ||
| 1896 | ++__i; | 2050 | ++__i; |
| 1897 | if (__child != nullptr) | 2051 | if (__child != nullptr) |
| 1898 | continue; | 2052 | continue; |
| ... | @@ -1909,7 +2063,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh | ... | @@ -1909,7 +2063,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh |
| 1909 | return end(); | 2063 | return end(); |
| 1910 | __node_pointer __ptr = __nh.__ptr_; | 2064 | __node_pointer __ptr = __nh.__ptr_; |
| 1911 | __end_node_pointer __parent; | 2065 | __end_node_pointer __parent; |
| 1912 | __node_base_pointer& __child = __find_leaf_high(__parent, __ptr->__value_); | 2066 | __node_base_pointer& __child = __find_leaf_high(__parent, __ptr->__get_value()); |
| 1913 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); | 2067 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); |
| 1914 | __nh.__release_ptr(); | 2068 | __nh.__release_ptr(); |
| 1915 | return iterator(__ptr); | 2069 | return iterator(__ptr); |
| ... | @@ -1924,21 +2078,20 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h | ... | @@ -1924,21 +2078,20 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h |
| 1924 | 2078 | ||
| 1925 | __node_pointer __ptr = __nh.__ptr_; | 2079 | __node_pointer __ptr = __nh.__ptr_; |
| 1926 | __end_node_pointer __parent; | 2080 | __end_node_pointer __parent; |
| 1927 | __node_base_pointer& __child = __find_leaf(__hint, __parent, __ptr->__value_); | 2081 | __node_base_pointer& __child = __find_leaf(__hint, __parent, __ptr->__get_value()); |
| 1928 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); | 2082 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); |
| 1929 | __nh.__release_ptr(); | 2083 | __nh.__release_ptr(); |
| 1930 | return iterator(__ptr); | 2084 | return iterator(__ptr); |
| 1931 | } | 2085 | } |
| 1932 | 2086 | ||
| 1933 | template <class _Tp, class _Compare, class _Allocator> | 2087 | template <class _Tp, class _Compare, class _Allocator> |
| 1934 | template <class _Tree> | 2088 | template <class _Comp2> |
| 1935 | _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(_Tree& __source) { | 2089 | _LIBCPP_HIDE_FROM_ABI void |
| 1936 | static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, ""); | 2090 | __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source) { |
| 1937 | 2091 | for (iterator __i = __source.begin(); __i != __source.end();) { | |
| 1938 | for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) { | ||
| 1939 | __node_pointer __src_ptr = __i.__get_np(); | 2092 | __node_pointer __src_ptr = __i.__get_np(); |
| 1940 | __end_node_pointer __parent; | 2093 | __end_node_pointer __parent; |
| 1941 | __node_base_pointer& __child = __find_leaf_high(__parent, __src_ptr->__value_); | 2094 | __node_base_pointer& __child = __find_leaf_high(__parent, __src_ptr->__get_value()); |
| 1942 | ++__i; | 2095 | ++__i; |
| 1943 | __source.__remove_node_pointer(__src_ptr); | 2096 | __source.__remove_node_pointer(__src_ptr); |
| 1944 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr)); | 2097 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr)); |
| ... | @@ -1987,34 +2140,17 @@ __tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) { | ... | @@ -1987,34 +2140,17 @@ __tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) { |
| 1987 | return __r; | 2140 | return __r; |
| 1988 | } | 2141 | } |
| 1989 | 2142 | ||
| 1990 | template <class _Tp, class _Compare, class _Allocator> | ||
| 1991 | template <class _Key> | ||
| 1992 | typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) { | ||
| 1993 | iterator __p = __lower_bound(__v, __root(), __end_node()); | ||
| 1994 | if (__p != end() && !value_comp()(__v, *__p)) | ||
| 1995 | return __p; | ||
| 1996 | return end(); | ||
| 1997 | } | ||
| 1998 | |||
| 1999 | template <class _Tp, class _Compare, class _Allocator> | ||
| 2000 | template <class _Key> | ||
| 2001 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator | ||
| 2002 | __tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const { | ||
| 2003 | const_iterator __p = __lower_bound(__v, __root(), __end_node()); | ||
| 2004 | if (__p != end() && !value_comp()(__v, *__p)) | ||
| 2005 | return __p; | ||
| 2006 | return end(); | ||
| 2007 | } | ||
| 2008 | |||
| 2009 | template <class _Tp, class _Compare, class _Allocator> | 2143 | template <class _Tp, class _Compare, class _Allocator> |
| 2010 | template <class _Key> | 2144 | template <class _Key> |
| 2011 | typename __tree<_Tp, _Compare, _Allocator>::size_type | 2145 | typename __tree<_Tp, _Compare, _Allocator>::size_type |
| 2012 | __tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const { | 2146 | __tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const { |
| 2013 | __node_pointer __rt = __root(); | 2147 | __node_pointer __rt = __root(); |
| 2148 | auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp()); | ||
| 2014 | while (__rt != nullptr) { | 2149 | while (__rt != nullptr) { |
| 2015 | if (value_comp()(__k, __rt->__value_)) { | 2150 | auto __comp_res = __comp(__k, __rt->__get_value()); |
| 2151 | if (__comp_res.__less()) { | ||
| 2016 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2152 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2017 | } else if (value_comp()(__rt->__value_, __k)) | 2153 | } else if (__comp_res.__greater()) |
| 2018 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2154 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2019 | else | 2155 | else |
| 2020 | return 1; | 2156 | return 1; |
| ... | @@ -2028,26 +2164,28 @@ typename __tree<_Tp, _Compare, _Allocator>::size_type | ... | @@ -2028,26 +2164,28 @@ typename __tree<_Tp, _Compare, _Allocator>::size_type |
| 2028 | __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const { | 2164 | __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const { |
| 2029 | __end_node_pointer __result = __end_node(); | 2165 | __end_node_pointer __result = __end_node(); |
| 2030 | __node_pointer __rt = __root(); | 2166 | __node_pointer __rt = __root(); |
| 2167 | auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp()); | ||
| 2031 | while (__rt != nullptr) { | 2168 | while (__rt != nullptr) { |
| 2032 | if (value_comp()(__k, __rt->__value_)) { | 2169 | auto __comp_res = __comp(__k, __rt->__get_value()); |
| 2170 | if (__comp_res.__less()) { | ||
| 2033 | __result = static_cast<__end_node_pointer>(__rt); | 2171 | __result = static_cast<__end_node_pointer>(__rt); |
| 2034 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2172 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2035 | } else if (value_comp()(__rt->__value_, __k)) | 2173 | } else if (__comp_res.__greater()) |
| 2036 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2174 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2037 | else | 2175 | else |
| 2038 | return std::distance( | 2176 | return std::distance( |
| 2039 | __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), | 2177 | __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), |
| 2040 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | 2178 | __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result)); |
| 2041 | } | 2179 | } |
| 2042 | return 0; | 2180 | return 0; |
| 2043 | } | 2181 | } |
| 2044 | 2182 | ||
| 2045 | template <class _Tp, class _Compare, class _Allocator> | 2183 | template <class _Tp, class _Compare, class _Allocator> |
| 2046 | template <class _Key> | 2184 | template <class _Key> |
| 2047 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 2185 | typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound_multi( |
| 2048 | __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) { | 2186 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) { |
| 2049 | while (__root != nullptr) { | 2187 | while (__root != nullptr) { |
| 2050 | if (!value_comp()(__root->__value_, __v)) { | 2188 | if (!value_comp()(__root->__get_value(), __v)) { |
| 2051 | __result = static_cast<__end_node_pointer>(__root); | 2189 | __result = static_cast<__end_node_pointer>(__root); |
| 2052 | __root = static_cast<__node_pointer>(__root->__left_); | 2190 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2053 | } else | 2191 | } else |
| ... | @@ -2058,10 +2196,10 @@ __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer | ... | @@ -2058,10 +2196,10 @@ __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer |
| 2058 | 2196 | ||
| 2059 | template <class _Tp, class _Compare, class _Allocator> | 2197 | template <class _Tp, class _Compare, class _Allocator> |
| 2060 | template <class _Key> | 2198 | template <class _Key> |
| 2061 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound( | 2199 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound_multi( |
| 2062 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) const { | 2200 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) const { |
| 2063 | while (__root != nullptr) { | 2201 | while (__root != nullptr) { |
| 2064 | if (!value_comp()(__root->__value_, __v)) { | 2202 | if (!value_comp()(__root->__get_value(), __v)) { |
| 2065 | __result = static_cast<__end_node_pointer>(__root); | 2203 | __result = static_cast<__end_node_pointer>(__root); |
| 2066 | __root = static_cast<__node_pointer>(__root->__left_); | 2204 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2067 | } else | 2205 | } else |
| ... | @@ -2072,10 +2210,10 @@ typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, | ... | @@ -2072,10 +2210,10 @@ typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, |
| 2072 | 2210 | ||
| 2073 | template <class _Tp, class _Compare, class _Allocator> | 2211 | template <class _Tp, class _Compare, class _Allocator> |
| 2074 | template <class _Key> | 2212 | template <class _Key> |
| 2075 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 2213 | typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound_multi( |
| 2076 | __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) { | 2214 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) { |
| 2077 | while (__root != nullptr) { | 2215 | while (__root != nullptr) { |
| 2078 | if (value_comp()(__v, __root->__value_)) { | 2216 | if (value_comp()(__v, __root->__get_value())) { |
| 2079 | __result = static_cast<__end_node_pointer>(__root); | 2217 | __result = static_cast<__end_node_pointer>(__root); |
| 2080 | __root = static_cast<__node_pointer>(__root->__left_); | 2218 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2081 | } else | 2219 | } else |
| ... | @@ -2086,10 +2224,10 @@ __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer | ... | @@ -2086,10 +2224,10 @@ __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer |
| 2086 | 2224 | ||
| 2087 | template <class _Tp, class _Compare, class _Allocator> | 2225 | template <class _Tp, class _Compare, class _Allocator> |
| 2088 | template <class _Key> | 2226 | template <class _Key> |
| 2089 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound( | 2227 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound_multi( |
| 2090 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) const { | 2228 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) const { |
| 2091 | while (__root != nullptr) { | 2229 | while (__root != nullptr) { |
| 2092 | if (value_comp()(__v, __root->__value_)) { | 2230 | if (value_comp()(__v, __root->__get_value())) { |
| 2093 | __result = static_cast<__end_node_pointer>(__root); | 2231 | __result = static_cast<__end_node_pointer>(__root); |
| 2094 | __root = static_cast<__node_pointer>(__root->__left_); | 2232 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2095 | } else | 2233 | } else |
| ... | @@ -2102,14 +2240,16 @@ template <class _Tp, class _Compare, class _Allocator> | ... | @@ -2102,14 +2240,16 @@ template <class _Tp, class _Compare, class _Allocator> |
| 2102 | template <class _Key> | 2240 | template <class _Key> |
| 2103 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> | 2241 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> |
| 2104 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) { | 2242 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) { |
| 2105 | typedef pair<iterator, iterator> _Pp; | 2243 | using _Pp = pair<iterator, iterator>; |
| 2106 | __end_node_pointer __result = __end_node(); | 2244 | __end_node_pointer __result = __end_node(); |
| 2107 | __node_pointer __rt = __root(); | 2245 | __node_pointer __rt = __root(); |
| 2246 | auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp()); | ||
| 2108 | while (__rt != nullptr) { | 2247 | while (__rt != nullptr) { |
| 2109 | if (value_comp()(__k, __rt->__value_)) { | 2248 | auto __comp_res = __comp(__k, __rt->__get_value()); |
| 2249 | if (__comp_res.__less()) { | ||
| 2110 | __result = static_cast<__end_node_pointer>(__rt); | 2250 | __result = static_cast<__end_node_pointer>(__rt); |
| 2111 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2251 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2112 | } else if (value_comp()(__rt->__value_, __k)) | 2252 | } else if (__comp_res.__greater()) |
| 2113 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2253 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2114 | else | 2254 | else |
| 2115 | return _Pp(iterator(__rt), | 2255 | return _Pp(iterator(__rt), |
| ... | @@ -2124,14 +2264,16 @@ template <class _Key> | ... | @@ -2124,14 +2264,16 @@ template <class _Key> |
| 2124 | pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, | 2264 | pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, |
| 2125 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> | 2265 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> |
| 2126 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const { | 2266 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const { |
| 2127 | typedef pair<const_iterator, const_iterator> _Pp; | 2267 | using _Pp = pair<const_iterator, const_iterator>; |
| 2128 | __end_node_pointer __result = __end_node(); | 2268 | __end_node_pointer __result = __end_node(); |
| 2129 | __node_pointer __rt = __root(); | 2269 | __node_pointer __rt = __root(); |
| 2270 | auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp()); | ||
| 2130 | while (__rt != nullptr) { | 2271 | while (__rt != nullptr) { |
| 2131 | if (value_comp()(__k, __rt->__value_)) { | 2272 | auto __comp_res = __comp(__k, __rt->__get_value()); |
| 2273 | if (__comp_res.__less()) { | ||
| 2132 | __result = static_cast<__end_node_pointer>(__rt); | 2274 | __result = static_cast<__end_node_pointer>(__rt); |
| 2133 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2275 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2134 | } else if (value_comp()(__rt->__value_, __k)) | 2276 | } else if (__comp_res.__greater()) |
| 2135 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2277 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2136 | else | 2278 | else |
| 2137 | return _Pp( | 2279 | return _Pp( |
| ... | @@ -2146,18 +2288,21 @@ template <class _Tp, class _Compare, class _Allocator> | ... | @@ -2146,18 +2288,21 @@ template <class _Tp, class _Compare, class _Allocator> |
| 2146 | template <class _Key> | 2288 | template <class _Key> |
| 2147 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> | 2289 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> |
| 2148 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) { | 2290 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) { |
| 2149 | typedef pair<iterator, iterator> _Pp; | 2291 | using _Pp = pair<iterator, iterator>; |
| 2150 | __end_node_pointer __result = __end_node(); | 2292 | __end_node_pointer __result = __end_node(); |
| 2151 | __node_pointer __rt = __root(); | 2293 | __node_pointer __rt = __root(); |
| 2294 | auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp()); | ||
| 2152 | while (__rt != nullptr) { | 2295 | while (__rt != nullptr) { |
| 2153 | if (value_comp()(__k, __rt->__value_)) { | 2296 | auto __comp_res = __comp(__k, __rt->__get_value()); |
| 2297 | if (__comp_res.__less()) { | ||
| 2154 | __result = static_cast<__end_node_pointer>(__rt); | 2298 | __result = static_cast<__end_node_pointer>(__rt); |
| 2155 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2299 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2156 | } else if (value_comp()(__rt->__value_, __k)) | 2300 | } else if (__comp_res.__greater()) |
| 2157 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2301 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2158 | else | 2302 | else |
| 2159 | return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), | 2303 | return _Pp( |
| 2160 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | 2304 | __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), |
| 2305 | __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | ||
| 2161 | } | 2306 | } |
| 2162 | return _Pp(iterator(__result), iterator(__result)); | 2307 | return _Pp(iterator(__result), iterator(__result)); |
| 2163 | } | 2308 | } |
| ... | @@ -2167,18 +2312,21 @@ template <class _Key> | ... | @@ -2167,18 +2312,21 @@ template <class _Key> |
| 2167 | pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, | 2312 | pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, |
| 2168 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> | 2313 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> |
| 2169 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const { | 2314 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const { |
| 2170 | typedef pair<const_iterator, const_iterator> _Pp; | 2315 | using _Pp = pair<const_iterator, const_iterator>; |
| 2171 | __end_node_pointer __result = __end_node(); | 2316 | __end_node_pointer __result = __end_node(); |
| 2172 | __node_pointer __rt = __root(); | 2317 | __node_pointer __rt = __root(); |
| 2318 | auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp()); | ||
| 2173 | while (__rt != nullptr) { | 2319 | while (__rt != nullptr) { |
| 2174 | if (value_comp()(__k, __rt->__value_)) { | 2320 | auto __comp_res = __comp(__k, __rt->__get_value()); |
| 2321 | if (__comp_res.__less()) { | ||
| 2175 | __result = static_cast<__end_node_pointer>(__rt); | 2322 | __result = static_cast<__end_node_pointer>(__rt); |
| 2176 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2323 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2177 | } else if (value_comp()(__rt->__value_, __k)) | 2324 | } else if (__comp_res.__greater()) |
| 2178 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2325 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2179 | else | 2326 | else |
| 2180 | return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), | 2327 | return _Pp( |
| 2181 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | 2328 | __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), |
| 2329 | __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | ||
| 2182 | } | 2330 | } |
| 2183 | return _Pp(const_iterator(__result), const_iterator(__result)); | 2331 | return _Pp(const_iterator(__result), const_iterator(__result)); |
| 2184 | } | 2332 | } |
| ... | @@ -2187,13 +2335,13 @@ template <class _Tp, class _Compare, class _Allocator> | ... | @@ -2187,13 +2335,13 @@ template <class _Tp, class _Compare, class _Allocator> |
| 2187 | typename __tree<_Tp, _Compare, _Allocator>::__node_holder | 2335 | typename __tree<_Tp, _Compare, _Allocator>::__node_holder |
| 2188 | __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT { | 2336 | __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT { |
| 2189 | __node_pointer __np = __p.__get_np(); | 2337 | __node_pointer __np = __p.__get_np(); |
| 2190 | if (__begin_node() == __p.__ptr_) { | 2338 | if (__begin_node_ == __p.__ptr_) { |
| 2191 | if (__np->__right_ != nullptr) | 2339 | if (__np->__right_ != nullptr) |
| 2192 | __begin_node() = static_cast<__end_node_pointer>(__np->__right_); | 2340 | __begin_node_ = static_cast<__end_node_pointer>(__np->__right_); |
| 2193 | else | 2341 | else |
| 2194 | __begin_node() = static_cast<__end_node_pointer>(__np->__parent_); | 2342 | __begin_node_ = static_cast<__end_node_pointer>(__np->__parent_); |
| 2195 | } | 2343 | } |
| 2196 | --size(); | 2344 | --__size_; |
| 2197 | std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); | 2345 | std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); |
| 2198 | return __node_holder(__np, _Dp(__node_alloc(), true)); | 2346 | return __node_holder(__np, _Dp(__node_alloc(), true)); |
| 2199 | } | 2347 | } |
lib/libcxx/include/__tuple/sfinae_helpers.h+1-44| ... | @@ -10,20 +10,6 @@ | ... | @@ -10,20 +10,6 @@ |
| 10 | #define _LIBCPP___TUPLE_SFINAE_HELPERS_H | 10 | #define _LIBCPP___TUPLE_SFINAE_HELPERS_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | ||
| 14 | #include <__fwd/tuple.h> | ||
| 15 | #include <__tuple/make_tuple_types.h> | ||
| 16 | #include <__tuple/tuple_element.h> | ||
| 17 | #include <__tuple/tuple_like_ext.h> | ||
| 18 | #include <__tuple/tuple_size.h> | ||
| 19 | #include <__tuple/tuple_types.h> | ||
| 20 | #include <__type_traits/conjunction.h> | ||
| 21 | #include <__type_traits/enable_if.h> | ||
| 22 | #include <__type_traits/integral_constant.h> | ||
| 23 | #include <__type_traits/is_constructible.h> | ||
| 24 | #include <__type_traits/is_same.h> | ||
| 25 | #include <__type_traits/remove_cvref.h> | ||
| 26 | #include <__type_traits/remove_reference.h> | ||
| 27 | 13 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -33,36 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -33,36 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 19 | ||
| 34 | #ifndef _LIBCPP_CXX03_LANG | 20 | #ifndef _LIBCPP_CXX03_LANG |
| 35 | 21 | ||
| 36 | struct __tuple_sfinae_base { | 22 | struct __check_tuple_constructor_fail { |
| 37 | template <template <class, class...> class _Trait, class... _LArgs, class... _RArgs> | ||
| 38 | static auto __do_test(__tuple_types<_LArgs...>, | ||
| 39 | __tuple_types<_RArgs...>) -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>; | ||
| 40 | template <template <class...> class> | ||
| 41 | static auto __do_test(...) -> false_type; | ||
| 42 | |||
| 43 | template <class _FromArgs, class _ToArgs> | ||
| 44 | using __constructible _LIBCPP_NODEBUG = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{})); | ||
| 45 | }; | ||
| 46 | |||
| 47 | // __tuple_constructible | ||
| 48 | |||
| 49 | template <class _Tp, | ||
| 50 | class _Up, | ||
| 51 | bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value, | ||
| 52 | bool = __tuple_like_ext<_Up>::value> | ||
| 53 | struct __tuple_constructible : public false_type {}; | ||
| 54 | |||
| 55 | template <class _Tp, class _Up> | ||
| 56 | struct __tuple_constructible<_Tp, _Up, true, true> | ||
| 57 | : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type, | ||
| 58 | typename __make_tuple_types<_Up>::type > {}; | ||
| 59 | |||
| 60 | template <size_t _Ip, class... _Tp> | ||
| 61 | struct tuple_element<_Ip, tuple<_Tp...> > { | ||
| 62 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type; | ||
| 63 | }; | ||
| 64 | |||
| 65 | struct _LIBCPP_EXPORTED_FROM_ABI __check_tuple_constructor_fail { | ||
| 66 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit_default() { return false; } | 23 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit_default() { return false; } |
| 67 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { return false; } | 24 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { return false; } |
| 68 | template <class...> | 25 | template <class...> |
lib/libcxx/include/__tuple/tuple_element.h-12| ... | @@ -11,8 +11,6 @@ | ... | @@ -11,8 +11,6 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__tuple/tuple_indices.h> | ||
| 15 | #include <__tuple/tuple_types.h> | ||
| 16 | 14 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -38,21 +36,11 @@ struct tuple_element<_Ip, const volatile _Tp> { | ... | @@ -38,21 +36,11 @@ struct tuple_element<_Ip, const volatile _Tp> { |
| 38 | using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type; | 36 | using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type; |
| 39 | }; | 37 | }; |
| 40 | 38 | ||
| 41 | #ifndef _LIBCPP_CXX03_LANG | ||
| 42 | |||
| 43 | template <size_t _Ip, class... _Types> | ||
| 44 | struct tuple_element<_Ip, __tuple_types<_Types...> > { | ||
| 45 | static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); | ||
| 46 | using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>; | ||
| 47 | }; | ||
| 48 | |||
| 49 | # if _LIBCPP_STD_VER >= 14 | 39 | # if _LIBCPP_STD_VER >= 14 |
| 50 | template <size_t _Ip, class... _Tp> | 40 | template <size_t _Ip, class... _Tp> |
| 51 | using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element<_Ip, _Tp...>::type; | 41 | using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element<_Ip, _Tp...>::type; |
| 52 | # endif | 42 | # endif |
| 53 | 43 | ||
| 54 | #endif // _LIBCPP_CXX03_LANG | ||
| 55 | |||
| 56 | _LIBCPP_END_NAMESPACE_STD | 44 | _LIBCPP_END_NAMESPACE_STD |
| 57 | 45 | ||
| 58 | #endif // _LIBCPP___TUPLE_TUPLE_ELEMENT_H | 46 | #endif // _LIBCPP___TUPLE_TUPLE_ELEMENT_H |
lib/libcxx/include/__tuple/tuple_size.h-4| ... | @@ -12,7 +12,6 @@ | ... | @@ -12,7 +12,6 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__fwd/tuple.h> | 14 | #include <__fwd/tuple.h> |
| 15 | #include <__tuple/tuple_types.h> | ||
| 16 | #include <__type_traits/enable_if.h> | 15 | #include <__type_traits/enable_if.h> |
| 17 | #include <__type_traits/integral_constant.h> | 16 | #include <__type_traits/integral_constant.h> |
| 18 | #include <__type_traits/is_const.h> | 17 | #include <__type_traits/is_const.h> |
| ... | @@ -59,9 +58,6 @@ struct tuple_size<const volatile _Tp> : public tuple_size<_Tp> {}; | ... | @@ -59,9 +58,6 @@ struct tuple_size<const volatile _Tp> : public tuple_size<_Tp> {}; |
| 59 | template <class... _Tp> | 58 | template <class... _Tp> |
| 60 | struct tuple_size<tuple<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; | 59 | struct tuple_size<tuple<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; |
| 61 | 60 | ||
| 62 | template <class... _Tp> | ||
| 63 | struct tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; | ||
| 64 | |||
| 65 | # if _LIBCPP_STD_VER >= 17 | 61 | # if _LIBCPP_STD_VER >= 17 |
| 66 | template <class _Tp> | 62 | template <class _Tp> |
| 67 | inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; | 63 | inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; |
lib/libcxx/include/__tuple/tuple_transform.h created+45| ... | @@ -0,0 +1,45 @@ | ||
| 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___TUPLE_TUPLE_TRANSFORM_H | ||
| 11 | #define _LIBCPP___TUPLE_TUPLE_TRANSFORM_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #include <__functional/invoke.h> | ||
| 16 | #include <__utility/forward.h> | ||
| 17 | #include <tuple> | ||
| 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 | ||
| 27 | |||
| 28 | #if _LIBCPP_STD_VER >= 23 | ||
| 29 | |||
| 30 | template <class _Fun, class _Tuple> | ||
| 31 | _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) { | ||
| 32 | return std::apply( | ||
| 33 | [&]<class... _Types>(_Types&&... __elements) { | ||
| 34 | return tuple<invoke_result_t<_Fun&, _Types>...>(std::invoke(__f, std::forward<_Types>(__elements))...); | ||
| 35 | }, | ||
| 36 | std::forward<_Tuple>(__tuple)); | ||
| 37 | } | ||
| 38 | |||
| 39 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 40 | |||
| 41 | _LIBCPP_END_NAMESPACE_STD | ||
| 42 | |||
| 43 | _LIBCPP_POP_MACROS | ||
| 44 | |||
| 45 | #endif // _LIBCPP___TUPLE_TUPLE_TRANSFORM_H | ||
lib/libcxx/include/__type_traits/aligned_storage.h+13-40| ... | @@ -11,8 +11,6 @@ | ... | @@ -11,8 +11,6 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | #include <__type_traits/type_list.h> | ||
| 16 | 14 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -21,10 +19,10 @@ | ... | @@ -21,10 +19,10 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 20 | ||
| 23 | template <class _Tp> | 21 | template <class _Tp> |
| 24 | struct __align_type { | 22 | struct _ALIGNAS(_LIBCPP_PREFERRED_ALIGNOF(_Tp)) _AlignedAsT {}; |
| 25 | static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); | 23 | |
| 26 | typedef _Tp type; | 24 | template <class... _Args> |
| 27 | }; | 25 | struct __max_align_impl : _AlignedAsT<_Args>... {}; |
| 28 | 26 | ||
| 29 | struct __struct_double { | 27 | struct __struct_double { |
| 30 | long double __lx; | 28 | long double __lx; |
| ... | @@ -33,41 +31,16 @@ struct __struct_double4 { | ... | @@ -33,41 +31,16 @@ struct __struct_double4 { |
| 33 | double __lx[4]; | 31 | double __lx[4]; |
| 34 | }; | 32 | }; |
| 35 | 33 | ||
| 36 | using __all_types _LIBCPP_NODEBUG = | 34 | inline const size_t __aligned_storage_max_align = |
| 37 | __type_list<__align_type<unsigned char>, | 35 | _LIBCPP_ALIGNOF(__max_align_impl<unsigned long long, double, long double, __struct_double, __struct_double4, int*>); |
| 38 | __align_type<unsigned short>, | ||
| 39 | __align_type<unsigned int>, | ||
| 40 | __align_type<unsigned long>, | ||
| 41 | __align_type<unsigned long long>, | ||
| 42 | __align_type<double>, | ||
| 43 | __align_type<long double>, | ||
| 44 | __align_type<__struct_double>, | ||
| 45 | __align_type<__struct_double4>, | ||
| 46 | __align_type<int*> >; | ||
| 47 | |||
| 48 | template <class _TL, size_t _Len> | ||
| 49 | struct __find_max_align; | ||
| 50 | |||
| 51 | template <class _Head, size_t _Len> | ||
| 52 | struct __find_max_align<__type_list<_Head>, _Len> : public integral_constant<size_t, _Head::value> {}; | ||
| 53 | |||
| 54 | template <size_t _Len, size_t _A1, size_t _A2> | ||
| 55 | struct __select_align { | ||
| 56 | private: | ||
| 57 | static const size_t __min = _A2 < _A1 ? _A2 : _A1; | ||
| 58 | static const size_t __max = _A1 < _A2 ? _A2 : _A1; | ||
| 59 | |||
| 60 | public: | ||
| 61 | static const size_t value = _Len < __max ? __min : __max; | ||
| 62 | }; | ||
| 63 | 36 | ||
| 64 | template <class _Head, class... _Tail, size_t _Len> | 37 | template <size_t _Len> |
| 65 | struct __find_max_align<__type_list<_Head, _Tail...>, _Len> | 38 | inline const size_t __aligned_storage_alignment = |
| 66 | : public integral_constant< | 39 | _Len > __aligned_storage_max_align |
| 67 | size_t, | 40 | ? __aligned_storage_max_align |
| 68 | __select_align<_Len, _Head::value, __find_max_align<__type_list<_Tail...>, _Len>::value>::value> {}; | 41 | : size_t(1) << ((sizeof(size_t) * __CHAR_BIT__) - __builtin_clzg(_Len) - 1); |
| 69 | 42 | ||
| 70 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> | 43 | template <size_t _Len, size_t _Align = __aligned_storage_alignment<_Len> > |
| 71 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_storage { | 44 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_storage { |
| 72 | union _ALIGNAS(_Align) type { | 45 | union _ALIGNAS(_Align) type { |
| 73 | unsigned char __data[(_Len + _Align - 1) / _Align * _Align]; | 46 | unsigned char __data[(_Len + _Align - 1) / _Align * _Align]; |
| ... | @@ -77,7 +50,7 @@ struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_storage { | ... | @@ -77,7 +50,7 @@ struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_storage { |
| 77 | #if _LIBCPP_STD_VER >= 14 | 50 | #if _LIBCPP_STD_VER >= 14 |
| 78 | 51 | ||
| 79 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 52 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 80 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> | 53 | template <size_t _Len, size_t _Align = __aligned_storage_alignment<_Len> > |
| 81 | using aligned_storage_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_storage<_Len, _Align>::type; | 54 | using aligned_storage_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_storage<_Len, _Align>::type; |
| 82 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 55 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 83 | 56 |
lib/libcxx/include/__type_traits/desugars_to.h+4| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H | 10 | #define _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | ||
| 13 | 14 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -64,6 +65,9 @@ template <class _CanonicalTag, class _Operation, class... _Args> | ... | @@ -64,6 +65,9 @@ template <class _CanonicalTag, class _Operation, class... _Args> |
| 64 | inline const bool __desugars_to_v<_CanonicalTag, _Operation&&, _Args...> = | 65 | inline const bool __desugars_to_v<_CanonicalTag, _Operation&&, _Args...> = |
| 65 | __desugars_to_v<_CanonicalTag, _Operation, _Args...>; | 66 | __desugars_to_v<_CanonicalTag, _Operation, _Args...>; |
| 66 | 67 | ||
| 68 | template <class _CanonicalTag, class _Operation, class... _Args> | ||
| 69 | struct __desugars_to : integral_constant<bool, __desugars_to_v<_CanonicalTag, _Operation, _Args...> > {}; | ||
| 70 | |||
| 67 | _LIBCPP_END_NAMESPACE_STD | 71 | _LIBCPP_END_NAMESPACE_STD |
| 68 | 72 | ||
| 69 | #endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H | 73 | #endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H |
lib/libcxx/include/__type_traits/invoke.h+8| ... | @@ -62,6 +62,9 @@ | ... | @@ -62,6 +62,9 @@ |
| 62 | // | 62 | // |
| 63 | // template <class Func, class... Args> | 63 | // template <class Func, class... Args> |
| 64 | // using __invoke_result_t = invoke_result_t<Func, Args...>; | 64 | // using __invoke_result_t = invoke_result_t<Func, Args...>; |
| 65 | // | ||
| 66 | // template <class Ret, class Func, class... Args> | ||
| 67 | // struct __is_invocable_r : is_invocable_r<Ret, Func, Args...> {}; | ||
| 65 | 68 | ||
| 66 | _LIBCPP_BEGIN_NAMESPACE_STD | 69 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 67 | 70 | ||
| ... | @@ -112,8 +115,10 @@ inline const bool __is_invocable_r_v = __is_invocable_r_impl<_Ret, __is_invocabl | ... | @@ -112,8 +115,10 @@ inline const bool __is_invocable_r_v = __is_invocable_r_impl<_Ret, __is_invocabl |
| 112 | template <bool __is_invocable, class... _Args> | 115 | template <bool __is_invocable, class... _Args> |
| 113 | inline const bool __is_nothrow_invocable_impl = false; | 116 | inline const bool __is_nothrow_invocable_impl = false; |
| 114 | 117 | ||
| 118 | # ifndef _LIBCPP_CXX03_LANG | ||
| 115 | template <class... _Args> | 119 | template <class... _Args> |
| 116 | inline const bool __is_nothrow_invocable_impl<true, _Args...> = noexcept(__builtin_invoke(std::declval<_Args>()...)); | 120 | inline const bool __is_nothrow_invocable_impl<true, _Args...> = noexcept(__builtin_invoke(std::declval<_Args>()...)); |
| 121 | # endif | ||
| 117 | 122 | ||
| 118 | template <class... _Args> | 123 | template <class... _Args> |
| 119 | inline const bool __is_nothrow_invocable_v = __is_nothrow_invocable_impl<__is_invocable_v<_Args...>, _Args...>; | 124 | inline const bool __is_nothrow_invocable_v = __is_nothrow_invocable_impl<__is_invocable_v<_Args...>, _Args...>; |
| ... | @@ -327,6 +332,9 @@ using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args. | ... | @@ -327,6 +332,9 @@ using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args. |
| 327 | 332 | ||
| 328 | #endif // __has_builtin(__builtin_invoke_r) | 333 | #endif // __has_builtin(__builtin_invoke_r) |
| 329 | 334 | ||
| 335 | template <class _Ret, class _Func, class... _Args> | ||
| 336 | struct __is_invocable_r : integral_constant<bool, __is_invocable_r_v<_Ret, _Func, _Args...> > {}; | ||
| 337 | |||
| 330 | template <class _Ret, bool = is_void<_Ret>::value> | 338 | template <class _Ret, bool = is_void<_Ret>::value> |
| 331 | struct __invoke_void_return_wrapper { | 339 | struct __invoke_void_return_wrapper { |
| 332 | template <class... _Args> | 340 | template <class... _Args> |
lib/libcxx/include/__type_traits/is_allocator.h+6-7| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | #include <__type_traits/void_t.h> | 14 | #include <__type_traits/void_t.h> |
| 16 | #include <__utility/declval.h> | 15 | #include <__utility/declval.h> |
| 17 | 16 | ||
| ... | @@ -21,13 +20,13 @@ | ... | @@ -21,13 +20,13 @@ |
| 21 | 20 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 22 | ||
| 24 | template <typename _Alloc, typename = void, typename = void> | 23 | template <class _Alloc, class = void, class = void> |
| 25 | struct __is_allocator : false_type {}; | 24 | inline const bool __is_allocator_v = false; |
| 26 | 25 | ||
| 27 | template <typename _Alloc> | 26 | template <class _Alloc> |
| 28 | struct __is_allocator<_Alloc, | 27 | inline const bool __is_allocator_v<_Alloc, |
| 29 | __void_t<typename _Alloc::value_type>, | 28 | __void_t<typename _Alloc::value_type>, |
| 30 | __void_t<decltype(std::declval<_Alloc&>().allocate(size_t(0)))> > : true_type {}; | 29 | __void_t<decltype(std::declval<_Alloc&>().allocate(size_t()))> > = true; |
| 31 | 30 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | 31 | _LIBCPP_END_NAMESPACE_STD |
| 33 | 32 |
lib/libcxx/include/__type_traits/is_array.h+26| ... | @@ -26,6 +26,32 @@ template <class _Tp> | ... | @@ -26,6 +26,32 @@ template <class _Tp> |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp); | 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp); |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | template <class _Tp> | ||
| 30 | inline const bool __is_bounded_array_v = __is_bounded_array(_Tp); | ||
| 31 | |||
| 32 | #if _LIBCPP_STD_VER >= 20 | ||
| 33 | |||
| 34 | template <class _Tp> | ||
| 35 | struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : bool_constant<__is_bounded_array(_Tp)> {}; | ||
| 36 | |||
| 37 | template <class _Tp> | ||
| 38 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp); | ||
| 39 | |||
| 40 | #endif | ||
| 41 | |||
| 42 | template <class _Tp> | ||
| 43 | inline const bool __is_unbounded_array_v = __is_unbounded_array(_Tp); | ||
| 44 | |||
| 45 | #if _LIBCPP_STD_VER >= 20 | ||
| 46 | |||
| 47 | template <class _Tp> | ||
| 48 | struct _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : bool_constant<__is_unbounded_array(_Tp)> {}; | ||
| 49 | |||
| 50 | template <class _Tp> | ||
| 51 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = __is_unbounded_array(_Tp); | ||
| 52 | |||
| 53 | #endif | ||
| 54 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | 55 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 56 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_ARRAY_H | 57 | #endif // _LIBCPP___TYPE_TRAITS_IS_ARRAY_H |
lib/libcxx/include/__type_traits/is_equality_comparable.h+16-21| ... | @@ -27,11 +27,11 @@ | ... | @@ -27,11 +27,11 @@ |
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | template <class _Tp, class _Up, class = void> | 29 | template <class _Tp, class _Up, class = void> |
| 30 | struct __is_equality_comparable : false_type {}; | 30 | inline const bool __is_equality_comparable_v = false; |
| 31 | 31 | ||
| 32 | template <class _Tp, class _Up> | 32 | template <class _Tp, class _Up> |
| 33 | struct __is_equality_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() == std::declval<_Up>())> > : true_type { | 33 | inline const bool |
| 34 | }; | 34 | __is_equality_comparable_v<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() == std::declval<_Up>())> > = true; |
| 35 | 35 | ||
| 36 | // A type is_trivially_equality_comparable if the expression `a == b` is equivalent to `std::memcmp(&a, &b, sizeof(T))` | 36 | // A type is_trivially_equality_comparable if the expression `a == b` is equivalent to `std::memcmp(&a, &b, sizeof(T))` |
| 37 | // (with `a` and `b` being of type `T`). For the case where we compare two object of the same type, we can use | 37 | // (with `a` and `b` being of type `T`). For the case where we compare two object of the same type, we can use |
| ... | @@ -48,40 +48,35 @@ struct __is_equality_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() | ... | @@ -48,40 +48,35 @@ struct __is_equality_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() |
| 48 | // representation may not be equivalent. | 48 | // representation may not be equivalent. |
| 49 | 49 | ||
| 50 | template <class _Tp, class _Up, class = void> | 50 | template <class _Tp, class _Up, class = void> |
| 51 | struct __libcpp_is_trivially_equality_comparable_impl : false_type {}; | 51 | inline const bool __is_trivially_equality_comparable_impl = false; |
| 52 | 52 | ||
| 53 | template <class _Tp> | 53 | template <class _Tp> |
| 54 | struct __libcpp_is_trivially_equality_comparable_impl<_Tp, _Tp> | 54 | inline const bool __is_trivially_equality_comparable_impl<_Tp, _Tp> |
| 55 | #if __has_builtin(__is_trivially_equality_comparable) | 55 | #if __has_builtin(__is_trivially_equality_comparable) |
| 56 | : integral_constant<bool, __is_trivially_equality_comparable(_Tp) && __is_equality_comparable<_Tp, _Tp>::value> { | 56 | = __is_trivially_equality_comparable(_Tp) && __is_equality_comparable_v<_Tp, _Tp>; |
| 57 | }; | ||
| 58 | #else | 57 | #else |
| 59 | : is_integral<_Tp> { | 58 | = is_integral<_Tp>::value; |
| 60 | }; | ||
| 61 | #endif // __has_builtin(__is_trivially_equality_comparable) | 59 | #endif // __has_builtin(__is_trivially_equality_comparable) |
| 62 | 60 | ||
| 63 | template <class _Tp, class _Up> | 61 | template <class _Tp, class _Up> |
| 64 | struct __libcpp_is_trivially_equality_comparable_impl< | 62 | inline const bool __is_trivially_equality_comparable_impl< |
| 65 | _Tp, | 63 | _Tp, |
| 66 | _Up, | 64 | _Up, |
| 67 | __enable_if_t<is_integral<_Tp>::value && is_integral<_Up>::value && !is_same<_Tp, _Up>::value && | 65 | __enable_if_t<is_integral<_Tp>::value && is_integral<_Up>::value && !is_same<_Tp, _Up>::value> > = |
| 68 | is_signed<_Tp>::value == is_signed<_Up>::value && sizeof(_Tp) == sizeof(_Up)> > : true_type {}; | 66 | is_signed<_Tp>::value == is_signed<_Up>::value && sizeof(_Tp) == sizeof(_Up); |
| 69 | 67 | ||
| 70 | template <class _Tp> | 68 | template <class _Tp> |
| 71 | struct __libcpp_is_trivially_equality_comparable_impl<_Tp*, _Tp*> : true_type {}; | 69 | inline const bool __is_trivially_equality_comparable_impl<_Tp*, _Tp*> = true; |
| 72 | 70 | ||
| 73 | // TODO: Use is_pointer_inverconvertible_base_of | 71 | // TODO: Use is_pointer_inverconvertible_base_of |
| 74 | template <class _Tp, class _Up> | 72 | template <class _Tp, class _Up> |
| 75 | struct __libcpp_is_trivially_equality_comparable_impl<_Tp*, _Up*> | 73 | inline const bool __is_trivially_equality_comparable_impl<_Tp*, _Up*> = |
| 76 | : integral_constant< | 74 | __is_equality_comparable_v<_Tp*, _Up*> && |
| 77 | bool, | 75 | (is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value || is_void<_Tp>::value || is_void<_Up>::value); |
| 78 | __is_equality_comparable<_Tp*, _Up*>::value && | ||
| 79 | (is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value || is_void<_Tp>::value || is_void<_Up>::value)> { | ||
| 80 | }; | ||
| 81 | 76 | ||
| 82 | template <class _Tp, class _Up> | 77 | template <class _Tp, class _Up> |
| 83 | using __libcpp_is_trivially_equality_comparable _LIBCPP_NODEBUG = | 78 | inline const bool __is_trivially_equality_comparable_v = |
| 84 | __libcpp_is_trivially_equality_comparable_impl<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >; | 79 | __is_trivially_equality_comparable_impl<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >; |
| 85 | 80 | ||
| 86 | _LIBCPP_END_NAMESPACE_STD | 81 | _LIBCPP_END_NAMESPACE_STD |
| 87 | 82 |
lib/libcxx/include/__type_traits/is_final.h+1-1| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct __libcpp_is_final : integral_constant<bool, __is_final(_Tp)> {}; | 22 | inline const bool __is_final_v = __is_final(_Tp); |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 14 | 24 | #if _LIBCPP_STD_VER >= 14 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_floating_point.h+7-6| ... | @@ -20,18 +20,19 @@ | ... | @@ -20,18 +20,19 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | // clang-format off | 22 | // clang-format off |
| 23 | template <class _Tp> struct __libcpp_is_floating_point : false_type {}; | 23 | template <class _Tp> inline const bool __is_floating_point_impl = false; |
| 24 | template <> struct __libcpp_is_floating_point<float> : true_type {}; | 24 | template <> inline const bool __is_floating_point_impl<float> = true; |
| 25 | template <> struct __libcpp_is_floating_point<double> : true_type {}; | 25 | template <> inline const bool __is_floating_point_impl<double> = true; |
| 26 | template <> struct __libcpp_is_floating_point<long double> : true_type {}; | 26 | template <> inline const bool __is_floating_point_impl<long double> = true; |
| 27 | // clang-format on | 27 | // clang-format on |
| 28 | 28 | ||
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| 30 | struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point : __libcpp_is_floating_point<__remove_cv_t<_Tp> > {}; | 30 | struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point |
| 31 | : integral_constant<bool, __is_floating_point_impl<__remove_cv_t<_Tp> > > {}; | ||
| 31 | 32 | ||
| 32 | #if _LIBCPP_STD_VER >= 17 | 33 | #if _LIBCPP_STD_VER >= 17 |
| 33 | template <class _Tp> | 34 | template <class _Tp> |
| 34 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; | 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_floating_point_v = __is_floating_point_impl<__remove_cv_t<_Tp>>; |
| 35 | #endif | 36 | #endif |
| 36 | 37 | ||
| 37 | _LIBCPP_END_NAMESPACE_STD | 38 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_generic_transparent_comparator.h created+30| ... | @@ -0,0 +1,30 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_GENERIC_TRANSPARENT_COMPARATOR_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_GENERIC_TRANSPARENT_COMPARATOR_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | // This trait returns true if the given _Comparator is known to accept any two types for comparison. This is separate | ||
| 21 | // from `__is_transparent_v`, since that only enables overloads of specific functions, but doesn't give any semantic | ||
| 22 | // guarantees. This trait guarantess that the comparator simply calls the appropriate comparison functions for any two | ||
| 23 | // types. | ||
| 24 | |||
| 25 | template <class _Comparator> | ||
| 26 | inline const bool __is_generic_transparent_comparator_v = false; | ||
| 27 | |||
| 28 | _LIBCPP_END_NAMESPACE_STD | ||
| 29 | |||
| 30 | #endif // _LIBCPP___TYPE_TRAITS_IS_GENERIC_TRANSPARENT_COMPARATOR_H | ||
lib/libcxx/include/__type_traits/is_specialization.h+2-6| ... | @@ -30,15 +30,11 @@ | ... | @@ -30,15 +30,11 @@ |
| 30 | 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | ||
| 33 | #if _LIBCPP_STD_VER >= 17 | ||
| 34 | |||
| 35 | template <class _Tp, template <class...> class _Template> | 33 | template <class _Tp, template <class...> class _Template> |
| 36 | inline constexpr bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template | 34 | inline const bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template |
| 37 | 35 | ||
| 38 | template <template <class...> class _Template, class... _Args> | 36 | template <template <class...> class _Template, class... _Args> |
| 39 | inline constexpr bool __is_specialization_v<_Template<_Args...>, _Template> = true; | 37 | inline const bool __is_specialization_v<_Template<_Args...>, _Template> = true; |
| 40 | |||
| 41 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 42 | 38 | ||
| 43 | _LIBCPP_END_NAMESPACE_STD | 39 | _LIBCPP_END_NAMESPACE_STD |
| 44 | 40 |
lib/libcxx/include/__type_traits/is_within_lifetime.h created+29| ... | @@ -0,0 +1,29 @@ | ||
| 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_WITHIN_LIFETIME_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_WITHIN_LIFETIME_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 | #if _LIBCPP_STD_VER >= 26 && __has_builtin(__builtin_is_within_lifetime) | ||
| 21 | template <class _Tp> | ||
| 22 | _LIBCPP_HIDE_FROM_ABI consteval bool is_within_lifetime(const _Tp* __p) noexcept { | ||
| 23 | return __builtin_is_within_lifetime(__p); | ||
| 24 | } | ||
| 25 | #endif | ||
| 26 | |||
| 27 | _LIBCPP_END_NAMESPACE_STD | ||
| 28 | |||
| 29 | #endif // _LIBCPP___TYPE_TRAITS_IS_WITHIN_LIFETIME_H | ||
lib/libcxx/include/__type_traits/make_transparent.h created+52| ... | @@ -0,0 +1,52 @@ | ||
| 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_MAKE_TRANSPARENT_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_TRANSPARENT_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/enable_if.h> | ||
| 14 | #include <__type_traits/is_empty.h> | ||
| 15 | #include <__type_traits/is_same.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 | // __make_transparent tries to create a transparent comparator from its non-transparent counterpart, e.g. obtain | ||
| 24 | // `less<>` from `less<T>`. This is useful in cases where conversions can be avoided (e.g. a string literal to a | ||
| 25 | // std::string). | ||
| 26 | |||
| 27 | template <class _Tp, class _Comparator> | ||
| 28 | struct __make_transparent { | ||
| 29 | using type _LIBCPP_NODEBUG = _Comparator; | ||
| 30 | }; | ||
| 31 | |||
| 32 | template <class _Tp, class _Comparator> | ||
| 33 | using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_Tp, _Comparator>::type; | ||
| 34 | |||
| 35 | template <class _Tp, | ||
| 36 | class _Comparator, | ||
| 37 | __enable_if_t<is_same<_Comparator, __make_transparent_t<_Tp, _Comparator> >::value, int> = 0> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI _Comparator& __as_transparent(_Comparator& __comp) { | ||
| 39 | return __comp; | ||
| 40 | } | ||
| 41 | |||
| 42 | template <class _Tp, | ||
| 43 | class _Comparator, | ||
| 44 | __enable_if_t<!is_same<_Comparator, __make_transparent_t<_Tp, _Comparator> >::value, int> = 0> | ||
| 45 | _LIBCPP_HIDE_FROM_ABI __make_transparent_t<_Tp, _Comparator> __as_transparent(_Comparator&) { | ||
| 46 | static_assert(is_empty<_Comparator>::value); | ||
| 47 | return __make_transparent_t<_Tp, _Comparator>(); | ||
| 48 | } | ||
| 49 | |||
| 50 | _LIBCPP_END_NAMESPACE_STD | ||
| 51 | |||
| 52 | #endif // _LIBCPP___TYPE_TRAITS_MAKE_TRANSPARENT_H | ||
lib/libcxx/include/__type_traits/reference_constructs_from_temporary.h+1-7| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 23 && __has_builtin(__reference_constructs_from_temporary) | 21 | #if _LIBCPP_STD_VER >= 23 |
| 22 | 22 | ||
| 23 | template <class _Tp, class _Up> | 23 | template <class _Tp, class _Up> |
| 24 | struct _LIBCPP_NO_SPECIALIZATIONS reference_constructs_from_temporary | 24 | struct _LIBCPP_NO_SPECIALIZATIONS reference_constructs_from_temporary |
| ... | @@ -30,14 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_constructs_from_tempo | ... | @@ -30,14 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_constructs_from_tempo |
| 30 | 30 | ||
| 31 | #endif | 31 | #endif |
| 32 | 32 | ||
| 33 | #if __has_builtin(__reference_constructs_from_temporary) | ||
| 34 | template <class _Tp, class _Up> | 33 | template <class _Tp, class _Up> |
| 35 | inline const bool __reference_constructs_from_temporary_v = __reference_constructs_from_temporary(_Tp, _Up); | 34 | inline const bool __reference_constructs_from_temporary_v = __reference_constructs_from_temporary(_Tp, _Up); |
| 36 | #else | ||
| 37 | // TODO(LLVM 22): Remove this as all supported compilers should have __reference_constructs_from_temporary implemented. | ||
| 38 | template <class _Tp, class _Up> | ||
| 39 | inline const bool __reference_constructs_from_temporary_v = __reference_binds_to_temporary(_Tp, _Up); | ||
| 40 | #endif | ||
| 41 | 35 | ||
| 42 | _LIBCPP_END_NAMESPACE_STD | 36 | _LIBCPP_END_NAMESPACE_STD |
| 43 | 37 |
lib/libcxx/include/__type_traits/reference_converts_from_temporary.h+1-1| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 23 && __has_builtin(__reference_converts_from_temporary) | 21 | #if _LIBCPP_STD_VER >= 23 |
| 22 | 22 | ||
| 23 | template <class _Tp, class _Up> | 23 | template <class _Tp, class _Up> |
| 24 | struct _LIBCPP_NO_SPECIALIZATIONS reference_converts_from_temporary | 24 | struct _LIBCPP_NO_SPECIALIZATIONS reference_converts_from_temporary |
lib/libcxx/include/__utility/cmp.h+19-7| ... | @@ -26,10 +26,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,10 +26,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | #if _LIBCPP_STD_VER >= 20 | 27 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 28 | ||
| 29 | template <typename _Tp, typename _Ip> | ||
| 30 | concept __comparison_can_promote_to = | ||
| 31 | sizeof(_Tp) < sizeof(_Ip) || (sizeof(_Tp) == sizeof(_Ip) && __signed_integer<_Tp>); | ||
| 32 | |||
| 29 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> | 33 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 30 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { | 34 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { |
| 31 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) | 35 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) |
| 32 | return __t == __u; | 36 | return __t == __u; |
| 37 | else if constexpr (__comparison_can_promote_to<_Tp, int> && __comparison_can_promote_to<_Up, int>) | ||
| 38 | return static_cast<int>(__t) == static_cast<int>(__u); | ||
| 39 | else if constexpr (__comparison_can_promote_to<_Tp, long long> && __comparison_can_promote_to<_Up, long long>) | ||
| 40 | return static_cast<long long>(__t) == static_cast<long long>(__u); | ||
| 33 | else if constexpr (is_signed_v<_Tp>) | 41 | else if constexpr (is_signed_v<_Tp>) |
| 34 | return __t < 0 ? false : make_unsigned_t<_Tp>(__t) == __u; | 42 | return __t < 0 ? false : make_unsigned_t<_Tp>(__t) == __u; |
| 35 | else | 43 | else |
| ... | @@ -37,14 +45,18 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { | ... | @@ -37,14 +45,18 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { |
| 37 | } | 45 | } |
| 38 | 46 | ||
| 39 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> | 47 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_not_equal(_Tp __t, _Up __u) noexcept { | 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_not_equal(_Tp __t, _Up __u) noexcept { |
| 41 | return !std::cmp_equal(__t, __u); | 49 | return !std::cmp_equal(__t, __u); |
| 42 | } | 50 | } |
| 43 | 51 | ||
| 44 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> | 52 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { | 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { |
| 46 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) | 54 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) |
| 47 | return __t < __u; | 55 | return __t < __u; |
| 56 | else if constexpr (__comparison_can_promote_to<_Tp, int> && __comparison_can_promote_to<_Up, int>) | ||
| 57 | return static_cast<int>(__t) < static_cast<int>(__u); | ||
| 58 | else if constexpr (__comparison_can_promote_to<_Tp, long long> && __comparison_can_promote_to<_Up, long long>) | ||
| 59 | return static_cast<long long>(__t) < static_cast<long long>(__u); | ||
| 48 | else if constexpr (is_signed_v<_Tp>) | 60 | else if constexpr (is_signed_v<_Tp>) |
| 49 | return __t < 0 ? true : make_unsigned_t<_Tp>(__t) < __u; | 61 | return __t < 0 ? true : make_unsigned_t<_Tp>(__t) < __u; |
| 50 | else | 62 | else |
| ... | @@ -52,22 +64,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { | ... | @@ -52,22 +64,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { |
| 52 | } | 64 | } |
| 53 | 65 | ||
| 54 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> | 66 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater(_Tp __t, _Up __u) noexcept { | 67 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater(_Tp __t, _Up __u) noexcept { |
| 56 | return std::cmp_less(__u, __t); | 68 | return std::cmp_less(__u, __t); |
| 57 | } | 69 | } |
| 58 | 70 | ||
| 59 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> | 71 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less_equal(_Tp __t, _Up __u) noexcept { | 72 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less_equal(_Tp __t, _Up __u) noexcept { |
| 61 | return !std::cmp_greater(__t, __u); | 73 | return !std::cmp_greater(__t, __u); |
| 62 | } | 74 | } |
| 63 | 75 | ||
| 64 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> | 76 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 65 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater_equal(_Tp __t, _Up __u) noexcept { | 77 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater_equal(_Tp __t, _Up __u) noexcept { |
| 66 | return !std::cmp_less(__t, __u); | 78 | return !std::cmp_less(__t, __u); |
| 67 | } | 79 | } |
| 68 | 80 | ||
| 69 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> | 81 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr bool in_range(_Up __u) noexcept { | 82 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool in_range(_Up __u) noexcept { |
| 71 | return std::cmp_less_equal(__u, numeric_limits<_Tp>::max()) && | 83 | return std::cmp_less_equal(__u, numeric_limits<_Tp>::max()) && |
| 72 | std::cmp_greater_equal(__u, numeric_limits<_Tp>::min()); | 84 | std::cmp_greater_equal(__u, numeric_limits<_Tp>::min()); |
| 73 | } | 85 | } |
lib/libcxx/include/__utility/default_three_way_comparator.h created+70| ... | @@ -0,0 +1,70 @@ | ||
| 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_DEFAULT_THREE_WAY_COMPARATOR_H | ||
| 10 | #define _LIBCPP___UTILITY_DEFAULT_THREE_WAY_COMPARATOR_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/enable_if.h> | ||
| 14 | #include <__type_traits/is_arithmetic.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 | // This struct can be specialized to provide a three way comparator between _LHS and _RHS. | ||
| 23 | // The return value should be | ||
| 24 | // - less than zero if (lhs_val < rhs_val) | ||
| 25 | // - greater than zero if (rhs_val < lhs_val) | ||
| 26 | // - zero otherwise | ||
| 27 | template <class _LHS, class _RHS, class = void> | ||
| 28 | struct __default_three_way_comparator; | ||
| 29 | |||
| 30 | template <class _LHS, class _RHS> | ||
| 31 | struct __default_three_way_comparator<_LHS, | ||
| 32 | _RHS, | ||
| 33 | __enable_if_t<is_arithmetic<_LHS>::value && is_arithmetic<_RHS>::value> > { | ||
| 34 | _LIBCPP_HIDE_FROM_ABI static int operator()(_LHS __lhs, _RHS __rhs) { | ||
| 35 | if (__lhs < __rhs) | ||
| 36 | return -1; | ||
| 37 | if (__lhs > __rhs) | ||
| 38 | return 1; | ||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | }; | ||
| 42 | |||
| 43 | #if _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_lt_synthesizes_from_spaceship) | ||
| 44 | template <class _LHS, class _RHS> | ||
| 45 | struct __default_three_way_comparator< | ||
| 46 | _LHS, | ||
| 47 | _RHS, | ||
| 48 | __enable_if_t<!(is_arithmetic<_LHS>::value && is_arithmetic<_RHS>::value) && | ||
| 49 | __builtin_lt_synthesizes_from_spaceship(const _LHS&, const _RHS&)>> { | ||
| 50 | _LIBCPP_HIDE_FROM_ABI static int operator()(const _LHS& __lhs, const _RHS& __rhs) { | ||
| 51 | auto __res = __lhs <=> __rhs; | ||
| 52 | if (__res < 0) | ||
| 53 | return -1; | ||
| 54 | if (__res > 0) | ||
| 55 | return 1; | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | }; | ||
| 59 | #endif | ||
| 60 | |||
| 61 | template <class _LHS, class _RHS, bool = true> | ||
| 62 | struct __has_default_three_way_comparator : false_type {}; | ||
| 63 | |||
| 64 | template <class _LHS, class _RHS> | ||
| 65 | struct __has_default_three_way_comparator<_LHS, _RHS, sizeof(__default_three_way_comparator<_LHS, _RHS>) >= 0> | ||
| 66 | : true_type {}; | ||
| 67 | |||
| 68 | _LIBCPP_END_NAMESPACE_STD | ||
| 69 | |||
| 70 | #endif // _LIBCPP___UTILITY_DEFAULT_THREE_WAY_COMPARATOR_H | ||
lib/libcxx/include/__utility/in_place.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | #if _LIBCPP_STD_VER >= 17 | 23 | #if _LIBCPP_STD_VER >= 17 |
| 24 | 24 | ||
| 25 | struct _LIBCPP_EXPORTED_FROM_ABI in_place_t { | 25 | struct in_place_t { |
| 26 | explicit in_place_t() = default; | 26 | explicit in_place_t() = default; |
| 27 | }; | 27 | }; |
| 28 | inline constexpr in_place_t in_place{}; | 28 | inline constexpr in_place_t in_place{}; |
lib/libcxx/include/__utility/integer_sequence.h+56-41| ... | @@ -11,63 +11,52 @@ | ... | @@ -11,63 +11,52 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__tuple/tuple_element.h> | ||
| 15 | #include <__tuple/tuple_size.h> | ||
| 14 | #include <__type_traits/is_integral.h> | 16 | #include <__type_traits/is_integral.h> |
| 15 | 17 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 19 | # pragma GCC system_header |
| 18 | #endif | 20 | #endif |
| 19 | 21 | ||
| 22 | #ifndef _LIBCPP_CXX03_LANG | ||
| 23 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 25 | ||
| 22 | template <size_t...> | 26 | # if __has_builtin(__make_integer_seq) |
| 23 | struct __tuple_indices; | 27 | template <template <class _Tp, _Tp...> class _BaseType, class _Tp, _Tp _SequenceSize> |
| 28 | using __make_integer_sequence_impl _LIBCPP_NODEBUG = __make_integer_seq<_BaseType, _Tp, _SequenceSize>; | ||
| 29 | # else | ||
| 30 | template <template <class _Tp, _Tp...> class _BaseType, class _Tp, _Tp _SequenceSize> | ||
| 31 | using __make_integer_sequence_impl _LIBCPP_NODEBUG = _BaseType<_Tp, __integer_pack(_SequenceSize)...>; | ||
| 32 | # endif | ||
| 24 | 33 | ||
| 25 | template <class _IdxType, _IdxType... _Values> | 34 | template <class _Tp, _Tp... _Indices> |
| 26 | struct __integer_sequence { | 35 | struct __integer_sequence { |
| 27 | template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType> | 36 | using value_type = _Tp; |
| 28 | using __convert _LIBCPP_NODEBUG = _ToIndexSeq<_ToIndexType, _Values...>; | 37 | static_assert(is_integral<_Tp>::value, "std::integer_sequence can only be instantiated with an integral type"); |
| 29 | 38 | [[__nodiscard__]] static _LIBCPP_HIDE_FROM_ABI constexpr size_t size() noexcept { return sizeof...(_Indices); } | |
| 30 | template <size_t _Sp> | ||
| 31 | using __to_tuple_indices _LIBCPP_NODEBUG = __tuple_indices<(_Values + _Sp)...>; | ||
| 32 | }; | 39 | }; |
| 33 | 40 | ||
| 34 | #if __has_builtin(__make_integer_seq) | 41 | template <size_t... _Indices> |
| 35 | template <size_t _Ep, size_t _Sp> | 42 | using __index_sequence _LIBCPP_NODEBUG = __integer_sequence<size_t, _Indices...>; |
| 36 | using __make_indices_imp _LIBCPP_NODEBUG = | ||
| 37 | typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>; | ||
| 38 | #elif __has_builtin(__integer_pack) | ||
| 39 | template <size_t _Ep, size_t _Sp> | ||
| 40 | using __make_indices_imp _LIBCPP_NODEBUG = | ||
| 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" | ||
| 44 | #endif | ||
| 45 | 43 | ||
| 46 | #if _LIBCPP_STD_VER >= 14 | 44 | template <size_t _SequenceSize> |
| 45 | using __make_index_sequence _LIBCPP_NODEBUG = __make_integer_sequence_impl<__integer_sequence, size_t, _SequenceSize>; | ||
| 47 | 46 | ||
| 48 | template <class _Tp, _Tp... _Ip> | 47 | template <class... _Args> |
| 49 | struct integer_sequence { | 48 | using __index_sequence_for _LIBCPP_NODEBUG = __make_index_sequence<sizeof...(_Args)>; |
| 50 | typedef _Tp value_type; | 49 | |
| 51 | static_assert(is_integral<_Tp>::value, "std::integer_sequence can only be instantiated with an integral type"); | 50 | # if _LIBCPP_STD_VER >= 14 |
| 52 | static _LIBCPP_HIDE_FROM_ABI constexpr size_t size() noexcept { return sizeof...(_Ip); } | 51 | |
| 53 | }; | 52 | template <class _Tp, _Tp... _Indices> |
| 53 | struct integer_sequence : __integer_sequence<_Tp, _Indices...> {}; | ||
| 54 | 54 | ||
| 55 | template <size_t... _Ip> | 55 | template <size_t... _Ip> |
| 56 | using index_sequence = integer_sequence<size_t, _Ip...>; | 56 | using index_sequence = integer_sequence<size_t, _Ip...>; |
| 57 | 57 | ||
| 58 | # if __has_builtin(__make_integer_seq) | ||
| 59 | |||
| 60 | template <class _Tp, _Tp _Ep> | 58 | template <class _Tp, _Tp _Ep> |
| 61 | using make_integer_sequence _LIBCPP_NODEBUG = __make_integer_seq<integer_sequence, _Tp, _Ep>; | 59 | using make_integer_sequence _LIBCPP_NODEBUG = __make_integer_sequence_impl<integer_sequence, _Tp, _Ep>; |
| 62 | |||
| 63 | # elif __has_builtin(__integer_pack) | ||
| 64 | |||
| 65 | template <class _Tp, _Tp _SequenceSize> | ||
| 66 | using make_integer_sequence _LIBCPP_NODEBUG = integer_sequence<_Tp, __integer_pack(_SequenceSize)...>; | ||
| 67 | |||
| 68 | # else | ||
| 69 | # error "No known way to get an integer pack from the compiler" | ||
| 70 | # endif | ||
| 71 | 60 | ||
| 72 | template <size_t _Np> | 61 | template <size_t _Np> |
| 73 | using make_index_sequence = make_integer_sequence<size_t, _Np>; | 62 | using make_index_sequence = make_integer_sequence<size_t, _Np>; |
| ... | @@ -75,16 +64,42 @@ using make_index_sequence = make_integer_sequence<size_t, _Np>; | ... | @@ -75,16 +64,42 @@ using make_index_sequence = make_integer_sequence<size_t, _Np>; |
| 75 | template <class... _Tp> | 64 | template <class... _Tp> |
| 76 | using index_sequence_for = make_index_sequence<sizeof...(_Tp)>; | 65 | using index_sequence_for = make_index_sequence<sizeof...(_Tp)>; |
| 77 | 66 | ||
| 78 | # if _LIBCPP_STD_VER >= 20 | 67 | # if _LIBCPP_STD_VER >= 20 |
| 79 | // Executes __func for every element in an index_sequence. | 68 | // Executes __func for every element in an index_sequence. |
| 80 | template <size_t... _Index, class _Function> | 69 | template <size_t... _Index, class _Function> |
| 81 | _LIBCPP_HIDE_FROM_ABI constexpr void __for_each_index_sequence(index_sequence<_Index...>, _Function __func) { | 70 | _LIBCPP_HIDE_FROM_ABI constexpr void __for_each_index_sequence(index_sequence<_Index...>, _Function __func) { |
| 82 | (__func.template operator()<_Index>(), ...); | 71 | (__func.template operator()<_Index>(), ...); |
| 83 | } | 72 | } |
| 84 | # endif // _LIBCPP_STD_VER >= 20 | 73 | # endif // _LIBCPP_STD_VER >= 20 |
| 74 | |||
| 75 | # if _LIBCPP_STD_VER >= 26 | ||
| 76 | // [intseq.binding], structured binding support | ||
| 77 | template <class _Tp, _Tp... _Indices> | ||
| 78 | struct tuple_size<integer_sequence<_Tp, _Indices...>> : integral_constant<size_t, sizeof...(_Indices)> {}; | ||
| 85 | 79 | ||
| 86 | #endif // _LIBCPP_STD_VER >= 14 | 80 | template <size_t _Ip, class _Tp, _Tp... _Indices> |
| 81 | struct tuple_element<_Ip, integer_sequence<_Tp, _Indices...>> { | ||
| 82 | static_assert(_Ip < sizeof...(_Indices), "Index out of bounds in std::tuple_element<> (std::integer_sequence)"); | ||
| 83 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 84 | }; | ||
| 85 | |||
| 86 | template <size_t _Ip, class _Tp, _Tp... _Indices> | ||
| 87 | struct tuple_element<_Ip, const integer_sequence<_Tp, _Indices...>> { | ||
| 88 | static_assert(_Ip < sizeof...(_Indices), "Index out of bounds in std::tuple_element<> (const std::integer_sequence)"); | ||
| 89 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 90 | }; | ||
| 91 | |||
| 92 | template <size_t _Ip, class _Tp, _Tp... _Indices> | ||
| 93 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp get(integer_sequence<_Tp, _Indices...>) noexcept { | ||
| 94 | static_assert(_Ip < sizeof...(_Indices), "Index out of bounds in std::get<> (std::integer_sequence)"); | ||
| 95 | return _Indices...[_Ip]; | ||
| 96 | } | ||
| 97 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 98 | |||
| 99 | # endif // _LIBCPP_STD_VER >= 14 | ||
| 87 | 100 | ||
| 88 | _LIBCPP_END_NAMESPACE_STD | 101 | _LIBCPP_END_NAMESPACE_STD |
| 89 | 102 | ||
| 103 | #endif // _LIBCPP_CXX03_LANG | ||
| 104 | |||
| 90 | #endif // _LIBCPP___UTILITY_INTEGER_SEQUENCE_H | 105 | #endif // _LIBCPP___UTILITY_INTEGER_SEQUENCE_H |
lib/libcxx/include/__utility/lazy_synth_three_way_comparator.h created+120| ... | @@ -0,0 +1,120 @@ | ||
| 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_LAZY_SYNTH_THREE_WAY_COMPARATOR_H | ||
| 10 | #define _LIBCPP___UTILITY_LAZY_SYNTH_THREE_WAY_COMPARATOR_H | ||
| 11 | |||
| 12 | #include <__assert> | ||
| 13 | #include <__config> | ||
| 14 | #include <__type_traits/conjunction.h> | ||
| 15 | #include <__type_traits/desugars_to.h> | ||
| 16 | #include <__type_traits/enable_if.h> | ||
| 17 | #include <__utility/default_three_way_comparator.h> | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | #endif | ||
| 22 | |||
| 23 | // This file implements a __lazy_synth_three_way_comparator, which tries to build an efficient three way comparison from | ||
| 24 | // a binary comparator. That is done in multiple steps: | ||
| 25 | // 1) Check whether the comparator desugars to a less-than operator | ||
| 26 | // If that is the case, check whether there exists a specialization of `__default_three_way_comparator`, which | ||
| 27 | // can be specialized to implement a three way comparator for the specific types. | ||
| 28 | // 2) Fall back to doing a lazy less than/greater than comparison | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | template <class _Comparator, class _LHS, class _RHS> | ||
| 33 | struct __lazy_compare_result { | ||
| 34 | const _Comparator& __comp_; | ||
| 35 | const _LHS& __lhs_; | ||
| 36 | const _RHS& __rhs_; | ||
| 37 | |||
| 38 | _LIBCPP_HIDE_FROM_ABI | ||
| 39 | __lazy_compare_result(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp, | ||
| 40 | _LIBCPP_CTOR_LIFETIMEBOUND const _LHS& __lhs, | ||
| 41 | _LIBCPP_CTOR_LIFETIMEBOUND const _RHS& __rhs) | ||
| 42 | : __comp_(__comp), __lhs_(__lhs), __rhs_(__rhs) {} | ||
| 43 | |||
| 44 | _LIBCPP_HIDE_FROM_ABI bool __less() const { | ||
| 45 | bool __result = __comp_(__lhs_, __rhs_); | ||
| 46 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__result ? !static_cast<bool>(__comp_(__rhs_, __lhs_)) : true, | ||
| 47 | "Comparator does not induce a strict weak ordering"); | ||
| 48 | return __result; | ||
| 49 | } | ||
| 50 | |||
| 51 | _LIBCPP_HIDE_FROM_ABI bool __greater() const { | ||
| 52 | bool __result = __comp_(__rhs_, __lhs_); | ||
| 53 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__result ? !static_cast<bool>(__comp_(__lhs_, __rhs_)) : true, | ||
| 54 | "Comparator does not induce a strict weak ordering"); | ||
| 55 | return __result; | ||
| 56 | } | ||
| 57 | }; | ||
| 58 | |||
| 59 | // This class provides three way comparison between _LHS and _RHS as efficiently as possible. This can be specialized if | ||
| 60 | // a comparator only compares part of the object, potentially allowing an efficient three way comparison between the | ||
| 61 | // subobjects. The specialization should use the __lazy_synth_three_way_comparator for the subobjects to achieve this. | ||
| 62 | template <class _Comparator, class _LHS, class _RHS, class = void> | ||
| 63 | struct __lazy_synth_three_way_comparator { | ||
| 64 | const _Comparator& __comp_; | ||
| 65 | |||
| 66 | _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp) | ||
| 67 | : __comp_(__comp) {} | ||
| 68 | |||
| 69 | _LIBCPP_HIDE_FROM_ABI __lazy_compare_result<_Comparator, _LHS, _RHS> | ||
| 70 | operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) const { | ||
| 71 | return __lazy_compare_result<_Comparator, _LHS, _RHS>(__comp_, __lhs, __rhs); | ||
| 72 | } | ||
| 73 | }; | ||
| 74 | |||
| 75 | struct __eager_compare_result { | ||
| 76 | int __res_; | ||
| 77 | |||
| 78 | _LIBCPP_HIDE_FROM_ABI explicit __eager_compare_result(int __res) : __res_(__res) {} | ||
| 79 | |||
| 80 | _LIBCPP_HIDE_FROM_ABI bool __less() const { return __res_ < 0; } | ||
| 81 | _LIBCPP_HIDE_FROM_ABI bool __greater() const { return __res_ > 0; } | ||
| 82 | }; | ||
| 83 | |||
| 84 | template <class _Comparator, class _LHS, class _RHS> | ||
| 85 | struct __lazy_synth_three_way_comparator<_Comparator, | ||
| 86 | _LHS, | ||
| 87 | _RHS, | ||
| 88 | __enable_if_t<_And<__desugars_to<__less_tag, _Comparator, _LHS, _RHS>, | ||
| 89 | __has_default_three_way_comparator<_LHS, _RHS> >::value> > { | ||
| 90 | // This lifetimebound annotation is technically incorrect, but other specializations actually capture the lifetime of | ||
| 91 | // the comparator. | ||
| 92 | _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {} | ||
| 93 | |||
| 94 | // Same comment as above. | ||
| 95 | _LIBCPP_HIDE_FROM_ABI static __eager_compare_result | ||
| 96 | operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) { | ||
| 97 | return __eager_compare_result(__default_three_way_comparator<_LHS, _RHS>()(__lhs, __rhs)); | ||
| 98 | } | ||
| 99 | }; | ||
| 100 | |||
| 101 | template <class _Comparator, class _LHS, class _RHS> | ||
| 102 | struct __lazy_synth_three_way_comparator<_Comparator, | ||
| 103 | _LHS, | ||
| 104 | _RHS, | ||
| 105 | __enable_if_t<_And<__desugars_to<__greater_tag, _Comparator, _LHS, _RHS>, | ||
| 106 | __has_default_three_way_comparator<_LHS, _RHS> >::value> > { | ||
| 107 | // This lifetimebound annotation is technically incorrect, but other specializations actually capture the lifetime of | ||
| 108 | // the comparator. | ||
| 109 | _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {} | ||
| 110 | |||
| 111 | // Same comment as above. | ||
| 112 | _LIBCPP_HIDE_FROM_ABI static __eager_compare_result | ||
| 113 | operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) { | ||
| 114 | return __eager_compare_result(-__default_three_way_comparator<_LHS, _RHS>()(__lhs, __rhs)); | ||
| 115 | } | ||
| 116 | }; | ||
| 117 | |||
| 118 | _LIBCPP_END_NAMESPACE_STD | ||
| 119 | |||
| 120 | #endif // _LIBCPP___UTILITY_LAZY_SYNTH_THREE_WAY_COMPARATOR_H | ||
lib/libcxx/include/__utility/pair.h+22-25| ... | @@ -18,7 +18,6 @@ | ... | @@ -18,7 +18,6 @@ |
| 18 | #include <__fwd/array.h> | 18 | #include <__fwd/array.h> |
| 19 | #include <__fwd/pair.h> | 19 | #include <__fwd/pair.h> |
| 20 | #include <__fwd/tuple.h> | 20 | #include <__fwd/tuple.h> |
| 21 | #include <__tuple/tuple_indices.h> | ||
| 22 | #include <__tuple/tuple_like_no_subrange.h> | 21 | #include <__tuple/tuple_like_no_subrange.h> |
| 23 | #include <__tuple/tuple_size.h> | 22 | #include <__tuple/tuple_size.h> |
| 24 | #include <__type_traits/common_reference.h> | 23 | #include <__type_traits/common_reference.h> |
| ... | @@ -32,14 +31,13 @@ | ... | @@ -32,14 +31,13 @@ |
| 32 | #include <__type_traits/is_implicitly_default_constructible.h> | 31 | #include <__type_traits/is_implicitly_default_constructible.h> |
| 33 | #include <__type_traits/is_nothrow_assignable.h> | 32 | #include <__type_traits/is_nothrow_assignable.h> |
| 34 | #include <__type_traits/is_nothrow_constructible.h> | 33 | #include <__type_traits/is_nothrow_constructible.h> |
| 35 | #include <__type_traits/is_replaceable.h> | ||
| 36 | #include <__type_traits/is_same.h> | ||
| 37 | #include <__type_traits/is_swappable.h> | 34 | #include <__type_traits/is_swappable.h> |
| 38 | #include <__type_traits/is_trivially_relocatable.h> | 35 | #include <__type_traits/is_trivially_relocatable.h> |
| 39 | #include <__type_traits/nat.h> | 36 | #include <__type_traits/nat.h> |
| 40 | #include <__type_traits/unwrap_ref.h> | 37 | #include <__type_traits/unwrap_ref.h> |
| 41 | #include <__utility/declval.h> | 38 | #include <__utility/declval.h> |
| 42 | #include <__utility/forward.h> | 39 | #include <__utility/forward.h> |
| 40 | #include <__utility/integer_sequence.h> | ||
| 43 | #include <__utility/move.h> | 41 | #include <__utility/move.h> |
| 44 | #include <__utility/piecewise_construct.h> | 42 | #include <__utility/piecewise_construct.h> |
| 45 | 43 | ||
| ... | @@ -102,7 +100,6 @@ struct pair | ... | @@ -102,7 +100,6 @@ struct pair |
| 102 | __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value, | 100 | __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value, |
| 103 | pair, | 101 | pair, |
| 104 | void>; | 102 | void>; |
| 105 | using __replaceable _LIBCPP_NODEBUG = __conditional_t<__is_replaceable_v<_T1> && __is_replaceable_v<_T2>, pair, void>; | ||
| 106 | 103 | ||
| 107 | _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default; | 104 | _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default; |
| 108 | _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default; | 105 | _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default; |
| ... | @@ -222,11 +219,7 @@ struct pair | ... | @@ -222,11 +219,7 @@ struct pair |
| 222 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 219 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 223 | pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) noexcept( | 220 | pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) noexcept( |
| 224 | is_nothrow_constructible<first_type, _Args1...>::value && is_nothrow_constructible<second_type, _Args2...>::value) | 221 | is_nothrow_constructible<first_type, _Args1...>::value && is_nothrow_constructible<second_type, _Args2...>::value) |
| 225 | : pair(__pc, | 222 | : pair(__pc, __first_args, __second_args, __index_sequence_for<_Args1...>(), __index_sequence_for<_Args2...>()) {} |
| 226 | __first_args, | ||
| 227 | __second_args, | ||
| 228 | typename __make_tuple_indices<sizeof...(_Args1)>::type(), | ||
| 229 | typename __make_tuple_indices<sizeof...(_Args2) >::type()) {} | ||
| 230 | 223 | ||
| 231 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& | 224 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& |
| 232 | operator=(__conditional_t<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value, | 225 | operator=(__conditional_t<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value, |
| ... | @@ -440,8 +433,8 @@ private: | ... | @@ -440,8 +433,8 @@ private: |
| 440 | pair(piecewise_construct_t, | 433 | pair(piecewise_construct_t, |
| 441 | tuple<_Args1...>& __first_args, | 434 | tuple<_Args1...>& __first_args, |
| 442 | tuple<_Args2...>& __second_args, | 435 | tuple<_Args2...>& __second_args, |
| 443 | __tuple_indices<_I1...>, | 436 | __index_sequence<_I1...>, |
| 444 | __tuple_indices<_I2...>) | 437 | __index_sequence<_I2...>) |
| 445 | : first(std::forward<_Args1>(std::get<_I1>(__first_args))...), | 438 | : first(std::forward<_Args1>(std::get<_I1>(__first_args))...), |
| 446 | second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {} | 439 | second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {} |
| 447 | #endif | 440 | #endif |
| ... | @@ -546,8 +539,8 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x | ... | @@ -546,8 +539,8 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x |
| 546 | #endif | 539 | #endif |
| 547 | 540 | ||
| 548 | template <class _T1, class _T2> | 541 | template <class _T1, class _T2> |
| 549 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> > | 542 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 550 | make_pair(_T1&& __t1, _T2&& __t2) { | 543 | pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> > make_pair(_T1&& __t1, _T2&& __t2) { |
| 551 | return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2)); | 544 | return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2)); |
| 552 | } | 545 | } |
| 553 | 546 | ||
| ... | @@ -619,67 +612,71 @@ struct __get_pair<1> { | ... | @@ -619,67 +612,71 @@ struct __get_pair<1> { |
| 619 | }; | 612 | }; |
| 620 | 613 | ||
| 621 | template <size_t _Ip, class _T1, class _T2> | 614 | template <size_t _Ip, class _T1, class _T2> |
| 622 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type& | 615 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 616 | typename tuple_element<_Ip, pair<_T1, _T2> >::type& | ||
| 623 | get(pair<_T1, _T2>& __p) _NOEXCEPT { | 617 | get(pair<_T1, _T2>& __p) _NOEXCEPT { |
| 624 | return __get_pair<_Ip>::get(__p); | 618 | return __get_pair<_Ip>::get(__p); |
| 625 | } | 619 | } |
| 626 | 620 | ||
| 627 | template <size_t _Ip, class _T1, class _T2> | 621 | template <size_t _Ip, class _T1, class _T2> |
| 628 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& | 622 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 623 | _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& | ||
| 629 | get(const pair<_T1, _T2>& __p) _NOEXCEPT { | 624 | get(const pair<_T1, _T2>& __p) _NOEXCEPT { |
| 630 | return __get_pair<_Ip>::get(__p); | 625 | return __get_pair<_Ip>::get(__p); |
| 631 | } | 626 | } |
| 632 | 627 | ||
| 633 | template <size_t _Ip, class _T1, class _T2> | 628 | template <size_t _Ip, class _T1, class _T2> |
| 634 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | 629 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 630 | typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | ||
| 635 | get(pair<_T1, _T2>&& __p) _NOEXCEPT { | 631 | get(pair<_T1, _T2>&& __p) _NOEXCEPT { |
| 636 | return __get_pair<_Ip>::get(std::move(__p)); | 632 | return __get_pair<_Ip>::get(std::move(__p)); |
| 637 | } | 633 | } |
| 638 | 634 | ||
| 639 | template <size_t _Ip, class _T1, class _T2> | 635 | template <size_t _Ip, class _T1, class _T2> |
| 640 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | 636 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 637 | _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& | ||
| 641 | get(const pair<_T1, _T2>&& __p) _NOEXCEPT { | 638 | get(const pair<_T1, _T2>&& __p) _NOEXCEPT { |
| 642 | return __get_pair<_Ip>::get(std::move(__p)); | 639 | return __get_pair<_Ip>::get(std::move(__p)); |
| 643 | } | 640 | } |
| 644 | 641 | ||
| 645 | #if _LIBCPP_STD_VER >= 14 | 642 | #if _LIBCPP_STD_VER >= 14 |
| 646 | template <class _T1, class _T2> | 643 | template <class _T1, class _T2> |
| 647 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT { | 644 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT { |
| 648 | return __p.first; | 645 | return __p.first; |
| 649 | } | 646 | } |
| 650 | 647 | ||
| 651 | template <class _T1, class _T2> | 648 | template <class _T1, class _T2> |
| 652 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT { | 649 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT { |
| 653 | return __p.first; | 650 | return __p.first; |
| 654 | } | 651 | } |
| 655 | 652 | ||
| 656 | template <class _T1, class _T2> | 653 | template <class _T1, class _T2> |
| 657 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { | 654 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { |
| 658 | return std::forward<_T1&&>(__p.first); | 655 | return std::forward<_T1&&>(__p.first); |
| 659 | } | 656 | } |
| 660 | 657 | ||
| 661 | template <class _T1, class _T2> | 658 | template <class _T1, class _T2> |
| 662 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT { | 659 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT { |
| 663 | return std::forward<_T1 const&&>(__p.first); | 660 | return std::forward<_T1 const&&>(__p.first); |
| 664 | } | 661 | } |
| 665 | 662 | ||
| 666 | template <class _T2, class _T1> | 663 | template <class _T2, class _T1> |
| 667 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT { | 664 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT { |
| 668 | return __p.second; | 665 | return __p.second; |
| 669 | } | 666 | } |
| 670 | 667 | ||
| 671 | template <class _T2, class _T1> | 668 | template <class _T2, class _T1> |
| 672 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT { | 669 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT { |
| 673 | return __p.second; | 670 | return __p.second; |
| 674 | } | 671 | } |
| 675 | 672 | ||
| 676 | template <class _T2, class _T1> | 673 | template <class _T2, class _T1> |
| 677 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { | 674 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { |
| 678 | return std::forward<_T2&&>(__p.second); | 675 | return std::forward<_T2&&>(__p.second); |
| 679 | } | 676 | } |
| 680 | 677 | ||
| 681 | template <class _T2, class _T1> | 678 | template <class _T2, class _T1> |
| 682 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT { | 679 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT { |
| 683 | return std::forward<_T2 const&&>(__p.second); | 680 | return std::forward<_T2 const&&>(__p.second); |
| 684 | } | 681 | } |
| 685 | 682 |
lib/libcxx/include/__utility/scope_guard.h+2| ... | @@ -43,6 +43,8 @@ public: | ... | @@ -43,6 +43,8 @@ public: |
| 43 | #endif | 43 | #endif |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__scope_guard); | ||
| 47 | |||
| 46 | template <class _Func> | 48 | template <class _Func> |
| 47 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __scope_guard<_Func> __make_scope_guard(_Func __func) { | 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __scope_guard<_Func> __make_scope_guard(_Func __func) { |
| 48 | return __scope_guard<_Func>(std::move(__func)); | 50 | return __scope_guard<_Func>(std::move(__func)); |
lib/libcxx/include/__utility/try_key_extraction.h created+114| ... | @@ -0,0 +1,114 @@ | ||
| 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_TRY_EXTRACT_KEY_H | ||
| 10 | #define _LIBCPP___UTILITY_TRY_EXTRACT_KEY_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/pair.h> | ||
| 14 | #include <__fwd/tuple.h> | ||
| 15 | #include <__type_traits/enable_if.h> | ||
| 16 | #include <__type_traits/is_same.h> | ||
| 17 | #include <__type_traits/remove_const.h> | ||
| 18 | #include <__type_traits/remove_const_ref.h> | ||
| 19 | #include <__utility/declval.h> | ||
| 20 | #include <__utility/forward.h> | ||
| 21 | #include <__utility/piecewise_construct.h> | ||
| 22 | #include <__utility/priority_tag.h> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 29 | |||
| 30 | template <class _KeyT, class _Ret, class _WithKey, class _WithoutKey, class... _Args> | ||
| 31 | _LIBCPP_HIDE_FROM_ABI _Ret | ||
| 32 | __try_key_extraction_impl(__priority_tag<0>, _WithKey, _WithoutKey __without_key, _Args&&... __args) { | ||
| 33 | return __without_key(std::forward<_Args>(__args)...); | ||
| 34 | } | ||
| 35 | |||
| 36 | template <class _KeyT, | ||
| 37 | class _Ret, | ||
| 38 | class _WithKey, | ||
| 39 | class _WithoutKey, | ||
| 40 | class _Arg, | ||
| 41 | __enable_if_t<is_same<_KeyT, __remove_const_ref_t<_Arg> >::value, int> = 0> | ||
| 42 | _LIBCPP_HIDE_FROM_ABI _Ret | ||
| 43 | __try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg&& __arg) { | ||
| 44 | return __with_key(__arg, std::forward<_Arg>(__arg)); | ||
| 45 | } | ||
| 46 | |||
| 47 | template <class _KeyT, | ||
| 48 | class _Ret, | ||
| 49 | class _WithKey, | ||
| 50 | class _WithoutKey, | ||
| 51 | class _Arg, | ||
| 52 | __enable_if_t<__is_pair_v<__remove_const_ref_t<_Arg> > && | ||
| 53 | is_same<__remove_const_t<typename __remove_const_ref_t<_Arg>::first_type>, _KeyT>::value, | ||
| 54 | int> = 0> | ||
| 55 | _LIBCPP_HIDE_FROM_ABI _Ret | ||
| 56 | __try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg&& __arg) { | ||
| 57 | return __with_key(__arg.first, std::forward<_Arg>(__arg)); | ||
| 58 | } | ||
| 59 | |||
| 60 | template <class _KeyT, | ||
| 61 | class _Ret, | ||
| 62 | class _WithKey, | ||
| 63 | class _WithoutKey, | ||
| 64 | class _Arg1, | ||
| 65 | class _Arg2, | ||
| 66 | __enable_if_t<is_same<_KeyT, __remove_const_ref_t<_Arg1> >::value, int> = 0> | ||
| 67 | _LIBCPP_HIDE_FROM_ABI _Ret | ||
| 68 | __try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg1&& __arg1, _Arg2&& __arg2) { | ||
| 69 | return __with_key(__arg1, std::forward<_Arg1>(__arg1), std::forward<_Arg2>(__arg2)); | ||
| 70 | } | ||
| 71 | |||
| 72 | #ifndef _LIBCPP_CXX03_LANG | ||
| 73 | template <class _KeyT, | ||
| 74 | class _Ret, | ||
| 75 | class _WithKey, | ||
| 76 | class _WithoutKey, | ||
| 77 | class _PiecewiseConstruct, | ||
| 78 | class _Tuple1, | ||
| 79 | class _Tuple2, | ||
| 80 | __enable_if_t<is_same<__remove_const_ref_t<_PiecewiseConstruct>, piecewise_construct_t>::value && | ||
| 81 | __is_tuple_v<_Tuple1> && tuple_size<_Tuple1>::value == 1 && | ||
| 82 | is_same<__remove_const_ref_t<typename tuple_element<0, _Tuple1>::type>, _KeyT>::value, | ||
| 83 | int> = 0> | ||
| 84 | _LIBCPP_HIDE_FROM_ABI _Ret __try_key_extraction_impl( | ||
| 85 | __priority_tag<1>, | ||
| 86 | _WithKey __with_key, | ||
| 87 | _WithoutKey, | ||
| 88 | _PiecewiseConstruct&& __pc, | ||
| 89 | _Tuple1&& __tuple1, | ||
| 90 | _Tuple2&& __tuple2) { | ||
| 91 | return __with_key( | ||
| 92 | std::get<0>(__tuple1), | ||
| 93 | std::forward<_PiecewiseConstruct>(__pc), | ||
| 94 | std::forward<_Tuple1>(__tuple1), | ||
| 95 | std::forward<_Tuple2>(__tuple2)); | ||
| 96 | } | ||
| 97 | #endif // _LIBCPP_CXX03_LANG | ||
| 98 | |||
| 99 | // This function tries extracting the given _KeyT from _Args... | ||
| 100 | // If it succeeds to extract the key, it calls the `__with_key` function with the extracted key and all of the | ||
| 101 | // arguments. Otherwise it calls the `__without_key` function with all of the arguments. | ||
| 102 | // | ||
| 103 | // Both `__with_key` and `__without_key` must take all arguments by reference. | ||
| 104 | template <class _KeyT, class _WithKey, class _WithoutKey, class... _Args> | ||
| 105 | _LIBCPP_HIDE_FROM_ABI decltype(std::declval<_WithoutKey>()(std::declval<_Args>()...)) | ||
| 106 | __try_key_extraction(_WithKey __with_key, _WithoutKey __without_key, _Args&&... __args) { | ||
| 107 | using _Ret = decltype(__without_key(std::forward<_Args>(__args)...)); | ||
| 108 | return std::__try_key_extraction_impl<_KeyT, _Ret>( | ||
| 109 | __priority_tag<1>(), __with_key, __without_key, std::forward<_Args>(__args)...); | ||
| 110 | } | ||
| 111 | |||
| 112 | _LIBCPP_END_NAMESPACE_STD | ||
| 113 | |||
| 114 | #endif // _LIBCPP___UTILITY_TRY_EXTRACT_KEY_H | ||
lib/libcxx/include/__vector/vector.h+187-160| ... | @@ -12,18 +12,17 @@ | ... | @@ -12,18 +12,17 @@ |
| 12 | #include <__algorithm/copy.h> | 12 | #include <__algorithm/copy.h> |
| 13 | #include <__algorithm/copy_n.h> | 13 | #include <__algorithm/copy_n.h> |
| 14 | #include <__algorithm/fill_n.h> | 14 | #include <__algorithm/fill_n.h> |
| 15 | #include <__algorithm/iterator_operations.h> | ||
| 15 | #include <__algorithm/max.h> | 16 | #include <__algorithm/max.h> |
| 16 | #include <__algorithm/min.h> | 17 | #include <__algorithm/min.h> |
| 17 | #include <__algorithm/move.h> | 18 | #include <__algorithm/move.h> |
| 18 | #include <__algorithm/move_backward.h> | 19 | #include <__algorithm/move_backward.h> |
| 19 | #include <__algorithm/ranges_copy_n.h> | ||
| 20 | #include <__algorithm/rotate.h> | 20 | #include <__algorithm/rotate.h> |
| 21 | #include <__assert> | 21 | #include <__assert> |
| 22 | #include <__config> | 22 | #include <__config> |
| 23 | #include <__debug_utils/sanitizers.h> | 23 | #include <__debug_utils/sanitizers.h> |
| 24 | #include <__format/enable_insertable.h> | 24 | #include <__format/enable_insertable.h> |
| 25 | #include <__fwd/vector.h> | 25 | #include <__fwd/vector.h> |
| 26 | #include <__iterator/advance.h> | ||
| 27 | #include <__iterator/bounded_iter.h> | 26 | #include <__iterator/bounded_iter.h> |
| 28 | #include <__iterator/concepts.h> | 27 | #include <__iterator/concepts.h> |
| 29 | #include <__iterator/distance.h> | 28 | #include <__iterator/distance.h> |
| ... | @@ -43,6 +42,7 @@ | ... | @@ -43,6 +42,7 @@ |
| 43 | #include <__memory/temp_value.h> | 42 | #include <__memory/temp_value.h> |
| 44 | #include <__memory/uninitialized_algorithms.h> | 43 | #include <__memory/uninitialized_algorithms.h> |
| 45 | #include <__ranges/access.h> | 44 | #include <__ranges/access.h> |
| 45 | #include <__ranges/as_rvalue_view.h> | ||
| 46 | #include <__ranges/concepts.h> | 46 | #include <__ranges/concepts.h> |
| 47 | #include <__ranges/container_compatible_range.h> | 47 | #include <__ranges/container_compatible_range.h> |
| 48 | #include <__ranges/from_range.h> | 48 | #include <__ranges/from_range.h> |
| ... | @@ -55,7 +55,6 @@ | ... | @@ -55,7 +55,6 @@ |
| 55 | #include <__type_traits/is_nothrow_assignable.h> | 55 | #include <__type_traits/is_nothrow_assignable.h> |
| 56 | #include <__type_traits/is_nothrow_constructible.h> | 56 | #include <__type_traits/is_nothrow_constructible.h> |
| 57 | #include <__type_traits/is_pointer.h> | 57 | #include <__type_traits/is_pointer.h> |
| 58 | #include <__type_traits/is_replaceable.h> | ||
| 59 | #include <__type_traits/is_same.h> | 58 | #include <__type_traits/is_same.h> |
| 60 | #include <__type_traits/is_trivially_relocatable.h> | 59 | #include <__type_traits/is_trivially_relocatable.h> |
| 61 | #include <__type_traits/type_identity.h> | 60 | #include <__type_traits/type_identity.h> |
| ... | @@ -86,6 +85,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -86,6 +85,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 86 | 85 | ||
| 87 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> | 86 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> |
| 88 | class vector { | 87 | class vector { |
| 88 | template <class _Up, class _Alloc> | ||
| 89 | using __split_buffer _LIBCPP_NODEBUG = std::__split_buffer<_Up, _Alloc, __split_buffer_pointer_layout>; | ||
| 90 | |||
| 89 | public: | 91 | public: |
| 90 | // | 92 | // |
| 91 | // Types | 93 | // Types |
| ... | @@ -113,7 +115,7 @@ public: | ... | @@ -113,7 +115,7 @@ public: |
| 113 | using reverse_iterator = std::reverse_iterator<iterator>; | 115 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 114 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | 116 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| 115 | 117 | ||
| 116 | // A vector containers the following members which may be trivially relocatable: | 118 | // A vector contains the following members which may be trivially relocatable: |
| 117 | // - pointer: may be trivially relocatable, so it's checked | 119 | // - pointer: may be trivially relocatable, so it's checked |
| 118 | // - allocator_type: may be trivially relocatable, so it's checked | 120 | // - allocator_type: may be trivially relocatable, so it's checked |
| 119 | // vector doesn't contain any self-references, so it's trivially relocatable if its members are. | 121 | // vector doesn't contain any self-references, so it's trivially relocatable if its members are. |
| ... | @@ -121,10 +123,6 @@ public: | ... | @@ -121,10 +123,6 @@ public: |
| 121 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | 123 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 122 | vector, | 124 | vector, |
| 123 | void>; | 125 | void>; |
| 124 | using __replaceable _LIBCPP_NODEBUG = | ||
| 125 | __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value, | ||
| 126 | vector, | ||
| 127 | void>; | ||
| 128 | 126 | ||
| 129 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | 127 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 130 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | 128 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| ... | @@ -174,7 +172,7 @@ public: | ... | @@ -174,7 +172,7 @@ public: |
| 174 | __guard.__complete(); | 172 | __guard.__complete(); |
| 175 | } | 173 | } |
| 176 | 174 | ||
| 177 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | 175 | template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0> |
| 178 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | 176 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
| 179 | vector(size_type __n, const value_type& __x, const allocator_type& __a) | 177 | vector(size_type __n, const value_type& __x, const allocator_type& __a) |
| 180 | : __alloc_(__a) { | 178 | : __alloc_(__a) { |
| ... | @@ -317,7 +315,7 @@ public: | ... | @@ -317,7 +315,7 @@ public: |
| 317 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | 315 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, |
| 318 | int> = 0> | 316 | int> = 0> |
| 319 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last) { | 317 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last) { |
| 320 | __assign_with_size(__first, __last, std::distance(__first, __last)); | 318 | __assign_with_size<_ClassicAlgPolicy>(__first, __last, std::distance(__first, __last)); |
| 321 | } | 319 | } |
| 322 | 320 | ||
| 323 | #if _LIBCPP_STD_VER >= 23 | 321 | #if _LIBCPP_STD_VER >= 23 |
| ... | @@ -325,7 +323,7 @@ public: | ... | @@ -325,7 +323,7 @@ public: |
| 325 | _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) { | 323 | _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) { |
| 326 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | 324 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| 327 | auto __n = static_cast<size_type>(ranges::distance(__range)); | 325 | auto __n = static_cast<size_type>(ranges::distance(__range)); |
| 328 | __assign_with_size(ranges::begin(__range), ranges::end(__range), __n); | 326 | __assign_with_size<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), __n); |
| 329 | 327 | ||
| 330 | } else { | 328 | } else { |
| 331 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | 329 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| ... | @@ -341,59 +339,67 @@ public: | ... | @@ -341,59 +339,67 @@ public: |
| 341 | } | 339 | } |
| 342 | #endif | 340 | #endif |
| 343 | 341 | ||
| 344 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | 342 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 345 | return this->__alloc_; | 343 | return this->__alloc_; |
| 346 | } | 344 | } |
| 347 | 345 | ||
| 348 | // | 346 | // |
| 349 | // Iterators | 347 | // Iterators |
| 350 | // | 348 | // |
| 351 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { | 349 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { |
| 352 | return __make_iter(__add_alignment_assumption(this->__begin_)); | 350 | return __make_iter(__add_alignment_assumption(this->__begin_)); |
| 353 | } | 351 | } |
| 354 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { | 352 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { |
| 355 | return __make_iter(__add_alignment_assumption(this->__begin_)); | 353 | return __make_iter(__add_alignment_assumption(this->__begin_)); |
| 356 | } | 354 | } |
| 357 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { | 355 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { |
| 358 | return __make_iter(__add_alignment_assumption(this->__end_)); | 356 | return __make_iter(__add_alignment_assumption(this->__end_)); |
| 359 | } | 357 | } |
| 360 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { | 358 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { |
| 361 | return __make_iter(__add_alignment_assumption(this->__end_)); | 359 | return __make_iter(__add_alignment_assumption(this->__end_)); |
| 362 | } | 360 | } |
| 363 | 361 | ||
| 364 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { | 362 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { |
| 365 | return reverse_iterator(end()); | 363 | return reverse_iterator(end()); |
| 366 | } | 364 | } |
| 367 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { | 365 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator |
| 366 | rbegin() const _NOEXCEPT { | ||
| 368 | return const_reverse_iterator(end()); | 367 | return const_reverse_iterator(end()); |
| 369 | } | 368 | } |
| 370 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { | 369 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { |
| 371 | return reverse_iterator(begin()); | 370 | return reverse_iterator(begin()); |
| 372 | } | 371 | } |
| 373 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | 372 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { |
| 374 | return const_reverse_iterator(begin()); | 373 | return const_reverse_iterator(begin()); |
| 375 | } | 374 | } |
| 376 | 375 | ||
| 377 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | 376 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { |
| 378 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | 377 | return begin(); |
| 379 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { | 378 | } |
| 379 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { | ||
| 380 | return end(); | ||
| 381 | } | ||
| 382 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator | ||
| 383 | crbegin() const _NOEXCEPT { | ||
| 380 | return rbegin(); | 384 | return rbegin(); |
| 381 | } | 385 | } |
| 382 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 386 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { |
| 387 | return rend(); | ||
| 388 | } | ||
| 383 | 389 | ||
| 384 | // | 390 | // |
| 385 | // [vector.capacity], capacity | 391 | // [vector.capacity], capacity |
| 386 | // | 392 | // |
| 387 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { | 393 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { |
| 388 | return static_cast<size_type>(this->__end_ - this->__begin_); | 394 | return static_cast<size_type>(this->__end_ - this->__begin_); |
| 389 | } | 395 | } |
| 390 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { | 396 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { |
| 391 | return static_cast<size_type>(this->__cap_ - this->__begin_); | 397 | return static_cast<size_type>(this->__cap_ - this->__begin_); |
| 392 | } | 398 | } |
| 393 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | 399 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { |
| 394 | return this->__begin_ == this->__end_; | 400 | return this->__begin_ == this->__end_; |
| 395 | } | 401 | } |
| 396 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 402 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 397 | return std::min<size_type>(__alloc_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); | 403 | return std::min<size_type>(__alloc_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); |
| 398 | } | 404 | } |
| 399 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); | 405 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); |
| ... | @@ -402,38 +408,39 @@ public: | ... | @@ -402,38 +408,39 @@ public: |
| 402 | // | 408 | // |
| 403 | // element access | 409 | // element access |
| 404 | // | 410 | // |
| 405 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT { | 411 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT { |
| 406 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); | 412 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); |
| 407 | return this->__begin_[__n]; | 413 | return this->__begin_[__n]; |
| 408 | } | 414 | } |
| 409 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT { | 415 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference |
| 416 | operator[](size_type __n) const _NOEXCEPT { | ||
| 410 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); | 417 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); |
| 411 | return this->__begin_[__n]; | 418 | return this->__begin_[__n]; |
| 412 | } | 419 | } |
| 413 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) { | 420 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) { |
| 414 | if (__n >= size()) | 421 | if (__n >= size()) |
| 415 | this->__throw_out_of_range(); | 422 | this->__throw_out_of_range(); |
| 416 | return this->__begin_[__n]; | 423 | return this->__begin_[__n]; |
| 417 | } | 424 | } |
| 418 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const { | 425 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const { |
| 419 | if (__n >= size()) | 426 | if (__n >= size()) |
| 420 | this->__throw_out_of_range(); | 427 | this->__throw_out_of_range(); |
| 421 | return this->__begin_[__n]; | 428 | return this->__begin_[__n]; |
| 422 | } | 429 | } |
| 423 | 430 | ||
| 424 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT { | 431 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT { |
| 425 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); | 432 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); |
| 426 | return *this->__begin_; | 433 | return *this->__begin_; |
| 427 | } | 434 | } |
| 428 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { | 435 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { |
| 429 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); | 436 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); |
| 430 | return *this->__begin_; | 437 | return *this->__begin_; |
| 431 | } | 438 | } |
| 432 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { | 439 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { |
| 433 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); | 440 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); |
| 434 | return *(this->__end_ - 1); | 441 | return *(this->__end_ - 1); |
| 435 | } | 442 | } |
| 436 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { | 443 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { |
| 437 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); | 444 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); |
| 438 | return *(this->__end_ - 1); | 445 | return *(this->__end_ - 1); |
| 439 | } | 446 | } |
| ... | @@ -441,11 +448,11 @@ public: | ... | @@ -441,11 +448,11 @@ public: |
| 441 | // | 448 | // |
| 442 | // [vector.data], data access | 449 | // [vector.data], data access |
| 443 | // | 450 | // |
| 444 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT { | 451 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT { |
| 445 | return std::__to_address(this->__begin_); | 452 | return std::__to_address(this->__begin_); |
| 446 | } | 453 | } |
| 447 | 454 | ||
| 448 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT { | 455 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT { |
| 449 | return std::__to_address(this->__begin_); | 456 | return std::__to_address(this->__begin_); |
| 450 | } | 457 | } |
| 451 | 458 | ||
| ... | @@ -478,7 +485,21 @@ public: | ... | @@ -478,7 +485,21 @@ public: |
| 478 | #if _LIBCPP_STD_VER >= 23 | 485 | #if _LIBCPP_STD_VER >= 23 |
| 479 | template <_ContainerCompatibleRange<_Tp> _Range> | 486 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 480 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { | 487 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { |
| 481 | insert_range(end(), std::forward<_Range>(__range)); | 488 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| 489 | auto __len = ranges::distance(__range); | ||
| 490 | if (__len <= __cap_ - __end_) { | ||
| 491 | __construct_at_end(ranges::begin(__range), ranges::end(__range), __len); | ||
| 492 | } else { | ||
| 493 | __split_buffer<value_type, allocator_type> __buffer(__recommend(size() + __len), size(), __alloc_); | ||
| 494 | __buffer.__construct_at_end_with_size(ranges::begin(__range), __len); | ||
| 495 | __swap_out_circular_buffer(__buffer); | ||
| 496 | } | ||
| 497 | } else { | ||
| 498 | vector __buffer(__alloc_); | ||
| 499 | for (auto&& __val : __range) | ||
| 500 | __buffer.emplace_back(std::forward<decltype(__val)>(__val)); | ||
| 501 | append_range(ranges::as_rvalue_view(__buffer)); | ||
| 502 | } | ||
| 482 | } | 503 | } |
| 483 | #endif | 504 | #endif |
| 484 | 505 | ||
| ... | @@ -512,7 +533,7 @@ public: | ... | @@ -512,7 +533,7 @@ public: |
| 512 | int> = 0> | 533 | int> = 0> |
| 513 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | 534 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator |
| 514 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { | 535 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { |
| 515 | return __insert_with_size(__position, __first, __last, std::distance(__first, __last)); | 536 | return __insert_with_size<_ClassicAlgPolicy>(__position, __first, __last, std::distance(__first, __last)); |
| 516 | } | 537 | } |
| 517 | 538 | ||
| 518 | #if _LIBCPP_STD_VER >= 23 | 539 | #if _LIBCPP_STD_VER >= 23 |
| ... | @@ -520,7 +541,7 @@ public: | ... | @@ -520,7 +541,7 @@ public: |
| 520 | _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { | 541 | _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { |
| 521 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | 542 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| 522 | auto __n = static_cast<size_type>(ranges::distance(__range)); | 543 | auto __n = static_cast<size_type>(ranges::distance(__range)); |
| 523 | return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n); | 544 | return __insert_with_size<_RangeAlgPolicy>(__position, ranges::begin(__range), ranges::end(__range), __n); |
| 524 | 545 | ||
| 525 | } else { | 546 | } else { |
| 526 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); | 547 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); |
| ... | @@ -613,12 +634,13 @@ private: | ... | @@ -613,12 +634,13 @@ private: |
| 613 | // The `_Iterator` in `*_with_size` functions can be input-only only if called from `*_range` (since C++23). | 634 | // The `_Iterator` in `*_with_size` functions can be input-only only if called from `*_range` (since C++23). |
| 614 | // Otherwise, `_Iterator` is a forward iterator. | 635 | // Otherwise, `_Iterator` is a forward iterator. |
| 615 | 636 | ||
| 616 | template <class _Iterator, class _Sentinel> | 637 | template <class _AlgPolicy, class _Iterator, class _Sentinel> |
| 617 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 638 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 618 | __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n); | 639 | __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n); |
| 619 | 640 | ||
| 620 | template <class _Iterator, | 641 | template <class _AlgPolicy, |
| 621 | __enable_if_t<!is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0> | 642 | class _Iterator, |
| 643 | __enable_if_t<!is_same<__policy_value_type<_AlgPolicy, _Iterator>, value_type>::value, int> = 0> | ||
| 622 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 644 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 623 | __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) { | 645 | __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) { |
| 624 | for (pointer __end_position = __position + __n; __position != __end_position; ++__position, (void)++__first) { | 646 | for (pointer __end_position = __position + __n; __position != __end_position; ++__position, (void)++__first) { |
| ... | @@ -627,25 +649,19 @@ private: | ... | @@ -627,25 +649,19 @@ private: |
| 627 | } | 649 | } |
| 628 | } | 650 | } |
| 629 | 651 | ||
| 630 | template <class _Iterator, | 652 | template <class _AlgPolicy, |
| 631 | __enable_if_t<is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0> | 653 | class _Iterator, |
| 654 | __enable_if_t<is_same<__policy_value_type<_AlgPolicy, _Iterator>, value_type>::value, int> = 0> | ||
| 632 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 655 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 633 | __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) { | 656 | __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) { |
| 634 | #if _LIBCPP_STD_VER >= 23 | 657 | std::__copy_n<_AlgPolicy>(std::move(__first), __n, __position); |
| 635 | if constexpr (!forward_iterator<_Iterator>) { // Handles input-only sized ranges for insert_range | ||
| 636 | ranges::copy_n(std::move(__first), __n, __position); | ||
| 637 | } else | ||
| 638 | #endif | ||
| 639 | { | ||
| 640 | std::copy_n(__first, __n, __position); | ||
| 641 | } | ||
| 642 | } | 658 | } |
| 643 | 659 | ||
| 644 | template <class _InputIterator, class _Sentinel> | 660 | template <class _InputIterator, class _Sentinel> |
| 645 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | 661 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator |
| 646 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); | 662 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); |
| 647 | 663 | ||
| 648 | template <class _Iterator, class _Sentinel> | 664 | template <class _AlgPolicy, class _Iterator, class _Sentinel> |
| 649 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | 665 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator |
| 650 | __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n); | 666 | __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n); |
| 651 | 667 | ||
| ... | @@ -653,9 +669,6 @@ private: | ... | @@ -653,9 +669,6 @@ private: |
| 653 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 669 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 654 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); | 670 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); |
| 655 | 671 | ||
| 656 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); | ||
| 657 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); | ||
| 658 | |||
| 659 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { | 672 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { |
| 660 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | 673 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR |
| 661 | // Bound the iterator according to the capacity, rather than the size. | 674 | // Bound the iterator according to the capacity, rather than the size. |
| ... | @@ -689,9 +702,9 @@ private: | ... | @@ -689,9 +702,9 @@ private: |
| 689 | } | 702 | } |
| 690 | 703 | ||
| 691 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 704 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 692 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | 705 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v); |
| 693 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer | 706 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer |
| 694 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); | 707 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v, pointer __p); |
| 695 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 708 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 696 | __move_range(pointer __from_s, pointer __from_e, pointer __to); | 709 | __move_range(pointer __from_s, pointer __from_e, pointer __to); |
| 697 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type) | 710 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type) |
| ... | @@ -811,26 +824,44 @@ private: | ... | @@ -811,26 +824,44 @@ private: |
| 811 | __add_alignment_assumption(_Ptr __p) _NOEXCEPT { | 824 | __add_alignment_assumption(_Ptr __p) _NOEXCEPT { |
| 812 | return __p; | 825 | return __p; |
| 813 | } | 826 | } |
| 827 | |||
| 828 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_layouts(__split_buffer<_Tp, allocator_type>& __sb) { | ||
| 829 | auto __vector_begin = __begin_; | ||
| 830 | auto __vector_sentinel = __end_; | ||
| 831 | auto __vector_cap = __cap_; | ||
| 832 | |||
| 833 | auto __sb_begin = __sb.begin(); | ||
| 834 | auto __sb_sentinel = __sb.__raw_sentinel(); | ||
| 835 | auto __sb_cap = __sb.__raw_capacity(); | ||
| 836 | |||
| 837 | // TODO: replace with __set_valid_range and __set_capacity when vector supports it. | ||
| 838 | __begin_ = __sb_begin; | ||
| 839 | __end_ = __sb_sentinel; | ||
| 840 | __cap_ = __sb_cap; | ||
| 841 | |||
| 842 | __sb.__set_valid_range(__vector_begin, __vector_sentinel); | ||
| 843 | __sb.__set_capacity(__vector_cap); | ||
| 844 | } | ||
| 814 | }; | 845 | }; |
| 815 | 846 | ||
| 816 | #if _LIBCPP_STD_VER >= 17 | 847 | #if _LIBCPP_STD_VER >= 17 |
| 817 | template <class _InputIterator, | 848 | template <class _InputIterator, |
| 818 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, | 849 | class _Alloc = allocator<__iterator_value_type<_InputIterator>>, |
| 819 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 850 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 820 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 851 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 821 | vector(_InputIterator, _InputIterator) -> vector<__iter_value_type<_InputIterator>, _Alloc>; | 852 | vector(_InputIterator, _InputIterator) -> vector<__iterator_value_type<_InputIterator>, _Alloc>; |
| 822 | 853 | ||
| 823 | template <class _InputIterator, | 854 | template <class _InputIterator, |
| 824 | class _Alloc, | 855 | class _Alloc, |
| 825 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 856 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 826 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 857 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 827 | vector(_InputIterator, _InputIterator, _Alloc) -> vector<__iter_value_type<_InputIterator>, _Alloc>; | 858 | vector(_InputIterator, _InputIterator, _Alloc) -> vector<__iterator_value_type<_InputIterator>, _Alloc>; |
| 828 | #endif | 859 | #endif |
| 829 | 860 | ||
| 830 | #if _LIBCPP_STD_VER >= 23 | 861 | #if _LIBCPP_STD_VER >= 23 |
| 831 | template <ranges::input_range _Range, | 862 | template <ranges::input_range _Range, |
| 832 | class _Alloc = allocator<ranges::range_value_t<_Range>>, | 863 | class _Alloc = allocator<ranges::range_value_t<_Range>>, |
| 833 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 864 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 834 | vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>; | 865 | vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>; |
| 835 | #endif | 866 | #endif |
| 836 | 867 | ||
| ... | @@ -839,17 +870,16 @@ vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_ | ... | @@ -839,17 +870,16 @@ vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_ |
| 839 | // function has a strong exception guarantee. | 870 | // function has a strong exception guarantee. |
| 840 | template <class _Tp, class _Allocator> | 871 | template <class _Tp, class _Allocator> |
| 841 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 872 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 842 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) { | 873 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v) { |
| 843 | __annotate_delete(); | 874 | __annotate_delete(); |
| 844 | auto __new_begin = __v.__begin_ - (__end_ - __begin_); | 875 | auto __new_begin = __v.begin() - size(); |
| 845 | std::__uninitialized_allocator_relocate( | 876 | std::__uninitialized_allocator_relocate( |
| 846 | this->__alloc_, std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin)); | 877 | this->__alloc_, std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin)); |
| 847 | __v.__begin_ = __new_begin; | 878 | __v.__set_valid_range(__new_begin, __v.end()); |
| 848 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | 879 | __end_ = __begin_; // All the objects have been destroyed by relocating them. |
| 849 | std::swap(this->__begin_, __v.__begin_); | 880 | |
| 850 | std::swap(this->__end_, __v.__end_); | 881 | __swap_layouts(__v); |
| 851 | std::swap(this->__cap_, __v.__cap_); | 882 | __v.__set_data(__v.begin()); |
| 852 | __v.__first_ = __v.__begin_; | ||
| 853 | __annotate_new(size()); | 883 | __annotate_new(size()); |
| 854 | } | 884 | } |
| 855 | 885 | ||
| ... | @@ -859,27 +889,25 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a | ... | @@ -859,27 +889,25 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a |
| 859 | // function has a strong exception guarantee if __begin_ == __p || __end_ == __p. | 889 | // function has a strong exception guarantee if __begin_ == __p || __end_ == __p. |
| 860 | template <class _Tp, class _Allocator> | 890 | template <class _Tp, class _Allocator> |
| 861 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | 891 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer |
| 862 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) { | 892 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v, pointer __p) { |
| 863 | __annotate_delete(); | 893 | __annotate_delete(); |
| 864 | pointer __ret = __v.__begin_; | 894 | pointer __ret = __v.begin(); |
| 865 | 895 | ||
| 866 | // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_) | 896 | // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_) |
| 867 | // in case something in [__begin_, __p) throws. | 897 | // in case something in [__begin_, __p) throws. |
| 868 | std::__uninitialized_allocator_relocate( | 898 | std::__uninitialized_allocator_relocate( |
| 869 | this->__alloc_, std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_)); | 899 | this->__alloc_, std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.end())); |
| 870 | __v.__end_ += (__end_ - __p); | 900 | auto __relocated_so_far = __end_ - __p; |
| 901 | __v.__set_sentinel(__v.end() + __relocated_so_far); | ||
| 871 | __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them. | 902 | __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them. |
| 872 | auto __new_begin = __v.__begin_ - (__p - __begin_); | 903 | auto __new_begin = __v.begin() - (__p - __begin_); |
| 873 | 904 | ||
| 874 | std::__uninitialized_allocator_relocate( | 905 | std::__uninitialized_allocator_relocate( |
| 875 | this->__alloc_, std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin)); | 906 | this->__alloc_, std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin)); |
| 876 | __v.__begin_ = __new_begin; | 907 | __v.__set_valid_range(__new_begin, __v.end()); |
| 877 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | 908 | __end_ = __begin_; // All the objects have been destroyed by relocating them. |
| 878 | 909 | __swap_layouts(__v); | |
| 879 | std::swap(this->__begin_, __v.__begin_); | 910 | __v.__set_data(__v.begin()); |
| 880 | std::swap(this->__end_, __v.__end_); | ||
| 881 | std::swap(this->__cap_, __v.__cap_); | ||
| 882 | __v.__first_ = __v.__begin_; | ||
| 883 | __annotate_new(size()); | 911 | __annotate_new(size()); |
| 884 | return __ret; | 912 | return __ret; |
| 885 | } | 913 | } |
| ... | @@ -945,36 +973,6 @@ vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __ | ... | @@ -945,36 +973,6 @@ vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __ |
| 945 | __tx.__pos_ = std::__uninitialized_allocator_copy(this->__alloc_, std::move(__first), std::move(__last), __tx.__pos_); | 973 | __tx.__pos_ = std::__uninitialized_allocator_copy(this->__alloc_, std::move(__first), std::move(__last), __tx.__pos_); |
| 946 | } | 974 | } |
| 947 | 975 | ||
| 948 | // Default constructs __n objects starting at __end_ | ||
| 949 | // throws if construction throws | ||
| 950 | // Postcondition: size() == size() + __n | ||
| 951 | // Exception safety: strong. | ||
| 952 | template <class _Tp, class _Allocator> | ||
| 953 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n) { | ||
| 954 | if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n) | ||
| 955 | this->__construct_at_end(__n); | ||
| 956 | else { | ||
| 957 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_); | ||
| 958 | __v.__construct_at_end(__n); | ||
| 959 | __swap_out_circular_buffer(__v); | ||
| 960 | } | ||
| 961 | } | ||
| 962 | |||
| 963 | // Default constructs __n objects starting at __end_ | ||
| 964 | // throws if construction throws | ||
| 965 | // Postcondition: size() == size() + __n | ||
| 966 | // Exception safety: strong. | ||
| 967 | template <class _Tp, class _Allocator> | ||
| 968 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) { | ||
| 969 | if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n) | ||
| 970 | this->__construct_at_end(__n, __x); | ||
| 971 | else { | ||
| 972 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_); | ||
| 973 | __v.__construct_at_end(__n, __x); | ||
| 974 | __swap_out_circular_buffer(__v); | ||
| 975 | } | ||
| 976 | } | ||
| 977 | |||
| 978 | template <class _Tp, class _Allocator> | 976 | template <class _Tp, class _Allocator> |
| 979 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x) | 977 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x) |
| 980 | #if _LIBCPP_STD_VER >= 17 | 978 | #if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1051,20 +1049,14 @@ vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __l | ... | @@ -1051,20 +1049,14 @@ vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __l |
| 1051 | } | 1049 | } |
| 1052 | 1050 | ||
| 1053 | template <class _Tp, class _Allocator> | 1051 | template <class _Tp, class _Allocator> |
| 1054 | template <class _Iterator, class _Sentinel> | 1052 | template <class _AlgPolicy, class _Iterator, class _Sentinel> |
| 1055 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 1053 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 1056 | vector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n) { | 1054 | vector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n) { |
| 1057 | size_type __new_size = static_cast<size_type>(__n); | 1055 | size_type __new_size = static_cast<size_type>(__n); |
| 1058 | if (__new_size <= capacity()) { | 1056 | if (__new_size <= capacity()) { |
| 1059 | if (__new_size > size()) { | 1057 | if (__new_size > size()) { |
| 1060 | #if _LIBCPP_STD_VER >= 23 | 1058 | auto __mid = std::__copy_n<_AlgPolicy>(std::move(__first), size(), this->__begin_).first; |
| 1061 | auto __mid = ranges::copy_n(std::move(__first), size(), this->__begin_).in; | ||
| 1062 | __construct_at_end(std::move(__mid), std::move(__last), __new_size - size()); | 1059 | __construct_at_end(std::move(__mid), std::move(__last), __new_size - size()); |
| 1063 | #else | ||
| 1064 | _Iterator __mid = std::next(__first, size()); | ||
| 1065 | std::copy(__first, __mid, this->__begin_); | ||
| 1066 | __construct_at_end(__mid, __last, __new_size - size()); | ||
| 1067 | #endif | ||
| 1068 | } else { | 1060 | } else { |
| 1069 | pointer __m = std::__copy(std::move(__first), __last, this->__begin_).second; | 1061 | pointer __m = std::__copy(std::move(__first), __last, this->__begin_).second; |
| 1070 | this->__destruct_at_end(__m); | 1062 | this->__destruct_at_end(__m); |
| ... | @@ -1097,7 +1089,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __ | ... | @@ -1097,7 +1089,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __ |
| 1097 | if (__n > capacity()) { | 1089 | if (__n > capacity()) { |
| 1098 | if (__n > max_size()) | 1090 | if (__n > max_size()) |
| 1099 | this->__throw_length_error(); | 1091 | this->__throw_length_error(); |
| 1100 | __split_buffer<value_type, allocator_type&> __v(__n, size(), this->__alloc_); | 1092 | __split_buffer<value_type, allocator_type> __v(__n, size(), this->__alloc_); |
| 1101 | __swap_out_circular_buffer(__v); | 1093 | __swap_out_circular_buffer(__v); |
| 1102 | } | 1094 | } |
| 1103 | } | 1095 | } |
| ... | @@ -1108,7 +1100,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE | ... | @@ -1108,7 +1100,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE |
| 1108 | #if _LIBCPP_HAS_EXCEPTIONS | 1100 | #if _LIBCPP_HAS_EXCEPTIONS |
| 1109 | try { | 1101 | try { |
| 1110 | #endif // _LIBCPP_HAS_EXCEPTIONS | 1102 | #endif // _LIBCPP_HAS_EXCEPTIONS |
| 1111 | __split_buffer<value_type, allocator_type&> __v(size(), size(), this->__alloc_); | 1103 | __split_buffer<value_type, allocator_type> __v(size(), size(), this->__alloc_); |
| 1112 | // The Standard mandates shrink_to_fit() does not increase the capacity. | 1104 | // The Standard mandates shrink_to_fit() does not increase the capacity. |
| 1113 | // With equal capacity keep the existing buffer. This avoids extra work | 1105 | // With equal capacity keep the existing buffer. This avoids extra work |
| 1114 | // due to swapping the elements. | 1106 | // due to swapping the elements. |
| ... | @@ -1125,14 +1117,33 @@ template <class _Tp, class _Allocator> | ... | @@ -1125,14 +1117,33 @@ template <class _Tp, class _Allocator> |
| 1125 | template <class... _Args> | 1117 | template <class... _Args> |
| 1126 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | 1118 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer |
| 1127 | vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { | 1119 | vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { |
| 1128 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), this->__alloc_); | 1120 | __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), size(), this->__alloc_); |
| 1129 | // __v.emplace_back(std::forward<_Args>(__args)...); | 1121 | // __v.emplace_back(std::forward<_Args>(__args)...); |
| 1130 | __alloc_traits::construct(this->__alloc_, std::__to_address(__v.__end_), std::forward<_Args>(__args)...); | 1122 | pointer __end = __v.end(); |
| 1131 | __v.__end_++; | 1123 | __alloc_traits::construct(this->__alloc_, std::__to_address(__end), std::forward<_Args>(__args)...); |
| 1124 | __v.__set_sentinel(++__end); | ||
| 1132 | __swap_out_circular_buffer(__v); | 1125 | __swap_out_circular_buffer(__v); |
| 1133 | return this->__end_; | 1126 | return this->__end_; |
| 1134 | } | 1127 | } |
| 1135 | 1128 | ||
| 1129 | // This makes the compiler inline `__else()` if `__cond` is known to be false. Currently LLVM doesn't do that without | ||
| 1130 | // the `__builtin_constant_p`, since it considers `__else` unlikely even through it's known to be run. | ||
| 1131 | // See https://llvm.org/PR154292 | ||
| 1132 | template <class _If, class _Else> | ||
| 1133 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __if_likely_else(bool __cond, _If __if, _Else __else) { | ||
| 1134 | if (__builtin_constant_p(__cond)) { | ||
| 1135 | if (__cond) | ||
| 1136 | __if(); | ||
| 1137 | else | ||
| 1138 | __else(); | ||
| 1139 | } else { | ||
| 1140 | if (__cond) [[__likely__]] | ||
| 1141 | __if(); | ||
| 1142 | else | ||
| 1143 | __else(); | ||
| 1144 | } | ||
| 1145 | } | ||
| 1146 | |||
| 1136 | template <class _Tp, class _Allocator> | 1147 | template <class _Tp, class _Allocator> |
| 1137 | template <class... _Args> | 1148 | template <class... _Args> |
| 1138 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline | 1149 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline |
| ... | @@ -1143,12 +1154,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline | ... | @@ -1143,12 +1154,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline |
| 1143 | #endif | 1154 | #endif |
| 1144 | vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { | 1155 | vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { |
| 1145 | pointer __end = this->__end_; | 1156 | pointer __end = this->__end_; |
| 1146 | if (__end < this->__cap_) { | 1157 | std::__if_likely_else( |
| 1147 | __emplace_back_assume_capacity(std::forward<_Args>(__args)...); | 1158 | __end < this->__cap_, |
| 1148 | ++__end; | 1159 | [&] { |
| 1149 | } else { | 1160 | __emplace_back_assume_capacity(std::forward<_Args>(__args)...); |
| 1150 | __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); | 1161 | ++__end; |
| 1151 | } | 1162 | }, |
| 1163 | [&] { __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); }); | ||
| 1164 | |||
| 1152 | this->__end_ = __end; | 1165 | this->__end_ = __end; |
| 1153 | #if _LIBCPP_STD_VER >= 17 | 1166 | #if _LIBCPP_STD_VER >= 17 |
| 1154 | return *(__end - 1); | 1167 | return *(__end - 1); |
| ... | @@ -1207,7 +1220,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) | ... | @@ -1207,7 +1220,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) |
| 1207 | *__p = *__xr; | 1220 | *__p = *__xr; |
| 1208 | } | 1221 | } |
| 1209 | } else { | 1222 | } else { |
| 1210 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); | 1223 | __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); |
| 1211 | __v.emplace_back(__x); | 1224 | __v.emplace_back(__x); |
| 1212 | __p = __swap_out_circular_buffer(__v, __p); | 1225 | __p = __swap_out_circular_buffer(__v, __p); |
| 1213 | } | 1226 | } |
| ... | @@ -1226,7 +1239,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { | ... | @@ -1226,7 +1239,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { |
| 1226 | *__p = std::move(__x); | 1239 | *__p = std::move(__x); |
| 1227 | } | 1240 | } |
| 1228 | } else { | 1241 | } else { |
| 1229 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); | 1242 | __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); |
| 1230 | __v.emplace_back(std::move(__x)); | 1243 | __v.emplace_back(std::move(__x)); |
| 1231 | __p = __swap_out_circular_buffer(__v, __p); | 1244 | __p = __swap_out_circular_buffer(__v, __p); |
| 1232 | } | 1245 | } |
| ... | @@ -1247,7 +1260,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { | ... | @@ -1247,7 +1260,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { |
| 1247 | *__p = std::move(__tmp.get()); | 1260 | *__p = std::move(__tmp.get()); |
| 1248 | } | 1261 | } |
| 1249 | } else { | 1262 | } else { |
| 1250 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); | 1263 | __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); |
| 1251 | __v.emplace_back(std::forward<_Args>(__args)...); | 1264 | __v.emplace_back(std::forward<_Args>(__args)...); |
| 1252 | __p = __swap_out_circular_buffer(__v, __p); | 1265 | __p = __swap_out_circular_buffer(__v, __p); |
| 1253 | } | 1266 | } |
| ... | @@ -1275,7 +1288,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_ | ... | @@ -1275,7 +1288,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_ |
| 1275 | std::fill_n(__p, __n, *__xr); | 1288 | std::fill_n(__p, __n, *__xr); |
| 1276 | } | 1289 | } |
| 1277 | } else { | 1290 | } else { |
| 1278 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); | 1291 | __split_buffer<value_type, allocator_type> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); |
| 1279 | __v.__construct_at_end(__n, __x); | 1292 | __v.__construct_at_end(__n, __x); |
| 1280 | __p = __swap_out_circular_buffer(__v, __p); | 1293 | __p = __swap_out_circular_buffer(__v, __p); |
| 1281 | } | 1294 | } |
| ... | @@ -1296,28 +1309,28 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu | ... | @@ -1296,28 +1309,28 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu |
| 1296 | if (__first == __last) | 1309 | if (__first == __last) |
| 1297 | (void)std::rotate(__p, __old_last, this->__end_); | 1310 | (void)std::rotate(__p, __old_last, this->__end_); |
| 1298 | else { | 1311 | else { |
| 1299 | __split_buffer<value_type, allocator_type&> __v(__alloc_); | 1312 | __split_buffer<value_type, allocator_type> __v(__alloc_); |
| 1300 | auto __guard = std::__make_exception_guard( | 1313 | auto __guard = std::__make_exception_guard( |
| 1301 | _AllocatorDestroyRangeReverse<allocator_type, pointer>(__alloc_, __old_last, this->__end_)); | 1314 | _AllocatorDestroyRangeReverse<allocator_type, pointer>(__alloc_, __old_last, this->__end_)); |
| 1302 | __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last)); | 1315 | __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last)); |
| 1303 | __split_buffer<value_type, allocator_type&> __merged( | 1316 | __split_buffer<value_type, allocator_type> __merged( |
| 1304 | __recommend(size() + __v.size()), __off, __alloc_); // has `__off` positions available at the front | 1317 | __recommend(size() + __v.size()), __off, __alloc_); // has `__off` positions available at the front |
| 1305 | std::__uninitialized_allocator_relocate( | 1318 | std::__uninitialized_allocator_relocate( |
| 1306 | __alloc_, std::__to_address(__old_last), std::__to_address(this->__end_), std::__to_address(__merged.__end_)); | 1319 | __alloc_, std::__to_address(__old_last), std::__to_address(this->__end_), std::__to_address(__merged.end())); |
| 1307 | __guard.__complete(); // Release the guard once objects in [__old_last_, __end_) have been successfully relocated. | 1320 | __guard.__complete(); // Release the guard once objects in [__old_last_, __end_) have been successfully relocated. |
| 1308 | __merged.__end_ += this->__end_ - __old_last; | 1321 | __merged.__set_sentinel(__merged.end() + (this->__end_ - __old_last)); |
| 1309 | this->__end_ = __old_last; | 1322 | this->__end_ = __old_last; |
| 1310 | std::__uninitialized_allocator_relocate( | 1323 | std::__uninitialized_allocator_relocate( |
| 1311 | __alloc_, std::__to_address(__v.__begin_), std::__to_address(__v.__end_), std::__to_address(__merged.__end_)); | 1324 | __alloc_, std::__to_address(__v.begin()), std::__to_address(__v.end()), std::__to_address(__merged.end())); |
| 1312 | __merged.__end_ += __v.size(); | 1325 | __merged.__set_sentinel(__merged.size() + __v.size()); |
| 1313 | __v.__end_ = __v.__begin_; | 1326 | __v.__set_sentinel(__v.begin()); |
| 1314 | __p = __swap_out_circular_buffer(__merged, __p); | 1327 | __p = __swap_out_circular_buffer(__merged, __p); |
| 1315 | } | 1328 | } |
| 1316 | return __make_iter(__p); | 1329 | return __make_iter(__p); |
| 1317 | } | 1330 | } |
| 1318 | 1331 | ||
| 1319 | template <class _Tp, class _Allocator> | 1332 | template <class _Tp, class _Allocator> |
| 1320 | template <class _Iterator, class _Sentinel> | 1333 | template <class _AlgPolicy, class _Iterator, class _Sentinel> |
| 1321 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | 1334 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator |
| 1322 | vector<_Tp, _Allocator>::__insert_with_size( | 1335 | vector<_Tp, _Allocator>::__insert_with_size( |
| 1323 | const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) { | 1336 | const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) { |
| ... | @@ -1338,15 +1351,15 @@ vector<_Tp, _Allocator>::__insert_with_size( | ... | @@ -1338,15 +1351,15 @@ vector<_Tp, _Allocator>::__insert_with_size( |
| 1338 | __construct_at_end(__m, __last, __n - __dx); | 1351 | __construct_at_end(__m, __last, __n - __dx); |
| 1339 | if (__dx > 0) { | 1352 | if (__dx > 0) { |
| 1340 | __move_range(__p, __old_last, __p + __n); | 1353 | __move_range(__p, __old_last, __p + __n); |
| 1341 | __insert_assign_n_unchecked(__first, __dx, __p); | 1354 | __insert_assign_n_unchecked<_AlgPolicy>(__first, __dx, __p); |
| 1342 | } | 1355 | } |
| 1343 | } | 1356 | } |
| 1344 | } else { | 1357 | } else { |
| 1345 | __move_range(__p, __old_last, __p + __n); | 1358 | __move_range(__p, __old_last, __p + __n); |
| 1346 | __insert_assign_n_unchecked(std::move(__first), __n, __p); | 1359 | __insert_assign_n_unchecked<_AlgPolicy>(std::move(__first), __n, __p); |
| 1347 | } | 1360 | } |
| 1348 | } else { | 1361 | } else { |
| 1349 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); | 1362 | __split_buffer<value_type, allocator_type> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); |
| 1350 | __v.__construct_at_end_with_size(std::move(__first), __n); | 1363 | __v.__construct_at_end_with_size(std::move(__first), __n); |
| 1351 | __p = __swap_out_circular_buffer(__v, __p); | 1364 | __p = __swap_out_circular_buffer(__v, __p); |
| 1352 | } | 1365 | } |
| ... | @@ -1355,21 +1368,35 @@ vector<_Tp, _Allocator>::__insert_with_size( | ... | @@ -1355,21 +1368,35 @@ vector<_Tp, _Allocator>::__insert_with_size( |
| 1355 | } | 1368 | } |
| 1356 | 1369 | ||
| 1357 | template <class _Tp, class _Allocator> | 1370 | template <class _Tp, class _Allocator> |
| 1358 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz) { | 1371 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __new_size) { |
| 1359 | size_type __cs = size(); | 1372 | size_type __current_size = size(); |
| 1360 | if (__cs < __sz) | 1373 | if (__current_size < __new_size) { |
| 1361 | this->__append(__sz - __cs); | 1374 | if (__new_size <= capacity()) { |
| 1362 | else if (__cs > __sz) | 1375 | __construct_at_end(__new_size - __current_size); |
| 1363 | this->__destruct_at_end(this->__begin_ + __sz); | 1376 | } else { |
| 1377 | __split_buffer<value_type, allocator_type> __v(__recommend(__new_size), __current_size, __alloc_); | ||
| 1378 | __v.__construct_at_end(__new_size - __current_size); | ||
| 1379 | __swap_out_circular_buffer(__v); | ||
| 1380 | } | ||
| 1381 | } else if (__current_size > __new_size) { | ||
| 1382 | this->__destruct_at_end(this->__begin_ + __new_size); | ||
| 1383 | } | ||
| 1364 | } | 1384 | } |
| 1365 | 1385 | ||
| 1366 | template <class _Tp, class _Allocator> | 1386 | template <class _Tp, class _Allocator> |
| 1367 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) { | 1387 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __new_size, const_reference __x) { |
| 1368 | size_type __cs = size(); | 1388 | size_type __current_size = size(); |
| 1369 | if (__cs < __sz) | 1389 | if (__current_size < __new_size) { |
| 1370 | this->__append(__sz - __cs, __x); | 1390 | if (__new_size <= capacity()) |
| 1371 | else if (__cs > __sz) | 1391 | __construct_at_end(__new_size - __current_size, __x); |
| 1372 | this->__destruct_at_end(this->__begin_ + __sz); | 1392 | else { |
| 1393 | __split_buffer<value_type, allocator_type> __v(__recommend(__new_size), __current_size, __alloc_); | ||
| 1394 | __v.__construct_at_end(__new_size - __current_size, __x); | ||
| 1395 | __swap_out_circular_buffer(__v); | ||
| 1396 | } | ||
| 1397 | } else if (__current_size > __new_size) { | ||
| 1398 | this->__destruct_at_end(this->__begin_ + __new_size); | ||
| 1399 | } | ||
| 1373 | } | 1400 | } |
| 1374 | 1401 | ||
| 1375 | template <class _Tp, class _Allocator> | 1402 | template <class _Tp, class _Allocator> |
lib/libcxx/include/__vector/vector_bool.h+76-83| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy.h> | 12 | #include <__algorithm/copy.h> |
| 13 | #include <__algorithm/copy_backward.h> | 13 | #include <__algorithm/copy_backward.h> |
| 14 | #include <__algorithm/copy_n.h> | ||
| 14 | #include <__algorithm/fill_n.h> | 15 | #include <__algorithm/fill_n.h> |
| 15 | #include <__algorithm/iterator_operations.h> | 16 | #include <__algorithm/iterator_operations.h> |
| 16 | #include <__algorithm/max.h> | 17 | #include <__algorithm/max.h> |
| ... | @@ -19,7 +20,7 @@ | ... | @@ -19,7 +20,7 @@ |
| 19 | #include <__bit_reference> | 20 | #include <__bit_reference> |
| 20 | #include <__config> | 21 | #include <__config> |
| 21 | #include <__functional/unary_function.h> | 22 | #include <__functional/unary_function.h> |
| 22 | #include <__fwd/bit_reference.h> // TODO: This is a workaround for https://github.com/llvm/llvm-project/issues/131814 | 23 | #include <__fwd/bit_reference.h> // TODO: This is a workaround for https://llvm.org/PR131814 |
| 23 | #include <__fwd/functional.h> | 24 | #include <__fwd/functional.h> |
| 24 | #include <__fwd/vector.h> | 25 | #include <__fwd/vector.h> |
| 25 | #include <__iterator/distance.h> | 26 | #include <__iterator/distance.h> |
| ... | @@ -234,74 +235,89 @@ public: | ... | @@ -234,74 +235,89 @@ public: |
| 234 | } | 235 | } |
| 235 | #endif | 236 | #endif |
| 236 | 237 | ||
| 237 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { | 238 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { |
| 238 | return allocator_type(this->__alloc_); | 239 | return allocator_type(this->__alloc_); |
| 239 | } | 240 | } |
| 240 | 241 | ||
| 241 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT; | 242 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT; |
| 242 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT { | 243 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT { |
| 243 | return __internal_cap_to_external(__cap_); | 244 | return __internal_cap_to_external(__cap_); |
| 244 | } | 245 | } |
| 245 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; } | 246 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { |
| 247 | return __size_; | ||
| 248 | } | ||
| 246 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { | 249 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { |
| 247 | return __size_ == 0; | 250 | return __size_ == 0; |
| 248 | } | 251 | } |
| 249 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); | 252 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); |
| 250 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; | 253 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; |
| 251 | 254 | ||
| 252 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return __make_iter(0); } | 255 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { |
| 253 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { return __make_iter(0); } | 256 | return __make_iter(0); |
| 254 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { return __make_iter(__size_); } | 257 | } |
| 255 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT { | 258 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { |
| 259 | return __make_iter(0); | ||
| 260 | } | ||
| 261 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { | ||
| 262 | return __make_iter(__size_); | ||
| 263 | } | ||
| 264 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT { | ||
| 256 | return __make_iter(__size_); | 265 | return __make_iter(__size_); |
| 257 | } | 266 | } |
| 258 | 267 | ||
| 259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT { | 268 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT { |
| 260 | return reverse_iterator(end()); | 269 | return reverse_iterator(end()); |
| 261 | } | 270 | } |
| 262 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT { | 271 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator |
| 272 | rbegin() const _NOEXCEPT { | ||
| 263 | return const_reverse_iterator(end()); | 273 | return const_reverse_iterator(end()); |
| 264 | } | 274 | } |
| 265 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT { | 275 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT { |
| 266 | return reverse_iterator(begin()); | 276 | return reverse_iterator(begin()); |
| 267 | } | 277 | } |
| 268 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT { | 278 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT { |
| 269 | return const_reverse_iterator(begin()); | 279 | return const_reverse_iterator(begin()); |
| 270 | } | 280 | } |
| 271 | 281 | ||
| 272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return __make_iter(0); } | 282 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { |
| 273 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT { | 283 | return __make_iter(0); |
| 284 | } | ||
| 285 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT { | ||
| 274 | return __make_iter(__size_); | 286 | return __make_iter(__size_); |
| 275 | } | 287 | } |
| 276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT { | 288 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator |
| 289 | crbegin() const _NOEXCEPT { | ||
| 277 | return rbegin(); | 290 | return rbegin(); |
| 278 | } | 291 | } |
| 279 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 292 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { |
| 293 | return rend(); | ||
| 294 | } | ||
| 280 | 295 | ||
| 281 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) { | 296 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) { |
| 282 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds"); | 297 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds"); |
| 283 | return __make_ref(__n); | 298 | return __make_ref(__n); |
| 284 | } | 299 | } |
| 285 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const { | 300 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference |
| 301 | operator[](size_type __n) const { | ||
| 286 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds"); | 302 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds"); |
| 287 | return __make_ref(__n); | 303 | return __make_ref(__n); |
| 288 | } | 304 | } |
| 289 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n); | 305 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n); |
| 290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const; | 306 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const; |
| 291 | 307 | ||
| 292 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() { | 308 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() { |
| 293 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector"); | 309 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector"); |
| 294 | return __make_ref(0); | 310 | return __make_ref(0); |
| 295 | } | 311 | } |
| 296 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const { | 312 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const { |
| 297 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector"); | 313 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector"); |
| 298 | return __make_ref(0); | 314 | return __make_ref(0); |
| 299 | } | 315 | } |
| 300 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() { | 316 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() { |
| 301 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector"); | 317 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector"); |
| 302 | return __make_ref(__size_ - 1); | 318 | return __make_ref(__size_ - 1); |
| 303 | } | 319 | } |
| 304 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const { | 320 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const { |
| 305 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector"); | 321 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector"); |
| 306 | return __make_ref(__size_ - 1); | 322 | return __make_ref(__size_ - 1); |
| 307 | } | 323 | } |
| ... | @@ -463,7 +479,6 @@ private: | ... | @@ -463,7 +479,6 @@ private: |
| 463 | return (__new_size + (__bits_per_word - 1)) & ~((size_type)__bits_per_word - 1); | 479 | return (__new_size + (__bits_per_word - 1)) & ~((size_type)__bits_per_word - 1); |
| 464 | } | 480 | } |
| 465 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const; | 481 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const; |
| 466 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x); | ||
| 467 | template <class _InputIterator, class _Sentinel> | 482 | template <class _InputIterator, class _Sentinel> |
| 468 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 483 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 469 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); | 484 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); |
| ... | @@ -552,20 +567,6 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const { | ... | @@ -552,20 +567,6 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const { |
| 552 | return std::max<size_type>(2 * __cap, __align_it(__new_size)); | 567 | return std::max<size_type>(2 * __cap, __align_it(__new_size)); |
| 553 | } | 568 | } |
| 554 | 569 | ||
| 555 | // Default constructs __n objects starting at __end_ | ||
| 556 | // Precondition: size() + __n <= capacity() | ||
| 557 | // Postcondition: size() == size() + __n | ||
| 558 | template <class _Allocator> | ||
| 559 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | ||
| 560 | vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) { | ||
| 561 | _LIBCPP_ASSERT_INTERNAL( | ||
| 562 | capacity() >= size() + __n, "vector<bool>::__construct_at_end called with insufficient capacity"); | ||
| 563 | std::fill_n(end(), __n, __x); | ||
| 564 | this->__size_ += __n; | ||
| 565 | if (end().__ctz_ != 0) // Ensure uninitialized leading bits in the last word are set to zero | ||
| 566 | std::fill_n(end(), __bits_per_word - end().__ctz_, 0); | ||
| 567 | } | ||
| 568 | |||
| 569 | template <class _Allocator> | 570 | template <class _Allocator> |
| 570 | template <class _InputIterator, class _Sentinel> | 571 | template <class _InputIterator, class _Sentinel> |
| 571 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 572 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| ... | @@ -598,7 +599,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n) | ... | @@ -598,7 +599,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n) |
| 598 | : __begin_(nullptr), __size_(0), __cap_(0) { | 599 | : __begin_(nullptr), __size_(0), __cap_(0) { |
| 599 | if (__n > 0) { | 600 | if (__n > 0) { |
| 600 | __vallocate(__n); | 601 | __vallocate(__n); |
| 601 | __construct_at_end(__n, false); | 602 | std::fill_n(__begin_, __external_cap_to_internal(__n), __storage_type(0)); |
| 603 | __size_ = __n; | ||
| 602 | } | 604 | } |
| 603 | } | 605 | } |
| 604 | 606 | ||
| ... | @@ -608,7 +610,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co | ... | @@ -608,7 +610,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co |
| 608 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | 610 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { |
| 609 | if (__n > 0) { | 611 | if (__n > 0) { |
| 610 | __vallocate(__n); | 612 | __vallocate(__n); |
| 611 | __construct_at_end(__n, false); | 613 | std::fill_n(__begin_, __external_cap_to_internal(__n), __storage_type(0)); |
| 614 | __size_ = __n; | ||
| 612 | } | 615 | } |
| 613 | } | 616 | } |
| 614 | #endif | 617 | #endif |
| ... | @@ -618,7 +621,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co | ... | @@ -618,7 +621,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co |
| 618 | : __begin_(nullptr), __size_(0), __cap_(0) { | 621 | : __begin_(nullptr), __size_(0), __cap_(0) { |
| 619 | if (__n > 0) { | 622 | if (__n > 0) { |
| 620 | __vallocate(__n); | 623 | __vallocate(__n); |
| 621 | __construct_at_end(__n, __x); | 624 | std::fill_n(__begin_, __external_cap_to_internal(__n), __storage_type(0) - __x); |
| 625 | __size_ = __n; | ||
| 622 | } | 626 | } |
| 623 | } | 627 | } |
| 624 | 628 | ||
| ... | @@ -628,7 +632,8 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all | ... | @@ -628,7 +632,8 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all |
| 628 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | 632 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { |
| 629 | if (__n > 0) { | 633 | if (__n > 0) { |
| 630 | __vallocate(__n); | 634 | __vallocate(__n); |
| 631 | __construct_at_end(__n, __x); | 635 | std::fill_n(__begin_, __external_cap_to_internal(__n), __storage_type(0) - __x); |
| 636 | __size_ = __n; | ||
| 632 | } | 637 | } |
| 633 | } | 638 | } |
| 634 | 639 | ||
| ... | @@ -697,7 +702,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v | ... | @@ -697,7 +702,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v |
| 697 | __alloc_(__storage_traits::select_on_container_copy_construction(__v.__alloc_)) { | 702 | __alloc_(__storage_traits::select_on_container_copy_construction(__v.__alloc_)) { |
| 698 | if (__v.size() > 0) { | 703 | if (__v.size() > 0) { |
| 699 | __vallocate(__v.size()); | 704 | __vallocate(__v.size()); |
| 700 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | 705 | std::copy_n(__v.__begin_, __external_cap_to_internal(__v.size()), __begin_); |
| 706 | __size_ = __v.size(); | ||
| 701 | } | 707 | } |
| 702 | } | 708 | } |
| 703 | 709 | ||
| ... | @@ -706,7 +712,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v | ... | @@ -706,7 +712,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v |
| 706 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) { | 712 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) { |
| 707 | if (__v.size() > 0) { | 713 | if (__v.size() > 0) { |
| 708 | __vallocate(__v.size()); | 714 | __vallocate(__v.size()); |
| 709 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | 715 | std::copy_n(__v.__begin_, __external_cap_to_internal(__v.size()), __begin_); |
| 716 | __size_ = __v.size(); | ||
| 710 | } | 717 | } |
| 711 | } | 718 | } |
| 712 | 719 | ||
| ... | @@ -719,7 +726,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator> | ... | @@ -719,7 +726,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator> |
| 719 | __vdeallocate(); | 726 | __vdeallocate(); |
| 720 | __vallocate(__v.__size_); | 727 | __vallocate(__v.__size_); |
| 721 | } | 728 | } |
| 722 | std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); | 729 | std::copy_n(__v.__begin_, __external_cap_to_internal(__v.size()), __begin_); |
| 723 | } | 730 | } |
| 724 | __size_ = __v.__size_; | 731 | __size_ = __v.__size_; |
| 725 | } | 732 | } |
| ... | @@ -754,7 +761,8 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator | ... | @@ -754,7 +761,8 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator |
| 754 | __v.__cap_ = __v.__size_ = 0; | 761 | __v.__cap_ = __v.__size_ = 0; |
| 755 | } else if (__v.size() > 0) { | 762 | } else if (__v.size() > 0) { |
| 756 | __vallocate(__v.size()); | 763 | __vallocate(__v.size()); |
| 757 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | 764 | __size_ = __v.__size_; |
| 765 | std::copy_n(__v.__begin_, __external_cap_to_internal(__v.size()), __begin_); | ||
| 758 | } | 766 | } |
| 759 | } | 767 | } |
| 760 | 768 | ||
| ... | @@ -849,7 +857,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type _ | ... | @@ -849,7 +857,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type _ |
| 849 | this->__throw_length_error(); | 857 | this->__throw_length_error(); |
| 850 | vector __v(this->get_allocator()); | 858 | vector __v(this->get_allocator()); |
| 851 | __v.__vallocate(__n); | 859 | __v.__vallocate(__n); |
| 852 | __v.__construct_at_end(this->begin(), this->end(), this->size()); | 860 | __v.__size_ = __size_; |
| 861 | std::copy_n(__begin_, __external_cap_to_internal(__size_), __v.__begin_); | ||
| 853 | swap(__v); | 862 | swap(__v); |
| 854 | } | 863 | } |
| 855 | } | 864 | } |
| ... | @@ -956,21 +965,14 @@ vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inp | ... | @@ -956,21 +965,14 @@ vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inp |
| 956 | } | 965 | } |
| 957 | vector __v(get_allocator()); | 966 | vector __v(get_allocator()); |
| 958 | if (__first != __last) { | 967 | if (__first != __last) { |
| 959 | #if _LIBCPP_HAS_EXCEPTIONS | 968 | auto __guard = std::__make_exception_guard([&] { erase(__old_end, end()); }); |
| 960 | try { | 969 | __v.__assign_with_sentinel(std::move(__first), std::move(__last)); |
| 961 | #endif // _LIBCPP_HAS_EXCEPTIONS | 970 | difference_type __old_size = static_cast<difference_type>(__old_end - begin()); |
| 962 | __v.__assign_with_sentinel(std::move(__first), std::move(__last)); | 971 | difference_type __old_p = __p - begin(); |
| 963 | difference_type __old_size = static_cast<difference_type>(__old_end - begin()); | 972 | reserve(__recommend(size() + __v.size())); |
| 964 | difference_type __old_p = __p - begin(); | 973 | __p = begin() + __old_p; |
| 965 | reserve(__recommend(size() + __v.size())); | 974 | __old_end = begin() + __old_size; |
| 966 | __p = begin() + __old_p; | 975 | __guard.__complete(); |
| 967 | __old_end = begin() + __old_size; | ||
| 968 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 969 | } catch (...) { | ||
| 970 | erase(__old_end, end()); | ||
| 971 | throw; | ||
| 972 | } | ||
| 973 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 974 | } | 976 | } |
| 975 | __p = std::rotate(__p, __old_end, end()); | 977 | __p = std::rotate(__p, __old_end, end()); |
| 976 | insert(__p, __v.begin(), __v.end()); | 978 | insert(__p, __v.begin(), __v.end()); |
| ... | @@ -1048,25 +1050,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x) | ... | @@ -1048,25 +1050,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x) |
| 1048 | } | 1050 | } |
| 1049 | 1051 | ||
| 1050 | template <class _Allocator> | 1052 | template <class _Allocator> |
| 1051 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::resize(size_type __sz, value_type __x) { | 1053 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::resize(size_type __new_size, value_type __x) { |
| 1052 | size_type __cs = size(); | 1054 | size_type __current_size = size(); |
| 1053 | if (__cs < __sz) { | 1055 | if (__new_size < __current_size) { |
| 1054 | iterator __r; | 1056 | __size_ = __new_size; |
| 1055 | size_type __c = capacity(); | 1057 | return; |
| 1056 | size_type __n = __sz - __cs; | 1058 | } |
| 1057 | if (__n <= __c && __cs <= __c - __n) { | 1059 | |
| 1058 | __r = end(); | 1060 | reserve(__new_size); |
| 1059 | __size_ += __n; | 1061 | std::fill_n(end(), __new_size - __current_size, __x); |
| 1060 | } else { | 1062 | __size_ = __new_size; |
| 1061 | vector __v(get_allocator()); | ||
| 1062 | __v.reserve(__recommend(__size_ + __n)); | ||
| 1063 | __v.__size_ = __size_ + __n; | ||
| 1064 | __r = std::copy(cbegin(), cend(), __v.begin()); | ||
| 1065 | swap(__v); | ||
| 1066 | } | ||
| 1067 | std::fill_n(__r, __n, __x); | ||
| 1068 | } else | ||
| 1069 | __size_ = __sz; | ||
| 1070 | } | 1063 | } |
| 1071 | 1064 | ||
| 1072 | template <class _Allocator> | 1065 | template <class _Allocator> |
lib/libcxx/include/any+118-155| ... | @@ -84,14 +84,12 @@ namespace std { | ... | @@ -84,14 +84,12 @@ namespace std { |
| 84 | # include <__cxx03/__config> | 84 | # include <__cxx03/__config> |
| 85 | #else | 85 | #else |
| 86 | # include <__config> | 86 | # include <__config> |
| 87 | # include <__memory/allocator.h> | 87 | # include <__memory/construct_at.h> |
| 88 | # include <__memory/allocator_destructor.h> | 88 | # include <__new/allocate.h> |
| 89 | # include <__memory/allocator_traits.h> | ||
| 90 | # include <__memory/unique_ptr.h> | ||
| 91 | # include <__type_traits/add_cv_quals.h> | 89 | # include <__type_traits/add_cv_quals.h> |
| 92 | # include <__type_traits/add_pointer.h> | 90 | # include <__type_traits/add_pointer.h> |
| 93 | # include <__type_traits/aligned_storage.h> | ||
| 94 | # include <__type_traits/conditional.h> | 91 | # include <__type_traits/conditional.h> |
| 92 | # include <__type_traits/conjunction.h> | ||
| 95 | # include <__type_traits/decay.h> | 93 | # include <__type_traits/decay.h> |
| 96 | # include <__type_traits/enable_if.h> | 94 | # include <__type_traits/enable_if.h> |
| 97 | # include <__type_traits/is_constructible.h> | 95 | # include <__type_traits/is_constructible.h> |
| ... | @@ -100,9 +98,11 @@ namespace std { | ... | @@ -100,9 +98,11 @@ namespace std { |
| 100 | # include <__type_traits/is_reference.h> | 98 | # include <__type_traits/is_reference.h> |
| 101 | # include <__type_traits/is_same.h> | 99 | # include <__type_traits/is_same.h> |
| 102 | # include <__type_traits/is_void.h> | 100 | # include <__type_traits/is_void.h> |
| 101 | # include <__type_traits/negation.h> | ||
| 103 | # include <__type_traits/remove_cv.h> | 102 | # include <__type_traits/remove_cv.h> |
| 104 | # include <__type_traits/remove_cvref.h> | 103 | # include <__type_traits/remove_cvref.h> |
| 105 | # include <__type_traits/remove_reference.h> | 104 | # include <__type_traits/remove_reference.h> |
| 105 | # include <__utility/exception_guard.h> | ||
| 106 | # include <__utility/forward.h> | 106 | # include <__utility/forward.h> |
| 107 | # include <__utility/in_place.h> | 107 | # include <__utility/in_place.h> |
| 108 | # include <__utility/move.h> | 108 | # include <__utility/move.h> |
| ... | @@ -142,21 +142,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -142,21 +142,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 142 | class any; | 142 | class any; |
| 143 | 143 | ||
| 144 | template <class _ValueType> | 144 | template <class _ValueType> |
| 145 | _LIBCPP_HIDE_FROM_ABI add_pointer_t<add_const_t<_ValueType>> any_cast(any const*) _NOEXCEPT; | 145 | _LIBCPP_HIDE_FROM_ABI add_pointer_t<add_const_t<_ValueType>> any_cast(any const*) noexcept; |
| 146 | 146 | ||
| 147 | template <class _ValueType> | 147 | template <class _ValueType> |
| 148 | _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT; | 148 | _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) noexcept; |
| 149 | 149 | ||
| 150 | namespace __any_imp { | 150 | namespace __any_imp { |
| 151 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 151 | inline constexpr size_t __small_buffer_size = 3 * sizeof(void*); |
| 152 | using _Buffer _LIBCPP_NODEBUG = aligned_storage_t<3 * sizeof(void*), alignof(void*)>; | 152 | inline constexpr size_t __small_buffer_alignment = alignof(void*); |
| 153 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 154 | 153 | ||
| 155 | template <class _Tp> | 154 | template <class _Tp> |
| 156 | using _IsSmallObject _LIBCPP_NODEBUG = | 155 | using _IsSmallObject _LIBCPP_NODEBUG = |
| 157 | integral_constant<bool, | 156 | integral_constant<bool, |
| 158 | sizeof(_Tp) <= sizeof(_Buffer) && alignof(_Buffer) % alignof(_Tp) == 0 && | 157 | sizeof(_Tp) <= __small_buffer_size && alignof(_Tp) <= __small_buffer_alignment && |
| 159 | is_nothrow_move_constructible<_Tp>::value >; | 158 | is_nothrow_move_constructible_v<_Tp>>; |
| 160 | 159 | ||
| 161 | enum class _Action { _Destroy, _Copy, _Move, _Get, _TypeInfo }; | 160 | enum class _Action { _Destroy, _Copy, _Move, _Get, _TypeInfo }; |
| 162 | 161 | ||
| ... | @@ -192,37 +191,44 @@ using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _Sma | ... | @@ -192,37 +191,44 @@ using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _Sma |
| 192 | class any { | 191 | class any { |
| 193 | public: | 192 | public: |
| 194 | // construct/destruct | 193 | // construct/destruct |
| 195 | _LIBCPP_HIDE_FROM_ABI constexpr any() _NOEXCEPT : __h_(nullptr) {} | 194 | _LIBCPP_HIDE_FROM_ABI constexpr any() noexcept : __h_(nullptr) {} |
| 196 | 195 | ||
| 197 | _LIBCPP_HIDE_FROM_ABI any(any const& __other) : __h_(nullptr) { | 196 | _LIBCPP_HIDE_FROM_ABI any(any const& __other) : __h_(nullptr) { |
| 198 | if (__other.__h_) | 197 | if (__other.__h_) |
| 199 | __other.__call(_Action::_Copy, this); | 198 | __other.__call(_Action::_Copy, this); |
| 200 | } | 199 | } |
| 201 | 200 | ||
| 202 | _LIBCPP_HIDE_FROM_ABI any(any&& __other) _NOEXCEPT : __h_(nullptr) { | 201 | _LIBCPP_HIDE_FROM_ABI any(any&& __other) noexcept : __h_(nullptr) { |
| 203 | if (__other.__h_) | 202 | if (__other.__h_) |
| 204 | __other.__call(_Action::_Move, this); | 203 | __other.__call(_Action::_Move, this); |
| 205 | } | 204 | } |
| 206 | 205 | ||
| 207 | template < class _ValueType, | 206 | template < |
| 208 | class _Tp = decay_t<_ValueType>, | 207 | class _ValueType, |
| 209 | class = enable_if_t< !is_same<_Tp, any>::value && !__is_inplace_type<_ValueType>::value && | 208 | class _Tp = decay_t<_ValueType>, |
| 210 | is_copy_constructible<_Tp>::value> > | 209 | enable_if_t<_And<_Not<is_same<_Tp, any>>, _Not<__is_inplace_type<_ValueType>>, is_copy_constructible<_Tp>>::value, |
| 211 | _LIBCPP_HIDE_FROM_ABI any(_ValueType&& __value); | 210 | int> = 0> |
| 211 | _LIBCPP_HIDE_FROM_ABI any(_ValueType&& __value) : __h_(nullptr) { | ||
| 212 | __any_imp::_Handler<_Tp>::__create(*this, std::forward<_ValueType>(__value)); | ||
| 213 | } | ||
| 212 | 214 | ||
| 213 | template <class _ValueType, | 215 | template <class _ValueType, |
| 214 | class... _Args, | 216 | class... _Args, |
| 215 | class _Tp = decay_t<_ValueType>, | 217 | class _Tp = decay_t<_ValueType>, |
| 216 | class = enable_if_t< is_constructible<_Tp, _Args...>::value && is_copy_constructible<_Tp>::value > > | 218 | enable_if_t<is_constructible_v<_Tp, _Args...> && is_copy_constructible_v<_Tp>, int> = 0> |
| 217 | _LIBCPP_HIDE_FROM_ABI explicit any(in_place_type_t<_ValueType>, _Args&&... __args); | 219 | _LIBCPP_HIDE_FROM_ABI explicit any(in_place_type_t<_ValueType>, _Args&&... __args) { |
| 220 | __any_imp::_Handler<_Tp>::__create(*this, std::forward<_Args>(__args)...); | ||
| 221 | } | ||
| 218 | 222 | ||
| 219 | template <class _ValueType, | 223 | template < |
| 220 | class _Up, | 224 | class _ValueType, |
| 221 | class... _Args, | 225 | class _Up, |
| 222 | class _Tp = decay_t<_ValueType>, | 226 | class... _Args, |
| 223 | class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value && | 227 | class _Tp = decay_t<_ValueType>, |
| 224 | is_copy_constructible<_Tp>::value> > | 228 | enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...> && is_copy_constructible_v<_Tp>, int> = 0> |
| 225 | _LIBCPP_HIDE_FROM_ABI explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args); | 229 | _LIBCPP_HIDE_FROM_ABI explicit any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) { |
| 230 | __any_imp::_Handler<_Tp>::__create(*this, __il, std::forward<_Args>(__args)...); | ||
| 231 | } | ||
| 226 | 232 | ||
| 227 | _LIBCPP_HIDE_FROM_ABI ~any() { this->reset(); } | 233 | _LIBCPP_HIDE_FROM_ABI ~any() { this->reset(); } |
| 228 | 234 | ||
| ... | @@ -232,43 +238,65 @@ public: | ... | @@ -232,43 +238,65 @@ public: |
| 232 | return *this; | 238 | return *this; |
| 233 | } | 239 | } |
| 234 | 240 | ||
| 235 | _LIBCPP_HIDE_FROM_ABI any& operator=(any&& __rhs) _NOEXCEPT { | 241 | _LIBCPP_HIDE_FROM_ABI any& operator=(any&& __rhs) noexcept { |
| 236 | any(std::move(__rhs)).swap(*this); | 242 | any(std::move(__rhs)).swap(*this); |
| 237 | return *this; | 243 | return *this; |
| 238 | } | 244 | } |
| 239 | 245 | ||
| 240 | template < class _ValueType, | ||
| 241 | class _Tp = decay_t<_ValueType>, | ||
| 242 | class = enable_if_t< !is_same<_Tp, any>::value && is_copy_constructible<_Tp>::value> > | ||
| 243 | _LIBCPP_HIDE_FROM_ABI any& operator=(_ValueType&& __rhs); | ||
| 244 | |||
| 245 | template <class _ValueType, | 246 | template <class _ValueType, |
| 246 | class... _Args, | 247 | class _Tp = decay_t<_ValueType>, |
| 247 | class _Tp = decay_t<_ValueType>, | 248 | enable_if_t<!is_same_v<_Tp, any> && is_copy_constructible_v<_Tp>, int> = 0> |
| 248 | class = enable_if_t< is_constructible<_Tp, _Args...>::value && is_copy_constructible<_Tp>::value> > | 249 | _LIBCPP_HIDE_FROM_ABI any& operator=(_ValueType&& __rhs) { |
| 249 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(_Args&&...); | 250 | any(std::forward<_ValueType>(__rhs)).swap(*this); |
| 251 | return *this; | ||
| 252 | } | ||
| 250 | 253 | ||
| 251 | template <class _ValueType, | 254 | template <class _ValueType, |
| 252 | class _Up, | ||
| 253 | class... _Args, | 255 | class... _Args, |
| 254 | class _Tp = decay_t<_ValueType>, | 256 | class _Tp = decay_t<_ValueType>, |
| 255 | class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value && | 257 | enable_if_t<is_constructible_v<_Tp, _Args...> && is_copy_constructible_v<_Tp>, int> = 0> |
| 256 | is_copy_constructible<_Tp>::value> > | 258 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(_Args&&... __args) { |
| 257 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up>, _Args&&...); | 259 | reset(); |
| 260 | return __any_imp::_Handler<_Tp>::__create(*this, std::forward<_Args>(__args)...); | ||
| 261 | } | ||
| 262 | |||
| 263 | template < | ||
| 264 | class _ValueType, | ||
| 265 | class _Up, | ||
| 266 | class... _Args, | ||
| 267 | class _Tp = decay_t<_ValueType>, | ||
| 268 | enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...> && is_copy_constructible_v<_Tp>, int> = 0> | ||
| 269 | _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { | ||
| 270 | reset(); | ||
| 271 | return __any_imp::_Handler<_Tp>::__create(*this, __il, std::forward<_Args>(__args)...); | ||
| 272 | } | ||
| 258 | 273 | ||
| 259 | // 6.3.3 any modifiers | 274 | // 6.3.3 any modifiers |
| 260 | _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT { | 275 | _LIBCPP_HIDE_FROM_ABI void reset() noexcept { |
| 261 | if (__h_) | 276 | if (__h_) |
| 262 | this->__call(_Action::_Destroy); | 277 | this->__call(_Action::_Destroy); |
| 263 | } | 278 | } |
| 264 | 279 | ||
| 265 | _LIBCPP_HIDE_FROM_ABI void swap(any& __rhs) _NOEXCEPT; | 280 | _LIBCPP_HIDE_FROM_ABI void swap(any& __rhs) noexcept { |
| 281 | if (this == &__rhs) | ||
| 282 | return; | ||
| 283 | if (__h_ && __rhs.__h_) { | ||
| 284 | any __tmp; | ||
| 285 | __rhs.__call(_Action::_Move, &__tmp); | ||
| 286 | this->__call(_Action::_Move, &__rhs); | ||
| 287 | __tmp.__call(_Action::_Move, this); | ||
| 288 | } else if (__h_) { | ||
| 289 | this->__call(_Action::_Move, &__rhs); | ||
| 290 | } else if (__rhs.__h_) { | ||
| 291 | __rhs.__call(_Action::_Move, this); | ||
| 292 | } | ||
| 293 | } | ||
| 266 | 294 | ||
| 267 | // 6.3.4 any observers | 295 | // 6.3.4 any observers |
| 268 | _LIBCPP_HIDE_FROM_ABI bool has_value() const _NOEXCEPT { return __h_ != nullptr; } | 296 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool has_value() const noexcept { return __h_ != nullptr; } |
| 269 | 297 | ||
| 270 | # if _LIBCPP_HAS_RTTI | 298 | # if _LIBCPP_HAS_RTTI |
| 271 | _LIBCPP_HIDE_FROM_ABI const type_info& type() const _NOEXCEPT { | 299 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const type_info& type() const noexcept { |
| 272 | if (__h_) { | 300 | if (__h_) { |
| 273 | return *static_cast<type_info const*>(this->__call(_Action::_TypeInfo)); | 301 | return *static_cast<type_info const*>(this->__call(_Action::_TypeInfo)); |
| 274 | } else { | 302 | } else { |
| ... | @@ -285,7 +313,7 @@ private: | ... | @@ -285,7 +313,7 @@ private: |
| 285 | union _Storage { | 313 | union _Storage { |
| 286 | _LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {} | 314 | _LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {} |
| 287 | void* __ptr; | 315 | void* __ptr; |
| 288 | __any_imp::_Buffer __buf; | 316 | alignas(__any_imp::__small_buffer_alignment) char __buf[__any_imp::__small_buffer_size]; |
| 289 | }; | 317 | }; |
| 290 | 318 | ||
| 291 | _LIBCPP_HIDE_FROM_ABI void* | 319 | _LIBCPP_HIDE_FROM_ABI void* |
| ... | @@ -305,10 +333,10 @@ private: | ... | @@ -305,10 +333,10 @@ private: |
| 305 | friend struct __any_imp::_LargeHandler; | 333 | friend struct __any_imp::_LargeHandler; |
| 306 | 334 | ||
| 307 | template <class _ValueType> | 335 | template <class _ValueType> |
| 308 | friend add_pointer_t<add_const_t<_ValueType>> any_cast(any const*) _NOEXCEPT; | 336 | friend add_pointer_t<add_const_t<_ValueType>> any_cast(any const*) noexcept; |
| 309 | 337 | ||
| 310 | template <class _ValueType> | 338 | template <class _ValueType> |
| 311 | friend add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT; | 339 | friend add_pointer_t<_ValueType> any_cast(any*) noexcept; |
| 312 | 340 | ||
| 313 | _HandleFuncPtr __h_ = nullptr; | 341 | _HandleFuncPtr __h_ = nullptr; |
| 314 | _Storage __s_; | 342 | _Storage __s_; |
| ... | @@ -339,22 +367,14 @@ struct _SmallHandler { | ... | @@ -339,22 +367,14 @@ struct _SmallHandler { |
| 339 | 367 | ||
| 340 | template <class... _Args> | 368 | template <class... _Args> |
| 341 | _LIBCPP_HIDE_FROM_ABI static _Tp& __create(any& __dest, _Args&&... __args) { | 369 | _LIBCPP_HIDE_FROM_ABI static _Tp& __create(any& __dest, _Args&&... __args) { |
| 342 | typedef allocator<_Tp> _Alloc; | 370 | auto __ret = std::__construct_at(reinterpret_cast<_Tp*>(&__dest.__s_.__buf), std::forward<_Args>(__args)...); |
| 343 | typedef allocator_traits<_Alloc> _ATraits; | ||
| 344 | _Alloc __a; | ||
| 345 | _Tp* __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s_.__buf)); | ||
| 346 | _ATraits::construct(__a, __ret, std::forward<_Args>(__args)...); | ||
| 347 | __dest.__h_ = &_SmallHandler::__handle; | 371 | __dest.__h_ = &_SmallHandler::__handle; |
| 348 | return *__ret; | 372 | return *__ret; |
| 349 | } | 373 | } |
| 350 | 374 | ||
| 351 | private: | 375 | private: |
| 352 | _LIBCPP_HIDE_FROM_ABI static void __destroy(any& __this) { | 376 | _LIBCPP_HIDE_FROM_ABI static void __destroy(any& __this) { |
| 353 | typedef allocator<_Tp> _Alloc; | 377 | std::__destroy_at(reinterpret_cast<_Tp*>(&__this.__s_.__buf)); |
| 354 | typedef allocator_traits<_Alloc> _ATraits; | ||
| 355 | _Alloc __a; | ||
| 356 | _Tp* __p = static_cast<_Tp*>(static_cast<void*>(&__this.__s_.__buf)); | ||
| 357 | _ATraits::destroy(__a, __p); | ||
| 358 | __this.__h_ = nullptr; | 378 | __this.__h_ = nullptr; |
| 359 | } | 379 | } |
| 360 | 380 | ||
| ... | @@ -406,26 +426,20 @@ struct _LargeHandler { | ... | @@ -406,26 +426,20 @@ struct _LargeHandler { |
| 406 | 426 | ||
| 407 | template <class... _Args> | 427 | template <class... _Args> |
| 408 | _LIBCPP_HIDE_FROM_ABI static _Tp& __create(any& __dest, _Args&&... __args) { | 428 | _LIBCPP_HIDE_FROM_ABI static _Tp& __create(any& __dest, _Args&&... __args) { |
| 409 | typedef allocator<_Tp> _Alloc; | 429 | _Tp* __ptr = static_cast<_Tp*>(std::__libcpp_allocate<_Tp>(__element_count(1))); |
| 410 | typedef allocator_traits<_Alloc> _ATraits; | 430 | std::__exception_guard __guard([&] { std::__libcpp_deallocate<_Tp>(__ptr, __element_count(1)); }); |
| 411 | typedef __allocator_destructor<_Alloc> _Dp; | 431 | std::__construct_at(__ptr, std::forward<_Args>(__args)...); |
| 412 | _Alloc __a; | 432 | __guard.__complete(); |
| 413 | unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1)); | 433 | __dest.__s_.__ptr = __ptr; |
| 414 | _Tp* __ret = __hold.get(); | ||
| 415 | _ATraits::construct(__a, __ret, std::forward<_Args>(__args)...); | ||
| 416 | __dest.__s_.__ptr = __hold.release(); | ||
| 417 | __dest.__h_ = &_LargeHandler::__handle; | 434 | __dest.__h_ = &_LargeHandler::__handle; |
| 418 | return *__ret; | 435 | return *__ptr; |
| 419 | } | 436 | } |
| 420 | 437 | ||
| 421 | private: | 438 | private: |
| 422 | _LIBCPP_HIDE_FROM_ABI static void __destroy(any& __this) { | 439 | _LIBCPP_HIDE_FROM_ABI static void __destroy(any& __this) { |
| 423 | typedef allocator<_Tp> _Alloc; | ||
| 424 | typedef allocator_traits<_Alloc> _ATraits; | ||
| 425 | _Alloc __a; | ||
| 426 | _Tp* __p = static_cast<_Tp*>(__this.__s_.__ptr); | 440 | _Tp* __p = static_cast<_Tp*>(__this.__s_.__ptr); |
| 427 | _ATraits::destroy(__a, __p); | 441 | std::__destroy_at(__p); |
| 428 | _ATraits::deallocate(__a, __p, 1); | 442 | std::__libcpp_deallocate<_Tp>(__p, __element_count(1)); |
| 429 | __this.__h_ = nullptr; | 443 | __this.__h_ = nullptr; |
| 430 | } | 444 | } |
| 431 | 445 | ||
| ... | @@ -456,72 +470,24 @@ private: | ... | @@ -456,72 +470,24 @@ private: |
| 456 | 470 | ||
| 457 | } // namespace __any_imp | 471 | } // namespace __any_imp |
| 458 | 472 | ||
| 459 | template <class _ValueType, class _Tp, class> | ||
| 460 | any::any(_ValueType&& __v) : __h_(nullptr) { | ||
| 461 | __any_imp::_Handler<_Tp>::__create(*this, std::forward<_ValueType>(__v)); | ||
| 462 | } | ||
| 463 | |||
| 464 | template <class _ValueType, class... _Args, class _Tp, class> | ||
| 465 | any::any(in_place_type_t<_ValueType>, _Args&&... __args) { | ||
| 466 | __any_imp::_Handler<_Tp>::__create(*this, std::forward<_Args>(__args)...); | ||
| 467 | } | ||
| 468 | |||
| 469 | template <class _ValueType, class _Up, class... _Args, class _Tp, class> | ||
| 470 | any::any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) { | ||
| 471 | __any_imp::_Handler<_Tp>::__create(*this, __il, std::forward<_Args>(__args)...); | ||
| 472 | } | ||
| 473 | |||
| 474 | template <class _ValueType, class, class> | ||
| 475 | inline _LIBCPP_HIDE_FROM_ABI any& any::operator=(_ValueType&& __v) { | ||
| 476 | any(std::forward<_ValueType>(__v)).swap(*this); | ||
| 477 | return *this; | ||
| 478 | } | ||
| 479 | |||
| 480 | template <class _ValueType, class... _Args, class _Tp, class> | ||
| 481 | inline _LIBCPP_HIDE_FROM_ABI _Tp& any::emplace(_Args&&... __args) { | ||
| 482 | reset(); | ||
| 483 | return __any_imp::_Handler<_Tp>::__create(*this, std::forward<_Args>(__args)...); | ||
| 484 | } | ||
| 485 | |||
| 486 | template <class _ValueType, class _Up, class... _Args, class _Tp, class> | ||
| 487 | inline _LIBCPP_HIDE_FROM_ABI _Tp& any::emplace(initializer_list<_Up> __il, _Args&&... __args) { | ||
| 488 | reset(); | ||
| 489 | return __any_imp::_Handler<_Tp>::__create(*this, __il, std::forward<_Args>(__args)...); | ||
| 490 | } | ||
| 491 | |||
| 492 | inline _LIBCPP_HIDE_FROM_ABI void any::swap(any& __rhs) _NOEXCEPT { | ||
| 493 | if (this == &__rhs) | ||
| 494 | return; | ||
| 495 | if (__h_ && __rhs.__h_) { | ||
| 496 | any __tmp; | ||
| 497 | __rhs.__call(_Action::_Move, &__tmp); | ||
| 498 | this->__call(_Action::_Move, &__rhs); | ||
| 499 | __tmp.__call(_Action::_Move, this); | ||
| 500 | } else if (__h_) { | ||
| 501 | this->__call(_Action::_Move, &__rhs); | ||
| 502 | } else if (__rhs.__h_) { | ||
| 503 | __rhs.__call(_Action::_Move, this); | ||
| 504 | } | ||
| 505 | } | ||
| 506 | |||
| 507 | // 6.4 Non-member functions | 473 | // 6.4 Non-member functions |
| 508 | 474 | ||
| 509 | inline _LIBCPP_HIDE_FROM_ABI void swap(any& __lhs, any& __rhs) _NOEXCEPT { __lhs.swap(__rhs); } | 475 | inline _LIBCPP_HIDE_FROM_ABI void swap(any& __lhs, any& __rhs) noexcept { __lhs.swap(__rhs); } |
| 510 | 476 | ||
| 511 | template <class _Tp, class... _Args> | 477 | template <class _Tp, class... _Args> |
| 512 | inline _LIBCPP_HIDE_FROM_ABI any make_any(_Args&&... __args) { | 478 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI any make_any(_Args&&... __args) { |
| 513 | return any(in_place_type<_Tp>, std::forward<_Args>(__args)...); | 479 | return any(in_place_type<_Tp>, std::forward<_Args>(__args)...); |
| 514 | } | 480 | } |
| 515 | 481 | ||
| 516 | template <class _Tp, class _Up, class... _Args> | 482 | template <class _Tp, class _Up, class... _Args> |
| 517 | inline _LIBCPP_HIDE_FROM_ABI any make_any(initializer_list<_Up> __il, _Args&&... __args) { | 483 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI any make_any(initializer_list<_Up> __il, _Args&&... __args) { |
| 518 | return any(in_place_type<_Tp>, __il, std::forward<_Args>(__args)...); | 484 | return any(in_place_type<_Tp>, __il, std::forward<_Args>(__args)...); |
| 519 | } | 485 | } |
| 520 | 486 | ||
| 521 | template <class _ValueType> | 487 | template <class _ValueType> |
| 522 | inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any const& __v) { | 488 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any const& __v) { |
| 523 | using _RawValueType = __remove_cvref_t<_ValueType>; | 489 | using _RawValueType = __remove_cvref_t<_ValueType>; |
| 524 | static_assert(is_constructible<_ValueType, _RawValueType const&>::value, | 490 | static_assert(is_constructible_v<_ValueType, _RawValueType const&>, |
| 525 | "ValueType is required to be a const lvalue reference " | 491 | "ValueType is required to be a const lvalue reference " |
| 526 | "or a CopyConstructible type"); | 492 | "or a CopyConstructible type"); |
| 527 | auto __tmp = std::any_cast<add_const_t<_RawValueType>>(&__v); | 493 | auto __tmp = std::any_cast<add_const_t<_RawValueType>>(&__v); |
| ... | @@ -531,9 +497,9 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any const& __v) { | ... | @@ -531,9 +497,9 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any const& __v) { |
| 531 | } | 497 | } |
| 532 | 498 | ||
| 533 | template <class _ValueType> | 499 | template <class _ValueType> |
| 534 | inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any& __v) { | 500 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any& __v) { |
| 535 | using _RawValueType = __remove_cvref_t<_ValueType>; | 501 | using _RawValueType = __remove_cvref_t<_ValueType>; |
| 536 | static_assert(is_constructible<_ValueType, _RawValueType&>::value, | 502 | static_assert(is_constructible_v<_ValueType, _RawValueType&>, |
| 537 | "ValueType is required to be an lvalue reference " | 503 | "ValueType is required to be an lvalue reference " |
| 538 | "or a CopyConstructible type"); | 504 | "or a CopyConstructible type"); |
| 539 | auto __tmp = std::any_cast<_RawValueType>(&__v); | 505 | auto __tmp = std::any_cast<_RawValueType>(&__v); |
| ... | @@ -543,9 +509,9 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any& __v) { | ... | @@ -543,9 +509,9 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any& __v) { |
| 543 | } | 509 | } |
| 544 | 510 | ||
| 545 | template <class _ValueType> | 511 | template <class _ValueType> |
| 546 | inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any&& __v) { | 512 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any&& __v) { |
| 547 | using _RawValueType = __remove_cvref_t<_ValueType>; | 513 | using _RawValueType = __remove_cvref_t<_ValueType>; |
| 548 | static_assert(is_constructible<_ValueType, _RawValueType>::value, | 514 | static_assert(is_constructible_v<_ValueType, _RawValueType>, |
| 549 | "ValueType is required to be an rvalue reference " | 515 | "ValueType is required to be an rvalue reference " |
| 550 | "or a CopyConstructible type"); | 516 | "or a CopyConstructible type"); |
| 551 | auto __tmp = std::any_cast<_RawValueType>(&__v); | 517 | auto __tmp = std::any_cast<_RawValueType>(&__v); |
| ... | @@ -555,39 +521,31 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any&& __v) { | ... | @@ -555,39 +521,31 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any&& __v) { |
| 555 | } | 521 | } |
| 556 | 522 | ||
| 557 | template <class _ValueType> | 523 | template <class _ValueType> |
| 558 | inline _LIBCPP_HIDE_FROM_ABI add_pointer_t<add_const_t<_ValueType>> any_cast(any const* __any) _NOEXCEPT { | 524 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI add_pointer_t<add_const_t<_ValueType>> any_cast(any const* __any) noexcept { |
| 559 | static_assert(!is_void_v<_ValueType>, "_ValueType may not be void."); | 525 | static_assert(!is_void_v<_ValueType>, "_ValueType may not be void."); |
| 560 | static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a reference."); | 526 | static_assert(!is_reference_v<_ValueType>, "_ValueType may not be a reference."); |
| 561 | return std::any_cast<_ValueType>(const_cast<any*>(__any)); | 527 | return std::any_cast<_ValueType>(const_cast<any*>(__any)); |
| 562 | } | 528 | } |
| 563 | 529 | ||
| 564 | template <class _RetType> | ||
| 565 | inline _LIBCPP_HIDE_FROM_ABI _RetType __pointer_or_func_cast(void* __p, /*IsFunction*/ false_type) noexcept { | ||
| 566 | return static_cast<_RetType>(__p); | ||
| 567 | } | ||
| 568 | |||
| 569 | template <class _RetType> | ||
| 570 | inline _LIBCPP_HIDE_FROM_ABI _RetType __pointer_or_func_cast(void*, /*IsFunction*/ true_type) noexcept { | ||
| 571 | return nullptr; | ||
| 572 | } | ||
| 573 | |||
| 574 | template <class _ValueType> | 530 | template <class _ValueType> |
| 575 | _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT { | 531 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) noexcept { |
| 576 | using __any_imp::_Action; | 532 | using __any_imp::_Action; |
| 577 | static_assert(!is_void_v<_ValueType>, "_ValueType may not be void."); | 533 | static_assert(!is_void_v<_ValueType>, "_ValueType may not be void."); |
| 578 | static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a reference."); | 534 | static_assert(!is_reference_v<_ValueType>, "_ValueType may not be a reference."); |
| 579 | typedef add_pointer_t<_ValueType> _ReturnType; | 535 | if constexpr (!is_function_v<_ValueType>) { |
| 580 | if (__any && __any->__h_) { | 536 | using _ReturnType = add_pointer_t<_ValueType>; |
| 581 | void* __p = __any->__call( | 537 | if (__any && __any->__h_) { |
| 582 | _Action::_Get, | 538 | void* __p = __any->__call( |
| 583 | nullptr, | 539 | _Action::_Get, |
| 540 | nullptr, | ||
| 584 | # if _LIBCPP_HAS_RTTI | 541 | # if _LIBCPP_HAS_RTTI |
| 585 | &typeid(_ValueType), | 542 | &typeid(_ValueType), |
| 586 | # else | 543 | # else |
| 587 | nullptr, | 544 | nullptr, |
| 588 | # endif | 545 | # endif |
| 589 | __any_imp::__get_fallback_typeid<_ValueType>()); | 546 | __any_imp::__get_fallback_typeid<_ValueType>()); |
| 590 | return std::__pointer_or_func_cast<_ReturnType>(__p, is_function<_ValueType>{}); | 547 | return static_cast<_ReturnType>(__p); |
| 548 | } | ||
| 591 | } | 549 | } |
| 592 | return nullptr; | 550 | return nullptr; |
| 593 | } | 551 | } |
| ... | @@ -613,6 +571,11 @@ _LIBCPP_POP_MACROS | ... | @@ -613,6 +571,11 @@ _LIBCPP_POP_MACROS |
| 613 | # include <type_traits> | 571 | # include <type_traits> |
| 614 | # include <variant> | 572 | # include <variant> |
| 615 | # endif | 573 | # endif |
| 574 | |||
| 575 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | ||
| 576 | # include <cstring> | ||
| 577 | # include <limits> | ||
| 578 | # endif | ||
| 616 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 579 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 617 | 580 | ||
| 618 | #endif // _LIBCPP_ANY | 581 | #endif // _LIBCPP_ANY |
lib/libcxx/include/array+88-56| ... | @@ -134,7 +134,6 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce | ... | @@ -134,7 +134,6 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce |
| 134 | # include <__type_traits/is_const.h> | 134 | # include <__type_traits/is_const.h> |
| 135 | # include <__type_traits/is_constructible.h> | 135 | # include <__type_traits/is_constructible.h> |
| 136 | # include <__type_traits/is_nothrow_constructible.h> | 136 | # include <__type_traits/is_nothrow_constructible.h> |
| 137 | # include <__type_traits/is_replaceable.h> | ||
| 138 | # include <__type_traits/is_same.h> | 137 | # include <__type_traits/is_same.h> |
| 139 | # include <__type_traits/is_swappable.h> | 138 | # include <__type_traits/is_swappable.h> |
| 140 | # include <__type_traits/is_trivially_relocatable.h> | 139 | # include <__type_traits/is_trivially_relocatable.h> |
| ... | @@ -176,7 +175,6 @@ template <class _Tp, size_t _Size> | ... | @@ -176,7 +175,6 @@ template <class _Tp, size_t _Size> |
| 176 | struct array { | 175 | struct array { |
| 177 | using __trivially_relocatable _LIBCPP_NODEBUG = | 176 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 178 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; | 177 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; |
| 179 | using __replaceable _LIBCPP_NODEBUG = __conditional_t<__is_replaceable_v<_Tp>, array, void>; | ||
| 180 | 178 | ||
| 181 | // types: | 179 | // types: |
| 182 | using __self _LIBCPP_NODEBUG = array; | 180 | using __self _LIBCPP_NODEBUG = array; |
| ... | @@ -212,28 +210,28 @@ struct array { | ... | @@ -212,28 +210,28 @@ struct array { |
| 212 | } | 210 | } |
| 213 | 211 | ||
| 214 | // iterators: | 212 | // iterators: |
| 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { | 213 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { |
| 216 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 214 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 217 | return std::__make_static_bounded_iter<_Size>(data(), data()); | 215 | return std::__make_static_bounded_iter<_Size>(data(), data()); |
| 218 | # else | 216 | # else |
| 219 | return iterator(data()); | 217 | return iterator(data()); |
| 220 | # endif | 218 | # endif |
| 221 | } | 219 | } |
| 222 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT { | 220 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT { |
| 223 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 221 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 224 | return std::__make_static_bounded_iter<_Size>(data(), data()); | 222 | return std::__make_static_bounded_iter<_Size>(data(), data()); |
| 225 | # else | 223 | # else |
| 226 | return const_iterator(data()); | 224 | return const_iterator(data()); |
| 227 | # endif | 225 | # endif |
| 228 | } | 226 | } |
| 229 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { | 227 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { |
| 230 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 228 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 231 | return std::__make_static_bounded_iter<_Size>(data() + _Size, data()); | 229 | return std::__make_static_bounded_iter<_Size>(data() + _Size, data()); |
| 232 | # else | 230 | # else |
| 233 | return iterator(data() + _Size); | 231 | return iterator(data() + _Size); |
| 234 | # endif | 232 | # endif |
| 235 | } | 233 | } |
| 236 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT { | 234 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT { |
| 237 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 235 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 238 | return std::__make_static_bounded_iter<_Size>(data() + _Size, data()); | 236 | return std::__make_static_bounded_iter<_Size>(data() + _Size, data()); |
| 239 | # else | 237 | # else |
| ... | @@ -241,62 +239,81 @@ struct array { | ... | @@ -241,62 +239,81 @@ struct array { |
| 241 | # endif | 239 | # endif |
| 242 | } | 240 | } |
| 243 | 241 | ||
| 244 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT { | 242 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT { |
| 245 | return reverse_iterator(end()); | 243 | return reverse_iterator(end()); |
| 246 | } | 244 | } |
| 247 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT { | 245 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator |
| 246 | rbegin() const _NOEXCEPT { | ||
| 248 | return const_reverse_iterator(end()); | 247 | return const_reverse_iterator(end()); |
| 249 | } | 248 | } |
| 250 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT { | 249 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT { |
| 251 | return reverse_iterator(begin()); | 250 | return reverse_iterator(begin()); |
| 252 | } | 251 | } |
| 253 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT { | 252 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT { |
| 254 | return const_reverse_iterator(begin()); | 253 | return const_reverse_iterator(begin()); |
| 255 | } | 254 | } |
| 256 | 255 | ||
| 257 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { return begin(); } | 256 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { |
| 258 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { return end(); } | 257 | return begin(); |
| 259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT { | 258 | } |
| 259 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { | ||
| 260 | return end(); | ||
| 261 | } | ||
| 262 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator | ||
| 263 | crbegin() const _NOEXCEPT { | ||
| 260 | return rbegin(); | 264 | return rbegin(); |
| 261 | } | 265 | } |
| 262 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 266 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { |
| 267 | return rend(); | ||
| 268 | } | ||
| 263 | 269 | ||
| 264 | // capacity: | 270 | // capacity: |
| 265 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; } | 271 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; } |
| 266 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; } | 272 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; } |
| 267 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; } | 273 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; } |
| 268 | 274 | ||
| 269 | // element access: | 275 | // element access: |
| 270 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT { | 276 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT { |
| 271 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>"); | 277 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>"); |
| 272 | return __elems_[__n]; | 278 | return __elems_[__n]; |
| 273 | } | 279 | } |
| 274 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference operator[](size_type __n) const _NOEXCEPT { | 280 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference |
| 281 | operator[](size_type __n) const _NOEXCEPT { | ||
| 275 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>"); | 282 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>"); |
| 276 | return __elems_[__n]; | 283 | return __elems_[__n]; |
| 277 | } | 284 | } |
| 278 | 285 | ||
| 279 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) { | 286 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) { |
| 280 | if (__n >= _Size) | 287 | if (__n >= _Size) |
| 281 | std::__throw_out_of_range("array::at"); | 288 | std::__throw_out_of_range("array::at"); |
| 282 | return __elems_[__n]; | 289 | return __elems_[__n]; |
| 283 | } | 290 | } |
| 284 | 291 | ||
| 285 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const { | 292 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const { |
| 286 | if (__n >= _Size) | 293 | if (__n >= _Size) |
| 287 | std::__throw_out_of_range("array::at"); | 294 | std::__throw_out_of_range("array::at"); |
| 288 | return __elems_[__n]; | 295 | return __elems_[__n]; |
| 289 | } | 296 | } |
| 290 | 297 | ||
| 291 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT { return (*this)[0]; } | 298 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT { |
| 292 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT { return (*this)[0]; } | 299 | return (*this)[0]; |
| 293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT { return (*this)[_Size - 1]; } | 300 | } |
| 294 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT { | 301 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT { |
| 302 | return (*this)[0]; | ||
| 303 | } | ||
| 304 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT { | ||
| 305 | return (*this)[_Size - 1]; | ||
| 306 | } | ||
| 307 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT { | ||
| 295 | return (*this)[_Size - 1]; | 308 | return (*this)[_Size - 1]; |
| 296 | } | 309 | } |
| 297 | 310 | ||
| 298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { return __elems_; } | 311 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { |
| 299 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { return __elems_; } | 312 | return __elems_; |
| 313 | } | ||
| 314 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { | ||
| 315 | return __elems_; | ||
| 316 | } | ||
| 300 | }; | 317 | }; |
| 301 | 318 | ||
| 302 | template <class _Tp> | 319 | template <class _Tp> |
| ... | @@ -330,8 +347,10 @@ struct array<_Tp, 0> { | ... | @@ -330,8 +347,10 @@ struct array<_Tp, 0> { |
| 330 | }; | 347 | }; |
| 331 | _ALIGNAS_TYPE(_ArrayInStructT) _EmptyType __elems_[sizeof(_ArrayInStructT)]; | 348 | _ALIGNAS_TYPE(_ArrayInStructT) _EmptyType __elems_[sizeof(_ArrayInStructT)]; |
| 332 | 349 | ||
| 333 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { return nullptr; } | 350 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 value_type* data() _NOEXCEPT { return nullptr; } |
| 334 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { return nullptr; } | 351 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const value_type* data() const _NOEXCEPT { |
| 352 | return nullptr; | ||
| 353 | } | ||
| 335 | 354 | ||
| 336 | // No explicit construct/copy/destroy for aggregate type | 355 | // No explicit construct/copy/destroy for aggregate type |
| 337 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void fill(const value_type&) { | 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void fill(const value_type&) { |
| ... | @@ -343,28 +362,28 @@ struct array<_Tp, 0> { | ... | @@ -343,28 +362,28 @@ struct array<_Tp, 0> { |
| 343 | } | 362 | } |
| 344 | 363 | ||
| 345 | // iterators: | 364 | // iterators: |
| 346 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { | 365 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { |
| 347 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 366 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 348 | return std::__make_static_bounded_iter<0>(data(), data()); | 367 | return std::__make_static_bounded_iter<0>(data(), data()); |
| 349 | # else | 368 | # else |
| 350 | return iterator(data()); | 369 | return iterator(data()); |
| 351 | # endif | 370 | # endif |
| 352 | } | 371 | } |
| 353 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT { | 372 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT { |
| 354 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 373 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 355 | return std::__make_static_bounded_iter<0>(data(), data()); | 374 | return std::__make_static_bounded_iter<0>(data(), data()); |
| 356 | # else | 375 | # else |
| 357 | return const_iterator(data()); | 376 | return const_iterator(data()); |
| 358 | # endif | 377 | # endif |
| 359 | } | 378 | } |
| 360 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { | 379 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { |
| 361 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 380 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 362 | return std::__make_static_bounded_iter<0>(data(), data()); | 381 | return std::__make_static_bounded_iter<0>(data(), data()); |
| 363 | # else | 382 | # else |
| 364 | return iterator(data()); | 383 | return iterator(data()); |
| 365 | # endif | 384 | # endif |
| 366 | } | 385 | } |
| 367 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT { | 386 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT { |
| 368 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | 387 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) |
| 369 | return std::__make_static_bounded_iter<0>(data(), data()); | 388 | return std::__make_static_bounded_iter<0>(data(), data()); |
| 370 | # else | 389 | # else |
| ... | @@ -372,68 +391,77 @@ struct array<_Tp, 0> { | ... | @@ -372,68 +391,77 @@ struct array<_Tp, 0> { |
| 372 | # endif | 391 | # endif |
| 373 | } | 392 | } |
| 374 | 393 | ||
| 375 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT { | 394 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT { |
| 376 | return reverse_iterator(end()); | 395 | return reverse_iterator(end()); |
| 377 | } | 396 | } |
| 378 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT { | 397 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator |
| 398 | rbegin() const _NOEXCEPT { | ||
| 379 | return const_reverse_iterator(end()); | 399 | return const_reverse_iterator(end()); |
| 380 | } | 400 | } |
| 381 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT { | 401 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rend() _NOEXCEPT { |
| 382 | return reverse_iterator(begin()); | 402 | return reverse_iterator(begin()); |
| 383 | } | 403 | } |
| 384 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT { | 404 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator rend() const _NOEXCEPT { |
| 385 | return const_reverse_iterator(begin()); | 405 | return const_reverse_iterator(begin()); |
| 386 | } | 406 | } |
| 387 | 407 | ||
| 388 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { return begin(); } | 408 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cbegin() const _NOEXCEPT { |
| 389 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { return end(); } | 409 | return begin(); |
| 390 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT { | 410 | } |
| 411 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator cend() const _NOEXCEPT { | ||
| 412 | return end(); | ||
| 413 | } | ||
| 414 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator | ||
| 415 | crbegin() const _NOEXCEPT { | ||
| 391 | return rbegin(); | 416 | return rbegin(); |
| 392 | } | 417 | } |
| 393 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 418 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_reverse_iterator crend() const _NOEXCEPT { |
| 419 | return rend(); | ||
| 420 | } | ||
| 394 | 421 | ||
| 395 | // capacity: | 422 | // capacity: |
| 396 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; } | 423 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; } |
| 397 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; } | 424 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; } |
| 398 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } | 425 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } |
| 399 | 426 | ||
| 400 | // element access: | 427 | // element access: |
| 401 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT { | 428 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT { |
| 402 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); | 429 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); |
| 403 | __libcpp_unreachable(); | 430 | __libcpp_unreachable(); |
| 404 | } | 431 | } |
| 405 | 432 | ||
| 406 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference operator[](size_type) const _NOEXCEPT { | 433 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference |
| 434 | operator[](size_type) const _NOEXCEPT { | ||
| 407 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); | 435 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); |
| 408 | __libcpp_unreachable(); | 436 | __libcpp_unreachable(); |
| 409 | } | 437 | } |
| 410 | 438 | ||
| 411 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) { | 439 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) { |
| 412 | std::__throw_out_of_range("array<T, 0>::at"); | 440 | std::__throw_out_of_range("array<T, 0>::at"); |
| 413 | __libcpp_unreachable(); | 441 | __libcpp_unreachable(); |
| 414 | } | 442 | } |
| 415 | 443 | ||
| 416 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const { | 444 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const { |
| 417 | std::__throw_out_of_range("array<T, 0>::at"); | 445 | std::__throw_out_of_range("array<T, 0>::at"); |
| 418 | __libcpp_unreachable(); | 446 | __libcpp_unreachable(); |
| 419 | } | 447 | } |
| 420 | 448 | ||
| 421 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT { | 449 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT { |
| 422 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array"); | 450 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array"); |
| 423 | __libcpp_unreachable(); | 451 | __libcpp_unreachable(); |
| 424 | } | 452 | } |
| 425 | 453 | ||
| 426 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT { | 454 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT { |
| 427 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array"); | 455 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array"); |
| 428 | __libcpp_unreachable(); | 456 | __libcpp_unreachable(); |
| 429 | } | 457 | } |
| 430 | 458 | ||
| 431 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT { | 459 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT { |
| 432 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array"); | 460 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array"); |
| 433 | __libcpp_unreachable(); | 461 | __libcpp_unreachable(); |
| 434 | } | 462 | } |
| 435 | 463 | ||
| 436 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT { | 464 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT { |
| 437 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array"); | 465 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array"); |
| 438 | __libcpp_unreachable(); | 466 | __libcpp_unreachable(); |
| 439 | } | 467 | } |
| ... | @@ -503,25 +531,29 @@ struct tuple_element<_Ip, array<_Tp, _Size> > { | ... | @@ -503,25 +531,29 @@ struct tuple_element<_Ip, array<_Tp, _Size> > { |
| 503 | }; | 531 | }; |
| 504 | 532 | ||
| 505 | template <size_t _Ip, class _Tp, size_t _Size> | 533 | template <size_t _Ip, class _Tp, size_t _Size> |
| 506 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT { | 534 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& |
| 535 | get(array<_Tp, _Size>& __a) _NOEXCEPT { | ||
| 507 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)"); | 536 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)"); |
| 508 | return __a.__elems_[_Ip]; | 537 | return __a.__elems_[_Ip]; |
| 509 | } | 538 | } |
| 510 | 539 | ||
| 511 | template <size_t _Ip, class _Tp, size_t _Size> | 540 | template <size_t _Ip, class _Tp, size_t _Size> |
| 512 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT { | 541 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& |
| 542 | get(const array<_Tp, _Size>& __a) _NOEXCEPT { | ||
| 513 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)"); | 543 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)"); |
| 514 | return __a.__elems_[_Ip]; | 544 | return __a.__elems_[_Ip]; |
| 515 | } | 545 | } |
| 516 | 546 | ||
| 517 | template <size_t _Ip, class _Tp, size_t _Size> | 547 | template <size_t _Ip, class _Tp, size_t _Size> |
| 518 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT { | 548 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& |
| 549 | get(array<_Tp, _Size>&& __a) _NOEXCEPT { | ||
| 519 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)"); | 550 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)"); |
| 520 | return std::move(__a.__elems_[_Ip]); | 551 | return std::move(__a.__elems_[_Ip]); |
| 521 | } | 552 | } |
| 522 | 553 | ||
| 523 | template <size_t _Ip, class _Tp, size_t _Size> | 554 | template <size_t _Ip, class _Tp, size_t _Size> |
| 524 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&& __a) _NOEXCEPT { | 555 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& |
| 556 | get(const array<_Tp, _Size>&& __a) _NOEXCEPT { | ||
| 525 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)"); | 557 | static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)"); |
| 526 | return std::move(__a.__elems_[_Ip]); | 558 | return std::move(__a.__elems_[_Ip]); |
| 527 | } | 559 | } |
| ... | @@ -541,7 +573,7 @@ __to_array_rvalue_impl(_Tp (&&__arr)[_Size], index_sequence<_Index...>) { | ... | @@ -541,7 +573,7 @@ __to_array_rvalue_impl(_Tp (&&__arr)[_Size], index_sequence<_Index...>) { |
| 541 | } | 573 | } |
| 542 | 574 | ||
| 543 | template <typename _Tp, size_t _Size> | 575 | template <typename _Tp, size_t _Size> |
| 544 | _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size> | 576 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size> |
| 545 | to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) { | 577 | to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) { |
| 546 | static_assert(!is_array_v<_Tp>, "[array.creation]/1: to_array does not accept multidimensional arrays."); | 578 | static_assert(!is_array_v<_Tp>, "[array.creation]/1: to_array does not accept multidimensional arrays."); |
| 547 | static_assert(is_constructible_v<_Tp, _Tp&>, "[array.creation]/1: to_array requires copy constructible elements."); | 579 | static_assert(is_constructible_v<_Tp, _Tp&>, "[array.creation]/1: to_array requires copy constructible elements."); |
| ... | @@ -549,7 +581,7 @@ to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) { | ... | @@ -549,7 +581,7 @@ to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) { |
| 549 | } | 581 | } |
| 550 | 582 | ||
| 551 | template <typename _Tp, size_t _Size> | 583 | template <typename _Tp, size_t _Size> |
| 552 | _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size> | 584 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size> |
| 553 | to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) { | 585 | to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) { |
| 554 | static_assert(!is_array_v<_Tp>, "[array.creation]/4: to_array does not accept multidimensional arrays."); | 586 | static_assert(!is_array_v<_Tp>, "[array.creation]/4: to_array does not accept multidimensional arrays."); |
| 555 | static_assert(is_move_constructible_v<_Tp>, "[array.creation]/4: to_array requires move constructible elements."); | 587 | static_assert(is_move_constructible_v<_Tp>, "[array.creation]/4: to_array requires move constructible elements."); |
lib/libcxx/include/atomic+2| ... | @@ -608,6 +608,8 @@ template <class T> | ... | @@ -608,6 +608,8 @@ template <class T> |
| 608 | # include <__atomic/atomic_init.h> | 608 | # include <__atomic/atomic_init.h> |
| 609 | # include <__atomic/atomic_lock_free.h> | 609 | # include <__atomic/atomic_lock_free.h> |
| 610 | # include <__atomic/atomic_sync.h> | 610 | # include <__atomic/atomic_sync.h> |
| 611 | # include <__atomic/atomic_sync_timed.h> | ||
| 612 | # include <__atomic/atomic_waitable_traits.h> | ||
| 611 | # include <__atomic/check_memory_order.h> | 613 | # include <__atomic/check_memory_order.h> |
| 612 | # include <__atomic/contention_t.h> | 614 | # include <__atomic/contention_t.h> |
| 613 | # include <__atomic/fence.h> | 615 | # include <__atomic/fence.h> |
lib/libcxx/include/barrier+20-24| ... | @@ -57,8 +57,6 @@ namespace std | ... | @@ -57,8 +57,6 @@ namespace std |
| 57 | # include <__atomic/memory_order.h> | 57 | # include <__atomic/memory_order.h> |
| 58 | # include <__cstddef/ptrdiff_t.h> | 58 | # include <__cstddef/ptrdiff_t.h> |
| 59 | # include <__memory/unique_ptr.h> | 59 | # include <__memory/unique_ptr.h> |
| 60 | # include <__thread/poll_with_backoff.h> | ||
| 61 | # include <__thread/timed_backoff_policy.h> | ||
| 62 | # include <__utility/move.h> | 60 | # include <__utility/move.h> |
| 63 | # include <cstdint> | 61 | # include <cstdint> |
| 64 | # include <limits> | 62 | # include <limits> |
| ... | @@ -97,19 +95,20 @@ using __barrier_phase_t _LIBCPP_NODEBUG = uint8_t; | ... | @@ -97,19 +95,20 @@ using __barrier_phase_t _LIBCPP_NODEBUG = uint8_t; |
| 97 | 95 | ||
| 98 | class __barrier_algorithm_base; | 96 | class __barrier_algorithm_base; |
| 99 | 97 | ||
| 100 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* | 98 | [[__gnu__::__returns_nonnull__, __gnu__::__malloc__]] |
| 101 | __construct_barrier_algorithm_base(ptrdiff_t& __expected); | 99 | _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected); |
| 102 | 100 | ||
| 103 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI bool | 101 | _LIBCPP_EXPORTED_FROM_ABI bool |
| 104 | __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept; | 102 | __arrive_barrier_algorithm_base([[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier, |
| 103 | __barrier_phase_t __old_phase) noexcept; | ||
| 105 | 104 | ||
| 106 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void | 105 | _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base( |
| 107 | __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept; | 106 | [[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier) noexcept; |
| 108 | 107 | ||
| 109 | template <class _CompletionF> | 108 | template <class _CompletionF> |
| 110 | class __barrier_base { | 109 | class __barrier_base { |
| 111 | ptrdiff_t __expected_; | 110 | ptrdiff_t __expected_; |
| 112 | unique_ptr<__barrier_algorithm_base, void (*)(__barrier_algorithm_base*)> __base_; | 111 | unique_ptr<__barrier_algorithm_base, void (*)(_LIBCPP_NOESCAPE __barrier_algorithm_base*)> __base_; |
| 113 | atomic<ptrdiff_t> __expected_adjustment_; | 112 | atomic<ptrdiff_t> __expected_adjustment_; |
| 114 | _CompletionF __completion_; | 113 | _CompletionF __completion_; |
| 115 | atomic<__barrier_phase_t> __phase_; | 114 | atomic<__barrier_phase_t> __phase_; |
| ... | @@ -119,14 +118,13 @@ public: | ... | @@ -119,14 +118,13 @@ public: |
| 119 | 118 | ||
| 120 | static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); } | 119 | static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); } |
| 121 | 120 | ||
| 122 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI | 121 | _LIBCPP_HIDE_FROM_ABI __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) |
| 123 | __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) | ||
| 124 | : __expected_(__expected), | 122 | : __expected_(__expected), |
| 125 | __base_(std::__construct_barrier_algorithm_base(this->__expected_), &__destroy_barrier_algorithm_base), | 123 | __base_(std::__construct_barrier_algorithm_base(this->__expected_), &__destroy_barrier_algorithm_base), |
| 126 | __expected_adjustment_(0), | 124 | __expected_adjustment_(0), |
| 127 | __completion_(std::move(__completion)), | 125 | __completion_(std::move(__completion)), |
| 128 | __phase_(0) {} | 126 | __phase_(0) {} |
| 129 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { | 127 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { |
| 130 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 128 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 131 | __update <= __expected_, "update is greater than the expected count for the current barrier phase"); | 129 | __update <= __expected_, "update is greater than the expected count for the current barrier phase"); |
| 132 | 130 | ||
| ... | @@ -141,11 +139,10 @@ public: | ... | @@ -141,11 +139,10 @@ public: |
| 141 | } | 139 | } |
| 142 | return __old_phase; | 140 | return __old_phase; |
| 143 | } | 141 | } |
| 144 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __old_phase) const { | 142 | _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __old_phase) const { |
| 145 | auto const __test_fn = [this, __old_phase]() -> bool { return __phase_.load(memory_order_acquire) != __old_phase; }; | 143 | __phase_.wait(__old_phase, std::memory_order_acquire); |
| 146 | std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy()); | ||
| 147 | } | 144 | } |
| 148 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() { | 145 | _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() { |
| 149 | __expected_adjustment_.fetch_sub(1, memory_order_relaxed); | 146 | __expected_adjustment_.fetch_sub(1, memory_order_relaxed); |
| 150 | (void)arrive(1); | 147 | (void)arrive(1); |
| 151 | } | 148 | } |
| ... | @@ -158,9 +155,10 @@ class barrier { | ... | @@ -158,9 +155,10 @@ class barrier { |
| 158 | public: | 155 | public: |
| 159 | using arrival_token = typename __barrier_base<_CompletionF>::arrival_token; | 156 | using arrival_token = typename __barrier_base<_CompletionF>::arrival_token; |
| 160 | 157 | ||
| 161 | static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return __barrier_base<_CompletionF>::max(); } | 158 | [[nodiscard]] static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { |
| 159 | return __barrier_base<_CompletionF>::max(); | ||
| 160 | } | ||
| 162 | 161 | ||
| 163 | _LIBCPP_AVAILABILITY_SYNC | ||
| 164 | _LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF()) | 162 | _LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF()) |
| 165 | : __b_(__count, std::move(__completion)) { | 163 | : __b_(__count, std::move(__completion)) { |
| 166 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 164 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| ... | @@ -175,15 +173,13 @@ public: | ... | @@ -175,15 +173,13 @@ public: |
| 175 | barrier(barrier const&) = delete; | 173 | barrier(barrier const&) = delete; |
| 176 | barrier& operator=(barrier const&) = delete; | 174 | barrier& operator=(barrier const&) = delete; |
| 177 | 175 | ||
| 178 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { | 176 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { |
| 179 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0"); | 177 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0"); |
| 180 | return __b_.arrive(__update); | 178 | return __b_.arrive(__update); |
| 181 | } | 179 | } |
| 182 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __phase) const { | 180 | _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __phase) const { __b_.wait(std::move(__phase)); } |
| 183 | __b_.wait(std::move(__phase)); | 181 | _LIBCPP_HIDE_FROM_ABI void arrive_and_wait() { wait(arrive()); } |
| 184 | } | 182 | _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() { __b_.arrive_and_drop(); } |
| 185 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait() { wait(arrive()); } | ||
| 186 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() { __b_.arrive_and_drop(); } | ||
| 187 | }; | 183 | }; |
| 188 | 184 | ||
| 189 | _LIBCPP_END_NAMESPACE_STD | 185 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/bitset+49-30| ... | @@ -147,7 +147,6 @@ template <size_t N> struct hash<std::bitset<N>>; | ... | @@ -147,7 +147,6 @@ template <size_t N> struct hash<std::bitset<N>>; |
| 147 | # include <__functional/hash.h> | 147 | # include <__functional/hash.h> |
| 148 | # include <__functional/identity.h> | 148 | # include <__functional/identity.h> |
| 149 | # include <__functional/unary_function.h> | 149 | # include <__functional/unary_function.h> |
| 150 | # include <__tuple/tuple_indices.h> | ||
| 151 | # include <__type_traits/enable_if.h> | 150 | # include <__type_traits/enable_if.h> |
| 152 | # include <__type_traits/integral_constant.h> | 151 | # include <__type_traits/integral_constant.h> |
| 153 | # include <__type_traits/is_char_like_type.h> | 152 | # include <__type_traits/is_char_like_type.h> |
| ... | @@ -314,7 +313,7 @@ private: | ... | @@ -314,7 +313,7 @@ private: |
| 314 | _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT; | 313 | _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT; |
| 315 | # else | 314 | # else |
| 316 | template <size_t... _Indices> | 315 | template <size_t... _Indices> |
| 317 | _LIBCPP_HIDE_FROM_ABI constexpr __bitset(unsigned long long __v, std::__tuple_indices<_Indices...>) _NOEXCEPT | 316 | _LIBCPP_HIDE_FROM_ABI constexpr __bitset(unsigned long long __v, __index_sequence<_Indices...>) _NOEXCEPT |
| 318 | : __first_{static_cast<__storage_type>(__v >> (_Indices * __bits_per_word))...} {} | 317 | : __first_{static_cast<__storage_type>(__v >> (_Indices * __bits_per_word))...} {} |
| 319 | # endif // _LIBCPP_CXX03_LANG | 318 | # endif // _LIBCPP_CXX03_LANG |
| 320 | }; | 319 | }; |
| ... | @@ -352,10 +351,9 @@ template <size_t _N_words, size_t _Size> | ... | @@ -352,10 +351,9 @@ template <size_t _N_words, size_t _Size> |
| 352 | inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT | 351 | inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT |
| 353 | # ifndef _LIBCPP_CXX03_LANG | 352 | # ifndef _LIBCPP_CXX03_LANG |
| 354 | : __bitset(__v, | 353 | : __bitset(__v, |
| 355 | std::__make_indices_imp< (_N_words < (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1) | 354 | __make_index_sequence<(_N_words < (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1) |
| 356 | ? _N_words | 355 | ? _N_words |
| 357 | : (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1, | 356 | : (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1>()) |
| 358 | 0>{}) | ||
| 359 | # endif | 357 | # endif |
| 360 | { | 358 | { |
| 361 | # ifdef _LIBCPP_CXX03_LANG | 359 | # ifdef _LIBCPP_CXX03_LANG |
| ... | @@ -677,53 +675,63 @@ public: | ... | @@ -677,53 +675,63 @@ public: |
| 677 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& set(size_t __pos, bool __val = true); | 675 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& set(size_t __pos, bool __val = true); |
| 678 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset() _NOEXCEPT; | 676 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset() _NOEXCEPT; |
| 679 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset(size_t __pos); | 677 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset(size_t __pos); |
| 680 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator~() const _NOEXCEPT; | 678 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator~() const _NOEXCEPT; |
| 681 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip() _NOEXCEPT; | 679 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip() _NOEXCEPT; |
| 682 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos); | 680 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos); |
| 683 | 681 | ||
| 684 | // element access: | 682 | // element access: |
| 685 | # ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | 683 | // TODO(LLVM 24): Remove the opt-out |
| 686 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { | 684 | # ifndef _LIBCPP_DEPRECATED_ABI_BITSET_CONST_SUBSCRIPT_RETURN_REF |
| 685 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { | ||
| 687 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); | 686 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); |
| 688 | return __base::__make_ref(__p); | 687 | return __base::__make_ref(__p); |
| 689 | } | 688 | } |
| 690 | # else | 689 | # else |
| 691 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference operator[](size_t __p) const { | 690 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference operator[](size_t __p) const { |
| 692 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); | 691 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); |
| 693 | return __base::__make_ref(__p); | 692 | return __base::__make_ref(__p); |
| 694 | } | 693 | } |
| 695 | # endif | 694 | # endif |
| 696 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) { | 695 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) { |
| 697 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); | 696 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); |
| 698 | return __base::__make_ref(__p); | 697 | return __base::__make_ref(__p); |
| 699 | } | 698 | } |
| 700 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return __base::to_ulong(); } | 699 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { |
| 701 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { | 700 | return __base::to_ulong(); |
| 701 | } | ||
| 702 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { | ||
| 702 | return __base::to_ullong(); | 703 | return __base::to_ullong(); |
| 703 | } | 704 | } |
| 704 | template <class _CharT, class _Traits, class _Allocator> | 705 | template <class _CharT, class _Traits, class _Allocator> |
| 705 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> | 706 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> |
| 706 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; | 707 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; |
| 707 | template <class _CharT, class _Traits> | 708 | template <class _CharT, class _Traits> |
| 708 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> > | 709 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI |
| 710 | _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> > | ||
| 709 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; | 711 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; |
| 710 | template <class _CharT> | 712 | template <class _CharT> |
| 711 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > | 713 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI |
| 714 | _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > | ||
| 712 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; | 715 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; |
| 713 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<char, char_traits<char>, allocator<char> > | 716 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI |
| 717 | _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<char, char_traits<char>, allocator<char> > | ||
| 714 | to_string(char __zero = '0', char __one = '1') const; | 718 | to_string(char __zero = '0', char __one = '1') const; |
| 715 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT; | 719 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT; |
| 716 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; } | 720 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; } |
| 717 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT; | 721 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT; |
| 718 | # if _LIBCPP_STD_VER <= 17 | 722 | # if _LIBCPP_STD_VER <= 17 |
| 719 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT; | 723 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT; |
| 720 | # endif | 724 | # endif |
| 721 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const; | 725 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const; |
| 722 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return __base::all(); } | 726 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { |
| 723 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return __base::any(); } | 727 | return __base::all(); |
| 724 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); } | 728 | } |
| 725 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT; | 729 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { |
| 726 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT; | 730 | return __base::any(); |
| 731 | } | ||
| 732 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); } | ||
| 733 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT; | ||
| 734 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT; | ||
| 727 | 735 | ||
| 728 | private: | 736 | private: |
| 729 | template <class _CharT, class _Traits> | 737 | template <class _CharT, class _Traits> |
| ... | @@ -869,7 +877,16 @@ bitset<_Size>::to_string(char __zero, char __one) const { | ... | @@ -869,7 +877,16 @@ bitset<_Size>::to_string(char __zero, char __one) const { |
| 869 | 877 | ||
| 870 | template <size_t _Size> | 878 | template <size_t _Size> |
| 871 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT { | 879 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT { |
| 872 | return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true)); | 880 | # if defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) |
| 881 | if constexpr (_Size == 0) { | ||
| 882 | return 0; | ||
| 883 | } else if constexpr (_Size <= __base::__bits_per_word) { | ||
| 884 | return __builtin_popcountg(static_cast<unsigned _BitInt(_Size)>(__base::__first_)); | ||
| 885 | } else | ||
| 886 | # endif | ||
| 887 | { | ||
| 888 | return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true)); | ||
| 889 | } | ||
| 873 | } | 890 | } |
| 874 | 891 | ||
| 875 | template <size_t _Size> | 892 | template <size_t _Size> |
| ... | @@ -912,7 +929,7 @@ bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT { | ... | @@ -912,7 +929,7 @@ bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT { |
| 912 | } | 929 | } |
| 913 | 930 | ||
| 914 | template <size_t _Size> | 931 | template <size_t _Size> |
| 915 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> | 932 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> |
| 916 | operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { | 933 | operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { |
| 917 | bitset<_Size> __r = __x; | 934 | bitset<_Size> __r = __x; |
| 918 | __r &= __y; | 935 | __r &= __y; |
| ... | @@ -920,7 +937,7 @@ operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { | ... | @@ -920,7 +937,7 @@ operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { |
| 920 | } | 937 | } |
| 921 | 938 | ||
| 922 | template <size_t _Size> | 939 | template <size_t _Size> |
| 923 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> | 940 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> |
| 924 | operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { | 941 | operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { |
| 925 | bitset<_Size> __r = __x; | 942 | bitset<_Size> __r = __x; |
| 926 | __r |= __y; | 943 | __r |= __y; |
| ... | @@ -928,7 +945,7 @@ operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { | ... | @@ -928,7 +945,7 @@ operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { |
| 928 | } | 945 | } |
| 929 | 946 | ||
| 930 | template <size_t _Size> | 947 | template <size_t _Size> |
| 931 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> | 948 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> |
| 932 | operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { | 949 | operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { |
| 933 | bitset<_Size> __r = __x; | 950 | bitset<_Size> __r = __x; |
| 934 | __r ^= __y; | 951 | __r ^= __y; |
| ... | @@ -937,7 +954,9 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { | ... | @@ -937,7 +954,9 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { |
| 937 | 954 | ||
| 938 | template <size_t _Size> | 955 | template <size_t _Size> |
| 939 | struct hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> { | 956 | struct hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> { |
| 940 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { return __bs.__hash_code(); } | 957 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { |
| 958 | return __bs.__hash_code(); | ||
| 959 | } | ||
| 941 | }; | 960 | }; |
| 942 | 961 | ||
| 943 | template <class _CharT, class _Traits, size_t _Size> | 962 | template <class _CharT, class _Traits, size_t _Size> |
lib/libcxx/include/ccomplex+3-11| ... | @@ -26,18 +26,10 @@ | ... | @@ -26,18 +26,10 @@ |
| 26 | # pragma GCC system_header | 26 | # pragma GCC system_header |
| 27 | # endif | 27 | # endif |
| 28 | 28 | ||
| 29 | # if _LIBCPP_STD_VER >= 20 | 29 | # if _LIBCPP_STD_VER >= 17 && !__building_module(std) && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS |
| 30 | 30 | # warning <ccomplex> is deprecated in C++17 and removed in C++20. Include <complex> instead. | |
| 31 | using __standard_header_ccomplex | ||
| 32 | _LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.") _LIBCPP_NODEBUG = void; | ||
| 33 | using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex; | ||
| 34 | |||
| 35 | # elif _LIBCPP_STD_VER >= 17 | ||
| 36 | |||
| 37 | using __standard_header_ccomplex _LIBCPP_DEPRECATED_("Include <complex> instead.") _LIBCPP_NODEBUG = void; | ||
| 38 | using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex; | ||
| 39 | |||
| 40 | # endif | 31 | # endif |
| 32 | |||
| 41 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 33 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 42 | 34 | ||
| 43 | #endif // _LIBCPP_CCOMPLEX | 35 | #endif // _LIBCPP_CCOMPLEX |
lib/libcxx/include/chrono+47| ... | @@ -218,6 +218,9 @@ template <class ToDuration, class Rep, class Period> | ... | @@ -218,6 +218,9 @@ template <class ToDuration, class Rep, class Period> |
| 218 | template <class ToDuration, class Rep, class Period> | 218 | template <class ToDuration, class Rep, class Period> |
| 219 | constexpr ToDuration round(const duration<Rep, Period>& d); // C++17 | 219 | constexpr ToDuration round(const duration<Rep, Period>& d); // C++17 |
| 220 | 220 | ||
| 221 | template <class T> struct is_clock; // C++20 | ||
| 222 | template <class T> inline constexpr bool is_clock_v = is_clock<T>::value; // C++20 | ||
| 223 | |||
| 221 | // duration I/O | 224 | // duration I/O |
| 222 | template<class charT, class traits, class Rep, class Period> // C++20 | 225 | template<class charT, class traits, class Rep, class Period> // C++20 |
| 223 | basic_ostream<charT, traits>& | 226 | basic_ostream<charT, traits>& |
| ... | @@ -1035,6 +1038,49 @@ constexpr chrono::year operator ""y(unsigned lo | ... | @@ -1035,6 +1038,49 @@ constexpr chrono::year operator ""y(unsigned lo |
| 1035 | } // chrono_literals | 1038 | } // chrono_literals |
| 1036 | } // literals | 1039 | } // literals |
| 1037 | 1040 | ||
| 1041 | namespace std { | ||
| 1042 | template<class T> | ||
| 1043 | struct hash; // C++26 | ||
| 1044 | template<class Rep, class Period> | ||
| 1045 | struct hash<chrono::duration<Rep, Period>>; // C++26 | ||
| 1046 | template<class Clock, class Duration> | ||
| 1047 | struct hash<chrono::time_point<Clock, Duration>>; // C++26 | ||
| 1048 | template<> | ||
| 1049 | struct hash<chrono::day>; // C++26 | ||
| 1050 | template<> | ||
| 1051 | struct hash<chrono::month>; // C++26 | ||
| 1052 | template<> | ||
| 1053 | struct hash<chrono::year>; // C++26 | ||
| 1054 | template<> | ||
| 1055 | struct hash<chrono::weekday>; // C++26 | ||
| 1056 | template<> | ||
| 1057 | struct hash<chrono::weekday_indexed>; // C++26 | ||
| 1058 | template<> | ||
| 1059 | struct hash<chrono::weekday_last>; // C++26 | ||
| 1060 | template<> | ||
| 1061 | struct hash<chrono::month_day>; // C++26 | ||
| 1062 | template<> | ||
| 1063 | struct hash<chrono::month_day_last>; // C++26 | ||
| 1064 | template<> | ||
| 1065 | struct hash<chrono::month_weekday>; // C++26 | ||
| 1066 | template<> | ||
| 1067 | struct hash<chrono::month_weekday_last>; // C++26 | ||
| 1068 | template<> | ||
| 1069 | struct hash<chrono::year_month>; // C++26 | ||
| 1070 | template<> | ||
| 1071 | struct hash<chrono::year_month_day>; // C++26 | ||
| 1072 | template<> | ||
| 1073 | struct hash<chrono::year_month_day_last>; // C++26 | ||
| 1074 | template<> | ||
| 1075 | struct hash<chrono::year_month_weekday>; // C++26 | ||
| 1076 | template<> | ||
| 1077 | struct hash<chrono::year_month_weekday_last>; // C++26 | ||
| 1078 | template<class Duration, class TimeZonePtr> | ||
| 1079 | struct hash<chrono::zoned_time<Duration, TimeZonePtr>>; // C++26 | ||
| 1080 | template<> | ||
| 1081 | struct hash<chrono::leap_second>; // C++26 | ||
| 1082 | } // namespace std | ||
| 1083 | |||
| 1038 | } // std | 1084 | } // std |
| 1039 | */ | 1085 | */ |
| 1040 | 1086 | ||
| ... | @@ -1057,6 +1103,7 @@ constexpr chrono::year operator ""y(unsigned lo | ... | @@ -1057,6 +1103,7 @@ constexpr chrono::year operator ""y(unsigned lo |
| 1057 | # include <__chrono/day.h> | 1103 | # include <__chrono/day.h> |
| 1058 | # include <__chrono/exception.h> | 1104 | # include <__chrono/exception.h> |
| 1059 | # include <__chrono/hh_mm_ss.h> | 1105 | # include <__chrono/hh_mm_ss.h> |
| 1106 | # include <__chrono/is_clock.h> | ||
| 1060 | # include <__chrono/literals.h> | 1107 | # include <__chrono/literals.h> |
| 1061 | # include <__chrono/local_info.h> | 1108 | # include <__chrono/local_info.h> |
| 1062 | # include <__chrono/month.h> | 1109 | # include <__chrono/month.h> |
lib/libcxx/include/ciso646+3-6| ... | @@ -24,13 +24,10 @@ | ... | @@ -24,13 +24,10 @@ |
| 24 | # pragma GCC system_header | 24 | # pragma GCC system_header |
| 25 | # endif | 25 | # endif |
| 26 | 26 | ||
| 27 | # if _LIBCPP_STD_VER >= 20 | 27 | # if _LIBCPP_STD_VER >= 20 && !__building_module(std) && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS |
| 28 | 28 | # warning <ciso646> is removed in C++20. Include <version> instead. | |
| 29 | using __standard_header_ciso646 | ||
| 30 | _LIBCPP_DEPRECATED_("removed in C++20. Include <version> instead.") _LIBCPP_NODEBUG = void; | ||
| 31 | using __use_standard_header_ciso646 _LIBCPP_NODEBUG = __standard_header_ciso646; | ||
| 32 | |||
| 33 | # endif | 29 | # endif |
| 30 | |||
| 34 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 31 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 35 | 32 | ||
| 36 | #endif // _LIBCPP_CISO646 | 33 | #endif // _LIBCPP_CISO646 |
lib/libcxx/include/complex+77-65| ... | @@ -319,8 +319,8 @@ public: | ... | @@ -319,8 +319,8 @@ public: |
| 319 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 complex(const complex<_Xp>& __c) | 319 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 complex(const complex<_Xp>& __c) |
| 320 | : __re_(__c.real()), __im_(__c.imag()) {} | 320 | : __re_(__c.real()), __im_(__c.imag()) {} |
| 321 | 321 | ||
| 322 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type real() const { return __re_; } | 322 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type real() const { return __re_; } |
| 323 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type imag() const { return __im_; } | 323 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type imag() const { return __im_; } |
| 324 | 324 | ||
| 325 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } | 325 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } |
| 326 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } | 326 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } |
| ... | @@ -432,8 +432,8 @@ public: | ... | @@ -432,8 +432,8 @@ public: |
| 432 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c); | 432 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c); |
| 433 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); | 433 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); |
| 434 | 434 | ||
| 435 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float real() const { return __re_; } | 435 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float real() const { return __re_; } |
| 436 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float imag() const { return __im_; } | 436 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float imag() const { return __im_; } |
| 437 | 437 | ||
| 438 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } | 438 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } |
| 439 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } | 439 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } |
| ... | @@ -529,8 +529,8 @@ public: | ... | @@ -529,8 +529,8 @@ public: |
| 529 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); | 529 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); |
| 530 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); | 530 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c); |
| 531 | 531 | ||
| 532 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double real() const { return __re_; } | 532 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double real() const { return __re_; } |
| 533 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double imag() const { return __im_; } | 533 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double imag() const { return __im_; } |
| 534 | 534 | ||
| 535 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } | 535 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } |
| 536 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } | 536 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } |
| ... | @@ -630,8 +630,8 @@ public: | ... | @@ -630,8 +630,8 @@ public: |
| 630 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); | 630 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c); |
| 631 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<double>& __c); | 631 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<double>& __c); |
| 632 | 632 | ||
| 633 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double real() const { return __re_; } | 633 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double real() const { return __re_; } |
| 634 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double imag() const { return __im_; } | 634 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double imag() const { return __im_; } |
| 635 | 635 | ||
| 636 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } | 636 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; } |
| 637 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } | 637 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; } |
| ... | @@ -732,7 +732,7 @@ inline _LIBCPP_CONSTEXPR complex<long double>::complex(const complex<double>& __ | ... | @@ -732,7 +732,7 @@ inline _LIBCPP_CONSTEXPR complex<long double>::complex(const complex<double>& __ |
| 732 | // 26.3.6 operators: | 732 | // 26.3.6 operators: |
| 733 | 733 | ||
| 734 | template <class _Tp> | 734 | template <class _Tp> |
| 735 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 735 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 736 | operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { | 736 | operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { |
| 737 | complex<_Tp> __t(__x); | 737 | complex<_Tp> __t(__x); |
| 738 | __t += __y; | 738 | __t += __y; |
| ... | @@ -740,7 +740,7 @@ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { | ... | @@ -740,7 +740,7 @@ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) { |
| 740 | } | 740 | } |
| 741 | 741 | ||
| 742 | template <class _Tp> | 742 | template <class _Tp> |
| 743 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 743 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 744 | operator+(const complex<_Tp>& __x, const _Tp& __y) { | 744 | operator+(const complex<_Tp>& __x, const _Tp& __y) { |
| 745 | complex<_Tp> __t(__x); | 745 | complex<_Tp> __t(__x); |
| 746 | __t += __y; | 746 | __t += __y; |
| ... | @@ -748,7 +748,7 @@ operator+(const complex<_Tp>& __x, const _Tp& __y) { | ... | @@ -748,7 +748,7 @@ operator+(const complex<_Tp>& __x, const _Tp& __y) { |
| 748 | } | 748 | } |
| 749 | 749 | ||
| 750 | template <class _Tp> | 750 | template <class _Tp> |
| 751 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 751 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 752 | operator+(const _Tp& __x, const complex<_Tp>& __y) { | 752 | operator+(const _Tp& __x, const complex<_Tp>& __y) { |
| 753 | complex<_Tp> __t(__y); | 753 | complex<_Tp> __t(__y); |
| 754 | __t += __x; | 754 | __t += __x; |
| ... | @@ -756,7 +756,7 @@ operator+(const _Tp& __x, const complex<_Tp>& __y) { | ... | @@ -756,7 +756,7 @@ operator+(const _Tp& __x, const complex<_Tp>& __y) { |
| 756 | } | 756 | } |
| 757 | 757 | ||
| 758 | template <class _Tp> | 758 | template <class _Tp> |
| 759 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 759 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 760 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { | 760 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { |
| 761 | complex<_Tp> __t(__x); | 761 | complex<_Tp> __t(__x); |
| 762 | __t -= __y; | 762 | __t -= __y; |
| ... | @@ -764,7 +764,7 @@ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { | ... | @@ -764,7 +764,7 @@ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) { |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | template <class _Tp> | 766 | template <class _Tp> |
| 767 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 767 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 768 | operator-(const complex<_Tp>& __x, const _Tp& __y) { | 768 | operator-(const complex<_Tp>& __x, const _Tp& __y) { |
| 769 | complex<_Tp> __t(__x); | 769 | complex<_Tp> __t(__x); |
| 770 | __t -= __y; | 770 | __t -= __y; |
| ... | @@ -772,7 +772,7 @@ operator-(const complex<_Tp>& __x, const _Tp& __y) { | ... | @@ -772,7 +772,7 @@ operator-(const complex<_Tp>& __x, const _Tp& __y) { |
| 772 | } | 772 | } |
| 773 | 773 | ||
| 774 | template <class _Tp> | 774 | template <class _Tp> |
| 775 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 775 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 776 | operator-(const _Tp& __x, const complex<_Tp>& __y) { | 776 | operator-(const _Tp& __x, const complex<_Tp>& __y) { |
| 777 | complex<_Tp> __t(-__y); | 777 | complex<_Tp> __t(-__y); |
| 778 | __t += __x; | 778 | __t += __x; |
| ... | @@ -780,13 +780,13 @@ operator-(const _Tp& __x, const complex<_Tp>& __y) { | ... | @@ -780,13 +780,13 @@ operator-(const _Tp& __x, const complex<_Tp>& __y) { |
| 780 | } | 780 | } |
| 781 | 781 | ||
| 782 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > | 782 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > |
| 783 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 783 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 784 | operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { | 784 | operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { |
| 785 | return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() * __rhs.__builtin()); | 785 | return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() * __rhs.__builtin()); |
| 786 | } | 786 | } |
| 787 | 787 | ||
| 788 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > | 788 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > |
| 789 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 789 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 790 | operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { | 790 | operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { |
| 791 | _Tp __a = __z.real(); | 791 | _Tp __a = __z.real(); |
| 792 | _Tp __b = __z.imag(); | 792 | _Tp __b = __z.imag(); |
| ... | @@ -797,7 +797,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { | ... | @@ -797,7 +797,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) { |
| 797 | } | 797 | } |
| 798 | 798 | ||
| 799 | template <class _Tp> | 799 | template <class _Tp> |
| 800 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 800 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 801 | operator*(const complex<_Tp>& __x, const _Tp& __y) { | 801 | operator*(const complex<_Tp>& __x, const _Tp& __y) { |
| 802 | complex<_Tp> __t(__x); | 802 | complex<_Tp> __t(__x); |
| 803 | __t *= __y; | 803 | __t *= __y; |
| ... | @@ -805,7 +805,7 @@ operator*(const complex<_Tp>& __x, const _Tp& __y) { | ... | @@ -805,7 +805,7 @@ operator*(const complex<_Tp>& __x, const _Tp& __y) { |
| 805 | } | 805 | } |
| 806 | 806 | ||
| 807 | template <class _Tp> | 807 | template <class _Tp> |
| 808 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 808 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 809 | operator*(const _Tp& __x, const complex<_Tp>& __y) { | 809 | operator*(const _Tp& __x, const complex<_Tp>& __y) { |
| 810 | complex<_Tp> __t(__y); | 810 | complex<_Tp> __t(__y); |
| 811 | __t *= __x; | 811 | __t *= __x; |
| ... | @@ -813,13 +813,13 @@ operator*(const _Tp& __x, const complex<_Tp>& __y) { | ... | @@ -813,13 +813,13 @@ operator*(const _Tp& __x, const complex<_Tp>& __y) { |
| 813 | } | 813 | } |
| 814 | 814 | ||
| 815 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > | 815 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> > |
| 816 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 816 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 817 | operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { | 817 | operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) { |
| 818 | return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() / __rhs.__builtin()); | 818 | return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() / __rhs.__builtin()); |
| 819 | } | 819 | } |
| 820 | 820 | ||
| 821 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > | 821 | template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> > |
| 822 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 822 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 823 | operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { | 823 | operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { |
| 824 | _Tp __a = __z.real(); | 824 | _Tp __a = __z.real(); |
| 825 | _Tp __b = __z.imag(); | 825 | _Tp __b = __z.imag(); |
| ... | @@ -831,13 +831,13 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { | ... | @@ -831,13 +831,13 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) { |
| 831 | } | 831 | } |
| 832 | 832 | ||
| 833 | template <class _Tp> | 833 | template <class _Tp> |
| 834 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 834 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 835 | operator/(const complex<_Tp>& __x, const _Tp& __y) { | 835 | operator/(const complex<_Tp>& __x, const _Tp& __y) { |
| 836 | return complex<_Tp>(__x.real() / __y, __x.imag() / __y); | 836 | return complex<_Tp>(__x.real() / __y, __x.imag() / __y); |
| 837 | } | 837 | } |
| 838 | 838 | ||
| 839 | template <class _Tp> | 839 | template <class _Tp> |
| 840 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 840 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 841 | operator/(const _Tp& __x, const complex<_Tp>& __y) { | 841 | operator/(const _Tp& __x, const complex<_Tp>& __y) { |
| 842 | complex<_Tp> __t(__x); | 842 | complex<_Tp> __t(__x); |
| 843 | __t /= __y; | 843 | __t /= __y; |
| ... | @@ -845,12 +845,14 @@ operator/(const _Tp& __x, const complex<_Tp>& __y) { | ... | @@ -845,12 +845,14 @@ operator/(const _Tp& __x, const complex<_Tp>& __y) { |
| 845 | } | 845 | } |
| 846 | 846 | ||
| 847 | template <class _Tp> | 847 | template <class _Tp> |
| 848 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator+(const complex<_Tp>& __x) { | 848 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 849 | operator+(const complex<_Tp>& __x) { | ||
| 849 | return __x; | 850 | return __x; |
| 850 | } | 851 | } |
| 851 | 852 | ||
| 852 | template <class _Tp> | 853 | template <class _Tp> |
| 853 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator-(const complex<_Tp>& __x) { | 854 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 855 | operator-(const complex<_Tp>& __x) { | ||
| 854 | return complex<_Tp>(-__x.real(), -__x.imag()); | 856 | return complex<_Tp>(-__x.real(), -__x.imag()); |
| 855 | } | 857 | } |
| 856 | 858 | ||
| ... | @@ -912,12 +914,13 @@ struct __libcpp_complex_overload_traits<_Tp, false, true> { | ... | @@ -912,12 +914,13 @@ struct __libcpp_complex_overload_traits<_Tp, false, true> { |
| 912 | // real | 914 | // real |
| 913 | 915 | ||
| 914 | template <class _Tp> | 916 | template <class _Tp> |
| 915 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp real(const complex<_Tp>& __c) { | 917 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp real(const complex<_Tp>& __c) { |
| 916 | return __c.real(); | 918 | return __c.real(); |
| 917 | } | 919 | } |
| 918 | 920 | ||
| 919 | template <class _Tp> | 921 | template <class _Tp> |
| 920 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __libcpp_complex_overload_traits<_Tp>::_ValueType | 922 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 923 | typename __libcpp_complex_overload_traits<_Tp>::_ValueType | ||
| 921 | real(_Tp __re) { | 924 | real(_Tp __re) { |
| 922 | return __re; | 925 | return __re; |
| 923 | } | 926 | } |
| ... | @@ -925,12 +928,13 @@ real(_Tp __re) { | ... | @@ -925,12 +928,13 @@ real(_Tp __re) { |
| 925 | // imag | 928 | // imag |
| 926 | 929 | ||
| 927 | template <class _Tp> | 930 | template <class _Tp> |
| 928 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp imag(const complex<_Tp>& __c) { | 931 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp imag(const complex<_Tp>& __c) { |
| 929 | return __c.imag(); | 932 | return __c.imag(); |
| 930 | } | 933 | } |
| 931 | 934 | ||
| 932 | template <class _Tp> | 935 | template <class _Tp> |
| 933 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __libcpp_complex_overload_traits<_Tp>::_ValueType | 936 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 937 | typename __libcpp_complex_overload_traits<_Tp>::_ValueType | ||
| 934 | imag(_Tp) { | 938 | imag(_Tp) { |
| 935 | return 0; | 939 | return 0; |
| 936 | } | 940 | } |
| ... | @@ -938,36 +942,36 @@ imag(_Tp) { | ... | @@ -938,36 +942,36 @@ imag(_Tp) { |
| 938 | // abs | 942 | // abs |
| 939 | 943 | ||
| 940 | template <class _Tp> | 944 | template <class _Tp> |
| 941 | inline _LIBCPP_HIDE_FROM_ABI _Tp abs(const complex<_Tp>& __c) { | 945 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _Tp abs(const complex<_Tp>& __c) { |
| 942 | return std::hypot(__c.real(), __c.imag()); | 946 | return std::hypot(__c.real(), __c.imag()); |
| 943 | } | 947 | } |
| 944 | 948 | ||
| 945 | // arg | 949 | // arg |
| 946 | 950 | ||
| 947 | template <class _Tp> | 951 | template <class _Tp> |
| 948 | inline _LIBCPP_HIDE_FROM_ABI _Tp arg(const complex<_Tp>& __c) { | 952 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _Tp arg(const complex<_Tp>& __c) { |
| 949 | return std::atan2(__c.imag(), __c.real()); | 953 | return std::atan2(__c.imag(), __c.real()); |
| 950 | } | 954 | } |
| 951 | 955 | ||
| 952 | template <class _Tp, __enable_if_t<is_same<_Tp, long double>::value, int> = 0> | 956 | template <class _Tp, __enable_if_t<is_same<_Tp, long double>::value, int> = 0> |
| 953 | inline _LIBCPP_HIDE_FROM_ABI long double arg(_Tp __re) { | 957 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double arg(_Tp __re) { |
| 954 | return std::atan2l(0.L, __re); | 958 | return std::atan2l(0.L, __re); |
| 955 | } | 959 | } |
| 956 | 960 | ||
| 957 | template <class _Tp, __enable_if_t<is_integral<_Tp>::value || is_same<_Tp, double>::value, int> = 0> | 961 | template <class _Tp, __enable_if_t<is_integral<_Tp>::value || is_same<_Tp, double>::value, int> = 0> |
| 958 | inline _LIBCPP_HIDE_FROM_ABI double arg(_Tp __re) { | 962 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double arg(_Tp __re) { |
| 959 | return std::atan2(0., __re); | 963 | return std::atan2(0., __re); |
| 960 | } | 964 | } |
| 961 | 965 | ||
| 962 | template <class _Tp, __enable_if_t<is_same<_Tp, float>::value, int> = 0> | 966 | template <class _Tp, __enable_if_t<is_same<_Tp, float>::value, int> = 0> |
| 963 | inline _LIBCPP_HIDE_FROM_ABI float arg(_Tp __re) { | 967 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float arg(_Tp __re) { |
| 964 | return std::atan2f(0.F, __re); | 968 | return std::atan2f(0.F, __re); |
| 965 | } | 969 | } |
| 966 | 970 | ||
| 967 | // norm | 971 | // norm |
| 968 | 972 | ||
| 969 | template <class _Tp> | 973 | template <class _Tp> |
| 970 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp norm(const complex<_Tp>& __c) { | 974 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp norm(const complex<_Tp>& __c) { |
| 971 | if (std::__constexpr_isinf(__c.real())) | 975 | if (std::__constexpr_isinf(__c.real())) |
| 972 | return std::abs(__c.real()); | 976 | return std::abs(__c.real()); |
| 973 | if (std::__constexpr_isinf(__c.imag())) | 977 | if (std::__constexpr_isinf(__c.imag())) |
| ... | @@ -976,7 +980,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp norm(const comple | ... | @@ -976,7 +980,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp norm(const comple |
| 976 | } | 980 | } |
| 977 | 981 | ||
| 978 | template <class _Tp> | 982 | template <class _Tp> |
| 979 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __libcpp_complex_overload_traits<_Tp>::_ValueType | 983 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 984 | typename __libcpp_complex_overload_traits<_Tp>::_ValueType | ||
| 980 | norm(_Tp __re) { | 985 | norm(_Tp __re) { |
| 981 | typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType; | 986 | typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType; |
| 982 | return static_cast<_ValueType>(__re) * __re; | 987 | return static_cast<_ValueType>(__re) * __re; |
| ... | @@ -985,12 +990,14 @@ norm(_Tp __re) { | ... | @@ -985,12 +990,14 @@ norm(_Tp __re) { |
| 985 | // conj | 990 | // conj |
| 986 | 991 | ||
| 987 | template <class _Tp> | 992 | template <class _Tp> |
| 988 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> conj(const complex<_Tp>& __c) { | 993 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 994 | conj(const complex<_Tp>& __c) { | ||
| 989 | return complex<_Tp>(__c.real(), -__c.imag()); | 995 | return complex<_Tp>(__c.real(), -__c.imag()); |
| 990 | } | 996 | } |
| 991 | 997 | ||
| 992 | template <class _Tp> | 998 | template <class _Tp> |
| 993 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __libcpp_complex_overload_traits<_Tp>::_ComplexType | 999 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1000 | typename __libcpp_complex_overload_traits<_Tp>::_ComplexType | ||
| 994 | conj(_Tp __re) { | 1001 | conj(_Tp __re) { |
| 995 | typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; | 1002 | typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; |
| 996 | return _ComplexType(__re); | 1003 | return _ComplexType(__re); |
| ... | @@ -999,7 +1006,7 @@ conj(_Tp __re) { | ... | @@ -999,7 +1006,7 @@ conj(_Tp __re) { |
| 999 | // proj | 1006 | // proj |
| 1000 | 1007 | ||
| 1001 | template <class _Tp> | 1008 | template <class _Tp> |
| 1002 | inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { | 1009 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { |
| 1003 | complex<_Tp> __r = __c; | 1010 | complex<_Tp> __r = __c; |
| 1004 | if (std::isinf(__c.real()) || std::isinf(__c.imag())) | 1011 | if (std::isinf(__c.real()) || std::isinf(__c.imag())) |
| 1005 | __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag())); | 1012 | __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag())); |
| ... | @@ -1007,14 +1014,16 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { | ... | @@ -1007,14 +1014,16 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { |
| 1007 | } | 1014 | } |
| 1008 | 1015 | ||
| 1009 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> | 1016 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> |
| 1010 | inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { | 1017 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType |
| 1018 | proj(_Tp __re) { | ||
| 1011 | if (std::isinf(__re)) | 1019 | if (std::isinf(__re)) |
| 1012 | __re = std::abs(__re); | 1020 | __re = std::abs(__re); |
| 1013 | return complex<_Tp>(__re); | 1021 | return complex<_Tp>(__re); |
| 1014 | } | 1022 | } |
| 1015 | 1023 | ||
| 1016 | template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> | 1024 | template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> |
| 1017 | inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { | 1025 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType |
| 1026 | proj(_Tp __re) { | ||
| 1018 | typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; | 1027 | typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; |
| 1019 | return _ComplexType(__re); | 1028 | return _ComplexType(__re); |
| 1020 | } | 1029 | } |
| ... | @@ -1022,7 +1031,7 @@ inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_Co | ... | @@ -1022,7 +1031,7 @@ inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_Co |
| 1022 | // polar | 1031 | // polar |
| 1023 | 1032 | ||
| 1024 | template <class _Tp> | 1033 | template <class _Tp> |
| 1025 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) { | 1034 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) { |
| 1026 | if (std::isnan(__rho) || std::signbit(__rho)) | 1035 | if (std::isnan(__rho) || std::signbit(__rho)) |
| 1027 | return complex<_Tp>(_Tp(NAN), _Tp(NAN)); | 1036 | return complex<_Tp>(_Tp(NAN), _Tp(NAN)); |
| 1028 | if (std::isnan(__theta)) { | 1037 | if (std::isnan(__theta)) { |
| ... | @@ -1047,21 +1056,21 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = | ... | @@ -1047,21 +1056,21 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = |
| 1047 | // log | 1056 | // log |
| 1048 | 1057 | ||
| 1049 | template <class _Tp> | 1058 | template <class _Tp> |
| 1050 | inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log(const complex<_Tp>& __x) { | 1059 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log(const complex<_Tp>& __x) { |
| 1051 | return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x)); | 1060 | return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x)); |
| 1052 | } | 1061 | } |
| 1053 | 1062 | ||
| 1054 | // log10 | 1063 | // log10 |
| 1055 | 1064 | ||
| 1056 | template <class _Tp> | 1065 | template <class _Tp> |
| 1057 | inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) { | 1066 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) { |
| 1058 | return std::log(__x) / std::log(_Tp(10)); | 1067 | return std::log(__x) / std::log(_Tp(10)); |
| 1059 | } | 1068 | } |
| 1060 | 1069 | ||
| 1061 | // sqrt | 1070 | // sqrt |
| 1062 | 1071 | ||
| 1063 | template <class _Tp> | 1072 | template <class _Tp> |
| 1064 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { | 1073 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { |
| 1065 | if (std::isinf(__x.imag())) | 1074 | if (std::isinf(__x.imag())) |
| 1066 | return complex<_Tp>(_Tp(INFINITY), __x.imag()); | 1075 | return complex<_Tp>(_Tp(INFINITY), __x.imag()); |
| 1067 | if (std::isinf(__x.real())) { | 1076 | if (std::isinf(__x.real())) { |
| ... | @@ -1075,7 +1084,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { | ... | @@ -1075,7 +1084,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { |
| 1075 | // exp | 1084 | // exp |
| 1076 | 1085 | ||
| 1077 | template <class _Tp> | 1086 | template <class _Tp> |
| 1078 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { | 1087 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { |
| 1079 | _Tp __i = __x.imag(); | 1088 | _Tp __i = __x.imag(); |
| 1080 | if (__i == 0) { | 1089 | if (__i == 0) { |
| 1081 | return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag())); | 1090 | return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag())); |
| ... | @@ -1097,24 +1106,27 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { | ... | @@ -1097,24 +1106,27 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { |
| 1097 | // pow | 1106 | // pow |
| 1098 | 1107 | ||
| 1099 | template <class _Tp> | 1108 | template <class _Tp> |
| 1100 | inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { | 1109 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const complex<_Tp>& __y) { |
| 1101 | return std::exp(__y * std::log(__x)); | 1110 | return std::exp(__y * std::log(__x)); |
| 1102 | } | 1111 | } |
| 1103 | 1112 | ||
| 1104 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0> | 1113 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0> |
| 1105 | inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const complex<_Tp>& __x, const complex<_Up>& __y) { | 1114 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > |
| 1115 | pow(const complex<_Tp>& __x, const complex<_Up>& __y) { | ||
| 1106 | typedef complex<__promote_t<_Tp, _Up> > result_type; | 1116 | typedef complex<__promote_t<_Tp, _Up> > result_type; |
| 1107 | return std::pow(result_type(__x), result_type(__y)); | 1117 | return std::pow(result_type(__x), result_type(__y)); |
| 1108 | } | 1118 | } |
| 1109 | 1119 | ||
| 1110 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0> | 1120 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0> |
| 1111 | inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const complex<_Tp>& __x, const _Up& __y) { | 1121 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > |
| 1122 | pow(const complex<_Tp>& __x, const _Up& __y) { | ||
| 1112 | typedef complex<__promote_t<_Tp, _Up> > result_type; | 1123 | typedef complex<__promote_t<_Tp, _Up> > result_type; |
| 1113 | return std::pow(result_type(__x), result_type(__y)); | 1124 | return std::pow(result_type(__x), result_type(__y)); |
| 1114 | } | 1125 | } |
| 1115 | 1126 | ||
| 1116 | template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0> | 1127 | template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0> |
| 1117 | inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const _Tp& __x, const complex<_Up>& __y) { | 1128 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > |
| 1129 | pow(const _Tp& __x, const complex<_Up>& __y) { | ||
| 1118 | typedef complex<__promote_t<_Tp, _Up> > result_type; | 1130 | typedef complex<__promote_t<_Tp, _Up> > result_type; |
| 1119 | return std::pow(result_type(__x), result_type(__y)); | 1131 | return std::pow(result_type(__x), result_type(__y)); |
| 1120 | } | 1132 | } |
| ... | @@ -1129,7 +1141,7 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) { | ... | @@ -1129,7 +1141,7 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) { |
| 1129 | // asinh | 1141 | // asinh |
| 1130 | 1142 | ||
| 1131 | template <class _Tp> | 1143 | template <class _Tp> |
| 1132 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { | 1144 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { |
| 1133 | const _Tp __pi(atan2(+0., -0.)); | 1145 | const _Tp __pi(atan2(+0., -0.)); |
| 1134 | if (std::isinf(__x.real())) { | 1146 | if (std::isinf(__x.real())) { |
| 1135 | if (std::isnan(__x.imag())) | 1147 | if (std::isnan(__x.imag())) |
| ... | @@ -1154,7 +1166,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { | ... | @@ -1154,7 +1166,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { |
| 1154 | // acosh | 1166 | // acosh |
| 1155 | 1167 | ||
| 1156 | template <class _Tp> | 1168 | template <class _Tp> |
| 1157 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { | 1169 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { |
| 1158 | const _Tp __pi(atan2(+0., -0.)); | 1170 | const _Tp __pi(atan2(+0., -0.)); |
| 1159 | if (std::isinf(__x.real())) { | 1171 | if (std::isinf(__x.real())) { |
| 1160 | if (std::isnan(__x.imag())) | 1172 | if (std::isnan(__x.imag())) |
| ... | @@ -1183,7 +1195,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { | ... | @@ -1183,7 +1195,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { |
| 1183 | // atanh | 1195 | // atanh |
| 1184 | 1196 | ||
| 1185 | template <class _Tp> | 1197 | template <class _Tp> |
| 1186 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { | 1198 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { |
| 1187 | const _Tp __pi(atan2(+0., -0.)); | 1199 | const _Tp __pi(atan2(+0., -0.)); |
| 1188 | if (std::isinf(__x.imag())) { | 1200 | if (std::isinf(__x.imag())) { |
| 1189 | return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); | 1201 | return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); |
| ... | @@ -1209,7 +1221,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { | ... | @@ -1209,7 +1221,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { |
| 1209 | // sinh | 1221 | // sinh |
| 1210 | 1222 | ||
| 1211 | template <class _Tp> | 1223 | template <class _Tp> |
| 1212 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { | 1224 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { |
| 1213 | if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) | 1225 | if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) |
| 1214 | return complex<_Tp>(__x.real(), _Tp(NAN)); | 1226 | return complex<_Tp>(__x.real(), _Tp(NAN)); |
| 1215 | if (__x.real() == 0 && !std::isfinite(__x.imag())) | 1227 | if (__x.real() == 0 && !std::isfinite(__x.imag())) |
| ... | @@ -1222,7 +1234,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { | ... | @@ -1222,7 +1234,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { |
| 1222 | // cosh | 1234 | // cosh |
| 1223 | 1235 | ||
| 1224 | template <class _Tp> | 1236 | template <class _Tp> |
| 1225 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { | 1237 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { |
| 1226 | if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) | 1238 | if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) |
| 1227 | return complex<_Tp>(std::abs(__x.real()), _Tp(NAN)); | 1239 | return complex<_Tp>(std::abs(__x.real()), _Tp(NAN)); |
| 1228 | if (__x.real() == 0 && !std::isfinite(__x.imag())) | 1240 | if (__x.real() == 0 && !std::isfinite(__x.imag())) |
| ... | @@ -1237,7 +1249,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { | ... | @@ -1237,7 +1249,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { |
| 1237 | // tanh | 1249 | // tanh |
| 1238 | 1250 | ||
| 1239 | template <class _Tp> | 1251 | template <class _Tp> |
| 1240 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { | 1252 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { |
| 1241 | if (std::isinf(__x.real())) { | 1253 | if (std::isinf(__x.real())) { |
| 1242 | if (!std::isfinite(__x.imag())) | 1254 | if (!std::isfinite(__x.imag())) |
| 1243 | return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0)); | 1255 | return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0)); |
| ... | @@ -1257,7 +1269,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { | ... | @@ -1257,7 +1269,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { |
| 1257 | // asin | 1269 | // asin |
| 1258 | 1270 | ||
| 1259 | template <class _Tp> | 1271 | template <class _Tp> |
| 1260 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { | 1272 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { |
| 1261 | complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real())); | 1273 | complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real())); |
| 1262 | return complex<_Tp>(__z.imag(), -__z.real()); | 1274 | return complex<_Tp>(__z.imag(), -__z.real()); |
| 1263 | } | 1275 | } |
| ... | @@ -1265,7 +1277,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { | ... | @@ -1265,7 +1277,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { |
| 1265 | // acos | 1277 | // acos |
| 1266 | 1278 | ||
| 1267 | template <class _Tp> | 1279 | template <class _Tp> |
| 1268 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { | 1280 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { |
| 1269 | const _Tp __pi(atan2(+0., -0.)); | 1281 | const _Tp __pi(atan2(+0., -0.)); |
| 1270 | if (std::isinf(__x.real())) { | 1282 | if (std::isinf(__x.real())) { |
| 1271 | if (std::isnan(__x.imag())) | 1283 | if (std::isnan(__x.imag())) |
| ... | @@ -1297,7 +1309,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { | ... | @@ -1297,7 +1309,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { |
| 1297 | // atan | 1309 | // atan |
| 1298 | 1310 | ||
| 1299 | template <class _Tp> | 1311 | template <class _Tp> |
| 1300 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> atan(const complex<_Tp>& __x) { | 1312 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> atan(const complex<_Tp>& __x) { |
| 1301 | complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real())); | 1313 | complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real())); |
| 1302 | return complex<_Tp>(__z.imag(), -__z.real()); | 1314 | return complex<_Tp>(__z.imag(), -__z.real()); |
| 1303 | } | 1315 | } |
| ... | @@ -1305,7 +1317,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atan(const complex<_Tp>& __x) { | ... | @@ -1305,7 +1317,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atan(const complex<_Tp>& __x) { |
| 1305 | // sin | 1317 | // sin |
| 1306 | 1318 | ||
| 1307 | template <class _Tp> | 1319 | template <class _Tp> |
| 1308 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> sin(const complex<_Tp>& __x) { | 1320 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> sin(const complex<_Tp>& __x) { |
| 1309 | complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real())); | 1321 | complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real())); |
| 1310 | return complex<_Tp>(__z.imag(), -__z.real()); | 1322 | return complex<_Tp>(__z.imag(), -__z.real()); |
| 1311 | } | 1323 | } |
| ... | @@ -1313,14 +1325,14 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sin(const complex<_Tp>& __x) { | ... | @@ -1313,14 +1325,14 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sin(const complex<_Tp>& __x) { |
| 1313 | // cos | 1325 | // cos |
| 1314 | 1326 | ||
| 1315 | template <class _Tp> | 1327 | template <class _Tp> |
| 1316 | inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> cos(const complex<_Tp>& __x) { | 1328 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> cos(const complex<_Tp>& __x) { |
| 1317 | return std::cosh(complex<_Tp>(-__x.imag(), __x.real())); | 1329 | return std::cosh(complex<_Tp>(-__x.imag(), __x.real())); |
| 1318 | } | 1330 | } |
| 1319 | 1331 | ||
| 1320 | // tan | 1332 | // tan |
| 1321 | 1333 | ||
| 1322 | template <class _Tp> | 1334 | template <class _Tp> |
| 1323 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) { | 1335 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) { |
| 1324 | complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real())); | 1336 | complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real())); |
| 1325 | return complex<_Tp>(__z.imag(), -__z.real()); | 1337 | return complex<_Tp>(__z.imag(), -__z.real()); |
| 1326 | } | 1338 | } |
| ... | @@ -1398,7 +1410,7 @@ struct tuple_element<_Ip, complex<_Tp>> { | ... | @@ -1398,7 +1410,7 @@ struct tuple_element<_Ip, complex<_Tp>> { |
| 1398 | }; | 1410 | }; |
| 1399 | 1411 | ||
| 1400 | template <size_t _Ip, class _Xp> | 1412 | template <size_t _Ip, class _Xp> |
| 1401 | _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept { | 1413 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept { |
| 1402 | static_assert(_Ip < 2, "Index value is out of range."); | 1414 | static_assert(_Ip < 2, "Index value is out of range."); |
| 1403 | if constexpr (_Ip == 0) { | 1415 | if constexpr (_Ip == 0) { |
| 1404 | return __z.__re_; | 1416 | return __z.__re_; |
| ... | @@ -1408,7 +1420,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept { | ... | @@ -1408,7 +1420,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept { |
| 1408 | } | 1420 | } |
| 1409 | 1421 | ||
| 1410 | template <size_t _Ip, class _Xp> | 1422 | template <size_t _Ip, class _Xp> |
| 1411 | _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept { | 1423 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept { |
| 1412 | static_assert(_Ip < 2, "Index value is out of range."); | 1424 | static_assert(_Ip < 2, "Index value is out of range."); |
| 1413 | if constexpr (_Ip == 0) { | 1425 | if constexpr (_Ip == 0) { |
| 1414 | return std::move(__z.__re_); | 1426 | return std::move(__z.__re_); |
| ... | @@ -1418,7 +1430,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept { | ... | @@ -1418,7 +1430,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept { |
| 1418 | } | 1430 | } |
| 1419 | 1431 | ||
| 1420 | template <size_t _Ip, class _Xp> | 1432 | template <size_t _Ip, class _Xp> |
| 1421 | _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept { | 1433 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept { |
| 1422 | static_assert(_Ip < 2, "Index value is out of range."); | 1434 | static_assert(_Ip < 2, "Index value is out of range."); |
| 1423 | if constexpr (_Ip == 0) { | 1435 | if constexpr (_Ip == 0) { |
| 1424 | return __z.__re_; | 1436 | return __z.__re_; |
| ... | @@ -1428,7 +1440,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept | ... | @@ -1428,7 +1440,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept |
| 1428 | } | 1440 | } |
| 1429 | 1441 | ||
| 1430 | template <size_t _Ip, class _Xp> | 1442 | template <size_t _Ip, class _Xp> |
| 1431 | _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexcept { | 1443 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexcept { |
| 1432 | static_assert(_Ip < 2, "Index value is out of range."); | 1444 | static_assert(_Ip < 2, "Index value is out of range."); |
| 1433 | if constexpr (_Ip == 0) { | 1445 | if constexpr (_Ip == 0) { |
| 1434 | return std::move(__z.__re_); | 1446 | return std::move(__z.__re_); |
lib/libcxx/include/complex.h+10-10| ... | @@ -18,19 +18,19 @@ | ... | @@ -18,19 +18,19 @@ |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 20 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 21 | # include <__cxx03/complex.h> | 21 | # include <__cxx03/__config> |
| 22 | #else | 22 | #else |
| 23 | # include <__config> | 23 | # include <__config> |
| 24 | #endif | ||
| 24 | 25 | ||
| 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | # pragma GCC system_header | 27 | # pragma GCC system_header |
| 27 | # endif | 28 | #endif |
| 28 | 29 | ||
| 29 | # ifdef __cplusplus | 30 | #ifdef __cplusplus |
| 30 | # include <complex> | 31 | # include <complex> |
| 31 | # elif __has_include_next(<complex.h>) | 32 | #elif __has_include_next(<complex.h>) |
| 32 | # include_next <complex.h> | 33 | # include_next <complex.h> |
| 33 | # endif | 34 | #endif |
| 34 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 35 | 35 | ||
| 36 | #endif // _LIBCPP_COMPLEX_H | 36 | #endif // _LIBCPP_COMPLEX_H |
lib/libcxx/include/condition_variable+3-3| ... | @@ -206,14 +206,14 @@ public: | ... | @@ -206,14 +206,14 @@ public: |
| 206 | # if _LIBCPP_STD_VER >= 20 | 206 | # if _LIBCPP_STD_VER >= 20 |
| 207 | 207 | ||
| 208 | template <class _Lock, class _Predicate> | 208 | template <class _Lock, class _Predicate> |
| 209 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred); | 209 | _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred); |
| 210 | 210 | ||
| 211 | template <class _Lock, class _Clock, class _Duration, class _Predicate> | 211 | template <class _Lock, class _Clock, class _Duration, class _Predicate> |
| 212 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait_until( | 212 | _LIBCPP_HIDE_FROM_ABI bool wait_until( |
| 213 | _Lock& __lock, stop_token __stoken, const chrono::time_point<_Clock, _Duration>& __abs_time, _Predicate __pred); | 213 | _Lock& __lock, stop_token __stoken, const chrono::time_point<_Clock, _Duration>& __abs_time, _Predicate __pred); |
| 214 | 214 | ||
| 215 | template <class _Lock, class _Rep, class _Period, class _Predicate> | 215 | template <class _Lock, class _Rep, class _Period, class _Predicate> |
| 216 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool | 216 | _LIBCPP_HIDE_FROM_ABI bool |
| 217 | wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred); | 217 | wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred); |
| 218 | 218 | ||
| 219 | # endif // _LIBCPP_STD_VER >= 20 | 219 | # endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/cstdalign+3-10| ... | @@ -43,17 +43,10 @@ Macros: | ... | @@ -43,17 +43,10 @@ Macros: |
| 43 | # undef __alignof_is_defined | 43 | # undef __alignof_is_defined |
| 44 | # define __alignof_is_defined 1 | 44 | # define __alignof_is_defined 1 |
| 45 | 45 | ||
| 46 | # if _LIBCPP_STD_VER >= 20 | 46 | # if _LIBCPP_STD_VER >= 17 && !__building_module(std) && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS |
| 47 | 47 | # warning <cstdalign> is deprecated in C++17 and removed in C++20. | |
| 48 | using __standard_header_cstdalign _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void; | ||
| 49 | using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign; | ||
| 50 | |||
| 51 | # elif _LIBCPP_STD_VER >= 17 | ||
| 52 | |||
| 53 | using __standard_header_cstdalign _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void; | ||
| 54 | using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign; | ||
| 55 | |||
| 56 | # endif | 48 | # endif |
| 49 | |||
| 57 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 50 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 58 | 51 | ||
| 59 | #endif // _LIBCPP_CSTDALIGN | 52 | #endif // _LIBCPP_CSTDALIGN |
lib/libcxx/include/cstdbool+3-10| ... | @@ -31,17 +31,10 @@ Macros: | ... | @@ -31,17 +31,10 @@ Macros: |
| 31 | # undef __bool_true_false_are_defined | 31 | # undef __bool_true_false_are_defined |
| 32 | # define __bool_true_false_are_defined 1 | 32 | # define __bool_true_false_are_defined 1 |
| 33 | 33 | ||
| 34 | # if _LIBCPP_STD_VER >= 20 | 34 | # if _LIBCPP_STD_VER >= 17 && !__building_module(std) && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS |
| 35 | 35 | # warning <cstdbool> is deprecated in C++17 and removed in C++20. | |
| 36 | using __standard_header_cstdbool _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void; | ||
| 37 | using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool; | ||
| 38 | |||
| 39 | # elif _LIBCPP_STD_VER >= 17 | ||
| 40 | |||
| 41 | using __standard_header_cstdbool _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void; | ||
| 42 | using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool; | ||
| 43 | |||
| 44 | # endif | 36 | # endif |
| 37 | |||
| 45 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 38 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 46 | 39 | ||
| 47 | #endif // _LIBCPP_CSTDBOOL | 40 | #endif // _LIBCPP_CSTDBOOL |
lib/libcxx/include/ctgmath+2-11| ... | @@ -28,17 +28,8 @@ | ... | @@ -28,17 +28,8 @@ |
| 28 | # pragma GCC system_header | 28 | # pragma GCC system_header |
| 29 | # endif | 29 | # endif |
| 30 | 30 | ||
| 31 | # if _LIBCPP_STD_VER >= 20 | 31 | # if _LIBCPP_STD_VER >= 17 && !__building_module(std) && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS |
| 32 | 32 | # warning <ctgmath> is deprecated in C++17 and removed in C++20. Include <cmath> and <complex> instead. | |
| 33 | using __standard_header_ctgmath | ||
| 34 | _LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void; | ||
| 35 | using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath; | ||
| 36 | |||
| 37 | # elif _LIBCPP_STD_VER >= 17 | ||
| 38 | |||
| 39 | using __standard_header_ctgmath _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void; | ||
| 40 | using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath; | ||
| 41 | |||
| 42 | # endif | 33 | # endif |
| 43 | 34 | ||
| 44 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 35 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/ctype.h+24-24| ... | @@ -30,36 +30,36 @@ int toupper(int c); | ... | @@ -30,36 +30,36 @@ int toupper(int c); |
| 30 | */ | 30 | */ |
| 31 | 31 | ||
| 32 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 32 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 33 | # include <__cxx03/ctype.h> | 33 | # include <__cxx03/__config> |
| 34 | #else | 34 | #else |
| 35 | # include <__config> | 35 | # include <__config> |
| 36 | #endif | ||
| 36 | 37 | ||
| 37 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 38 | # pragma GCC system_header | 39 | # pragma GCC system_header |
| 39 | # endif | 40 | #endif |
| 40 | 41 | ||
| 41 | # if __has_include_next(<ctype.h>) | 42 | #if __has_include_next(<ctype.h>) |
| 42 | # include_next <ctype.h> | 43 | # include_next <ctype.h> |
| 43 | # endif | 44 | #endif |
| 44 | 45 | ||
| 45 | # ifdef __cplusplus | 46 | #ifdef __cplusplus |
| 46 | 47 | ||
| 47 | # undef isalnum | 48 | # undef isalnum |
| 48 | # undef isalpha | 49 | # undef isalpha |
| 49 | # undef isblank | 50 | # undef isblank |
| 50 | # undef iscntrl | 51 | # undef iscntrl |
| 51 | # undef isdigit | 52 | # undef isdigit |
| 52 | # undef isgraph | 53 | # undef isgraph |
| 53 | # undef islower | 54 | # undef islower |
| 54 | # undef isprint | 55 | # undef isprint |
| 55 | # undef ispunct | 56 | # undef ispunct |
| 56 | # undef isspace | 57 | # undef isspace |
| 57 | # undef isupper | 58 | # undef isupper |
| 58 | # undef isxdigit | 59 | # undef isxdigit |
| 59 | # undef tolower | 60 | # undef tolower |
| 60 | # undef toupper | 61 | # undef toupper |
| 61 | 62 | ||
| 62 | # endif | 63 | #endif |
| 63 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 64 | 64 | ||
| 65 | #endif // _LIBCPP_CTYPE_H | 65 | #endif // _LIBCPP_CTYPE_H |
lib/libcxx/include/cwchar+2-2| ... | @@ -231,8 +231,8 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) | ... | @@ -231,8 +231,8 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) |
| 231 | 231 | ||
| 232 | template <class _Tp, class _Up> | 232 | template <class _Tp, class _Up> |
| 233 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp* __str, _Up __value, size_t __count) { | 233 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp* __str, _Up __value, size_t __count) { |
| 234 | static_assert(sizeof(_Tp) == sizeof(wchar_t)&& _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t) && | 234 | static_assert(sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t) && |
| 235 | __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value, | 235 | __is_trivially_equality_comparable_v<_Tp, _Tp>, |
| 236 | "Calling wmemchr on non-trivially equality comparable types is unsafe."); | 236 | "Calling wmemchr on non-trivially equality comparable types is unsafe."); |
| 237 | 237 | ||
| 238 | # if __has_builtin(__builtin_wmemchr) | 238 | # if __has_builtin(__builtin_wmemchr) |
lib/libcxx/include/deque+109-225| ... | @@ -191,9 +191,9 @@ template <class T, class Allocator, class Predicate> | ... | @@ -191,9 +191,9 @@ template <class T, class Allocator, class Predicate> |
| 191 | # include <__algorithm/min.h> | 191 | # include <__algorithm/min.h> |
| 192 | # include <__algorithm/move.h> | 192 | # include <__algorithm/move.h> |
| 193 | # include <__algorithm/move_backward.h> | 193 | # include <__algorithm/move_backward.h> |
| 194 | # include <__algorithm/ranges_copy_n.h> | ||
| 194 | # include <__algorithm/remove.h> | 195 | # include <__algorithm/remove.h> |
| 195 | # include <__algorithm/remove_if.h> | 196 | # include <__algorithm/remove_if.h> |
| 196 | # include <__algorithm/unwrap_iter.h> | ||
| 197 | # include <__assert> | 197 | # include <__assert> |
| 198 | # include <__config> | 198 | # include <__config> |
| 199 | # include <__debug_utils/sanitizers.h> | 199 | # include <__debug_utils/sanitizers.h> |
| ... | @@ -220,21 +220,19 @@ template <class T, class Allocator, class Predicate> | ... | @@ -220,21 +220,19 @@ template <class T, class Allocator, class Predicate> |
| 220 | # include <__ranges/concepts.h> | 220 | # include <__ranges/concepts.h> |
| 221 | # include <__ranges/container_compatible_range.h> | 221 | # include <__ranges/container_compatible_range.h> |
| 222 | # include <__ranges/from_range.h> | 222 | # include <__ranges/from_range.h> |
| 223 | # include <__ranges/size.h> | ||
| 224 | # include <__split_buffer> | 223 | # include <__split_buffer> |
| 225 | # include <__type_traits/conditional.h> | 224 | # include <__type_traits/conditional.h> |
| 226 | # include <__type_traits/container_traits.h> | 225 | # include <__type_traits/container_traits.h> |
| 227 | # include <__type_traits/disjunction.h> | ||
| 228 | # include <__type_traits/enable_if.h> | 226 | # include <__type_traits/enable_if.h> |
| 229 | # include <__type_traits/is_allocator.h> | 227 | # include <__type_traits/is_allocator.h> |
| 230 | # include <__type_traits/is_convertible.h> | 228 | # include <__type_traits/is_convertible.h> |
| 231 | # include <__type_traits/is_nothrow_assignable.h> | 229 | # include <__type_traits/is_nothrow_assignable.h> |
| 232 | # include <__type_traits/is_nothrow_constructible.h> | 230 | # include <__type_traits/is_nothrow_constructible.h> |
| 233 | # include <__type_traits/is_replaceable.h> | ||
| 234 | # include <__type_traits/is_same.h> | 231 | # include <__type_traits/is_same.h> |
| 235 | # include <__type_traits/is_swappable.h> | 232 | # include <__type_traits/is_swappable.h> |
| 236 | # include <__type_traits/is_trivially_relocatable.h> | 233 | # include <__type_traits/is_trivially_relocatable.h> |
| 237 | # include <__type_traits/type_identity.h> | 234 | # include <__type_traits/type_identity.h> |
| 235 | # include <__utility/exception_guard.h> | ||
| 238 | # include <__utility/forward.h> | 236 | # include <__utility/forward.h> |
| 239 | # include <__utility/move.h> | 237 | # include <__utility/move.h> |
| 240 | # include <__utility/pair.h> | 238 | # include <__utility/pair.h> |
| ... | @@ -461,9 +459,8 @@ private: | ... | @@ -461,9 +459,8 @@ private: |
| 461 | __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>; | 459 | __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>; |
| 462 | 460 | ||
| 463 | public: | 461 | public: |
| 464 | using __is_segmented_iterator _LIBCPP_NODEBUG = true_type; | 462 | using __segment_iterator _LIBCPP_NODEBUG = _MapPointer; |
| 465 | using __segment_iterator _LIBCPP_NODEBUG = _MapPointer; | 463 | using __local_iterator _LIBCPP_NODEBUG = _Pointer; |
| 466 | using __local_iterator _LIBCPP_NODEBUG = _Pointer; | ||
| 467 | 464 | ||
| 468 | static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; } | 465 | static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; } |
| 469 | static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; } | 466 | static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; } |
| ... | @@ -488,6 +485,9 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, | ... | @@ -488,6 +485,9 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, |
| 488 | 485 | ||
| 489 | template <class _Tp, class _Allocator /*= allocator<_Tp>*/> | 486 | template <class _Tp, class _Allocator /*= allocator<_Tp>*/> |
| 490 | class deque { | 487 | class deque { |
| 488 | template <class _Up, class _Alloc> | ||
| 489 | using __split_buffer _LIBCPP_NODEBUG = std::__split_buffer<_Up, _Alloc, __split_buffer_pointer_layout>; | ||
| 490 | |||
| 491 | public: | 491 | public: |
| 492 | // types: | 492 | // types: |
| 493 | 493 | ||
| ... | @@ -531,10 +531,6 @@ public: | ... | @@ -531,10 +531,6 @@ public: |
| 531 | __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | 531 | __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 532 | deque, | 532 | deque, |
| 533 | void>; | 533 | void>; |
| 534 | using __replaceable _LIBCPP_NODEBUG = | ||
| 535 | __conditional_t<__is_replaceable_v<__map> && __container_allocator_is_replaceable<__alloc_traits>::value, | ||
| 536 | deque, | ||
| 537 | void>; | ||
| 538 | 534 | ||
| 539 | static_assert(is_nothrow_default_constructible<allocator_type>::value == | 535 | static_assert(is_nothrow_default_constructible<allocator_type>::value == |
| 540 | is_nothrow_default_constructible<__pointer_allocator>::value, | 536 | is_nothrow_default_constructible<__pointer_allocator>::value, |
| ... | @@ -635,7 +631,7 @@ public: | ... | @@ -635,7 +631,7 @@ public: |
| 635 | # endif | 631 | # endif |
| 636 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v); | 632 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v); |
| 637 | 633 | ||
| 638 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | 634 | template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0> |
| 639 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a) | 635 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a) |
| 640 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | 636 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { |
| 641 | __annotate_new(0); | 637 | __annotate_new(0); |
| ... | @@ -703,8 +699,16 @@ public: | ... | @@ -703,8 +699,16 @@ public: |
| 703 | __assign_with_size_random_access(ranges::begin(__range), __n); | 699 | __assign_with_size_random_access(ranges::begin(__range), __n); |
| 704 | 700 | ||
| 705 | } else if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | 701 | } else if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| 706 | auto __n = static_cast<size_type>(ranges::distance(__range)); | 702 | auto __n = ranges::distance(__range); |
| 707 | __assign_with_size(ranges::begin(__range), __n); | 703 | auto __first = ranges::begin(__range); |
| 704 | |||
| 705 | auto __result = std::ranges::copy_n(std::move(__first), std::min<size_t>(__n, size()), begin()); | ||
| 706 | |||
| 707 | if (static_cast<size_type>(__n) > size()) { | ||
| 708 | __append_with_size(std::move(__result.in), __n - size()); | ||
| 709 | } else { | ||
| 710 | __erase_to_end(__result.out); | ||
| 711 | } | ||
| 708 | 712 | ||
| 709 | } else { | 713 | } else { |
| 710 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | 714 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| ... | @@ -720,45 +724,53 @@ public: | ... | @@ -720,45 +724,53 @@ public: |
| 720 | 724 | ||
| 721 | // iterators: | 725 | // iterators: |
| 722 | 726 | ||
| 723 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { | 727 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { |
| 724 | __map_pointer __mp = __map_.begin() + __start_ / __block_size; | 728 | __map_pointer __mp = __map_.begin() + __start_ / __block_size; |
| 725 | return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size); | 729 | return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size); |
| 726 | } | 730 | } |
| 727 | 731 | ||
| 728 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { | 732 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { |
| 729 | __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size); | 733 | __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size); |
| 730 | return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size); | 734 | return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size); |
| 731 | } | 735 | } |
| 732 | 736 | ||
| 733 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { | 737 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { |
| 734 | size_type __p = size() + __start_; | 738 | size_type __p = size() + __start_; |
| 735 | __map_pointer __mp = __map_.begin() + __p / __block_size; | 739 | __map_pointer __mp = __map_.begin() + __p / __block_size; |
| 736 | return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size); | 740 | return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size); |
| 737 | } | 741 | } |
| 738 | 742 | ||
| 739 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { | 743 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { |
| 740 | size_type __p = size() + __start_; | 744 | size_type __p = size() + __start_; |
| 741 | __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size); | 745 | __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size); |
| 742 | return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size); | 746 | return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size); |
| 743 | } | 747 | } |
| 744 | 748 | ||
| 745 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } | 749 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } |
| 746 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 750 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { |
| 747 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | 751 | return const_reverse_iterator(end()); |
| 748 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 752 | } |
| 753 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | ||
| 754 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | ||
| 755 | return const_reverse_iterator(begin()); | ||
| 756 | } | ||
| 749 | 757 | ||
| 750 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | 758 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } |
| 751 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | 759 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } |
| 752 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 760 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { |
| 753 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 761 | return const_reverse_iterator(end()); |
| 762 | } | ||
| 763 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { | ||
| 764 | return const_reverse_iterator(begin()); | ||
| 765 | } | ||
| 754 | 766 | ||
| 755 | // capacity: | 767 | // capacity: |
| 756 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size(); } | 768 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size(); } |
| 757 | 769 | ||
| 758 | _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_; } | 770 | _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_; } |
| 759 | _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_; } | 771 | _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_; } |
| 760 | 772 | ||
| 761 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 773 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 762 | return std::min<size_type>(__alloc_traits::max_size(__alloc()), numeric_limits<difference_type>::max()); | 774 | return std::min<size_type>(__alloc_traits::max_size(__alloc()), numeric_limits<difference_type>::max()); |
| 763 | } | 775 | } |
| 764 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); | 776 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); |
| ... | @@ -767,18 +779,22 @@ public: | ... | @@ -767,18 +779,22 @@ public: |
| 767 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | 779 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } |
| 768 | 780 | ||
| 769 | // element access: | 781 | // element access: |
| 770 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT; | 782 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT; |
| 771 | _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __i) const _NOEXCEPT; | 783 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __i) const _NOEXCEPT; |
| 772 | _LIBCPP_HIDE_FROM_ABI reference at(size_type __i); | 784 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference at(size_type __i); |
| 773 | _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __i) const; | 785 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __i) const; |
| 774 | _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT; | 786 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT; |
| 775 | _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT; | 787 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT; |
| 776 | _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT; | 788 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT; |
| 777 | _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT; | 789 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT; |
| 778 | 790 | ||
| 779 | // 23.2.2.3 modifiers: | 791 | // 23.2.2.3 modifiers: |
| 780 | _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); | 792 | _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); |
| 781 | _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v); | 793 | _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v); |
| 794 | |||
| 795 | template <class... _Args> | ||
| 796 | _LIBCPP_HIDE_FROM_ABI iterator __emplace(const_iterator __p, _Args&&... __args); | ||
| 797 | |||
| 782 | # ifndef _LIBCPP_CXX03_LANG | 798 | # ifndef _LIBCPP_CXX03_LANG |
| 783 | # if _LIBCPP_STD_VER >= 17 | 799 | # if _LIBCPP_STD_VER >= 17 |
| 784 | template <class... _Args> | 800 | template <class... _Args> |
| ... | @@ -791,8 +807,11 @@ public: | ... | @@ -791,8 +807,11 @@ public: |
| 791 | template <class... _Args> | 807 | template <class... _Args> |
| 792 | _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); | 808 | _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); |
| 793 | # endif | 809 | # endif |
| 810 | |||
| 794 | template <class... _Args> | 811 | template <class... _Args> |
| 795 | _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args); | 812 | _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args) { |
| 813 | return __emplace(__p, std::forward<_Args>(__args)...); | ||
| 814 | } | ||
| 796 | 815 | ||
| 797 | _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); | 816 | _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); |
| 798 | _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v); | 817 | _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v); |
| ... | @@ -805,17 +824,21 @@ public: | ... | @@ -805,17 +824,21 @@ public: |
| 805 | 824 | ||
| 806 | template <_ContainerCompatibleRange<_Tp> _Range> | 825 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 807 | _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { | 826 | _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { |
| 808 | insert_range(end(), std::forward<_Range>(__range)); | 827 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| 828 | __append_with_size(ranges::begin(__range), ranges::distance(__range)); | ||
| 829 | } else { | ||
| 830 | __append_with_sentinel(ranges::begin(__range), ranges::end(__range)); | ||
| 831 | } | ||
| 809 | } | 832 | } |
| 810 | # endif | 833 | # endif |
| 811 | 834 | ||
| 812 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v); | 835 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { return __emplace(__p, std::move(__v)); } |
| 813 | 836 | ||
| 814 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) { | 837 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) { |
| 815 | return insert(__p, __il.begin(), __il.end()); | 838 | return insert(__p, __il.begin(), __il.end()); |
| 816 | } | 839 | } |
| 817 | # endif // _LIBCPP_CXX03_LANG | 840 | # endif // _LIBCPP_CXX03_LANG |
| 818 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v); | 841 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { return __emplace(__p, __v); } |
| 819 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v); | 842 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v); |
| 820 | template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0> | 843 | template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0> |
| 821 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l); | 844 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l); |
| ... | @@ -1109,7 +1132,7 @@ public: | ... | @@ -1109,7 +1132,7 @@ public: |
| 1109 | // This function tests deque object annotations. | 1132 | // This function tests deque object annotations. |
| 1110 | if (empty()) { | 1133 | if (empty()) { |
| 1111 | for (__map_const_iterator __it = __map_.begin(); __it != __map_.end(); ++__it) { | 1134 | for (__map_const_iterator __it = __map_.begin(); __it != __map_.end(); ++__it) { |
| 1112 | if (!__sanitizer_verify_double_ended_contiguous_container( | 1135 | if (!::__sanitizer_verify_double_ended_contiguous_container( |
| 1113 | std::__to_address(*__it), | 1136 | std::__to_address(*__it), |
| 1114 | std::__to_address(*__it), | 1137 | std::__to_address(*__it), |
| 1115 | std::__to_address(*__it), | 1138 | std::__to_address(*__it), |
| ... | @@ -1141,7 +1164,7 @@ public: | ... | @@ -1141,7 +1164,7 @@ public: |
| 1141 | 1164 | ||
| 1142 | // Is the block before or after deque blocks that contain elements? | 1165 | // Is the block before or after deque blocks that contain elements? |
| 1143 | if (__it < __first_mp || __it > __last_mp) { | 1166 | if (__it < __first_mp || __it > __last_mp) { |
| 1144 | if (!__sanitizer_verify_double_ended_contiguous_container( | 1167 | if (!::__sanitizer_verify_double_ended_contiguous_container( |
| 1145 | std::__to_address(*__it), | 1168 | std::__to_address(*__it), |
| 1146 | std::__to_address(*__it), | 1169 | std::__to_address(*__it), |
| 1147 | std::__to_address(*__it), | 1170 | std::__to_address(*__it), |
| ... | @@ -1151,7 +1174,7 @@ public: | ... | @@ -1151,7 +1174,7 @@ public: |
| 1151 | const void* __containers_buffer_beg = (__it == __first_mp) ? __p_beg : (const void*)std::__to_address(*__it); | 1174 | const void* __containers_buffer_beg = (__it == __first_mp) ? __p_beg : (const void*)std::__to_address(*__it); |
| 1152 | const void* __containers_buffer_end = | 1175 | const void* __containers_buffer_end = |
| 1153 | (__it == __last_mp) ? __p_end : (const void*)std::__to_address(*__it + __block_size); | 1176 | (__it == __last_mp) ? __p_end : (const void*)std::__to_address(*__it + __block_size); |
| 1154 | if (!__sanitizer_verify_double_ended_contiguous_container( | 1177 | if (!::__sanitizer_verify_double_ended_contiguous_container( |
| 1155 | std::__to_address(*__it), | 1178 | std::__to_address(*__it), |
| 1156 | __containers_buffer_beg, | 1179 | __containers_buffer_beg, |
| 1157 | __containers_buffer_end, | 1180 | __containers_buffer_end, |
| ... | @@ -1191,7 +1214,7 @@ private: | ... | @@ -1191,7 +1214,7 @@ private: |
| 1191 | 1214 | ||
| 1192 | template <class _RandomAccessIterator> | 1215 | template <class _RandomAccessIterator> |
| 1193 | _LIBCPP_HIDE_FROM_ABI void __assign_with_size_random_access(_RandomAccessIterator __f, difference_type __n); | 1216 | _LIBCPP_HIDE_FROM_ABI void __assign_with_size_random_access(_RandomAccessIterator __f, difference_type __n); |
| 1194 | template <class _Iterator> | 1217 | template <class _AlgPolicy, class _Iterator> |
| 1195 | _LIBCPP_HIDE_FROM_ABI void __assign_with_size(_Iterator __f, difference_type __n); | 1218 | _LIBCPP_HIDE_FROM_ABI void __assign_with_size(_Iterator __f, difference_type __n); |
| 1196 | 1219 | ||
| 1197 | template <class _Iterator, class _Sentinel> | 1220 | template <class _Iterator, class _Sentinel> |
| ... | @@ -1239,8 +1262,8 @@ private: | ... | @@ -1239,8 +1262,8 @@ private: |
| 1239 | clear(); | 1262 | clear(); |
| 1240 | shrink_to_fit(); | 1263 | shrink_to_fit(); |
| 1241 | } | 1264 | } |
| 1242 | __alloc() = __c.__alloc(); | 1265 | __alloc() = __c.__alloc(); |
| 1243 | __map_.__alloc_ = __c.__map_.__alloc_; | 1266 | __map_.__get_allocator() = __c.__map_.__get_allocator(); |
| 1244 | } | 1267 | } |
| 1245 | 1268 | ||
| 1246 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const deque&, false_type) {} | 1269 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const deque&, false_type) {} |
| ... | @@ -1256,22 +1279,22 @@ _LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque | ... | @@ -1256,22 +1279,22 @@ _LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque |
| 1256 | 1279 | ||
| 1257 | # if _LIBCPP_STD_VER >= 17 | 1280 | # if _LIBCPP_STD_VER >= 17 |
| 1258 | template <class _InputIterator, | 1281 | template <class _InputIterator, |
| 1259 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, | 1282 | class _Alloc = allocator<__iterator_value_type<_InputIterator>>, |
| 1260 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1283 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1261 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 1284 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 1262 | deque(_InputIterator, _InputIterator) -> deque<__iter_value_type<_InputIterator>, _Alloc>; | 1285 | deque(_InputIterator, _InputIterator) -> deque<__iterator_value_type<_InputIterator>, _Alloc>; |
| 1263 | 1286 | ||
| 1264 | template <class _InputIterator, | 1287 | template <class _InputIterator, |
| 1265 | class _Alloc, | 1288 | class _Alloc, |
| 1266 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1289 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1267 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 1290 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 1268 | deque(_InputIterator, _InputIterator, _Alloc) -> deque<__iter_value_type<_InputIterator>, _Alloc>; | 1291 | deque(_InputIterator, _InputIterator, _Alloc) -> deque<__iterator_value_type<_InputIterator>, _Alloc>; |
| 1269 | # endif | 1292 | # endif |
| 1270 | 1293 | ||
| 1271 | # if _LIBCPP_STD_VER >= 23 | 1294 | # if _LIBCPP_STD_VER >= 23 |
| 1272 | template <ranges::input_range _Range, | 1295 | template <ranges::input_range _Range, |
| 1273 | class _Alloc = allocator<ranges::range_value_t<_Range>>, | 1296 | class _Alloc = allocator<ranges::range_value_t<_Range>>, |
| 1274 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 1297 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 1275 | deque(from_range_t, _Range&&, _Alloc = _Alloc()) -> deque<ranges::range_value_t<_Range>, _Alloc>; | 1298 | deque(from_range_t, _Range&&, _Alloc = _Alloc()) -> deque<ranges::range_value_t<_Range>, _Alloc>; |
| 1276 | # endif | 1299 | # endif |
| 1277 | 1300 | ||
| ... | @@ -1319,7 +1342,7 @@ deque<_Tp, _Allocator>::deque(const deque& __c) | ... | @@ -1319,7 +1342,7 @@ deque<_Tp, _Allocator>::deque(const deque& __c) |
| 1319 | : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))), | 1342 | : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))), |
| 1320 | __start_(0), | 1343 | __start_(0), |
| 1321 | __size_(0), | 1344 | __size_(0), |
| 1322 | __alloc_(__map_.__alloc_) { | 1345 | __alloc_(__map_.__get_allocator()) { |
| 1323 | __annotate_new(0); | 1346 | __annotate_new(0); |
| 1324 | __append(__c.begin(), __c.end()); | 1347 | __append(__c.begin(), __c.end()); |
| 1325 | } | 1348 | } |
| ... | @@ -1451,24 +1474,6 @@ deque<_Tp, _Allocator>::__assign_with_size_random_access(_RandomAccessIterator _ | ... | @@ -1451,24 +1474,6 @@ deque<_Tp, _Allocator>::__assign_with_size_random_access(_RandomAccessIterator _ |
| 1451 | __erase_to_end(std::copy_n(__f, __n, begin())); | 1474 | __erase_to_end(std::copy_n(__f, __n, begin())); |
| 1452 | } | 1475 | } |
| 1453 | 1476 | ||
| 1454 | template <class _Tp, class _Allocator> | ||
| 1455 | template <class _Iterator> | ||
| 1456 | _LIBCPP_HIDE_FROM_ABI void deque<_Tp, _Allocator>::__assign_with_size(_Iterator __f, difference_type __n) { | ||
| 1457 | if (static_cast<size_type>(__n) > size()) { | ||
| 1458 | auto __added_size = __n - size(); | ||
| 1459 | |||
| 1460 | auto __i = begin(); | ||
| 1461 | for (auto __count = size(); __count != 0; --__count) { | ||
| 1462 | *__i++ = *__f++; | ||
| 1463 | } | ||
| 1464 | |||
| 1465 | __append_with_size(__f, __added_size); | ||
| 1466 | |||
| 1467 | } else { | ||
| 1468 | __erase_to_end(std::copy_n(__f, __n, begin())); | ||
| 1469 | } | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | template <class _Tp, class _Allocator> | 1477 | template <class _Tp, class _Allocator> |
| 1473 | void deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v) { | 1478 | void deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v) { |
| 1474 | if (__n > size()) { | 1479 | if (__n > size()) { |
| ... | @@ -1661,56 +1666,11 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) { | ... | @@ -1661,56 +1666,11 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) { |
| 1661 | return *begin(); | 1666 | return *begin(); |
| 1662 | # endif | 1667 | # endif |
| 1663 | } | 1668 | } |
| 1664 | 1669 | # endif // _LIBCPP_CXX03_LANG | |
| 1665 | template <class _Tp, class _Allocator> | ||
| 1666 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v) { | ||
| 1667 | size_type __pos = __p - begin(); | ||
| 1668 | size_type __to_end = size() - __pos; | ||
| 1669 | allocator_type& __a = __alloc(); | ||
| 1670 | if (__pos < __to_end) { // insert by shifting things backward | ||
| 1671 | if (__front_spare() == 0) | ||
| 1672 | __add_front_capacity(); | ||
| 1673 | // __front_spare() >= 1 | ||
| 1674 | __annotate_increase_front(1); | ||
| 1675 | if (__pos == 0) { | ||
| 1676 | __alloc_traits::construct(__a, std::addressof(*--begin()), std::move(__v)); | ||
| 1677 | --__start_; | ||
| 1678 | ++__size(); | ||
| 1679 | } else { | ||
| 1680 | iterator __b = begin(); | ||
| 1681 | iterator __bm1 = std::prev(__b); | ||
| 1682 | __alloc_traits::construct(__a, std::addressof(*__bm1), std::move(*__b)); | ||
| 1683 | --__start_; | ||
| 1684 | ++__size(); | ||
| 1685 | if (__pos > 1) | ||
| 1686 | __b = std::move(std::next(__b), __b + __pos, __b); | ||
| 1687 | *__b = std::move(__v); | ||
| 1688 | } | ||
| 1689 | } else { // insert by shifting things forward | ||
| 1690 | if (__back_spare() == 0) | ||
| 1691 | __add_back_capacity(); | ||
| 1692 | // __back_capacity >= 1 | ||
| 1693 | __annotate_increase_back(1); | ||
| 1694 | size_type __de = size() - __pos; | ||
| 1695 | if (__de == 0) { | ||
| 1696 | __alloc_traits::construct(__a, std::addressof(*end()), std::move(__v)); | ||
| 1697 | ++__size(); | ||
| 1698 | } else { | ||
| 1699 | iterator __e = end(); | ||
| 1700 | iterator __em1 = std::prev(__e); | ||
| 1701 | __alloc_traits::construct(__a, std::addressof(*__e), std::move(*__em1)); | ||
| 1702 | ++__size(); | ||
| 1703 | if (__de > 1) | ||
| 1704 | __e = std::move_backward(__e - __de, __em1, __e); | ||
| 1705 | *--__e = std::move(__v); | ||
| 1706 | } | ||
| 1707 | } | ||
| 1708 | return begin() + __pos; | ||
| 1709 | } | ||
| 1710 | 1670 | ||
| 1711 | template <class _Tp, class _Allocator> | 1671 | template <class _Tp, class _Allocator> |
| 1712 | template <class... _Args> | 1672 | template <class... _Args> |
| 1713 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args) { | 1673 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::__emplace(const_iterator __p, _Args&&... __args) { |
| 1714 | size_type __pos = __p - begin(); | 1674 | size_type __pos = __p - begin(); |
| 1715 | size_type __to_end = size() - __pos; | 1675 | size_type __to_end = size() - __pos; |
| 1716 | allocator_type& __a = __alloc(); | 1676 | allocator_type& __a = __alloc(); |
| ... | @@ -1757,60 +1717,6 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::emplace(const_ | ... | @@ -1757,60 +1717,6 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::emplace(const_ |
| 1757 | return begin() + __pos; | 1717 | return begin() + __pos; |
| 1758 | } | 1718 | } |
| 1759 | 1719 | ||
| 1760 | # endif // _LIBCPP_CXX03_LANG | ||
| 1761 | |||
| 1762 | template <class _Tp, class _Allocator> | ||
| 1763 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v) { | ||
| 1764 | size_type __pos = __p - begin(); | ||
| 1765 | size_type __to_end = size() - __pos; | ||
| 1766 | allocator_type& __a = __alloc(); | ||
| 1767 | if (__pos < __to_end) { // insert by shifting things backward | ||
| 1768 | if (__front_spare() == 0) | ||
| 1769 | __add_front_capacity(); | ||
| 1770 | // __front_spare() >= 1 | ||
| 1771 | __annotate_increase_front(1); | ||
| 1772 | if (__pos == 0) { | ||
| 1773 | __alloc_traits::construct(__a, std::addressof(*--begin()), __v); | ||
| 1774 | --__start_; | ||
| 1775 | ++__size(); | ||
| 1776 | } else { | ||
| 1777 | const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v); | ||
| 1778 | iterator __b = begin(); | ||
| 1779 | iterator __bm1 = std::prev(__b); | ||
| 1780 | if (__vt == pointer_traits<const_pointer>::pointer_to(*__b)) | ||
| 1781 | __vt = pointer_traits<const_pointer>::pointer_to(*__bm1); | ||
| 1782 | __alloc_traits::construct(__a, std::addressof(*__bm1), std::move(*__b)); | ||
| 1783 | --__start_; | ||
| 1784 | ++__size(); | ||
| 1785 | if (__pos > 1) | ||
| 1786 | __b = __move_and_check(std::next(__b), __b + __pos, __b, __vt); | ||
| 1787 | *__b = *__vt; | ||
| 1788 | } | ||
| 1789 | } else { // insert by shifting things forward | ||
| 1790 | if (__back_spare() == 0) | ||
| 1791 | __add_back_capacity(); | ||
| 1792 | // __back_capacity >= 1 | ||
| 1793 | __annotate_increase_back(1); | ||
| 1794 | size_type __de = size() - __pos; | ||
| 1795 | if (__de == 0) { | ||
| 1796 | __alloc_traits::construct(__a, std::addressof(*end()), __v); | ||
| 1797 | ++__size(); | ||
| 1798 | } else { | ||
| 1799 | const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v); | ||
| 1800 | iterator __e = end(); | ||
| 1801 | iterator __em1 = std::prev(__e); | ||
| 1802 | if (__vt == pointer_traits<const_pointer>::pointer_to(*__em1)) | ||
| 1803 | __vt = pointer_traits<const_pointer>::pointer_to(*__e); | ||
| 1804 | __alloc_traits::construct(__a, std::addressof(*__e), std::move(*__em1)); | ||
| 1805 | ++__size(); | ||
| 1806 | if (__de > 1) | ||
| 1807 | __e = __move_backward_and_check(__e - __de, __em1, __e, __vt); | ||
| 1808 | *--__e = *__vt; | ||
| 1809 | } | ||
| 1810 | } | ||
| 1811 | return begin() + __pos; | ||
| 1812 | } | ||
| 1813 | |||
| 1814 | template <class _Tp, class _Allocator> | 1720 | template <class _Tp, class _Allocator> |
| 1815 | typename deque<_Tp, _Allocator>::iterator | 1721 | typename deque<_Tp, _Allocator>::iterator |
| 1816 | deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_type& __v) { | 1722 | deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_type& __v) { |
| ... | @@ -1874,9 +1780,9 @@ template <class _Tp, class _Allocator> | ... | @@ -1874,9 +1780,9 @@ template <class _Tp, class _Allocator> |
| 1874 | template <class _Iterator, class _Sentinel> | 1780 | template <class _Iterator, class _Sentinel> |
| 1875 | _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::iterator | 1781 | _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::iterator |
| 1876 | deque<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) { | 1782 | deque<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) { |
| 1877 | __split_buffer<value_type, allocator_type&> __buf(__alloc()); | 1783 | __split_buffer<value_type, allocator_type> __buf(__alloc()); |
| 1878 | __buf.__construct_at_end_with_sentinel(std::move(__f), std::move(__l)); | 1784 | __buf.__construct_at_end_with_sentinel(std::move(__f), std::move(__l)); |
| 1879 | typedef typename __split_buffer<value_type, allocator_type&>::iterator __bi; | 1785 | typedef typename __split_buffer<value_type, allocator_type>::iterator __bi; |
| 1880 | return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end())); | 1786 | return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end())); |
| 1881 | } | 1787 | } |
| 1882 | 1788 | ||
| ... | @@ -1891,9 +1797,9 @@ template <class _Tp, class _Allocator> | ... | @@ -1891,9 +1797,9 @@ template <class _Tp, class _Allocator> |
| 1891 | template <class _Iterator> | 1797 | template <class _Iterator> |
| 1892 | _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::iterator | 1798 | _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::iterator |
| 1893 | deque<_Tp, _Allocator>::__insert_with_size(const_iterator __p, _Iterator __f, size_type __n) { | 1799 | deque<_Tp, _Allocator>::__insert_with_size(const_iterator __p, _Iterator __f, size_type __n) { |
| 1894 | __split_buffer<value_type, allocator_type&> __buf(__n, 0, __alloc()); | 1800 | __split_buffer<value_type, allocator_type> __buf(__n, 0, __alloc()); |
| 1895 | __buf.__construct_at_end_with_size(__f, __n); | 1801 | __buf.__construct_at_end_with_size(std::move(__f), __n); |
| 1896 | typedef typename __split_buffer<value_type, allocator_type&>::iterator __fwd; | 1802 | typedef typename __split_buffer<value_type, allocator_type>::iterator __fwd; |
| 1897 | return insert(__p, move_iterator<__fwd>(__buf.begin()), move_iterator<__fwd>(__buf.end())); | 1803 | return insert(__p, move_iterator<__fwd>(__buf.begin()), move_iterator<__fwd>(__buf.end())); |
| 1898 | } | 1804 | } |
| 1899 | 1805 | ||
| ... | @@ -2071,8 +1977,8 @@ void deque<_Tp, _Allocator>::__add_front_capacity() { | ... | @@ -2071,8 +1977,8 @@ void deque<_Tp, _Allocator>::__add_front_capacity() { |
| 2071 | } | 1977 | } |
| 2072 | // Else need to allocate 1 buffer, *and* we need to reallocate __map_. | 1978 | // Else need to allocate 1 buffer, *and* we need to reallocate __map_. |
| 2073 | else { | 1979 | else { |
| 2074 | __split_buffer<pointer, __pointer_allocator&> __buf( | 1980 | __split_buffer<pointer, __pointer_allocator> __buf( |
| 2075 | std::max<size_type>(2 * __map_.capacity(), 1), 0, __map_.__alloc_); | 1981 | std::max<size_type>(2 * __map_.capacity(), 1), 0, __map_.__get_allocator()); |
| 2076 | 1982 | ||
| 2077 | typedef __allocator_destructor<_Allocator> _Dp; | 1983 | typedef __allocator_destructor<_Allocator> _Dp; |
| 2078 | unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size)); | 1984 | unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size)); |
| ... | @@ -2081,10 +1987,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity() { | ... | @@ -2081,10 +1987,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity() { |
| 2081 | 1987 | ||
| 2082 | for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i) | 1988 | for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i) |
| 2083 | __buf.emplace_back(*__i); | 1989 | __buf.emplace_back(*__i); |
| 2084 | std::swap(__map_.__first_, __buf.__first_); | 1990 | __map_.__swap_without_allocator(__buf); |
| 2085 | std::swap(__map_.__begin_, __buf.__begin_); | ||
| 2086 | std::swap(__map_.__end_, __buf.__end_); | ||
| 2087 | std::swap(__map_.__cap_, __buf.__cap_); | ||
| 2088 | __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size; | 1991 | __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size; |
| 2089 | } | 1992 | } |
| 2090 | __annotate_whole_block(0, __asan_poison); | 1993 | __annotate_whole_block(0, __asan_poison); |
| ... | @@ -2134,34 +2037,26 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) { | ... | @@ -2134,34 +2037,26 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) { |
| 2134 | // Else need to allocate __nb buffers, *and* we need to reallocate __map_. | 2037 | // Else need to allocate __nb buffers, *and* we need to reallocate __map_. |
| 2135 | else { | 2038 | else { |
| 2136 | size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty(); | 2039 | size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty(); |
| 2137 | __split_buffer<pointer, __pointer_allocator&> __buf( | 2040 | __split_buffer<pointer, __pointer_allocator> __buf( |
| 2138 | std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__alloc_); | 2041 | std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__get_allocator()); |
| 2139 | # if _LIBCPP_HAS_EXCEPTIONS | 2042 | auto __guard = std::__make_exception_guard([&] { |
| 2140 | try { | ||
| 2141 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2142 | for (; __nb > 0; --__nb) { | ||
| 2143 | __buf.emplace_back(__alloc_traits::allocate(__a, __block_size)); | ||
| 2144 | // ASan: this is empty container, we have to poison whole block | ||
| 2145 | __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); | ||
| 2146 | } | ||
| 2147 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2148 | } catch (...) { | ||
| 2149 | __annotate_delete(); | 2043 | __annotate_delete(); |
| 2150 | for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) | 2044 | for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) |
| 2151 | __alloc_traits::deallocate(__a, *__i, __block_size); | 2045 | __alloc_traits::deallocate(__a, *__i, __block_size); |
| 2152 | throw; | 2046 | }); |
| 2047 | for (; __nb > 0; --__nb) { | ||
| 2048 | __buf.emplace_back(__alloc_traits::allocate(__a, __block_size)); | ||
| 2049 | // ASan: this is empty container, we have to poison whole block | ||
| 2050 | __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); | ||
| 2153 | } | 2051 | } |
| 2154 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2052 | __guard.__complete(); |
| 2155 | for (; __back_capacity > 0; --__back_capacity) { | 2053 | for (; __back_capacity > 0; --__back_capacity) { |
| 2156 | __buf.emplace_back(__map_.back()); | 2054 | __buf.emplace_back(__map_.back()); |
| 2157 | __map_.pop_back(); | 2055 | __map_.pop_back(); |
| 2158 | } | 2056 | } |
| 2159 | for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i) | 2057 | for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i) |
| 2160 | __buf.emplace_back(*__i); | 2058 | __buf.emplace_back(*__i); |
| 2161 | std::swap(__map_.__first_, __buf.__first_); | 2059 | __map_.__swap_without_allocator(__buf); |
| 2162 | std::swap(__map_.__begin_, __buf.__begin_); | ||
| 2163 | std::swap(__map_.__end_, __buf.__end_); | ||
| 2164 | std::swap(__map_.__cap_, __buf.__cap_); | ||
| 2165 | __start_ += __ds; | 2060 | __start_ += __ds; |
| 2166 | } | 2061 | } |
| 2167 | } | 2062 | } |
| ... | @@ -2194,8 +2089,8 @@ void deque<_Tp, _Allocator>::__add_back_capacity() { | ... | @@ -2194,8 +2089,8 @@ void deque<_Tp, _Allocator>::__add_back_capacity() { |
| 2194 | } | 2089 | } |
| 2195 | // Else need to allocate 1 buffer, *and* we need to reallocate __map_. | 2090 | // Else need to allocate 1 buffer, *and* we need to reallocate __map_. |
| 2196 | else { | 2091 | else { |
| 2197 | __split_buffer<pointer, __pointer_allocator&> __buf( | 2092 | __split_buffer<pointer, __pointer_allocator> __buf( |
| 2198 | std::max<size_type>(2 * __map_.capacity(), 1), __map_.size(), __map_.__alloc_); | 2093 | std::max<size_type>(2 * __map_.capacity(), 1), __map_.size(), __map_.__get_allocator()); |
| 2199 | 2094 | ||
| 2200 | typedef __allocator_destructor<_Allocator> _Dp; | 2095 | typedef __allocator_destructor<_Allocator> _Dp; |
| 2201 | unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size)); | 2096 | unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size)); |
| ... | @@ -2204,10 +2099,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity() { | ... | @@ -2204,10 +2099,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity() { |
| 2204 | 2099 | ||
| 2205 | for (__map_pointer __i = __map_.end(); __i != __map_.begin();) | 2100 | for (__map_pointer __i = __map_.end(); __i != __map_.begin();) |
| 2206 | __buf.emplace_front(*--__i); | 2101 | __buf.emplace_front(*--__i); |
| 2207 | std::swap(__map_.__first_, __buf.__first_); | 2102 | __map_.__swap_without_allocator(__buf); |
| 2208 | std::swap(__map_.__begin_, __buf.__begin_); | ||
| 2209 | std::swap(__map_.__end_, __buf.__end_); | ||
| 2210 | std::swap(__map_.__cap_, __buf.__cap_); | ||
| 2211 | __annotate_whole_block(__map_.size() - 1, __asan_poison); | 2103 | __annotate_whole_block(__map_.size() - 1, __asan_poison); |
| 2212 | } | 2104 | } |
| 2213 | } | 2105 | } |
| ... | @@ -2257,36 +2149,28 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { | ... | @@ -2257,36 +2149,28 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { |
| 2257 | // Else need to allocate __nb buffers, *and* we need to reallocate __map_. | 2149 | // Else need to allocate __nb buffers, *and* we need to reallocate __map_. |
| 2258 | else { | 2150 | else { |
| 2259 | size_type __ds = __front_capacity * __block_size; | 2151 | size_type __ds = __front_capacity * __block_size; |
| 2260 | __split_buffer<pointer, __pointer_allocator&> __buf( | 2152 | __split_buffer<pointer, __pointer_allocator> __buf( |
| 2261 | std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), | 2153 | std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), |
| 2262 | __map_.size() - __front_capacity, | 2154 | __map_.size() - __front_capacity, |
| 2263 | __map_.__alloc_); | 2155 | __map_.__get_allocator()); |
| 2264 | # if _LIBCPP_HAS_EXCEPTIONS | 2156 | auto __guard = std::__make_exception_guard([&] { |
| 2265 | try { | ||
| 2266 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2267 | for (; __nb > 0; --__nb) { | ||
| 2268 | __buf.emplace_back(__alloc_traits::allocate(__a, __block_size)); | ||
| 2269 | // ASan: this is an empty container, we have to poison the whole block | ||
| 2270 | __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); | ||
| 2271 | } | ||
| 2272 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2273 | } catch (...) { | ||
| 2274 | __annotate_delete(); | 2157 | __annotate_delete(); |
| 2275 | for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) | 2158 | for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) |
| 2276 | __alloc_traits::deallocate(__a, *__i, __block_size); | 2159 | __alloc_traits::deallocate(__a, *__i, __block_size); |
| 2277 | throw; | 2160 | }); |
| 2161 | for (; __nb > 0; --__nb) { | ||
| 2162 | __buf.emplace_back(__alloc_traits::allocate(__a, __block_size)); | ||
| 2163 | // ASan: this is an empty container, we have to poison the whole block | ||
| 2164 | __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); | ||
| 2278 | } | 2165 | } |
| 2279 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2166 | __guard.__complete(); |
| 2280 | for (; __front_capacity > 0; --__front_capacity) { | 2167 | for (; __front_capacity > 0; --__front_capacity) { |
| 2281 | __buf.emplace_back(__map_.front()); | 2168 | __buf.emplace_back(__map_.front()); |
| 2282 | __map_.pop_front(); | 2169 | __map_.pop_front(); |
| 2283 | } | 2170 | } |
| 2284 | for (__map_pointer __i = __map_.end(); __i != __map_.begin();) | 2171 | for (__map_pointer __i = __map_.end(); __i != __map_.begin();) |
| 2285 | __buf.emplace_front(*--__i); | 2172 | __buf.emplace_front(*--__i); |
| 2286 | std::swap(__map_.__first_, __buf.__first_); | 2173 | __map_.__swap_without_allocator(__buf); |
| 2287 | std::swap(__map_.__begin_, __buf.__begin_); | ||
| 2288 | std::swap(__map_.__end_, __buf.__end_); | ||
| 2289 | std::swap(__map_.__cap_, __buf.__cap_); | ||
| 2290 | __start_ -= __ds; | 2174 | __start_ -= __ds; |
| 2291 | } | 2175 | } |
| 2292 | } | 2176 | } |
lib/libcxx/include/errno.h+269-269| ... | @@ -23,381 +23,381 @@ Macros: | ... | @@ -23,381 +23,381 @@ Macros: |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 25 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 26 | # include <__cxx03/errno.h> | 26 | # include <__cxx03/__config> |
| 27 | #else | 27 | #else |
| 28 | # include <__config> | 28 | # include <__config> |
| 29 | #endif | ||
| 29 | 30 | ||
| 30 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 31 | # pragma GCC system_header | 32 | # pragma GCC system_header |
| 32 | # endif | 33 | #endif |
| 33 | 34 | ||
| 34 | # if __has_include_next(<errno.h>) | 35 | #if __has_include_next(<errno.h>) |
| 35 | # include_next <errno.h> | 36 | # include_next <errno.h> |
| 36 | # endif | 37 | #endif |
| 37 | 38 | ||
| 38 | # ifdef __cplusplus | 39 | #ifdef __cplusplus |
| 39 | 40 | ||
| 40 | # if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) | 41 | # if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) |
| 41 | 42 | ||
| 42 | # ifdef ELAST | 43 | # ifdef ELAST |
| 43 | 44 | ||
| 44 | static const int __elast1 = ELAST + 1; | 45 | static const int __elast1 = ELAST + 1; |
| 45 | static const int __elast2 = ELAST + 2; | 46 | static const int __elast2 = ELAST + 2; |
| 46 | 47 | ||
| 47 | # else | 48 | # else |
| 48 | 49 | ||
| 49 | static const int __elast1 = 104; | 50 | static const int __elast1 = 104; |
| 50 | static const int __elast2 = 105; | 51 | static const int __elast2 = 105; |
| 51 | 52 | ||
| 52 | # endif | 53 | # endif |
| 53 | 54 | ||
| 54 | # ifdef ENOTRECOVERABLE | 55 | # ifdef ENOTRECOVERABLE |
| 55 | 56 | ||
| 56 | # define EOWNERDEAD __elast1 | 57 | # define EOWNERDEAD __elast1 |
| 57 | 58 | ||
| 58 | # ifdef ELAST | 59 | # ifdef ELAST |
| 59 | # undef ELAST | 60 | # undef ELAST |
| 60 | # define ELAST EOWNERDEAD | 61 | # define ELAST EOWNERDEAD |
| 61 | # endif | 62 | # endif |
| 62 | 63 | ||
| 63 | # elif defined(EOWNERDEAD) | 64 | # elif defined(EOWNERDEAD) |
| 64 | 65 | ||
| 65 | # define ENOTRECOVERABLE __elast1 | 66 | # define ENOTRECOVERABLE __elast1 |
| 66 | # ifdef ELAST | 67 | # ifdef ELAST |
| 67 | # undef ELAST | 68 | # undef ELAST |
| 68 | # define ELAST ENOTRECOVERABLE | 69 | # define ELAST ENOTRECOVERABLE |
| 69 | # endif | 70 | # endif |
| 70 | 71 | ||
| 71 | # else // defined(EOWNERDEAD) | 72 | # else // defined(EOWNERDEAD) |
| 72 | 73 | ||
| 73 | # define EOWNERDEAD __elast1 | 74 | # define EOWNERDEAD __elast1 |
| 74 | # define ENOTRECOVERABLE __elast2 | 75 | # define ENOTRECOVERABLE __elast2 |
| 75 | # ifdef ELAST | 76 | # ifdef ELAST |
| 76 | # undef ELAST | 77 | # undef ELAST |
| 77 | # define ELAST ENOTRECOVERABLE | 78 | # define ELAST ENOTRECOVERABLE |
| 78 | # endif | 79 | # endif |
| 79 | 80 | ||
| 80 | # endif // defined(EOWNERDEAD) | 81 | # endif // defined(EOWNERDEAD) |
| 81 | 82 | ||
| 82 | # endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) | 83 | # endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) |
| 83 | 84 | ||
| 84 | // supply errno values likely to be missing, particularly on Windows | 85 | // supply errno values likely to be missing, particularly on Windows |
| 85 | 86 | ||
| 86 | # ifndef EAFNOSUPPORT | 87 | # ifndef EAFNOSUPPORT |
| 87 | # define EAFNOSUPPORT 9901 | 88 | # define EAFNOSUPPORT 9901 |
| 88 | # endif | 89 | # endif |
| 89 | 90 | ||
| 90 | # ifndef EADDRINUSE | 91 | # ifndef EADDRINUSE |
| 91 | # define EADDRINUSE 9902 | 92 | # define EADDRINUSE 9902 |
| 92 | # endif | 93 | # endif |
| 93 | 94 | ||
| 94 | # ifndef EADDRNOTAVAIL | 95 | # ifndef EADDRNOTAVAIL |
| 95 | # define EADDRNOTAVAIL 9903 | 96 | # define EADDRNOTAVAIL 9903 |
| 96 | # endif | 97 | # endif |
| 97 | 98 | ||
| 98 | # ifndef EISCONN | 99 | # ifndef EISCONN |
| 99 | # define EISCONN 9904 | 100 | # define EISCONN 9904 |
| 100 | # endif | 101 | # endif |
| 101 | 102 | ||
| 102 | # ifndef EBADMSG | 103 | # ifndef EBADMSG |
| 103 | # define EBADMSG 9905 | 104 | # define EBADMSG 9905 |
| 104 | # endif | 105 | # endif |
| 105 | 106 | ||
| 106 | # ifndef ECONNABORTED | 107 | # ifndef ECONNABORTED |
| 107 | # define ECONNABORTED 9906 | 108 | # define ECONNABORTED 9906 |
| 108 | # endif | 109 | # endif |
| 109 | 110 | ||
| 110 | # ifndef EALREADY | 111 | # ifndef EALREADY |
| 111 | # define EALREADY 9907 | 112 | # define EALREADY 9907 |
| 112 | # endif | 113 | # endif |
| 113 | 114 | ||
| 114 | # ifndef ECONNREFUSED | 115 | # ifndef ECONNREFUSED |
| 115 | # define ECONNREFUSED 9908 | 116 | # define ECONNREFUSED 9908 |
| 116 | # endif | 117 | # endif |
| 117 | 118 | ||
| 118 | # ifndef ECONNRESET | 119 | # ifndef ECONNRESET |
| 119 | # define ECONNRESET 9909 | 120 | # define ECONNRESET 9909 |
| 120 | # endif | 121 | # endif |
| 121 | 122 | ||
| 122 | # ifndef EDESTADDRREQ | 123 | # ifndef EDESTADDRREQ |
| 123 | # define EDESTADDRREQ 9910 | 124 | # define EDESTADDRREQ 9910 |
| 124 | # endif | 125 | # endif |
| 125 | 126 | ||
| 126 | # ifndef EHOSTUNREACH | 127 | # ifndef EHOSTUNREACH |
| 127 | # define EHOSTUNREACH 9911 | 128 | # define EHOSTUNREACH 9911 |
| 128 | # endif | 129 | # endif |
| 129 | 130 | ||
| 130 | # ifndef EIDRM | 131 | # ifndef EIDRM |
| 131 | # define EIDRM 9912 | 132 | # define EIDRM 9912 |
| 132 | # endif | 133 | # endif |
| 133 | 134 | ||
| 134 | # ifndef EMSGSIZE | 135 | # ifndef EMSGSIZE |
| 135 | # define EMSGSIZE 9913 | 136 | # define EMSGSIZE 9913 |
| 136 | # endif | 137 | # endif |
| 137 | 138 | ||
| 138 | # ifndef ENETDOWN | 139 | # ifndef ENETDOWN |
| 139 | # define ENETDOWN 9914 | 140 | # define ENETDOWN 9914 |
| 140 | # endif | 141 | # endif |
| 141 | 142 | ||
| 142 | # ifndef ENETRESET | 143 | # ifndef ENETRESET |
| 143 | # define ENETRESET 9915 | 144 | # define ENETRESET 9915 |
| 144 | # endif | 145 | # endif |
| 145 | 146 | ||
| 146 | # ifndef ENETUNREACH | 147 | # ifndef ENETUNREACH |
| 147 | # define ENETUNREACH 9916 | 148 | # define ENETUNREACH 9916 |
| 148 | # endif | 149 | # endif |
| 149 | 150 | ||
| 150 | # ifndef ENOBUFS | 151 | # ifndef ENOBUFS |
| 151 | # define ENOBUFS 9917 | 152 | # define ENOBUFS 9917 |
| 152 | # endif | 153 | # endif |
| 153 | 154 | ||
| 154 | # ifndef ENOLINK | 155 | # ifndef ENOLINK |
| 155 | # define ENOLINK 9918 | 156 | # define ENOLINK 9918 |
| 156 | # endif | 157 | # endif |
| 157 | 158 | ||
| 158 | # ifndef ENODATA | 159 | # ifndef ENODATA |
| 159 | # define ENODATA 9919 | 160 | # define ENODATA 9919 |
| 160 | # endif | 161 | # endif |
| 161 | 162 | ||
| 162 | # ifndef ENOMSG | 163 | # ifndef ENOMSG |
| 163 | # define ENOMSG 9920 | 164 | # define ENOMSG 9920 |
| 164 | # endif | 165 | # endif |
| 165 | 166 | ||
| 166 | # ifndef ENOPROTOOPT | 167 | # ifndef ENOPROTOOPT |
| 167 | # define ENOPROTOOPT 9921 | 168 | # define ENOPROTOOPT 9921 |
| 168 | # endif | 169 | # endif |
| 169 | 170 | ||
| 170 | # ifndef ENOSR | 171 | # ifndef ENOSR |
| 171 | # define ENOSR 9922 | 172 | # define ENOSR 9922 |
| 172 | # endif | 173 | # endif |
| 173 | 174 | ||
| 174 | # ifndef ENOTSOCK | 175 | # ifndef ENOTSOCK |
| 175 | # define ENOTSOCK 9923 | 176 | # define ENOTSOCK 9923 |
| 176 | # endif | 177 | # endif |
| 177 | 178 | ||
| 178 | # ifndef ENOSTR | 179 | # ifndef ENOSTR |
| 179 | # define ENOSTR 9924 | 180 | # define ENOSTR 9924 |
| 180 | # endif | 181 | # endif |
| 181 | 182 | ||
| 182 | # ifndef ENOTCONN | 183 | # ifndef ENOTCONN |
| 183 | # define ENOTCONN 9925 | 184 | # define ENOTCONN 9925 |
| 184 | # endif | 185 | # endif |
| 185 | 186 | ||
| 186 | # ifndef ENOTSUP | 187 | # ifndef ENOTSUP |
| 187 | # define ENOTSUP 9926 | 188 | # define ENOTSUP 9926 |
| 188 | # endif | 189 | # endif |
| 189 | 190 | ||
| 190 | # ifndef ECANCELED | 191 | # ifndef ECANCELED |
| 191 | # define ECANCELED 9927 | 192 | # define ECANCELED 9927 |
| 192 | # endif | 193 | # endif |
| 193 | 194 | ||
| 194 | # ifndef EINPROGRESS | 195 | # ifndef EINPROGRESS |
| 195 | # define EINPROGRESS 9928 | 196 | # define EINPROGRESS 9928 |
| 196 | # endif | 197 | # endif |
| 197 | 198 | ||
| 198 | # ifndef EOPNOTSUPP | 199 | # ifndef EOPNOTSUPP |
| 199 | # define EOPNOTSUPP 9929 | 200 | # define EOPNOTSUPP 9929 |
| 200 | # endif | 201 | # endif |
| 201 | 202 | ||
| 202 | # ifndef EWOULDBLOCK | 203 | # ifndef EWOULDBLOCK |
| 203 | # define EWOULDBLOCK 9930 | 204 | # define EWOULDBLOCK 9930 |
| 204 | # endif | 205 | # endif |
| 205 | 206 | ||
| 206 | # ifndef EOWNERDEAD | 207 | # ifndef EOWNERDEAD |
| 207 | # define EOWNERDEAD 9931 | 208 | # define EOWNERDEAD 9931 |
| 208 | # endif | 209 | # endif |
| 209 | 210 | ||
| 210 | # ifndef EPROTO | 211 | # ifndef EPROTO |
| 211 | # define EPROTO 9932 | 212 | # define EPROTO 9932 |
| 212 | # endif | 213 | # endif |
| 213 | 214 | ||
| 214 | # ifndef EPROTONOSUPPORT | 215 | # ifndef EPROTONOSUPPORT |
| 215 | # define EPROTONOSUPPORT 9933 | 216 | # define EPROTONOSUPPORT 9933 |
| 216 | # endif | 217 | # endif |
| 217 | 218 | ||
| 218 | # ifndef ENOTRECOVERABLE | 219 | # ifndef ENOTRECOVERABLE |
| 219 | # define ENOTRECOVERABLE 9934 | 220 | # define ENOTRECOVERABLE 9934 |
| 220 | # endif | 221 | # endif |
| 221 | 222 | ||
| 222 | # ifndef ETIME | 223 | # ifndef ETIME |
| 223 | # define ETIME 9935 | 224 | # define ETIME 9935 |
| 224 | # endif | 225 | # endif |
| 225 | 226 | ||
| 226 | # ifndef ETXTBSY | 227 | # ifndef ETXTBSY |
| 227 | # define ETXTBSY 9936 | 228 | # define ETXTBSY 9936 |
| 228 | # endif | 229 | # endif |
| 229 | 230 | ||
| 230 | # ifndef ETIMEDOUT | 231 | # ifndef ETIMEDOUT |
| 231 | # define ETIMEDOUT 9938 | 232 | # define ETIMEDOUT 9938 |
| 232 | # endif | 233 | # endif |
| 233 | 234 | ||
| 234 | # ifndef ELOOP | 235 | # ifndef ELOOP |
| 235 | # define ELOOP 9939 | 236 | # define ELOOP 9939 |
| 236 | # endif | 237 | # endif |
| 237 | 238 | ||
| 238 | # ifndef EOVERFLOW | 239 | # ifndef EOVERFLOW |
| 239 | # define EOVERFLOW 9940 | 240 | # define EOVERFLOW 9940 |
| 240 | # endif | 241 | # endif |
| 241 | 242 | ||
| 242 | # ifndef EPROTOTYPE | 243 | # ifndef EPROTOTYPE |
| 243 | # define EPROTOTYPE 9941 | 244 | # define EPROTOTYPE 9941 |
| 244 | # endif | 245 | # endif |
| 245 | 246 | ||
| 246 | # ifndef ENOSYS | 247 | # ifndef ENOSYS |
| 247 | # define ENOSYS 9942 | 248 | # define ENOSYS 9942 |
| 248 | # endif | 249 | # endif |
| 249 | 250 | ||
| 250 | # ifndef EINVAL | 251 | # ifndef EINVAL |
| 251 | # define EINVAL 9943 | 252 | # define EINVAL 9943 |
| 252 | # endif | 253 | # endif |
| 253 | 254 | ||
| 254 | # ifndef ERANGE | 255 | # ifndef ERANGE |
| 255 | # define ERANGE 9944 | 256 | # define ERANGE 9944 |
| 256 | # endif | 257 | # endif |
| 257 | 258 | ||
| 258 | # ifndef EILSEQ | 259 | # ifndef EILSEQ |
| 259 | # define EILSEQ 9945 | 260 | # define EILSEQ 9945 |
| 260 | # endif | 261 | # endif |
| 261 | 262 | ||
| 262 | // Windows Mobile doesn't appear to define these: | 263 | // Windows Mobile doesn't appear to define these: |
| 263 | 264 | ||
| 264 | # ifndef E2BIG | 265 | # ifndef E2BIG |
| 265 | # define E2BIG 9946 | 266 | # define E2BIG 9946 |
| 266 | # endif | 267 | # endif |
| 267 | 268 | ||
| 268 | # ifndef EDOM | 269 | # ifndef EDOM |
| 269 | # define EDOM 9947 | 270 | # define EDOM 9947 |
| 270 | # endif | 271 | # endif |
| 271 | 272 | ||
| 272 | # ifndef EFAULT | 273 | # ifndef EFAULT |
| 273 | # define EFAULT 9948 | 274 | # define EFAULT 9948 |
| 274 | # endif | 275 | # endif |
| 275 | 276 | ||
| 276 | # ifndef EBADF | 277 | # ifndef EBADF |
| 277 | # define EBADF 9949 | 278 | # define EBADF 9949 |
| 278 | # endif | 279 | # endif |
| 279 | 280 | ||
| 280 | # ifndef EPIPE | 281 | # ifndef EPIPE |
| 281 | # define EPIPE 9950 | 282 | # define EPIPE 9950 |
| 282 | # endif | 283 | # endif |
| 283 | 284 | ||
| 284 | # ifndef EXDEV | 285 | # ifndef EXDEV |
| 285 | # define EXDEV 9951 | 286 | # define EXDEV 9951 |
| 286 | # endif | 287 | # endif |
| 287 | 288 | ||
| 288 | # ifndef EBUSY | 289 | # ifndef EBUSY |
| 289 | # define EBUSY 9952 | 290 | # define EBUSY 9952 |
| 290 | # endif | 291 | # endif |
| 291 | 292 | ||
| 292 | # ifndef ENOTEMPTY | 293 | # ifndef ENOTEMPTY |
| 293 | # define ENOTEMPTY 9953 | 294 | # define ENOTEMPTY 9953 |
| 294 | # endif | 295 | # endif |
| 295 | 296 | ||
| 296 | # ifndef ENOEXEC | 297 | # ifndef ENOEXEC |
| 297 | # define ENOEXEC 9954 | 298 | # define ENOEXEC 9954 |
| 298 | # endif | 299 | # endif |
| 299 | 300 | ||
| 300 | # ifndef EEXIST | 301 | # ifndef EEXIST |
| 301 | # define EEXIST 9955 | 302 | # define EEXIST 9955 |
| 302 | # endif | 303 | # endif |
| 303 | 304 | ||
| 304 | # ifndef EFBIG | 305 | # ifndef EFBIG |
| 305 | # define EFBIG 9956 | 306 | # define EFBIG 9956 |
| 306 | # endif | 307 | # endif |
| 307 | 308 | ||
| 308 | # ifndef ENAMETOOLONG | 309 | # ifndef ENAMETOOLONG |
| 309 | # define ENAMETOOLONG 9957 | 310 | # define ENAMETOOLONG 9957 |
| 310 | # endif | 311 | # endif |
| 311 | 312 | ||
| 312 | # ifndef ENOTTY | 313 | # ifndef ENOTTY |
| 313 | # define ENOTTY 9958 | 314 | # define ENOTTY 9958 |
| 314 | # endif | 315 | # endif |
| 315 | 316 | ||
| 316 | # ifndef EINTR | 317 | # ifndef EINTR |
| 317 | # define EINTR 9959 | 318 | # define EINTR 9959 |
| 318 | # endif | 319 | # endif |
| 319 | 320 | ||
| 320 | # ifndef ESPIPE | 321 | # ifndef ESPIPE |
| 321 | # define ESPIPE 9960 | 322 | # define ESPIPE 9960 |
| 322 | # endif | 323 | # endif |
| 323 | 324 | ||
| 324 | # ifndef EIO | 325 | # ifndef EIO |
| 325 | # define EIO 9961 | 326 | # define EIO 9961 |
| 326 | # endif | 327 | # endif |
| 327 | 328 | ||
| 328 | # ifndef EISDIR | 329 | # ifndef EISDIR |
| 329 | # define EISDIR 9962 | 330 | # define EISDIR 9962 |
| 330 | # endif | 331 | # endif |
| 331 | 332 | ||
| 332 | # ifndef ECHILD | 333 | # ifndef ECHILD |
| 333 | # define ECHILD 9963 | 334 | # define ECHILD 9963 |
| 334 | # endif | 335 | # endif |
| 335 | 336 | ||
| 336 | # ifndef ENOLCK | 337 | # ifndef ENOLCK |
| 337 | # define ENOLCK 9964 | 338 | # define ENOLCK 9964 |
| 338 | # endif | 339 | # endif |
| 339 | 340 | ||
| 340 | # ifndef ENOSPC | 341 | # ifndef ENOSPC |
| 341 | # define ENOSPC 9965 | 342 | # define ENOSPC 9965 |
| 342 | # endif | 343 | # endif |
| 343 | 344 | ||
| 344 | # ifndef ENXIO | 345 | # ifndef ENXIO |
| 345 | # define ENXIO 9966 | 346 | # define ENXIO 9966 |
| 346 | # endif | 347 | # endif |
| 347 | 348 | ||
| 348 | # ifndef ENODEV | 349 | # ifndef ENODEV |
| 349 | # define ENODEV 9967 | 350 | # define ENODEV 9967 |
| 350 | # endif | 351 | # endif |
| 351 | 352 | ||
| 352 | # ifndef ENOENT | 353 | # ifndef ENOENT |
| 353 | # define ENOENT 9968 | 354 | # define ENOENT 9968 |
| 354 | # endif | 355 | # endif |
| 355 | 356 | ||
| 356 | # ifndef ESRCH | 357 | # ifndef ESRCH |
| 357 | # define ESRCH 9969 | 358 | # define ESRCH 9969 |
| 358 | # endif | 359 | # endif |
| 359 | 360 | ||
| 360 | # ifndef ENOTDIR | 361 | # ifndef ENOTDIR |
| 361 | # define ENOTDIR 9970 | 362 | # define ENOTDIR 9970 |
| 362 | # endif | 363 | # endif |
| 363 | 364 | ||
| 364 | # ifndef ENOMEM | 365 | # ifndef ENOMEM |
| 365 | # define ENOMEM 9971 | 366 | # define ENOMEM 9971 |
| 366 | # endif | 367 | # endif |
| 367 | 368 | ||
| 368 | # ifndef EPERM | 369 | # ifndef EPERM |
| 369 | # define EPERM 9972 | 370 | # define EPERM 9972 |
| 370 | # endif | 371 | # endif |
| 371 | 372 | ||
| 372 | # ifndef EACCES | 373 | # ifndef EACCES |
| 373 | # define EACCES 9973 | 374 | # define EACCES 9973 |
| 374 | # endif | 375 | # endif |
| 375 | 376 | ||
| 376 | # ifndef EROFS | 377 | # ifndef EROFS |
| 377 | # define EROFS 9974 | 378 | # define EROFS 9974 |
| 378 | # endif | 379 | # endif |
| 379 | 380 | ||
| 380 | # ifndef EDEADLK | 381 | # ifndef EDEADLK |
| 381 | # define EDEADLK 9975 | 382 | # define EDEADLK 9975 |
| 382 | # endif | 383 | # endif |
| 383 | 384 | ||
| 384 | # ifndef EAGAIN | 385 | # ifndef EAGAIN |
| 385 | # define EAGAIN 9976 | 386 | # define EAGAIN 9976 |
| 386 | # endif | 387 | # endif |
| 387 | 388 | ||
| 388 | # ifndef ENFILE | 389 | # ifndef ENFILE |
| 389 | # define ENFILE 9977 | 390 | # define ENFILE 9977 |
| 390 | # endif | 391 | # endif |
| 391 | 392 | ||
| 392 | # ifndef EMFILE | 393 | # ifndef EMFILE |
| 393 | # define EMFILE 9978 | 394 | # define EMFILE 9978 |
| 394 | # endif | 395 | # endif |
| 395 | 396 | ||
| 396 | # ifndef EMLINK | 397 | # ifndef EMLINK |
| 397 | # define EMLINK 9979 | 398 | # define EMLINK 9979 |
| 398 | # endif | 399 | # endif |
| 399 | 400 | ||
| 400 | # endif // __cplusplus | 401 | #endif // __cplusplus |
| 401 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 402 | 402 | ||
| 403 | #endif // _LIBCPP_ERRNO_H | 403 | #endif // _LIBCPP_ERRNO_H |
lib/libcxx/include/exception+4-1| ... | @@ -93,10 +93,13 @@ template <class E> void rethrow_if_nested(const E& e); | ... | @@ -93,10 +93,13 @@ template <class E> void rethrow_if_nested(const E& e); |
| 93 | 93 | ||
| 94 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 94 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 95 | # include <cstddef> | 95 | # include <cstddef> |
| 96 | # include <cstdlib> | ||
| 97 | # include <new> | 96 | # include <new> |
| 98 | # include <type_traits> | 97 | # include <type_traits> |
| 99 | # endif | 98 | # endif |
| 99 | |||
| 100 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | ||
| 101 | # include <cstdlib> | ||
| 102 | # endif | ||
| 100 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 103 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 101 | 104 | ||
| 102 | #endif // _LIBCPP_EXCEPTION | 105 | #endif // _LIBCPP_EXCEPTION |
lib/libcxx/include/ext/hash_map+7-48| ... | @@ -206,6 +206,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> | ... | @@ -206,6 +206,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 206 | #else | 206 | #else |
| 207 | # include <__config> | 207 | # include <__config> |
| 208 | # include <__hash_table> | 208 | # include <__hash_table> |
| 209 | # include <__memory/compressed_pair.h> | ||
| 209 | # include <algorithm> | 210 | # include <algorithm> |
| 210 | # include <ext/__hash> | 211 | # include <ext/__hash> |
| 211 | # include <functional> | 212 | # include <functional> |
| ... | @@ -224,21 +225,9 @@ _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <un | ... | @@ -224,21 +225,9 @@ _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <un |
| 224 | 225 | ||
| 225 | namespace __gnu_cxx { | 226 | namespace __gnu_cxx { |
| 226 | 227 | ||
| 227 | template <class _Tp, class _Hash, bool = std::is_empty<_Hash>::value && !std::__libcpp_is_final<_Hash>::value > | ||
| 228 | class __hash_map_hasher : private _Hash { | ||
| 229 | public: | ||
| 230 | _LIBCPP_HIDE_FROM_ABI __hash_map_hasher() : _Hash() {} | ||
| 231 | _LIBCPP_HIDE_FROM_ABI __hash_map_hasher(const _Hash& __h) : _Hash(__h) {} | ||
| 232 | _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const { return *this; } | ||
| 233 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Tp& __x) const { return static_cast<const _Hash&>(*this)(__x.first); } | ||
| 234 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const typename _Tp::first_type& __x) const { | ||
| 235 | return static_cast<const _Hash&>(*this)(__x); | ||
| 236 | } | ||
| 237 | }; | ||
| 238 | |||
| 239 | template <class _Tp, class _Hash> | 228 | template <class _Tp, class _Hash> |
| 240 | class __hash_map_hasher<_Tp, _Hash, false> { | 229 | class __hash_map_hasher { |
| 241 | _Hash __hash_; | 230 | _LIBCPP_COMPRESSED_ELEMENT(_Hash, __hash_); |
| 242 | 231 | ||
| 243 | public: | 232 | public: |
| 244 | _LIBCPP_HIDE_FROM_ABI __hash_map_hasher() : __hash_() {} | 233 | _LIBCPP_HIDE_FROM_ABI __hash_map_hasher() : __hash_() {} |
| ... | @@ -248,30 +237,9 @@ public: | ... | @@ -248,30 +237,9 @@ public: |
| 248 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const typename _Tp::first_type& __x) const { return __hash_(__x); } | 237 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const typename _Tp::first_type& __x) const { return __hash_(__x); } |
| 249 | }; | 238 | }; |
| 250 | 239 | ||
| 251 | template <class _Tp, class _Pred, bool = std::is_empty<_Pred>::value && !std::__libcpp_is_final<_Pred>::value > | ||
| 252 | class __hash_map_equal : private _Pred { | ||
| 253 | public: | ||
| 254 | _LIBCPP_HIDE_FROM_ABI __hash_map_equal() : _Pred() {} | ||
| 255 | _LIBCPP_HIDE_FROM_ABI __hash_map_equal(const _Pred& __p) : _Pred(__p) {} | ||
| 256 | _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const { return *this; } | ||
| 257 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | ||
| 258 | return static_cast<const _Pred&>(*this)(__x.first, __y.first); | ||
| 259 | } | ||
| 260 | _LIBCPP_HIDE_FROM_ABI bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const { | ||
| 261 | return static_cast<const _Pred&>(*this)(__x, __y.first); | ||
| 262 | } | ||
| 263 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const { | ||
| 264 | return static_cast<const _Pred&>(*this)(__x.first, __y); | ||
| 265 | } | ||
| 266 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 267 | operator()(const typename _Tp::first_type& __x, const typename _Tp::first_type& __y) const { | ||
| 268 | return static_cast<const _Pred&>(*this)(__x, __y); | ||
| 269 | } | ||
| 270 | }; | ||
| 271 | |||
| 272 | template <class _Tp, class _Pred> | 240 | template <class _Tp, class _Pred> |
| 273 | class __hash_map_equal<_Tp, _Pred, false> { | 241 | class __hash_map_equal { |
| 274 | _Pred __pred_; | 242 | _LIBCPP_COMPRESSED_ELEMENT(_Pred, __pred_); |
| 275 | 243 | ||
| 276 | public: | 244 | public: |
| 277 | _LIBCPP_HIDE_FROM_ABI __hash_map_equal() : __pred_() {} | 245 | _LIBCPP_HIDE_FROM_ABI __hash_map_equal() : __pred_() {} |
| ... | @@ -467,8 +435,6 @@ private: | ... | @@ -467,8 +435,6 @@ private: |
| 467 | 435 | ||
| 468 | __table __table_; | 436 | __table __table_; |
| 469 | 437 | ||
| 470 | typedef typename __table::__node_pointer __node_pointer; | ||
| 471 | typedef typename __table::__node_const_pointer __node_const_pointer; | ||
| 472 | typedef typename __table::__node_traits __node_traits; | 438 | typedef typename __table::__node_traits __node_traits; |
| 473 | typedef typename __table::__node_allocator __node_allocator; | 439 | typedef typename __table::__node_allocator __node_allocator; |
| 474 | typedef typename __table::__node __node; | 440 | typedef typename __table::__node __node; |
| ... | @@ -604,10 +570,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( | ... | @@ -604,10 +570,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( |
| 604 | } | 570 | } |
| 605 | 571 | ||
| 606 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 572 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 607 | hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(const hash_map& __u) : __table_(__u.__table_) { | 573 | hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(const hash_map& __u) : __table_(__u.__table_) {} |
| 608 | __table_.__rehash_unique(__u.bucket_count()); | ||
| 609 | insert(__u.begin(), __u.end()); | ||
| 610 | } | ||
| 611 | 574 | ||
| 612 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 575 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 613 | typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | 576 | typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| ... | @@ -693,7 +656,6 @@ private: | ... | @@ -693,7 +656,6 @@ private: |
| 693 | 656 | ||
| 694 | __table __table_; | 657 | __table __table_; |
| 695 | 658 | ||
| 696 | typedef typename __table::__node_traits __node_traits; | ||
| 697 | typedef typename __table::__node_allocator __node_allocator; | 659 | typedef typename __table::__node_allocator __node_allocator; |
| 698 | typedef typename __table::__node __node; | 660 | typedef typename __table::__node __node; |
| 699 | typedef __hash_map_node_destructor<__node_allocator> _Dp; | 661 | typedef __hash_map_node_destructor<__node_allocator> _Dp; |
| ... | @@ -822,10 +784,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( | ... | @@ -822,10 +784,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( |
| 822 | } | 784 | } |
| 823 | 785 | ||
| 824 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 786 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 825 | hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(const hash_multimap& __u) : __table_(__u.__table_) { | 787 | hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(const hash_multimap& __u) : __table_(__u.__table_) {} |
| 826 | __table_.__rehash_multi(__u.bucket_count()); | ||
| 827 | insert(__u.begin(), __u.end()); | ||
| 828 | } | ||
| 829 | 788 | ||
| 830 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 789 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 831 | template <class _InputIterator> | 790 | template <class _InputIterator> |
lib/libcxx/include/ext/hash_set+2-8| ... | @@ -356,10 +356,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set( | ... | @@ -356,10 +356,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set( |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 358 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 359 | hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(const hash_set& __u) : __table_(__u.__table_) { | 359 | hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(const hash_set& __u) : __table_(__u.__table_) {} |
| 360 | __table_.__rehash_unique(__u.bucket_count()); | ||
| 361 | insert(__u.begin(), __u.end()); | ||
| 362 | } | ||
| 363 | 360 | ||
| 364 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 361 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 365 | template <class _InputIterator> | 362 | template <class _InputIterator> |
| ... | @@ -534,10 +531,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset( | ... | @@ -534,10 +531,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset( |
| 534 | } | 531 | } |
| 535 | 532 | ||
| 536 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 533 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 537 | hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(const hash_multiset& __u) : __table_(__u.__table_) { | 534 | hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(const hash_multiset& __u) : __table_(__u.__table_) {} |
| 538 | __table_.__rehash_multi(__u.bucket_count()); | ||
| 539 | insert(__u.begin(), __u.end()); | ||
| 540 | } | ||
| 541 | 535 | ||
| 542 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 536 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 543 | template <class _InputIterator> | 537 | template <class _InputIterator> |
lib/libcxx/include/fenv.h+43-43| ... | @@ -50,69 +50,69 @@ int feupdateenv(const fenv_t* envp); | ... | @@ -50,69 +50,69 @@ int feupdateenv(const fenv_t* envp); |
| 50 | */ | 50 | */ |
| 51 | 51 | ||
| 52 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 52 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 53 | # include <__cxx03/fenv.h> | 53 | # include <__cxx03/__config> |
| 54 | #else | 54 | #else |
| 55 | # include <__config> | 55 | # include <__config> |
| 56 | #endif | ||
| 56 | 57 | ||
| 57 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 58 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 58 | # pragma GCC system_header | 59 | # pragma GCC system_header |
| 59 | # endif | 60 | #endif |
| 60 | 61 | ||
| 61 | # if __has_include_next(<fenv.h>) | 62 | #if __has_include_next(<fenv.h>) |
| 62 | # include_next <fenv.h> | 63 | # include_next <fenv.h> |
| 63 | # endif | 64 | #endif |
| 64 | 65 | ||
| 65 | # ifdef __cplusplus | 66 | #ifdef __cplusplus |
| 66 | 67 | ||
| 67 | extern "C++" { | 68 | extern "C++" { |
| 68 | 69 | ||
| 69 | # ifdef feclearexcept | 70 | # ifdef feclearexcept |
| 70 | # undef feclearexcept | 71 | # undef feclearexcept |
| 71 | # endif | 72 | # endif |
| 72 | 73 | ||
| 73 | # ifdef fegetexceptflag | 74 | # ifdef fegetexceptflag |
| 74 | # undef fegetexceptflag | 75 | # undef fegetexceptflag |
| 75 | # endif | 76 | # endif |
| 76 | 77 | ||
| 77 | # ifdef feraiseexcept | 78 | # ifdef feraiseexcept |
| 78 | # undef feraiseexcept | 79 | # undef feraiseexcept |
| 79 | # endif | 80 | # endif |
| 80 | 81 | ||
| 81 | # ifdef fesetexceptflag | 82 | # ifdef fesetexceptflag |
| 82 | # undef fesetexceptflag | 83 | # undef fesetexceptflag |
| 83 | # endif | 84 | # endif |
| 84 | 85 | ||
| 85 | # ifdef fetestexcept | 86 | # ifdef fetestexcept |
| 86 | # undef fetestexcept | 87 | # undef fetestexcept |
| 87 | # endif | 88 | # endif |
| 88 | 89 | ||
| 89 | # ifdef fegetround | 90 | # ifdef fegetround |
| 90 | # undef fegetround | 91 | # undef fegetround |
| 91 | # endif | 92 | # endif |
| 92 | 93 | ||
| 93 | # ifdef fesetround | 94 | # ifdef fesetround |
| 94 | # undef fesetround | 95 | # undef fesetround |
| 95 | # endif | 96 | # endif |
| 96 | 97 | ||
| 97 | # ifdef fegetenv | 98 | # ifdef fegetenv |
| 98 | # undef fegetenv | 99 | # undef fegetenv |
| 99 | # endif | 100 | # endif |
| 100 | 101 | ||
| 101 | # ifdef feholdexcept | 102 | # ifdef feholdexcept |
| 102 | # undef feholdexcept | 103 | # undef feholdexcept |
| 103 | # endif | 104 | # endif |
| 104 | 105 | ||
| 105 | # ifdef fesetenv | 106 | # ifdef fesetenv |
| 106 | # undef fesetenv | 107 | # undef fesetenv |
| 107 | # endif | 108 | # endif |
| 108 | 109 | ||
| 109 | # ifdef feupdateenv | 110 | # ifdef feupdateenv |
| 110 | # undef feupdateenv | 111 | # undef feupdateenv |
| 111 | # endif | 112 | # endif |
| 112 | 113 | ||
| 113 | } // extern "C++" | 114 | } // extern "C++" |
| 114 | 115 | ||
| 115 | # endif // defined(__cplusplus) | 116 | #endif // defined(__cplusplus) |
| 116 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 117 | 117 | ||
| 118 | #endif // _LIBCPP_FENV_H | 118 | #endif // _LIBCPP_FENV_H |
lib/libcxx/include/flat_map+663-11| ... | @@ -17,18 +17,359 @@ | ... | @@ -17,18 +17,359 @@ |
| 17 | #include <initializer_list> // see [initializer.list.syn] | 17 | #include <initializer_list> // see [initializer.list.syn] |
| 18 | 18 | ||
| 19 | namespace std { | 19 | namespace std { |
| 20 | struct sorted_unique_t { explicit sorted_unique_t() = default; }; | ||
| 21 | inline constexpr sorted_unique_t sorted_unique{}; | ||
| 22 | |||
| 20 | // [flat.map], class template flat_map | 23 | // [flat.map], class template flat_map |
| 21 | template<class Key, class T, class Compare = less<Key>, | 24 | template<class Key, class T, class Compare = less<Key>, |
| 22 | class KeyContainer = vector<Key>, class MappedContainer = vector<T>> | 25 | class KeyContainer = vector<Key>, class MappedContainer = vector<T>> |
| 23 | class flat_map; | 26 | class flat_map { |
| 27 | public: | ||
| 28 | // types | ||
| 29 | using key_type = Key; | ||
| 30 | using mapped_type = T; | ||
| 31 | using value_type = pair<key_type, mapped_type>; | ||
| 32 | using key_compare = Compare; | ||
| 33 | using reference = pair<const key_type&, mapped_type&>; | ||
| 34 | using const_reference = pair<const key_type&, const mapped_type&>; | ||
| 35 | using size_type = size_t; | ||
| 36 | using difference_type = ptrdiff_t; | ||
| 37 | using iterator = implementation-defined; // see [container.requirements] | ||
| 38 | using const_iterator = implementation-defined; // see [container.requirements] | ||
| 39 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 40 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 41 | using key_container_type = KeyContainer; | ||
| 42 | using mapped_container_type = MappedContainer; | ||
| 24 | 43 | ||
| 25 | struct sorted_unique_t { explicit sorted_unique_t() = default; }; | 44 | class value_compare { |
| 26 | inline constexpr sorted_unique_t sorted_unique{}; | 45 | private: |
| 46 | key_compare comp; // exposition only | ||
| 47 | constexpr value_compare(key_compare c) : comp(c) { } // exposition only | ||
| 48 | |||
| 49 | public: | ||
| 50 | constexpr bool operator()(const_reference x, const_reference y) const { | ||
| 51 | return comp(x.first, y.first); | ||
| 52 | } | ||
| 53 | }; | ||
| 54 | |||
| 55 | struct containers { | ||
| 56 | key_container_type keys; | ||
| 57 | mapped_container_type values; | ||
| 58 | }; | ||
| 59 | |||
| 60 | // [flat.map.cons], constructors | ||
| 61 | constexpr flat_map() : flat_map(key_compare()) { } | ||
| 62 | |||
| 63 | constexpr flat_map(const flat_map&); | ||
| 64 | constexpr flat_map(flat_map&&); | ||
| 65 | constexpr flat_map& operator=(const flat_map&); | ||
| 66 | constexpr flat_map& operator=(flat_map&&); | ||
| 67 | |||
| 68 | constexpr explicit flat_map(const key_compare& comp) | ||
| 69 | : c(), compare(comp) { } | ||
| 70 | |||
| 71 | constexpr flat_map(key_container_type key_cont, mapped_container_type mapped_cont, | ||
| 72 | const key_compare& comp = key_compare()); | ||
| 73 | |||
| 74 | constexpr flat_map(sorted_unique_t, key_container_type key_cont, | ||
| 75 | mapped_container_type mapped_cont, | ||
| 76 | const key_compare& comp = key_compare()); | ||
| 77 | |||
| 78 | template<class InputIterator> | ||
| 79 | constexpr flat_map(InputIterator first, InputIterator last, | ||
| 80 | const key_compare& comp = key_compare()) | ||
| 81 | : c(), compare(comp) { insert(first, last); } | ||
| 82 | |||
| 83 | template<class InputIterator> | ||
| 84 | constexpr flat_map(sorted_unique_t, InputIterator first, InputIterator last, | ||
| 85 | const key_compare& comp = key_compare()) | ||
| 86 | : c(), compare(comp) { insert(sorted_unique, first, last); } | ||
| 87 | |||
| 88 | template<container-compatible-range<value_type> R> | ||
| 89 | constexpr flat_map(from_range_t, R&& rg) | ||
| 90 | : flat_map(from_range, std::forward<R>(rg), key_compare()) { } | ||
| 91 | template<container-compatible-range<value_type> R> | ||
| 92 | constexpr flat_map(from_range_t, R&& rg, const key_compare& comp) | ||
| 93 | : flat_map(comp) { insert_range(std::forward<R>(rg)); } | ||
| 94 | |||
| 95 | constexpr flat_map(initializer_list<value_type> il, const key_compare& comp = key_compare()) | ||
| 96 | : flat_map(il.begin(), il.end(), comp) { } | ||
| 97 | |||
| 98 | constexpr flat_map(sorted_unique_t, initializer_list<value_type> il, | ||
| 99 | const key_compare& comp = key_compare()) | ||
| 100 | : flat_map(sorted_unique, il.begin(), il.end(), comp) { } | ||
| 101 | |||
| 102 | // [flat.map.cons.alloc], constructors with allocators | ||
| 103 | |||
| 104 | template<class Alloc> | ||
| 105 | constexpr explicit flat_map(const Alloc& a); | ||
| 106 | template<class Alloc> | ||
| 107 | constexpr flat_map(const key_compare& comp, const Alloc& a); | ||
| 108 | template<class Alloc> | ||
| 109 | constexpr flat_map(const key_container_type& key_cont, | ||
| 110 | const mapped_container_type& mapped_cont, | ||
| 111 | const Alloc& a); | ||
| 112 | template<class Alloc> | ||
| 113 | constexpr flat_map(const key_container_type& key_cont, | ||
| 114 | const mapped_container_type& mapped_cont, | ||
| 115 | const key_compare& comp, const Alloc& a); | ||
| 116 | template<class Alloc> | ||
| 117 | constexpr flat_map(sorted_unique_t, const key_container_type& key_cont, | ||
| 118 | const mapped_container_type& mapped_cont, const Alloc& a); | ||
| 119 | template<class Alloc> | ||
| 120 | constexpr flat_map(sorted_unique_t, const key_container_type& key_cont, | ||
| 121 | const mapped_container_type& mapped_cont, const key_compare& comp, | ||
| 122 | const Alloc& a); | ||
| 123 | template<class Alloc> | ||
| 124 | constexpr flat_map(const flat_map&, const Alloc& a); | ||
| 125 | template<class Alloc> | ||
| 126 | constexpr flat_map(flat_map&&, const Alloc& a); | ||
| 127 | template<class InputIterator, class Alloc> | ||
| 128 | constexpr flat_map(InputIterator first, InputIterator last, const Alloc& a); | ||
| 129 | template<class InputIterator, class Alloc> | ||
| 130 | constexpr flat_map(InputIterator first, InputIterator last, | ||
| 131 | const key_compare& comp, const Alloc& a); | ||
| 132 | template<class InputIterator, class Alloc> | ||
| 133 | constexpr flat_map(sorted_unique_t, InputIterator first, InputIterator last, | ||
| 134 | const Alloc& a); | ||
| 135 | template<class InputIterator, class Alloc> | ||
| 136 | constexpr flat_map(sorted_unique_t, InputIterator first, InputIterator last, | ||
| 137 | const key_compare& comp, const Alloc& a); | ||
| 138 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 139 | constexpr flat_map(from_range_t, R&& rg, const Alloc& a); | ||
| 140 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 141 | constexpr flat_map(from_range_t, R&& rg, const key_compare& comp, const Alloc& a); | ||
| 142 | template<class Alloc> | ||
| 143 | constexpr flat_map(initializer_list<value_type> il, const Alloc& a); | ||
| 144 | template<class Alloc> | ||
| 145 | constexpr flat_map(initializer_list<value_type> il, const key_compare& comp, | ||
| 146 | const Alloc& a); | ||
| 147 | template<class Alloc> | ||
| 148 | constexpr flat_map(sorted_unique_t, initializer_list<value_type> il, const Alloc& a); | ||
| 149 | template<class Alloc> | ||
| 150 | constexpr flat_map(sorted_unique_t, initializer_list<value_type> il, | ||
| 151 | const key_compare& comp, const Alloc& a); | ||
| 152 | |||
| 153 | constexpr flat_map& operator=(initializer_list<value_type>); | ||
| 154 | |||
| 155 | // iterators | ||
| 156 | constexpr iterator begin() noexcept; | ||
| 157 | constexpr const_iterator begin() const noexcept; | ||
| 158 | constexpr iterator end() noexcept; | ||
| 159 | constexpr const_iterator end() const noexcept; | ||
| 160 | |||
| 161 | constexpr reverse_iterator rbegin() noexcept; | ||
| 162 | constexpr const_reverse_iterator rbegin() const noexcept; | ||
| 163 | constexpr reverse_iterator rend() noexcept; | ||
| 164 | constexpr const_reverse_iterator rend() const noexcept; | ||
| 165 | |||
| 166 | constexpr const_iterator cbegin() const noexcept; | ||
| 167 | constexpr const_iterator cend() const noexcept; | ||
| 168 | constexpr const_reverse_iterator crbegin() const noexcept; | ||
| 169 | constexpr const_reverse_iterator crend() const noexcept; | ||
| 170 | |||
| 171 | // [flat.map.capacity], capacity | ||
| 172 | constexpr bool empty() const noexcept; | ||
| 173 | constexpr size_type size() const noexcept; | ||
| 174 | constexpr size_type max_size() const noexcept; | ||
| 175 | |||
| 176 | // [flat.map.access], element access | ||
| 177 | constexpr mapped_type& operator[](const key_type& x); | ||
| 178 | constexpr mapped_type& operator[](key_type&& x); | ||
| 179 | template<class K> constexpr mapped_type& operator[](K&& x); | ||
| 180 | constexpr mapped_type& at(const key_type& x); | ||
| 181 | constexpr const mapped_type& at(const key_type& x) const; | ||
| 182 | template<class K> constexpr mapped_type& at(const K& x); | ||
| 183 | template<class K> constexpr const mapped_type& at(const K& x) const; | ||
| 184 | |||
| 185 | // [flat.map.modifiers], modifiers | ||
| 186 | template<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args); | ||
| 187 | template<class... Args> | ||
| 188 | constexpr iterator emplace_hint(const_iterator position, Args&&... args); | ||
| 189 | |||
| 190 | constexpr pair<iterator, bool> insert(const value_type& x) | ||
| 191 | { return emplace(x); } | ||
| 192 | constexpr pair<iterator, bool> insert(value_type&& x) | ||
| 193 | { return emplace(std::move(x)); } | ||
| 194 | constexpr iterator insert(const_iterator position, const value_type& x) | ||
| 195 | { return emplace_hint(position, x); } | ||
| 196 | constexpr iterator insert(const_iterator position, value_type&& x) | ||
| 197 | { return emplace_hint(position, std::move(x)); } | ||
| 198 | |||
| 199 | template<class P> constexpr pair<iterator, bool> insert(P&& x); | ||
| 200 | template<class P> | ||
| 201 | constexpr iterator insert(const_iterator position, P&&); | ||
| 202 | template<class InputIterator> | ||
| 203 | constexpr void insert(InputIterator first, InputIterator last); | ||
| 204 | template<class InputIterator> | ||
| 205 | constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last); | ||
| 206 | template<container-compatible-range<value_type> R> | ||
| 207 | constexpr void insert_range(R&& rg); | ||
| 208 | template<container-compatible-range<value_type> R> | ||
| 209 | constexpr void insert_range(sorted_unique_t, R&& rg); | ||
| 210 | |||
| 211 | constexpr void insert(initializer_list<value_type> il) | ||
| 212 | { insert(il.begin(), il.end()); } | ||
| 213 | constexpr void insert(sorted_unique_t, initializer_list<value_type> il) | ||
| 214 | { insert(sorted_unique, il.begin(), il.end()); } | ||
| 215 | |||
| 216 | constexpr containers extract() &&; | ||
| 217 | constexpr void replace(key_container_type&& key_cont, mapped_container_type&& mapped_cont); | ||
| 218 | |||
| 219 | template<class... Args> | ||
| 220 | constexpr pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); | ||
| 221 | template<class... Args> | ||
| 222 | constexpr pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); | ||
| 223 | template<class K, class... Args> | ||
| 224 | constexpr pair<iterator, bool> try_emplace(K&& k, Args&&... args); | ||
| 225 | template<class... Args> | ||
| 226 | constexpr iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); | ||
| 227 | template<class... Args> | ||
| 228 | constexpr iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); | ||
| 229 | template<class K, class... Args> | ||
| 230 | constexpr iterator try_emplace(const_iterator hint, K&& k, Args&&... args); | ||
| 231 | template<class M> | ||
| 232 | constexpr pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); | ||
| 233 | template<class M> | ||
| 234 | constexpr pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); | ||
| 235 | template<class K, class M> | ||
| 236 | constexpr pair<iterator, bool> insert_or_assign(K&& k, M&& obj); | ||
| 237 | template<class M> | ||
| 238 | constexpr iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); | ||
| 239 | template<class M> | ||
| 240 | constexpr iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); | ||
| 241 | template<class K, class M> | ||
| 242 | constexpr iterator insert_or_assign(const_iterator hint, K&& k, M&& obj); | ||
| 243 | |||
| 244 | constexpr iterator erase(iterator position); | ||
| 245 | constexpr iterator erase(const_iterator position); | ||
| 246 | constexpr size_type erase(const key_type& x); | ||
| 247 | template<class K> constexpr size_type erase(K&& x); | ||
| 248 | constexpr iterator erase(const_iterator first, const_iterator last); | ||
| 249 | |||
| 250 | constexpr void swap(flat_map& y) noexcept(see below); | ||
| 251 | constexpr void clear() noexcept; | ||
| 252 | |||
| 253 | // observers | ||
| 254 | constexpr key_compare key_comp() const; | ||
| 255 | constexpr value_compare value_comp() const; | ||
| 256 | |||
| 257 | constexpr const key_container_type& keys() const noexcept { return c.keys; } | ||
| 258 | constexpr const mapped_container_type& values() const noexcept { return c.values; } | ||
| 259 | |||
| 260 | // map operations | ||
| 261 | constexpr iterator find(const key_type& x); | ||
| 262 | constexpr const_iterator find(const key_type& x) const; | ||
| 263 | template<class K> constexpr iterator find(const K& x); | ||
| 264 | template<class K> constexpr const_iterator find(const K& x) const; | ||
| 265 | |||
| 266 | constexpr size_type count(const key_type& x) const; | ||
| 267 | template<class K> constexpr size_type count(const K& x) const; | ||
| 268 | |||
| 269 | constexpr bool contains(const key_type& x) const; | ||
| 270 | template<class K> constexpr bool contains(const K& x) const; | ||
| 271 | |||
| 272 | constexpr iterator lower_bound(const key_type& x); | ||
| 273 | constexpr const_iterator lower_bound(const key_type& x) const; | ||
| 274 | template<class K> constexpr iterator lower_bound(const K& x); | ||
| 275 | template<class K> constexpr const_iterator lower_bound(const K& x) const; | ||
| 276 | |||
| 277 | constexpr iterator upper_bound(const key_type& x); | ||
| 278 | constexpr const_iterator upper_bound(const key_type& x) const; | ||
| 279 | template<class K> constexpr iterator upper_bound(const K& x); | ||
| 280 | template<class K> constexpr const_iterator upper_bound(const K& x) const; | ||
| 281 | |||
| 282 | constexpr pair<iterator, iterator> equal_range(const key_type& x); | ||
| 283 | constexpr pair<const_iterator, const_iterator> equal_range(const key_type& x) const; | ||
| 284 | template<class K> constexpr pair<iterator, iterator> equal_range(const K& x); | ||
| 285 | template<class K> | ||
| 286 | constexpr pair<const_iterator, const_iterator> equal_range(const K& x) const; | ||
| 287 | |||
| 288 | friend constexpr bool operator==(const flat_map& x, const flat_map& y); | ||
| 289 | |||
| 290 | friend constexpr synth-three-way-result<value_type> | ||
| 291 | operator<=>(const flat_map& x, const flat_map& y); | ||
| 292 | |||
| 293 | friend constexpr void swap(flat_map& x, flat_map& y) noexcept(noexcept(x.swap(y))) | ||
| 294 | { x.swap(y); } | ||
| 295 | |||
| 296 | private: | ||
| 297 | containers c; // exposition only | ||
| 298 | key_compare compare; // exposition only | ||
| 299 | |||
| 300 | struct key-equiv { // exposition only | ||
| 301 | constexpr key-equiv(key_compare c) : comp(c) { } | ||
| 302 | constexpr bool operator()(const_reference x, const_reference y) const { | ||
| 303 | return !comp(x.first, y.first) && !comp(y.first, x.first); | ||
| 304 | } | ||
| 305 | key_compare comp; | ||
| 306 | }; | ||
| 307 | }; | ||
| 308 | |||
| 309 | template<class KeyContainer, class MappedContainer, | ||
| 310 | class Compare = less<typename KeyContainer::value_type>> | ||
| 311 | flat_map(KeyContainer, MappedContainer, Compare = Compare()) | ||
| 312 | -> flat_map<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 313 | Compare, KeyContainer, MappedContainer>; | ||
| 314 | |||
| 315 | template<class KeyContainer, class MappedContainer, class Allocator> | ||
| 316 | flat_map(KeyContainer, MappedContainer, Allocator) | ||
| 317 | -> flat_map<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 318 | less<typename KeyContainer::value_type>, KeyContainer, MappedContainer>; | ||
| 319 | template<class KeyContainer, class MappedContainer, class Compare, class Allocator> | ||
| 320 | flat_map(KeyContainer, MappedContainer, Compare, Allocator) | ||
| 321 | -> flat_map<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 322 | Compare, KeyContainer, MappedContainer>; | ||
| 323 | |||
| 324 | template<class KeyContainer, class MappedContainer, | ||
| 325 | class Compare = less<typename KeyContainer::value_type>> | ||
| 326 | flat_map(sorted_unique_t, KeyContainer, MappedContainer, Compare = Compare()) | ||
| 327 | -> flat_map<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 328 | Compare, KeyContainer, MappedContainer>; | ||
| 329 | |||
| 330 | template<class KeyContainer, class MappedContainer, class Allocator> | ||
| 331 | flat_map(sorted_unique_t, KeyContainer, MappedContainer, Allocator) | ||
| 332 | -> flat_map<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 333 | less<typename KeyContainer::value_type>, KeyContainer, MappedContainer>; | ||
| 334 | template<class KeyContainer, class MappedContainer, class Compare, class Allocator> | ||
| 335 | flat_map(sorted_unique_t, KeyContainer, MappedContainer, Compare, Allocator) | ||
| 336 | -> flat_map<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 337 | Compare, KeyContainer, MappedContainer>; | ||
| 338 | |||
| 339 | template<class InputIterator, class Compare = less<iter-key-type<InputIterator>>> | ||
| 340 | flat_map(InputIterator, InputIterator, Compare = Compare()) | ||
| 341 | -> flat_map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Compare>; | ||
| 342 | |||
| 343 | template<class InputIterator, class Compare = less<iter-key-type<InputIterator>>> | ||
| 344 | flat_map(sorted_unique_t, InputIterator, InputIterator, Compare = Compare()) | ||
| 345 | -> flat_map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Compare>; | ||
| 346 | |||
| 347 | template<ranges::input_range R, class Compare = less<range-key-type<R>>, | ||
| 348 | class Allocator = allocator<byte>> | ||
| 349 | flat_map(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) | ||
| 350 | -> flat_map<range-key-type<R>, range-mapped-type<R>, Compare, | ||
| 351 | vector<range-key-type<R>, alloc-rebind<Allocator, range-key-type<R>>>, | ||
| 352 | vector<range-mapped-type<R>, alloc-rebind<Allocator, range-mapped-type<R>>>>; | ||
| 353 | |||
| 354 | template<ranges::input_range R, class Allocator> | ||
| 355 | flat_map(from_range_t, R&&, Allocator) | ||
| 356 | -> flat_map<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, | ||
| 357 | vector<range-key-type<R>, alloc-rebind<Allocator, range-key-type<R>>>, | ||
| 358 | vector<range-mapped-type<R>, alloc-rebind<Allocator, range-mapped-type<R>>>>; | ||
| 359 | |||
| 360 | template<class Key, class T, class Compare = less<Key>> | ||
| 361 | flat_map(initializer_list<pair<Key, T>>, Compare = Compare()) | ||
| 362 | -> flat_map<Key, T, Compare>; | ||
| 363 | |||
| 364 | template<class Key, class T, class Compare = less<Key>> | ||
| 365 | flat_map(sorted_unique_t, initializer_list<pair<Key, T>>, Compare = Compare()) | ||
| 366 | -> flat_map<Key, T, Compare>; | ||
| 27 | 367 | ||
| 28 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | 368 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, |
| 29 | class Allocator> | 369 | class Allocator> |
| 30 | struct uses_allocator<flat_map<Key, T, Compare, KeyContainer, MappedContainer>, | 370 | struct uses_allocator<flat_map<Key, T, Compare, KeyContainer, MappedContainer>, Allocator> |
| 31 | Allocator>; | 371 | : bool_constant<uses_allocator_v<KeyContainer, Allocator> && |
| 372 | uses_allocator_v<MappedContainer, Allocator>> { }; | ||
| 32 | 373 | ||
| 33 | // [flat.map.erasure], erasure for flat_map | 374 | // [flat.map.erasure], erasure for flat_map |
| 34 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | 375 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, |
| ... | @@ -36,18 +377,329 @@ namespace std { | ... | @@ -36,18 +377,329 @@ namespace std { |
| 36 | typename flat_map<Key, T, Compare, KeyContainer, MappedContainer>::size_type | 377 | typename flat_map<Key, T, Compare, KeyContainer, MappedContainer>::size_type |
| 37 | erase_if(flat_map<Key, T, Compare, KeyContainer, MappedContainer>& c, Predicate pred); | 378 | erase_if(flat_map<Key, T, Compare, KeyContainer, MappedContainer>& c, Predicate pred); |
| 38 | 379 | ||
| 380 | struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; }; | ||
| 381 | inline constexpr sorted_equivalent_t sorted_equivalent{}; | ||
| 382 | |||
| 39 | // [flat.multimap], class template flat_multimap | 383 | // [flat.multimap], class template flat_multimap |
| 40 | template<class Key, class T, class Compare = less<Key>, | 384 | template<class Key, class T, class Compare = less<Key>, |
| 41 | class KeyContainer = vector<Key>, class MappedContainer = vector<T>> | 385 | class KeyContainer = vector<Key>, class MappedContainer = vector<T>> |
| 42 | class flat_multimap; | 386 | class flat_multimap { |
| 387 | public: | ||
| 388 | // types | ||
| 389 | using key_type = Key; | ||
| 390 | using mapped_type = T; | ||
| 391 | using value_type = pair<key_type, mapped_type>; | ||
| 392 | using key_compare = Compare; | ||
| 393 | using reference = pair<const key_type&, mapped_type&>; | ||
| 394 | using const_reference = pair<const key_type&, const mapped_type&>; | ||
| 395 | using size_type = size_t; | ||
| 396 | using difference_type = ptrdiff_t; | ||
| 397 | using iterator = implementation-defined; // see [container.requirements] | ||
| 398 | using const_iterator = implementation-defined; // see [container.requirements] | ||
| 399 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 400 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 401 | using key_container_type = KeyContainer; | ||
| 402 | using mapped_container_type = MappedContainer; | ||
| 43 | 403 | ||
| 44 | struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; }; | 404 | class value_compare { |
| 45 | inline constexpr sorted_equivalent_t sorted_equivalent{}; | 405 | private: |
| 406 | key_compare comp; // exposition only | ||
| 407 | constexpr value_compare(key_compare c) : comp(c) { } // exposition only | ||
| 408 | |||
| 409 | public: | ||
| 410 | constexpr bool operator()(const_reference x, const_reference y) const { | ||
| 411 | return comp(x.first, y.first); | ||
| 412 | } | ||
| 413 | }; | ||
| 414 | |||
| 415 | struct containers { | ||
| 416 | key_container_type keys; | ||
| 417 | mapped_container_type values; | ||
| 418 | }; | ||
| 419 | |||
| 420 | // [flat.multimap.cons], constructors | ||
| 421 | constexpr flat_multimap() : flat_multimap(key_compare()) { } | ||
| 422 | |||
| 423 | constexpr flat_multimap(const flat_multimap&); | ||
| 424 | constexpr flat_multimap(flat_multimap&&); | ||
| 425 | constexpr flat_multimap& operator=(const flat_multimap&); | ||
| 426 | constexpr flat_multimap& operator=(flat_multimap&&); | ||
| 427 | |||
| 428 | constexpr explicit flat_multimap(const key_compare& comp) | ||
| 429 | : c(), compare(comp) { } | ||
| 430 | |||
| 431 | constexpr flat_multimap(key_container_type key_cont, mapped_container_type mapped_cont, | ||
| 432 | const key_compare& comp = key_compare()); | ||
| 433 | |||
| 434 | constexpr flat_multimap(sorted_equivalent_t, | ||
| 435 | key_container_type key_cont, mapped_container_type mapped_cont, | ||
| 436 | const key_compare& comp = key_compare()); | ||
| 437 | |||
| 438 | template<class InputIterator> | ||
| 439 | constexpr flat_multimap(InputIterator first, InputIterator last, | ||
| 440 | const key_compare& comp = key_compare()) | ||
| 441 | : c(), compare(comp) | ||
| 442 | { insert(first, last); } | ||
| 443 | |||
| 444 | template<class InputIterator> | ||
| 445 | constexpr flat_multimap(sorted_equivalent_t, InputIterator first, InputIterator last, | ||
| 446 | const key_compare& comp = key_compare()) | ||
| 447 | : c(), compare(comp) { insert(sorted_equivalent, first, last); } | ||
| 448 | |||
| 449 | template<container-compatible-range<value_type> R> | ||
| 450 | constexpr flat_multimap(from_range_t, R&& rg) | ||
| 451 | : flat_multimap(from_range, std::forward<R>(rg), key_compare()) { } | ||
| 452 | template<container-compatible-range<value_type> R> | ||
| 453 | constexpr flat_multimap(from_range_t, R&& rg, const key_compare& comp) | ||
| 454 | : flat_multimap(comp) { insert_range(std::forward<R>(rg)); } | ||
| 455 | |||
| 456 | constexpr flat_multimap(initializer_list<value_type> il, | ||
| 457 | const key_compare& comp = key_compare()) | ||
| 458 | : flat_multimap(il.begin(), il.end(), comp) { } | ||
| 459 | |||
| 460 | constexpr flat_multimap(sorted_equivalent_t, initializer_list<value_type> il, | ||
| 461 | const key_compare& comp = key_compare()) | ||
| 462 | : flat_multimap(sorted_equivalent, il.begin(), il.end(), comp) { } | ||
| 463 | |||
| 464 | // [flat.multimap.cons.alloc], constructors with allocators | ||
| 465 | |||
| 466 | template<class Alloc> | ||
| 467 | constexpr explicit flat_multimap(const Alloc& a); | ||
| 468 | template<class Alloc> | ||
| 469 | constexpr flat_multimap(const key_compare& comp, const Alloc& a); | ||
| 470 | template<class Alloc> | ||
| 471 | constexpr flat_multimap(const key_container_type& key_cont, | ||
| 472 | const mapped_container_type& mapped_cont, const Alloc& a); | ||
| 473 | template<class Alloc> | ||
| 474 | constexpr flat_multimap(const key_container_type& key_cont, | ||
| 475 | const mapped_container_type& mapped_cont, | ||
| 476 | const key_compare& comp, const Alloc& a); | ||
| 477 | template<class Alloc> | ||
| 478 | constexpr flat_multimap(sorted_equivalent_t, const key_container_type& key_cont, | ||
| 479 | const mapped_container_type& mapped_cont, const Alloc& a); | ||
| 480 | template<class Alloc> | ||
| 481 | constexpr flat_multimap(sorted_equivalent_t, const key_container_type& key_cont, | ||
| 482 | const mapped_container_type& mapped_cont, | ||
| 483 | const key_compare& comp, const Alloc& a); | ||
| 484 | template<class Alloc> | ||
| 485 | constexpr flat_multimap(const flat_multimap&, const Alloc& a); | ||
| 486 | template<class Alloc> | ||
| 487 | constexpr flat_multimap(flat_multimap&&, const Alloc& a); | ||
| 488 | template<class InputIterator, class Alloc> | ||
| 489 | constexpr flat_multimap(InputIterator first, InputIterator last, const Alloc& a); | ||
| 490 | template<class InputIterator, class Alloc> | ||
| 491 | constexpr flat_multimap(InputIterator first, InputIterator last, | ||
| 492 | const key_compare& comp, const Alloc& a); | ||
| 493 | template<class InputIterator, class Alloc> | ||
| 494 | constexpr flat_multimap(sorted_equivalent_t, InputIterator first, InputIterator last, | ||
| 495 | const Alloc& a); | ||
| 496 | template<class InputIterator, class Alloc> | ||
| 497 | constexpr flat_multimap(sorted_equivalent_t, InputIterator first, InputIterator last, | ||
| 498 | const key_compare& comp, const Alloc& a); | ||
| 499 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 500 | constexpr flat_multimap(from_range_t, R&& rg, const Alloc& a); | ||
| 501 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 502 | constexpr flat_multimap(from_range_t, R&& rg, const key_compare& comp, const Alloc& a); | ||
| 503 | template<class Alloc> | ||
| 504 | constexpr flat_multimap(initializer_list<value_type> il, const Alloc& a); | ||
| 505 | template<class Alloc> | ||
| 506 | constexpr flat_multimap(initializer_list<value_type> il, const key_compare& comp, | ||
| 507 | const Alloc& a); | ||
| 508 | template<class Alloc> | ||
| 509 | constexpr flat_multimap(sorted_equivalent_t, initializer_list<value_type> il, | ||
| 510 | const Alloc& a); | ||
| 511 | template<class Alloc> | ||
| 512 | constexpr flat_multimap(sorted_equivalent_t, initializer_list<value_type> il, | ||
| 513 | const key_compare& comp, const Alloc& a); | ||
| 514 | |||
| 515 | flat_multimap& operator=(initializer_list<value_type>); | ||
| 516 | |||
| 517 | // iterators | ||
| 518 | constexpr iterator begin() noexcept; | ||
| 519 | constexpr const_iterator begin() const noexcept; | ||
| 520 | constexpr iterator end() noexcept; | ||
| 521 | constexpr const_iterator end() const noexcept; | ||
| 522 | |||
| 523 | constexpr reverse_iterator rbegin() noexcept; | ||
| 524 | constexpr const_reverse_iterator rbegin() const noexcept; | ||
| 525 | constexpr reverse_iterator rend() noexcept; | ||
| 526 | constexpr const_reverse_iterator rend() const noexcept; | ||
| 527 | |||
| 528 | constexpr const_iterator cbegin() const noexcept; | ||
| 529 | constexpr const_iterator cend() const noexcept; | ||
| 530 | constexpr const_reverse_iterator crbegin() const noexcept; | ||
| 531 | constexpr const_reverse_iterator crend() const noexcept; | ||
| 532 | |||
| 533 | // capacity | ||
| 534 | constexpr bool empty() const noexcept; | ||
| 535 | constexpr size_type size() const noexcept; | ||
| 536 | constexpr size_type max_size() const noexcept; | ||
| 537 | |||
| 538 | // modifiers | ||
| 539 | template<class... Args> constexpr iterator emplace(Args&&... args); | ||
| 540 | template<class... Args> | ||
| 541 | constexpr iterator emplace_hint(const_iterator position, Args&&... args); | ||
| 542 | |||
| 543 | constexpr iterator insert(const value_type& x) | ||
| 544 | { return emplace(x); } | ||
| 545 | constexpr iterator insert(value_type&& x) | ||
| 546 | { return emplace(std::move(x)); } | ||
| 547 | constexpr iterator insert(const_iterator position, const value_type& x) | ||
| 548 | { return emplace_hint(position, x); } | ||
| 549 | constexpr iterator insert(const_iterator position, value_type&& x) | ||
| 550 | { return emplace_hint(position, std::move(x)); } | ||
| 551 | |||
| 552 | template<class P> constexpr iterator insert(P&& x); | ||
| 553 | template<class P> | ||
| 554 | constexpr iterator insert(const_iterator position, P&&); | ||
| 555 | template<class InputIterator> | ||
| 556 | constexpr void insert(InputIterator first, InputIterator last); | ||
| 557 | template<class InputIterator> | ||
| 558 | constexpr void insert(sorted_equivalent_t, InputIterator first, InputIterator last); | ||
| 559 | template<container-compatible-range<value_type> R> | ||
| 560 | constexpr void insert_range(R&& rg); | ||
| 561 | template<container-compatible-range<value_type> R> | ||
| 562 | constexpr void insert_range(sorted_equivalent_t, R&& rg); | ||
| 563 | |||
| 564 | constexpr void insert(initializer_list<value_type> il) | ||
| 565 | { insert(il.begin(), il.end()); } | ||
| 566 | constexpr void insert(sorted_equivalent_t, initializer_list<value_type> il) | ||
| 567 | { insert(sorted_equivalent, il.begin(), il.end()); } | ||
| 568 | |||
| 569 | constexpr containers extract() &&; | ||
| 570 | constexpr void replace(key_container_type&& key_cont, mapped_container_type&& mapped_cont); | ||
| 571 | |||
| 572 | constexpr iterator erase(iterator position); | ||
| 573 | constexpr iterator erase(const_iterator position); | ||
| 574 | constexpr size_type erase(const key_type& x); | ||
| 575 | template<class K> constexpr size_type erase(K&& x); | ||
| 576 | constexpr iterator erase(const_iterator first, const_iterator last); | ||
| 577 | |||
| 578 | constexpr void swap(flat_multimap&) | ||
| 579 | noexcept(is_nothrow_swappable_v<key_container_type> && | ||
| 580 | is_nothrow_swappable_v<mapped_container_type> && | ||
| 581 | is_nothrow_swappable_v<key_compare>); | ||
| 582 | constexpr void clear() noexcept; | ||
| 583 | |||
| 584 | // observers | ||
| 585 | constexpr key_compare key_comp() const; | ||
| 586 | constexpr value_compare value_comp() const; | ||
| 587 | |||
| 588 | constexpr const key_container_type& keys() const noexcept { return c.keys; } | ||
| 589 | constexpr const mapped_container_type& values() const noexcept { return c.values; } | ||
| 590 | |||
| 591 | // map operations | ||
| 592 | constexpr iterator find(const key_type& x); | ||
| 593 | constexpr const_iterator find(const key_type& x) const; | ||
| 594 | template<class K> constexpr iterator find(const K& x); | ||
| 595 | template<class K> constexpr const_iterator find(const K& x) const; | ||
| 596 | |||
| 597 | constexpr size_type count(const key_type& x) const; | ||
| 598 | template<class K> constexpr size_type count(const K& x) const; | ||
| 599 | |||
| 600 | constexpr bool contains(const key_type& x) const; | ||
| 601 | template<class K> constexpr bool contains(const K& x) const; | ||
| 602 | |||
| 603 | constexpr iterator lower_bound(const key_type& x); | ||
| 604 | constexpr const_iterator lower_bound(const key_type& x) const; | ||
| 605 | template<class K> constexpr iterator lower_bound(const K& x); | ||
| 606 | template<class K> constexpr const_iterator lower_bound(const K& x) const; | ||
| 607 | |||
| 608 | constexpr iterator upper_bound(const key_type& x); | ||
| 609 | constexpr const_iterator upper_bound(const key_type& x) const; | ||
| 610 | template<class K> constexpr iterator upper_bound(const K& x); | ||
| 611 | template<class K> constexpr const_iterator upper_bound(const K& x) const; | ||
| 612 | |||
| 613 | constexpr pair<iterator, iterator> equal_range(const key_type& x); | ||
| 614 | constexpr pair<const_iterator, const_iterator> equal_range(const key_type& x) const; | ||
| 615 | template<class K> | ||
| 616 | constexpr pair<iterator, iterator> equal_range(const K& x); | ||
| 617 | template<class K> | ||
| 618 | constexpr pair<const_iterator, const_iterator> equal_range(const K& x) const; | ||
| 619 | |||
| 620 | friend constexpr bool operator==(const flat_multimap& x, const flat_multimap& y); | ||
| 621 | |||
| 622 | friend constexpr synth-three-way-result<value_type> | ||
| 623 | operator<=>(const flat_multimap& x, const flat_multimap& y); | ||
| 624 | |||
| 625 | friend constexpr void swap(flat_multimap& x, flat_multimap& y) | ||
| 626 | noexcept(noexcept(x.swap(y))) | ||
| 627 | { x.swap(y); } | ||
| 628 | |||
| 629 | private: | ||
| 630 | containers c; // exposition only | ||
| 631 | key_compare compare; // exposition only | ||
| 632 | }; | ||
| 633 | |||
| 634 | template<class KeyContainer, class MappedContainer, | ||
| 635 | class Compare = less<typename KeyContainer::value_type>> | ||
| 636 | flat_multimap(KeyContainer, MappedContainer, Compare = Compare()) | ||
| 637 | -> flat_multimap<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 638 | Compare, KeyContainer, MappedContainer>; | ||
| 639 | |||
| 640 | template<class KeyContainer, class MappedContainer, class Allocator> | ||
| 641 | flat_multimap(KeyContainer, MappedContainer, Allocator) | ||
| 642 | -> flat_multimap<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 643 | less<typename KeyContainer::value_type>, KeyContainer, MappedContainer>; | ||
| 644 | template<class KeyContainer, class MappedContainer, class Compare, class Allocator> | ||
| 645 | flat_multimap(KeyContainer, MappedContainer, Compare, Allocator) | ||
| 646 | -> flat_multimap<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 647 | Compare, KeyContainer, MappedContainer>; | ||
| 648 | |||
| 649 | template<class KeyContainer, class MappedContainer, | ||
| 650 | class Compare = less<typename KeyContainer::value_type>> | ||
| 651 | flat_multimap(sorted_equivalent_t, KeyContainer, MappedContainer, Compare = Compare()) | ||
| 652 | -> flat_multimap<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 653 | Compare, KeyContainer, MappedContainer>; | ||
| 654 | |||
| 655 | template<class KeyContainer, class MappedContainer, class Allocator> | ||
| 656 | flat_multimap(sorted_equivalent_t, KeyContainer, MappedContainer, Allocator) | ||
| 657 | -> flat_multimap<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 658 | less<typename KeyContainer::value_type>, KeyContainer, MappedContainer>; | ||
| 659 | template<class KeyContainer, class MappedContainer, class Compare, class Allocator> | ||
| 660 | flat_multimap(sorted_equivalent_t, KeyContainer, MappedContainer, Compare, Allocator) | ||
| 661 | -> flat_multimap<typename KeyContainer::value_type, typename MappedContainer::value_type, | ||
| 662 | Compare, KeyContainer, MappedContainer>; | ||
| 663 | |||
| 664 | template<class InputIterator, class Compare = less<iter-key-type<InputIterator>>> | ||
| 665 | flat_multimap(InputIterator, InputIterator, Compare = Compare()) | ||
| 666 | -> flat_multimap<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Compare>; | ||
| 667 | |||
| 668 | template<class InputIterator, class Compare = less<iter-key-type<InputIterator>>> | ||
| 669 | flat_multimap(sorted_equivalent_t, InputIterator, InputIterator, Compare = Compare()) | ||
| 670 | -> flat_multimap<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Compare>; | ||
| 671 | |||
| 672 | template<ranges::input_range R, class Compare = less<range-key-type<R>>, | ||
| 673 | class Allocator = allocator<byte>> | ||
| 674 | flat_multimap(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) | ||
| 675 | -> flat_multimap<range-key-type<R>, range-mapped-type<R>, Compare, | ||
| 676 | vector<range-key-type<R>, | ||
| 677 | alloc-rebind<Allocator, range-key-type<R>>>, | ||
| 678 | vector<range-mapped-type<R>, | ||
| 679 | alloc-rebind<Allocator, range-mapped-type<R>>>>; | ||
| 680 | |||
| 681 | template<ranges::input_range R, class Allocator> | ||
| 682 | flat_multimap(from_range_t, R&&, Allocator) | ||
| 683 | -> flat_multimap<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, | ||
| 684 | vector<range-key-type<R>, | ||
| 685 | alloc-rebind<Allocator, range-key-type<R>>>, | ||
| 686 | vector<range-mapped-type<R>, | ||
| 687 | alloc-rebind<Allocator, range-mapped-type<R>>>>; | ||
| 688 | |||
| 689 | template<class Key, class T, class Compare = less<Key>> | ||
| 690 | flat_multimap(initializer_list<pair<Key, T>>, Compare = Compare()) | ||
| 691 | -> flat_multimap<Key, T, Compare>; | ||
| 692 | |||
| 693 | template<class Key, class T, class Compare = less<Key>> | ||
| 694 | flat_multimap(sorted_equivalent_t, initializer_list<pair<Key, T>>, Compare = Compare()) | ||
| 695 | -> flat_multimap<Key, T, Compare>; | ||
| 46 | 696 | ||
| 47 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | 697 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, |
| 48 | class Allocator> | 698 | class Allocator> |
| 49 | struct uses_allocator<flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>, | 699 | struct uses_allocator<flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>, |
| 50 | Allocator>; | 700 | Allocator> |
| 701 | : bool_constant<uses_allocator_v<KeyContainer, Allocator> && | ||
| 702 | uses_allocator_v<MappedContainer, Allocator>> { }; | ||
| 51 | 703 | ||
| 52 | // [flat.multimap.erasure], erasure for flat_multimap | 704 | // [flat.multimap.erasure], erasure for flat_multimap |
| 53 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | 705 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, |
lib/libcxx/include/flat_set+543-8| ... | @@ -17,30 +17,565 @@ | ... | @@ -17,30 +17,565 @@ |
| 17 | #include <initializer_list> // see [initializer.list.syn] | 17 | #include <initializer_list> // see [initializer.list.syn] |
| 18 | 18 | ||
| 19 | namespace std { | 19 | namespace std { |
| 20 | struct sorted_unique_t { explicit sorted_unique_t() = default; }; | ||
| 21 | inline constexpr sorted_unique_t sorted_unique{}; | ||
| 22 | |||
| 20 | // [flat.set], class template flat_set | 23 | // [flat.set], class template flat_set |
| 21 | template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>> | 24 | template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>> |
| 22 | class flat_set; | 25 | class flat_set { |
| 26 | public: | ||
| 27 | // types | ||
| 28 | using key_type = Key; | ||
| 29 | using value_type = Key; | ||
| 30 | using key_compare = Compare; | ||
| 31 | using value_compare = Compare; | ||
| 32 | using reference = value_type&; | ||
| 33 | using const_reference = const value_type&; | ||
| 34 | using size_type = KeyContainer::size_type; | ||
| 35 | using difference_type = KeyContainer::difference_type; | ||
| 36 | using iterator = implementation-defined; // see [container.requirements] | ||
| 37 | using const_iterator = implementation-defined; // see [container.requirements] | ||
| 38 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 39 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 40 | using container_type = KeyContainer; | ||
| 23 | 41 | ||
| 24 | struct sorted_unique_t { explicit sorted_unique_t() = default; }; | 42 | // [flat.set.cons], constructors |
| 25 | inline constexpr sorted_unique_t sorted_unique{}; | 43 | constexpr flat_set() : flat_set(key_compare()) { } |
| 44 | |||
| 45 | constexpr flat_set(const flat_set&); | ||
| 46 | constexpr flat_set(flat_set&&); | ||
| 47 | constexpr flat_set& operator=(const flat_set&); | ||
| 48 | constexpr flat_set& operator=(flat_set&&); | ||
| 49 | |||
| 50 | constexpr explicit flat_set(const key_compare& comp) | ||
| 51 | : c(), compare(comp) { } | ||
| 52 | |||
| 53 | constexpr explicit flat_set(container_type cont, const key_compare& comp = key_compare()); | ||
| 54 | |||
| 55 | constexpr flat_set(sorted_unique_t, container_type cont, | ||
| 56 | const key_compare& comp = key_compare()) | ||
| 57 | : c(std::move(cont)), compare(comp) { } | ||
| 58 | |||
| 59 | template<class InputIterator> | ||
| 60 | constexpr flat_set(InputIterator first, InputIterator last, | ||
| 61 | const key_compare& comp = key_compare()) | ||
| 62 | : c(), compare(comp) | ||
| 63 | { insert(first, last); } | ||
| 64 | |||
| 65 | template<class InputIterator> | ||
| 66 | constexpr flat_set(sorted_unique_t, InputIterator first, InputIterator last, | ||
| 67 | const key_compare& comp = key_compare()) | ||
| 68 | : c(first, last), compare(comp) { } | ||
| 69 | |||
| 70 | template<container-compatible-range<value_type> R> | ||
| 71 | constexpr flat_set(from_range_t, R&& rg) | ||
| 72 | : flat_set(from_range, std::forward<R>(rg), key_compare()) { } | ||
| 73 | template<container-compatible-range<value_type> R> | ||
| 74 | constexpr flat_set(from_range_t, R&& rg, const key_compare& comp) | ||
| 75 | : flat_set(comp) | ||
| 76 | { insert_range(std::forward<R>(rg)); } | ||
| 77 | |||
| 78 | constexpr flat_set(initializer_list<value_type> il, const key_compare& comp = key_compare()) | ||
| 79 | : flat_set(il.begin(), il.end(), comp) { } | ||
| 80 | |||
| 81 | constexpr flat_set(sorted_unique_t, initializer_list<value_type> il, | ||
| 82 | const key_compare& comp = key_compare()) | ||
| 83 | : flat_set(sorted_unique, il.begin(), il.end(), comp) { } | ||
| 84 | |||
| 85 | // [flat.set.cons.alloc], constructors with allocators | ||
| 86 | |||
| 87 | template<class Alloc> | ||
| 88 | constexpr explicit flat_set(const Alloc& a); | ||
| 89 | template<class Alloc> | ||
| 90 | constexpr flat_set(const key_compare& comp, const Alloc& a); | ||
| 91 | template<class Alloc> | ||
| 92 | constexpr flat_set(const container_type& cont, const Alloc& a); | ||
| 93 | template<class Alloc> | ||
| 94 | constexpr flat_set(const container_type& cont, const key_compare& comp, const Alloc& a); | ||
| 95 | template<class Alloc> | ||
| 96 | constexpr flat_set(sorted_unique_t, const container_type& cont, const Alloc& a); | ||
| 97 | template<class Alloc> | ||
| 98 | constexpr flat_set(sorted_unique_t, const container_type& cont, | ||
| 99 | const key_compare& comp, const Alloc& a); | ||
| 100 | template<class Alloc> | ||
| 101 | constexpr flat_set(const flat_set&, const Alloc& a); | ||
| 102 | template<class Alloc> | ||
| 103 | constexpr flat_set(flat_set&&, const Alloc& a); | ||
| 104 | template<class InputIterator, class Alloc> | ||
| 105 | constexpr flat_set(InputIterator first, InputIterator last, const Alloc& a); | ||
| 106 | template<class InputIterator, class Alloc> | ||
| 107 | constexpr flat_set(InputIterator first, InputIterator last, | ||
| 108 | const key_compare& comp, const Alloc& a); | ||
| 109 | template<class InputIterator, class Alloc> | ||
| 110 | constexpr flat_set(sorted_unique_t, InputIterator first, InputIterator last, | ||
| 111 | const Alloc& a); | ||
| 112 | template<class InputIterator, class Alloc> | ||
| 113 | constexpr flat_set(sorted_unique_t, InputIterator first, InputIterator last, | ||
| 114 | const key_compare& comp, const Alloc& a); | ||
| 115 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 116 | constexpr flat_set(from_range_t, R&& rg, const Alloc& a); | ||
| 117 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 118 | constexpr flat_set(from_range_t, R&& rg, const key_compare& comp, const Alloc& a); | ||
| 119 | template<class Alloc> | ||
| 120 | constexpr flat_set(initializer_list<value_type> il, const Alloc& a); | ||
| 121 | template<class Alloc> | ||
| 122 | constexpr flat_set(initializer_list<value_type> il, const key_compare& comp, | ||
| 123 | const Alloc& a); | ||
| 124 | template<class Alloc> | ||
| 125 | constexpr flat_set(sorted_unique_t, initializer_list<value_type> il, const Alloc& a); | ||
| 126 | template<class Alloc> | ||
| 127 | constexpr flat_set(sorted_unique_t, initializer_list<value_type> il, | ||
| 128 | const key_compare& comp, const Alloc& a); | ||
| 129 | |||
| 130 | constexpr flat_set& operator=(initializer_list<value_type>); | ||
| 131 | |||
| 132 | // iterators | ||
| 133 | constexpr iterator begin() noexcept; | ||
| 134 | constexpr const_iterator begin() const noexcept; | ||
| 135 | constexpr iterator end() noexcept; | ||
| 136 | constexpr const_iterator end() const noexcept; | ||
| 137 | |||
| 138 | constexpr reverse_iterator rbegin() noexcept; | ||
| 139 | constexpr const_reverse_iterator rbegin() const noexcept; | ||
| 140 | constexpr reverse_iterator rend() noexcept; | ||
| 141 | constexpr const_reverse_iterator rend() const noexcept; | ||
| 142 | |||
| 143 | constexpr const_iterator cbegin() const noexcept; | ||
| 144 | constexpr const_iterator cend() const noexcept; | ||
| 145 | constexpr const_reverse_iterator crbegin() const noexcept; | ||
| 146 | constexpr const_reverse_iterator crend() const noexcept; | ||
| 147 | |||
| 148 | // capacity | ||
| 149 | constexpr bool empty() const noexcept; | ||
| 150 | constexpr size_type size() const noexcept; | ||
| 151 | constexpr size_type max_size() const noexcept; | ||
| 152 | |||
| 153 | // [flat.set.modifiers], modifiers | ||
| 154 | template<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args); | ||
| 155 | template<class... Args> | ||
| 156 | constexpr iterator emplace_hint(const_iterator position, Args&&... args); | ||
| 157 | |||
| 158 | constexpr pair<iterator, bool> insert(const value_type& x) | ||
| 159 | { return emplace(x); } | ||
| 160 | constexpr pair<iterator, bool> insert(value_type&& x) | ||
| 161 | { return emplace(std::move(x)); } | ||
| 162 | template<class K> constexpr pair<iterator, bool> insert(K&& x); | ||
| 163 | constexpr iterator insert(const_iterator position, const value_type& x) | ||
| 164 | { return emplace_hint(position, x); } | ||
| 165 | constexpr iterator insert(const_iterator position, value_type&& x) | ||
| 166 | { return emplace_hint(position, std::move(x)); } | ||
| 167 | template<class K> constexpr iterator insert(const_iterator hint, K&& x); | ||
| 168 | |||
| 169 | template<class InputIterator> | ||
| 170 | constexpr void insert(InputIterator first, InputIterator last); | ||
| 171 | template<class InputIterator> | ||
| 172 | constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last); | ||
| 173 | template<container-compatible-range<value_type> R> | ||
| 174 | constexpr void insert_range(R&& rg); | ||
| 175 | template<container-compatible-range<value_type> R> | ||
| 176 | constexpr void insert_range(sorted_unique_t, R&& rg); | ||
| 177 | |||
| 178 | constexpr void insert(initializer_list<value_type> il) | ||
| 179 | { insert(il.begin(), il.end()); } | ||
| 180 | constexpr void insert(sorted_unique_t, initializer_list<value_type> il) | ||
| 181 | { insert(sorted_unique, il.begin(), il.end()); } | ||
| 182 | |||
| 183 | constexpr container_type extract() &&; | ||
| 184 | constexpr void replace(container_type&&); | ||
| 185 | |||
| 186 | constexpr iterator erase(iterator position) requires (!same_as<iterator, const_iterator>); | ||
| 187 | constexpr iterator erase(const_iterator position); | ||
| 188 | constexpr size_type erase(const key_type& x); | ||
| 189 | template<class K> constexpr size_type erase(K&& x); | ||
| 190 | constexpr iterator erase(const_iterator first, const_iterator last); | ||
| 191 | |||
| 192 | constexpr void swap(flat_set& y) noexcept(see below); | ||
| 193 | constexpr void clear() noexcept; | ||
| 194 | |||
| 195 | // observers | ||
| 196 | constexpr key_compare key_comp() const; | ||
| 197 | constexpr value_compare value_comp() const; | ||
| 198 | |||
| 199 | // set operations | ||
| 200 | constexpr iterator find(const key_type& x); | ||
| 201 | constexpr const_iterator find(const key_type& x) const; | ||
| 202 | template<class K> constexpr iterator find(const K& x); | ||
| 203 | template<class K> constexpr const_iterator find(const K& x) const; | ||
| 204 | |||
| 205 | constexpr size_type count(const key_type& x) const; | ||
| 206 | template<class K> constexpr size_type count(const K& x) const; | ||
| 207 | |||
| 208 | constexpr bool contains(const key_type& x) const; | ||
| 209 | template<class K> constexpr bool contains(const K& x) const; | ||
| 210 | |||
| 211 | constexpr iterator lower_bound(const key_type& x); | ||
| 212 | constexpr const_iterator lower_bound(const key_type& x) const; | ||
| 213 | template<class K> constexpr iterator lower_bound(const K& x); | ||
| 214 | template<class K> constexpr const_iterator lower_bound(const K& x) const; | ||
| 215 | |||
| 216 | constexpr iterator upper_bound(const key_type& x); | ||
| 217 | constexpr const_iterator upper_bound(const key_type& x) const; | ||
| 218 | template<class K> constexpr iterator upper_bound(const K& x); | ||
| 219 | template<class K> constexpr const_iterator upper_bound(const K& x) const; | ||
| 220 | |||
| 221 | constexpr pair<iterator, iterator> equal_range(const key_type& x); | ||
| 222 | constexpr pair<const_iterator, const_iterator> equal_range(const key_type& x) const; | ||
| 223 | template<class K> | ||
| 224 | constexpr pair<iterator, iterator> equal_range(const K& x); | ||
| 225 | template<class K> | ||
| 226 | constexpr pair<const_iterator, const_iterator> equal_range(const K& x) const; | ||
| 227 | |||
| 228 | friend constexpr bool operator==(const flat_set& x, const flat_set& y); | ||
| 229 | |||
| 230 | friend constexpr synth-three-way-result<value_type> | ||
| 231 | operator<=>(const flat_set& x, const flat_set& y); | ||
| 232 | |||
| 233 | friend constexpr void swap(flat_set& x, flat_set& y) noexcept(noexcept(x.swap(y))) | ||
| 234 | { x.swap(y); } | ||
| 235 | |||
| 236 | private: | ||
| 237 | container_type c; // exposition only | ||
| 238 | key_compare compare; // exposition only | ||
| 239 | }; | ||
| 240 | |||
| 241 | template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>> | ||
| 242 | flat_set(KeyContainer, Compare = Compare()) | ||
| 243 | -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 244 | template<class KeyContainer, class Allocator> | ||
| 245 | flat_set(KeyContainer, Allocator) | ||
| 246 | -> flat_set<typename KeyContainer::value_type, | ||
| 247 | less<typename KeyContainer::value_type>, KeyContainer>; | ||
| 248 | template<class KeyContainer, class Compare, class Allocator> | ||
| 249 | flat_set(KeyContainer, Compare, Allocator) | ||
| 250 | -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 251 | |||
| 252 | template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>> | ||
| 253 | flat_set(sorted_unique_t, KeyContainer, Compare = Compare()) | ||
| 254 | -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 255 | template<class KeyContainer, class Allocator> | ||
| 256 | flat_set(sorted_unique_t, KeyContainer, Allocator) | ||
| 257 | -> flat_set<typename KeyContainer::value_type, | ||
| 258 | less<typename KeyContainer::value_type>, KeyContainer>; | ||
| 259 | template<class KeyContainer, class Compare, class Allocator> | ||
| 260 | flat_set(sorted_unique_t, KeyContainer, Compare, Allocator) | ||
| 261 | -> flat_set<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 262 | |||
| 263 | template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>> | ||
| 264 | flat_set(InputIterator, InputIterator, Compare = Compare()) | ||
| 265 | -> flat_set<iter-value-type<InputIterator>, Compare>; | ||
| 266 | |||
| 267 | template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>> | ||
| 268 | flat_set(sorted_unique_t, InputIterator, InputIterator, Compare = Compare()) | ||
| 269 | -> flat_set<iter-value-type<InputIterator>, Compare>; | ||
| 270 | |||
| 271 | template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>, | ||
| 272 | class Allocator = allocator<ranges::range_value_t<R>>> | ||
| 273 | flat_set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) | ||
| 274 | -> flat_set<ranges::range_value_t<R>, Compare, | ||
| 275 | vector<ranges::range_value_t<R>, | ||
| 276 | alloc-rebind<Allocator, ranges::range_value_t<R>>>>; | ||
| 277 | |||
| 278 | template<ranges::input_range R, class Allocator> | ||
| 279 | flat_set(from_range_t, R&&, Allocator) | ||
| 280 | -> flat_set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, | ||
| 281 | vector<ranges::range_value_t<R>, | ||
| 282 | alloc-rebind<Allocator, ranges::range_value_t<R>>>>; | ||
| 283 | |||
| 284 | template<class Key, class Compare = less<Key>> | ||
| 285 | flat_set(initializer_list<Key>, Compare = Compare()) | ||
| 286 | -> flat_set<Key, Compare>; | ||
| 287 | |||
| 288 | template<class Key, class Compare = less<Key>> | ||
| 289 | flat_set(sorted_unique_t, initializer_list<Key>, Compare = Compare()) | ||
| 290 | -> flat_set<Key, Compare>; | ||
| 26 | 291 | ||
| 27 | template<class Key, class Compare, class KeyContainer, class Allocator> | 292 | template<class Key, class Compare, class KeyContainer, class Allocator> |
| 28 | struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>; | 293 | struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator> |
| 294 | : bool_constant<uses_allocator_v<KeyContainer, Allocator>> { }; | ||
| 29 | 295 | ||
| 30 | // [flat.set.erasure], erasure for flat_set | 296 | // [flat.set.erasure], erasure for flat_set |
| 31 | template<class Key, class Compare, class KeyContainer, class Predicate> | 297 | template<class Key, class Compare, class KeyContainer, class Predicate> |
| 32 | typename flat_set<Key, Compare, KeyContainer>::size_type | 298 | typename flat_set<Key, Compare, KeyContainer>::size_type |
| 33 | erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred); | 299 | erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred); |
| 34 | 300 | ||
| 301 | struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; }; | ||
| 302 | inline constexpr sorted_equivalent_t sorted_equivalent{}; | ||
| 303 | |||
| 35 | // [flat.multiset], class template flat_multiset | 304 | // [flat.multiset], class template flat_multiset |
| 36 | template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>> | 305 | template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>> |
| 37 | class flat_multiset; | 306 | class flat_multiset { |
| 307 | public: | ||
| 308 | // types | ||
| 309 | using key_type = Key; | ||
| 310 | using value_type = Key; | ||
| 311 | using key_compare = Compare; | ||
| 312 | using value_compare = Compare; | ||
| 313 | using reference = value_type&; | ||
| 314 | using const_reference = const value_type&; | ||
| 315 | using size_type = KeyContainer::size_type; | ||
| 316 | using difference_type = KeyContainer::difference_type; | ||
| 317 | using iterator = implementation-defined; // see [container.requirements] | ||
| 318 | using const_iterator = implementation-defined; // see [container.requirements] | ||
| 319 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 320 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 321 | using container_type = KeyContainer; | ||
| 38 | 322 | ||
| 39 | struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; }; | 323 | // [flat.multiset.cons], constructors |
| 40 | inline constexpr sorted_equivalent_t sorted_equivalent{}; | 324 | constexpr flat_multiset() : flat_multiset(key_compare()) { } |
| 325 | |||
| 326 | constexpr flat_multiset(const flat_multiset&); | ||
| 327 | constexpr flat_multiset(flat_multiset&&); | ||
| 328 | constexpr flat_multiset& operator=(const flat_multiset&); | ||
| 329 | constexpr flat_multiset& operator=(flat_multiset&&); | ||
| 330 | |||
| 331 | constexpr explicit flat_multiset(const key_compare& comp) | ||
| 332 | : c(), compare(comp) { } | ||
| 333 | |||
| 334 | constexpr explicit flat_multiset(container_type cont, | ||
| 335 | const key_compare& comp = key_compare()); | ||
| 336 | |||
| 337 | constexpr flat_multiset(sorted_equivalent_t, container_type cont, | ||
| 338 | const key_compare& comp = key_compare()) | ||
| 339 | : c(std::move(cont)), compare(comp) { } | ||
| 340 | |||
| 341 | template<class InputIterator> | ||
| 342 | constexpr flat_multiset(InputIterator first, InputIterator last, | ||
| 343 | const key_compare& comp = key_compare()) | ||
| 344 | : c(), compare(comp) | ||
| 345 | { insert(first, last); } | ||
| 346 | |||
| 347 | template<class InputIterator> | ||
| 348 | constexpr flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last, | ||
| 349 | const key_compare& comp = key_compare()) | ||
| 350 | : c(first, last), compare(comp) { } | ||
| 351 | |||
| 352 | template<container-compatible-range<value_type> R> | ||
| 353 | constexpr flat_multiset(from_range_t, R&& rg) | ||
| 354 | : flat_multiset(from_range, std::forward<R>(rg), key_compare()) { } | ||
| 355 | template<container-compatible-range<value_type> R> | ||
| 356 | constexpr flat_multiset(from_range_t, R&& rg, const key_compare& comp) | ||
| 357 | : flat_multiset(comp) | ||
| 358 | { insert_range(std::forward<R>(rg)); } | ||
| 359 | |||
| 360 | constexpr flat_multiset(initializer_list<value_type> il, | ||
| 361 | const key_compare& comp = key_compare()) | ||
| 362 | : flat_multiset(il.begin(), il.end(), comp) { } | ||
| 363 | |||
| 364 | constexpr flat_multiset(sorted_equivalent_t, initializer_list<value_type> il, | ||
| 365 | const key_compare& comp = key_compare()) | ||
| 366 | : flat_multiset(sorted_equivalent, il.begin(), il.end(), comp) { } | ||
| 367 | |||
| 368 | // [flat.multiset.cons.alloc], constructors with allocators | ||
| 369 | |||
| 370 | template<class Alloc> | ||
| 371 | constexpr explicit flat_multiset(const Alloc& a); | ||
| 372 | template<class Alloc> | ||
| 373 | constexpr flat_multiset(const key_compare& comp, const Alloc& a); | ||
| 374 | template<class Alloc> | ||
| 375 | constexpr flat_multiset(const container_type& cont, const Alloc& a); | ||
| 376 | template<class Alloc> | ||
| 377 | constexpr flat_multiset(const container_type& cont, const key_compare& comp, | ||
| 378 | const Alloc& a); | ||
| 379 | template<class Alloc> | ||
| 380 | constexpr flat_multiset(sorted_equivalent_t, const container_type& cont, const Alloc& a); | ||
| 381 | template<class Alloc> | ||
| 382 | constexpr flat_multiset(sorted_equivalent_t, const container_type& cont, | ||
| 383 | const key_compare& comp, const Alloc& a); | ||
| 384 | template<class Alloc> | ||
| 385 | constexpr flat_multiset(const flat_multiset&, const Alloc& a); | ||
| 386 | template<class Alloc> | ||
| 387 | constexpr flat_multiset(flat_multiset&&, const Alloc& a); | ||
| 388 | template<class InputIterator, class Alloc> | ||
| 389 | constexpr flat_multiset(InputIterator first, InputIterator last, const Alloc& a); | ||
| 390 | template<class InputIterator, class Alloc> | ||
| 391 | constexpr flat_multiset(InputIterator first, InputIterator last, | ||
| 392 | const key_compare& comp, const Alloc& a); | ||
| 393 | template<class InputIterator, class Alloc> | ||
| 394 | constexpr flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last, | ||
| 395 | const Alloc& a); | ||
| 396 | template<class InputIterator, class Alloc> | ||
| 397 | constexpr flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last, | ||
| 398 | const key_compare& comp, const Alloc& a); | ||
| 399 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 400 | constexpr flat_multiset(from_range_t, R&& rg, const Alloc& a); | ||
| 401 | template<container-compatible-range<value_type> R, class Alloc> | ||
| 402 | constexpr flat_multiset(from_range_t, R&& rg, const key_compare& comp, const Alloc& a); | ||
| 403 | template<class Alloc> | ||
| 404 | constexpr flat_multiset(initializer_list<value_type> il, const Alloc& a); | ||
| 405 | template<class Alloc> | ||
| 406 | constexpr flat_multiset(initializer_list<value_type> il, const key_compare& comp, | ||
| 407 | const Alloc& a); | ||
| 408 | template<class Alloc> | ||
| 409 | constexpr flat_multiset(sorted_equivalent_t, initializer_list<value_type> il, | ||
| 410 | const Alloc& a); | ||
| 411 | template<class Alloc> | ||
| 412 | constexpr flat_multiset(sorted_equivalent_t, initializer_list<value_type> il, | ||
| 413 | const key_compare& comp, const Alloc& a); | ||
| 414 | |||
| 415 | constexpr flat_multiset& operator=(initializer_list<value_type>); | ||
| 416 | |||
| 417 | // iterators | ||
| 418 | constexpr iterator begin() noexcept; | ||
| 419 | constexpr const_iterator begin() const noexcept; | ||
| 420 | constexpr iterator end() noexcept; | ||
| 421 | constexpr const_iterator end() const noexcept; | ||
| 422 | |||
| 423 | constexpr reverse_iterator rbegin() noexcept; | ||
| 424 | constexpr const_reverse_iterator rbegin() const noexcept; | ||
| 425 | constexpr reverse_iterator rend() noexcept; | ||
| 426 | constexpr const_reverse_iterator rend() const noexcept; | ||
| 427 | |||
| 428 | constexpr const_iterator cbegin() const noexcept; | ||
| 429 | constexpr const_iterator cend() const noexcept; | ||
| 430 | constexpr const_reverse_iterator crbegin() const noexcept; | ||
| 431 | constexpr const_reverse_iterator crend() const noexcept; | ||
| 432 | |||
| 433 | // capacity | ||
| 434 | constexpr bool empty() const noexcept; | ||
| 435 | constexpr size_type size() const noexcept; | ||
| 436 | constexpr size_type max_size() const noexcept; | ||
| 437 | |||
| 438 | // [flat.multiset.modifiers], modifiers | ||
| 439 | template<class... Args> constexpr iterator emplace(Args&&... args); | ||
| 440 | template<class... Args> | ||
| 441 | constexpr iterator emplace_hint(const_iterator position, Args&&... args); | ||
| 442 | |||
| 443 | constexpr iterator insert(const value_type& x) | ||
| 444 | { return emplace(x); } | ||
| 445 | constexpr iterator insert(value_type&& x) | ||
| 446 | { return emplace(std::move(x)); } | ||
| 447 | constexpr iterator insert(const_iterator position, const value_type& x) | ||
| 448 | { return emplace_hint(position, x); } | ||
| 449 | constexpr iterator insert(const_iterator position, value_type&& x) | ||
| 450 | { return emplace_hint(position, std::move(x)); } | ||
| 451 | |||
| 452 | template<class InputIterator> | ||
| 453 | constexpr void insert(InputIterator first, InputIterator last); | ||
| 454 | template<class InputIterator> | ||
| 455 | constexpr void insert(sorted_equivalent_t, InputIterator first, InputIterator last); | ||
| 456 | template<container-compatible-range<value_type> R> | ||
| 457 | constexpr void insert_range(R&& rg); | ||
| 458 | template<container-compatible-range<value_type> R> | ||
| 459 | constexpr void insert_range(sorted_equivalent_t, R&& rg); | ||
| 460 | |||
| 461 | constexpr void insert(initializer_list<value_type> il) | ||
| 462 | { insert(il.begin(), il.end()); } | ||
| 463 | constexpr void insert(sorted_equivalent_t, initializer_list<value_type> il) | ||
| 464 | { insert(sorted_equivalent, il.begin(), il.end()); } | ||
| 465 | |||
| 466 | constexpr container_type extract() &&; | ||
| 467 | constexpr void replace(container_type&&); | ||
| 468 | |||
| 469 | constexpr iterator erase(iterator position) requires (!same_as<iterator, const_iterator>); | ||
| 470 | constexpr iterator erase(const_iterator position); | ||
| 471 | constexpr size_type erase(const key_type& x); | ||
| 472 | template<class K> constexpr size_type erase(K&& x); | ||
| 473 | constexpr iterator erase(const_iterator first, const_iterator last); | ||
| 474 | |||
| 475 | constexpr void swap(flat_multiset& y) noexcept(see below); | ||
| 476 | constexpr void clear() noexcept; | ||
| 477 | |||
| 478 | // observers | ||
| 479 | constexpr key_compare key_comp() const; | ||
| 480 | constexpr value_compare value_comp() const; | ||
| 481 | |||
| 482 | // set operations | ||
| 483 | constexpr iterator find(const key_type& x); | ||
| 484 | constexpr const_iterator find(const key_type& x) const; | ||
| 485 | template<class K> constexpr iterator find(const K& x); | ||
| 486 | template<class K> constexpr const_iterator find(const K& x) const; | ||
| 487 | |||
| 488 | constexpr size_type count(const key_type& x) const; | ||
| 489 | template<class K> constexpr size_type count(const K& x) const; | ||
| 490 | |||
| 491 | constexpr bool contains(const key_type& x) const; | ||
| 492 | template<class K> constexpr bool contains(const K& x) const; | ||
| 493 | |||
| 494 | constexpr iterator lower_bound(const key_type& x); | ||
| 495 | constexpr const_iterator lower_bound(const key_type& x) const; | ||
| 496 | template<class K> constexpr iterator lower_bound(const K& x); | ||
| 497 | template<class K> constexpr const_iterator lower_bound(const K& x) const; | ||
| 498 | |||
| 499 | constexpr iterator upper_bound(const key_type& x); | ||
| 500 | constexpr const_iterator upper_bound(const key_type& x) const; | ||
| 501 | template<class K> constexpr iterator upper_bound(const K& x); | ||
| 502 | template<class K> constexpr const_iterator upper_bound(const K& x) const; | ||
| 503 | |||
| 504 | constexpr pair<iterator, iterator> equal_range(const key_type& x); | ||
| 505 | constexpr pair<const_iterator, const_iterator> equal_range(const key_type& x) const; | ||
| 506 | template<class K> | ||
| 507 | constexpr pair<iterator, iterator> equal_range(const K& x); | ||
| 508 | template<class K> | ||
| 509 | constexpr pair<const_iterator, const_iterator> equal_range(const K& x) const; | ||
| 510 | |||
| 511 | friend constexpr bool operator==(const flat_multiset& x, const flat_multiset& y); | ||
| 512 | |||
| 513 | friend constexpr synth-three-way-result<value_type> | ||
| 514 | operator<=>(const flat_multiset& x, const flat_multiset& y); | ||
| 515 | |||
| 516 | friend constexpr void swap(flat_multiset& x, flat_multiset& y) | ||
| 517 | noexcept(noexcept(x.swap(y))) | ||
| 518 | { x.swap(y); } | ||
| 519 | |||
| 520 | private: | ||
| 521 | container_type c; // exposition only | ||
| 522 | key_compare compare; // exposition only | ||
| 523 | }; | ||
| 524 | |||
| 525 | template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>> | ||
| 526 | flat_multiset(KeyContainer, Compare = Compare()) | ||
| 527 | -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 528 | template<class KeyContainer, class Allocator> | ||
| 529 | flat_multiset(KeyContainer, Allocator) | ||
| 530 | -> flat_multiset<typename KeyContainer::value_type, | ||
| 531 | less<typename KeyContainer::value_type>, KeyContainer>; | ||
| 532 | template<class KeyContainer, class Compare, class Allocator> | ||
| 533 | flat_multiset(KeyContainer, Compare, Allocator) | ||
| 534 | -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 535 | |||
| 536 | template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>> | ||
| 537 | flat_multiset(sorted_equivalent_t, KeyContainer, Compare = Compare()) | ||
| 538 | -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 539 | template<class KeyContainer, class Allocator> | ||
| 540 | flat_multiset(sorted_equivalent_t, KeyContainer, Allocator) | ||
| 541 | -> flat_multiset<typename KeyContainer::value_type, | ||
| 542 | less<typename KeyContainer::value_type>, KeyContainer>; | ||
| 543 | template<class KeyContainer, class Compare, class Allocator> | ||
| 544 | flat_multiset(sorted_equivalent_t, KeyContainer, Compare, Allocator) | ||
| 545 | -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>; | ||
| 546 | |||
| 547 | template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>> | ||
| 548 | flat_multiset(InputIterator, InputIterator, Compare = Compare()) | ||
| 549 | -> flat_multiset<iter-value-type<InputIterator>, Compare>; | ||
| 550 | |||
| 551 | template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>> | ||
| 552 | flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, Compare = Compare()) | ||
| 553 | -> flat_multiset<iter-value-type<InputIterator>, Compare>; | ||
| 554 | |||
| 555 | template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>, | ||
| 556 | class Allocator = allocator<ranges::range_value_t<R>>> | ||
| 557 | flat_multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) | ||
| 558 | -> flat_multiset<ranges::range_value_t<R>, Compare, | ||
| 559 | vector<ranges::range_value_t<R>, | ||
| 560 | alloc-rebind<Allocator, ranges::range_value_t<R>>>>; | ||
| 561 | |||
| 562 | template<ranges::input_range R, class Allocator> | ||
| 563 | flat_multiset(from_range_t, R&&, Allocator) | ||
| 564 | -> flat_multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, | ||
| 565 | vector<ranges::range_value_t<R>, | ||
| 566 | alloc-rebind<Allocator, ranges::range_value_t<R>>>>; | ||
| 567 | |||
| 568 | template<class Key, class Compare = less<Key>> | ||
| 569 | flat_multiset(initializer_list<Key>, Compare = Compare()) | ||
| 570 | -> flat_multiset<Key, Compare>; | ||
| 571 | |||
| 572 | template<class Key, class Compare = less<Key>> | ||
| 573 | flat_multiset(sorted_equivalent_t, initializer_list<Key>, Compare = Compare()) | ||
| 574 | -> flat_multiset<Key, Compare>; | ||
| 41 | 575 | ||
| 42 | template<class Key, class Compare, class KeyContainer, class Allocator> | 576 | template<class Key, class Compare, class KeyContainer, class Allocator> |
| 43 | struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>; | 577 | struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator> |
| 578 | : bool_constant<uses_allocator_v<KeyContainer, Allocator>> { }; | ||
| 44 | 579 | ||
| 45 | // [flat.multiset.erasure], erasure for flat_multiset | 580 | // [flat.multiset.erasure], erasure for flat_multiset |
| 46 | template<class Key, class Compare, class KeyContainer, class Predicate> | 581 | template<class Key, class Compare, class KeyContainer, class Predicate> |
lib/libcxx/include/float.h+16-16| ... | @@ -71,29 +71,29 @@ Macros: | ... | @@ -71,29 +71,29 @@ Macros: |
| 71 | */ | 71 | */ |
| 72 | 72 | ||
| 73 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 73 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 74 | # include <__cxx03/float.h> | 74 | # include <__cxx03/__config> |
| 75 | #else | 75 | #else |
| 76 | # include <__config> | 76 | # include <__config> |
| 77 | #endif | ||
| 77 | 78 | ||
| 78 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 79 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 79 | # pragma GCC system_header | 80 | # pragma GCC system_header |
| 80 | # endif | 81 | #endif |
| 81 | 82 | ||
| 82 | # if __has_include_next(<float.h>) | 83 | #if __has_include_next(<float.h>) |
| 83 | # include_next <float.h> | 84 | # include_next <float.h> |
| 84 | # endif | 85 | #endif |
| 85 | 86 | ||
| 86 | # ifdef __cplusplus | 87 | #ifdef __cplusplus |
| 87 | 88 | ||
| 88 | # ifndef FLT_EVAL_METHOD | 89 | # ifndef FLT_EVAL_METHOD |
| 89 | # define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ | 90 | # define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ |
| 90 | # endif | 91 | # endif |
| 91 | 92 | ||
| 92 | # ifndef DECIMAL_DIG | 93 | # ifndef DECIMAL_DIG |
| 93 | # define DECIMAL_DIG __DECIMAL_DIG__ | 94 | # define DECIMAL_DIG __DECIMAL_DIG__ |
| 94 | # endif | 95 | # endif |
| 95 | 96 | ||
| 96 | # endif // __cplusplus | 97 | #endif // __cplusplus |
| 97 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 98 | 98 | ||
| 99 | #endif // _LIBCPP_FLOAT_H | 99 | #endif // _LIBCPP_FLOAT_H |
lib/libcxx/include/forward_list+33-53| ... | @@ -223,18 +223,17 @@ template <class T, class Allocator, class Predicate> | ... | @@ -223,18 +223,17 @@ template <class T, class Allocator, class Predicate> |
| 223 | # include <__ranges/concepts.h> | 223 | # include <__ranges/concepts.h> |
| 224 | # include <__ranges/container_compatible_range.h> | 224 | # include <__ranges/container_compatible_range.h> |
| 225 | # include <__ranges/from_range.h> | 225 | # include <__ranges/from_range.h> |
| 226 | # include <__type_traits/conditional.h> | ||
| 227 | # include <__type_traits/container_traits.h> | 226 | # include <__type_traits/container_traits.h> |
| 228 | # include <__type_traits/enable_if.h> | 227 | # include <__type_traits/enable_if.h> |
| 229 | # include <__type_traits/is_allocator.h> | 228 | # include <__type_traits/is_allocator.h> |
| 230 | # include <__type_traits/is_const.h> | 229 | # include <__type_traits/is_const.h> |
| 231 | # include <__type_traits/is_nothrow_assignable.h> | 230 | # include <__type_traits/is_nothrow_assignable.h> |
| 232 | # include <__type_traits/is_nothrow_constructible.h> | 231 | # include <__type_traits/is_nothrow_constructible.h> |
| 233 | # include <__type_traits/is_pointer.h> | ||
| 234 | # include <__type_traits/is_same.h> | 232 | # include <__type_traits/is_same.h> |
| 235 | # include <__type_traits/is_swappable.h> | 233 | # include <__type_traits/is_swappable.h> |
| 236 | # include <__type_traits/remove_cv.h> | 234 | # include <__type_traits/remove_cv.h> |
| 237 | # include <__type_traits/type_identity.h> | 235 | # include <__type_traits/type_identity.h> |
| 236 | # include <__utility/exception_guard.h> | ||
| 238 | # include <__utility/forward.h> | 237 | # include <__utility/forward.h> |
| 239 | # include <__utility/move.h> | 238 | # include <__utility/move.h> |
| 240 | # include <__utility/swap.h> | 239 | # include <__utility/swap.h> |
| ... | @@ -283,17 +282,6 @@ struct __forward_node_traits { | ... | @@ -283,17 +282,6 @@ struct __forward_node_traits { |
| 283 | typedef _NodePtr __node_pointer; | 282 | typedef _NodePtr __node_pointer; |
| 284 | typedef __forward_begin_node<_NodePtr> __begin_node; | 283 | typedef __forward_begin_node<_NodePtr> __begin_node; |
| 285 | typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; | 284 | typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; |
| 286 | |||
| 287 | // TODO(LLVM 22): Remove this check | ||
| 288 | # ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | ||
| 289 | static_assert(sizeof(__begin_node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__begin_node_pointer) == | ||
| 290 | _LIBCPP_ALIGNOF(__node_pointer), | ||
| 291 | "It looks like you are using std::forward_list with a fancy pointer type that thas a different " | ||
| 292 | "representation depending on whether it points to a forward_list base pointer or a forward_list node " | ||
| 293 | "pointer (both of which are implementation details of the standard library). This means that your ABI " | ||
| 294 | "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define " | ||
| 295 | "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); | ||
| 296 | # endif | ||
| 297 | }; | 285 | }; |
| 298 | 286 | ||
| 299 | template <class _NodePtr> | 287 | template <class _NodePtr> |
| ... | @@ -680,7 +668,7 @@ public: | ... | @@ -680,7 +668,7 @@ public: |
| 680 | # endif | 668 | # endif |
| 681 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); | 669 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); |
| 682 | 670 | ||
| 683 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 671 | template <__enable_if_t<__is_allocator_v<_Alloc>, int> = 0> |
| 684 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI | 672 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 685 | forward_list(size_type __n, const value_type& __v, const allocator_type& __a) | 673 | forward_list(size_type __n, const value_type& __v, const allocator_type& __a) |
| 686 | : __base(__a) { | 674 | : __base(__a) { |
| ... | @@ -744,50 +732,52 @@ public: | ... | @@ -744,50 +732,52 @@ public: |
| 744 | 732 | ||
| 745 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); | 733 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); |
| 746 | 734 | ||
| 747 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | 735 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 748 | return allocator_type(this->__alloc_); | 736 | return allocator_type(this->__alloc_); |
| 749 | } | 737 | } |
| 750 | 738 | ||
| 751 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { | 739 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { |
| 752 | return iterator(__base::__before_begin()->__next_); | 740 | return iterator(__base::__before_begin()->__next_); |
| 753 | } | 741 | } |
| 754 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { | 742 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { |
| 755 | return const_iterator(__base::__before_begin()->__next_); | 743 | return const_iterator(__base::__before_begin()->__next_); |
| 756 | } | 744 | } |
| 757 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); } | 745 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { |
| 758 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { | 746 | return iterator(nullptr); |
| 747 | } | ||
| 748 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { | ||
| 759 | return const_iterator(nullptr); | 749 | return const_iterator(nullptr); |
| 760 | } | 750 | } |
| 761 | 751 | ||
| 762 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { | 752 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { |
| 763 | return const_iterator(__base::__before_begin()->__next_); | 753 | return const_iterator(__base::__before_begin()->__next_); |
| 764 | } | 754 | } |
| 765 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { | 755 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { |
| 766 | return const_iterator(nullptr); | 756 | return const_iterator(nullptr); |
| 767 | } | 757 | } |
| 768 | 758 | ||
| 769 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { | 759 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { |
| 770 | return iterator(__base::__before_begin()); | 760 | return iterator(__base::__before_begin()); |
| 771 | } | 761 | } |
| 772 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT { | 762 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT { |
| 773 | return const_iterator(__base::__before_begin()); | 763 | return const_iterator(__base::__before_begin()); |
| 774 | } | 764 | } |
| 775 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT { | 765 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT { |
| 776 | return const_iterator(__base::__before_begin()); | 766 | return const_iterator(__base::__before_begin()); |
| 777 | } | 767 | } |
| 778 | 768 | ||
| 779 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | 769 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { |
| 780 | return __base::__before_begin()->__next_ == nullptr; | 770 | return __base::__before_begin()->__next_ == nullptr; |
| 781 | } | 771 | } |
| 782 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 772 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 783 | return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); | 773 | return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); |
| 784 | } | 774 | } |
| 785 | 775 | ||
| 786 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() { | 776 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() { |
| 787 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); | 777 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); |
| 788 | return __base::__before_begin()->__next_->__get_value(); | 778 | return __base::__before_begin()->__next_->__get_value(); |
| 789 | } | 779 | } |
| 790 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const { | 780 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const { |
| 791 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); | 781 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); |
| 792 | return __base::__before_begin()->__next_->__get_value(); | 782 | return __base::__before_begin()->__next_->__get_value(); |
| 793 | } | 783 | } |
| ... | @@ -918,22 +908,22 @@ private: | ... | @@ -918,22 +908,22 @@ private: |
| 918 | 908 | ||
| 919 | # if _LIBCPP_STD_VER >= 17 | 909 | # if _LIBCPP_STD_VER >= 17 |
| 920 | template <class _InputIterator, | 910 | template <class _InputIterator, |
| 921 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, | 911 | class _Alloc = allocator<__iterator_value_type<_InputIterator>>, |
| 922 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 912 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 923 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 913 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 924 | forward_list(_InputIterator, _InputIterator) -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; | 914 | forward_list(_InputIterator, _InputIterator) -> forward_list<__iterator_value_type<_InputIterator>, _Alloc>; |
| 925 | 915 | ||
| 926 | template <class _InputIterator, | 916 | template <class _InputIterator, |
| 927 | class _Alloc, | 917 | class _Alloc, |
| 928 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 918 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 929 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 919 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 930 | forward_list(_InputIterator, _InputIterator, _Alloc) -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; | 920 | forward_list(_InputIterator, _InputIterator, _Alloc) -> forward_list<__iterator_value_type<_InputIterator>, _Alloc>; |
| 931 | # endif | 921 | # endif |
| 932 | 922 | ||
| 933 | # if _LIBCPP_STD_VER >= 23 | 923 | # if _LIBCPP_STD_VER >= 23 |
| 934 | template <ranges::input_range _Range, | 924 | template <ranges::input_range _Range, |
| 935 | class _Alloc = allocator<ranges::range_value_t<_Range>>, | 925 | class _Alloc = allocator<ranges::range_value_t<_Range>>, |
| 936 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 926 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 937 | forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges::range_value_t<_Range>, _Alloc>; | 927 | forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges::range_value_t<_Range>, _Alloc>; |
| 938 | # endif | 928 | # endif |
| 939 | 929 | ||
| ... | @@ -1180,22 +1170,17 @@ forward_list<_Tp, _Alloc>::__insert_after(const_iterator __p, size_type __n, _Ar | ... | @@ -1180,22 +1170,17 @@ forward_list<_Tp, _Alloc>::__insert_after(const_iterator __p, size_type __n, _Ar |
| 1180 | if (__n > 0) { | 1170 | if (__n > 0) { |
| 1181 | __node_pointer __first = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...); | 1171 | __node_pointer __first = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1182 | __node_pointer __last = __first; | 1172 | __node_pointer __last = __first; |
| 1183 | # if _LIBCPP_HAS_EXCEPTIONS | 1173 | auto __guard = std::__make_exception_guard([&] { |
| 1184 | try { | ||
| 1185 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1186 | for (--__n; __n != 0; --__n, __last = __last->__next_) { | ||
| 1187 | __last->__next_ = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...); | ||
| 1188 | } | ||
| 1189 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1190 | } catch (...) { | ||
| 1191 | while (__first != nullptr) { | 1174 | while (__first != nullptr) { |
| 1192 | __node_pointer __next = __first->__next_; | 1175 | __node_pointer __next = __first->__next_; |
| 1193 | this->__delete_node(__first); | 1176 | this->__delete_node(__first); |
| 1194 | __first = __next; | 1177 | __first = __next; |
| 1195 | } | 1178 | } |
| 1196 | throw; | 1179 | }); |
| 1180 | for (--__n; __n != 0; --__n, __last = __last->__next_) { | ||
| 1181 | __last->__next_ = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...); | ||
| 1197 | } | 1182 | } |
| 1198 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1183 | __guard.__complete(); |
| 1199 | __last->__next_ = __r->__next_; | 1184 | __last->__next_ = __r->__next_; |
| 1200 | __r->__next_ = __first; | 1185 | __r->__next_ = __first; |
| 1201 | __r = std::__static_fancy_pointer_cast<__begin_node_pointer>(__last); | 1186 | __r = std::__static_fancy_pointer_cast<__begin_node_pointer>(__last); |
| ... | @@ -1220,22 +1205,17 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp | ... | @@ -1220,22 +1205,17 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp |
| 1220 | __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f); | 1205 | __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f); |
| 1221 | __node_pointer __last = __first; | 1206 | __node_pointer __last = __first; |
| 1222 | 1207 | ||
| 1223 | # if _LIBCPP_HAS_EXCEPTIONS | 1208 | auto __guard = std::__make_exception_guard([&] { |
| 1224 | try { | ||
| 1225 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1226 | for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) { | ||
| 1227 | __last->__next_ = this->__create_node(/* next = */ nullptr, *__f); | ||
| 1228 | } | ||
| 1229 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1230 | } catch (...) { | ||
| 1231 | while (__first != nullptr) { | 1209 | while (__first != nullptr) { |
| 1232 | __node_pointer __next = __first->__next_; | 1210 | __node_pointer __next = __first->__next_; |
| 1233 | this->__delete_node(__first); | 1211 | this->__delete_node(__first); |
| 1234 | __first = __next; | 1212 | __first = __next; |
| 1235 | } | 1213 | } |
| 1236 | throw; | 1214 | }); |
| 1215 | for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) { | ||
| 1216 | __last->__next_ = this->__create_node(/* next = */ nullptr, *__f); | ||
| 1237 | } | 1217 | } |
| 1238 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1218 | __guard.__complete(); |
| 1239 | 1219 | ||
| 1240 | __last->__next_ = __r->__next_; | 1220 | __last->__next_ = __r->__next_; |
| 1241 | __r->__next_ = __first; | 1221 | __r->__next_ = __first; |
lib/libcxx/include/fstream+57-42| ... | @@ -221,7 +221,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -221,7 +221,7 @@ _LIBCPP_PUSH_MACROS |
| 221 | 221 | ||
| 222 | _LIBCPP_BEGIN_NAMESPACE_STD | 222 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 223 | 223 | ||
| 224 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) | 224 | # if _LIBCPP_STD_VER >= 23 && defined(_LIBCPP_WIN32API) |
| 225 | _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept; | 225 | _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept; |
| 226 | # endif | 226 | # endif |
| 227 | 227 | ||
| ... | @@ -254,7 +254,7 @@ public: | ... | @@ -254,7 +254,7 @@ public: |
| 254 | void swap(basic_filebuf& __rhs); | 254 | void swap(basic_filebuf& __rhs); |
| 255 | 255 | ||
| 256 | // 27.9.1.4 Members: | 256 | // 27.9.1.4 Members: |
| 257 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; | 257 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 258 | basic_filebuf* open(const char* __s, ios_base::openmode __mode); | 258 | basic_filebuf* open(const char* __s, ios_base::openmode __mode); |
| 259 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | 259 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 260 | basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode); | 260 | basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode); |
| ... | @@ -262,15 +262,14 @@ public: | ... | @@ -262,15 +262,14 @@ public: |
| 262 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const string& __s, ios_base::openmode __mode); | 262 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const string& __s, ios_base::openmode __mode); |
| 263 | 263 | ||
| 264 | # if _LIBCPP_STD_VER >= 17 | 264 | # if _LIBCPP_STD_VER >= 17 |
| 265 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI basic_filebuf* | 265 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const filesystem::path& __p, ios_base::openmode __mode) { |
| 266 | open(const filesystem::path& __p, ios_base::openmode __mode) { | ||
| 267 | return open(__p.c_str(), __mode); | 266 | return open(__p.c_str(), __mode); |
| 268 | } | 267 | } |
| 269 | # endif | 268 | # endif |
| 270 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode __mode); | 269 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode __mode); |
| 271 | basic_filebuf* close(); | 270 | basic_filebuf* close(); |
| 272 | # if _LIBCPP_STD_VER >= 26 | 271 | # if _LIBCPP_STD_VER >= 26 |
| 273 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { | 272 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { |
| 274 | _LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened"); | 273 | _LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened"); |
| 275 | # if defined(_LIBCPP_WIN32API) | 274 | # if defined(_LIBCPP_WIN32API) |
| 276 | return std::__filebuf_windows_native_handle(__file_); | 275 | return std::__filebuf_windows_native_handle(__file_); |
| ... | @@ -299,6 +298,16 @@ protected: | ... | @@ -299,6 +298,16 @@ protected: |
| 299 | int sync() override; | 298 | int sync() override; |
| 300 | void imbue(const locale& __loc) override; | 299 | void imbue(const locale& __loc) override; |
| 301 | 300 | ||
| 301 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL streamsize xsputn(const char_type* __str, streamsize __len) override { | ||
| 302 | if (__always_noconv_ && __len >= (this->epptr() - this->pbase())) { | ||
| 303 | if (traits_type::eq_int_type(overflow(), traits_type::eof())) | ||
| 304 | return 0; | ||
| 305 | |||
| 306 | return std::fwrite(__str, sizeof(char_type), __len, __file_); | ||
| 307 | } | ||
| 308 | return basic_streambuf<_CharT, _Traits>::xsputn(__str, __len); | ||
| 309 | } | ||
| 310 | |||
| 302 | private: | 311 | private: |
| 303 | char* __extbuf_; | 312 | char* __extbuf_; |
| 304 | const char* __extbufnext_; | 313 | const char* __extbufnext_; |
| ... | @@ -401,6 +410,14 @@ private: | ... | @@ -401,6 +410,14 @@ private: |
| 401 | } | 410 | } |
| 402 | } | 411 | } |
| 403 | } | 412 | } |
| 413 | |||
| 414 | _LIBCPP_HIDE_FROM_ABI typename traits_type::int_type __overflow_failed() { | ||
| 415 | if (this->pptr() == this->epptr() + 1) { | ||
| 416 | this->pbump(-1); // lose the character we overflowed above -- we don't really have a | ||
| 417 | // choice since we couldn't commit the contents of the put area | ||
| 418 | } | ||
| 419 | return traits_type::eof(); | ||
| 420 | } | ||
| 404 | }; | 421 | }; |
| 405 | 422 | ||
| 406 | template <class _CharT, class _Traits> | 423 | template <class _CharT, class _Traits> |
| ... | @@ -742,7 +759,12 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::close() { | ... | @@ -742,7 +759,12 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::close() { |
| 742 | if (fclose(__h.release())) | 759 | if (fclose(__h.release())) |
| 743 | __rt = nullptr; | 760 | __rt = nullptr; |
| 744 | __file_ = nullptr; | 761 | __file_ = nullptr; |
| 745 | setbuf(0, 0); | 762 | // Reset the get and the put areas without getting rid of the underlying buffers, |
| 763 | // which might have been configured by the user. Make sure to keep the buffers | ||
| 764 | // since the user may re-open the stream. | ||
| 765 | this->setg(nullptr, nullptr, nullptr); | ||
| 766 | this->setp(nullptr, nullptr); | ||
| 767 | __cm_ = __no_io_operations; | ||
| 746 | } | 768 | } |
| 747 | return __rt; | 769 | return __rt; |
| 748 | } | 770 | } |
| ... | @@ -821,14 +843,6 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -821,14 +843,6 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 821 | 843 | ||
| 822 | template <class _CharT, class _Traits> | 844 | template <class _CharT, class _Traits> |
| 823 | typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::overflow(int_type __c) { | 845 | typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::overflow(int_type __c) { |
| 824 | auto __failed = [this]() { | ||
| 825 | if (this->pptr() == this->epptr() + 1) { | ||
| 826 | this->pbump(-1); // lose the character we overflowed above -- we don't really have a | ||
| 827 | // choice since we couldn't commit the contents of the put area | ||
| 828 | } | ||
| 829 | return traits_type::eof(); | ||
| 830 | }; | ||
| 831 | |||
| 832 | if (__file_ == nullptr) | 846 | if (__file_ == nullptr) |
| 833 | return traits_type::eof(); | 847 | return traits_type::eof(); |
| 834 | __write_mode(); | 848 | __write_mode(); |
| ... | @@ -850,7 +864,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -850,7 +864,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 850 | if (__always_noconv_) { | 864 | if (__always_noconv_) { |
| 851 | size_t __n = static_cast<size_t>(this->pptr() - this->pbase()); | 865 | size_t __n = static_cast<size_t>(this->pptr() - this->pbase()); |
| 852 | if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) { | 866 | if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) { |
| 853 | return __failed(); | 867 | return __overflow_failed(); |
| 854 | } | 868 | } |
| 855 | } else { | 869 | } else { |
| 856 | if (!__cv_) | 870 | if (!__cv_) |
| ... | @@ -864,14 +878,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -864,14 +878,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 864 | do { | 878 | do { |
| 865 | codecvt_base::result __r = __cv_->out(__st_, __b, __p, __end, __extbuf_, __extbuf_ + __ebs_, __extbuf_end); | 879 | codecvt_base::result __r = __cv_->out(__st_, __b, __p, __end, __extbuf_, __extbuf_ + __ebs_, __extbuf_end); |
| 866 | if (__end == __b) { | 880 | if (__end == __b) { |
| 867 | return __failed(); | 881 | return __overflow_failed(); |
| 868 | } | 882 | } |
| 869 | 883 | ||
| 870 | // No conversion needed: output characters directly to the file, done. | 884 | // No conversion needed: output characters directly to the file, done. |
| 871 | if (__r == codecvt_base::noconv) { | 885 | if (__r == codecvt_base::noconv) { |
| 872 | size_t __n = static_cast<size_t>(__p - __b); | 886 | size_t __n = static_cast<size_t>(__p - __b); |
| 873 | if (std::fwrite(__b, 1, __n, __file_) != __n) { | 887 | if (std::fwrite(__b, 1, __n, __file_) != __n) { |
| 874 | return __failed(); | 888 | return __overflow_failed(); |
| 875 | } | 889 | } |
| 876 | break; | 890 | break; |
| 877 | 891 | ||
| ... | @@ -879,7 +893,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -879,7 +893,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 879 | } else if (__r == codecvt_base::ok) { | 893 | } else if (__r == codecvt_base::ok) { |
| 880 | size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_); | 894 | size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_); |
| 881 | if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { | 895 | if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { |
| 882 | return __failed(); | 896 | return __overflow_failed(); |
| 883 | } | 897 | } |
| 884 | break; | 898 | break; |
| 885 | 899 | ||
| ... | @@ -888,13 +902,13 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -888,13 +902,13 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 888 | } else if (__r == codecvt_base::partial) { | 902 | } else if (__r == codecvt_base::partial) { |
| 889 | size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_); | 903 | size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_); |
| 890 | if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { | 904 | if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) { |
| 891 | return __failed(); | 905 | return __overflow_failed(); |
| 892 | } | 906 | } |
| 893 | __b = const_cast<char_type*>(__end); | 907 | __b = const_cast<char_type*>(__end); |
| 894 | continue; | 908 | continue; |
| 895 | 909 | ||
| 896 | } else { | 910 | } else { |
| 897 | return __failed(); | 911 | return __overflow_failed(); |
| 898 | } | 912 | } |
| 899 | } while (true); | 913 | } while (true); |
| 900 | } | 914 | } |
| ... | @@ -977,7 +991,7 @@ template <class _CharT, class _Traits> | ... | @@ -977,7 +991,7 @@ template <class _CharT, class _Traits> |
| 977 | int basic_filebuf<_CharT, _Traits>::__fseek(FILE* __file, pos_type __offset, int __whence) { | 991 | int basic_filebuf<_CharT, _Traits>::__fseek(FILE* __file, pos_type __offset, int __whence) { |
| 978 | # if defined(_LIBCPP_MSVCRT_LIKE) | 992 | # if defined(_LIBCPP_MSVCRT_LIKE) |
| 979 | return _fseeki64(__file, __offset, __whence); | 993 | return _fseeki64(__file, __offset, __whence); |
| 980 | # elif defined(_NEWLIB_VERSION) | 994 | # elif _LIBCPP_LIBC_NEWLIB |
| 981 | return fseek(__file, __offset, __whence); | 995 | return fseek(__file, __offset, __whence); |
| 982 | # else | 996 | # else |
| 983 | return ::fseeko(__file, __offset, __whence); | 997 | return ::fseeko(__file, __offset, __whence); |
| ... | @@ -988,7 +1002,7 @@ template <class _CharT, class _Traits> | ... | @@ -988,7 +1002,7 @@ template <class _CharT, class _Traits> |
| 988 | typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::__ftell(FILE* __file) { | 1002 | typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::__ftell(FILE* __file) { |
| 989 | # if defined(_LIBCPP_MSVCRT_LIKE) | 1003 | # if defined(_LIBCPP_MSVCRT_LIKE) |
| 990 | return _ftelli64(__file); | 1004 | return _ftelli64(__file); |
| 991 | # elif defined(_NEWLIB_VERSION) | 1005 | # elif _LIBCPP_LIBC_NEWLIB |
| 992 | return ftell(__file); | 1006 | return ftell(__file); |
| 993 | # else | 1007 | # else |
| 994 | return ftello(__file); | 1008 | return ftello(__file); |
| ... | @@ -1147,27 +1161,27 @@ public: | ... | @@ -1147,27 +1161,27 @@ public: |
| 1147 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); | 1161 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); |
| 1148 | # if _LIBCPP_STD_VER >= 17 | 1162 | # if _LIBCPP_STD_VER >= 17 |
| 1149 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> | 1163 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1150 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY | 1164 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in) |
| 1151 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in) | ||
| 1152 | : basic_ifstream(__p.c_str(), __mode) {} | 1165 | : basic_ifstream(__p.c_str(), __mode) {} |
| 1153 | # endif // _LIBCPP_STD_VER >= 17 | 1166 | # endif // _LIBCPP_STD_VER >= 17 |
| 1154 | _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs); | 1167 | _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs); |
| 1155 | _LIBCPP_HIDE_FROM_ABI basic_ifstream& operator=(basic_ifstream&& __rhs); | 1168 | _LIBCPP_HIDE_FROM_ABI basic_ifstream& operator=(basic_ifstream&& __rhs); |
| 1156 | _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream& __rhs); | 1169 | _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream& __rhs); |
| 1157 | 1170 | ||
| 1158 | _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; | 1171 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1159 | # if _LIBCPP_STD_VER >= 26 | 1172 | # if _LIBCPP_STD_VER >= 26 |
| 1160 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } | 1173 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { |
| 1174 | return rdbuf()->native_handle(); | ||
| 1175 | } | ||
| 1161 | # endif | 1176 | # endif |
| 1162 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; | 1177 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 1163 | void open(const char* __s, ios_base::openmode __mode = ios_base::in); | 1178 | void open(const char* __s, ios_base::openmode __mode = ios_base::in); |
| 1164 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | 1179 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 1165 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); | 1180 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); |
| 1166 | # endif | 1181 | # endif |
| 1167 | void open(const string& __s, ios_base::openmode __mode = ios_base::in); | 1182 | void open(const string& __s, ios_base::openmode __mode = ios_base::in); |
| 1168 | # if _LIBCPP_STD_VER >= 17 | 1183 | # if _LIBCPP_STD_VER >= 17 |
| 1169 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void | 1184 | _LIBCPP_HIDE_FROM_ABI void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) { |
| 1170 | open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) { | ||
| 1171 | return open(__p.c_str(), __mode); | 1185 | return open(__p.c_str(), __mode); |
| 1172 | } | 1186 | } |
| 1173 | # endif // _LIBCPP_STD_VER >= 17 | 1187 | # endif // _LIBCPP_STD_VER >= 17 |
| ... | @@ -1304,8 +1318,7 @@ public: | ... | @@ -1304,8 +1318,7 @@ public: |
| 1304 | 1318 | ||
| 1305 | # if _LIBCPP_STD_VER >= 17 | 1319 | # if _LIBCPP_STD_VER >= 17 |
| 1306 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> | 1320 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1307 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY | 1321 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out) |
| 1308 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out) | ||
| 1309 | : basic_ofstream(__p.c_str(), __mode) {} | 1322 | : basic_ofstream(__p.c_str(), __mode) {} |
| 1310 | # endif // _LIBCPP_STD_VER >= 17 | 1323 | # endif // _LIBCPP_STD_VER >= 17 |
| 1311 | 1324 | ||
| ... | @@ -1313,11 +1326,13 @@ public: | ... | @@ -1313,11 +1326,13 @@ public: |
| 1313 | _LIBCPP_HIDE_FROM_ABI basic_ofstream& operator=(basic_ofstream&& __rhs); | 1326 | _LIBCPP_HIDE_FROM_ABI basic_ofstream& operator=(basic_ofstream&& __rhs); |
| 1314 | _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream& __rhs); | 1327 | _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream& __rhs); |
| 1315 | 1328 | ||
| 1316 | _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; | 1329 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1317 | # if _LIBCPP_STD_VER >= 26 | 1330 | # if _LIBCPP_STD_VER >= 26 |
| 1318 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } | 1331 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { |
| 1332 | return rdbuf()->native_handle(); | ||
| 1333 | } | ||
| 1319 | # endif | 1334 | # endif |
| 1320 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; | 1335 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 1321 | void open(const char* __s, ios_base::openmode __mode = ios_base::out); | 1336 | void open(const char* __s, ios_base::openmode __mode = ios_base::out); |
| 1322 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | 1337 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 1323 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); | 1338 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); |
| ... | @@ -1325,8 +1340,7 @@ public: | ... | @@ -1325,8 +1340,7 @@ public: |
| 1325 | void open(const string& __s, ios_base::openmode __mode = ios_base::out); | 1340 | void open(const string& __s, ios_base::openmode __mode = ios_base::out); |
| 1326 | 1341 | ||
| 1327 | # if _LIBCPP_STD_VER >= 17 | 1342 | # if _LIBCPP_STD_VER >= 17 |
| 1328 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void | 1343 | _LIBCPP_HIDE_FROM_ABI void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) { |
| 1329 | open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) { | ||
| 1330 | return open(__p.c_str(), __mode); | 1344 | return open(__p.c_str(), __mode); |
| 1331 | } | 1345 | } |
| 1332 | # endif // _LIBCPP_STD_VER >= 17 | 1346 | # endif // _LIBCPP_STD_VER >= 17 |
| ... | @@ -1466,8 +1480,7 @@ public: | ... | @@ -1466,8 +1480,7 @@ public: |
| 1466 | 1480 | ||
| 1467 | # if _LIBCPP_STD_VER >= 17 | 1481 | # if _LIBCPP_STD_VER >= 17 |
| 1468 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> | 1482 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1469 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream( | 1483 | _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) |
| 1470 | const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) | ||
| 1471 | : basic_fstream(__p.c_str(), __mode) {} | 1484 | : basic_fstream(__p.c_str(), __mode) {} |
| 1472 | # endif // _LIBCPP_STD_VER >= 17 | 1485 | # endif // _LIBCPP_STD_VER >= 17 |
| 1473 | 1486 | ||
| ... | @@ -1477,11 +1490,13 @@ public: | ... | @@ -1477,11 +1490,13 @@ public: |
| 1477 | 1490 | ||
| 1478 | _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream& __rhs); | 1491 | _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream& __rhs); |
| 1479 | 1492 | ||
| 1480 | _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; | 1493 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1481 | # if _LIBCPP_STD_VER >= 26 | 1494 | # if _LIBCPP_STD_VER >= 26 |
| 1482 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } | 1495 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { |
| 1496 | return rdbuf()->native_handle(); | ||
| 1497 | } | ||
| 1483 | # endif | 1498 | # endif |
| 1484 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; | 1499 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 1485 | _LIBCPP_HIDE_FROM_ABI void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); | 1500 | _LIBCPP_HIDE_FROM_ABI void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1486 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | 1501 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 1487 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); | 1502 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| ... | @@ -1489,7 +1504,7 @@ public: | ... | @@ -1489,7 +1504,7 @@ public: |
| 1489 | _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); | 1504 | _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1490 | 1505 | ||
| 1491 | # if _LIBCPP_STD_VER >= 17 | 1506 | # if _LIBCPP_STD_VER >= 17 |
| 1492 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void | 1507 | _LIBCPP_HIDE_FROM_ABI void |
| 1493 | open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) { | 1508 | open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) { |
| 1494 | return open(__p.c_str(), __mode); | 1509 | return open(__p.c_str(), __mode); |
| 1495 | } | 1510 | } |
lib/libcxx/include/future+41-51| ... | @@ -397,12 +397,14 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; | ... | @@ -397,12 +397,14 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; |
| 397 | # include <__type_traits/decay.h> | 397 | # include <__type_traits/decay.h> |
| 398 | # include <__type_traits/enable_if.h> | 398 | # include <__type_traits/enable_if.h> |
| 399 | # include <__type_traits/invoke.h> | 399 | # include <__type_traits/invoke.h> |
| 400 | # include <__type_traits/is_constructible.h> | ||
| 400 | # include <__type_traits/is_same.h> | 401 | # include <__type_traits/is_same.h> |
| 401 | # include <__type_traits/remove_cvref.h> | 402 | # include <__type_traits/remove_cvref.h> |
| 402 | # include <__type_traits/remove_reference.h> | 403 | # include <__type_traits/remove_reference.h> |
| 403 | # include <__type_traits/strip_signature.h> | 404 | # include <__type_traits/strip_signature.h> |
| 404 | # include <__type_traits/underlying_type.h> | 405 | # include <__type_traits/underlying_type.h> |
| 405 | # include <__utility/auto_cast.h> | 406 | # include <__utility/auto_cast.h> |
| 407 | # include <__utility/exception_guard.h> | ||
| 406 | # include <__utility/forward.h> | 408 | # include <__utility/forward.h> |
| 407 | # include <__utility/move.h> | 409 | # include <__utility/move.h> |
| 408 | # include <__utility/swap.h> | 410 | # include <__utility/swap.h> |
| ... | @@ -477,13 +479,13 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) { | ... | @@ -477,13 +479,13 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) { |
| 477 | _LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred}; | 479 | _LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred}; |
| 478 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_status) | 480 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_status) |
| 479 | 481 | ||
| 480 | _LIBCPP_EXPORTED_FROM_ABI const error_category& future_category() _NOEXCEPT; | 482 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& future_category() _NOEXCEPT; |
| 481 | 483 | ||
| 482 | inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(future_errc __e) _NOEXCEPT { | 484 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(future_errc __e) _NOEXCEPT { |
| 483 | return error_code(static_cast<int>(__e), future_category()); | 485 | return error_code(static_cast<int>(__e), future_category()); |
| 484 | } | 486 | } |
| 485 | 487 | ||
| 486 | inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(future_errc __e) _NOEXCEPT { | 488 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(future_errc __e) _NOEXCEPT { |
| 487 | return error_condition(static_cast<int>(__e), future_category()); | 489 | return error_condition(static_cast<int>(__e), future_category()); |
| 488 | } | 490 | } |
| 489 | 491 | ||
| ... | @@ -502,7 +504,7 @@ public: | ... | @@ -502,7 +504,7 @@ public: |
| 502 | _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} | 504 | _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} |
| 503 | # endif | 505 | # endif |
| 504 | 506 | ||
| 505 | _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } | 507 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } |
| 506 | 508 | ||
| 507 | _LIBCPP_HIDE_FROM_ABI future_error(const future_error&) _NOEXCEPT = default; | 509 | _LIBCPP_HIDE_FROM_ABI future_error(const future_error&) _NOEXCEPT = default; |
| 508 | ~future_error() _NOEXCEPT override; | 510 | ~future_error() _NOEXCEPT override; |
| ... | @@ -583,12 +585,9 @@ inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _P | ... | @@ -583,12 +585,9 @@ inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _P |
| 583 | template <class _Rp> | 585 | template <class _Rp> |
| 584 | class _LIBCPP_HIDDEN __assoc_state : public __assoc_sub_state { | 586 | class _LIBCPP_HIDDEN __assoc_state : public __assoc_sub_state { |
| 585 | typedef __assoc_sub_state base; | 587 | typedef __assoc_sub_state base; |
| 586 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 587 | typedef typename aligned_storage<sizeof(_Rp), _LIBCPP_ALIGNOF(_Rp)>::type _Up; | ||
| 588 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 589 | 588 | ||
| 590 | protected: | 589 | protected: |
| 591 | _Up __value_; | 590 | _ALIGNAS_TYPE(_Rp) char __value_[sizeof(_Rp)]; |
| 592 | 591 | ||
| 593 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override; | 592 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override; |
| 594 | 593 | ||
| ... | @@ -943,15 +942,15 @@ public: | ... | @@ -943,15 +942,15 @@ public: |
| 943 | } | 942 | } |
| 944 | 943 | ||
| 945 | _LIBCPP_HIDE_FROM_ABI ~future(); | 944 | _LIBCPP_HIDE_FROM_ABI ~future(); |
| 946 | _LIBCPP_HIDE_FROM_ABI shared_future<_Rp> share() _NOEXCEPT; | 945 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_future<_Rp> share() _NOEXCEPT; |
| 947 | 946 | ||
| 948 | // retrieving the value | 947 | // retrieving the value |
| 949 | _LIBCPP_HIDE_FROM_ABI _Rp get(); | 948 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Rp get(); |
| 950 | 949 | ||
| 951 | _LIBCPP_HIDE_FROM_ABI void swap(future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 950 | _LIBCPP_HIDE_FROM_ABI void swap(future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 952 | 951 | ||
| 953 | // functions to check state | 952 | // functions to check state |
| 954 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } | 953 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } |
| 955 | 954 | ||
| 956 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } | 955 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } |
| 957 | template <class _Rep, class _Period> | 956 | template <class _Rep, class _Period> |
| ... | @@ -1014,15 +1013,15 @@ public: | ... | @@ -1014,15 +1013,15 @@ public: |
| 1014 | } | 1013 | } |
| 1015 | 1014 | ||
| 1016 | _LIBCPP_HIDE_FROM_ABI ~future(); | 1015 | _LIBCPP_HIDE_FROM_ABI ~future(); |
| 1017 | _LIBCPP_HIDE_FROM_ABI shared_future<_Rp&> share() _NOEXCEPT; | 1016 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_future<_Rp&> share() _NOEXCEPT; |
| 1018 | 1017 | ||
| 1019 | // retrieving the value | 1018 | // retrieving the value |
| 1020 | _LIBCPP_HIDE_FROM_ABI _Rp& get(); | 1019 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Rp& get(); |
| 1021 | 1020 | ||
| 1022 | _LIBCPP_HIDE_FROM_ABI void swap(future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 1021 | _LIBCPP_HIDE_FROM_ABI void swap(future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 1023 | 1022 | ||
| 1024 | // functions to check state | 1023 | // functions to check state |
| 1025 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } | 1024 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } |
| 1026 | 1025 | ||
| 1027 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } | 1026 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } |
| 1028 | template <class _Rep, class _Period> | 1027 | template <class _Rep, class _Period> |
| ... | @@ -1089,7 +1088,7 @@ public: | ... | @@ -1089,7 +1088,7 @@ public: |
| 1089 | _LIBCPP_HIDE_FROM_ABI void swap(future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 1088 | _LIBCPP_HIDE_FROM_ABI void swap(future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 1090 | 1089 | ||
| 1091 | // functions to check state | 1090 | // functions to check state |
| 1092 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } | 1091 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } |
| 1093 | 1092 | ||
| 1094 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } | 1093 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } |
| 1095 | template <class _Rep, class _Period> | 1094 | template <class _Rep, class _Period> |
| ... | @@ -1139,7 +1138,7 @@ public: | ... | @@ -1139,7 +1138,7 @@ public: |
| 1139 | _LIBCPP_HIDE_FROM_ABI void swap(promise& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 1138 | _LIBCPP_HIDE_FROM_ABI void swap(promise& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 1140 | 1139 | ||
| 1141 | // retrieving the result | 1140 | // retrieving the result |
| 1142 | _LIBCPP_HIDE_FROM_ABI future<_Rp> get_future(); | 1141 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<_Rp> get_future(); |
| 1143 | 1142 | ||
| 1144 | // setting the result | 1143 | // setting the result |
| 1145 | _LIBCPP_HIDE_FROM_ABI void set_value(const _Rp& __r); | 1144 | _LIBCPP_HIDE_FROM_ABI void set_value(const _Rp& __r); |
| ... | @@ -1256,7 +1255,7 @@ public: | ... | @@ -1256,7 +1255,7 @@ public: |
| 1256 | _LIBCPP_HIDE_FROM_ABI void swap(promise& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 1255 | _LIBCPP_HIDE_FROM_ABI void swap(promise& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 1257 | 1256 | ||
| 1258 | // retrieving the result | 1257 | // retrieving the result |
| 1259 | _LIBCPP_HIDE_FROM_ABI future<_Rp&> get_future(); | 1258 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<_Rp&> get_future(); |
| 1260 | 1259 | ||
| 1261 | // setting the result | 1260 | // setting the result |
| 1262 | _LIBCPP_HIDE_FROM_ABI void set_value(_Rp& __r); | 1261 | _LIBCPP_HIDE_FROM_ABI void set_value(_Rp& __r); |
| ... | @@ -1366,7 +1365,7 @@ public: | ... | @@ -1366,7 +1365,7 @@ public: |
| 1366 | _LIBCPP_HIDE_FROM_ABI void swap(promise& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 1365 | _LIBCPP_HIDE_FROM_ABI void swap(promise& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 1367 | 1366 | ||
| 1368 | // retrieving the result | 1367 | // retrieving the result |
| 1369 | future<void> get_future(); | 1368 | [[__nodiscard__]] future<void> get_future(); |
| 1370 | 1369 | ||
| 1371 | // setting the result | 1370 | // setting the result |
| 1372 | void set_value(); | 1371 | void set_value(); |
| ... | @@ -1639,10 +1638,10 @@ public: | ... | @@ -1639,10 +1638,10 @@ public: |
| 1639 | __p_.swap(__other.__p_); | 1638 | __p_.swap(__other.__p_); |
| 1640 | } | 1639 | } |
| 1641 | 1640 | ||
| 1642 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } | 1641 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } |
| 1643 | 1642 | ||
| 1644 | // result retrieval | 1643 | // result retrieval |
| 1645 | _LIBCPP_HIDE_FROM_ABI future<_Rp> get_future() { return __p_.get_future(); } | 1644 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<_Rp> get_future() { return __p_.get_future(); } |
| 1646 | 1645 | ||
| 1647 | // execution | 1646 | // execution |
| 1648 | _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); | 1647 | _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); |
| ... | @@ -1728,10 +1727,10 @@ public: | ... | @@ -1728,10 +1727,10 @@ public: |
| 1728 | __p_.swap(__other.__p_); | 1727 | __p_.swap(__other.__p_); |
| 1729 | } | 1728 | } |
| 1730 | 1729 | ||
| 1731 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } | 1730 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } |
| 1732 | 1731 | ||
| 1733 | // result retrieval | 1732 | // result retrieval |
| 1734 | _LIBCPP_HIDE_FROM_ABI future<void> get_future() { return __p_.get_future(); } | 1733 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<void> get_future() { return __p_.get_future(); } |
| 1735 | 1734 | ||
| 1736 | // execution | 1735 | // execution |
| 1737 | _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); | 1736 | _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); |
| ... | @@ -1815,16 +1814,9 @@ template <class _Rp, class _Fp> | ... | @@ -1815,16 +1814,9 @@ template <class _Rp, class _Fp> |
| 1815 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { | 1814 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { |
| 1816 | unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h( | 1815 | unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h( |
| 1817 | new __async_assoc_state<_Rp, _Fp>(std::forward<_Fp>(__f))); | 1816 | new __async_assoc_state<_Rp, _Fp>(std::forward<_Fp>(__f))); |
| 1818 | # if _LIBCPP_HAS_EXCEPTIONS | 1817 | auto __guard = std::__make_exception_guard([&] { __h->__make_ready(); }); |
| 1819 | try { | 1818 | std::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach(); |
| 1820 | # endif | 1819 | __guard.__complete(); |
| 1821 | std::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach(); | ||
| 1822 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1823 | } catch (...) { | ||
| 1824 | __h->__make_ready(); | ||
| 1825 | throw; | ||
| 1826 | } | ||
| 1827 | # endif | ||
| 1828 | return future<_Rp>(__h.get()); | 1820 | return future<_Rp>(__h.get()); |
| 1829 | } | 1821 | } |
| 1830 | 1822 | ||
| ... | @@ -1837,20 +1829,16 @@ class _LIBCPP_HIDDEN __async_func { | ... | @@ -1837,20 +1829,16 @@ class _LIBCPP_HIDDEN __async_func { |
| 1837 | public: | 1829 | public: |
| 1838 | using _Rp _LIBCPP_NODEBUG = __invoke_result_t<_Fp, _Args...>; | 1830 | using _Rp _LIBCPP_NODEBUG = __invoke_result_t<_Fp, _Args...>; |
| 1839 | 1831 | ||
| 1840 | _LIBCPP_HIDE_FROM_ABI explicit __async_func(_Fp&& __f, _Args&&... __args) | 1832 | template <class _Gp, class... _BArgs> |
| 1841 | : __f_(std::move(__f), std::move(__args)...) {} | 1833 | _LIBCPP_HIDE_FROM_ABI explicit __async_func(_Gp&& __g, _BArgs&&... __bargs) |
| 1834 | : __f_(std::forward<_Gp>(__g), std::forward<_BArgs>(__bargs)...) {} | ||
| 1842 | 1835 | ||
| 1843 | _LIBCPP_HIDE_FROM_ABI __async_func(__async_func&& __f) : __f_(std::move(__f.__f_)) {} | 1836 | _LIBCPP_HIDE_FROM_ABI __async_func(__async_func&& __f) : __f_(std::move(__f.__f_)) {} |
| 1844 | 1837 | ||
| 1845 | _LIBCPP_HIDE_FROM_ABI _Rp operator()() { | 1838 | _LIBCPP_HIDE_FROM_ABI _Rp operator()() { |
| 1846 | typedef typename __make_tuple_indices<1 + sizeof...(_Args), 1>::type _Index; | 1839 | return [&]<size_t... _Indices>(__index_sequence<_Indices...>) -> _Rp { |
| 1847 | return __execute(_Index()); | 1840 | return std::__invoke(std::move(std::get<_Indices>(__f_))...); |
| 1848 | } | 1841 | }(__index_sequence_for<_Fp, _Args...>{}); |
| 1849 | |||
| 1850 | private: | ||
| 1851 | template <size_t... _Indices> | ||
| 1852 | _LIBCPP_HIDE_FROM_ABI _Rp __execute(__tuple_indices<_Indices...>) { | ||
| 1853 | return std::__invoke(std::move(std::get<0>(__f_)), std::move(std::get<_Indices>(__f_))...); | ||
| 1854 | } | 1842 | } |
| 1855 | }; | 1843 | }; |
| 1856 | 1844 | ||
| ... | @@ -1861,6 +1849,10 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch | ... | @@ -1861,6 +1849,10 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch |
| 1861 | template <class _Fp, class... _Args> | 1849 | template <class _Fp, class... _Args> |
| 1862 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> > | 1850 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> > |
| 1863 | async(launch __policy, _Fp&& __f, _Args&&... __args) { | 1851 | async(launch __policy, _Fp&& __f, _Args&&... __args) { |
| 1852 | static_assert(is_constructible<__decay_t<_Fp>, _Fp>::value, ""); | ||
| 1853 | static_assert(_And<is_constructible<__decay_t<_Args>, _Args>...>::value, ""); | ||
| 1854 | static_assert(__is_invocable_v<__decay_t<_Fp>, __decay_t<_Args>...>, ""); | ||
| 1855 | |||
| 1864 | typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; | 1856 | typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; |
| 1865 | typedef typename _BF::_Rp _Rp; | 1857 | typedef typename _BF::_Rp _Rp; |
| 1866 | 1858 | ||
| ... | @@ -1868,8 +1860,7 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { | ... | @@ -1868,8 +1860,7 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { |
| 1868 | try { | 1860 | try { |
| 1869 | # endif | 1861 | # endif |
| 1870 | if (__does_policy_contain(__policy, launch::async)) | 1862 | if (__does_policy_contain(__policy, launch::async)) |
| 1871 | return std::__make_async_assoc_state<_Rp>( | 1863 | return std::__make_async_assoc_state<_Rp>(_BF(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)); |
| 1872 | _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); | ||
| 1873 | # if _LIBCPP_HAS_EXCEPTIONS | 1864 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1874 | } catch (...) { | 1865 | } catch (...) { |
| 1875 | if (__policy == launch::async) | 1866 | if (__policy == launch::async) |
| ... | @@ -1878,8 +1869,7 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { | ... | @@ -1878,8 +1869,7 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { |
| 1878 | # endif | 1869 | # endif |
| 1879 | 1870 | ||
| 1880 | if (__does_policy_contain(__policy, launch::deferred)) | 1871 | if (__does_policy_contain(__policy, launch::deferred)) |
| 1881 | return std::__make_deferred_assoc_state<_Rp>( | 1872 | return std::__make_deferred_assoc_state<_Rp>(_BF(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)); |
| 1882 | _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); | ||
| 1883 | return future<_Rp>{}; | 1873 | return future<_Rp>{}; |
| 1884 | } | 1874 | } |
| 1885 | 1875 | ||
| ... | @@ -1915,12 +1905,12 @@ public: | ... | @@ -1915,12 +1905,12 @@ public: |
| 1915 | } | 1905 | } |
| 1916 | 1906 | ||
| 1917 | // retrieving the value | 1907 | // retrieving the value |
| 1918 | _LIBCPP_HIDE_FROM_ABI const _Rp& get() const { return __state_->copy(); } | 1908 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Rp& get() const { return __state_->copy(); } |
| 1919 | 1909 | ||
| 1920 | _LIBCPP_HIDE_FROM_ABI void swap(shared_future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 1910 | _LIBCPP_HIDE_FROM_ABI void swap(shared_future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 1921 | 1911 | ||
| 1922 | // functions to check state | 1912 | // functions to check state |
| 1923 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } | 1913 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } |
| 1924 | 1914 | ||
| 1925 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } | 1915 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } |
| 1926 | template <class _Rep, class _Period> | 1916 | template <class _Rep, class _Period> |
| ... | @@ -1971,12 +1961,12 @@ public: | ... | @@ -1971,12 +1961,12 @@ public: |
| 1971 | } | 1961 | } |
| 1972 | 1962 | ||
| 1973 | // retrieving the value | 1963 | // retrieving the value |
| 1974 | _LIBCPP_HIDE_FROM_ABI _Rp& get() const { return __state_->copy(); } | 1964 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Rp& get() const { return __state_->copy(); } |
| 1975 | 1965 | ||
| 1976 | _LIBCPP_HIDE_FROM_ABI void swap(shared_future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 1966 | _LIBCPP_HIDE_FROM_ABI void swap(shared_future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 1977 | 1967 | ||
| 1978 | // functions to check state | 1968 | // functions to check state |
| 1979 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } | 1969 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } |
| 1980 | 1970 | ||
| 1981 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } | 1971 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } |
| 1982 | template <class _Rep, class _Period> | 1972 | template <class _Rep, class _Period> |
| ... | @@ -2032,7 +2022,7 @@ public: | ... | @@ -2032,7 +2022,7 @@ public: |
| 2032 | _LIBCPP_HIDE_FROM_ABI void swap(shared_future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } | 2022 | _LIBCPP_HIDE_FROM_ABI void swap(shared_future& __rhs) _NOEXCEPT { std::swap(__state_, __rhs.__state_); } |
| 2033 | 2023 | ||
| 2034 | // functions to check state | 2024 | // functions to check state |
| 2035 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } | 2025 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __state_ != nullptr; } |
| 2036 | 2026 | ||
| 2037 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } | 2027 | _LIBCPP_HIDE_FROM_ABI void wait() const { __state_->wait(); } |
| 2038 | template <class _Rep, class _Period> | 2028 | template <class _Rep, class _Period> |
lib/libcxx/include/initializer_list+9-3| ... | @@ -78,11 +78,17 @@ public: | ... | @@ -78,11 +78,17 @@ public: |
| 78 | 78 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} | 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} |
| 80 | 80 | ||
| 81 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t size() const _NOEXCEPT { return __size_; } | 81 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t size() const _NOEXCEPT { |
| 82 | return __size_; | ||
| 83 | } | ||
| 82 | 84 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin() const _NOEXCEPT { return __begin_; } | 85 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* begin() const _NOEXCEPT { |
| 86 | return __begin_; | ||
| 87 | } | ||
| 84 | 88 | ||
| 85 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end() const _NOEXCEPT { return __begin_ + __size_; } | 89 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end() const _NOEXCEPT { |
| 90 | return __begin_ + __size_; | ||
| 91 | } | ||
| 86 | }; | 92 | }; |
| 87 | 93 | ||
| 88 | template <class _Ep> | 94 | template <class _Ep> |
lib/libcxx/include/inttypes.h+16-16| ... | @@ -236,33 +236,33 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int | ... | @@ -236,33 +236,33 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int |
| 236 | */ | 236 | */ |
| 237 | 237 | ||
| 238 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 238 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 239 | # include <__cxx03/inttypes.h> | 239 | # include <__cxx03/__config> |
| 240 | #else | 240 | #else |
| 241 | # include <__config> | 241 | # include <__config> |
| 242 | #endif | ||
| 242 | 243 | ||
| 243 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 244 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 244 | # pragma GCC system_header | 245 | # pragma GCC system_header |
| 245 | # endif | 246 | #endif |
| 246 | 247 | ||
| 247 | /* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed | 248 | /* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed |
| 248 | for C++11 unless __STDC_FORMAT_MACROS is defined | 249 | for C++11 unless __STDC_FORMAT_MACROS is defined |
| 249 | */ | 250 | */ |
| 250 | # if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) | 251 | #if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) |
| 251 | # define __STDC_FORMAT_MACROS | 252 | # define __STDC_FORMAT_MACROS |
| 252 | # endif | 253 | #endif |
| 253 | 254 | ||
| 254 | # if __has_include_next(<inttypes.h>) | 255 | #if __has_include_next(<inttypes.h>) |
| 255 | # include_next <inttypes.h> | 256 | # include_next <inttypes.h> |
| 256 | # endif | 257 | #endif |
| 257 | 258 | ||
| 258 | # ifdef __cplusplus | 259 | #ifdef __cplusplus |
| 259 | 260 | ||
| 260 | # include <stdint.h> | 261 | # include <stdint.h> |
| 261 | 262 | ||
| 262 | # undef imaxabs | 263 | # undef imaxabs |
| 263 | # undef imaxdiv | 264 | # undef imaxdiv |
| 264 | 265 | ||
| 265 | # endif // __cplusplus | 266 | #endif // __cplusplus |
| 266 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 267 | 267 | ||
| 268 | #endif // _LIBCPP_INTTYPES_H | 268 | #endif // _LIBCPP_INTTYPES_H |
lib/libcxx/include/ios+28-28| ... | @@ -305,25 +305,25 @@ public: | ... | @@ -305,25 +305,25 @@ public: |
| 305 | class _LIBCPP_EXPORTED_FROM_ABI Init; | 305 | class _LIBCPP_EXPORTED_FROM_ABI Init; |
| 306 | 306 | ||
| 307 | // 27.5.2.2 fmtflags state: | 307 | // 27.5.2.2 fmtflags state: |
| 308 | _LIBCPP_HIDE_FROM_ABI fmtflags flags() const; | 308 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI fmtflags flags() const; |
| 309 | _LIBCPP_HIDE_FROM_ABI fmtflags flags(fmtflags __fmtfl); | 309 | _LIBCPP_HIDE_FROM_ABI fmtflags flags(fmtflags __fmtfl); |
| 310 | _LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl); | 310 | _LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl); |
| 311 | _LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl, fmtflags __mask); | 311 | _LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl, fmtflags __mask); |
| 312 | _LIBCPP_HIDE_FROM_ABI void unsetf(fmtflags __mask); | 312 | _LIBCPP_HIDE_FROM_ABI void unsetf(fmtflags __mask); |
| 313 | 313 | ||
| 314 | _LIBCPP_HIDE_FROM_ABI streamsize precision() const; | 314 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI streamsize precision() const; |
| 315 | _LIBCPP_HIDE_FROM_ABI streamsize precision(streamsize __prec); | 315 | _LIBCPP_HIDE_FROM_ABI streamsize precision(streamsize __prec); |
| 316 | _LIBCPP_HIDE_FROM_ABI streamsize width() const; | 316 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI streamsize width() const; |
| 317 | _LIBCPP_HIDE_FROM_ABI streamsize width(streamsize __wide); | 317 | _LIBCPP_HIDE_FROM_ABI streamsize width(streamsize __wide); |
| 318 | 318 | ||
| 319 | // 27.5.2.3 locales: | 319 | // 27.5.2.3 locales: |
| 320 | locale imbue(const locale& __loc); | 320 | locale imbue(const locale& __loc); |
| 321 | locale getloc() const; | 321 | [[__nodiscard__]] locale getloc() const; |
| 322 | 322 | ||
| 323 | // 27.5.2.5 storage: | 323 | // 27.5.2.5 storage: |
| 324 | static int xalloc(); | 324 | [[__nodiscard__]] static int xalloc(); |
| 325 | long& iword(int __index); | 325 | [[__nodiscard__]] long& iword(int __index); |
| 326 | void*& pword(int __index); | 326 | [[__nodiscard__]] void*& pword(int __index); |
| 327 | 327 | ||
| 328 | // destructor | 328 | // destructor |
| 329 | virtual ~ios_base(); | 329 | virtual ~ios_base(); |
| ... | @@ -338,16 +338,16 @@ public: | ... | @@ -338,16 +338,16 @@ public: |
| 338 | 338 | ||
| 339 | static bool sync_with_stdio(bool __sync = true); | 339 | static bool sync_with_stdio(bool __sync = true); |
| 340 | 340 | ||
| 341 | _LIBCPP_HIDE_FROM_ABI iostate rdstate() const; | 341 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iostate rdstate() const; |
| 342 | void clear(iostate __state = goodbit); | 342 | void clear(iostate __state = goodbit); |
| 343 | _LIBCPP_HIDE_FROM_ABI void setstate(iostate __state); | 343 | _LIBCPP_HIDE_FROM_ABI void setstate(iostate __state); |
| 344 | 344 | ||
| 345 | _LIBCPP_HIDE_FROM_ABI bool good() const; | 345 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool good() const; |
| 346 | _LIBCPP_HIDE_FROM_ABI bool eof() const; | 346 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool eof() const; |
| 347 | _LIBCPP_HIDE_FROM_ABI bool fail() const; | 347 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool fail() const; |
| 348 | _LIBCPP_HIDE_FROM_ABI bool bad() const; | 348 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool bad() const; |
| 349 | 349 | ||
| 350 | _LIBCPP_HIDE_FROM_ABI iostate exceptions() const; | 350 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iostate exceptions() const; |
| 351 | _LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate); | 351 | _LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate); |
| 352 | 352 | ||
| 353 | void __set_badbit_and_consider_rethrow(); | 353 | void __set_badbit_and_consider_rethrow(); |
| ... | @@ -425,13 +425,13 @@ template <> | ... | @@ -425,13 +425,13 @@ template <> |
| 425 | struct is_error_code_enum<io_errc::__lx> : public true_type {}; | 425 | struct is_error_code_enum<io_errc::__lx> : public true_type {}; |
| 426 | # endif | 426 | # endif |
| 427 | 427 | ||
| 428 | _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; | 428 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; |
| 429 | 429 | ||
| 430 | inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(io_errc __e) _NOEXCEPT { | 430 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(io_errc __e) _NOEXCEPT { |
| 431 | return error_code(static_cast<int>(__e), iostream_category()); | 431 | return error_code(static_cast<int>(__e), iostream_category()); |
| 432 | } | 432 | } |
| 433 | 433 | ||
| 434 | inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(io_errc __e) _NOEXCEPT { | 434 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(io_errc __e) _NOEXCEPT { |
| 435 | return error_condition(static_cast<int>(__e), iostream_category()); | 435 | return error_condition(static_cast<int>(__e), iostream_category()); |
| 436 | } | 436 | } |
| 437 | 437 | ||
| ... | @@ -580,16 +580,16 @@ public: | ... | @@ -580,16 +580,16 @@ public: |
| 580 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); } | 580 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); } |
| 581 | # endif | 581 | # endif |
| 582 | 582 | ||
| 583 | _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); } | 583 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); } |
| 584 | _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); } | 584 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); } |
| 585 | _LIBCPP_HIDE_FROM_ABI void clear(iostate __state = goodbit) { ios_base::clear(__state); } | 585 | _LIBCPP_HIDE_FROM_ABI void clear(iostate __state = goodbit) { ios_base::clear(__state); } |
| 586 | _LIBCPP_HIDE_FROM_ABI void setstate(iostate __state) { ios_base::setstate(__state); } | 586 | _LIBCPP_HIDE_FROM_ABI void setstate(iostate __state) { ios_base::setstate(__state); } |
| 587 | _LIBCPP_HIDE_FROM_ABI bool good() const { return ios_base::good(); } | 587 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool good() const { return ios_base::good(); } |
| 588 | _LIBCPP_HIDE_FROM_ABI bool eof() const { return ios_base::eof(); } | 588 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool eof() const { return ios_base::eof(); } |
| 589 | _LIBCPP_HIDE_FROM_ABI bool fail() const { return ios_base::fail(); } | 589 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool fail() const { return ios_base::fail(); } |
| 590 | _LIBCPP_HIDE_FROM_ABI bool bad() const { return ios_base::bad(); } | 590 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool bad() const { return ios_base::bad(); } |
| 591 | 591 | ||
| 592 | _LIBCPP_HIDE_FROM_ABI iostate exceptions() const { return ios_base::exceptions(); } | 592 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iostate exceptions() const { return ios_base::exceptions(); } |
| 593 | _LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate) { ios_base::exceptions(__iostate); } | 593 | _LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate) { ios_base::exceptions(__iostate); } |
| 594 | 594 | ||
| 595 | // 27.5.4.1 Constructor/destructor: | 595 | // 27.5.4.1 Constructor/destructor: |
| ... | @@ -597,21 +597,21 @@ public: | ... | @@ -597,21 +597,21 @@ public: |
| 597 | ~basic_ios() override; | 597 | ~basic_ios() override; |
| 598 | 598 | ||
| 599 | // 27.5.4.2 Members: | 599 | // 27.5.4.2 Members: |
| 600 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie() const; | 600 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie() const; |
| 601 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); | 601 | _LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); |
| 602 | 602 | ||
| 603 | _LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf() const; | 603 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf() const; |
| 604 | _LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); | 604 | _LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); |
| 605 | 605 | ||
| 606 | basic_ios& copyfmt(const basic_ios& __rhs); | 606 | basic_ios& copyfmt(const basic_ios& __rhs); |
| 607 | 607 | ||
| 608 | _LIBCPP_HIDE_FROM_ABI char_type fill() const; | 608 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type fill() const; |
| 609 | _LIBCPP_HIDE_FROM_ABI char_type fill(char_type __ch); | 609 | _LIBCPP_HIDE_FROM_ABI char_type fill(char_type __ch); |
| 610 | 610 | ||
| 611 | _LIBCPP_HIDE_FROM_ABI locale imbue(const locale& __loc); | 611 | _LIBCPP_HIDE_FROM_ABI locale imbue(const locale& __loc); |
| 612 | 612 | ||
| 613 | _LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const; | 613 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const; |
| 614 | _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const; | 614 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const; |
| 615 | 615 | ||
| 616 | protected: | 616 | protected: |
| 617 | _LIBCPP_HIDE_FROM_ABI basic_ios() { | 617 | _LIBCPP_HIDE_FROM_ABI basic_ios() { |
lib/libcxx/include/istream+19-13| ... | @@ -70,6 +70,7 @@ public: | ... | @@ -70,6 +70,7 @@ public: |
| 70 | basic_istream& getline(char_type* s, streamsize n, char_type delim); | 70 | basic_istream& getline(char_type* s, streamsize n, char_type delim); |
| 71 | 71 | ||
| 72 | basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()); | 72 | basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()); |
| 73 | basic_istream& ignore(streamsize n, char_type delim); // Since C++26, implemented as a DR | ||
| 73 | int_type peek(); | 74 | int_type peek(); |
| 74 | basic_istream& read (char_type* s, streamsize n); | 75 | basic_istream& read (char_type* s, streamsize n); |
| 75 | streamsize readsome(char_type* s, streamsize n); | 76 | streamsize readsome(char_type* s, streamsize n); |
| ... | @@ -172,6 +173,7 @@ template <class Stream, class T> | ... | @@ -172,6 +173,7 @@ template <class Stream, class T> |
| 172 | # include <__type_traits/conjunction.h> | 173 | # include <__type_traits/conjunction.h> |
| 173 | # include <__type_traits/enable_if.h> | 174 | # include <__type_traits/enable_if.h> |
| 174 | # include <__type_traits/is_base_of.h> | 175 | # include <__type_traits/is_base_of.h> |
| 176 | # include <__type_traits/is_same.h> | ||
| 175 | # include <__type_traits/make_unsigned.h> | 177 | # include <__type_traits/make_unsigned.h> |
| 176 | # include <__utility/declval.h> | 178 | # include <__utility/declval.h> |
| 177 | # include <__utility/forward.h> | 179 | # include <__utility/forward.h> |
| ... | @@ -207,7 +209,7 @@ public: | ... | @@ -207,7 +209,7 @@ public: |
| 207 | typedef typename traits_type::off_type off_type; | 209 | typedef typename traits_type::off_type off_type; |
| 208 | 210 | ||
| 209 | // 27.7.1.1.1 Constructor/destructor: | 211 | // 27.7.1.1.1 Constructor/destructor: |
| 210 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) | 212 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) |
| 211 | : __gc_(0) { | 213 | : __gc_(0) { |
| 212 | this->init(__sb); | 214 | this->init(__sb); |
| 213 | } | 215 | } |
| ... | @@ -219,7 +221,7 @@ protected: | ... | @@ -219,7 +221,7 @@ protected: |
| 219 | // 27.7.1.1.2 Assign/swap: | 221 | // 27.7.1.1.2 Assign/swap: |
| 220 | inline _LIBCPP_HIDE_FROM_ABI basic_istream& operator=(basic_istream&& __rhs); | 222 | inline _LIBCPP_HIDE_FROM_ABI basic_istream& operator=(basic_istream&& __rhs); |
| 221 | 223 | ||
| 222 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_istream& __rhs) { | 224 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 void swap(basic_istream& __rhs) { |
| 223 | std::swap(__gc_, __rhs.__gc_); | 225 | std::swap(__gc_, __rhs.__gc_); |
| 224 | basic_ios<char_type, traits_type>::swap(__rhs); | 226 | basic_ios<char_type, traits_type>::swap(__rhs); |
| 225 | } | 227 | } |
| ... | @@ -232,17 +234,17 @@ public: | ... | @@ -232,17 +234,17 @@ public: |
| 232 | class sentry; | 234 | class sentry; |
| 233 | 235 | ||
| 234 | // 27.7.1.2 Formatted input: | 236 | // 27.7.1.2 Formatted input: |
| 235 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)) { | 237 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)) { |
| 236 | return __pf(*this); | 238 | return __pf(*this); |
| 237 | } | 239 | } |
| 238 | 240 | ||
| 239 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& | 241 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_istream& |
| 240 | operator>>(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) { | 242 | operator>>(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) { |
| 241 | __pf(*this); | 243 | __pf(*this); |
| 242 | return *this; | 244 | return *this; |
| 243 | } | 245 | } |
| 244 | 246 | ||
| 245 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& operator>>(ios_base& (*__pf)(ios_base&)) { | 247 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_istream& operator>>(ios_base& (*__pf)(ios_base&)) { |
| 246 | __pf(*this); | 248 | __pf(*this); |
| 247 | return *this; | 249 | return *this; |
| 248 | } | 250 | } |
| ... | @@ -263,35 +265,39 @@ public: | ... | @@ -263,35 +265,39 @@ public: |
| 263 | basic_istream& operator>>(void*& __p); | 265 | basic_istream& operator>>(void*& __p); |
| 264 | 266 | ||
| 265 | // 27.7.1.3 Unformatted input: | 267 | // 27.7.1.3 Unformatted input: |
| 266 | _LIBCPP_HIDE_FROM_ABI streamsize gcount() const { return __gc_; } | 268 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI streamsize gcount() const { return __gc_; } |
| 267 | int_type get(); | 269 | int_type get(); |
| 268 | 270 | ||
| 269 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& get(char_type& __c) { | 271 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_istream& get(char_type& __c) { |
| 270 | int_type __ch = get(); | 272 | int_type __ch = get(); |
| 271 | if (__ch != traits_type::eof()) | 273 | if (__ch != traits_type::eof()) |
| 272 | __c = traits_type::to_char_type(__ch); | 274 | __c = traits_type::to_char_type(__ch); |
| 273 | return *this; | 275 | return *this; |
| 274 | } | 276 | } |
| 275 | 277 | ||
| 276 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& get(char_type* __s, streamsize __n) { | 278 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_istream& get(char_type* __s, streamsize __n) { |
| 277 | return get(__s, __n, this->widen('\n')); | 279 | return get(__s, __n, this->widen('\n')); |
| 278 | } | 280 | } |
| 279 | 281 | ||
| 280 | basic_istream& get(char_type* __s, streamsize __n, char_type __dlm); | 282 | basic_istream& get(char_type* __s, streamsize __n, char_type __dlm); |
| 281 | 283 | ||
| 282 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& get(basic_streambuf<char_type, traits_type>& __sb) { | 284 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_istream& get(basic_streambuf<char_type, traits_type>& __sb) { |
| 283 | return get(__sb, this->widen('\n')); | 285 | return get(__sb, this->widen('\n')); |
| 284 | } | 286 | } |
| 285 | 287 | ||
| 286 | basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm); | 288 | basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm); |
| 287 | 289 | ||
| 288 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& getline(char_type* __s, streamsize __n) { | 290 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_istream& getline(char_type* __s, streamsize __n) { |
| 289 | return getline(__s, __n, this->widen('\n')); | 291 | return getline(__s, __n, this->widen('\n')); |
| 290 | } | 292 | } |
| 291 | 293 | ||
| 292 | basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm); | 294 | basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm); |
| 293 | 295 | ||
| 294 | basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); | 296 | basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); |
| 297 | template <class _Tp = char_type, __enable_if_t<is_same<_Tp, char>::value, int> = 0> | ||
| 298 | _LIBCPP_HIDE_FROM_ABI basic_istream& ignore(streamsize __n, char_type __delim) { | ||
| 299 | return ignore(__n, traits_type::to_int_type(__delim)); | ||
| 300 | } | ||
| 295 | int_type peek(); | 301 | int_type peek(); |
| 296 | basic_istream& read(char_type* __s, streamsize __n); | 302 | basic_istream& read(char_type* __s, streamsize __n); |
| 297 | streamsize readsome(char_type* __s, streamsize __n); | 303 | streamsize readsome(char_type* __s, streamsize __n); |
| ... | @@ -300,7 +306,7 @@ public: | ... | @@ -300,7 +306,7 @@ public: |
| 300 | basic_istream& unget(); | 306 | basic_istream& unget(); |
| 301 | int sync(); | 307 | int sync(); |
| 302 | 308 | ||
| 303 | pos_type tellg(); | 309 | [[__nodiscard__]] pos_type tellg(); |
| 304 | basic_istream& seekg(pos_type __pos); | 310 | basic_istream& seekg(pos_type __pos); |
| 305 | basic_istream& seekg(off_type __off, ios_base::seekdir __dir); | 311 | basic_istream& seekg(off_type __off, ios_base::seekdir __dir); |
| 306 | }; | 312 | }; |
| ... | @@ -1178,7 +1184,7 @@ public: | ... | @@ -1178,7 +1184,7 @@ public: |
| 1178 | typedef typename traits_type::off_type off_type; | 1184 | typedef typename traits_type::off_type off_type; |
| 1179 | 1185 | ||
| 1180 | // constructor/destructor | 1186 | // constructor/destructor |
| 1181 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb) | 1187 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb) |
| 1182 | : basic_istream<_CharT, _Traits>(__sb) {} | 1188 | : basic_istream<_CharT, _Traits>(__sb) {} |
| 1183 | 1189 | ||
| 1184 | ~basic_iostream() override; | 1190 | ~basic_iostream() override; |
| ... | @@ -1189,7 +1195,7 @@ protected: | ... | @@ -1189,7 +1195,7 @@ protected: |
| 1189 | // assign/swap | 1195 | // assign/swap |
| 1190 | inline _LIBCPP_HIDE_FROM_ABI basic_iostream& operator=(basic_iostream&& __rhs); | 1196 | inline _LIBCPP_HIDE_FROM_ABI basic_iostream& operator=(basic_iostream&& __rhs); |
| 1191 | 1197 | ||
| 1192 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_iostream& __rhs) { | 1198 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 void swap(basic_iostream& __rhs) { |
| 1193 | basic_istream<char_type, traits_type>::swap(__rhs); | 1199 | basic_istream<char_type, traits_type>::swap(__rhs); |
| 1194 | } | 1200 | } |
| 1195 | }; | 1201 | }; |
lib/libcxx/include/iterator+10| ... | @@ -737,6 +737,16 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; | ... | @@ -737,6 +737,16 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 737 | # include <compare> | 737 | # include <compare> |
| 738 | # include <concepts> | 738 | # include <concepts> |
| 739 | 739 | ||
| 740 | // [range.access.general] | ||
| 741 | # if _LIBCPP_STD_VER >= 20 | ||
| 742 | # include <__ranges/access.h> | ||
| 743 | # include <__ranges/data.h> | ||
| 744 | # include <__ranges/empty.h> | ||
| 745 | # include <__ranges/rbegin.h> | ||
| 746 | # include <__ranges/rend.h> | ||
| 747 | # include <__ranges/size.h> | ||
| 748 | # endif | ||
| 749 | |||
| 740 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 750 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 741 | # pragma GCC system_header | 751 | # pragma GCC system_header |
| 742 | # endif | 752 | # endif |
lib/libcxx/include/latch+7-5| ... | @@ -70,7 +70,9 @@ class latch { | ... | @@ -70,7 +70,9 @@ class latch { |
| 70 | atomic<ptrdiff_t> __a_; | 70 | atomic<ptrdiff_t> __a_; |
| 71 | 71 | ||
| 72 | public: | 72 | public: |
| 73 | static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); } | 73 | [[nodiscard]] static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { |
| 74 | return numeric_limits<ptrdiff_t>::max(); | ||
| 75 | } | ||
| 74 | 76 | ||
| 75 | inline _LIBCPP_HIDE_FROM_ABI constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected) { | 77 | inline _LIBCPP_HIDE_FROM_ABI constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected) { |
| 76 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 78 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| ... | @@ -87,7 +89,7 @@ public: | ... | @@ -87,7 +89,7 @@ public: |
| 87 | latch(const latch&) = delete; | 89 | latch(const latch&) = delete; |
| 88 | latch& operator=(const latch&) = delete; | 90 | latch& operator=(const latch&) = delete; |
| 89 | 91 | ||
| 90 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void count_down(ptrdiff_t __update = 1) { | 92 | inline _LIBCPP_HIDE_FROM_ABI void count_down(ptrdiff_t __update = 1) { |
| 91 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::count_down called with a negative value"); | 93 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::count_down called with a negative value"); |
| 92 | auto const __old = __a_.fetch_sub(__update, memory_order_release); | 94 | auto const __old = __a_.fetch_sub(__update, memory_order_release); |
| 93 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 95 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| ... | @@ -97,16 +99,16 @@ public: | ... | @@ -97,16 +99,16 @@ public: |
| 97 | if (__old == __update) | 99 | if (__old == __update) |
| 98 | __a_.notify_all(); | 100 | __a_.notify_all(); |
| 99 | } | 101 | } |
| 100 | inline _LIBCPP_HIDE_FROM_ABI bool try_wait() const noexcept { | 102 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI bool try_wait() const noexcept { |
| 101 | auto __value = __a_.load(memory_order_acquire); | 103 | auto __value = __a_.load(memory_order_acquire); |
| 102 | return try_wait_impl(__value); | 104 | return try_wait_impl(__value); |
| 103 | } | 105 | } |
| 104 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait() const { | 106 | inline _LIBCPP_HIDE_FROM_ABI void wait() const { |
| 105 | std::__atomic_wait_unless(__a_, memory_order_acquire, [this](ptrdiff_t& __value) -> bool { | 107 | std::__atomic_wait_unless(__a_, memory_order_acquire, [this](ptrdiff_t& __value) -> bool { |
| 106 | return try_wait_impl(__value); | 108 | return try_wait_impl(__value); |
| 107 | }); | 109 | }); |
| 108 | } | 110 | } |
| 109 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) { | 111 | inline _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) { |
| 110 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value"); | 112 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value"); |
| 111 | // other preconditions on __update are checked in count_down() | 113 | // other preconditions on __update are checked in count_down() |
| 112 | 114 |
lib/libcxx/include/limits+4-4| ... | @@ -107,7 +107,7 @@ template<> class numeric_limits<cv long double>; | ... | @@ -107,7 +107,7 @@ template<> class numeric_limits<cv long double>; |
| 107 | #else | 107 | #else |
| 108 | # include <__config> | 108 | # include <__config> |
| 109 | # include <__type_traits/is_arithmetic.h> | 109 | # include <__type_traits/is_arithmetic.h> |
| 110 | # include <__type_traits/is_signed.h> | 110 | # include <__type_traits/is_same.h> |
| 111 | 111 | ||
| 112 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 112 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 113 | # pragma GCC system_header | 113 | # pragma GCC system_header |
| ... | @@ -217,10 +217,10 @@ protected: | ... | @@ -217,10 +217,10 @@ protected: |
| 217 | 217 | ||
| 218 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; | 218 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 219 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; | 219 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| 220 | static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value; | 220 | static _LIBCPP_CONSTEXPR const bool is_modulo = !is_signed; |
| 221 | 221 | ||
| 222 | # if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__) | 222 | # if defined(__i386__) || defined(__x86_64__) || defined(__wasm__) |
| 223 | static _LIBCPP_CONSTEXPR const bool traps = true; | 223 | static _LIBCPP_CONSTEXPR const bool traps = is_same<decltype(+_Tp(0)), _Tp>::value; |
| 224 | # else | 224 | # else |
| 225 | static _LIBCPP_CONSTEXPR const bool traps = false; | 225 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 226 | # endif | 226 | # endif |
lib/libcxx/include/list+61-79| ... | @@ -228,15 +228,14 @@ template <class T, class Allocator, class Predicate> | ... | @@ -228,15 +228,14 @@ template <class T, class Allocator, class Predicate> |
| 228 | # include <__ranges/concepts.h> | 228 | # include <__ranges/concepts.h> |
| 229 | # include <__ranges/container_compatible_range.h> | 229 | # include <__ranges/container_compatible_range.h> |
| 230 | # include <__ranges/from_range.h> | 230 | # include <__ranges/from_range.h> |
| 231 | # include <__type_traits/conditional.h> | ||
| 232 | # include <__type_traits/container_traits.h> | 231 | # include <__type_traits/container_traits.h> |
| 233 | # include <__type_traits/enable_if.h> | 232 | # include <__type_traits/enable_if.h> |
| 234 | # include <__type_traits/is_allocator.h> | 233 | # include <__type_traits/is_allocator.h> |
| 235 | # include <__type_traits/is_nothrow_assignable.h> | 234 | # include <__type_traits/is_nothrow_assignable.h> |
| 236 | # include <__type_traits/is_nothrow_constructible.h> | 235 | # include <__type_traits/is_nothrow_constructible.h> |
| 237 | # include <__type_traits/is_pointer.h> | ||
| 238 | # include <__type_traits/is_same.h> | 236 | # include <__type_traits/is_same.h> |
| 239 | # include <__type_traits/type_identity.h> | 237 | # include <__type_traits/type_identity.h> |
| 238 | # include <__utility/exception_guard.h> | ||
| 240 | # include <__utility/forward.h> | 239 | # include <__utility/forward.h> |
| 241 | # include <__utility/move.h> | 240 | # include <__utility/move.h> |
| 242 | # include <__utility/swap.h> | 241 | # include <__utility/swap.h> |
| ... | @@ -275,17 +274,6 @@ template <class _Tp, class _VoidPtr> | ... | @@ -275,17 +274,6 @@ template <class _Tp, class _VoidPtr> |
| 275 | struct __list_node_pointer_traits { | 274 | struct __list_node_pointer_traits { |
| 276 | typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer; | 275 | typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer; |
| 277 | typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer; | 276 | typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer; |
| 278 | |||
| 279 | // TODO(LLVM 22): Remove this check | ||
| 280 | # ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | ||
| 281 | static_assert(sizeof(__node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__base_pointer) == | ||
| 282 | _LIBCPP_ALIGNOF(__node_pointer), | ||
| 283 | "It looks like you are using std::list with a fancy pointer type that thas a different representation " | ||
| 284 | "depending on whether it points to a list base pointer or a list node pointer (both of which are " | ||
| 285 | "implementation details of the standard library). This means that your ABI is being broken between " | ||
| 286 | "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the " | ||
| 287 | "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); | ||
| 288 | # endif | ||
| 289 | }; | 277 | }; |
| 290 | 278 | ||
| 291 | template <class _Tp, class _VoidPtr> | 279 | template <class _Tp, class _VoidPtr> |
| ... | @@ -724,7 +712,7 @@ public: | ... | @@ -724,7 +712,7 @@ public: |
| 724 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); | 712 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); |
| 725 | # endif | 713 | # endif |
| 726 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); | 714 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); |
| 727 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 715 | template <__enable_if_t<__is_allocator_v<_Alloc>, int> = 0> |
| 728 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI | 716 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 729 | list(size_type __n, const value_type& __x, const allocator_type& __a) | 717 | list(size_type __n, const value_type& __x, const allocator_type& __a) |
| 730 | : __base(__a) { | 718 | : __base(__a) { |
| ... | @@ -786,57 +774,71 @@ public: | ... | @@ -786,57 +774,71 @@ public: |
| 786 | 774 | ||
| 787 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x); | 775 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x); |
| 788 | 776 | ||
| 789 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; | 777 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; |
| 790 | 778 | ||
| 791 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; } | 779 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { |
| 780 | return this->__size_; | ||
| 781 | } | ||
| 792 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | 782 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { |
| 793 | return __base::empty(); | 783 | return __base::empty(); |
| 794 | } | 784 | } |
| 795 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 785 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 796 | return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max()); | 786 | return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max()); |
| 797 | } | 787 | } |
| 798 | 788 | ||
| 799 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); } | 789 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { |
| 800 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); } | 790 | return __base::begin(); |
| 801 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); } | 791 | } |
| 802 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); } | 792 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { |
| 803 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { | 793 | return __base::begin(); |
| 794 | } | ||
| 795 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { | ||
| 796 | return __base::end(); | ||
| 797 | } | ||
| 798 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { | ||
| 799 | return __base::end(); | ||
| 800 | } | ||
| 801 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { | ||
| 804 | return __base::begin(); | 802 | return __base::begin(); |
| 805 | } | 803 | } |
| 806 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); } | 804 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { |
| 805 | return __base::end(); | ||
| 806 | } | ||
| 807 | 807 | ||
| 808 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { | 808 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { |
| 809 | return reverse_iterator(end()); | 809 | return reverse_iterator(end()); |
| 810 | } | 810 | } |
| 811 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { | 811 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator |
| 812 | rbegin() const _NOEXCEPT { | ||
| 812 | return const_reverse_iterator(end()); | 813 | return const_reverse_iterator(end()); |
| 813 | } | 814 | } |
| 814 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { | 815 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { |
| 815 | return reverse_iterator(begin()); | 816 | return reverse_iterator(begin()); |
| 816 | } | 817 | } |
| 817 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | 818 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { |
| 818 | return const_reverse_iterator(begin()); | 819 | return const_reverse_iterator(begin()); |
| 819 | } | 820 | } |
| 820 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { | 821 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator |
| 822 | crbegin() const _NOEXCEPT { | ||
| 821 | return const_reverse_iterator(end()); | 823 | return const_reverse_iterator(end()); |
| 822 | } | 824 | } |
| 823 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { | 825 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { |
| 824 | return const_reverse_iterator(begin()); | 826 | return const_reverse_iterator(begin()); |
| 825 | } | 827 | } |
| 826 | 828 | ||
| 827 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() { | 829 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() { |
| 828 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); | 830 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); |
| 829 | return __base::__end_.__next_->__as_node()->__get_value(); | 831 | return __base::__end_.__next_->__as_node()->__get_value(); |
| 830 | } | 832 | } |
| 831 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const { | 833 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const { |
| 832 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); | 834 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); |
| 833 | return __base::__end_.__next_->__as_node()->__get_value(); | 835 | return __base::__end_.__next_->__as_node()->__get_value(); |
| 834 | } | 836 | } |
| 835 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference back() { | 837 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference back() { |
| 836 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); | 838 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); |
| 837 | return __base::__end_.__prev_->__as_node()->__get_value(); | 839 | return __base::__end_.__prev_->__as_node()->__get_value(); |
| 838 | } | 840 | } |
| 839 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference back() const { | 841 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference back() const { |
| 840 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); | 842 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); |
| 841 | return __base::__end_.__prev_->__as_node()->__get_value(); | 843 | return __base::__end_.__prev_->__as_node()->__get_value(); |
| 842 | } | 844 | } |
| ... | @@ -1000,22 +1002,22 @@ private: | ... | @@ -1000,22 +1002,22 @@ private: |
| 1000 | 1002 | ||
| 1001 | # if _LIBCPP_STD_VER >= 17 | 1003 | # if _LIBCPP_STD_VER >= 17 |
| 1002 | template <class _InputIterator, | 1004 | template <class _InputIterator, |
| 1003 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, | 1005 | class _Alloc = allocator<__iterator_value_type<_InputIterator>>, |
| 1004 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1006 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1005 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 1007 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 1006 | list(_InputIterator, _InputIterator) -> list<__iter_value_type<_InputIterator>, _Alloc>; | 1008 | list(_InputIterator, _InputIterator) -> list<__iterator_value_type<_InputIterator>, _Alloc>; |
| 1007 | 1009 | ||
| 1008 | template <class _InputIterator, | 1010 | template <class _InputIterator, |
| 1009 | class _Alloc, | 1011 | class _Alloc, |
| 1010 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1012 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1011 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 1013 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 1012 | list(_InputIterator, _InputIterator, _Alloc) -> list<__iter_value_type<_InputIterator>, _Alloc>; | 1014 | list(_InputIterator, _InputIterator, _Alloc) -> list<__iterator_value_type<_InputIterator>, _Alloc>; |
| 1013 | # endif | 1015 | # endif |
| 1014 | 1016 | ||
| 1015 | # if _LIBCPP_STD_VER >= 23 | 1017 | # if _LIBCPP_STD_VER >= 23 |
| 1016 | template <ranges::input_range _Range, | 1018 | template <ranges::input_range _Range, |
| 1017 | class _Alloc = allocator<ranges::range_value_t<_Range>>, | 1019 | class _Alloc = allocator<ranges::range_value_t<_Range>>, |
| 1018 | class = enable_if_t<__is_allocator<_Alloc>::value> > | 1020 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 1019 | list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_Range>, _Alloc>; | 1021 | list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_Range>, _Alloc>; |
| 1020 | # endif | 1022 | # endif |
| 1021 | 1023 | ||
| ... | @@ -1233,14 +1235,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ | ... | @@ -1233,14 +1235,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1233 | ++__ds; | 1235 | ++__ds; |
| 1234 | __r = iterator(__node->__as_link()); | 1236 | __r = iterator(__node->__as_link()); |
| 1235 | iterator __e = __r; | 1237 | iterator __e = __r; |
| 1236 | # if _LIBCPP_HAS_EXCEPTIONS | 1238 | auto __guard = std::__make_exception_guard([&] { |
| 1237 | try { | ||
| 1238 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1239 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { | ||
| 1240 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); | ||
| 1241 | } | ||
| 1242 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1243 | } catch (...) { | ||
| 1244 | while (true) { | 1239 | while (true) { |
| 1245 | __base_pointer __prev = __e.__ptr_->__prev_; | 1240 | __base_pointer __prev = __e.__ptr_->__prev_; |
| 1246 | __node_pointer __current = __e.__ptr_->__as_node(); | 1241 | __node_pointer __current = __e.__ptr_->__as_node(); |
| ... | @@ -1249,9 +1244,11 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ | ... | @@ -1249,9 +1244,11 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1249 | break; | 1244 | break; |
| 1250 | __e = iterator(__prev); | 1245 | __e = iterator(__prev); |
| 1251 | } | 1246 | } |
| 1252 | throw; | 1247 | }); |
| 1248 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { | ||
| 1249 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); | ||
| 1253 | } | 1250 | } |
| 1254 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1251 | __guard.__complete(); |
| 1255 | __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); | 1252 | __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); |
| 1256 | this->__size_ += __ds; | 1253 | this->__size_ += __ds; |
| 1257 | } | 1254 | } |
| ... | @@ -1276,14 +1273,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se | ... | @@ -1276,14 +1273,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se |
| 1276 | ++__ds; | 1273 | ++__ds; |
| 1277 | __r = iterator(__node->__as_link()); | 1274 | __r = iterator(__node->__as_link()); |
| 1278 | iterator __e = __r; | 1275 | iterator __e = __r; |
| 1279 | # if _LIBCPP_HAS_EXCEPTIONS | 1276 | auto __guard = std::__make_exception_guard([&] { |
| 1280 | try { | ||
| 1281 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1282 | for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) { | ||
| 1283 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link(); | ||
| 1284 | } | ||
| 1285 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1286 | } catch (...) { | ||
| 1287 | while (true) { | 1277 | while (true) { |
| 1288 | __base_pointer __prev = __e.__ptr_->__prev_; | 1278 | __base_pointer __prev = __e.__ptr_->__prev_; |
| 1289 | __node_pointer __current = __e.__ptr_->__as_node(); | 1279 | __node_pointer __current = __e.__ptr_->__as_node(); |
| ... | @@ -1292,9 +1282,11 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se | ... | @@ -1292,9 +1282,11 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se |
| 1292 | break; | 1282 | break; |
| 1293 | __e = iterator(__prev); | 1283 | __e = iterator(__prev); |
| 1294 | } | 1284 | } |
| 1295 | throw; | 1285 | }); |
| 1286 | for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) { | ||
| 1287 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link(); | ||
| 1296 | } | 1288 | } |
| 1297 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1289 | __guard.__complete(); |
| 1298 | __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); | 1290 | __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); |
| 1299 | this->__size_ += __ds; | 1291 | this->__size_ += __ds; |
| 1300 | } | 1292 | } |
| ... | @@ -1452,14 +1444,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n) { | ... | @@ -1452,14 +1444,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n) { |
| 1452 | ++__ds; | 1444 | ++__ds; |
| 1453 | iterator __r = iterator(__node->__as_link()); | 1445 | iterator __r = iterator(__node->__as_link()); |
| 1454 | iterator __e = __r; | 1446 | iterator __e = __r; |
| 1455 | # if _LIBCPP_HAS_EXCEPTIONS | 1447 | auto __guard = std::__make_exception_guard([&] { |
| 1456 | try { | ||
| 1457 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1458 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { | ||
| 1459 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link(); | ||
| 1460 | } | ||
| 1461 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1462 | } catch (...) { | ||
| 1463 | while (true) { | 1448 | while (true) { |
| 1464 | __base_pointer __prev = __e.__ptr_->__prev_; | 1449 | __base_pointer __prev = __e.__ptr_->__prev_; |
| 1465 | __node_pointer __current = __e.__ptr_->__as_node(); | 1450 | __node_pointer __current = __e.__ptr_->__as_node(); |
| ... | @@ -1468,9 +1453,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n) { | ... | @@ -1468,9 +1453,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n) { |
| 1468 | break; | 1453 | break; |
| 1469 | __e = iterator(__prev); | 1454 | __e = iterator(__prev); |
| 1470 | } | 1455 | } |
| 1471 | throw; | 1456 | }); |
| 1457 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { | ||
| 1458 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link(); | ||
| 1472 | } | 1459 | } |
| 1473 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1460 | __guard.__complete(); |
| 1474 | __link_nodes_at_back(__r.__ptr_, __e.__ptr_); | 1461 | __link_nodes_at_back(__r.__ptr_, __e.__ptr_); |
| 1475 | this->__size_ += __ds; | 1462 | this->__size_ += __ds; |
| 1476 | } | 1463 | } |
| ... | @@ -1488,14 +1475,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n, cons | ... | @@ -1488,14 +1475,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n, cons |
| 1488 | __base_pointer __nl = __node->__as_link(); | 1475 | __base_pointer __nl = __node->__as_link(); |
| 1489 | iterator __r = iterator(__nl); | 1476 | iterator __r = iterator(__nl); |
| 1490 | iterator __e = __r; | 1477 | iterator __e = __r; |
| 1491 | # if _LIBCPP_HAS_EXCEPTIONS | 1478 | auto __guard = std::__make_exception_guard([&] { |
| 1492 | try { | ||
| 1493 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 1494 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { | ||
| 1495 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); | ||
| 1496 | } | ||
| 1497 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1498 | } catch (...) { | ||
| 1499 | while (true) { | 1479 | while (true) { |
| 1500 | __base_pointer __prev = __e.__ptr_->__prev_; | 1480 | __base_pointer __prev = __e.__ptr_->__prev_; |
| 1501 | __node_pointer __current = __e.__ptr_->__as_node(); | 1481 | __node_pointer __current = __e.__ptr_->__as_node(); |
| ... | @@ -1504,9 +1484,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n, cons | ... | @@ -1504,9 +1484,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n, cons |
| 1504 | break; | 1484 | break; |
| 1505 | __e = iterator(__prev); | 1485 | __e = iterator(__prev); |
| 1506 | } | 1486 | } |
| 1507 | throw; | 1487 | }); |
| 1488 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { | ||
| 1489 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); | ||
| 1508 | } | 1490 | } |
| 1509 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1491 | __guard.__complete(); |
| 1510 | __link_nodes(__base::__end_as_link(), __r.__ptr_, __e.__ptr_); | 1492 | __link_nodes(__base::__end_as_link(), __r.__ptr_, __e.__ptr_); |
| 1511 | this->__size_ += __ds; | 1493 | this->__size_ += __ds; |
| 1512 | } | 1494 | } |
lib/libcxx/include/map+386-274| ... | @@ -577,12 +577,12 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -577,12 +577,12 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 577 | # include <__algorithm/equal.h> | 577 | # include <__algorithm/equal.h> |
| 578 | # include <__algorithm/lexicographical_compare.h> | 578 | # include <__algorithm/lexicographical_compare.h> |
| 579 | # include <__algorithm/lexicographical_compare_three_way.h> | 579 | # include <__algorithm/lexicographical_compare_three_way.h> |
| 580 | # include <__algorithm/specialized_algorithms.h> | ||
| 580 | # include <__assert> | 581 | # include <__assert> |
| 581 | # include <__config> | 582 | # include <__config> |
| 582 | # include <__functional/binary_function.h> | 583 | # include <__functional/binary_function.h> |
| 583 | # include <__functional/is_transparent.h> | 584 | # include <__functional/is_transparent.h> |
| 584 | # include <__functional/operations.h> | 585 | # include <__functional/operations.h> |
| 585 | # include <__fwd/map.h> | ||
| 586 | # include <__iterator/erase_if_container.h> | 586 | # include <__iterator/erase_if_container.h> |
| 587 | # include <__iterator/iterator_traits.h> | 587 | # include <__iterator/iterator_traits.h> |
| 588 | # include <__iterator/ranges_iterator_traits.h> | 588 | # include <__iterator/ranges_iterator_traits.h> |
| ... | @@ -590,19 +590,23 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -590,19 +590,23 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 590 | # include <__memory/addressof.h> | 590 | # include <__memory/addressof.h> |
| 591 | # include <__memory/allocator.h> | 591 | # include <__memory/allocator.h> |
| 592 | # include <__memory/allocator_traits.h> | 592 | # include <__memory/allocator_traits.h> |
| 593 | # include <__memory/compressed_pair.h> | ||
| 593 | # include <__memory/pointer_traits.h> | 594 | # include <__memory/pointer_traits.h> |
| 594 | # include <__memory/unique_ptr.h> | 595 | # include <__memory/unique_ptr.h> |
| 595 | # include <__memory_resource/polymorphic_allocator.h> | 596 | # include <__memory_resource/polymorphic_allocator.h> |
| 596 | # include <__node_handle> | 597 | # include <__node_handle> |
| 598 | # include <__ranges/access.h> | ||
| 597 | # include <__ranges/concepts.h> | 599 | # include <__ranges/concepts.h> |
| 598 | # include <__ranges/container_compatible_range.h> | 600 | # include <__ranges/container_compatible_range.h> |
| 599 | # include <__ranges/from_range.h> | 601 | # include <__ranges/from_range.h> |
| 600 | # include <__tree> | 602 | # include <__tree> |
| 601 | # include <__type_traits/container_traits.h> | 603 | # include <__type_traits/container_traits.h> |
| 602 | # include <__type_traits/is_allocator.h> | 604 | # include <__type_traits/is_allocator.h> |
| 605 | # include <__type_traits/make_transparent.h> | ||
| 603 | # include <__type_traits/remove_const.h> | 606 | # include <__type_traits/remove_const.h> |
| 604 | # include <__type_traits/type_identity.h> | 607 | # include <__type_traits/type_identity.h> |
| 605 | # include <__utility/forward.h> | 608 | # include <__utility/forward.h> |
| 609 | # include <__utility/lazy_synth_three_way_comparator.h> | ||
| 606 | # include <__utility/pair.h> | 610 | # include <__utility/pair.h> |
| 607 | # include <__utility/piecewise_construct.h> | 611 | # include <__utility/piecewise_construct.h> |
| 608 | # include <__utility/swap.h> | 612 | # include <__utility/swap.h> |
| ... | @@ -632,47 +636,9 @@ _LIBCPP_PUSH_MACROS | ... | @@ -632,47 +636,9 @@ _LIBCPP_PUSH_MACROS |
| 632 | 636 | ||
| 633 | _LIBCPP_BEGIN_NAMESPACE_STD | 637 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 634 | 638 | ||
| 635 | template <class _Key, | ||
| 636 | class _CP, | ||
| 637 | class _Compare, | ||
| 638 | bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value> | ||
| 639 | class __map_value_compare : private _Compare { | ||
| 640 | public: | ||
| 641 | _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) | ||
| 642 | : _Compare() {} | ||
| 643 | _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) | ||
| 644 | : _Compare(__c) {} | ||
| 645 | _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; } | ||
| 646 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { | ||
| 647 | return static_cast<const _Compare&>(*this)(__x.first, __y.first); | ||
| 648 | } | ||
| 649 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { | ||
| 650 | return static_cast<const _Compare&>(*this)(__x.first, __y); | ||
| 651 | } | ||
| 652 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { | ||
| 653 | return static_cast<const _Compare&>(*this)(__x, __y.first); | ||
| 654 | } | ||
| 655 | _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { | ||
| 656 | using std::swap; | ||
| 657 | swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); | ||
| 658 | } | ||
| 659 | |||
| 660 | # if _LIBCPP_STD_VER >= 14 | ||
| 661 | template <typename _K2> | ||
| 662 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { | ||
| 663 | return static_cast<const _Compare&>(*this)(__x, __y.first); | ||
| 664 | } | ||
| 665 | |||
| 666 | template <typename _K2> | ||
| 667 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { | ||
| 668 | return static_cast<const _Compare&>(*this)(__x.first, __y); | ||
| 669 | } | ||
| 670 | # endif | ||
| 671 | }; | ||
| 672 | |||
| 673 | template <class _Key, class _CP, class _Compare> | 639 | template <class _Key, class _CP, class _Compare> |
| 674 | class __map_value_compare<_Key, _CP, _Compare, false> { | 640 | class __map_value_compare { |
| 675 | _Compare __comp_; | 641 | _LIBCPP_COMPRESSED_ELEMENT(_Compare, __comp_); |
| 676 | 642 | ||
| 677 | public: | 643 | public: |
| 678 | _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) | 644 | _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) |
| ... | @@ -684,7 +650,7 @@ public: | ... | @@ -684,7 +650,7 @@ public: |
| 684 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { return __comp_(__x.first, __y.first); } | 650 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { return __comp_(__x.first, __y.first); } |
| 685 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { return __comp_(__x.first, __y); } | 651 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { return __comp_(__x.first, __y); } |
| 686 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { return __comp_(__x, __y.first); } | 652 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { return __comp_(__x, __y.first); } |
| 687 | void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { | 653 | _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { |
| 688 | using std::swap; | 654 | using std::swap; |
| 689 | swap(__comp_, __y.__comp_); | 655 | swap(__comp_, __y.__comp_); |
| 690 | } | 656 | } |
| ... | @@ -702,9 +668,58 @@ public: | ... | @@ -702,9 +668,58 @@ public: |
| 702 | # endif | 668 | # endif |
| 703 | }; | 669 | }; |
| 704 | 670 | ||
| 705 | template <class _Key, class _CP, class _Compare, bool __b> | 671 | template <class _Key, class _MapValueT, class _Compare> |
| 672 | struct __make_transparent<_Key, __map_value_compare<_Key, _MapValueT, _Compare> > { | ||
| 673 | using type _LIBCPP_NODEBUG = __map_value_compare<_Key, _MapValueT, __make_transparent_t<_Key, _Compare> >; | ||
| 674 | }; | ||
| 675 | |||
| 676 | # if _LIBCPP_STD_VER >= 14 | ||
| 677 | template <class _MapValueT, class _Key, class _Compare> | ||
| 678 | struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _Compare>, _MapValueT, _MapValueT> { | ||
| 679 | __lazy_synth_three_way_comparator<_Compare, _Key, _Key> __comp_; | ||
| 680 | |||
| 681 | __lazy_synth_three_way_comparator( | ||
| 682 | _LIBCPP_CTOR_LIFETIMEBOUND const __map_value_compare<_Key, _MapValueT, _Compare>& __comp) | ||
| 683 | : __comp_(__comp.key_comp()) {} | ||
| 684 | |||
| 685 | _LIBCPP_HIDE_FROM_ABI auto | ||
| 686 | operator()(_LIBCPP_LIFETIMEBOUND const _MapValueT& __lhs, _LIBCPP_LIFETIMEBOUND const _MapValueT& __rhs) const { | ||
| 687 | return __comp_(__lhs.first, __rhs.first); | ||
| 688 | } | ||
| 689 | }; | ||
| 690 | |||
| 691 | template <class _MapValueT, class _Key, class _TransparentKey, class _Compare> | ||
| 692 | struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _Compare>, _TransparentKey, _MapValueT> { | ||
| 693 | __lazy_synth_three_way_comparator<_Compare, _TransparentKey, _Key> __comp_; | ||
| 694 | |||
| 695 | __lazy_synth_three_way_comparator( | ||
| 696 | _LIBCPP_CTOR_LIFETIMEBOUND const __map_value_compare<_Key, _MapValueT, _Compare>& __comp) | ||
| 697 | : __comp_(__comp.key_comp()) {} | ||
| 698 | |||
| 699 | _LIBCPP_HIDE_FROM_ABI auto | ||
| 700 | operator()(_LIBCPP_LIFETIMEBOUND const _TransparentKey& __lhs, _LIBCPP_LIFETIMEBOUND const _MapValueT& __rhs) const { | ||
| 701 | return __comp_(__lhs, __rhs.first); | ||
| 702 | } | ||
| 703 | }; | ||
| 704 | |||
| 705 | template <class _MapValueT, class _Key, class _TransparentKey, class _Compare> | ||
| 706 | struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _Compare>, _MapValueT, _TransparentKey> { | ||
| 707 | __lazy_synth_three_way_comparator<_Compare, _Key, _TransparentKey> __comp_; | ||
| 708 | |||
| 709 | __lazy_synth_three_way_comparator( | ||
| 710 | _LIBCPP_CTOR_LIFETIMEBOUND const __map_value_compare<_Key, _MapValueT, _Compare>& __comp) | ||
| 711 | : __comp_(__comp.key_comp()) {} | ||
| 712 | |||
| 713 | _LIBCPP_HIDE_FROM_ABI auto | ||
| 714 | operator()(_LIBCPP_LIFETIMEBOUND const _MapValueT& __lhs, _LIBCPP_LIFETIMEBOUND const _TransparentKey& __rhs) const { | ||
| 715 | return __comp_(__lhs.first, __rhs); | ||
| 716 | } | ||
| 717 | }; | ||
| 718 | # endif // _LIBCPP_STD_VER >= 14 | ||
| 719 | |||
| 720 | template <class _Key, class _CP, class _Compare> | ||
| 706 | inline _LIBCPP_HIDE_FROM_ABI void | 721 | inline _LIBCPP_HIDE_FROM_ABI void |
| 707 | swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, __map_value_compare<_Key, _CP, _Compare, __b>& __y) | 722 | swap(__map_value_compare<_Key, _CP, _Compare>& __x, __map_value_compare<_Key, _CP, _Compare>& __y) |
| 708 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 723 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 709 | __x.swap(__y); | 724 | __x.swap(__y); |
| 710 | } | 725 | } |
| ... | @@ -742,9 +757,9 @@ public: | ... | @@ -742,9 +757,9 @@ public: |
| 742 | 757 | ||
| 743 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { | 758 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 744 | if (__second_constructed) | 759 | if (__second_constructed) |
| 745 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.second)); | 760 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().second)); |
| 746 | if (__first_constructed) | 761 | if (__first_constructed) |
| 747 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.first)); | 762 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().first)); |
| 748 | if (__p) | 763 | if (__p) |
| 749 | __alloc_traits::deallocate(__na_, __p, 1); | 764 | __alloc_traits::deallocate(__na_, __p, 1); |
| 750 | } | 765 | } |
| ... | @@ -804,7 +819,26 @@ public: | ... | @@ -804,7 +819,26 @@ public: |
| 804 | friend class multimap; | 819 | friend class multimap; |
| 805 | template <class> | 820 | template <class> |
| 806 | friend class __map_const_iterator; | 821 | friend class __map_const_iterator; |
| 822 | |||
| 823 | template <class, class...> | ||
| 824 | friend struct __specialized_algorithm; | ||
| 825 | }; | ||
| 826 | |||
| 827 | # ifndef _LIBCPP_CXX03_LANG | ||
| 828 | template <class _Alg, class _TreeIterator> | ||
| 829 | struct __specialized_algorithm<_Alg, __iterator_pair<__map_iterator<_TreeIterator>, __map_iterator<_TreeIterator>>> { | ||
| 830 | using __base _LIBCPP_NODEBUG = __specialized_algorithm<_Alg, __iterator_pair<_TreeIterator, _TreeIterator>>; | ||
| 831 | |||
| 832 | static const bool __has_algorithm = __base::__has_algorithm; | ||
| 833 | |||
| 834 | using __iterator _LIBCPP_NODEBUG = __map_iterator<_TreeIterator>; | ||
| 835 | |||
| 836 | template <class... _Args> | ||
| 837 | _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Args&&... __args) { | ||
| 838 | __base()(__first.__i_, __last.__i_, std::forward<_Args>(__args)...); | ||
| 839 | } | ||
| 807 | }; | 840 | }; |
| 841 | # endif | ||
| 808 | 842 | ||
| 809 | template <class _TreeIterator> | 843 | template <class _TreeIterator> |
| 810 | class __map_const_iterator { | 844 | class __map_const_iterator { |
| ... | @@ -859,9 +893,33 @@ public: | ... | @@ -859,9 +893,33 @@ public: |
| 859 | friend class multimap; | 893 | friend class multimap; |
| 860 | template <class, class, class> | 894 | template <class, class, class> |
| 861 | friend class __tree_const_iterator; | 895 | friend class __tree_const_iterator; |
| 896 | |||
| 897 | template <class, class...> | ||
| 898 | friend struct __specialized_algorithm; | ||
| 862 | }; | 899 | }; |
| 863 | 900 | ||
| 864 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 901 | # ifndef _LIBCPP_CXX03_LANG |
| 902 | template <class _Alg, class _TreeIterator> | ||
| 903 | struct __specialized_algorithm< | ||
| 904 | _Alg, | ||
| 905 | __iterator_pair<__map_const_iterator<_TreeIterator>, __map_const_iterator<_TreeIterator>>> { | ||
| 906 | using __base _LIBCPP_NODEBUG = __specialized_algorithm<_Alg, __iterator_pair<_TreeIterator, _TreeIterator>>; | ||
| 907 | |||
| 908 | static const bool __has_algorithm = __base::__has_algorithm; | ||
| 909 | |||
| 910 | using __iterator _LIBCPP_NODEBUG = __map_const_iterator<_TreeIterator>; | ||
| 911 | |||
| 912 | template <class... _Args> | ||
| 913 | _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Args&&... __args) { | ||
| 914 | __base()(__first.__i_, __last.__i_, std::forward<_Args>(__args)...); | ||
| 915 | } | ||
| 916 | }; | ||
| 917 | # endif | ||
| 918 | |||
| 919 | template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > | ||
| 920 | class multimap; | ||
| 921 | |||
| 922 | template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > | ||
| 865 | class map { | 923 | class map { |
| 866 | public: | 924 | public: |
| 867 | // types: | 925 | // types: |
| ... | @@ -970,17 +1028,17 @@ public: | ... | @@ -970,17 +1028,17 @@ public: |
| 970 | : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {} | 1028 | : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 971 | # endif | 1029 | # endif |
| 972 | 1030 | ||
| 973 | _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); } | 1031 | _LIBCPP_HIDE_FROM_ABI map(const map& __m) = default; |
| 974 | 1032 | ||
| 975 | _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) = default; | 1033 | _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) = default; |
| 976 | 1034 | ||
| 977 | # ifndef _LIBCPP_CXX03_LANG | 1035 | # ifndef _LIBCPP_CXX03_LANG |
| 978 | 1036 | ||
| 979 | _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) = default; | 1037 | _LIBCPP_HIDE_FROM_ABI map(map&& __m) = default; |
| 980 | 1038 | ||
| 981 | _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a); | 1039 | _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a) : __tree_(std::move(__m.__tree_), __a) {} |
| 982 | 1040 | ||
| 983 | _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) = default; | 1041 | _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) = default; |
| 984 | 1042 | ||
| 985 | _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 1043 | _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 986 | : __tree_(__vc(__comp)) { | 1044 | : __tree_(__vc(__comp)) { |
| ... | @@ -998,7 +1056,8 @@ public: | ... | @@ -998,7 +1056,8 @@ public: |
| 998 | # endif | 1056 | # endif |
| 999 | 1057 | ||
| 1000 | _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list<value_type> __il) { | 1058 | _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list<value_type> __il) { |
| 1001 | __tree_.__assign_unique(__il.begin(), __il.end()); | 1059 | clear(); |
| 1060 | insert(__il.begin(), __il.end()); | ||
| 1002 | return *this; | 1061 | return *this; |
| 1003 | } | 1062 | } |
| 1004 | 1063 | ||
| ... | @@ -1006,43 +1065,66 @@ public: | ... | @@ -1006,43 +1065,66 @@ public: |
| 1006 | 1065 | ||
| 1007 | _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} | 1066 | _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} |
| 1008 | 1067 | ||
| 1009 | _LIBCPP_HIDE_FROM_ABI map(const map& __m, const allocator_type& __a) | 1068 | _LIBCPP_HIDE_FROM_ABI map(const map& __m, const allocator_type& __alloc) : __tree_(__m.__tree_, __alloc) {} |
| 1010 | : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) { | ||
| 1011 | insert(__m.begin(), __m.end()); | ||
| 1012 | } | ||
| 1013 | 1069 | ||
| 1014 | _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); } | 1070 | _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); } |
| 1015 | 1071 | ||
| 1016 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 1072 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 1017 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 1073 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| 1018 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } | 1074 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } |
| 1019 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } | 1075 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } |
| 1020 | 1076 | ||
| 1021 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } | 1077 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } |
| 1022 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 1078 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { |
| 1023 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | 1079 | return const_reverse_iterator(end()); |
| 1024 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 1080 | } |
| 1081 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | ||
| 1082 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | ||
| 1083 | return const_reverse_iterator(begin()); | ||
| 1084 | } | ||
| 1025 | 1085 | ||
| 1026 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | 1086 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } |
| 1027 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | 1087 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } |
| 1028 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 1088 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1029 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 1089 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1030 | 1090 | ||
| 1031 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 1091 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 1032 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 1092 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1033 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 1093 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1034 | 1094 | ||
| 1035 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); | 1095 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); |
| 1036 | # ifndef _LIBCPP_CXX03_LANG | 1096 | # ifndef _LIBCPP_CXX03_LANG |
| 1037 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); | 1097 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); |
| 1038 | # endif | 1098 | # endif |
| 1039 | 1099 | ||
| 1040 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); | 1100 | template <class _Arg, |
| 1041 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; | 1101 | __enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0> |
| 1102 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mapped_type& at(_Arg&& __arg) { | ||
| 1103 | auto [_, __child] = __tree_.__find_equal(__arg); | ||
| 1104 | if (__child == nullptr) | ||
| 1105 | std::__throw_out_of_range("map::at: key not found"); | ||
| 1106 | return static_cast<__node_pointer>(__child)->__get_value().second; | ||
| 1107 | } | ||
| 1108 | |||
| 1109 | template <class _Arg, | ||
| 1110 | __enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0> | ||
| 1111 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const mapped_type& at(_Arg&& __arg) const { | ||
| 1112 | auto [_, __child] = __tree_.__find_equal(__arg); | ||
| 1113 | if (__child == nullptr) | ||
| 1114 | std::__throw_out_of_range("map::at: key not found"); | ||
| 1115 | return static_cast<__node_pointer>(__child)->__get_value().second; | ||
| 1116 | } | ||
| 1042 | 1117 | ||
| 1043 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__tree_.__alloc()); } | 1118 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); |
| 1044 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } | 1119 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; |
| 1045 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } | 1120 | |
| 1121 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | ||
| 1122 | return allocator_type(__tree_.__alloc()); | ||
| 1123 | } | ||
| 1124 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } | ||
| 1125 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { | ||
| 1126 | return value_compare(__tree_.value_comp().key_comp()); | ||
| 1127 | } | ||
| 1046 | 1128 | ||
| 1047 | # ifndef _LIBCPP_CXX03_LANG | 1129 | # ifndef _LIBCPP_CXX03_LANG |
| 1048 | template <class... _Args> | 1130 | template <class... _Args> |
| ... | @@ -1052,7 +1134,7 @@ public: | ... | @@ -1052,7 +1134,7 @@ public: |
| 1052 | 1134 | ||
| 1053 | template <class... _Args> | 1135 | template <class... _Args> |
| 1054 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { | 1136 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
| 1055 | return __tree_.__emplace_hint_unique(__p.__i_, std::forward<_Args>(__args)...); | 1137 | return __tree_.__emplace_hint_unique(__p.__i_, std::forward<_Args>(__args)...).first; |
| 1056 | } | 1138 | } |
| 1057 | 1139 | ||
| 1058 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1140 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| ... | @@ -1062,7 +1144,7 @@ public: | ... | @@ -1062,7 +1144,7 @@ public: |
| 1062 | 1144 | ||
| 1063 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1145 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1064 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { | 1146 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { |
| 1065 | return __tree_.__emplace_hint_unique(__pos.__i_, std::forward<_Pp>(__p)); | 1147 | return __tree_.__emplace_hint_unique(__pos.__i_, std::forward<_Pp>(__p)).first; |
| 1066 | } | 1148 | } |
| 1067 | 1149 | ||
| 1068 | # endif // _LIBCPP_CXX03_LANG | 1150 | # endif // _LIBCPP_CXX03_LANG |
| ... | @@ -1070,7 +1152,7 @@ public: | ... | @@ -1070,7 +1152,7 @@ public: |
| 1070 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); } | 1152 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); } |
| 1071 | 1153 | ||
| 1072 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { | 1154 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| 1073 | return __tree_.__emplace_hint_unique(__p.__i_, __v); | 1155 | return __tree_.__emplace_hint_unique(__p.__i_, __v).first; |
| 1074 | } | 1156 | } |
| 1075 | 1157 | ||
| 1076 | # ifndef _LIBCPP_CXX03_LANG | 1158 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -1079,25 +1161,21 @@ public: | ... | @@ -1079,25 +1161,21 @@ public: |
| 1079 | } | 1161 | } |
| 1080 | 1162 | ||
| 1081 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { | 1163 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { |
| 1082 | return __tree_.__emplace_hint_unique(__p.__i_, std::move(__v)); | 1164 | return __tree_.__emplace_hint_unique(__p.__i_, std::move(__v)).first; |
| 1083 | } | 1165 | } |
| 1084 | 1166 | ||
| 1085 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 1167 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1086 | # endif | 1168 | # endif |
| 1087 | 1169 | ||
| 1088 | template <class _InputIterator> | 1170 | template <class _InputIterator> |
| 1089 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { | 1171 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { |
| 1090 | for (const_iterator __e = cend(); __f != __l; ++__f) | 1172 | __tree_.__insert_range_unique(__first, __last); |
| 1091 | insert(__e.__i_, *__f); | ||
| 1092 | } | 1173 | } |
| 1093 | 1174 | ||
| 1094 | # if _LIBCPP_STD_VER >= 23 | 1175 | # if _LIBCPP_STD_VER >= 23 |
| 1095 | template <_ContainerCompatibleRange<value_type> _Range> | 1176 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1096 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1177 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1097 | const_iterator __end = cend(); | 1178 | __tree_.__insert_range_unique(ranges::begin(__range), ranges::end(__range)); |
| 1098 | for (auto&& __element : __range) { | ||
| 1099 | insert(__end.__i_, std::forward<decltype(__element)>(__element)); | ||
| 1100 | } | ||
| 1101 | } | 1179 | } |
| 1102 | # endif | 1180 | # endif |
| 1103 | 1181 | ||
| ... | @@ -1105,17 +1183,13 @@ public: | ... | @@ -1105,17 +1183,13 @@ public: |
| 1105 | 1183 | ||
| 1106 | template <class... _Args> | 1184 | template <class... _Args> |
| 1107 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) { | 1185 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) { |
| 1108 | return __tree_.__emplace_unique_key_args( | 1186 | return __tree_.__emplace_unique( |
| 1109 | __k, | 1187 | std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple(std::forward<_Args>(__args)...)); |
| 1110 | std::piecewise_construct, | ||
| 1111 | std::forward_as_tuple(__k), | ||
| 1112 | std::forward_as_tuple(std::forward<_Args>(__args)...)); | ||
| 1113 | } | 1188 | } |
| 1114 | 1189 | ||
| 1115 | template <class... _Args> | 1190 | template <class... _Args> |
| 1116 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) { | 1191 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) { |
| 1117 | return __tree_.__emplace_unique_key_args( | 1192 | return __tree_.__emplace_unique( |
| 1118 | __k, | ||
| 1119 | std::piecewise_construct, | 1193 | std::piecewise_construct, |
| 1120 | std::forward_as_tuple(std::move(__k)), | 1194 | std::forward_as_tuple(std::move(__k)), |
| 1121 | std::forward_as_tuple(std::forward<_Args>(__args)...)); | 1195 | std::forward_as_tuple(std::forward<_Args>(__args)...)); |
| ... | @@ -1124,9 +1198,8 @@ public: | ... | @@ -1124,9 +1198,8 @@ public: |
| 1124 | template <class... _Args> | 1198 | template <class... _Args> |
| 1125 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) { | 1199 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) { |
| 1126 | return __tree_ | 1200 | return __tree_ |
| 1127 | .__emplace_hint_unique_key_args( | 1201 | .__emplace_hint_unique( |
| 1128 | __h.__i_, | 1202 | __h.__i_, |
| 1129 | __k, | ||
| 1130 | std::piecewise_construct, | 1203 | std::piecewise_construct, |
| 1131 | std::forward_as_tuple(__k), | 1204 | std::forward_as_tuple(__k), |
| 1132 | std::forward_as_tuple(std::forward<_Args>(__args)...)) | 1205 | std::forward_as_tuple(std::forward<_Args>(__args)...)) |
| ... | @@ -1136,9 +1209,8 @@ public: | ... | @@ -1136,9 +1209,8 @@ public: |
| 1136 | template <class... _Args> | 1209 | template <class... _Args> |
| 1137 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) { | 1210 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) { |
| 1138 | return __tree_ | 1211 | return __tree_ |
| 1139 | .__emplace_hint_unique_key_args( | 1212 | .__emplace_hint_unique( |
| 1140 | __h.__i_, | 1213 | __h.__i_, |
| 1141 | __k, | ||
| 1142 | std::piecewise_construct, | 1214 | std::piecewise_construct, |
| 1143 | std::forward_as_tuple(std::move(__k)), | 1215 | std::forward_as_tuple(std::move(__k)), |
| 1144 | std::forward_as_tuple(std::forward<_Args>(__args)...)) | 1216 | std::forward_as_tuple(std::forward<_Args>(__args)...)) |
| ... | @@ -1147,27 +1219,25 @@ public: | ... | @@ -1147,27 +1219,25 @@ public: |
| 1147 | 1219 | ||
| 1148 | template <class _Vp> | 1220 | template <class _Vp> |
| 1149 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) { | 1221 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) { |
| 1150 | iterator __p = lower_bound(__k); | 1222 | auto __result = __tree_.__emplace_unique(__k, std::forward<_Vp>(__v)); |
| 1151 | if (__p != end() && !key_comp()(__k, __p->first)) { | 1223 | auto& [__iter, __inserted] = __result; |
| 1152 | __p->second = std::forward<_Vp>(__v); | 1224 | if (!__inserted) |
| 1153 | return std::make_pair(__p, false); | 1225 | __iter->second = std::forward<_Vp>(__v); |
| 1154 | } | 1226 | return __result; |
| 1155 | return std::make_pair(emplace_hint(__p, __k, std::forward<_Vp>(__v)), true); | ||
| 1156 | } | 1227 | } |
| 1157 | 1228 | ||
| 1158 | template <class _Vp> | 1229 | template <class _Vp> |
| 1159 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) { | 1230 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) { |
| 1160 | iterator __p = lower_bound(__k); | 1231 | auto __result = __tree_.__emplace_unique(std::move(__k), std::forward<_Vp>(__v)); |
| 1161 | if (__p != end() && !key_comp()(__k, __p->first)) { | 1232 | auto& [__iter, __inserted] = __result; |
| 1162 | __p->second = std::forward<_Vp>(__v); | 1233 | if (!__inserted) |
| 1163 | return std::make_pair(__p, false); | 1234 | __iter->second = std::forward<_Vp>(__v); |
| 1164 | } | 1235 | return __result; |
| 1165 | return std::make_pair(emplace_hint(__p, std::move(__k), std::forward<_Vp>(__v)), true); | ||
| 1166 | } | 1236 | } |
| 1167 | 1237 | ||
| 1168 | template <class _Vp> | 1238 | template <class _Vp> |
| 1169 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) { | 1239 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) { |
| 1170 | auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, __k, std::forward<_Vp>(__v)); | 1240 | auto [__r, __inserted] = __tree_.__emplace_hint_unique(__h.__i_, __k, std::forward<_Vp>(__v)); |
| 1171 | 1241 | ||
| 1172 | if (!__inserted) | 1242 | if (!__inserted) |
| 1173 | __r->second = std::forward<_Vp>(__v); | 1243 | __r->second = std::forward<_Vp>(__v); |
| ... | @@ -1177,8 +1247,7 @@ public: | ... | @@ -1177,8 +1247,7 @@ public: |
| 1177 | 1247 | ||
| 1178 | template <class _Vp> | 1248 | template <class _Vp> |
| 1179 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) { | 1249 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) { |
| 1180 | auto [__r, __inserted] = | 1250 | auto [__r, __inserted] = __tree_.__emplace_hint_unique(__h.__i_, std::move(__k), std::forward<_Vp>(__v)); |
| 1181 | __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, std::move(__k), std::forward<_Vp>(__v)); | ||
| 1182 | 1251 | ||
| 1183 | if (!__inserted) | 1252 | if (!__inserted) |
| 1184 | __r->second = std::forward<_Vp>(__v); | 1253 | __r->second = std::forward<_Vp>(__v); |
| ... | @@ -1207,10 +1276,10 @@ public: | ... | @@ -1207,10 +1276,10 @@ public: |
| 1207 | "node_type with incompatible allocator passed to map::insert()"); | 1276 | "node_type with incompatible allocator passed to map::insert()"); |
| 1208 | return __tree_.template __node_handle_insert_unique<node_type>(__hint.__i_, std::move(__nh)); | 1277 | return __tree_.template __node_handle_insert_unique<node_type>(__hint.__i_, std::move(__nh)); |
| 1209 | } | 1278 | } |
| 1210 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 1279 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 1211 | return __tree_.template __node_handle_extract<node_type>(__key); | 1280 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1212 | } | 1281 | } |
| 1213 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { | 1282 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { |
| 1214 | return __tree_.template __node_handle_extract<node_type>(__it.__i_); | 1283 | return __tree_.template __node_handle_extract<node_type>(__it.__i_); |
| 1215 | } | 1284 | } |
| 1216 | template <class _Compare2> | 1285 | template <class _Compare2> |
| ... | @@ -1241,75 +1310,105 @@ public: | ... | @@ -1241,75 +1310,105 @@ public: |
| 1241 | 1310 | ||
| 1242 | _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); } | 1311 | _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); } |
| 1243 | 1312 | ||
| 1244 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 1313 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1245 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 1314 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1246 | # if _LIBCPP_STD_VER >= 14 | 1315 | # if _LIBCPP_STD_VER >= 14 |
| 1247 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1316 | template <typename _K2, |
| 1248 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1317 | enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>, |
| 1318 | int> = 0> | ||
| 1319 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | ||
| 1249 | return __tree_.find(__k); | 1320 | return __tree_.find(__k); |
| 1250 | } | 1321 | } |
| 1251 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1322 | template <typename _K2, |
| 1252 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1323 | enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>, |
| 1324 | int> = 0> | ||
| 1325 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | ||
| 1253 | return __tree_.find(__k); | 1326 | return __tree_.find(__k); |
| 1254 | } | 1327 | } |
| 1255 | # endif | 1328 | # endif |
| 1256 | 1329 | ||
| 1257 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } | 1330 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 1331 | return __tree_.__count_unique(__k); | ||
| 1332 | } | ||
| 1258 | # if _LIBCPP_STD_VER >= 14 | 1333 | # if _LIBCPP_STD_VER >= 14 |
| 1259 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1334 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1260 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1335 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1261 | return __tree_.__count_multi(__k); | 1336 | return __tree_.__count_multi(__k); |
| 1262 | } | 1337 | } |
| 1263 | # endif | 1338 | # endif |
| 1264 | 1339 | ||
| 1265 | # if _LIBCPP_STD_VER >= 20 | 1340 | # if _LIBCPP_STD_VER >= 20 |
| 1266 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1341 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1267 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1342 | template <typename _K2, |
| 1268 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1343 | enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>, |
| 1344 | int> = 0> | ||
| 1345 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | ||
| 1269 | return find(__k) != end(); | 1346 | return find(__k) != end(); |
| 1270 | } | 1347 | } |
| 1271 | # endif // _LIBCPP_STD_VER >= 20 | 1348 | # endif // _LIBCPP_STD_VER >= 20 |
| 1272 | 1349 | ||
| 1273 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 1350 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { |
| 1274 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 1351 | return __tree_.__lower_bound_unique(__k); |
| 1352 | } | ||
| 1353 | |||
| 1354 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { | ||
| 1355 | return __tree_.__lower_bound_unique(__k); | ||
| 1356 | } | ||
| 1357 | |||
| 1358 | // The transparent versions of the lookup functions use the _multi version, since a non-element key is allowed to | ||
| 1359 | // match multiple elements. | ||
| 1275 | # if _LIBCPP_STD_VER >= 14 | 1360 | # if _LIBCPP_STD_VER >= 14 |
| 1276 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1361 | template <typename _K2, |
| 1277 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 1362 | enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>, |
| 1278 | return __tree_.lower_bound(__k); | 1363 | int> = 0> |
| 1364 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | ||
| 1365 | return __tree_.__lower_bound_multi(__k); | ||
| 1279 | } | 1366 | } |
| 1280 | 1367 | ||
| 1281 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1368 | template <typename _K2, |
| 1282 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 1369 | enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>, |
| 1283 | return __tree_.lower_bound(__k); | 1370 | int> = 0> |
| 1371 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | ||
| 1372 | return __tree_.__lower_bound_multi(__k); | ||
| 1284 | } | 1373 | } |
| 1285 | # endif | 1374 | # endif |
| 1286 | 1375 | ||
| 1287 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 1376 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { |
| 1288 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 1377 | return __tree_.__upper_bound_unique(__k); |
| 1289 | # if _LIBCPP_STD_VER >= 14 | ||
| 1290 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | ||
| 1291 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | ||
| 1292 | return __tree_.upper_bound(__k); | ||
| 1293 | } | 1378 | } |
| 1294 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1379 | |
| 1295 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 1380 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { |
| 1296 | return __tree_.upper_bound(__k); | 1381 | return __tree_.__upper_bound_unique(__k); |
| 1382 | } | ||
| 1383 | |||
| 1384 | # if _LIBCPP_STD_VER >= 14 | ||
| 1385 | template <typename _K2, | ||
| 1386 | enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>, | ||
| 1387 | int> = 0> | ||
| 1388 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | ||
| 1389 | return __tree_.__upper_bound_multi(__k); | ||
| 1390 | } | ||
| 1391 | template <typename _K2, | ||
| 1392 | enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>, | ||
| 1393 | int> = 0> | ||
| 1394 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | ||
| 1395 | return __tree_.__upper_bound_multi(__k); | ||
| 1297 | } | 1396 | } |
| 1298 | # endif | 1397 | # endif |
| 1299 | 1398 | ||
| 1300 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 1399 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1301 | return __tree_.__equal_range_unique(__k); | 1400 | return __tree_.__equal_range_unique(__k); |
| 1302 | } | 1401 | } |
| 1303 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 1402 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1304 | return __tree_.__equal_range_unique(__k); | 1403 | return __tree_.__equal_range_unique(__k); |
| 1305 | } | 1404 | } |
| 1306 | # if _LIBCPP_STD_VER >= 14 | 1405 | # if _LIBCPP_STD_VER >= 14 |
| 1307 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1406 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1308 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1407 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1309 | return __tree_.__equal_range_multi(__k); | 1408 | return __tree_.__equal_range_multi(__k); |
| 1310 | } | 1409 | } |
| 1311 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1410 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1312 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1411 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1313 | return __tree_.__equal_range_multi(__k); | 1412 | return __tree_.__equal_range_multi(__k); |
| 1314 | } | 1413 | } |
| 1315 | # endif | 1414 | # endif |
| ... | @@ -1319,7 +1418,6 @@ private: | ... | @@ -1319,7 +1418,6 @@ private: |
| 1319 | typedef typename __base::__node_allocator __node_allocator; | 1418 | typedef typename __base::__node_allocator __node_allocator; |
| 1320 | typedef typename __base::__node_pointer __node_pointer; | 1419 | typedef typename __base::__node_pointer __node_pointer; |
| 1321 | typedef typename __base::__node_base_pointer __node_base_pointer; | 1420 | typedef typename __base::__node_base_pointer __node_base_pointer; |
| 1322 | typedef typename __base::__parent_pointer __parent_pointer; | ||
| 1323 | 1421 | ||
| 1324 | typedef __map_node_destructor<__node_allocator> _Dp; | 1422 | typedef __map_node_destructor<__node_allocator> _Dp; |
| 1325 | typedef unique_ptr<__node, _Dp> __node_holder; | 1423 | typedef unique_ptr<__node, _Dp> __node_holder; |
| ... | @@ -1327,6 +1425,8 @@ private: | ... | @@ -1327,6 +1425,8 @@ private: |
| 1327 | # ifdef _LIBCPP_CXX03_LANG | 1425 | # ifdef _LIBCPP_CXX03_LANG |
| 1328 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k); | 1426 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k); |
| 1329 | # endif | 1427 | # endif |
| 1428 | |||
| 1429 | friend struct __specialized_algorithm<_Algorithm::__for_each, __single_range<map> >; | ||
| 1330 | }; | 1430 | }; |
| 1331 | 1431 | ||
| 1332 | # if _LIBCPP_STD_VER >= 17 | 1432 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1334,8 +1434,8 @@ template <class _InputIterator, | ... | @@ -1334,8 +1434,8 @@ template <class _InputIterator, |
| 1334 | class _Compare = less<__iter_key_type<_InputIterator>>, | 1434 | class _Compare = less<__iter_key_type<_InputIterator>>, |
| 1335 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, | 1435 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 1336 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 1436 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 1337 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 1437 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 1338 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1438 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1339 | map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) | 1439 | map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1340 | -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; | 1440 | -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 1341 | 1441 | ||
| ... | @@ -1343,8 +1443,8 @@ map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocat | ... | @@ -1343,8 +1443,8 @@ map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocat |
| 1343 | template <ranges::input_range _Range, | 1443 | template <ranges::input_range _Range, |
| 1344 | class _Compare = less<__range_key_type<_Range>>, | 1444 | class _Compare = less<__range_key_type<_Range>>, |
| 1345 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, | 1445 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, |
| 1346 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 1446 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 1347 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1447 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1348 | map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) | 1448 | map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1349 | -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; | 1449 | -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; |
| 1350 | # endif | 1450 | # endif |
| ... | @@ -1353,16 +1453,15 @@ template <class _Key, | ... | @@ -1353,16 +1453,15 @@ template <class _Key, |
| 1353 | class _Tp, | 1453 | class _Tp, |
| 1354 | class _Compare = less<remove_const_t<_Key>>, | 1454 | class _Compare = less<remove_const_t<_Key>>, |
| 1355 | class _Allocator = allocator<pair<const _Key, _Tp>>, | 1455 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 1356 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 1456 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 1357 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1457 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1358 | map(initializer_list<pair<_Key, _Tp>>, | 1458 | map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1359 | _Compare = _Compare(), | 1459 | -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; |
| 1360 | _Allocator = _Allocator()) -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; | ||
| 1361 | 1460 | ||
| 1362 | template <class _InputIterator, | 1461 | template <class _InputIterator, |
| 1363 | class _Allocator, | 1462 | class _Allocator, |
| 1364 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 1463 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 1365 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1464 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1366 | map(_InputIterator, _InputIterator, _Allocator) | 1465 | map(_InputIterator, _InputIterator, _Allocator) |
| 1367 | -> map<__iter_key_type<_InputIterator>, | 1466 | -> map<__iter_key_type<_InputIterator>, |
| 1368 | __iter_mapped_type<_InputIterator>, | 1467 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -1370,44 +1469,44 @@ map(_InputIterator, _InputIterator, _Allocator) | ... | @@ -1370,44 +1469,44 @@ map(_InputIterator, _InputIterator, _Allocator) |
| 1370 | _Allocator>; | 1469 | _Allocator>; |
| 1371 | 1470 | ||
| 1372 | # if _LIBCPP_STD_VER >= 23 | 1471 | # if _LIBCPP_STD_VER >= 23 |
| 1373 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1472 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1374 | map(from_range_t, _Range&&, _Allocator) | 1473 | map(from_range_t, _Range&&, _Allocator) |
| 1375 | -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; | 1474 | -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; |
| 1376 | # endif | 1475 | # endif |
| 1377 | 1476 | ||
| 1378 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1477 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1379 | map(initializer_list<pair<_Key, _Tp>>, | 1478 | map(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 1380 | _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; | 1479 | -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 1381 | # endif | 1480 | # endif |
| 1382 | 1481 | ||
| 1383 | # ifndef _LIBCPP_CXX03_LANG | 1482 | # if _LIBCPP_STD_VER >= 14 |
| 1384 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1483 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1385 | map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) | 1484 | struct __specialized_algorithm<_Algorithm::__for_each, __single_range<map<_Key, _Tp, _Compare, _Allocator>>> { |
| 1386 | : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { | 1485 | using __map _LIBCPP_NODEBUG = map<_Key, _Tp, _Compare, _Allocator>; |
| 1387 | if (__a != __m.get_allocator()) { | 1486 | |
| 1388 | const_iterator __e = cend(); | 1487 | static const bool __has_algorithm = true; |
| 1389 | while (!__m.empty()) { | 1488 | |
| 1390 | __tree_.__insert_unique_from_orphaned_node(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_)); | 1489 | template <class _Map, class _Func, class _Proj> |
| 1391 | } | 1490 | _LIBCPP_HIDE_FROM_ABI static auto operator()(_Map&& __map, _Func __func, _Proj __proj) { |
| 1491 | auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()( | ||
| 1492 | __map.__tree_, std::move(__func), std::move(__proj)); | ||
| 1493 | return std::make_pair(__map.end(), std::move(__func2)); | ||
| 1392 | } | 1494 | } |
| 1393 | } | 1495 | }; |
| 1496 | # endif | ||
| 1394 | 1497 | ||
| 1498 | # ifndef _LIBCPP_CXX03_LANG | ||
| 1395 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1499 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1396 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { | 1500 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { |
| 1397 | return __tree_ | 1501 | return __tree_.__emplace_unique(std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) |
| 1398 | .__emplace_unique_key_args(__k, std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) | ||
| 1399 | .first->second; | 1502 | .first->second; |
| 1400 | } | 1503 | } |
| 1401 | 1504 | ||
| 1402 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1505 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1403 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { | 1506 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { |
| 1404 | // TODO investigate this clang-tidy warning. | ||
| 1405 | // NOLINTBEGIN(bugprone-use-after-move) | ||
| 1406 | return __tree_ | 1507 | return __tree_ |
| 1407 | .__emplace_unique_key_args( | 1508 | .__emplace_unique(std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) |
| 1408 | __k, std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) | ||
| 1409 | .first->second; | 1509 | .first->second; |
| 1410 | // NOLINTEND(bugprone-use-after-move) | ||
| 1411 | } | 1510 | } |
| 1412 | 1511 | ||
| 1413 | # else // _LIBCPP_CXX03_LANG | 1512 | # else // _LIBCPP_CXX03_LANG |
| ... | @@ -1417,44 +1516,41 @@ typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder | ... | @@ -1417,44 +1516,41 @@ typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder |
| 1417 | map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) { | 1516 | map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) { |
| 1418 | __node_allocator& __na = __tree_.__node_alloc(); | 1517 | __node_allocator& __na = __tree_.__node_alloc(); |
| 1419 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1518 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1420 | __node_traits::construct(__na, std::addressof(__h->__value_.first), __k); | 1519 | __node_traits::construct(__na, std::addressof(__h->__get_value().first), __k); |
| 1421 | __h.get_deleter().__first_constructed = true; | 1520 | __h.get_deleter().__first_constructed = true; |
| 1422 | __node_traits::construct(__na, std::addressof(__h->__value_.second)); | 1521 | __node_traits::construct(__na, std::addressof(__h->__get_value().second)); |
| 1423 | __h.get_deleter().__second_constructed = true; | 1522 | __h.get_deleter().__second_constructed = true; |
| 1424 | return __h; | 1523 | return __h; |
| 1425 | } | 1524 | } |
| 1426 | 1525 | ||
| 1427 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1526 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1428 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { | 1527 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { |
| 1429 | __parent_pointer __parent; | 1528 | auto [__parent, __child] = __tree_.__find_equal(__k); |
| 1430 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); | 1529 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 1431 | __node_pointer __r = static_cast<__node_pointer>(__child); | ||
| 1432 | if (__child == nullptr) { | 1530 | if (__child == nullptr) { |
| 1433 | __node_holder __h = __construct_node_with_key(__k); | 1531 | __node_holder __h = __construct_node_with_key(__k); |
| 1434 | __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | 1532 | __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
| 1435 | __r = __h.release(); | 1533 | __r = __h.release(); |
| 1436 | } | 1534 | } |
| 1437 | return __r->__value_.second; | 1535 | return __r->__get_value().second; |
| 1438 | } | 1536 | } |
| 1439 | 1537 | ||
| 1440 | # endif // _LIBCPP_CXX03_LANG | 1538 | # endif // _LIBCPP_CXX03_LANG |
| 1441 | 1539 | ||
| 1442 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1540 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1443 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { | 1541 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { |
| 1444 | __parent_pointer __parent; | 1542 | auto [_, __child] = __tree_.__find_equal(__k); |
| 1445 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); | ||
| 1446 | if (__child == nullptr) | 1543 | if (__child == nullptr) |
| 1447 | std::__throw_out_of_range("map::at: key not found"); | 1544 | std::__throw_out_of_range("map::at: key not found"); |
| 1448 | return static_cast<__node_pointer>(__child)->__value_.second; | 1545 | return static_cast<__node_pointer>(__child)->__get_value().second; |
| 1449 | } | 1546 | } |
| 1450 | 1547 | ||
| 1451 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1548 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1452 | const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const { | 1549 | const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const { |
| 1453 | __parent_pointer __parent; | 1550 | auto [_, __child] = __tree_.__find_equal(__k); |
| 1454 | __node_base_pointer __child = __tree_.__find_equal(__parent, __k); | ||
| 1455 | if (__child == nullptr) | 1551 | if (__child == nullptr) |
| 1456 | std::__throw_out_of_range("map::at: key not found"); | 1552 | std::__throw_out_of_range("map::at: key not found"); |
| 1457 | return static_cast<__node_pointer>(__child)->__value_.second; | 1553 | return static_cast<__node_pointer>(__child)->__get_value().second; |
| 1458 | } | 1554 | } |
| 1459 | 1555 | ||
| 1460 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1556 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1637,22 +1733,17 @@ public: | ... | @@ -1637,22 +1733,17 @@ public: |
| 1637 | : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {} | 1733 | : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 1638 | # endif | 1734 | # endif |
| 1639 | 1735 | ||
| 1640 | _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m) | 1736 | _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m) = default; |
| 1641 | : __tree_(__m.__tree_.value_comp(), | ||
| 1642 | __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc())) { | ||
| 1643 | insert(__m.begin(), __m.end()); | ||
| 1644 | } | ||
| 1645 | 1737 | ||
| 1646 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) = default; | 1738 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) = default; |
| 1647 | 1739 | ||
| 1648 | # ifndef _LIBCPP_CXX03_LANG | 1740 | # ifndef _LIBCPP_CXX03_LANG |
| 1649 | 1741 | ||
| 1650 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value) = default; | 1742 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) = default; |
| 1651 | 1743 | ||
| 1652 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a); | 1744 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a) : __tree_(std::move(__m.__tree_), __a) {} |
| 1653 | 1745 | ||
| 1654 | _LIBCPP_HIDE_FROM_ABI multimap& | 1746 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) = default; |
| 1655 | operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) = default; | ||
| 1656 | 1747 | ||
| 1657 | _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 1748 | _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 1658 | : __tree_(__vc(__comp)) { | 1749 | : __tree_(__vc(__comp)) { |
| ... | @@ -1671,7 +1762,8 @@ public: | ... | @@ -1671,7 +1762,8 @@ public: |
| 1671 | # endif | 1762 | # endif |
| 1672 | 1763 | ||
| 1673 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list<value_type> __il) { | 1764 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list<value_type> __il) { |
| 1674 | __tree_.__assign_multi(__il.begin(), __il.end()); | 1765 | clear(); |
| 1766 | insert(__il.begin(), __il.end()); | ||
| 1675 | return *this; | 1767 | return *this; |
| 1676 | } | 1768 | } |
| 1677 | 1769 | ||
| ... | @@ -1679,37 +1771,42 @@ public: | ... | @@ -1679,37 +1771,42 @@ public: |
| 1679 | 1771 | ||
| 1680 | _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} | 1772 | _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} |
| 1681 | 1773 | ||
| 1682 | _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m, const allocator_type& __a) | 1774 | _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m, const allocator_type& __a) : __tree_(__m.__tree_, __a) {} |
| 1683 | : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) { | ||
| 1684 | insert(__m.begin(), __m.end()); | ||
| 1685 | } | ||
| 1686 | 1775 | ||
| 1687 | _LIBCPP_HIDE_FROM_ABI ~multimap() { | 1776 | _LIBCPP_HIDE_FROM_ABI ~multimap() { |
| 1688 | static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); | 1777 | static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 1689 | } | 1778 | } |
| 1690 | 1779 | ||
| 1691 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 1780 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 1692 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 1781 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| 1693 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } | 1782 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } |
| 1694 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } | 1783 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } |
| 1695 | 1784 | ||
| 1696 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } | 1785 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } |
| 1697 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 1786 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { |
| 1698 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | 1787 | return const_reverse_iterator(end()); |
| 1699 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 1788 | } |
| 1789 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | ||
| 1790 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | ||
| 1791 | return const_reverse_iterator(begin()); | ||
| 1792 | } | ||
| 1700 | 1793 | ||
| 1701 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | 1794 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } |
| 1702 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | 1795 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } |
| 1703 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 1796 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1704 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 1797 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1705 | 1798 | ||
| 1706 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 1799 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 1707 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 1800 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1708 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 1801 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1709 | 1802 | ||
| 1710 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__tree_.__alloc()); } | 1803 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 1711 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } | 1804 | return allocator_type(__tree_.__alloc()); |
| 1712 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } | 1805 | } |
| 1806 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } | ||
| 1807 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { | ||
| 1808 | return value_compare(__tree_.value_comp().key_comp()); | ||
| 1809 | } | ||
| 1713 | 1810 | ||
| 1714 | # ifndef _LIBCPP_CXX03_LANG | 1811 | # ifndef _LIBCPP_CXX03_LANG |
| 1715 | 1812 | ||
| ... | @@ -1751,17 +1848,13 @@ public: | ... | @@ -1751,17 +1848,13 @@ public: |
| 1751 | 1848 | ||
| 1752 | template <class _InputIterator> | 1849 | template <class _InputIterator> |
| 1753 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { | 1850 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { |
| 1754 | for (const_iterator __e = cend(); __f != __l; ++__f) | 1851 | __tree_.__insert_range_multi(__f, __l); |
| 1755 | __tree_.__emplace_hint_multi(__e.__i_, *__f); | ||
| 1756 | } | 1852 | } |
| 1757 | 1853 | ||
| 1758 | # if _LIBCPP_STD_VER >= 23 | 1854 | # if _LIBCPP_STD_VER >= 23 |
| 1759 | template <_ContainerCompatibleRange<value_type> _Range> | 1855 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1760 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1856 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1761 | const_iterator __end = cend(); | 1857 | __tree_.__insert_range_multi(ranges::begin(__range), ranges::end(__range)); |
| 1762 | for (auto&& __element : __range) { | ||
| 1763 | __tree_.__emplace_hint_multi(__end.__i_, std::forward<decltype(__element)>(__element)); | ||
| 1764 | } | ||
| 1765 | } | 1858 | } |
| 1766 | # endif | 1859 | # endif |
| 1767 | 1860 | ||
| ... | @@ -1783,10 +1876,10 @@ public: | ... | @@ -1783,10 +1876,10 @@ public: |
| 1783 | "node_type with incompatible allocator passed to multimap::insert()"); | 1876 | "node_type with incompatible allocator passed to multimap::insert()"); |
| 1784 | return __tree_.template __node_handle_insert_multi<node_type>(__hint.__i_, std::move(__nh)); | 1877 | return __tree_.template __node_handle_insert_multi<node_type>(__hint.__i_, std::move(__nh)); |
| 1785 | } | 1878 | } |
| 1786 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 1879 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 1787 | return __tree_.template __node_handle_extract<node_type>(__key); | 1880 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1788 | } | 1881 | } |
| 1789 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { | 1882 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { |
| 1790 | return __tree_.template __node_handle_extract<node_type>(__it.__i_); | 1883 | return __tree_.template __node_handle_extract<node_type>(__it.__i_); |
| 1791 | } | 1884 | } |
| 1792 | template <class _Compare2> | 1885 | template <class _Compare2> |
| ... | @@ -1821,75 +1914,89 @@ public: | ... | @@ -1821,75 +1914,89 @@ public: |
| 1821 | __tree_.swap(__m.__tree_); | 1914 | __tree_.swap(__m.__tree_); |
| 1822 | } | 1915 | } |
| 1823 | 1916 | ||
| 1824 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 1917 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1825 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 1918 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1826 | # if _LIBCPP_STD_VER >= 14 | 1919 | # if _LIBCPP_STD_VER >= 14 |
| 1827 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1920 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1828 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1921 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1829 | return __tree_.find(__k); | 1922 | return __tree_.find(__k); |
| 1830 | } | 1923 | } |
| 1831 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1924 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1832 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1925 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1833 | return __tree_.find(__k); | 1926 | return __tree_.find(__k); |
| 1834 | } | 1927 | } |
| 1835 | # endif | 1928 | # endif |
| 1836 | 1929 | ||
| 1837 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } | 1930 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 1931 | return __tree_.__count_multi(__k); | ||
| 1932 | } | ||
| 1838 | # if _LIBCPP_STD_VER >= 14 | 1933 | # if _LIBCPP_STD_VER >= 14 |
| 1839 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1934 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1840 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1935 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1841 | return __tree_.__count_multi(__k); | 1936 | return __tree_.__count_multi(__k); |
| 1842 | } | 1937 | } |
| 1843 | # endif | 1938 | # endif |
| 1844 | 1939 | ||
| 1845 | # if _LIBCPP_STD_VER >= 20 | 1940 | # if _LIBCPP_STD_VER >= 20 |
| 1846 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1941 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1847 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1942 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1848 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1943 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1849 | return find(__k) != end(); | 1944 | return find(__k) != end(); |
| 1850 | } | 1945 | } |
| 1851 | # endif // _LIBCPP_STD_VER >= 20 | 1946 | # endif // _LIBCPP_STD_VER >= 20 |
| 1852 | 1947 | ||
| 1853 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 1948 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { |
| 1854 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 1949 | return __tree_.__lower_bound_multi(__k); |
| 1950 | } | ||
| 1951 | |||
| 1952 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { | ||
| 1953 | return __tree_.__lower_bound_multi(__k); | ||
| 1954 | } | ||
| 1955 | |||
| 1855 | # if _LIBCPP_STD_VER >= 14 | 1956 | # if _LIBCPP_STD_VER >= 14 |
| 1856 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1957 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1857 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 1958 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1858 | return __tree_.lower_bound(__k); | 1959 | return __tree_.__lower_bound_multi(__k); |
| 1859 | } | 1960 | } |
| 1860 | 1961 | ||
| 1861 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1962 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1862 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 1963 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1863 | return __tree_.lower_bound(__k); | 1964 | return __tree_.__lower_bound_multi(__k); |
| 1864 | } | 1965 | } |
| 1865 | # endif | 1966 | # endif |
| 1866 | 1967 | ||
| 1867 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 1968 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { |
| 1868 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 1969 | return __tree_.__upper_bound_multi(__k); |
| 1970 | } | ||
| 1971 | |||
| 1972 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { | ||
| 1973 | return __tree_.__upper_bound_multi(__k); | ||
| 1974 | } | ||
| 1975 | |||
| 1869 | # if _LIBCPP_STD_VER >= 14 | 1976 | # if _LIBCPP_STD_VER >= 14 |
| 1870 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1977 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1871 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | 1978 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 1872 | return __tree_.upper_bound(__k); | 1979 | return __tree_.__upper_bound_multi(__k); |
| 1873 | } | 1980 | } |
| 1874 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1981 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1875 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 1982 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 1876 | return __tree_.upper_bound(__k); | 1983 | return __tree_.__upper_bound_multi(__k); |
| 1877 | } | 1984 | } |
| 1878 | # endif | 1985 | # endif |
| 1879 | 1986 | ||
| 1880 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 1987 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1881 | return __tree_.__equal_range_multi(__k); | 1988 | return __tree_.__equal_range_multi(__k); |
| 1882 | } | 1989 | } |
| 1883 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 1990 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1884 | return __tree_.__equal_range_multi(__k); | 1991 | return __tree_.__equal_range_multi(__k); |
| 1885 | } | 1992 | } |
| 1886 | # if _LIBCPP_STD_VER >= 14 | 1993 | # if _LIBCPP_STD_VER >= 14 |
| 1887 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1994 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1888 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1995 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1889 | return __tree_.__equal_range_multi(__k); | 1996 | return __tree_.__equal_range_multi(__k); |
| 1890 | } | 1997 | } |
| 1891 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1998 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1892 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1999 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1893 | return __tree_.__equal_range_multi(__k); | 2000 | return __tree_.__equal_range_multi(__k); |
| 1894 | } | 2001 | } |
| 1895 | # endif | 2002 | # endif |
| ... | @@ -1901,6 +2008,8 @@ private: | ... | @@ -1901,6 +2008,8 @@ private: |
| 1901 | 2008 | ||
| 1902 | typedef __map_node_destructor<__node_allocator> _Dp; | 2009 | typedef __map_node_destructor<__node_allocator> _Dp; |
| 1903 | typedef unique_ptr<__node, _Dp> __node_holder; | 2010 | typedef unique_ptr<__node, _Dp> __node_holder; |
| 2011 | |||
| 2012 | friend struct __specialized_algorithm<_Algorithm::__for_each, __single_range<multimap> >; | ||
| 1904 | }; | 2013 | }; |
| 1905 | 2014 | ||
| 1906 | # if _LIBCPP_STD_VER >= 17 | 2015 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1908,8 +2017,8 @@ template <class _InputIterator, | ... | @@ -1908,8 +2017,8 @@ template <class _InputIterator, |
| 1908 | class _Compare = less<__iter_key_type<_InputIterator>>, | 2017 | class _Compare = less<__iter_key_type<_InputIterator>>, |
| 1909 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, | 2018 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 1910 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 2019 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 1911 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 2020 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 1912 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2021 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1913 | multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) | 2022 | multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1914 | -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; | 2023 | -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 1915 | 2024 | ||
| ... | @@ -1917,8 +2026,8 @@ multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Al | ... | @@ -1917,8 +2026,8 @@ multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Al |
| 1917 | template <ranges::input_range _Range, | 2026 | template <ranges::input_range _Range, |
| 1918 | class _Compare = less<__range_key_type<_Range>>, | 2027 | class _Compare = less<__range_key_type<_Range>>, |
| 1919 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, | 2028 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, |
| 1920 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 2029 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 1921 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2030 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1922 | multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) | 2031 | multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1923 | -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; | 2032 | -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; |
| 1924 | # endif | 2033 | # endif |
| ... | @@ -1927,16 +2036,15 @@ template <class _Key, | ... | @@ -1927,16 +2036,15 @@ template <class _Key, |
| 1927 | class _Tp, | 2036 | class _Tp, |
| 1928 | class _Compare = less<remove_const_t<_Key>>, | 2037 | class _Compare = less<remove_const_t<_Key>>, |
| 1929 | class _Allocator = allocator<pair<const _Key, _Tp>>, | 2038 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 1930 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 2039 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 1931 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2040 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1932 | multimap(initializer_list<pair<_Key, _Tp>>, | 2041 | multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1933 | _Compare = _Compare(), | 2042 | -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; |
| 1934 | _Allocator = _Allocator()) -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; | ||
| 1935 | 2043 | ||
| 1936 | template <class _InputIterator, | 2044 | template <class _InputIterator, |
| 1937 | class _Allocator, | 2045 | class _Allocator, |
| 1938 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 2046 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 1939 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2047 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1940 | multimap(_InputIterator, _InputIterator, _Allocator) | 2048 | multimap(_InputIterator, _InputIterator, _Allocator) |
| 1941 | -> multimap<__iter_key_type<_InputIterator>, | 2049 | -> multimap<__iter_key_type<_InputIterator>, |
| 1942 | __iter_mapped_type<_InputIterator>, | 2050 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -1944,26 +2052,30 @@ multimap(_InputIterator, _InputIterator, _Allocator) | ... | @@ -1944,26 +2052,30 @@ multimap(_InputIterator, _InputIterator, _Allocator) |
| 1944 | _Allocator>; | 2052 | _Allocator>; |
| 1945 | 2053 | ||
| 1946 | # if _LIBCPP_STD_VER >= 23 | 2054 | # if _LIBCPP_STD_VER >= 23 |
| 1947 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2055 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1948 | multimap(from_range_t, _Range&&, _Allocator) | 2056 | multimap(from_range_t, _Range&&, _Allocator) |
| 1949 | -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; | 2057 | -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; |
| 1950 | # endif | 2058 | # endif |
| 1951 | 2059 | ||
| 1952 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 2060 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1953 | multimap(initializer_list<pair<_Key, _Tp>>, | 2061 | multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 1954 | _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; | 2062 | -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 1955 | # endif | 2063 | # endif |
| 1956 | 2064 | ||
| 1957 | # ifndef _LIBCPP_CXX03_LANG | 2065 | # if _LIBCPP_STD_VER >= 14 |
| 1958 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 2066 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1959 | multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) | 2067 | struct __specialized_algorithm<_Algorithm::__for_each, __single_range<multimap<_Key, _Tp, _Compare, _Allocator>>> { |
| 1960 | : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { | 2068 | using __map _LIBCPP_NODEBUG = multimap<_Key, _Tp, _Compare, _Allocator>; |
| 1961 | if (__a != __m.get_allocator()) { | 2069 | |
| 1962 | const_iterator __e = cend(); | 2070 | static const bool __has_algorithm = true; |
| 1963 | while (!__m.empty()) | 2071 | |
| 1964 | __tree_.__insert_multi_from_orphaned_node(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_)); | 2072 | template <class _Map, class _Func, class _Proj> |
| 2073 | _LIBCPP_HIDE_FROM_ABI static auto operator()(_Map&& __map, _Func __func, _Proj __proj) { | ||
| 2074 | auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()( | ||
| 2075 | __map.__tree_, std::move(__func), std::move(__proj)); | ||
| 2076 | return std::make_pair(__map.end(), std::move(__func2)); | ||
| 1965 | } | 2077 | } |
| 1966 | } | 2078 | }; |
| 1967 | # endif | 2079 | # endif |
| 1968 | 2080 | ||
| 1969 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 2081 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
lib/libcxx/include/math.h+19| ... | @@ -429,6 +429,25 @@ using std::__math::isnormal; | ... | @@ -429,6 +429,25 @@ using std::__math::isnormal; |
| 429 | using std::__math::isunordered; | 429 | using std::__math::isunordered; |
| 430 | # endif // _LIBCPP_MSVCRT | 430 | # endif // _LIBCPP_MSVCRT |
| 431 | 431 | ||
| 432 | # if defined(_LIBCPP_MSVCRT) && _LIBCPP_STD_VER >= 20 | ||
| 433 | // MS UCRT incorrectly defines some functions in a way not working with integer types. Until C++20, this was worked | ||
| 434 | // around by -fdelayed-template-parsing. Since C++20, we can use standard feature "requires" instead. | ||
| 435 | |||
| 436 | // TODO: Remove the workaround once UCRT fixes these functions. Note that this doesn't seem planned as of 2025-07 per | ||
| 437 | // https://developercommunity.visualstudio.com/t/10294165. | ||
| 438 | |||
| 439 | using std::__math::__ucrt::isfinite; | ||
| 440 | using std::__math::__ucrt::isgreater; | ||
| 441 | using std::__math::__ucrt::isgreaterequal; | ||
| 442 | using std::__math::__ucrt::isinf; | ||
| 443 | using std::__math::__ucrt::isless; | ||
| 444 | using std::__math::__ucrt::islessequal; | ||
| 445 | using std::__math::__ucrt::islessgreater; | ||
| 446 | using std::__math::__ucrt::isnan; | ||
| 447 | using std::__math::__ucrt::isnormal; | ||
| 448 | using std::__math::__ucrt::isunordered; | ||
| 449 | # endif // defined(_LIBCPP_MSVCRT) && _LIBCPP_STD_VER >= 20 | ||
| 450 | |||
| 432 | // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math | 451 | // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math |
| 433 | // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads | 452 | // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads |
| 434 | // templates. Functions are preferred over function templates during overload resolution, which means that our overload | 453 | // templates. Functions are preferred over function templates during overload resolution, which means that our overload |
lib/libcxx/include/mdspan+1-5| ... | @@ -450,11 +450,7 @@ namespace std { | ... | @@ -450,11 +450,7 @@ namespace std { |
| 450 | # include <__config> | 450 | # include <__config> |
| 451 | 451 | ||
| 452 | # if _LIBCPP_STD_VER >= 23 | 452 | # if _LIBCPP_STD_VER >= 23 |
| 453 | # include <__fwd/mdspan.h> // TODO(boomanaiden154): This is currently a | 453 | # include <__fwd/mdspan.h> |
| 454 | // non-standard extension to include | ||
| 455 | // std::dynamic_extent tracked by LWG issue 4275. | ||
| 456 | // This comment should be deleted or the include | ||
| 457 | // deleted upon resolution. | ||
| 458 | # include <__fwd/span.h> | 454 | # include <__fwd/span.h> |
| 459 | # include <__mdspan/default_accessor.h> | 455 | # include <__mdspan/default_accessor.h> |
| 460 | # include <__mdspan/extents.h> | 456 | # include <__mdspan/extents.h> |
lib/libcxx/include/mutex+29-19| ... | @@ -229,12 +229,12 @@ public: | ... | @@ -229,12 +229,12 @@ public: |
| 229 | recursive_mutex& operator=(const recursive_mutex&) = delete; | 229 | recursive_mutex& operator=(const recursive_mutex&) = delete; |
| 230 | 230 | ||
| 231 | void lock(); | 231 | void lock(); |
| 232 | bool try_lock() _NOEXCEPT; | 232 | [[__nodiscard__]] bool try_lock() _NOEXCEPT; |
| 233 | void unlock() _NOEXCEPT; | 233 | void unlock() _NOEXCEPT; |
| 234 | 234 | ||
| 235 | typedef __libcpp_recursive_mutex_t* native_handle_type; | 235 | typedef __libcpp_recursive_mutex_t* native_handle_type; |
| 236 | 236 | ||
| 237 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; } | 237 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; } |
| 238 | }; | 238 | }; |
| 239 | 239 | ||
| 240 | class _LIBCPP_EXPORTED_FROM_ABI timed_mutex { | 240 | class _LIBCPP_EXPORTED_FROM_ABI timed_mutex { |
| ... | @@ -251,14 +251,14 @@ public: | ... | @@ -251,14 +251,14 @@ public: |
| 251 | 251 | ||
| 252 | public: | 252 | public: |
| 253 | void lock(); | 253 | void lock(); |
| 254 | bool try_lock() _NOEXCEPT; | 254 | [[__nodiscard__]] bool try_lock() _NOEXCEPT; |
| 255 | template <class _Rep, class _Period> | 255 | template <class _Rep, class _Period> |
| 256 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | 256 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { |
| 257 | return try_lock_until(chrono::steady_clock::now() + __d); | 257 | return try_lock_until(chrono::steady_clock::now() + __d); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | template <class _Clock, class _Duration> | 260 | template <class _Clock, class _Duration> |
| 261 | _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | 261 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { |
| 262 | using namespace chrono; | 262 | using namespace chrono; |
| 263 | unique_lock<mutex> __lk(__m_); | 263 | unique_lock<mutex> __lk(__m_); |
| 264 | bool __no_timeout = _Clock::now() < __t; | 264 | bool __no_timeout = _Clock::now() < __t; |
| ... | @@ -288,14 +288,14 @@ public: | ... | @@ -288,14 +288,14 @@ public: |
| 288 | recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; | 288 | recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; |
| 289 | 289 | ||
| 290 | void lock(); | 290 | void lock(); |
| 291 | bool try_lock() _NOEXCEPT; | 291 | [[__nodiscard__]] bool try_lock() _NOEXCEPT; |
| 292 | template <class _Rep, class _Period> | 292 | template <class _Rep, class _Period> |
| 293 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | 293 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { |
| 294 | return try_lock_until(chrono::steady_clock::now() + __d); | 294 | return try_lock_until(chrono::steady_clock::now() + __d); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | template <class _Clock, class _Duration> | 297 | template <class _Clock, class _Duration> |
| 298 | _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | 298 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { |
| 299 | using namespace chrono; | 299 | using namespace chrono; |
| 300 | __thread_id __id = this_thread::get_id(); | 300 | __thread_id __id = this_thread::get_id(); |
| 301 | unique_lock<mutex> __lk(__m_); | 301 | unique_lock<mutex> __lk(__m_); |
| ... | @@ -320,7 +320,7 @@ public: | ... | @@ -320,7 +320,7 @@ public: |
| 320 | }; | 320 | }; |
| 321 | 321 | ||
| 322 | template <class _L0, class _L1> | 322 | template <class _L0, class _L1> |
| 323 | _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { | 323 | [[__nodiscard__]] _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { |
| 324 | unique_lock<_L0> __u0(__l0, try_to_lock_t()); | 324 | unique_lock<_L0> __u0(__l0, try_to_lock_t()); |
| 325 | if (__u0.owns_lock()) { | 325 | if (__u0.owns_lock()) { |
| 326 | if (__l1.try_lock()) { | 326 | if (__l1.try_lock()) { |
| ... | @@ -335,7 +335,8 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { | ... | @@ -335,7 +335,8 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { |
| 335 | # ifndef _LIBCPP_CXX03_LANG | 335 | # ifndef _LIBCPP_CXX03_LANG |
| 336 | 336 | ||
| 337 | template <class _L0, class _L1, class _L2, class... _L3> | 337 | template <class _L0, class _L1, class _L2, class... _L3> |
| 338 | _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { | 338 | [[__nodiscard__]] _LIBCPP_NO_THREAD_SAFETY_ANALYSIS |
| 339 | _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { | ||
| 339 | int __r = 0; | 340 | int __r = 0; |
| 340 | unique_lock<_L0> __u0(__l0, try_to_lock); | 341 | unique_lock<_L0> __u0(__l0, try_to_lock); |
| 341 | if (__u0.owns_lock()) { | 342 | if (__u0.owns_lock()) { |
| ... | @@ -350,8 +351,11 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3 | ... | @@ -350,8 +351,11 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3 |
| 350 | 351 | ||
| 351 | # endif // _LIBCPP_CXX03_LANG | 352 | # endif // _LIBCPP_CXX03_LANG |
| 352 | 353 | ||
| 354 | // We're using unique_lock to implement the functions, which thread annotations don't support. So we have to disable | ||
| 355 | // the analysis inside the function. | ||
| 353 | template <class _L0, class _L1> | 356 | template <class _L0, class _L1> |
| 354 | _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) { | 357 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) |
| 358 | _LIBCPP_ACQUIRE_CAPABILITY(__l0, __l1) { | ||
| 355 | while (true) { | 359 | while (true) { |
| 356 | { | 360 | { |
| 357 | unique_lock<_L0> __u0(__l0); | 361 | unique_lock<_L0> __u0(__l0); |
| ... | @@ -375,7 +379,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) { | ... | @@ -375,7 +379,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) { |
| 375 | # ifndef _LIBCPP_CXX03_LANG | 379 | # ifndef _LIBCPP_CXX03_LANG |
| 376 | 380 | ||
| 377 | template <class _L0, class _L1, class _L2, class... _L3> | 381 | template <class _L0, class _L1, class _L2, class... _L3> |
| 378 | void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { | 382 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { |
| 379 | while (true) { | 383 | while (true) { |
| 380 | switch (__i) { | 384 | switch (__i) { |
| 381 | case 0: { | 385 | case 0: { |
| ... | @@ -410,8 +414,14 @@ void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { | ... | @@ -410,8 +414,14 @@ void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { |
| 410 | } | 414 | } |
| 411 | } | 415 | } |
| 412 | 416 | ||
| 417 | // We're using unique_lock to implement the functions, which thread annotations don't support. So we have to disable | ||
| 418 | // the analysis inside the function. | ||
| 413 | template <class _L0, class _L1, class _L2, class... _L3> | 419 | template <class _L0, class _L1, class _L2, class... _L3> |
| 414 | inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { | 420 | _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) |
| 421 | # if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101 | ||
| 422 | _LIBCPP_ACQUIRE_CAPABILITY(__l0, __l1, __l2, __l3...) | ||
| 423 | # endif | ||
| 424 | { | ||
| 415 | std::__lock_first(0, __l0, __l1, __l2, __l3...); | 425 | std::__lock_first(0, __l0, __l1, __l2, __l3...); |
| 416 | } | 426 | } |
| 417 | 427 | ||
| ... | @@ -469,17 +479,14 @@ public: | ... | @@ -469,17 +479,14 @@ public: |
| 469 | 479 | ||
| 470 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {} | 480 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {} |
| 471 | 481 | ||
| 472 | _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { | 482 | _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { __unlock_unpack(make_index_sequence<sizeof...(_MArgs)>(), __t_); } |
| 473 | typedef typename __make_tuple_indices<sizeof...(_MArgs)>::type _Indices; | ||
| 474 | __unlock_unpack(_Indices{}, __t_); | ||
| 475 | } | ||
| 476 | 483 | ||
| 477 | scoped_lock(scoped_lock const&) = delete; | 484 | scoped_lock(scoped_lock const&) = delete; |
| 478 | scoped_lock& operator=(scoped_lock const&) = delete; | 485 | scoped_lock& operator=(scoped_lock const&) = delete; |
| 479 | 486 | ||
| 480 | private: | 487 | private: |
| 481 | template <size_t... _Indx> | 488 | template <size_t... _Indx> |
| 482 | _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) { | 489 | _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(index_sequence<_Indx...>, _MutexTuple& __mt) { |
| 483 | (std::get<_Indx>(__mt).unlock(), ...); | 490 | (std::get<_Indx>(__mt).unlock(), ...); |
| 484 | } | 491 | } |
| 485 | 492 | ||
| ... | @@ -494,6 +501,10 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -494,6 +501,10 @@ _LIBCPP_END_NAMESPACE_STD |
| 494 | 501 | ||
| 495 | _LIBCPP_POP_MACROS | 502 | _LIBCPP_POP_MACROS |
| 496 | 503 | ||
| 504 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | ||
| 505 | # include <typeinfo> | ||
| 506 | # endif | ||
| 507 | |||
| 497 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 508 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 498 | # include <atomic> | 509 | # include <atomic> |
| 499 | # include <concepts> | 510 | # include <concepts> |
| ... | @@ -507,7 +518,6 @@ _LIBCPP_POP_MACROS | ... | @@ -507,7 +518,6 @@ _LIBCPP_POP_MACROS |
| 507 | # include <stdexcept> | 518 | # include <stdexcept> |
| 508 | # include <system_error> | 519 | # include <system_error> |
| 509 | # include <type_traits> | 520 | # include <type_traits> |
| 510 | # include <typeinfo> | ||
| 511 | # endif | 521 | # endif |
| 512 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 522 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 513 | 523 |
lib/libcxx/include/optional+644-149| ... | @@ -20,6 +20,11 @@ namespace std { | ... | @@ -20,6 +20,11 @@ namespace std { |
| 20 | template <class T> | 20 | template <class T> |
| 21 | class optional; | 21 | class optional; |
| 22 | 22 | ||
| 23 | template<class T> | ||
| 24 | constexpr bool ranges::enable_view<optional<T>> = true; | ||
| 25 | template<class T> | ||
| 26 | constexpr auto format_kind<optional<T>> = range_format::disabled; | ||
| 27 | |||
| 23 | template<class T> | 28 | template<class T> |
| 24 | concept is-derived-from-optional = requires(const T& t) { // exposition only | 29 | concept is-derived-from-optional = requires(const T& t) { // exposition only |
| 25 | []<class U>(const optional<U>&){ }(t); | 30 | []<class U>(const optional<U>&){ }(t); |
| ... | @@ -102,6 +107,8 @@ namespace std { | ... | @@ -102,6 +107,8 @@ namespace std { |
| 102 | class optional { | 107 | class optional { |
| 103 | public: | 108 | public: |
| 104 | using value_type = T; | 109 | using value_type = T; |
| 110 | using iterator = implementation-defined; // see [optional.iterators] | ||
| 111 | using const_iterator = implementation-defined; // see [optional.iterators] | ||
| 105 | 112 | ||
| 106 | // [optional.ctor], constructors | 113 | // [optional.ctor], constructors |
| 107 | constexpr optional() noexcept; | 114 | constexpr optional() noexcept; |
| ... | @@ -112,7 +119,7 @@ namespace std { | ... | @@ -112,7 +119,7 @@ namespace std { |
| 112 | constexpr explicit optional(in_place_t, Args &&...); | 119 | constexpr explicit optional(in_place_t, Args &&...); |
| 113 | template<class U, class... Args> | 120 | template<class U, class... Args> |
| 114 | constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...); | 121 | constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...); |
| 115 | template<class U = T> | 122 | template<class U = remove_cv_t<T>> |
| 116 | constexpr explicit(see-below) optional(U &&); | 123 | constexpr explicit(see-below) optional(U &&); |
| 117 | template<class U> | 124 | template<class U> |
| 118 | explicit(see-below) optional(const optional<U> &); // constexpr in C++20 | 125 | explicit(see-below) optional(const optional<U> &); // constexpr in C++20 |
| ... | @@ -126,7 +133,7 @@ namespace std { | ... | @@ -126,7 +133,7 @@ namespace std { |
| 126 | optional &operator=(nullopt_t) noexcept; // constexpr in C++20 | 133 | optional &operator=(nullopt_t) noexcept; // constexpr in C++20 |
| 127 | constexpr optional &operator=(const optional &); | 134 | constexpr optional &operator=(const optional &); |
| 128 | constexpr optional &operator=(optional &&) noexcept(see below); | 135 | constexpr optional &operator=(optional &&) noexcept(see below); |
| 129 | template<class U = T> optional &operator=(U &&); // constexpr in C++20 | 136 | template<class U = remove_cv_t<T>> optional &operator=(U &&); // constexpr in C++20 |
| 130 | template<class U> optional &operator=(const optional<U> &); // constexpr in C++20 | 137 | template<class U> optional &operator=(const optional<U> &); // constexpr in C++20 |
| 131 | template<class U> optional &operator=(optional<U> &&); // constexpr in C++20 | 138 | template<class U> optional &operator=(optional<U> &&); // constexpr in C++20 |
| 132 | template<class... Args> T& emplace(Args &&...); // constexpr in C++20 | 139 | template<class... Args> T& emplace(Args &&...); // constexpr in C++20 |
| ... | @@ -135,6 +142,12 @@ namespace std { | ... | @@ -135,6 +142,12 @@ namespace std { |
| 135 | // [optional.swap], swap | 142 | // [optional.swap], swap |
| 136 | void swap(optional &) noexcept(see below ); // constexpr in C++20 | 143 | void swap(optional &) noexcept(see below ); // constexpr in C++20 |
| 137 | 144 | ||
| 145 | // [optional.iterators], iterator support | ||
| 146 | constexpr iterator begin() noexcept; | ||
| 147 | constexpr const_iterator begin() const noexcept; | ||
| 148 | constexpr iterator end() noexcept; | ||
| 149 | constexpr const_iterator end() const noexcept; | ||
| 150 | |||
| 138 | // [optional.observe], observers | 151 | // [optional.observe], observers |
| 139 | constexpr T const *operator->() const noexcept; | 152 | constexpr T const *operator->() const noexcept; |
| 140 | constexpr T *operator->() noexcept; | 153 | constexpr T *operator->() noexcept; |
| ... | @@ -148,8 +161,8 @@ namespace std { | ... | @@ -148,8 +161,8 @@ namespace std { |
| 148 | constexpr T &value() &; | 161 | constexpr T &value() &; |
| 149 | constexpr T &&value() &&; | 162 | constexpr T &&value() &&; |
| 150 | constexpr const T &&value() const &&; | 163 | constexpr const T &&value() const &&; |
| 151 | template<class U> constexpr T value_or(U &&) const &; | 164 | template<class U = remove_cv_t<T>> constexpr T value_or(U &&) const &; |
| 152 | template<class U> constexpr T value_or(U &&) &&; | 165 | template<class U = remove_cv_t<T>> constexpr T value_or(U &&) &&; |
| 153 | 166 | ||
| 154 | // [optional.monadic], monadic operations | 167 | // [optional.monadic], monadic operations |
| 155 | template<class F> constexpr auto and_then(F&& f) &; // since C++23 | 168 | template<class F> constexpr auto and_then(F&& f) &; // since C++23 |
| ... | @@ -173,6 +186,71 @@ namespace std { | ... | @@ -173,6 +186,71 @@ namespace std { |
| 173 | template<class T> | 186 | template<class T> |
| 174 | optional(T) -> optional<T>; | 187 | optional(T) -> optional<T>; |
| 175 | 188 | ||
| 189 | template<class T> | ||
| 190 | class optional<T&> { // since C++26 | ||
| 191 | public: | ||
| 192 | using value_type = T; | ||
| 193 | using iterator = implementation-defined; // see [optional.ref.iterators] | ||
| 194 | |||
| 195 | public: | ||
| 196 | // [optional.ref.ctor], constructors | ||
| 197 | constexpr optional() noexcept = default; | ||
| 198 | constexpr optional(nullopt_t) noexcept : optional() {} | ||
| 199 | constexpr optional(const optional& rhs) noexcept = default; | ||
| 200 | |||
| 201 | template<class Arg> | ||
| 202 | constexpr explicit optional(in_place_t, Arg&& arg); | ||
| 203 | template<class U> | ||
| 204 | constexpr explicit(see below) optional(U&& u) noexcept(see below); | ||
| 205 | template<class U> | ||
| 206 | constexpr explicit(see below) optional(optional<U>& rhs) noexcept(see below); | ||
| 207 | template<class U> | ||
| 208 | constexpr explicit(see below) optional(const optional<U>& rhs) noexcept(see below); | ||
| 209 | template<class U> | ||
| 210 | constexpr explicit(see below) optional(optional<U>&& rhs) noexcept(see below); | ||
| 211 | template<class U> | ||
| 212 | constexpr explicit(see below) optional(const optional<U>&& rhs) noexcept(see below); | ||
| 213 | |||
| 214 | constexpr ~optional() = default; | ||
| 215 | |||
| 216 | // [optional.ref.assign], assignment | ||
| 217 | constexpr optional& operator=(nullopt_t) noexcept; | ||
| 218 | constexpr optional& operator=(const optional& rhs) noexcept = default; | ||
| 219 | |||
| 220 | template<class U> constexpr T& emplace(U&& u) noexcept(see below); | ||
| 221 | |||
| 222 | // [optional.ref.swap], swap | ||
| 223 | constexpr void swap(optional& rhs) noexcept; | ||
| 224 | |||
| 225 | // [optional.ref.iterators], iterator support | ||
| 226 | constexpr iterator begin() const noexcept; | ||
| 227 | constexpr iterator end() const noexcept; | ||
| 228 | |||
| 229 | // [optional.ref.observe], observers | ||
| 230 | constexpr T* operator->() const noexcept; | ||
| 231 | constexpr T& operator*() const noexcept; | ||
| 232 | constexpr explicit operator bool() const noexcept; | ||
| 233 | constexpr bool has_value() const noexcept; | ||
| 234 | constexpr T& value() const; // freestanding-deleted | ||
| 235 | template<class U = remove_cv_t<T>> | ||
| 236 | constexpr remove_cv_t<T> value_or(U&& u) const; | ||
| 237 | |||
| 238 | // [optional.ref.monadic], monadic operations | ||
| 239 | template<class F> constexpr auto and_then(F&& f) const; | ||
| 240 | template<class F> constexpr optional<invoke_result_t<F, T&>> transform(F&& f) const; | ||
| 241 | template<class F> constexpr optional or_else(F&& f) const; | ||
| 242 | |||
| 243 | // [optional.ref.mod], modifiers | ||
| 244 | constexpr void reset() noexcept; | ||
| 245 | |||
| 246 | private: | ||
| 247 | T* val = nullptr; // exposition only | ||
| 248 | |||
| 249 | // [optional.ref.expos], exposition only helper functions | ||
| 250 | template<class U> | ||
| 251 | constexpr void convert-ref-init-val(U&& u); // exposition only | ||
| 252 | }; | ||
| 253 | |||
| 176 | } // namespace std | 254 | } // namespace std |
| 177 | 255 | ||
| 178 | */ | 256 | */ |
| ... | @@ -186,13 +264,19 @@ namespace std { | ... | @@ -186,13 +264,19 @@ namespace std { |
| 186 | # include <__compare/three_way_comparable.h> | 264 | # include <__compare/three_way_comparable.h> |
| 187 | # include <__concepts/invocable.h> | 265 | # include <__concepts/invocable.h> |
| 188 | # include <__config> | 266 | # include <__config> |
| 267 | # include <__cstddef/ptrdiff_t.h> | ||
| 189 | # include <__exception/exception.h> | 268 | # include <__exception/exception.h> |
| 269 | # include <__format/range_format.h> | ||
| 190 | # include <__functional/hash.h> | 270 | # include <__functional/hash.h> |
| 191 | # include <__functional/invoke.h> | 271 | # include <__functional/invoke.h> |
| 192 | # include <__functional/unary_function.h> | 272 | # include <__functional/unary_function.h> |
| 193 | # include <__fwd/functional.h> | 273 | # include <__fwd/functional.h> |
| 274 | # include <__iterator/bounded_iter.h> | ||
| 275 | # include <__iterator/wrap_iter.h> | ||
| 194 | # include <__memory/addressof.h> | 276 | # include <__memory/addressof.h> |
| 195 | # include <__memory/construct_at.h> | 277 | # include <__memory/construct_at.h> |
| 278 | # include <__ranges/enable_borrowed_range.h> | ||
| 279 | # include <__ranges/enable_view.h> | ||
| 196 | # include <__tuple/sfinae_helpers.h> | 280 | # include <__tuple/sfinae_helpers.h> |
| 197 | # include <__type_traits/add_pointer.h> | 281 | # include <__type_traits/add_pointer.h> |
| 198 | # include <__type_traits/conditional.h> | 282 | # include <__type_traits/conditional.h> |
| ... | @@ -200,6 +284,7 @@ namespace std { | ... | @@ -200,6 +284,7 @@ namespace std { |
| 200 | # include <__type_traits/decay.h> | 284 | # include <__type_traits/decay.h> |
| 201 | # include <__type_traits/disjunction.h> | 285 | # include <__type_traits/disjunction.h> |
| 202 | # include <__type_traits/enable_if.h> | 286 | # include <__type_traits/enable_if.h> |
| 287 | # include <__type_traits/integral_constant.h> | ||
| 203 | # include <__type_traits/invoke.h> | 288 | # include <__type_traits/invoke.h> |
| 204 | # include <__type_traits/is_array.h> | 289 | # include <__type_traits/is_array.h> |
| 205 | # include <__type_traits/is_assignable.h> | 290 | # include <__type_traits/is_assignable.h> |
| ... | @@ -207,11 +292,11 @@ namespace std { | ... | @@ -207,11 +292,11 @@ namespace std { |
| 207 | # include <__type_traits/is_convertible.h> | 292 | # include <__type_traits/is_convertible.h> |
| 208 | # include <__type_traits/is_core_convertible.h> | 293 | # include <__type_traits/is_core_convertible.h> |
| 209 | # include <__type_traits/is_destructible.h> | 294 | # include <__type_traits/is_destructible.h> |
| 295 | # include <__type_traits/is_function.h> | ||
| 210 | # include <__type_traits/is_nothrow_assignable.h> | 296 | # include <__type_traits/is_nothrow_assignable.h> |
| 211 | # include <__type_traits/is_nothrow_constructible.h> | 297 | # include <__type_traits/is_nothrow_constructible.h> |
| 212 | # include <__type_traits/is_object.h> | 298 | # include <__type_traits/is_object.h> |
| 213 | # include <__type_traits/is_reference.h> | 299 | # include <__type_traits/is_reference.h> |
| 214 | # include <__type_traits/is_replaceable.h> | ||
| 215 | # include <__type_traits/is_same.h> | 300 | # include <__type_traits/is_same.h> |
| 216 | # include <__type_traits/is_scalar.h> | 301 | # include <__type_traits/is_scalar.h> |
| 217 | # include <__type_traits/is_swappable.h> | 302 | # include <__type_traits/is_swappable.h> |
| ... | @@ -220,6 +305,7 @@ namespace std { | ... | @@ -220,6 +305,7 @@ namespace std { |
| 220 | # include <__type_traits/is_trivially_destructible.h> | 305 | # include <__type_traits/is_trivially_destructible.h> |
| 221 | # include <__type_traits/is_trivially_relocatable.h> | 306 | # include <__type_traits/is_trivially_relocatable.h> |
| 222 | # include <__type_traits/negation.h> | 307 | # include <__type_traits/negation.h> |
| 308 | # include <__type_traits/reference_constructs_from_temporary.h> | ||
| 223 | # include <__type_traits/remove_const.h> | 309 | # include <__type_traits/remove_const.h> |
| 224 | # include <__type_traits/remove_cv.h> | 310 | # include <__type_traits/remove_cv.h> |
| 225 | # include <__type_traits/remove_cvref.h> | 311 | # include <__type_traits/remove_cvref.h> |
| ... | @@ -255,7 +341,7 @@ public: | ... | @@ -255,7 +341,7 @@ public: |
| 255 | _LIBCPP_HIDE_FROM_ABI bad_optional_access& operator=(const bad_optional_access&) _NOEXCEPT = default; | 341 | _LIBCPP_HIDE_FROM_ABI bad_optional_access& operator=(const bad_optional_access&) _NOEXCEPT = default; |
| 256 | // Get the key function ~bad_optional_access() into the dylib | 342 | // Get the key function ~bad_optional_access() into the dylib |
| 257 | ~bad_optional_access() _NOEXCEPT override; | 343 | ~bad_optional_access() _NOEXCEPT override; |
| 258 | const char* what() const _NOEXCEPT override; | 344 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 259 | }; | 345 | }; |
| 260 | 346 | ||
| 261 | } // namespace std | 347 | } // namespace std |
| ... | @@ -358,7 +444,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> { | ... | @@ -358,7 +444,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> { |
| 358 | using value_type = _Tp; | 444 | using value_type = _Tp; |
| 359 | using __base::__base; | 445 | using __base::__base; |
| 360 | 446 | ||
| 361 | _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__engaged_; } | 447 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__engaged_; } |
| 362 | 448 | ||
| 363 | _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() & noexcept { return this->__val_; } | 449 | _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() & noexcept { return this->__val_; } |
| 364 | _LIBCPP_HIDE_FROM_ABI constexpr const value_type& __get() const& noexcept { return this->__val_; } | 450 | _LIBCPP_HIDE_FROM_ABI constexpr const value_type& __get() const& noexcept { return this->__val_; } |
| ... | @@ -390,58 +476,60 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> { | ... | @@ -390,58 +476,60 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> { |
| 390 | __construct(std::forward<_That>(__opt).__get()); | 476 | __construct(std::forward<_That>(__opt).__get()); |
| 391 | } | 477 | } |
| 392 | } | 478 | } |
| 479 | |||
| 480 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | ||
| 481 | __swap(__optional_storage_base& __rhs) noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_swappable_v<_Tp>) { | ||
| 482 | using std::swap; | ||
| 483 | if (this->has_value() == __rhs.has_value()) { | ||
| 484 | if (this->has_value()) | ||
| 485 | swap(this->__get(), __rhs.__get()); | ||
| 486 | } else { | ||
| 487 | if (this->has_value()) { | ||
| 488 | __rhs.__construct(std::move(this->__get())); | ||
| 489 | this->reset(); | ||
| 490 | } else { | ||
| 491 | this->__construct(std::move(__rhs.__get())); | ||
| 492 | __rhs.reset(); | ||
| 493 | } | ||
| 494 | } | ||
| 495 | } | ||
| 393 | }; | 496 | }; |
| 394 | 497 | ||
| 395 | // optional<T&> is currently required to be ill-formed. However, it may | ||
| 396 | // be allowed in the future. For this reason, it has already been implemented | ||
| 397 | // to ensure we can make the change in an ABI-compatible manner. | ||
| 398 | template <class _Tp> | 498 | template <class _Tp> |
| 399 | struct __optional_storage_base<_Tp, true> { | 499 | struct __optional_storage_base<_Tp, true> { |
| 400 | using value_type = _Tp; | 500 | using value_type = _Tp; |
| 401 | using __raw_type _LIBCPP_NODEBUG = remove_reference_t<_Tp>; | 501 | using __raw_type _LIBCPP_NODEBUG = remove_reference_t<_Tp>; |
| 402 | __raw_type* __value_; | 502 | __raw_type* __value_; |
| 403 | 503 | ||
| 504 | _LIBCPP_HIDE_FROM_ABI constexpr __optional_storage_base() noexcept : __value_(nullptr) {} | ||
| 505 | |||
| 404 | template <class _Up> | 506 | template <class _Up> |
| 405 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() { | 507 | _LIBCPP_HIDE_FROM_ABI constexpr void __convert_init_ref_val(_Up&& __val) noexcept { |
| 406 | using _RawUp = __libcpp_remove_reference_t<_Up>; | 508 | _Tp& __r(std::forward<_Up>(__val)); |
| 407 | using _UpPtr = _RawUp*; | 509 | __value_ = std::addressof(__r); |
| 408 | using _RawTp = __libcpp_remove_reference_t<_Tp>; | ||
| 409 | using _TpPtr = _RawTp*; | ||
| 410 | using _CheckLValueArg = | ||
| 411 | integral_constant<bool, | ||
| 412 | (is_lvalue_reference<_Up>::value && is_convertible<_UpPtr, _TpPtr>::value) || | ||
| 413 | is_same<_RawUp, reference_wrapper<_RawTp>>::value || | ||
| 414 | is_same<_RawUp, reference_wrapper<__remove_const_t<_RawTp>>>::value >; | ||
| 415 | return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value) || | ||
| 416 | (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value && | ||
| 417 | is_convertible<_UpPtr, _TpPtr>::value); | ||
| 418 | } | 510 | } |
| 419 | 511 | ||
| 420 | _LIBCPP_HIDE_FROM_ABI constexpr __optional_storage_base() noexcept : __value_(nullptr) {} | ||
| 421 | |||
| 422 | template <class _UArg> | 512 | template <class _UArg> |
| 423 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_storage_base(in_place_t, _UArg&& __uarg) | 513 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_storage_base(in_place_t, _UArg&& __uarg) { |
| 424 | : __value_(std::addressof(__uarg)) { | 514 | static_assert(!__reference_constructs_from_temporary_v<_Tp, _UArg>, |
| 425 | static_assert(__can_bind_reference<_UArg>(), | 515 | "Attempted to construct a reference element in optional from a " |
| 426 | "Attempted to construct a reference element in tuple from a " | ||
| 427 | "possible temporary"); | 516 | "possible temporary"); |
| 517 | __convert_init_ref_val(std::forward<_UArg>(__uarg)); | ||
| 428 | } | 518 | } |
| 429 | 519 | ||
| 430 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { __value_ = nullptr; } | 520 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { __value_ = nullptr; } |
| 431 | 521 | ||
| 432 | _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __value_ != nullptr; } | 522 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __value_ != nullptr; } |
| 433 | |||
| 434 | _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() const& noexcept { return *__value_; } | ||
| 435 | 523 | ||
| 436 | _LIBCPP_HIDE_FROM_ABI constexpr value_type&& __get() const&& noexcept { return std::forward<value_type>(*__value_); } | 524 | _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() const noexcept { return *__value_; } |
| 437 | 525 | ||
| 438 | template <class _UArg> | 526 | template <class _UArg> |
| 439 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val) { | 527 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val) { |
| 440 | _LIBCPP_ASSERT_INTERNAL(!has_value(), "__construct called for engaged __optional_storage"); | 528 | _LIBCPP_ASSERT_INTERNAL(!has_value(), "__construct called for engaged __optional_storage"); |
| 441 | static_assert(__can_bind_reference<_UArg>(), | 529 | static_assert(!__reference_constructs_from_temporary_v<_Tp, _UArg>, |
| 442 | "Attempted to construct a reference element in tuple from a " | 530 | "Attempted to construct a reference element in tuple from a " |
| 443 | "possible temporary"); | 531 | "possible temporary"); |
| 444 | __value_ = std::addressof(__val); | 532 | __convert_init_ref_val(std::forward<_UArg>(__val)); |
| 445 | } | 533 | } |
| 446 | 534 | ||
| 447 | template <class _That> | 535 | template <class _That> |
| ... | @@ -462,9 +550,13 @@ struct __optional_storage_base<_Tp, true> { | ... | @@ -462,9 +550,13 @@ struct __optional_storage_base<_Tp, true> { |
| 462 | __construct(std::forward<_That>(__opt).__get()); | 550 | __construct(std::forward<_That>(__opt).__get()); |
| 463 | } | 551 | } |
| 464 | } | 552 | } |
| 553 | |||
| 554 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __swap(__optional_storage_base& __rhs) noexcept { | ||
| 555 | std::swap(__value_, __rhs.__value_); | ||
| 556 | } | ||
| 465 | }; | 557 | }; |
| 466 | 558 | ||
| 467 | template <class _Tp, bool = is_trivially_copy_constructible<_Tp>::value> | 559 | template <class _Tp, bool = is_trivially_copy_constructible_v<_Tp> || is_lvalue_reference_v<_Tp>> |
| 468 | struct __optional_copy_base : __optional_storage_base<_Tp> { | 560 | struct __optional_copy_base : __optional_storage_base<_Tp> { |
| 469 | using __optional_storage_base<_Tp>::__optional_storage_base; | 561 | using __optional_storage_base<_Tp>::__optional_storage_base; |
| 470 | }; | 562 | }; |
| ... | @@ -484,7 +576,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp> { | ... | @@ -484,7 +576,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp> { |
| 484 | _LIBCPP_HIDE_FROM_ABI __optional_copy_base& operator=(__optional_copy_base&&) = default; | 576 | _LIBCPP_HIDE_FROM_ABI __optional_copy_base& operator=(__optional_copy_base&&) = default; |
| 485 | }; | 577 | }; |
| 486 | 578 | ||
| 487 | template <class _Tp, bool = is_trivially_move_constructible<_Tp>::value> | 579 | template <class _Tp, bool = is_trivially_move_constructible_v<_Tp> || is_lvalue_reference_v<_Tp>> |
| 488 | struct __optional_move_base : __optional_copy_base<_Tp> { | 580 | struct __optional_move_base : __optional_copy_base<_Tp> { |
| 489 | using __optional_copy_base<_Tp>::__optional_copy_base; | 581 | using __optional_copy_base<_Tp>::__optional_copy_base; |
| 490 | }; | 582 | }; |
| ... | @@ -507,8 +599,9 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp> { | ... | @@ -507,8 +599,9 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp> { |
| 507 | }; | 599 | }; |
| 508 | 600 | ||
| 509 | template <class _Tp, | 601 | template <class _Tp, |
| 510 | bool = is_trivially_destructible<_Tp>::value && is_trivially_copy_constructible<_Tp>::value && | 602 | bool = (is_trivially_destructible_v<_Tp> && is_trivially_copy_constructible_v<_Tp> && |
| 511 | is_trivially_copy_assignable<_Tp>::value> | 603 | is_trivially_copy_assignable_v<_Tp>) || |
| 604 | is_lvalue_reference_v<_Tp>> | ||
| 512 | struct __optional_copy_assign_base : __optional_move_base<_Tp> { | 605 | struct __optional_copy_assign_base : __optional_move_base<_Tp> { |
| 513 | using __optional_move_base<_Tp>::__optional_move_base; | 606 | using __optional_move_base<_Tp>::__optional_move_base; |
| 514 | }; | 607 | }; |
| ... | @@ -531,8 +624,9 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp> { | ... | @@ -531,8 +624,9 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp> { |
| 531 | }; | 624 | }; |
| 532 | 625 | ||
| 533 | template <class _Tp, | 626 | template <class _Tp, |
| 534 | bool = is_trivially_destructible<_Tp>::value && is_trivially_move_constructible<_Tp>::value && | 627 | bool = (is_trivially_destructible_v<_Tp> && is_trivially_move_constructible_v<_Tp> && |
| 535 | is_trivially_move_assignable<_Tp>::value> | 628 | is_trivially_move_assignable_v<_Tp>) || |
| 629 | is_lvalue_reference_v<_Tp>> | ||
| 536 | struct __optional_move_assign_base : __optional_copy_assign_base<_Tp> { | 630 | struct __optional_move_assign_base : __optional_copy_assign_base<_Tp> { |
| 537 | using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base; | 631 | using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base; |
| 538 | }; | 632 | }; |
| ... | @@ -561,12 +655,24 @@ using __optional_sfinae_ctor_base_t _LIBCPP_NODEBUG = | ... | @@ -561,12 +655,24 @@ using __optional_sfinae_ctor_base_t _LIBCPP_NODEBUG = |
| 561 | 655 | ||
| 562 | template <class _Tp> | 656 | template <class _Tp> |
| 563 | using __optional_sfinae_assign_base_t _LIBCPP_NODEBUG = | 657 | using __optional_sfinae_assign_base_t _LIBCPP_NODEBUG = |
| 564 | __sfinae_assign_base< (is_copy_constructible<_Tp>::value && is_copy_assignable<_Tp>::value), | 658 | __sfinae_assign_base< (is_copy_constructible_v<_Tp> && is_copy_assignable_v<_Tp>) || is_lvalue_reference_v<_Tp>, |
| 565 | (is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value) >; | 659 | (is_move_constructible_v<_Tp> && is_move_assignable_v<_Tp>) || is_lvalue_reference_v<_Tp>>; |
| 566 | 660 | ||
| 567 | template <class _Tp> | 661 | template <class _Tp> |
| 568 | class optional; | 662 | class optional; |
| 569 | 663 | ||
| 664 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR | ||
| 665 | template <class _Tp> | ||
| 666 | constexpr bool ranges::enable_view<optional<_Tp>> = true; | ||
| 667 | |||
| 668 | template <class _Tp> | ||
| 669 | constexpr range_format format_kind<optional<_Tp>> = range_format::disabled; | ||
| 670 | |||
| 671 | template <class _Tp> | ||
| 672 | constexpr bool ranges::enable_borrowed_range<optional<_Tp&>> = true; | ||
| 673 | |||
| 674 | # endif | ||
| 675 | |||
| 570 | # if _LIBCPP_STD_VER >= 20 | 676 | # if _LIBCPP_STD_VER >= 20 |
| 571 | 677 | ||
| 572 | template <class _Tp> | 678 | template <class _Tp> |
| ... | @@ -579,29 +685,150 @@ struct __is_std_optional : false_type {}; | ... | @@ -579,29 +685,150 @@ struct __is_std_optional : false_type {}; |
| 579 | template <class _Tp> | 685 | template <class _Tp> |
| 580 | struct __is_std_optional<optional<_Tp>> : true_type {}; | 686 | struct __is_std_optional<optional<_Tp>> : true_type {}; |
| 581 | 687 | ||
| 688 | template <class _Tp, class... _Args> | ||
| 689 | inline constexpr bool __is_constructible_for_optional_v = is_constructible_v<_Tp, _Args...>; | ||
| 690 | |||
| 691 | template <class _Tp, class... _Args> | ||
| 692 | struct __is_constructible_for_optional : bool_constant<__is_constructible_for_optional_v<_Tp, _Args...>> {}; | ||
| 693 | |||
| 694 | template <class _Tp, class _Up, class... _Args> | ||
| 695 | inline constexpr bool __is_constructible_for_optional_initializer_list_v = | ||
| 696 | is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>; | ||
| 697 | |||
| 698 | # if _LIBCPP_STD_VER >= 26 | ||
| 699 | template <class _Tp, class... _Args> | ||
| 700 | inline constexpr bool __is_constructible_for_optional_v<_Tp&, _Args...> = false; | ||
| 701 | template <class _Tp, class _Arg> | ||
| 702 | inline constexpr bool __is_constructible_for_optional_v<_Tp&, _Arg> = | ||
| 703 | is_constructible_v<_Tp&, _Arg> && !reference_constructs_from_temporary_v<_Tp&, _Arg>; | ||
| 704 | |||
| 705 | template <class _Tp, class _Up, class... _Args> | ||
| 706 | inline constexpr bool __is_constructible_for_optional_initializer_list_v<_Tp&, _Up, _Args...> = false; | ||
| 707 | # endif | ||
| 708 | |||
| 709 | template <class _Tp, class = void> | ||
| 710 | struct __optional_iterator {}; | ||
| 711 | |||
| 712 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR | ||
| 713 | |||
| 714 | template <class _Tp> | ||
| 715 | struct __optional_iterator<_Tp, enable_if_t<is_object_v<_Tp>>> { | ||
| 716 | private: | ||
| 717 | using __pointer _LIBCPP_NODEBUG = add_pointer_t<_Tp>; | ||
| 718 | using __const_pointer _LIBCPP_NODEBUG = add_pointer_t<const _Tp>; | ||
| 719 | |||
| 720 | public: | ||
| 721 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL | ||
| 722 | using iterator = __bounded_iter<__wrap_iter<__pointer>>; | ||
| 723 | using const_iterator = __bounded_iter<__wrap_iter<__const_pointer>>; | ||
| 724 | # else | ||
| 725 | using iterator = __wrap_iter<__pointer>; | ||
| 726 | using const_iterator = __wrap_iter<__const_pointer>; | ||
| 727 | # endif | ||
| 728 | |||
| 729 | // [optional.iterators], iterator support | ||
| 730 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() noexcept { | ||
| 731 | auto& __derived_self = static_cast<optional<_Tp>&>(*this); | ||
| 732 | auto* __ptr = std::addressof(__derived_self.__get()); | ||
| 733 | |||
| 734 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL | ||
| 735 | return std::__make_bounded_iter( | ||
| 736 | __wrap_iter<__pointer>(__ptr), | ||
| 737 | __wrap_iter<__pointer>(__ptr), | ||
| 738 | __wrap_iter<__pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0)); | ||
| 739 | # else | ||
| 740 | return iterator(__ptr); | ||
| 741 | # endif | ||
| 742 | } | ||
| 743 | |||
| 744 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept { | ||
| 745 | auto& __derived_self = static_cast<const optional<_Tp>&>(*this); | ||
| 746 | auto* __ptr = std::addressof(__derived_self.__get()); | ||
| 747 | |||
| 748 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL | ||
| 749 | return std::__make_bounded_iter( | ||
| 750 | __wrap_iter<__const_pointer>(__ptr), | ||
| 751 | __wrap_iter<__const_pointer>(__ptr), | ||
| 752 | __wrap_iter<__const_pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0)); | ||
| 753 | # else | ||
| 754 | return const_iterator(__ptr); | ||
| 755 | # endif | ||
| 756 | } | ||
| 757 | |||
| 758 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator end() noexcept { | ||
| 759 | return begin() + (static_cast<optional<_Tp>&>(*this).has_value() ? 1 : 0); | ||
| 760 | } | ||
| 761 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept { | ||
| 762 | return begin() + (static_cast<const optional<_Tp>&>(*this).has_value() ? 1 : 0); | ||
| 763 | } | ||
| 764 | }; | ||
| 765 | |||
| 766 | template <class _Tp> | ||
| 767 | struct __optional_iterator<_Tp&, enable_if_t<is_object_v<_Tp> && !__is_unbounded_array_v<_Tp> >> { | ||
| 768 | private: | ||
| 769 | using __pointer _LIBCPP_NODEBUG = add_pointer_t<_Tp>; | ||
| 770 | |||
| 771 | public: | ||
| 772 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL | ||
| 773 | using iterator = __bounded_iter<__wrap_iter<__pointer>>; | ||
| 774 | # else | ||
| 775 | using iterator = __wrap_iter<__pointer>; | ||
| 776 | # endif | ||
| 777 | |||
| 778 | // [optional.ref.iterators], iterator support | ||
| 779 | |||
| 780 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const noexcept { | ||
| 781 | auto& __derived_self = static_cast<const optional<_Tp&>&>(*this); | ||
| 782 | auto* __ptr = __derived_self.has_value() ? std::addressof(__derived_self.__get()) : nullptr; | ||
| 783 | |||
| 784 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL | ||
| 785 | return std::__make_bounded_iter( | ||
| 786 | __wrap_iter<__pointer>(__ptr), | ||
| 787 | __wrap_iter<__pointer>(__ptr), | ||
| 788 | __wrap_iter<__pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0)); | ||
| 789 | # else | ||
| 790 | return iterator(__ptr); | ||
| 791 | # endif | ||
| 792 | } | ||
| 793 | |||
| 794 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const noexcept { | ||
| 795 | return begin() + (static_cast<const optional<_Tp&>&>(*this).has_value() ? 1 : 0); | ||
| 796 | } | ||
| 797 | }; | ||
| 798 | |||
| 799 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR | ||
| 800 | |||
| 582 | template <class _Tp> | 801 | template <class _Tp> |
| 583 | class _LIBCPP_DECLSPEC_EMPTY_BASES optional | 802 | class _LIBCPP_DECLSPEC_EMPTY_BASES optional |
| 584 | : private __optional_move_assign_base<_Tp>, | 803 | : private __optional_move_assign_base<_Tp>, |
| 585 | private __optional_sfinae_ctor_base_t<_Tp>, | 804 | private __optional_sfinae_ctor_base_t<_Tp>, |
| 586 | private __optional_sfinae_assign_base_t<_Tp> { | 805 | private __optional_sfinae_assign_base_t<_Tp>, |
| 806 | public __optional_iterator<_Tp> { | ||
| 587 | using __base _LIBCPP_NODEBUG = __optional_move_assign_base<_Tp>; | 807 | using __base _LIBCPP_NODEBUG = __optional_move_assign_base<_Tp>; |
| 588 | 808 | ||
| 589 | public: | 809 | public: |
| 590 | using value_type = _Tp; | 810 | using value_type = __libcpp_remove_reference_t<_Tp>; |
| 591 | 811 | ||
| 592 | using __trivially_relocatable _LIBCPP_NODEBUG = | 812 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 593 | conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>; | 813 | conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>; |
| 594 | using __replaceable _LIBCPP_NODEBUG = conditional_t<__is_replaceable_v<_Tp>, optional, void>; | ||
| 595 | 814 | ||
| 596 | private: | 815 | private: |
| 597 | // Disable the reference extension using this static assert. | 816 | static_assert(!is_same_v<__remove_cvref_t<_Tp>, in_place_t>, |
| 598 | static_assert(!is_same_v<__remove_cvref_t<value_type>, in_place_t>, | ||
| 599 | "instantiation of optional with in_place_t is ill-formed"); | 817 | "instantiation of optional with in_place_t is ill-formed"); |
| 600 | static_assert(!is_same_v<__remove_cvref_t<value_type>, nullopt_t>, | 818 | static_assert(!is_same_v<__remove_cvref_t<_Tp>, nullopt_t>, "instantiation of optional with nullopt_t is ill-formed"); |
| 601 | "instantiation of optional with nullopt_t is ill-formed"); | 819 | # if _LIBCPP_STD_VER >= 26 |
| 602 | static_assert(!is_reference_v<value_type>, "instantiation of optional with a reference type is ill-formed"); | 820 | static_assert(!is_rvalue_reference_v<_Tp>, "instantiation of optional with an rvalue reference type is ill-formed"); |
| 603 | static_assert(is_destructible_v<value_type>, "instantiation of optional with a non-destructible type is ill-formed"); | 821 | # else |
| 604 | static_assert(!is_array_v<value_type>, "instantiation of optional with an array type is ill-formed"); | 822 | static_assert(!is_reference_v<_Tp>, "instantiation of optional with a reference type is ill-formed"); |
| 823 | # endif | ||
| 824 | static_assert(is_destructible_v<_Tp>, "instantiation of optional with a non-destructible type is ill-formed"); | ||
| 825 | static_assert(!is_array_v<_Tp>, "instantiation of optional with an array type is ill-formed"); | ||
| 826 | |||
| 827 | # if _LIBCPP_STD_VER >= 26 | ||
| 828 | template <class _Up> | ||
| 829 | constexpr static bool __libcpp_opt_ref_ctor_deleted = | ||
| 830 | is_lvalue_reference_v<_Tp> && reference_constructs_from_temporary_v<_Tp, _Up>; | ||
| 831 | # endif | ||
| 605 | 832 | ||
| 606 | // LWG2756: conditionally explicit conversion from _Up | 833 | // LWG2756: conditionally explicit conversion from _Up |
| 607 | struct _CheckOptionalArgsConstructor { | 834 | struct _CheckOptionalArgsConstructor { |
| ... | @@ -674,45 +901,131 @@ public: | ... | @@ -674,45 +901,131 @@ public: |
| 674 | _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default; | 901 | _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default; |
| 675 | _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {} | 902 | _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {} |
| 676 | 903 | ||
| 677 | template <class _InPlaceT, | 904 | template < |
| 678 | class... _Args, | 905 | class _InPlaceT, |
| 679 | enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>, is_constructible<value_type, _Args...>>::value, int> = 0> | 906 | class... _Args, |
| 907 | enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>, __is_constructible_for_optional<_Tp, _Args...>>::value, int> = 0> | ||
| 680 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args) | 908 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args) |
| 681 | : __base(in_place, std::forward<_Args>(__args)...) {} | 909 | : __base(in_place, std::forward<_Args>(__args)...) {} |
| 682 | 910 | ||
| 683 | template <class _Up, | 911 | template <class _Up, |
| 684 | class... _Args, | 912 | class... _Args, |
| 685 | enable_if_t<is_constructible_v<value_type, initializer_list<_Up>&, _Args...>, int> = 0> | 913 | enable_if_t<__is_constructible_for_optional_initializer_list_v<_Tp, _Up, _Args...>, int> = 0> |
| 686 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) | 914 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) |
| 687 | : __base(in_place, __il, std::forward<_Args>(__args)...) {} | 915 | : __base(in_place, __il, std::forward<_Args>(__args)...) {} |
| 688 | 916 | ||
| 689 | template <class _Up = value_type, | 917 | template <class _Up = _Tp, enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0> |
| 690 | enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0> | 918 | _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) |
| 691 | _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {} | 919 | # if _LIBCPP_STD_VER >= 26 |
| 920 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>) | ||
| 921 | # endif | ||
| 922 | : __base(in_place, std::forward<_Up>(__v)) { | ||
| 923 | } | ||
| 692 | 924 | ||
| 693 | template <class _Up, enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0> | 925 | template <class _Up = remove_cv_t<_Tp>, |
| 694 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {} | 926 | enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0> |
| 927 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) | ||
| 928 | # if _LIBCPP_STD_VER >= 26 | ||
| 929 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>) | ||
| 930 | # endif | ||
| 931 | : __base(in_place, std::forward<_Up>(__v)) { | ||
| 932 | } | ||
| 695 | 933 | ||
| 696 | // LWG2756: conditionally explicit conversion from const optional<_Up>& | 934 | // LWG2756: conditionally explicit conversion from const optional<_Up>& |
| 697 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> | 935 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> |
| 698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) { | 936 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) |
| 937 | # if _LIBCPP_STD_VER >= 26 | ||
| 938 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up&>) | ||
| 939 | # endif | ||
| 940 | { | ||
| 699 | this->__construct_from(__v); | 941 | this->__construct_from(__v); |
| 700 | } | 942 | } |
| 701 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> | 943 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> |
| 702 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) { | 944 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) |
| 945 | # if _LIBCPP_STD_VER >= 26 | ||
| 946 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up&>) | ||
| 947 | # endif | ||
| 948 | { | ||
| 703 | this->__construct_from(__v); | 949 | this->__construct_from(__v); |
| 704 | } | 950 | } |
| 705 | 951 | ||
| 706 | // LWG2756: conditionally explicit conversion from optional<_Up>&& | 952 | // LWG2756: conditionally explicit conversion from optional<_Up>&& |
| 707 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0> | 953 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0> |
| 708 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) { | 954 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) |
| 955 | # if _LIBCPP_STD_VER >= 26 | ||
| 956 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>) | ||
| 957 | # endif | ||
| 958 | { | ||
| 709 | this->__construct_from(std::move(__v)); | 959 | this->__construct_from(std::move(__v)); |
| 710 | } | 960 | } |
| 711 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0> | 961 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0> |
| 712 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) { | 962 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) |
| 963 | # if _LIBCPP_STD_VER >= 26 | ||
| 964 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>) | ||
| 965 | # endif | ||
| 966 | { | ||
| 713 | this->__construct_from(std::move(__v)); | 967 | this->__construct_from(std::move(__v)); |
| 714 | } | 968 | } |
| 715 | 969 | ||
| 970 | // deleted optional<T&> constructors and additional optional<T&> constructors | ||
| 971 | # if _LIBCPP_STD_VER >= 26 | ||
| 972 | // optional(U&&) | ||
| 973 | template <class _Up = _Tp, enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0> | ||
| 974 | requires __libcpp_opt_ref_ctor_deleted<_Up> | ||
| 975 | optional(_Up&&) = delete; | ||
| 976 | |||
| 977 | template <class _Up = remove_cv_t<_Tp>, | ||
| 978 | enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0> | ||
| 979 | requires __libcpp_opt_ref_ctor_deleted<_Up> | ||
| 980 | explicit optional(_Up&&) = delete; | ||
| 981 | |||
| 982 | // optional(optional<U>& rhs) | ||
| 983 | template <class _Up> | ||
| 984 | requires(!__libcpp_opt_ref_ctor_deleted<_Up>) && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | ||
| 985 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&> | ||
| 986 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up&, _Tp&>) | ||
| 987 | optional(optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up&>) { | ||
| 988 | this->__construct_from(__rhs); | ||
| 989 | } | ||
| 990 | |||
| 991 | template <class _Up> | ||
| 992 | requires __libcpp_opt_ref_ctor_deleted<_Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | ||
| 993 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&> | ||
| 994 | constexpr explicit optional(optional<_Up>& __rhs) noexcept = delete; | ||
| 995 | |||
| 996 | // optional(const optional<U>&) | ||
| 997 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> | ||
| 998 | requires __libcpp_opt_ref_ctor_deleted<_Up> | ||
| 999 | optional(const optional<_Up>&) = delete; | ||
| 1000 | |||
| 1001 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> | ||
| 1002 | requires __libcpp_opt_ref_ctor_deleted<_Up> | ||
| 1003 | explicit optional(const optional<_Up>&) = delete; | ||
| 1004 | |||
| 1005 | // optional(optional<U>&&) | ||
| 1006 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0> | ||
| 1007 | requires __libcpp_opt_ref_ctor_deleted<_Up> | ||
| 1008 | optional(optional<_Up>&&) = delete; | ||
| 1009 | |||
| 1010 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0> | ||
| 1011 | requires __libcpp_opt_ref_ctor_deleted<_Up> | ||
| 1012 | explicit optional(optional<_Up>&&) = delete; | ||
| 1013 | |||
| 1014 | // optional(const optional<U>&&) | ||
| 1015 | template <class _Up> | ||
| 1016 | requires(!__libcpp_opt_ref_ctor_deleted<_Up>) && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | ||
| 1017 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up> | ||
| 1018 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!is_convertible_v<const _Up, _Tp&>) | ||
| 1019 | optional(const optional<_Up>&& __v) noexcept(is_nothrow_constructible_v<_Tp&, const _Up>) { | ||
| 1020 | this->__construct_from(std::move(__v)); | ||
| 1021 | } | ||
| 1022 | |||
| 1023 | template <class _Up> | ||
| 1024 | requires __libcpp_opt_ref_ctor_deleted<_Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | ||
| 1025 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up> | ||
| 1026 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>&& __v) noexcept = delete; | ||
| 1027 | # endif | ||
| 1028 | |||
| 716 | # if _LIBCPP_STD_VER >= 23 | 1029 | # if _LIBCPP_STD_VER >= 23 |
| 717 | template <class _Tag, | 1030 | template <class _Tag, |
| 718 | class _Fp, | 1031 | class _Fp, |
| ... | @@ -731,11 +1044,12 @@ public: | ... | @@ -731,11 +1044,12 @@ public: |
| 731 | _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(optional&&) = default; | 1044 | _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(optional&&) = default; |
| 732 | 1045 | ||
| 733 | // LWG2756 | 1046 | // LWG2756 |
| 734 | template <class _Up = value_type, | 1047 | template <class _Up = remove_cv_t<_Tp>, |
| 735 | enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Up>, optional>, | 1048 | enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Up>, optional>, |
| 736 | _Or<_IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>>>, | 1049 | _Or<_IsNotSame<__remove_cvref_t<_Up>, _Tp>, _Not<is_scalar<_Tp>>>, |
| 737 | is_constructible<value_type, _Up>, | 1050 | is_constructible<_Tp, _Up>, |
| 738 | is_assignable<value_type&, _Up>>::value, | 1051 | is_assignable<_Tp&, _Up>, |
| 1052 | is_object<_Tp>>::value, | ||
| 739 | int> = 0> | 1053 | int> = 0> |
| 740 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) { | 1054 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) { |
| 741 | if (this->has_value()) | 1055 | if (this->has_value()) |
| ... | @@ -759,8 +1073,12 @@ public: | ... | @@ -759,8 +1073,12 @@ public: |
| 759 | return *this; | 1073 | return *this; |
| 760 | } | 1074 | } |
| 761 | 1075 | ||
| 762 | template <class... _Args, enable_if_t<is_constructible_v<value_type, _Args...>, int> = 0> | 1076 | template <class... _Args, enable_if_t<__is_constructible_for_optional_v<_Tp, _Args...>, int> = 0> |
| 763 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) { | 1077 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) |
| 1078 | # if _LIBCPP_STD_VER >= 26 | ||
| 1079 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp, _Args...>) | ||
| 1080 | # endif | ||
| 1081 | { | ||
| 764 | reset(); | 1082 | reset(); |
| 765 | this->__construct(std::forward<_Args>(__args)...); | 1083 | this->__construct(std::forward<_Args>(__args)...); |
| 766 | return this->__get(); | 1084 | return this->__get(); |
| ... | @@ -768,56 +1086,72 @@ public: | ... | @@ -768,56 +1086,72 @@ public: |
| 768 | 1086 | ||
| 769 | template <class _Up, | 1087 | template <class _Up, |
| 770 | class... _Args, | 1088 | class... _Args, |
| 771 | enable_if_t<is_constructible_v<value_type, initializer_list<_Up>&, _Args...>, int> = 0> | 1089 | enable_if_t<__is_constructible_for_optional_initializer_list_v<_Tp, _Up, _Args...>, int> = 0> |
| 772 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { | 1090 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { |
| 773 | reset(); | 1091 | reset(); |
| 774 | this->__construct(__il, std::forward<_Args>(__args)...); | 1092 | this->__construct(__il, std::forward<_Args>(__args)...); |
| 775 | return this->__get(); | 1093 | return this->__get(); |
| 776 | } | 1094 | } |
| 777 | 1095 | ||
| 778 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 1096 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional& __opt) noexcept( |
| 779 | swap(optional& __opt) noexcept(is_nothrow_move_constructible_v<value_type> && is_nothrow_swappable_v<value_type>) { | 1097 | (is_nothrow_move_constructible_v<_Tp> && is_nothrow_swappable_v<_Tp>) |
| 780 | if (this->has_value() == __opt.has_value()) { | 1098 | # if _LIBCPP_STD_VER >= 26 |
| 781 | using std::swap; | 1099 | || is_lvalue_reference_v<_Tp> |
| 782 | if (this->has_value()) | 1100 | # endif |
| 783 | swap(this->__get(), __opt.__get()); | 1101 | ) { |
| 784 | } else { | 1102 | this->__swap(__opt); |
| 785 | if (this->has_value()) { | ||
| 786 | __opt.__construct(std::move(this->__get())); | ||
| 787 | reset(); | ||
| 788 | } else { | ||
| 789 | this->__construct(std::move(__opt.__get())); | ||
| 790 | __opt.reset(); | ||
| 791 | } | ||
| 792 | } | ||
| 793 | } | 1103 | } |
| 794 | 1104 | ||
| 795 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const noexcept { | 1105 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp const> operator->() const noexcept |
| 1106 | # if _LIBCPP_STD_VER >= 26 | ||
| 1107 | requires(is_object_v<_Tp>) | ||
| 1108 | # endif | ||
| 1109 | { | ||
| 796 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); | 1110 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); |
| 797 | return std::addressof(this->__get()); | 1111 | return std::addressof(this->__get()); |
| 798 | } | 1112 | } |
| 799 | 1113 | ||
| 800 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() noexcept { | 1114 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> operator->() noexcept |
| 1115 | # if _LIBCPP_STD_VER >= 26 | ||
| 1116 | requires(is_object_v<_Tp>) | ||
| 1117 | # endif | ||
| 1118 | { | ||
| 801 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); | 1119 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); |
| 802 | return std::addressof(this->__get()); | 1120 | return std::addressof(this->__get()); |
| 803 | } | 1121 | } |
| 804 | 1122 | ||
| 805 | _LIBCPP_HIDE_FROM_ABI constexpr const value_type& operator*() const& noexcept { | 1123 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const& noexcept |
| 1124 | # if _LIBCPP_STD_VER >= 26 | ||
| 1125 | requires(is_object_v<_Tp>) | ||
| 1126 | # endif | ||
| 1127 | { | ||
| 806 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); | 1128 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); |
| 807 | return this->__get(); | 1129 | return this->__get(); |
| 808 | } | 1130 | } |
| 809 | 1131 | ||
| 810 | _LIBCPP_HIDE_FROM_ABI constexpr value_type& operator*() & noexcept { | 1132 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() & noexcept |
| 1133 | # if _LIBCPP_STD_VER >= 26 | ||
| 1134 | requires(is_object_v<_Tp>) | ||
| 1135 | # endif | ||
| 1136 | { | ||
| 811 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); | 1137 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); |
| 812 | return this->__get(); | 1138 | return this->__get(); |
| 813 | } | 1139 | } |
| 814 | 1140 | ||
| 815 | _LIBCPP_HIDE_FROM_ABI constexpr value_type&& operator*() && noexcept { | 1141 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator*() && noexcept |
| 1142 | # if _LIBCPP_STD_VER >= 26 | ||
| 1143 | requires(is_object_v<_Tp>) | ||
| 1144 | # endif | ||
| 1145 | { | ||
| 816 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); | 1146 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); |
| 817 | return std::move(this->__get()); | 1147 | return std::move(this->__get()); |
| 818 | } | 1148 | } |
| 819 | 1149 | ||
| 820 | _LIBCPP_HIDE_FROM_ABI constexpr const value_type&& operator*() const&& noexcept { | 1150 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& operator*() const&& noexcept |
| 1151 | # if _LIBCPP_STD_VER >= 26 | ||
| 1152 | requires(is_object_v<_Tp>) | ||
| 1153 | # endif | ||
| 1154 | { | ||
| 821 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); | 1155 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); |
| 822 | return std::move(this->__get()); | 1156 | return std::move(this->__get()); |
| 823 | } | 1157 | } |
| ... | @@ -827,48 +1161,73 @@ public: | ... | @@ -827,48 +1161,73 @@ public: |
| 827 | using __base::__get; | 1161 | using __base::__get; |
| 828 | using __base::has_value; | 1162 | using __base::has_value; |
| 829 | 1163 | ||
| 830 | _LIBCPP_HIDE_FROM_ABI constexpr value_type const& value() const& { | 1164 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& value() const& |
| 1165 | # if _LIBCPP_STD_VER >= 26 | ||
| 1166 | requires(is_object_v<_Tp>) | ||
| 1167 | # endif | ||
| 1168 | { | ||
| 831 | if (!this->has_value()) | 1169 | if (!this->has_value()) |
| 832 | std::__throw_bad_optional_access(); | 1170 | std::__throw_bad_optional_access(); |
| 833 | return this->__get(); | 1171 | return this->__get(); |
| 834 | } | 1172 | } |
| 835 | 1173 | ||
| 836 | _LIBCPP_HIDE_FROM_ABI constexpr value_type& value() & { | 1174 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() & |
| 1175 | # if _LIBCPP_STD_VER >= 26 | ||
| 1176 | requires(is_object_v<_Tp>) | ||
| 1177 | # endif | ||
| 1178 | { | ||
| 837 | if (!this->has_value()) | 1179 | if (!this->has_value()) |
| 838 | std::__throw_bad_optional_access(); | 1180 | std::__throw_bad_optional_access(); |
| 839 | return this->__get(); | 1181 | return this->__get(); |
| 840 | } | 1182 | } |
| 841 | 1183 | ||
| 842 | _LIBCPP_HIDE_FROM_ABI constexpr value_type&& value() && { | 1184 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() && |
| 1185 | # if _LIBCPP_STD_VER >= 26 | ||
| 1186 | requires(is_object_v<_Tp>) | ||
| 1187 | # endif | ||
| 1188 | { | ||
| 843 | if (!this->has_value()) | 1189 | if (!this->has_value()) |
| 844 | std::__throw_bad_optional_access(); | 1190 | std::__throw_bad_optional_access(); |
| 845 | return std::move(this->__get()); | 1191 | return std::move(this->__get()); |
| 846 | } | 1192 | } |
| 847 | 1193 | ||
| 848 | _LIBCPP_HIDE_FROM_ABI constexpr value_type const&& value() const&& { | 1194 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp const&& value() const&& |
| 1195 | # if _LIBCPP_STD_VER >= 26 | ||
| 1196 | requires(is_object_v<_Tp>) | ||
| 1197 | # endif | ||
| 1198 | { | ||
| 849 | if (!this->has_value()) | 1199 | if (!this->has_value()) |
| 850 | std::__throw_bad_optional_access(); | 1200 | std::__throw_bad_optional_access(); |
| 851 | return std::move(this->__get()); | 1201 | return std::move(this->__get()); |
| 852 | } | 1202 | } |
| 853 | 1203 | ||
| 854 | template <class _Up> | 1204 | template <class _Up = remove_cv_t<_Tp>> |
| 855 | _LIBCPP_HIDE_FROM_ABI constexpr value_type value_or(_Up&& __v) const& { | 1205 | # if _LIBCPP_STD_VER >= 26 |
| 856 | static_assert(is_copy_constructible_v<value_type>, "optional<T>::value_or: T must be copy constructible"); | 1206 | requires(is_object_v<_Tp>) |
| 857 | static_assert(is_convertible_v<_Up, value_type>, "optional<T>::value_or: U must be convertible to T"); | 1207 | # endif |
| 858 | return this->has_value() ? this->__get() : static_cast<value_type>(std::forward<_Up>(__v)); | 1208 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) const& { |
| 1209 | static_assert(is_copy_constructible_v<_Tp>, "optional<T>::value_or: T must be copy constructible"); | ||
| 1210 | static_assert(is_convertible_v<_Up, _Tp>, "optional<T>::value_or: U must be convertible to T"); | ||
| 1211 | return this->has_value() ? this->__get() : static_cast<_Tp>(std::forward<_Up>(__v)); | ||
| 859 | } | 1212 | } |
| 860 | 1213 | ||
| 861 | template <class _Up> | 1214 | template <class _Up = remove_cv_t<_Tp>> |
| 862 | _LIBCPP_HIDE_FROM_ABI constexpr value_type value_or(_Up&& __v) && { | 1215 | # if _LIBCPP_STD_VER >= 26 |
| 863 | static_assert(is_move_constructible_v<value_type>, "optional<T>::value_or: T must be move constructible"); | 1216 | requires(is_object_v<_Tp>) |
| 864 | static_assert(is_convertible_v<_Up, value_type>, "optional<T>::value_or: U must be convertible to T"); | 1217 | # endif |
| 865 | return this->has_value() ? std::move(this->__get()) : static_cast<value_type>(std::forward<_Up>(__v)); | 1218 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) && { |
| 1219 | static_assert(is_move_constructible_v<_Tp>, "optional<T>::value_or: T must be move constructible"); | ||
| 1220 | static_assert(is_convertible_v<_Up, _Tp>, "optional<T>::value_or: U must be convertible to T"); | ||
| 1221 | return this->has_value() ? std::move(this->__get()) : static_cast<_Tp>(std::forward<_Up>(__v)); | ||
| 866 | } | 1222 | } |
| 867 | 1223 | ||
| 868 | # if _LIBCPP_STD_VER >= 23 | 1224 | # if _LIBCPP_STD_VER >= 23 |
| 869 | template <class _Func> | 1225 | template <class _Func> |
| 870 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { | 1226 | # if _LIBCPP_STD_VER >= 26 |
| 871 | using _Up = invoke_result_t<_Func, value_type&>; | 1227 | requires(is_object_v<_Tp>) |
| 1228 | # endif | ||
| 1229 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { | ||
| 1230 | using _Up = invoke_result_t<_Func, _Tp&>; | ||
| 872 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | 1231 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| 873 | "Result of f(value()) must be a specialization of std::optional"); | 1232 | "Result of f(value()) must be a specialization of std::optional"); |
| 874 | if (*this) | 1233 | if (*this) |
| ... | @@ -877,8 +1236,11 @@ public: | ... | @@ -877,8 +1236,11 @@ public: |
| 877 | } | 1236 | } |
| 878 | 1237 | ||
| 879 | template <class _Func> | 1238 | template <class _Func> |
| 880 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { | 1239 | # if _LIBCPP_STD_VER >= 26 |
| 881 | using _Up = invoke_result_t<_Func, const value_type&>; | 1240 | requires(is_object_v<_Tp>) |
| 1241 | # endif | ||
| 1242 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { | ||
| 1243 | using _Up = invoke_result_t<_Func, const _Tp&>; | ||
| 882 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | 1244 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| 883 | "Result of f(value()) must be a specialization of std::optional"); | 1245 | "Result of f(value()) must be a specialization of std::optional"); |
| 884 | if (*this) | 1246 | if (*this) |
| ... | @@ -887,8 +1249,11 @@ public: | ... | @@ -887,8 +1249,11 @@ public: |
| 887 | } | 1249 | } |
| 888 | 1250 | ||
| 889 | template <class _Func> | 1251 | template <class _Func> |
| 890 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { | 1252 | # if _LIBCPP_STD_VER >= 26 |
| 891 | using _Up = invoke_result_t<_Func, value_type&&>; | 1253 | requires(is_object_v<_Tp>) |
| 1254 | # endif | ||
| 1255 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { | ||
| 1256 | using _Up = invoke_result_t<_Func, _Tp&&>; | ||
| 892 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | 1257 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| 893 | "Result of f(std::move(value())) must be a specialization of std::optional"); | 1258 | "Result of f(std::move(value())) must be a specialization of std::optional"); |
| 894 | if (*this) | 1259 | if (*this) |
| ... | @@ -897,8 +1262,11 @@ public: | ... | @@ -897,8 +1262,11 @@ public: |
| 897 | } | 1262 | } |
| 898 | 1263 | ||
| 899 | template <class _Func> | 1264 | template <class _Func> |
| 900 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { | 1265 | # if _LIBCPP_STD_VER >= 26 |
| 901 | using _Up = invoke_result_t<_Func, const value_type&&>; | 1266 | requires(is_object_v<_Tp>) |
| 1267 | # endif | ||
| 1268 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { | ||
| 1269 | using _Up = invoke_result_t<_Func, const _Tp&&>; | ||
| 902 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | 1270 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| 903 | "Result of f(std::move(value())) must be a specialization of std::optional"); | 1271 | "Result of f(std::move(value())) must be a specialization of std::optional"); |
| 904 | if (*this) | 1272 | if (*this) |
| ... | @@ -907,8 +1275,11 @@ public: | ... | @@ -907,8 +1275,11 @@ public: |
| 907 | } | 1275 | } |
| 908 | 1276 | ||
| 909 | template <class _Func> | 1277 | template <class _Func> |
| 910 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & { | 1278 | # if _LIBCPP_STD_VER >= 26 |
| 911 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>; | 1279 | requires(is_object_v<_Tp>) |
| 1280 | # endif | ||
| 1281 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & { | ||
| 1282 | using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&>>; | ||
| 912 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); | 1283 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); |
| 913 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); | 1284 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); |
| 914 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t"); | 1285 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t"); |
| ... | @@ -919,8 +1290,11 @@ public: | ... | @@ -919,8 +1290,11 @@ public: |
| 919 | } | 1290 | } |
| 920 | 1291 | ||
| 921 | template <class _Func> | 1292 | template <class _Func> |
| 922 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& { | 1293 | # if _LIBCPP_STD_VER >= 26 |
| 923 | using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>; | 1294 | requires(is_object_v<_Tp>) |
| 1295 | # endif | ||
| 1296 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& { | ||
| 1297 | using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&>>; | ||
| 924 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); | 1298 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); |
| 925 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); | 1299 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); |
| 926 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t"); | 1300 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t"); |
| ... | @@ -931,8 +1305,11 @@ public: | ... | @@ -931,8 +1305,11 @@ public: |
| 931 | } | 1305 | } |
| 932 | 1306 | ||
| 933 | template <class _Func> | 1307 | template <class _Func> |
| 934 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && { | 1308 | # if _LIBCPP_STD_VER >= 26 |
| 935 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>; | 1309 | requires(is_object_v<_Tp>) |
| 1310 | # endif | ||
| 1311 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && { | ||
| 1312 | using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&&>>; | ||
| 936 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); | 1313 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); |
| 937 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); | 1314 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); |
| 938 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(std::move(value())) should not be std::nullopt_t"); | 1315 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(std::move(value())) should not be std::nullopt_t"); |
| ... | @@ -943,8 +1320,11 @@ public: | ... | @@ -943,8 +1320,11 @@ public: |
| 943 | } | 1320 | } |
| 944 | 1321 | ||
| 945 | template <class _Func> | 1322 | template <class _Func> |
| 946 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& { | 1323 | # if _LIBCPP_STD_VER >= 26 |
| 947 | using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>; | 1324 | requires(is_object_v<_Tp>) |
| 1325 | # endif | ||
| 1326 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& { | ||
| 1327 | using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&&>>; | ||
| 948 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); | 1328 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); |
| 949 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); | 1329 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); |
| 950 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(std::move(value())) should not be std::nullopt_t"); | 1330 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(std::move(value())) should not be std::nullopt_t"); |
| ... | @@ -955,8 +1335,11 @@ public: | ... | @@ -955,8 +1335,11 @@ public: |
| 955 | } | 1335 | } |
| 956 | 1336 | ||
| 957 | template <invocable _Func> | 1337 | template <invocable _Func> |
| 958 | _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) const& | 1338 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) const& |
| 959 | requires is_copy_constructible_v<value_type> | 1339 | requires is_copy_constructible_v<_Tp> |
| 1340 | # if _LIBCPP_STD_VER >= 26 | ||
| 1341 | && (is_object_v<_Tp>) | ||
| 1342 | # endif | ||
| 960 | { | 1343 | { |
| 961 | static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>, | 1344 | static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>, |
| 962 | "Result of f() should be the same type as this optional"); | 1345 | "Result of f() should be the same type as this optional"); |
| ... | @@ -966,8 +1349,11 @@ public: | ... | @@ -966,8 +1349,11 @@ public: |
| 966 | } | 1349 | } |
| 967 | 1350 | ||
| 968 | template <invocable _Func> | 1351 | template <invocable _Func> |
| 969 | _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) && | 1352 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) && |
| 970 | requires is_move_constructible_v<value_type> | 1353 | requires is_move_constructible_v<_Tp> |
| 1354 | # if _LIBCPP_STD_VER >= 26 | ||
| 1355 | && (is_object_v<_Tp>) | ||
| 1356 | # endif | ||
| 971 | { | 1357 | { |
| 972 | static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>, | 1358 | static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>, |
| 973 | "Result of f() should be the same type as this optional"); | 1359 | "Result of f() should be the same type as this optional"); |
| ... | @@ -978,6 +1364,78 @@ public: | ... | @@ -978,6 +1364,78 @@ public: |
| 978 | # endif // _LIBCPP_STD_VER >= 23 | 1364 | # endif // _LIBCPP_STD_VER >= 23 |
| 979 | 1365 | ||
| 980 | using __base::reset; | 1366 | using __base::reset; |
| 1367 | |||
| 1368 | // optional<T&> overloads | ||
| 1369 | # if _LIBCPP_STD_VER >= 26 | ||
| 1370 | |||
| 1371 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> operator->() const noexcept | ||
| 1372 | requires(is_lvalue_reference_v<_Tp>) | ||
| 1373 | { | ||
| 1374 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value"); | ||
| 1375 | return std::addressof(this->__get()); | ||
| 1376 | } | ||
| 1377 | |||
| 1378 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() const noexcept | ||
| 1379 | requires(is_lvalue_reference_v<_Tp>) | ||
| 1380 | { | ||
| 1381 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value"); | ||
| 1382 | return this->__get(); | ||
| 1383 | } | ||
| 1384 | |||
| 1385 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() const | ||
| 1386 | requires(is_lvalue_reference_v<_Tp>) | ||
| 1387 | { | ||
| 1388 | if (!this->has_value()) | ||
| 1389 | std::__throw_bad_optional_access(); | ||
| 1390 | return this->__get(); | ||
| 1391 | } | ||
| 1392 | |||
| 1393 | template <class _Up = remove_cvref_t<_Tp>> | ||
| 1394 | requires(is_lvalue_reference_v<_Tp> && is_object_v<__libcpp_remove_reference_t<_Tp>> && | ||
| 1395 | !is_array_v<__libcpp_remove_reference_t<_Tp>>) | ||
| 1396 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decay_t<_Tp> value_or(_Up&& __v) const { | ||
| 1397 | static_assert( | ||
| 1398 | is_constructible_v<remove_cvref_t<_Tp>, _Tp&>, "optional<T&>::value_or: remove_cv_t<T> must be constructible"); | ||
| 1399 | static_assert( | ||
| 1400 | is_convertible_v<_Up, remove_cvref_t<_Tp>>, "optional<T&>::value_or: U must be convertible to remove_cv_t<T>"); | ||
| 1401 | return this->has_value() ? this->__get() : static_cast<remove_cvref_t<_Tp>>(std::forward<_Up>(__v)); | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | template <class _Func> | ||
| 1405 | requires(is_lvalue_reference_v<_Tp>) | ||
| 1406 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const { | ||
| 1407 | using _Up = invoke_result_t<_Func, _Tp&>; | ||
| 1408 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | ||
| 1409 | "Result of f(value()) must be a specialization of std::optional"); | ||
| 1410 | if (*this) | ||
| 1411 | return std::invoke(std::forward<_Func>(__f), value()); | ||
| 1412 | return remove_cvref_t<_Up>(); | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | template <class _Func> | ||
| 1416 | requires(is_lvalue_reference_v<_Tp>) | ||
| 1417 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional<remove_cv_t<invoke_result_t<_Func, _Tp&>>> | ||
| 1418 | transform(_Func&& __f) const { | ||
| 1419 | using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>; | ||
| 1420 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); | ||
| 1421 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); | ||
| 1422 | static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t"); | ||
| 1423 | static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type"); | ||
| 1424 | if (*this) | ||
| 1425 | return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), value()); | ||
| 1426 | return optional<_Up>(); | ||
| 1427 | } | ||
| 1428 | |||
| 1429 | template <invocable _Func> | ||
| 1430 | requires(is_lvalue_reference_v<_Tp>) | ||
| 1431 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) const { | ||
| 1432 | static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>, | ||
| 1433 | "Result of f() should be the same type as this optional"); | ||
| 1434 | if (*this) | ||
| 1435 | return *this; | ||
| 1436 | return std::forward<_Func>(__f)(); | ||
| 1437 | } | ||
| 1438 | # endif | ||
| 981 | }; | 1439 | }; |
| 982 | 1440 | ||
| 983 | template <class _Tp> | 1441 | template <class _Tp> |
| ... | @@ -1154,7 +1612,9 @@ template < | ... | @@ -1154,7 +1612,9 @@ template < |
| 1154 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, | 1612 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, |
| 1155 | int> = 0> | 1613 | int> = 0> |
| 1156 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const _Up& __v) { | 1614 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const _Up& __v) { |
| 1157 | return static_cast<bool>(__x) ? *__x == __v : false; | 1615 | if (__x.has_value()) |
| 1616 | return *__x == __v; | ||
| 1617 | return false; | ||
| 1158 | } | 1618 | } |
| 1159 | 1619 | ||
| 1160 | template < | 1620 | template < |
| ... | @@ -1163,7 +1623,9 @@ template < | ... | @@ -1163,7 +1623,9 @@ template < |
| 1163 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, | 1623 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, |
| 1164 | int> = 0> | 1624 | int> = 0> |
| 1165 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const _Tp& __v, const optional<_Up>& __x) { | 1625 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const _Tp& __v, const optional<_Up>& __x) { |
| 1166 | return static_cast<bool>(__x) ? __v == *__x : false; | 1626 | if (__x.has_value()) |
| 1627 | return __v == *__x; | ||
| 1628 | return false; | ||
| 1167 | } | 1629 | } |
| 1168 | 1630 | ||
| 1169 | template < | 1631 | template < |
| ... | @@ -1172,7 +1634,9 @@ template < | ... | @@ -1172,7 +1634,9 @@ template < |
| 1172 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, | 1634 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, |
| 1173 | int> = 0> | 1635 | int> = 0> |
| 1174 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, const _Up& __v) { | 1636 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, const _Up& __v) { |
| 1175 | return static_cast<bool>(__x) ? *__x != __v : true; | 1637 | if (__x.has_value()) |
| 1638 | return *__x != __v; | ||
| 1639 | return true; | ||
| 1176 | } | 1640 | } |
| 1177 | 1641 | ||
| 1178 | template < | 1642 | template < |
| ... | @@ -1181,7 +1645,9 @@ template < | ... | @@ -1181,7 +1645,9 @@ template < |
| 1181 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, | 1645 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, |
| 1182 | int> = 0> | 1646 | int> = 0> |
| 1183 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const _Tp& __v, const optional<_Up>& __x) { | 1647 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const _Tp& __v, const optional<_Up>& __x) { |
| 1184 | return static_cast<bool>(__x) ? __v != *__x : true; | 1648 | if (__x.has_value()) |
| 1649 | return __v != *__x; | ||
| 1650 | return true; | ||
| 1185 | } | 1651 | } |
| 1186 | 1652 | ||
| 1187 | template < class _Tp, | 1653 | template < class _Tp, |
| ... | @@ -1189,7 +1655,9 @@ template < class _Tp, | ... | @@ -1189,7 +1655,9 @@ template < class _Tp, |
| 1189 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, | 1655 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, |
| 1190 | int> = 0> | 1656 | int> = 0> |
| 1191 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>& __x, const _Up& __v) { | 1657 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>& __x, const _Up& __v) { |
| 1192 | return static_cast<bool>(__x) ? *__x < __v : true; | 1658 | if (__x.has_value()) |
| 1659 | return *__x < __v; | ||
| 1660 | return true; | ||
| 1193 | } | 1661 | } |
| 1194 | 1662 | ||
| 1195 | template < class _Tp, | 1663 | template < class _Tp, |
| ... | @@ -1197,7 +1665,9 @@ template < class _Tp, | ... | @@ -1197,7 +1665,9 @@ template < class _Tp, |
| 1197 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, | 1665 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, |
| 1198 | int> = 0> | 1666 | int> = 0> |
| 1199 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const _Tp& __v, const optional<_Up>& __x) { | 1667 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const _Tp& __v, const optional<_Up>& __x) { |
| 1200 | return static_cast<bool>(__x) ? __v < *__x : false; | 1668 | if (__x.has_value()) |
| 1669 | return __v < *__x; | ||
| 1670 | return false; | ||
| 1201 | } | 1671 | } |
| 1202 | 1672 | ||
| 1203 | template < | 1673 | template < |
| ... | @@ -1206,7 +1676,9 @@ template < | ... | @@ -1206,7 +1676,9 @@ template < |
| 1206 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, | 1676 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, |
| 1207 | int> = 0> | 1677 | int> = 0> |
| 1208 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, const _Up& __v) { | 1678 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, const _Up& __v) { |
| 1209 | return static_cast<bool>(__x) ? *__x <= __v : true; | 1679 | if (__x.has_value()) |
| 1680 | return *__x <= __v; | ||
| 1681 | return true; | ||
| 1210 | } | 1682 | } |
| 1211 | 1683 | ||
| 1212 | template < | 1684 | template < |
| ... | @@ -1215,7 +1687,9 @@ template < | ... | @@ -1215,7 +1687,9 @@ template < |
| 1215 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, | 1687 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, |
| 1216 | int> = 0> | 1688 | int> = 0> |
| 1217 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const _Tp& __v, const optional<_Up>& __x) { | 1689 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const _Tp& __v, const optional<_Up>& __x) { |
| 1218 | return static_cast<bool>(__x) ? __v <= *__x : false; | 1690 | if (__x.has_value()) |
| 1691 | return __v <= *__x; | ||
| 1692 | return false; | ||
| 1219 | } | 1693 | } |
| 1220 | 1694 | ||
| 1221 | template < class _Tp, | 1695 | template < class _Tp, |
| ... | @@ -1223,7 +1697,9 @@ template < class _Tp, | ... | @@ -1223,7 +1697,9 @@ template < class _Tp, |
| 1223 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, | 1697 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, |
| 1224 | int> = 0> | 1698 | int> = 0> |
| 1225 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, const _Up& __v) { | 1699 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, const _Up& __v) { |
| 1226 | return static_cast<bool>(__x) ? *__x > __v : false; | 1700 | if (__x.has_value()) |
| 1701 | return *__x > __v; | ||
| 1702 | return false; | ||
| 1227 | } | 1703 | } |
| 1228 | 1704 | ||
| 1229 | template < class _Tp, | 1705 | template < class _Tp, |
| ... | @@ -1231,7 +1707,9 @@ template < class _Tp, | ... | @@ -1231,7 +1707,9 @@ template < class _Tp, |
| 1231 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, | 1707 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, |
| 1232 | int> = 0> | 1708 | int> = 0> |
| 1233 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const _Tp& __v, const optional<_Up>& __x) { | 1709 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const _Tp& __v, const optional<_Up>& __x) { |
| 1234 | return static_cast<bool>(__x) ? __v > *__x : true; | 1710 | if (__x.has_value()) |
| 1711 | return __v > *__x; | ||
| 1712 | return true; | ||
| 1235 | } | 1713 | } |
| 1236 | 1714 | ||
| 1237 | template < | 1715 | template < |
| ... | @@ -1240,7 +1718,9 @@ template < | ... | @@ -1240,7 +1718,9 @@ template < |
| 1240 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, | 1718 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, |
| 1241 | int> = 0> | 1719 | int> = 0> |
| 1242 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>& __x, const _Up& __v) { | 1720 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>& __x, const _Up& __v) { |
| 1243 | return static_cast<bool>(__x) ? *__x >= __v : false; | 1721 | if (__x.has_value()) |
| 1722 | return *__x >= __v; | ||
| 1723 | return false; | ||
| 1244 | } | 1724 | } |
| 1245 | 1725 | ||
| 1246 | template < | 1726 | template < |
| ... | @@ -1249,7 +1729,9 @@ template < | ... | @@ -1249,7 +1729,9 @@ template < |
| 1249 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, | 1729 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, |
| 1250 | int> = 0> | 1730 | int> = 0> |
| 1251 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const _Tp& __v, const optional<_Up>& __x) { | 1731 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const _Tp& __v, const optional<_Up>& __x) { |
| 1252 | return static_cast<bool>(__x) ? __v >= *__x : true; | 1732 | if (__x.has_value()) |
| 1733 | return __v >= *__x; | ||
| 1734 | return true; | ||
| 1253 | } | 1735 | } |
| 1254 | 1736 | ||
| 1255 | # if _LIBCPP_STD_VER >= 20 | 1737 | # if _LIBCPP_STD_VER >= 20 |
| ... | @@ -1264,23 +1746,36 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { | ... | @@ -1264,23 +1746,36 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { |
| 1264 | # endif // _LIBCPP_STD_VER >= 20 | 1746 | # endif // _LIBCPP_STD_VER >= 20 |
| 1265 | 1747 | ||
| 1266 | template <class _Tp, enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, int> = 0> | 1748 | template <class _Tp, enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, int> = 0> |
| 1267 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 1749 | inline _LIBCPP_HIDE_FROM_ABI |
| 1268 | swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) { | 1750 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) { |
| 1269 | __x.swap(__y); | 1751 | __x.swap(__y); |
| 1270 | } | 1752 | } |
| 1271 | 1753 | ||
| 1272 | template <class _Tp> | 1754 | struct __make_optional_barrier_tag { |
| 1273 | _LIBCPP_HIDE_FROM_ABI constexpr optional<decay_t<_Tp>> make_optional(_Tp&& __v) { | 1755 | explicit __make_optional_barrier_tag() = default; |
| 1756 | }; | ||
| 1757 | |||
| 1758 | template < | ||
| 1759 | # if _LIBCPP_STD_VER >= 26 | ||
| 1760 | __make_optional_barrier_tag = __make_optional_barrier_tag{}, | ||
| 1761 | # endif | ||
| 1762 | class _Tp, | ||
| 1763 | enable_if_t<is_constructible_v<decay_t<_Tp>, _Tp>, int> = 0> | ||
| 1764 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional<decay_t<_Tp>> make_optional(_Tp&& __v) { | ||
| 1274 | return optional<decay_t<_Tp>>(std::forward<_Tp>(__v)); | 1765 | return optional<decay_t<_Tp>>(std::forward<_Tp>(__v)); |
| 1275 | } | 1766 | } |
| 1276 | 1767 | ||
| 1277 | template <class _Tp, class... _Args> | 1768 | template <class _Tp, class... _Args, enable_if_t<__is_constructible_for_optional_v<_Tp, _Args...>, int> = 0> |
| 1278 | _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(_Args&&... __args) { | 1769 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(_Args&&... __args) { |
| 1279 | return optional<_Tp>(in_place, std::forward<_Args>(__args)...); | 1770 | return optional<_Tp>(in_place, std::forward<_Args>(__args)...); |
| 1280 | } | 1771 | } |
| 1281 | 1772 | ||
| 1282 | template <class _Tp, class _Up, class... _Args> | 1773 | template <class _Tp, |
| 1283 | _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up> __il, _Args&&... __args) { | 1774 | class _Up, |
| 1775 | class... _Args, | ||
| 1776 | enable_if_t<__is_constructible_for_optional_initializer_list_v<_Tp, _Up, _Args...>, int> = 0> | ||
| 1777 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> | ||
| 1778 | make_optional(initializer_list<_Up> __il, _Args&&... __args) { | ||
| 1284 | return optional<_Tp>(in_place, __il, std::forward<_Args>(__args)...); | 1779 | return optional<_Tp>(in_place, __il, std::forward<_Args>(__args)...); |
| 1285 | } | 1780 | } |
| 1286 | 1781 | ||
| ... | @@ -1291,7 +1786,7 @@ struct hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > { | ... | @@ -1291,7 +1786,7 @@ struct hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > { |
| 1291 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | 1786 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; |
| 1292 | # endif | 1787 | # endif |
| 1293 | 1788 | ||
| 1294 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const optional<_Tp>& __opt) const { | 1789 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t operator()(const optional<_Tp>& __opt) const { |
| 1295 | return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0; | 1790 | return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0; |
| 1296 | } | 1791 | } |
| 1297 | }; | 1792 | }; |
lib/libcxx/include/print+9-5| ... | @@ -329,7 +329,8 @@ __vprint_unicode([[maybe_unused]] FILE* __stream, | ... | @@ -329,7 +329,8 @@ __vprint_unicode([[maybe_unused]] FILE* __stream, |
| 329 | } // namespace __print | 329 | } // namespace __print |
| 330 | 330 | ||
| 331 | template <class... _Args> | 331 | template <class... _Args> |
| 332 | _LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { | 332 | _LIBCPP_HIDE_FROM_ABI void |
| 333 | print(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, format_string<_Args...> __fmt, _Args&&... __args) { | ||
| 333 | # if _LIBCPP_HAS_UNICODE | 334 | # if _LIBCPP_HAS_UNICODE |
| 334 | if constexpr (__print::__use_unicode_execution_charset) | 335 | if constexpr (__print::__use_unicode_execution_charset) |
| 335 | __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false); | 336 | __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false); |
| ... | @@ -346,7 +347,8 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg | ... | @@ -346,7 +347,8 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg |
| 346 | } | 347 | } |
| 347 | 348 | ||
| 348 | template <class... _Args> | 349 | template <class... _Args> |
| 349 | _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { | 350 | _LIBCPP_HIDE_FROM_ABI void |
| 351 | println(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, format_string<_Args...> __fmt, _Args&&... __args) { | ||
| 350 | # if _LIBCPP_HAS_UNICODE | 352 | # if _LIBCPP_HAS_UNICODE |
| 351 | // Note the wording in the Standard is inefficient. The output of | 353 | // Note the wording in the Standard is inefficient. The output of |
| 352 | // std::format is a std::string which is then copied. This solution | 354 | // std::format is a std::string which is then copied. This solution |
| ... | @@ -361,7 +363,7 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt | ... | @@ -361,7 +363,7 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt |
| 361 | } | 363 | } |
| 362 | 364 | ||
| 363 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | 365 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 364 | _LIBCPP_HIDE_FROM_ABI inline void println(FILE* __stream) { | 366 | _LIBCPP_HIDE_FROM_ABI inline void println(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream) { |
| 365 | std::print(__stream, "\n"); | 367 | std::print(__stream, "\n"); |
| 366 | } | 368 | } |
| 367 | 369 | ||
| ... | @@ -377,7 +379,8 @@ _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __a | ... | @@ -377,7 +379,8 @@ _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __a |
| 377 | 379 | ||
| 378 | # if _LIBCPP_HAS_UNICODE | 380 | # if _LIBCPP_HAS_UNICODE |
| 379 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | 381 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 380 | _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(FILE* __stream, string_view __fmt, format_args __args) { | 382 | _LIBCPP_HIDE_FROM_ABI inline void |
| 383 | vprint_unicode(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, string_view __fmt, format_args __args) { | ||
| 381 | __print::__vprint_unicode(__stream, __fmt, __args, false); | 384 | __print::__vprint_unicode(__stream, __fmt, __args, false); |
| 382 | } | 385 | } |
| 383 | 386 | ||
| ... | @@ -389,7 +392,8 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(string_view __fmt, format_args | ... | @@ -389,7 +392,8 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(string_view __fmt, format_args |
| 389 | # endif // _LIBCPP_HAS_UNICODE | 392 | # endif // _LIBCPP_HAS_UNICODE |
| 390 | 393 | ||
| 391 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). | 394 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 392 | _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args) { | 395 | _LIBCPP_HIDE_FROM_ABI inline void |
| 396 | vprint_nonunicode(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, string_view __fmt, format_args __args) { | ||
| 393 | __print::__vprint_nonunicode(__stream, __fmt, __args, false); | 397 | __print::__vprint_nonunicode(__stream, __fmt, __args, false); |
| 394 | } | 398 | } |
| 395 | 399 |
lib/libcxx/include/queue+39-37| ... | @@ -376,12 +376,12 @@ public: | ... | @@ -376,12 +376,12 @@ public: |
| 376 | # endif // _LIBCPP_CXX03_LANG | 376 | # endif // _LIBCPP_CXX03_LANG |
| 377 | 377 | ||
| 378 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | 378 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 379 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } | 379 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 380 | 380 | ||
| 381 | _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } | 381 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } |
| 382 | _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); } | 382 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); } |
| 383 | _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); } | 383 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); } |
| 384 | _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); } | 384 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); } |
| 385 | 385 | ||
| 386 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } | 386 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } |
| 387 | # ifndef _LIBCPP_CXX03_LANG | 387 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -437,19 +437,19 @@ public: | ... | @@ -437,19 +437,19 @@ public: |
| 437 | }; | 437 | }; |
| 438 | 438 | ||
| 439 | # if _LIBCPP_STD_VER >= 17 | 439 | # if _LIBCPP_STD_VER >= 17 |
| 440 | template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> > | 440 | template <class _Container, class = enable_if_t<!__is_allocator_v<_Container>>> |
| 441 | queue(_Container) -> queue<typename _Container::value_type, _Container>; | 441 | queue(_Container) -> queue<typename _Container::value_type, _Container>; |
| 442 | 442 | ||
| 443 | template <class _Container, | 443 | template <class _Container, |
| 444 | class _Alloc, | 444 | class _Alloc, |
| 445 | class = enable_if_t<!__is_allocator<_Container>::value>, | 445 | class = enable_if_t<!__is_allocator_v<_Container>>, |
| 446 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > | 446 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > |
| 447 | queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>; | 447 | queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>; |
| 448 | # endif | 448 | # endif |
| 449 | 449 | ||
| 450 | # if _LIBCPP_STD_VER >= 23 | 450 | # if _LIBCPP_STD_VER >= 23 |
| 451 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> | 451 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 452 | queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>; | 452 | queue(_InputIterator, _InputIterator) -> queue<__iterator_value_type<_InputIterator>>; |
| 453 | 453 | ||
| 454 | template <ranges::input_range _Range> | 454 | template <ranges::input_range _Range> |
| 455 | queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; | 455 | queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; |
| ... | @@ -457,11 +457,11 @@ queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; | ... | @@ -457,11 +457,11 @@ queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; |
| 457 | template <class _InputIterator, | 457 | template <class _InputIterator, |
| 458 | class _Alloc, | 458 | class _Alloc, |
| 459 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, | 459 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, |
| 460 | __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 460 | __enable_if_t<__is_allocator_v<_Alloc>, int> = 0> |
| 461 | queue(_InputIterator, _InputIterator, _Alloc) | 461 | queue(_InputIterator, _InputIterator, _Alloc) |
| 462 | -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | 462 | -> queue<__iterator_value_type<_InputIterator>, deque<__iterator_value_type<_InputIterator>, _Alloc>>; |
| 463 | 463 | ||
| 464 | template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 464 | template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator_v<_Alloc>, int> = 0> |
| 465 | queue(from_range_t, _Range&&, _Alloc) | 465 | queue(from_range_t, _Range&&, _Alloc) |
| 466 | -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; | 466 | -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; |
| 467 | # endif | 467 | # endif |
| ... | @@ -664,8 +664,10 @@ public: | ... | @@ -664,8 +664,10 @@ public: |
| 664 | # endif | 664 | # endif |
| 665 | 665 | ||
| 666 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | 666 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 667 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } | 667 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 668 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } | 668 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference top() const { |
| 669 | return c.front(); | ||
| 670 | } | ||
| 669 | 671 | ||
| 670 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); | 672 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); |
| 671 | # ifndef _LIBCPP_CXX03_LANG | 673 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -700,45 +702,45 @@ public: | ... | @@ -700,45 +702,45 @@ public: |
| 700 | # if _LIBCPP_STD_VER >= 17 | 702 | # if _LIBCPP_STD_VER >= 17 |
| 701 | template <class _Compare, | 703 | template <class _Compare, |
| 702 | class _Container, | 704 | class _Container, |
| 703 | class = enable_if_t<!__is_allocator<_Compare>::value>, | 705 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 704 | class = enable_if_t<!__is_allocator<_Container>::value> > | 706 | class = enable_if_t<!__is_allocator_v<_Container>>> |
| 705 | priority_queue(_Compare, _Container) -> priority_queue<typename _Container::value_type, _Container, _Compare>; | 707 | priority_queue(_Compare, _Container) -> priority_queue<typename _Container::value_type, _Container, _Compare>; |
| 706 | 708 | ||
| 707 | template <class _InputIterator, | 709 | template <class _InputIterator, |
| 708 | class _Compare = less<__iter_value_type<_InputIterator>>, | 710 | class _Compare = less<__iterator_value_type<_InputIterator>>, |
| 709 | class _Container = vector<__iter_value_type<_InputIterator>>, | 711 | class _Container = vector<__iterator_value_type<_InputIterator>>, |
| 710 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 712 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 711 | class = enable_if_t<!__is_allocator<_Compare>::value>, | 713 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 712 | class = enable_if_t<!__is_allocator<_Container>::value> > | 714 | class = enable_if_t<!__is_allocator_v<_Container>>> |
| 713 | priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) | 715 | priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) |
| 714 | -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; | 716 | -> priority_queue<__iterator_value_type<_InputIterator>, _Container, _Compare>; |
| 715 | 717 | ||
| 716 | template <class _Compare, | 718 | template <class _Compare, |
| 717 | class _Container, | 719 | class _Container, |
| 718 | class _Alloc, | 720 | class _Alloc, |
| 719 | class = enable_if_t<!__is_allocator<_Compare>::value>, | 721 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 720 | class = enable_if_t<!__is_allocator<_Container>::value>, | 722 | class = enable_if_t<!__is_allocator_v<_Container>>, |
| 721 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > | 723 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> |
| 722 | priority_queue(_Compare, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Compare>; | 724 | priority_queue(_Compare, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Compare>; |
| 723 | 725 | ||
| 724 | template <class _InputIterator, | 726 | template <class _InputIterator, |
| 725 | class _Allocator, | 727 | class _Allocator, |
| 726 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 728 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 727 | class = enable_if_t<__is_allocator<_Allocator>::value> > | 729 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 728 | priority_queue(_InputIterator, _InputIterator, _Allocator) | 730 | priority_queue(_InputIterator, _InputIterator, _Allocator) |
| 729 | -> priority_queue<__iter_value_type<_InputIterator>, | 731 | -> priority_queue<__iterator_value_type<_InputIterator>, |
| 730 | vector<__iter_value_type<_InputIterator>, _Allocator>, | 732 | vector<__iterator_value_type<_InputIterator>, _Allocator>, |
| 731 | less<__iter_value_type<_InputIterator>>>; | 733 | less<__iterator_value_type<_InputIterator>>>; |
| 732 | 734 | ||
| 733 | template <class _InputIterator, | 735 | template <class _InputIterator, |
| 734 | class _Compare, | 736 | class _Compare, |
| 735 | class _Allocator, | 737 | class _Allocator, |
| 736 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 738 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 737 | class = enable_if_t<!__is_allocator<_Compare>::value>, | 739 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 738 | class = enable_if_t<__is_allocator<_Allocator>::value> > | 740 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 739 | priority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) | 741 | priority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) |
| 740 | -> priority_queue<__iter_value_type<_InputIterator>, | 742 | -> priority_queue<__iterator_value_type<_InputIterator>, |
| 741 | vector<__iter_value_type<_InputIterator>, _Allocator>, | 743 | vector<__iterator_value_type<_InputIterator>, _Allocator>, |
| 742 | _Compare>; | 744 | _Compare>; |
| 743 | 745 | ||
| 744 | template <class _InputIterator, | 746 | template <class _InputIterator, |
| ... | @@ -746,8 +748,8 @@ template <class _InputIterator, | ... | @@ -746,8 +748,8 @@ template <class _InputIterator, |
| 746 | class _Container, | 748 | class _Container, |
| 747 | class _Alloc, | 749 | class _Alloc, |
| 748 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 750 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 749 | class = enable_if_t<!__is_allocator<_Compare>::value>, | 751 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 750 | class = enable_if_t<!__is_allocator<_Container>::value>, | 752 | class = enable_if_t<!__is_allocator_v<_Container>>, |
| 751 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > | 753 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > |
| 752 | priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) | 754 | priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) |
| 753 | -> priority_queue<typename _Container::value_type, _Container, _Compare>; | 755 | -> priority_queue<typename _Container::value_type, _Container, _Compare>; |
| ... | @@ -757,19 +759,19 @@ priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) | ... | @@ -757,19 +759,19 @@ priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) |
| 757 | 759 | ||
| 758 | template <ranges::input_range _Range, | 760 | template <ranges::input_range _Range, |
| 759 | class _Compare = less<ranges::range_value_t<_Range>>, | 761 | class _Compare = less<ranges::range_value_t<_Range>>, |
| 760 | class = enable_if_t<!__is_allocator<_Compare>::value>> | 762 | class = enable_if_t<!__is_allocator_v<_Compare>>> |
| 761 | priority_queue(from_range_t, _Range&&, _Compare = _Compare()) | 763 | priority_queue(from_range_t, _Range&&, _Compare = _Compare()) |
| 762 | -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>; | 764 | -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>; |
| 763 | 765 | ||
| 764 | template <ranges::input_range _Range, | 766 | template <ranges::input_range _Range, |
| 765 | class _Compare, | 767 | class _Compare, |
| 766 | class _Alloc, | 768 | class _Alloc, |
| 767 | class = enable_if_t<!__is_allocator<_Compare>::value>, | 769 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 768 | class = enable_if_t<__is_allocator<_Alloc>::value>> | 770 | class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 769 | priority_queue(from_range_t, _Range&&, _Compare, _Alloc) | 771 | priority_queue(from_range_t, _Range&&, _Compare, _Alloc) |
| 770 | -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, _Compare>; | 772 | -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, _Compare>; |
| 771 | 773 | ||
| 772 | template <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_allocator<_Alloc>::value>> | 774 | template <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_allocator_v<_Alloc>>> |
| 773 | priority_queue(from_range_t, _Range&&, _Alloc) | 775 | priority_queue(from_range_t, _Range&&, _Alloc) |
| 774 | -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>; | 776 | -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>; |
| 775 | 777 |
lib/libcxx/include/ranges+48| ... | @@ -116,6 +116,10 @@ namespace std::ranges { | ... | @@ -116,6 +116,10 @@ namespace std::ranges { |
| 116 | // [range.dangling], dangling iterator handling | 116 | // [range.dangling], dangling iterator handling |
| 117 | struct dangling; | 117 | struct dangling; |
| 118 | 118 | ||
| 119 | // [range.elementsof], class template elements_of | ||
| 120 | template<range R, class Allocator = allocator<byte>> | ||
| 121 | struct elements_of; | ||
| 122 | |||
| 119 | template<range R> | 123 | template<range R> |
| 120 | using borrowed_iterator_t = see below; | 124 | using borrowed_iterator_t = see below; |
| 121 | 125 | ||
| ... | @@ -267,6 +271,11 @@ namespace std::ranges { | ... | @@ -267,6 +271,11 @@ namespace std::ranges { |
| 267 | template<class W, class Bound> | 271 | template<class W, class Bound> |
| 268 | inline constexpr bool enable_borrowed_range<iota_view<W, Bound>> = true; | 272 | inline constexpr bool enable_borrowed_range<iota_view<W, Bound>> = true; |
| 269 | 273 | ||
| 274 | namespace views { | ||
| 275 | inline constexpr unspecified iota = unspecified; | ||
| 276 | inline constexpr unspecified indices = unspecified; // Since C++26 | ||
| 277 | } | ||
| 278 | |||
| 270 | // [range.repeat], repeat view | 279 | // [range.repeat], repeat view |
| 271 | template<class T> | 280 | template<class T> |
| 272 | concept integer-like-with-usable-difference-type = // exposition only | 281 | concept integer-like-with-usable-difference-type = // exposition only |
| ... | @@ -339,6 +348,41 @@ namespace std::ranges { | ... | @@ -339,6 +348,41 @@ namespace std::ranges { |
| 339 | 348 | ||
| 340 | namespace views { inline constexpr unspecified zip = unspecified; } // C++23 | 349 | namespace views { inline constexpr unspecified zip = unspecified; } // C++23 |
| 341 | 350 | ||
| 351 | // [range.zip.transform], zip transform view | ||
| 352 | template<move_constructible F, input_range... Views> | ||
| 353 | requires (view<Views> && ...) && (sizeof...(Views) > 0) && is_object_v<F> && | ||
| 354 | regular_invocable<F&, range_reference_t<Views>...> && | ||
| 355 | can-reference<invoke_result_t<F&, range_reference_t<Views>...>> | ||
| 356 | class zip_transform_view; // C++23 | ||
| 357 | |||
| 358 | namespace views { inline constexpr unspecified zip_transform = unspecified; } // C++23 | ||
| 359 | |||
| 360 | // [range.adjacent], adjacent view | ||
| 361 | template<forward_range V, size_t N> | ||
| 362 | requires view<V> && (N > 0) | ||
| 363 | class adjacent_view; | ||
| 364 | |||
| 365 | template<class V, size_t N> | ||
| 366 | constexpr bool enable_borrowed_range<adjacent_view<V, N>> = | ||
| 367 | enable_borrowed_range<V>; | ||
| 368 | |||
| 369 | namespace views { | ||
| 370 | template<size_t N> | ||
| 371 | constexpr unspecified adjacent = unspecified; | ||
| 372 | inline constexpr auto pairwise = adjacent<2>; | ||
| 373 | } | ||
| 374 | |||
| 375 | // [range.adjacent.transform], adjacent transform view | ||
| 376 | template<forward_range V, move_constructible F, size_t N> | ||
| 377 | requires see below | ||
| 378 | class adjacent_transform_view; | ||
| 379 | |||
| 380 | namespace views { | ||
| 381 | template<size_t N> | ||
| 382 | constexpr unspecified adjacent_transform = unspecified; | ||
| 383 | inline constexpr auto pairwise_transform = adjacent_transform<2>; | ||
| 384 | } | ||
| 385 | |||
| 342 | // [range.as.rvalue] | 386 | // [range.as.rvalue] |
| 343 | template <view V> | 387 | template <view V> |
| 344 | requires input_range<V> | 388 | requires input_range<V> |
| ... | @@ -404,6 +448,7 @@ namespace std { | ... | @@ -404,6 +448,7 @@ namespace std { |
| 404 | # include <__ranges/data.h> | 448 | # include <__ranges/data.h> |
| 405 | # include <__ranges/drop_view.h> | 449 | # include <__ranges/drop_view.h> |
| 406 | # include <__ranges/drop_while_view.h> | 450 | # include <__ranges/drop_while_view.h> |
| 451 | # include <__ranges/elements_of.h> | ||
| 407 | # include <__ranges/elements_view.h> | 452 | # include <__ranges/elements_view.h> |
| 408 | # include <__ranges/empty.h> | 453 | # include <__ranges/empty.h> |
| 409 | # include <__ranges/empty_view.h> | 454 | # include <__ranges/empty_view.h> |
| ... | @@ -433,12 +478,15 @@ namespace std { | ... | @@ -433,12 +478,15 @@ namespace std { |
| 433 | # endif | 478 | # endif |
| 434 | 479 | ||
| 435 | # if _LIBCPP_STD_VER >= 23 | 480 | # if _LIBCPP_STD_VER >= 23 |
| 481 | # include <__ranges/adjacent_transform_view.h> | ||
| 482 | # include <__ranges/adjacent_view.h> | ||
| 436 | # include <__ranges/as_rvalue_view.h> | 483 | # include <__ranges/as_rvalue_view.h> |
| 437 | # include <__ranges/chunk_by_view.h> | 484 | # include <__ranges/chunk_by_view.h> |
| 438 | # include <__ranges/from_range.h> | 485 | # include <__ranges/from_range.h> |
| 439 | # include <__ranges/join_with_view.h> | 486 | # include <__ranges/join_with_view.h> |
| 440 | # include <__ranges/repeat_view.h> | 487 | # include <__ranges/repeat_view.h> |
| 441 | # include <__ranges/to.h> | 488 | # include <__ranges/to.h> |
| 489 | # include <__ranges/zip_transform_view.h> | ||
| 442 | # include <__ranges/zip_view.h> | 490 | # include <__ranges/zip_view.h> |
| 443 | # endif | 491 | # endif |
| 444 | 492 |
lib/libcxx/include/regex+33-31| ... | @@ -986,7 +986,7 @@ public: | ... | @@ -986,7 +986,7 @@ public: |
| 986 | explicit regex_error(regex_constants::error_type __ecode); | 986 | explicit regex_error(regex_constants::error_type __ecode); |
| 987 | _LIBCPP_HIDE_FROM_ABI regex_error(const regex_error&) _NOEXCEPT = default; | 987 | _LIBCPP_HIDE_FROM_ABI regex_error(const regex_error&) _NOEXCEPT = default; |
| 988 | ~regex_error() _NOEXCEPT override; | 988 | ~regex_error() _NOEXCEPT override; |
| 989 | _LIBCPP_HIDE_FROM_ABI regex_constants::error_type code() const { return __code_; } | 989 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI regex_constants::error_type code() const { return __code_; } |
| 990 | }; | 990 | }; |
| 991 | 991 | ||
| 992 | template <regex_constants::error_type _Ev> | 992 | template <regex_constants::error_type _Ev> |
| ... | @@ -1004,7 +1004,7 @@ public: | ... | @@ -1004,7 +1004,7 @@ public: |
| 1004 | typedef _CharT char_type; | 1004 | typedef _CharT char_type; |
| 1005 | typedef basic_string<char_type> string_type; | 1005 | typedef basic_string<char_type> string_type; |
| 1006 | typedef locale locale_type; | 1006 | typedef locale locale_type; |
| 1007 | # if defined(__BIONIC__) || defined(_NEWLIB_VERSION) | 1007 | # if defined(__BIONIC__) || _LIBCPP_LIBC_NEWLIB |
| 1008 | // Originally bionic's ctype_base used its own ctype masks because the | 1008 | // Originally bionic's ctype_base used its own ctype masks because the |
| 1009 | // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask | 1009 | // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask |
| 1010 | // was only 8 bits wide and already saturated, so it used a wider type here | 1010 | // was only 8 bits wide and already saturated, so it used a wider type here |
| ... | @@ -1013,9 +1013,7 @@ public: | ... | @@ -1013,9 +1013,7 @@ public: |
| 1013 | // implementation, but this was not updated to match. Since then Android has | 1013 | // implementation, but this was not updated to match. Since then Android has |
| 1014 | // needed to maintain a stable libc++ ABI, and this can't be changed without | 1014 | // needed to maintain a stable libc++ ABI, and this can't be changed without |
| 1015 | // an ABI break. | 1015 | // an ABI break. |
| 1016 | // We also need this workaround for newlib since _NEWLIB_VERSION is not | 1016 | // We also need this workaround for newlib since newlib is |
| 1017 | // defined yet inside __config, so we can't set the | ||
| 1018 | // _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE macro. Additionally, newlib is | ||
| 1019 | // often used for space constrained environments, so it makes sense not to | 1017 | // often used for space constrained environments, so it makes sense not to |
| 1020 | // duplicate the ctype table. | 1018 | // duplicate the ctype table. |
| 1021 | typedef uint16_t char_class_type; | 1019 | typedef uint16_t char_class_type; |
| ... | @@ -2120,7 +2118,7 @@ public: | ... | @@ -2120,7 +2118,7 @@ public: |
| 2120 | __ranges_.push_back( | 2118 | __ranges_.push_back( |
| 2121 | std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end()))); | 2119 | std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end()))); |
| 2122 | } else { | 2120 | } else { |
| 2123 | if (__b.size() != 1 || __e.size() != 1) | 2121 | if (__b.size() != 1 || __e.size() != 1 || char_traits<typename string_type::value_type>::lt(__e[0], __b[0])) |
| 2124 | std::__throw_regex_error<regex_constants::error_range>(); | 2122 | std::__throw_regex_error<regex_constants::error_range>(); |
| 2125 | if (__icase_) { | 2123 | if (__icase_) { |
| 2126 | __b[0] = __traits_.translate_nocase(__b[0]); | 2124 | __b[0] = __traits_.translate_nocase(__b[0]); |
| ... | @@ -2414,8 +2412,8 @@ public: | ... | @@ -2414,8 +2412,8 @@ public: |
| 2414 | # endif // _LIBCPP_CXX03_LANG | 2412 | # endif // _LIBCPP_CXX03_LANG |
| 2415 | 2413 | ||
| 2416 | // const operations: | 2414 | // const operations: |
| 2417 | _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; } | 2415 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; } |
| 2418 | _LIBCPP_HIDE_FROM_ABI flag_type flags() const { return __flags_; } | 2416 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI flag_type flags() const { return __flags_; } |
| 2419 | 2417 | ||
| 2420 | // locale: | 2418 | // locale: |
| 2421 | _LIBCPP_HIDE_FROM_ABI locale_type imbue(locale_type __loc) { | 2419 | _LIBCPP_HIDE_FROM_ABI locale_type imbue(locale_type __loc) { |
| ... | @@ -2423,7 +2421,7 @@ public: | ... | @@ -2423,7 +2421,7 @@ public: |
| 2423 | __start_.reset(); | 2421 | __start_.reset(); |
| 2424 | return __traits_.imbue(__loc); | 2422 | return __traits_.imbue(__loc); |
| 2425 | } | 2423 | } |
| 2426 | _LIBCPP_HIDE_FROM_ABI locale_type getloc() const { return __traits_.getloc(); } | 2424 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI locale_type getloc() const { return __traits_.getloc(); } |
| 2427 | 2425 | ||
| 2428 | // swap: | 2426 | // swap: |
| 2429 | void swap(basic_regex& __r); | 2427 | void swap(basic_regex& __r); |
| ... | @@ -4208,17 +4206,17 @@ public: | ... | @@ -4208,17 +4206,17 @@ public: |
| 4208 | 4206 | ||
| 4209 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR sub_match() : matched() {} | 4207 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR sub_match() : matched() {} |
| 4210 | 4208 | ||
| 4211 | _LIBCPP_HIDE_FROM_ABI difference_type length() const { | 4209 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI difference_type length() const { |
| 4212 | return matched ? std::distance(this->first, this->second) : 0; | 4210 | return matched ? std::distance(this->first, this->second) : 0; |
| 4213 | } | 4211 | } |
| 4214 | _LIBCPP_HIDE_FROM_ABI string_type str() const { | 4212 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type str() const { |
| 4215 | return matched ? string_type(this->first, this->second) : string_type(); | 4213 | return matched ? string_type(this->first, this->second) : string_type(); |
| 4216 | } | 4214 | } |
| 4217 | _LIBCPP_HIDE_FROM_ABI operator string_type() const { return str(); } | 4215 | _LIBCPP_HIDE_FROM_ABI operator string_type() const { return str(); } |
| 4218 | 4216 | ||
| 4219 | _LIBCPP_HIDE_FROM_ABI int compare(const sub_match& __s) const { return str().compare(__s.str()); } | 4217 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int compare(const sub_match& __s) const { return str().compare(__s.str()); } |
| 4220 | _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return str().compare(__s); } | 4218 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return str().compare(__s); } |
| 4221 | _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return str().compare(__s); } | 4219 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return str().compare(__s); } |
| 4222 | 4220 | ||
| 4223 | _LIBCPP_HIDE_FROM_ABI void swap(sub_match& __s) _NOEXCEPT_(__is_nothrow_swappable_v<_BidirectionalIterator>) { | 4221 | _LIBCPP_HIDE_FROM_ABI void swap(sub_match& __s) _NOEXCEPT_(__is_nothrow_swappable_v<_BidirectionalIterator>) { |
| 4224 | this->pair<_BidirectionalIterator, _BidirectionalIterator>::swap(__s); | 4222 | this->pair<_BidirectionalIterator, _BidirectionalIterator>::swap(__s); |
| ... | @@ -4583,49 +4581,53 @@ public: | ... | @@ -4583,49 +4581,53 @@ public: |
| 4583 | _LIBCPP_HIDE_FROM_ABI bool ready() const { return __ready_; } | 4581 | _LIBCPP_HIDE_FROM_ABI bool ready() const { return __ready_; } |
| 4584 | 4582 | ||
| 4585 | // size: | 4583 | // size: |
| 4586 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); } | 4584 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); } |
| 4587 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); } | 4585 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); } |
| 4588 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | 4586 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } |
| 4589 | 4587 | ||
| 4590 | // element access: | 4588 | // element access: |
| 4591 | _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const { | 4589 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const { |
| 4592 | // If the match results are not ready, this will return `0`. | 4590 | // If the match results are not ready, this will return `0`. |
| 4593 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::length() called when not ready"); | 4591 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::length() called when not ready"); |
| 4594 | return (*this)[__sub].length(); | 4592 | return (*this)[__sub].length(); |
| 4595 | } | 4593 | } |
| 4596 | _LIBCPP_HIDE_FROM_ABI difference_type position(size_type __sub = 0) const { | 4594 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI difference_type position(size_type __sub = 0) const { |
| 4597 | // If the match results are not ready, this will return the result of subtracting two default-constructed iterators | 4595 | // If the match results are not ready, this will return the result of subtracting two default-constructed iterators |
| 4598 | // (which is typically a well-defined operation). | 4596 | // (which is typically a well-defined operation). |
| 4599 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::position() called when not ready"); | 4597 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::position() called when not ready"); |
| 4600 | return std::distance(__position_start_, (*this)[__sub].first); | 4598 | return std::distance(__position_start_, (*this)[__sub].first); |
| 4601 | } | 4599 | } |
| 4602 | _LIBCPP_HIDE_FROM_ABI string_type str(size_type __sub = 0) const { | 4600 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type str(size_type __sub = 0) const { |
| 4603 | // If the match results are not ready, this will return an empty string. | 4601 | // If the match results are not ready, this will return an empty string. |
| 4604 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::str() called when not ready"); | 4602 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::str() called when not ready"); |
| 4605 | return (*this)[__sub].str(); | 4603 | return (*this)[__sub].str(); |
| 4606 | } | 4604 | } |
| 4607 | _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const { | 4605 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const { |
| 4608 | // If the match results are not ready, this call will be equivalent to calling this function with `__n >= size()`, | 4606 | // If the match results are not ready, this call will be equivalent to calling this function with `__n >= size()`, |
| 4609 | // returning an empty subrange. | 4607 | // returning an empty subrange. |
| 4610 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::operator[]() called when not ready"); | 4608 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::operator[]() called when not ready"); |
| 4611 | return __n < __matches_.size() ? __matches_[__n] : __unmatched_; | 4609 | return __n < __matches_.size() ? __matches_[__n] : __unmatched_; |
| 4612 | } | 4610 | } |
| 4613 | 4611 | ||
| 4614 | _LIBCPP_HIDE_FROM_ABI const_reference prefix() const { | 4612 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference prefix() const { |
| 4615 | // If the match results are not ready, this will return a default-constructed empty `__suffix_`. | 4613 | // If the match results are not ready, this will return a default-constructed empty `__suffix_`. |
| 4616 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::prefix() called when not ready"); | 4614 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::prefix() called when not ready"); |
| 4617 | return __prefix_; | 4615 | return __prefix_; |
| 4618 | } | 4616 | } |
| 4619 | _LIBCPP_HIDE_FROM_ABI const_reference suffix() const { | 4617 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference suffix() const { |
| 4620 | // If the match results are not ready, this will return a default-constructed empty `__suffix_`. | 4618 | // If the match results are not ready, this will return a default-constructed empty `__suffix_`. |
| 4621 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::suffix() called when not ready"); | 4619 | _LIBCPP_ASSERT_PEDANTIC(ready(), "match_results::suffix() called when not ready"); |
| 4622 | return __suffix_; | 4620 | return __suffix_; |
| 4623 | } | 4621 | } |
| 4624 | 4622 | ||
| 4625 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return empty() ? __matches_.end() : __matches_.begin(); } | 4623 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { |
| 4626 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __matches_.end(); } | 4624 | return empty() ? __matches_.end() : __matches_.begin(); |
| 4627 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const { return empty() ? __matches_.end() : __matches_.begin(); } | 4625 | } |
| 4628 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const { return __matches_.end(); } | 4626 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __matches_.end(); } |
| 4627 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const { | ||
| 4628 | return empty() ? __matches_.end() : __matches_.begin(); | ||
| 4629 | } | ||
| 4630 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const { return __matches_.end(); } | ||
| 4629 | 4631 | ||
| 4630 | // format: | 4632 | // format: |
| 4631 | template <class _OutputIter> | 4633 | template <class _OutputIter> |
| ... | @@ -4641,14 +4643,14 @@ public: | ... | @@ -4641,14 +4643,14 @@ public: |
| 4641 | return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags); | 4643 | return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags); |
| 4642 | } | 4644 | } |
| 4643 | template <class _ST, class _SA> | 4645 | template <class _ST, class _SA> |
| 4644 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, _ST, _SA> | 4646 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_string<char_type, _ST, _SA> |
| 4645 | format(const basic_string<char_type, _ST, _SA>& __fmt, | 4647 | format(const basic_string<char_type, _ST, _SA>& __fmt, |
| 4646 | regex_constants::match_flag_type __flags = regex_constants::format_default) const { | 4648 | regex_constants::match_flag_type __flags = regex_constants::format_default) const { |
| 4647 | basic_string<char_type, _ST, _SA> __r; | 4649 | basic_string<char_type, _ST, _SA> __r; |
| 4648 | format(std::back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(), __flags); | 4650 | format(std::back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(), __flags); |
| 4649 | return __r; | 4651 | return __r; |
| 4650 | } | 4652 | } |
| 4651 | _LIBCPP_HIDE_FROM_ABI string_type | 4653 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type |
| 4652 | format(const char_type* __fmt, regex_constants::match_flag_type __flags = regex_constants::format_default) const { | 4654 | format(const char_type* __fmt, regex_constants::match_flag_type __flags = regex_constants::format_default) const { |
| 4653 | string_type __r; | 4655 | string_type __r; |
| 4654 | format(std::back_inserter(__r), __fmt, __fmt + char_traits<char_type>::length(__fmt), __flags); | 4656 | format(std::back_inserter(__r), __fmt, __fmt + char_traits<char_type>::length(__fmt), __flags); |
| ... | @@ -4656,7 +4658,7 @@ public: | ... | @@ -4656,7 +4658,7 @@ public: |
| 4656 | } | 4658 | } |
| 4657 | 4659 | ||
| 4658 | // allocator: | 4660 | // allocator: |
| 4659 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const { return __matches_.get_allocator(); } | 4661 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const { return __matches_.get_allocator(); } |
| 4660 | 4662 | ||
| 4661 | // swap: | 4663 | // swap: |
| 4662 | void swap(match_results& __m); | 4664 | void swap(match_results& __m); |
| ... | @@ -5377,7 +5379,7 @@ public: | ... | @@ -5377,7 +5379,7 @@ public: |
| 5377 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); } | 5379 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); } |
| 5378 | # endif | 5380 | # endif |
| 5379 | 5381 | ||
| 5380 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; } | 5382 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; } |
| 5381 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); } | 5383 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); } |
| 5382 | 5384 | ||
| 5383 | regex_iterator& operator++(); | 5385 | regex_iterator& operator++(); |
| ... | @@ -5558,7 +5560,7 @@ public: | ... | @@ -5558,7 +5560,7 @@ public: |
| 5558 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); } | 5560 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); } |
| 5559 | # endif | 5561 | # endif |
| 5560 | 5562 | ||
| 5561 | _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; } | 5563 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; } |
| 5562 | _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; } | 5564 | _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; } |
| 5563 | 5565 | ||
| 5564 | regex_token_iterator& operator++(); | 5566 | regex_token_iterator& operator++(); |
lib/libcxx/include/scoped_allocator+16-11| ... | @@ -382,13 +382,17 @@ public: | ... | @@ -382,13 +382,17 @@ public: |
| 382 | // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; | 382 | // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; |
| 383 | // ~scoped_allocator_adaptor() = default; | 383 | // ~scoped_allocator_adaptor() = default; |
| 384 | 384 | ||
| 385 | _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return _Base::inner_allocator(); } | 385 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { |
| 386 | _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT { | 386 | return _Base::inner_allocator(); |
| 387 | } | ||
| 388 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT { | ||
| 387 | return _Base::inner_allocator(); | 389 | return _Base::inner_allocator(); |
| 388 | } | 390 | } |
| 389 | 391 | ||
| 390 | _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return _Base::outer_allocator(); } | 392 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { |
| 391 | _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT { | 393 | return _Base::outer_allocator(); |
| 394 | } | ||
| 395 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT { | ||
| 392 | return _Base::outer_allocator(); | 396 | return _Base::outer_allocator(); |
| 393 | } | 397 | } |
| 394 | 398 | ||
| ... | @@ -403,7 +407,7 @@ public: | ... | @@ -403,7 +407,7 @@ public: |
| 403 | allocator_traits<outer_allocator_type>::deallocate(outer_allocator(), __p, __n); | 407 | allocator_traits<outer_allocator_type>::deallocate(outer_allocator(), __p, __n); |
| 404 | } | 408 | } |
| 405 | 409 | ||
| 406 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const { | 410 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const { |
| 407 | return allocator_traits<outer_allocator_type>::max_size(outer_allocator()); | 411 | return allocator_traits<outer_allocator_type>::max_size(outer_allocator()); |
| 408 | } | 412 | } |
| 409 | 413 | ||
| ... | @@ -434,10 +438,10 @@ public: | ... | @@ -434,10 +438,10 @@ public: |
| 434 | piecewise_construct, | 438 | piecewise_construct, |
| 435 | __transform_tuple(typename __uses_alloc_ctor< _T1, inner_allocator_type&, _Args1... >::type(), | 439 | __transform_tuple(typename __uses_alloc_ctor< _T1, inner_allocator_type&, _Args1... >::type(), |
| 436 | std::move(__x), | 440 | std::move(__x), |
| 437 | typename __make_tuple_indices<sizeof...(_Args1)>::type{}), | 441 | __index_sequence_for<_Args1...>()), |
| 438 | __transform_tuple(typename __uses_alloc_ctor< _T2, inner_allocator_type&, _Args2... >::type(), | 442 | __transform_tuple(typename __uses_alloc_ctor< _T2, inner_allocator_type&, _Args2... >::type(), |
| 439 | std::move(__y), | 443 | std::move(__y), |
| 440 | typename __make_tuple_indices<sizeof...(_Args2)>::type{})); | 444 | __index_sequence_for<_Args2...>())); |
| 441 | } | 445 | } |
| 442 | 446 | ||
| 443 | template <class _T1, class _T2> | 447 | template <class _T1, class _T2> |
| ... | @@ -473,7 +477,8 @@ public: | ... | @@ -473,7 +477,8 @@ public: |
| 473 | allocator_traits<typename _OM::type>::destroy(_OM()(outer_allocator()), __p); | 477 | allocator_traits<typename _OM::type>::destroy(_OM()(outer_allocator()), __p); |
| 474 | } | 478 | } |
| 475 | 479 | ||
| 476 | _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT { | 480 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor |
| 481 | select_on_container_copy_construction() const _NOEXCEPT { | ||
| 477 | return _Base::select_on_container_copy_construction(); | 482 | return _Base::select_on_container_copy_construction(); |
| 478 | } | 483 | } |
| 479 | 484 | ||
| ... | @@ -503,20 +508,20 @@ private: | ... | @@ -503,20 +508,20 @@ private: |
| 503 | 508 | ||
| 504 | template <class... _Args, size_t... _Idx> | 509 | template <class... _Args, size_t... _Idx> |
| 505 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...> | 510 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...> |
| 506 | __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) { | 511 | __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, __index_sequence<_Idx...>) { |
| 507 | return std::forward_as_tuple(std::get<_Idx>(std::move(__t))...); | 512 | return std::forward_as_tuple(std::get<_Idx>(std::move(__t))...); |
| 508 | } | 513 | } |
| 509 | 514 | ||
| 510 | template <class... _Args, size_t... _Idx> | 515 | template <class... _Args, size_t... _Idx> |
| 511 | _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t, inner_allocator_type&, _Args&&...> | 516 | _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t, inner_allocator_type&, _Args&&...> |
| 512 | __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) { | 517 | __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, __index_sequence<_Idx...>) { |
| 513 | using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>; | 518 | using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>; |
| 514 | return _Tup(allocator_arg, inner_allocator(), std::get<_Idx>(std::move(__t))...); | 519 | return _Tup(allocator_arg, inner_allocator(), std::get<_Idx>(std::move(__t))...); |
| 515 | } | 520 | } |
| 516 | 521 | ||
| 517 | template <class... _Args, size_t... _Idx> | 522 | template <class... _Args, size_t... _Idx> |
| 518 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., inner_allocator_type&> | 523 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., inner_allocator_type&> |
| 519 | __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) { | 524 | __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, __index_sequence<_Idx...>) { |
| 520 | using _Tup = tuple<_Args&&..., inner_allocator_type&>; | 525 | using _Tup = tuple<_Args&&..., inner_allocator_type&>; |
| 521 | return _Tup(std::get<_Idx>(std::move(__t))..., inner_allocator()); | 526 | return _Tup(std::get<_Idx>(std::move(__t))..., inner_allocator()); |
| 522 | } | 527 | } |
lib/libcxx/include/semaphore+15-18| ... | @@ -55,12 +55,11 @@ using binary_semaphore = counting_semaphore<1>; // since C++20 | ... | @@ -55,12 +55,11 @@ using binary_semaphore = counting_semaphore<1>; // since C++20 |
| 55 | # include <__assert> | 55 | # include <__assert> |
| 56 | # include <__atomic/atomic.h> | 56 | # include <__atomic/atomic.h> |
| 57 | # include <__atomic/atomic_sync.h> | 57 | # include <__atomic/atomic_sync.h> |
| 58 | # include <__atomic/atomic_sync_timed.h> | ||
| 58 | # include <__atomic/memory_order.h> | 59 | # include <__atomic/memory_order.h> |
| 59 | # include <__chrono/time_point.h> | 60 | # include <__chrono/time_point.h> |
| 60 | # include <__cstddef/ptrdiff_t.h> | 61 | # include <__cstddef/ptrdiff_t.h> |
| 61 | # include <__thread/poll_with_backoff.h> | ||
| 62 | # include <__thread/support.h> | 62 | # include <__thread/support.h> |
| 63 | # include <__thread/timed_backoff_policy.h> | ||
| 64 | # include <limits> | 63 | # include <limits> |
| 65 | # include <version> | 64 | # include <version> |
| 66 | 65 | ||
| ... | @@ -90,7 +89,7 @@ class __atomic_semaphore_base { | ... | @@ -90,7 +89,7 @@ class __atomic_semaphore_base { |
| 90 | 89 | ||
| 91 | public: | 90 | public: |
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a_(__count) {} | 91 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a_(__count) {} |
| 93 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void release(ptrdiff_t __update = 1) { | 92 | _LIBCPP_HIDE_FROM_ABI void release(ptrdiff_t __update = 1) { |
| 94 | auto __old = __a_.fetch_add(__update, memory_order_release); | 93 | auto __old = __a_.fetch_add(__update, memory_order_release); |
| 95 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 94 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 96 | __update <= _LIBCPP_SEMAPHORE_MAX - __old, "update is greater than the expected value"); | 95 | __update <= _LIBCPP_SEMAPHORE_MAX - __old, "update is greater than the expected value"); |
| ... | @@ -98,26 +97,26 @@ public: | ... | @@ -98,26 +97,26 @@ public: |
| 98 | __a_.notify_all(); | 97 | __a_.notify_all(); |
| 99 | } | 98 | } |
| 100 | } | 99 | } |
| 101 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() { | 100 | _LIBCPP_HIDE_FROM_ABI void acquire() { |
| 102 | std::__atomic_wait_unless(__a_, memory_order_relaxed, [this](ptrdiff_t& __old) { | 101 | std::__atomic_wait_unless(__a_, memory_order_relaxed, [this](ptrdiff_t& __old) { |
| 103 | return __try_acquire_impl(__old); | 102 | return __try_acquire_impl(__old); |
| 104 | }); | 103 | }); |
| 105 | } | 104 | } |
| 106 | template <class _Rep, class _Period> | 105 | template <class _Rep, class _Period> |
| 107 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool | 106 | _LIBCPP_HIDE_FROM_ABI bool try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { |
| 108 | try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { | ||
| 109 | if (__rel_time == chrono::duration<_Rep, _Period>::zero()) | 107 | if (__rel_time == chrono::duration<_Rep, _Period>::zero()) |
| 110 | return try_acquire(); | 108 | return try_acquire(); |
| 111 | auto const __poll_fn = [this]() { return try_acquire(); }; | 109 | |
| 112 | return std::__libcpp_thread_poll_with_backoff(__poll_fn, __libcpp_timed_backoff_policy(), __rel_time); | 110 | return std::__atomic_wait_unless_with_timeout( |
| 111 | __a_, memory_order_relaxed, [this](ptrdiff_t& __old) { return __try_acquire_impl(__old); }, __rel_time); | ||
| 113 | } | 112 | } |
| 114 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool try_acquire() { | 113 | _LIBCPP_HIDE_FROM_ABI bool try_acquire() { |
| 115 | auto __old = __a_.load(memory_order_relaxed); | 114 | auto __old = __a_.load(memory_order_relaxed); |
| 116 | return __try_acquire_impl(__old); | 115 | return __try_acquire_impl(__old); |
| 117 | } | 116 | } |
| 118 | 117 | ||
| 119 | private: | 118 | private: |
| 120 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __try_acquire_impl(ptrdiff_t& __old) { | 119 | _LIBCPP_HIDE_FROM_ABI bool __try_acquire_impl(ptrdiff_t& __old) { |
| 121 | while (true) { | 120 | while (true) { |
| 122 | if (__old == 0) | 121 | if (__old == 0) |
| 123 | return false; | 122 | return false; |
| ... | @@ -134,7 +133,7 @@ class counting_semaphore { | ... | @@ -134,7 +133,7 @@ class counting_semaphore { |
| 134 | public: | 133 | public: |
| 135 | static_assert(__least_max_value >= 0, "The least maximum value must be a positive number"); | 134 | static_assert(__least_max_value >= 0, "The least maximum value must be a positive number"); |
| 136 | 135 | ||
| 137 | static constexpr ptrdiff_t max() noexcept { return __least_max_value; } | 136 | [[nodiscard]] static constexpr ptrdiff_t max() noexcept { return __least_max_value; } |
| 138 | 137 | ||
| 139 | _LIBCPP_HIDE_FROM_ABI constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore_(__count) { | 138 | _LIBCPP_HIDE_FROM_ABI constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore_(__count) { |
| 140 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | 139 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| ... | @@ -151,20 +150,18 @@ public: | ... | @@ -151,20 +150,18 @@ public: |
| 151 | counting_semaphore(const counting_semaphore&) = delete; | 150 | counting_semaphore(const counting_semaphore&) = delete; |
| 152 | counting_semaphore& operator=(const counting_semaphore&) = delete; | 151 | counting_semaphore& operator=(const counting_semaphore&) = delete; |
| 153 | 152 | ||
| 154 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void release(ptrdiff_t __update = 1) { | 153 | _LIBCPP_HIDE_FROM_ABI void release(ptrdiff_t __update = 1) { |
| 155 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "counting_semaphore:release called with a negative value"); | 154 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "counting_semaphore:release called with a negative value"); |
| 156 | __semaphore_.release(__update); | 155 | __semaphore_.release(__update); |
| 157 | } | 156 | } |
| 158 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() { __semaphore_.acquire(); } | 157 | _LIBCPP_HIDE_FROM_ABI void acquire() { __semaphore_.acquire(); } |
| 159 | template <class _Rep, class _Period> | 158 | template <class _Rep, class _Period> |
| 160 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool | 159 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { |
| 161 | try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { | ||
| 162 | return __semaphore_.try_acquire_for(chrono::duration_cast<chrono::nanoseconds>(__rel_time)); | 160 | return __semaphore_.try_acquire_for(chrono::duration_cast<chrono::nanoseconds>(__rel_time)); |
| 163 | } | 161 | } |
| 164 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool try_acquire() { return __semaphore_.try_acquire(); } | 162 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool try_acquire() { return __semaphore_.try_acquire(); } |
| 165 | template <class _Clock, class _Duration> | 163 | template <class _Clock, class _Duration> |
| 166 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool | 164 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool try_acquire_until(chrono::time_point<_Clock, _Duration> const& __abs_time) { |
| 167 | try_acquire_until(chrono::time_point<_Clock, _Duration> const& __abs_time) { | ||
| 168 | auto const __current = _Clock::now(); | 165 | auto const __current = _Clock::now(); |
| 169 | if (__current >= __abs_time) | 166 | if (__current >= __abs_time) |
| 170 | return try_acquire(); | 167 | return try_acquire(); |
lib/libcxx/include/set+220-192| ... | @@ -518,19 +518,19 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -518,19 +518,19 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
| 518 | # include <__algorithm/equal.h> | 518 | # include <__algorithm/equal.h> |
| 519 | # include <__algorithm/lexicographical_compare.h> | 519 | # include <__algorithm/lexicographical_compare.h> |
| 520 | # include <__algorithm/lexicographical_compare_three_way.h> | 520 | # include <__algorithm/lexicographical_compare_three_way.h> |
| 521 | # include <__algorithm/specialized_algorithms.h> | ||
| 521 | # include <__assert> | 522 | # include <__assert> |
| 522 | # include <__config> | 523 | # include <__config> |
| 523 | # include <__functional/is_transparent.h> | 524 | # include <__functional/is_transparent.h> |
| 524 | # include <__functional/operations.h> | 525 | # include <__functional/operations.h> |
| 525 | # include <__fwd/set.h> | ||
| 526 | # include <__iterator/erase_if_container.h> | 526 | # include <__iterator/erase_if_container.h> |
| 527 | # include <__iterator/iterator_traits.h> | 527 | # include <__iterator/iterator_traits.h> |
| 528 | # include <__iterator/ranges_iterator_traits.h> | ||
| 529 | # include <__iterator/reverse_iterator.h> | 528 | # include <__iterator/reverse_iterator.h> |
| 530 | # include <__memory/allocator.h> | 529 | # include <__memory/allocator.h> |
| 531 | # include <__memory/allocator_traits.h> | 530 | # include <__memory/allocator_traits.h> |
| 532 | # include <__memory_resource/polymorphic_allocator.h> | 531 | # include <__memory_resource/polymorphic_allocator.h> |
| 533 | # include <__node_handle> | 532 | # include <__node_handle> |
| 533 | # include <__ranges/access.h> | ||
| 534 | # include <__ranges/concepts.h> | 534 | # include <__ranges/concepts.h> |
| 535 | # include <__ranges/container_compatible_range.h> | 535 | # include <__ranges/container_compatible_range.h> |
| 536 | # include <__ranges/from_range.h> | 536 | # include <__ranges/from_range.h> |
| ... | @@ -538,7 +538,6 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -538,7 +538,6 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
| 538 | # include <__type_traits/container_traits.h> | 538 | # include <__type_traits/container_traits.h> |
| 539 | # include <__type_traits/enable_if.h> | 539 | # include <__type_traits/enable_if.h> |
| 540 | # include <__type_traits/is_allocator.h> | 540 | # include <__type_traits/is_allocator.h> |
| 541 | # include <__type_traits/is_nothrow_assignable.h> | ||
| 542 | # include <__type_traits/is_nothrow_constructible.h> | 541 | # include <__type_traits/is_nothrow_constructible.h> |
| 543 | # include <__type_traits/is_same.h> | 542 | # include <__type_traits/is_same.h> |
| 544 | # include <__type_traits/is_swappable.h> | 543 | # include <__type_traits/is_swappable.h> |
| ... | @@ -570,7 +569,10 @@ _LIBCPP_PUSH_MACROS | ... | @@ -570,7 +569,10 @@ _LIBCPP_PUSH_MACROS |
| 570 | 569 | ||
| 571 | _LIBCPP_BEGIN_NAMESPACE_STD | 570 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 572 | 571 | ||
| 573 | template <class _Key, class _Compare, class _Allocator> | 572 | template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > |
| 573 | class multiset; | ||
| 574 | |||
| 575 | template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > | ||
| 574 | class set { | 576 | class set { |
| 575 | public: | 577 | public: |
| 576 | // types: | 578 | // types: |
| ... | @@ -660,22 +662,20 @@ public: | ... | @@ -660,22 +662,20 @@ public: |
| 660 | : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {} | 662 | : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 661 | # endif | 663 | # endif |
| 662 | 664 | ||
| 663 | _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); } | 665 | _LIBCPP_HIDE_FROM_ABI set(const set& __s) = default; |
| 664 | 666 | ||
| 665 | _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) = default; | 667 | _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) = default; |
| 666 | 668 | ||
| 667 | # ifndef _LIBCPP_CXX03_LANG | 669 | # ifndef _LIBCPP_CXX03_LANG |
| 668 | _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value) = default; | 670 | _LIBCPP_HIDE_FROM_ABI set(set&& __s) = default; |
| 669 | # endif // _LIBCPP_CXX03_LANG | 671 | # endif // _LIBCPP_CXX03_LANG |
| 670 | 672 | ||
| 671 | _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {} | 673 | _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {} |
| 672 | 674 | ||
| 673 | _LIBCPP_HIDE_FROM_ABI set(const set& __s, const allocator_type& __a) : __tree_(__s.__tree_.value_comp(), __a) { | 675 | _LIBCPP_HIDE_FROM_ABI set(const set& __s, const allocator_type& __alloc) : __tree_(__s.__tree_, __alloc) {} |
| 674 | insert(__s.begin(), __s.end()); | ||
| 675 | } | ||
| 676 | 676 | ||
| 677 | # ifndef _LIBCPP_CXX03_LANG | 677 | # ifndef _LIBCPP_CXX03_LANG |
| 678 | _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a); | 678 | _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __alloc) : __tree_(std::move(__s.__tree_), __alloc) {} |
| 679 | 679 | ||
| 680 | _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) | 680 | _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 681 | : __tree_(__comp) { | 681 | : __tree_(__comp) { |
| ... | @@ -693,36 +693,38 @@ public: | ... | @@ -693,36 +693,38 @@ public: |
| 693 | # endif | 693 | # endif |
| 694 | 694 | ||
| 695 | _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) { | 695 | _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) { |
| 696 | __tree_.__assign_unique(__il.begin(), __il.end()); | 696 | clear(); |
| 697 | insert(__il.begin(), __il.end()); | ||
| 697 | return *this; | 698 | return *this; |
| 698 | } | 699 | } |
| 699 | 700 | ||
| 700 | _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) noexcept(is_nothrow_move_assignable<__base>::value) { | 701 | _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) = default; |
| 701 | __tree_ = std::move(__s.__tree_); | ||
| 702 | return *this; | ||
| 703 | } | ||
| 704 | # endif // _LIBCPP_CXX03_LANG | 702 | # endif // _LIBCPP_CXX03_LANG |
| 705 | 703 | ||
| 706 | _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); } | 704 | _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); } |
| 707 | 705 | ||
| 708 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 706 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 709 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 707 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| 710 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } | 708 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } |
| 711 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } | 709 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } |
| 712 | 710 | ||
| 713 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } | 711 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } |
| 714 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 712 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { |
| 715 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | 713 | return const_reverse_iterator(end()); |
| 716 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 714 | } |
| 715 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | ||
| 716 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | ||
| 717 | return const_reverse_iterator(begin()); | ||
| 718 | } | ||
| 717 | 719 | ||
| 718 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | 720 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } |
| 719 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | 721 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } |
| 720 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 722 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 721 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 723 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 722 | 724 | ||
| 723 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 725 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 724 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 726 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 725 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 727 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 726 | 728 | ||
| 727 | // modifiers: | 729 | // modifiers: |
| 728 | # ifndef _LIBCPP_CXX03_LANG | 730 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -732,28 +734,24 @@ public: | ... | @@ -732,28 +734,24 @@ public: |
| 732 | } | 734 | } |
| 733 | template <class... _Args> | 735 | template <class... _Args> |
| 734 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { | 736 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
| 735 | return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...); | 737 | return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...).first; |
| 736 | } | 738 | } |
| 737 | # endif // _LIBCPP_CXX03_LANG | 739 | # endif // _LIBCPP_CXX03_LANG |
| 738 | 740 | ||
| 739 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); } | 741 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); } |
| 740 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { | 742 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| 741 | return __tree_.__emplace_hint_unique(__p, __v); | 743 | return __tree_.__emplace_hint_unique(__p, __v).first; |
| 742 | } | 744 | } |
| 743 | 745 | ||
| 744 | template <class _InputIterator> | 746 | template <class _InputIterator> |
| 745 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { | 747 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { |
| 746 | for (const_iterator __e = cend(); __f != __l; ++__f) | 748 | __tree_.__insert_range_unique(__first, __last); |
| 747 | __tree_.__emplace_hint_unique(__e, *__f); | ||
| 748 | } | 749 | } |
| 749 | 750 | ||
| 750 | # if _LIBCPP_STD_VER >= 23 | 751 | # if _LIBCPP_STD_VER >= 23 |
| 751 | template <_ContainerCompatibleRange<value_type> _Range> | 752 | template <_ContainerCompatibleRange<value_type> _Range> |
| 752 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 753 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 753 | const_iterator __end = cend(); | 754 | __tree_.__insert_range_unique(ranges::begin(__range), ranges::end(__range)); |
| 754 | for (auto&& __element : __range) { | ||
| 755 | __tree_.__emplace_hint_unique(__end, std::forward<decltype(__element)>(__element)); | ||
| 756 | } | ||
| 757 | } | 755 | } |
| 758 | # endif | 756 | # endif |
| 759 | 757 | ||
| ... | @@ -763,7 +761,7 @@ public: | ... | @@ -763,7 +761,7 @@ public: |
| 763 | } | 761 | } |
| 764 | 762 | ||
| 765 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { | 763 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { |
| 766 | return __tree_.__emplace_hint_unique(__p, std::move(__v)); | 764 | return __tree_.__emplace_hint_unique(__p, std::move(__v)).first; |
| 767 | } | 765 | } |
| 768 | 766 | ||
| 769 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 767 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| ... | @@ -785,10 +783,10 @@ public: | ... | @@ -785,10 +783,10 @@ public: |
| 785 | "node_type with incompatible allocator passed to set::insert()"); | 783 | "node_type with incompatible allocator passed to set::insert()"); |
| 786 | return __tree_.template __node_handle_insert_unique<node_type>(__hint, std::move(__nh)); | 784 | return __tree_.template __node_handle_insert_unique<node_type>(__hint, std::move(__nh)); |
| 787 | } | 785 | } |
| 788 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 786 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 789 | return __tree_.template __node_handle_extract<node_type>(__key); | 787 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 790 | } | 788 | } |
| 791 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { | 789 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { |
| 792 | return __tree_.template __node_handle_extract<node_type>(__it); | 790 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 793 | } | 791 | } |
| 794 | template <class _Compare2> | 792 | template <class _Compare2> |
| ... | @@ -819,101 +817,120 @@ public: | ... | @@ -819,101 +817,120 @@ public: |
| 819 | 817 | ||
| 820 | _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); } | 818 | _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); } |
| 821 | 819 | ||
| 822 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); } | 820 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); } |
| 823 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); } | 821 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); } |
| 824 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); } | 822 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); } |
| 825 | 823 | ||
| 826 | // set operations: | 824 | // set operations: |
| 827 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 825 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 828 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 826 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 829 | # if _LIBCPP_STD_VER >= 14 | 827 | # if _LIBCPP_STD_VER >= 14 |
| 830 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 828 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 831 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 829 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 832 | return __tree_.find(__k); | 830 | return __tree_.find(__k); |
| 833 | } | 831 | } |
| 834 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 832 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 835 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 833 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 836 | return __tree_.find(__k); | 834 | return __tree_.find(__k); |
| 837 | } | 835 | } |
| 838 | # endif | 836 | # endif |
| 839 | 837 | ||
| 840 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } | 838 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 839 | return __tree_.__count_unique(__k); | ||
| 840 | } | ||
| 841 | # if _LIBCPP_STD_VER >= 14 | 841 | # if _LIBCPP_STD_VER >= 14 |
| 842 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 842 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 843 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 843 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 844 | return __tree_.__count_multi(__k); | 844 | return __tree_.__count_multi(__k); |
| 845 | } | 845 | } |
| 846 | # endif | 846 | # endif |
| 847 | 847 | ||
| 848 | # if _LIBCPP_STD_VER >= 20 | 848 | # if _LIBCPP_STD_VER >= 20 |
| 849 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 849 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 850 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 850 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 851 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 851 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 852 | return find(__k) != end(); | 852 | return find(__k) != end(); |
| 853 | } | 853 | } |
| 854 | # endif // _LIBCPP_STD_VER >= 20 | 854 | # endif // _LIBCPP_STD_VER >= 20 |
| 855 | 855 | ||
| 856 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 856 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { |
| 857 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 857 | return __tree_.__lower_bound_unique(__k); |
| 858 | } | ||
| 859 | |||
| 860 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { | ||
| 861 | return __tree_.__lower_bound_unique(__k); | ||
| 862 | } | ||
| 863 | |||
| 864 | // The transparent versions of the lookup functions use the _multi version, since a non-element key is allowed to | ||
| 865 | // match multiple elements. | ||
| 858 | # if _LIBCPP_STD_VER >= 14 | 866 | # if _LIBCPP_STD_VER >= 14 |
| 859 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 867 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 860 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 868 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 861 | return __tree_.lower_bound(__k); | 869 | return __tree_.__lower_bound_multi(__k); |
| 862 | } | 870 | } |
| 863 | 871 | ||
| 864 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 872 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 865 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 873 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 866 | return __tree_.lower_bound(__k); | 874 | return __tree_.__lower_bound_multi(__k); |
| 867 | } | 875 | } |
| 868 | # endif | 876 | # endif |
| 869 | 877 | ||
| 870 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 878 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { |
| 871 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 879 | return __tree_.__upper_bound_unique(__k); |
| 880 | } | ||
| 881 | |||
| 882 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { | ||
| 883 | return __tree_.__upper_bound_unique(__k); | ||
| 884 | } | ||
| 885 | |||
| 872 | # if _LIBCPP_STD_VER >= 14 | 886 | # if _LIBCPP_STD_VER >= 14 |
| 873 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 887 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 874 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | 888 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 875 | return __tree_.upper_bound(__k); | 889 | return __tree_.__upper_bound_multi(__k); |
| 876 | } | 890 | } |
| 877 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 891 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 878 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 892 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 879 | return __tree_.upper_bound(__k); | 893 | return __tree_.__upper_bound_multi(__k); |
| 880 | } | 894 | } |
| 881 | # endif | 895 | # endif |
| 882 | 896 | ||
| 883 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 897 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 884 | return __tree_.__equal_range_unique(__k); | 898 | return __tree_.__equal_range_unique(__k); |
| 885 | } | 899 | } |
| 886 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 900 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 887 | return __tree_.__equal_range_unique(__k); | 901 | return __tree_.__equal_range_unique(__k); |
| 888 | } | 902 | } |
| 889 | # if _LIBCPP_STD_VER >= 14 | 903 | # if _LIBCPP_STD_VER >= 14 |
| 890 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 904 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 891 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 905 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 892 | return __tree_.__equal_range_multi(__k); | 906 | return __tree_.__equal_range_multi(__k); |
| 893 | } | 907 | } |
| 894 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 908 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 895 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 909 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 896 | return __tree_.__equal_range_multi(__k); | 910 | return __tree_.__equal_range_multi(__k); |
| 897 | } | 911 | } |
| 898 | # endif | 912 | # endif |
| 913 | |||
| 914 | template <class, class...> | ||
| 915 | friend struct __specialized_algorithm; | ||
| 899 | }; | 916 | }; |
| 900 | 917 | ||
| 901 | # if _LIBCPP_STD_VER >= 17 | 918 | # if _LIBCPP_STD_VER >= 17 |
| 902 | template <class _InputIterator, | 919 | template <class _InputIterator, |
| 903 | class _Compare = less<__iter_value_type<_InputIterator>>, | 920 | class _Compare = less<__iterator_value_type<_InputIterator>>, |
| 904 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, | 921 | class _Allocator = allocator<__iterator_value_type<_InputIterator>>, |
| 905 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 922 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 906 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | 923 | class = enable_if_t<__is_allocator_v<_Allocator>>, |
| 907 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | 924 | class = enable_if_t<!__is_allocator_v<_Compare>>> |
| 908 | set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) | 925 | set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 909 | -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; | 926 | -> set<__iterator_value_type<_InputIterator>, _Compare, _Allocator>; |
| 910 | 927 | ||
| 911 | # if _LIBCPP_STD_VER >= 23 | 928 | # if _LIBCPP_STD_VER >= 23 |
| 912 | template <ranges::input_range _Range, | 929 | template <ranges::input_range _Range, |
| 913 | class _Compare = less<ranges::range_value_t<_Range>>, | 930 | class _Compare = less<ranges::range_value_t<_Range>>, |
| 914 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | 931 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 915 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | 932 | class = enable_if_t<__is_allocator_v<_Allocator>>, |
| 916 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | 933 | class = enable_if_t<!__is_allocator_v<_Compare>>> |
| 917 | set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) | 934 | set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 918 | -> set<ranges::range_value_t<_Range>, _Compare, _Allocator>; | 935 | -> set<ranges::range_value_t<_Range>, _Compare, _Allocator>; |
| 919 | # endif | 936 | # endif |
| ... | @@ -921,41 +938,43 @@ set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) | ... | @@ -921,41 +938,43 @@ set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 921 | template <class _Key, | 938 | template <class _Key, |
| 922 | class _Compare = less<_Key>, | 939 | class _Compare = less<_Key>, |
| 923 | class _Allocator = allocator<_Key>, | 940 | class _Allocator = allocator<_Key>, |
| 924 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | 941 | class = enable_if_t<!__is_allocator_v<_Compare>>, |
| 925 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 942 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 926 | set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) -> set<_Key, _Compare, _Allocator>; | 943 | set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) -> set<_Key, _Compare, _Allocator>; |
| 927 | 944 | ||
| 928 | template <class _InputIterator, | 945 | template <class _InputIterator, |
| 929 | class _Allocator, | 946 | class _Allocator, |
| 930 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 947 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 931 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 948 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 932 | set(_InputIterator, | 949 | set(_InputIterator, _InputIterator, _Allocator) |
| 933 | _InputIterator, | 950 | -> set<__iterator_value_type<_InputIterator>, less<__iterator_value_type<_InputIterator>>, _Allocator>; |
| 934 | _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; | ||
| 935 | 951 | ||
| 936 | # if _LIBCPP_STD_VER >= 23 | 952 | # if _LIBCPP_STD_VER >= 23 |
| 937 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 953 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 938 | set(from_range_t, | 954 | set(from_range_t, _Range&&, _Allocator) |
| 939 | _Range&&, | 955 | -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; |
| 940 | _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; | ||
| 941 | # endif | 956 | # endif |
| 942 | 957 | ||
| 943 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 958 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 944 | set(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>; | 959 | set(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>; |
| 945 | # endif | 960 | # endif |
| 946 | 961 | ||
| 947 | # ifndef _LIBCPP_CXX03_LANG | 962 | # if _LIBCPP_STD_VER >= 14 |
| 963 | template <class _Alg, class _Key, class _Compare, class _Allocator> | ||
| 964 | struct __specialized_algorithm<_Alg, __single_range<set<_Key, _Compare, _Allocator>>> { | ||
| 965 | using __set _LIBCPP_NODEBUG = set<_Key, _Compare, _Allocator>; | ||
| 948 | 966 | ||
| 949 | template <class _Key, class _Compare, class _Allocator> | 967 | static const bool __has_algorithm = |
| 950 | set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) { | 968 | __specialized_algorithm<_Alg, __single_range<typename __set::__base>>::__has_algorithm; |
| 951 | if (__a != __s.get_allocator()) { | ||
| 952 | const_iterator __e = cend(); | ||
| 953 | while (!__s.empty()) | ||
| 954 | insert(__e, std::move(__s.__tree_.remove(__s.begin())->__value_)); | ||
| 955 | } | ||
| 956 | } | ||
| 957 | 969 | ||
| 958 | # endif // _LIBCPP_CXX03_LANG | 970 | // set's begin() and end() are identical with and without const qualification |
| 971 | template <class... _Args> | ||
| 972 | _LIBCPP_HIDE_FROM_ABI static auto operator()(const __set& __set, _Args&&... __args) { | ||
| 973 | return __specialized_algorithm<_Alg, __single_range<typename __set::__base>>()( | ||
| 974 | __set.__tree_, std::forward<_Args>(__args)...); | ||
| 975 | } | ||
| 976 | }; | ||
| 977 | # endif | ||
| 959 | 978 | ||
| 960 | template <class _Key, class _Compare, class _Allocator> | 979 | template <class _Key, class _Compare, class _Allocator> |
| 961 | inline _LIBCPP_HIDE_FROM_ABI bool | 980 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | @@ -1119,24 +1138,17 @@ public: | ... | @@ -1119,24 +1138,17 @@ public: |
| 1119 | : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {} | 1138 | : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 1120 | # endif | 1139 | # endif |
| 1121 | 1140 | ||
| 1122 | _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s) | 1141 | _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s) = default; |
| 1123 | : __tree_(__s.__tree_.value_comp(), | ||
| 1124 | __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) { | ||
| 1125 | insert(__s.begin(), __s.end()); | ||
| 1126 | } | ||
| 1127 | 1142 | ||
| 1128 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) = default; | 1143 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) = default; |
| 1129 | 1144 | ||
| 1130 | # ifndef _LIBCPP_CXX03_LANG | 1145 | # ifndef _LIBCPP_CXX03_LANG |
| 1131 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value) = default; | 1146 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) = default; |
| 1132 | 1147 | ||
| 1133 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); | 1148 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) {} |
| 1134 | # endif // _LIBCPP_CXX03_LANG | 1149 | # endif // _LIBCPP_CXX03_LANG |
| 1135 | _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {} | 1150 | _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {} |
| 1136 | _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a) | 1151 | _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a) : __tree_(__s.__tree_, __a) {} |
| 1137 | : __tree_(__s.__tree_.value_comp(), __a) { | ||
| 1138 | insert(__s.begin(), __s.end()); | ||
| 1139 | } | ||
| 1140 | 1152 | ||
| 1141 | # ifndef _LIBCPP_CXX03_LANG | 1153 | # ifndef _LIBCPP_CXX03_LANG |
| 1142 | _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) | 1154 | _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| ... | @@ -1156,38 +1168,40 @@ public: | ... | @@ -1156,38 +1168,40 @@ public: |
| 1156 | # endif | 1168 | # endif |
| 1157 | 1169 | ||
| 1158 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list<value_type> __il) { | 1170 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list<value_type> __il) { |
| 1159 | __tree_.__assign_multi(__il.begin(), __il.end()); | 1171 | clear(); |
| 1172 | insert(__il.begin(), __il.end()); | ||
| 1160 | return *this; | 1173 | return *this; |
| 1161 | } | 1174 | } |
| 1162 | 1175 | ||
| 1163 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(multiset&& __s) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) { | 1176 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(multiset&& __s) = default; |
| 1164 | __tree_ = std::move(__s.__tree_); | ||
| 1165 | return *this; | ||
| 1166 | } | ||
| 1167 | # endif // _LIBCPP_CXX03_LANG | 1177 | # endif // _LIBCPP_CXX03_LANG |
| 1168 | 1178 | ||
| 1169 | _LIBCPP_HIDE_FROM_ABI ~multiset() { | 1179 | _LIBCPP_HIDE_FROM_ABI ~multiset() { |
| 1170 | static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); | 1180 | static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 1171 | } | 1181 | } |
| 1172 | 1182 | ||
| 1173 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 1183 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 1174 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 1184 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| 1175 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } | 1185 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); } |
| 1176 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } | 1186 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); } |
| 1177 | 1187 | ||
| 1178 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } | 1188 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } |
| 1179 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 1189 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { |
| 1180 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | 1190 | return const_reverse_iterator(end()); |
| 1181 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 1191 | } |
| 1192 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | ||
| 1193 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | ||
| 1194 | return const_reverse_iterator(begin()); | ||
| 1195 | } | ||
| 1182 | 1196 | ||
| 1183 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | 1197 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } |
| 1184 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | 1198 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } |
| 1185 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } | 1199 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1186 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 1200 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1187 | 1201 | ||
| 1188 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | 1202 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } |
| 1189 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } | 1203 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1190 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } | 1204 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1191 | 1205 | ||
| 1192 | // modifiers: | 1206 | // modifiers: |
| 1193 | # ifndef _LIBCPP_CXX03_LANG | 1207 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -1207,18 +1221,14 @@ public: | ... | @@ -1207,18 +1221,14 @@ public: |
| 1207 | } | 1221 | } |
| 1208 | 1222 | ||
| 1209 | template <class _InputIterator> | 1223 | template <class _InputIterator> |
| 1210 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { | 1224 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { |
| 1211 | for (const_iterator __e = cend(); __f != __l; ++__f) | 1225 | __tree_.__insert_range_multi(__first, __last); |
| 1212 | __tree_.__emplace_hint_multi(__e, *__f); | ||
| 1213 | } | 1226 | } |
| 1214 | 1227 | ||
| 1215 | # if _LIBCPP_STD_VER >= 23 | 1228 | # if _LIBCPP_STD_VER >= 23 |
| 1216 | template <_ContainerCompatibleRange<value_type> _Range> | 1229 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1217 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1230 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1218 | const_iterator __end = cend(); | 1231 | __tree_.__insert_range_multi(ranges::begin(__range), ranges::end(__range)); |
| 1219 | for (auto&& __element : __range) { | ||
| 1220 | __tree_.__emplace_hint_multi(__end, std::forward<decltype(__element)>(__element)); | ||
| 1221 | } | ||
| 1222 | } | 1232 | } |
| 1223 | # endif | 1233 | # endif |
| 1224 | 1234 | ||
| ... | @@ -1248,10 +1258,10 @@ public: | ... | @@ -1248,10 +1258,10 @@ public: |
| 1248 | "node_type with incompatible allocator passed to multiset::insert()"); | 1258 | "node_type with incompatible allocator passed to multiset::insert()"); |
| 1249 | return __tree_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh)); | 1259 | return __tree_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh)); |
| 1250 | } | 1260 | } |
| 1251 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 1261 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 1252 | return __tree_.template __node_handle_extract<node_type>(__key); | 1262 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1253 | } | 1263 | } |
| 1254 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { | 1264 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { |
| 1255 | return __tree_.template __node_handle_extract<node_type>(__it); | 1265 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 1256 | } | 1266 | } |
| 1257 | template <class _Compare2> | 1267 | template <class _Compare2> |
| ... | @@ -1284,101 +1294,118 @@ public: | ... | @@ -1284,101 +1294,118 @@ public: |
| 1284 | __tree_.swap(__s.__tree_); | 1294 | __tree_.swap(__s.__tree_); |
| 1285 | } | 1295 | } |
| 1286 | 1296 | ||
| 1287 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); } | 1297 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); } |
| 1288 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); } | 1298 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); } |
| 1289 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); } | 1299 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); } |
| 1290 | 1300 | ||
| 1291 | // set operations: | 1301 | // set operations: |
| 1292 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } | 1302 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1293 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } | 1303 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1294 | # if _LIBCPP_STD_VER >= 14 | 1304 | # if _LIBCPP_STD_VER >= 14 |
| 1295 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1305 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1296 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1306 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1297 | return __tree_.find(__k); | 1307 | return __tree_.find(__k); |
| 1298 | } | 1308 | } |
| 1299 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1309 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1300 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1310 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1301 | return __tree_.find(__k); | 1311 | return __tree_.find(__k); |
| 1302 | } | 1312 | } |
| 1303 | # endif | 1313 | # endif |
| 1304 | 1314 | ||
| 1305 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } | 1315 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 1316 | return __tree_.__count_multi(__k); | ||
| 1317 | } | ||
| 1306 | # if _LIBCPP_STD_VER >= 14 | 1318 | # if _LIBCPP_STD_VER >= 14 |
| 1307 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1319 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1308 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1320 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1309 | return __tree_.__count_multi(__k); | 1321 | return __tree_.__count_multi(__k); |
| 1310 | } | 1322 | } |
| 1311 | # endif | 1323 | # endif |
| 1312 | 1324 | ||
| 1313 | # if _LIBCPP_STD_VER >= 20 | 1325 | # if _LIBCPP_STD_VER >= 20 |
| 1314 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1326 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1315 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1327 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1316 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1328 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1317 | return find(__k) != end(); | 1329 | return find(__k) != end(); |
| 1318 | } | 1330 | } |
| 1319 | # endif // _LIBCPP_STD_VER >= 20 | 1331 | # endif // _LIBCPP_STD_VER >= 20 |
| 1320 | 1332 | ||
| 1321 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } | 1333 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { |
| 1322 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } | 1334 | return __tree_.__lower_bound_multi(__k); |
| 1335 | } | ||
| 1336 | |||
| 1337 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { | ||
| 1338 | return __tree_.__lower_bound_multi(__k); | ||
| 1339 | } | ||
| 1340 | |||
| 1323 | # if _LIBCPP_STD_VER >= 14 | 1341 | # if _LIBCPP_STD_VER >= 14 |
| 1324 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1342 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1325 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { | 1343 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1326 | return __tree_.lower_bound(__k); | 1344 | return __tree_.__lower_bound_multi(__k); |
| 1327 | } | 1345 | } |
| 1328 | 1346 | ||
| 1329 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1347 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1330 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { | 1348 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1331 | return __tree_.lower_bound(__k); | 1349 | return __tree_.__lower_bound_multi(__k); |
| 1332 | } | 1350 | } |
| 1333 | # endif | 1351 | # endif |
| 1334 | 1352 | ||
| 1335 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } | 1353 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { |
| 1336 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } | 1354 | return __tree_.__upper_bound_multi(__k); |
| 1355 | } | ||
| 1356 | |||
| 1357 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { | ||
| 1358 | return __tree_.__upper_bound_multi(__k); | ||
| 1359 | } | ||
| 1360 | |||
| 1337 | # if _LIBCPP_STD_VER >= 14 | 1361 | # if _LIBCPP_STD_VER >= 14 |
| 1338 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1362 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1339 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { | 1363 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 1340 | return __tree_.upper_bound(__k); | 1364 | return __tree_.__upper_bound_multi(__k); |
| 1341 | } | 1365 | } |
| 1342 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1366 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1343 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { | 1367 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 1344 | return __tree_.upper_bound(__k); | 1368 | return __tree_.__upper_bound_multi(__k); |
| 1345 | } | 1369 | } |
| 1346 | # endif | 1370 | # endif |
| 1347 | 1371 | ||
| 1348 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 1372 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1349 | return __tree_.__equal_range_multi(__k); | 1373 | return __tree_.__equal_range_multi(__k); |
| 1350 | } | 1374 | } |
| 1351 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 1375 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1352 | return __tree_.__equal_range_multi(__k); | 1376 | return __tree_.__equal_range_multi(__k); |
| 1353 | } | 1377 | } |
| 1354 | # if _LIBCPP_STD_VER >= 14 | 1378 | # if _LIBCPP_STD_VER >= 14 |
| 1355 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1379 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1356 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1380 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1357 | return __tree_.__equal_range_multi(__k); | 1381 | return __tree_.__equal_range_multi(__k); |
| 1358 | } | 1382 | } |
| 1359 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> | 1383 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1360 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1384 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1361 | return __tree_.__equal_range_multi(__k); | 1385 | return __tree_.__equal_range_multi(__k); |
| 1362 | } | 1386 | } |
| 1363 | # endif | 1387 | # endif |
| 1388 | |||
| 1389 | template <class, class...> | ||
| 1390 | friend struct __specialized_algorithm; | ||
| 1364 | }; | 1391 | }; |
| 1365 | 1392 | ||
| 1366 | # if _LIBCPP_STD_VER >= 17 | 1393 | # if _LIBCPP_STD_VER >= 17 |
| 1367 | template <class _InputIterator, | 1394 | template <class _InputIterator, |
| 1368 | class _Compare = less<__iter_value_type<_InputIterator>>, | 1395 | class _Compare = less<__iterator_value_type<_InputIterator>>, |
| 1369 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, | 1396 | class _Allocator = allocator<__iterator_value_type<_InputIterator>>, |
| 1370 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 1397 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 1371 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | 1398 | class = enable_if_t<__is_allocator_v<_Allocator>>, |
| 1372 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | 1399 | class = enable_if_t<!__is_allocator_v<_Compare>>> |
| 1373 | multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) | 1400 | multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1374 | -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; | 1401 | -> multiset<__iterator_value_type<_InputIterator>, _Compare, _Allocator>; |
| 1375 | 1402 | ||
| 1376 | # if _LIBCPP_STD_VER >= 23 | 1403 | # if _LIBCPP_STD_VER >= 23 |
| 1377 | template <ranges::input_range _Range, | 1404 | template <ranges::input_range _Range, |
| 1378 | class _Compare = less<ranges::range_value_t<_Range>>, | 1405 | class _Compare = less<ranges::range_value_t<_Range>>, |
| 1379 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | 1406 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 1380 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | 1407 | class = enable_if_t<__is_allocator_v<_Allocator>>, |
| 1381 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | 1408 | class = enable_if_t<!__is_allocator_v<_Compare>>> |
| 1382 | multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) | 1409 | multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1383 | -> multiset<ranges::range_value_t<_Range>, _Compare, _Allocator>; | 1410 | -> multiset<ranges::range_value_t<_Range>, _Compare, _Allocator>; |
| 1384 | # endif | 1411 | # endif |
| ... | @@ -1386,43 +1413,44 @@ multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator( | ... | @@ -1386,43 +1413,44 @@ multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator( |
| 1386 | template <class _Key, | 1413 | template <class _Key, |
| 1387 | class _Compare = less<_Key>, | 1414 | class _Compare = less<_Key>, |
| 1388 | class _Allocator = allocator<_Key>, | 1415 | class _Allocator = allocator<_Key>, |
| 1389 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | 1416 | class = enable_if_t<__is_allocator_v<_Allocator>>, |
| 1390 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | 1417 | class = enable_if_t<!__is_allocator_v<_Compare>>> |
| 1391 | multiset(initializer_list<_Key>, | 1418 | multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1392 | _Compare = _Compare(), | 1419 | -> multiset<_Key, _Compare, _Allocator>; |
| 1393 | _Allocator = _Allocator()) -> multiset<_Key, _Compare, _Allocator>; | ||
| 1394 | 1420 | ||
| 1395 | template <class _InputIterator, | 1421 | template <class _InputIterator, |
| 1396 | class _Allocator, | 1422 | class _Allocator, |
| 1397 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, | 1423 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>, |
| 1398 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1424 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1399 | multiset(_InputIterator, _InputIterator, _Allocator) | 1425 | multiset(_InputIterator, _InputIterator, _Allocator) |
| 1400 | -> multiset<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; | 1426 | -> multiset<__iterator_value_type<_InputIterator>, less<__iterator_value_type<_InputIterator>>, _Allocator>; |
| 1401 | 1427 | ||
| 1402 | # if _LIBCPP_STD_VER >= 23 | 1428 | # if _LIBCPP_STD_VER >= 23 |
| 1403 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1429 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1404 | multiset(from_range_t, | 1430 | multiset(from_range_t, _Range&&, _Allocator) |
| 1405 | _Range&&, | 1431 | -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; |
| 1406 | _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; | ||
| 1407 | # endif | 1432 | # endif |
| 1408 | 1433 | ||
| 1409 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> | 1434 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1410 | multiset(initializer_list<_Key>, _Allocator) -> multiset<_Key, less<_Key>, _Allocator>; | 1435 | multiset(initializer_list<_Key>, _Allocator) -> multiset<_Key, less<_Key>, _Allocator>; |
| 1411 | # endif | 1436 | # endif |
| 1412 | 1437 | ||
| 1413 | # ifndef _LIBCPP_CXX03_LANG | 1438 | # if _LIBCPP_STD_VER >= 14 |
| 1439 | template <class _Alg, class _Key, class _Compare, class _Allocator> | ||
| 1440 | struct __specialized_algorithm<_Alg, __single_range<multiset<_Key, _Compare, _Allocator>>> { | ||
| 1441 | using __set _LIBCPP_NODEBUG = multiset<_Key, _Compare, _Allocator>; | ||
| 1414 | 1442 | ||
| 1415 | template <class _Key, class _Compare, class _Allocator> | 1443 | static const bool __has_algorithm = |
| 1416 | multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) | 1444 | __specialized_algorithm<_Alg, __single_range<typename __set::__base>>::__has_algorithm; |
| 1417 | : __tree_(std::move(__s.__tree_), __a) { | ||
| 1418 | if (__a != __s.get_allocator()) { | ||
| 1419 | const_iterator __e = cend(); | ||
| 1420 | while (!__s.empty()) | ||
| 1421 | insert(__e, std::move(__s.__tree_.remove(__s.begin())->__value_)); | ||
| 1422 | } | ||
| 1423 | } | ||
| 1424 | 1445 | ||
| 1425 | # endif // _LIBCPP_CXX03_LANG | 1446 | // set's begin() and end() are identical with and without const qualification |
| 1447 | template <class... _Args> | ||
| 1448 | _LIBCPP_HIDE_FROM_ABI static auto operator()(const __set& __set, _Args&&... __args) { | ||
| 1449 | return __specialized_algorithm<_Alg, __single_range<typename __set::__base>>()( | ||
| 1450 | __set.__tree_, std::forward<_Args>(__args)...); | ||
| 1451 | } | ||
| 1452 | }; | ||
| 1453 | # endif | ||
| 1426 | 1454 | ||
| 1427 | template <class _Key, class _Compare, class _Allocator> | 1455 | template <class _Key, class _Compare, class _Allocator> |
| 1428 | inline _LIBCPP_HIDE_FROM_ABI bool | 1456 | inline _LIBCPP_HIDE_FROM_ABI bool |
lib/libcxx/include/shared_mutex+3-8| ... | @@ -138,6 +138,7 @@ template <class Mutex> | ... | @@ -138,6 +138,7 @@ template <class Mutex> |
| 138 | # include <__mutex/tag_types.h> | 138 | # include <__mutex/tag_types.h> |
| 139 | # include <__mutex/unique_lock.h> | 139 | # include <__mutex/unique_lock.h> |
| 140 | # include <__system_error/throw_system_error.h> | 140 | # include <__system_error/throw_system_error.h> |
| 141 | # include <__utility/move.h> | ||
| 141 | # include <__utility/swap.h> | 142 | # include <__utility/swap.h> |
| 142 | # include <cerrno> | 143 | # include <cerrno> |
| 143 | # include <version> | 144 | # include <version> |
| ... | @@ -340,14 +341,8 @@ public: | ... | @@ -340,14 +341,8 @@ public: |
| 340 | } | 341 | } |
| 341 | 342 | ||
| 342 | _LIBCPP_HIDE_FROM_ABI shared_lock& operator=(shared_lock&& __u) _NOEXCEPT { | 343 | _LIBCPP_HIDE_FROM_ABI shared_lock& operator=(shared_lock&& __u) _NOEXCEPT { |
| 343 | if (__owns_) | 344 | if (this != std::addressof(__u)) |
| 344 | __m_->unlock_shared(); | 345 | shared_lock(std::move(__u)).swap(*this); |
| 345 | __m_ = nullptr; | ||
| 346 | __owns_ = false; | ||
| 347 | __m_ = __u.__m_; | ||
| 348 | __owns_ = __u.__owns_; | ||
| 349 | __u.__m_ = nullptr; | ||
| 350 | __u.__owns_ = false; | ||
| 351 | return *this; | 346 | return *this; |
| 352 | } | 347 | } |
| 353 | 348 |
lib/libcxx/include/span+53-37| ... | @@ -310,30 +310,32 @@ public: | ... | @@ -310,30 +310,32 @@ public: |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | template <size_t _Count> | 312 | template <size_t _Count> |
| 313 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> first() const noexcept { | 313 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> first() const noexcept { |
| 314 | static_assert(_Count <= _Extent, "span<T, N>::first<Count>(): Count out of range"); | 314 | static_assert(_Count <= _Extent, "span<T, N>::first<Count>(): Count out of range"); |
| 315 | return span<element_type, _Count>{data(), _Count}; | 315 | return span<element_type, _Count>{data(), _Count}; |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | template <size_t _Count> | 318 | template <size_t _Count> |
| 319 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> last() const noexcept { | 319 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> last() const noexcept { |
| 320 | static_assert(_Count <= _Extent, "span<T, N>::last<Count>(): Count out of range"); | 320 | static_assert(_Count <= _Extent, "span<T, N>::last<Count>(): Count out of range"); |
| 321 | return span<element_type, _Count>{data() + size() - _Count, _Count}; | 321 | return span<element_type, _Count>{data() + size() - _Count, _Count}; |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept { | 324 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> |
| 325 | first(size_type __count) const noexcept { | ||
| 325 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T, N>::first(count): count out of range"); | 326 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T, N>::first(count): count out of range"); |
| 326 | return {data(), __count}; | 327 | return {data(), __count}; |
| 327 | } | 328 | } |
| 328 | 329 | ||
| 329 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept { | 330 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> |
| 331 | last(size_type __count) const noexcept { | ||
| 330 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T, N>::last(count): count out of range"); | 332 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T, N>::last(count): count out of range"); |
| 331 | return {data() + size() - __count, __count}; | 333 | return {data() + size() - __count, __count}; |
| 332 | } | 334 | } |
| 333 | 335 | ||
| 334 | template <size_t _Offset, size_t _Count = dynamic_extent> | 336 | template <size_t _Offset, size_t _Count = dynamic_extent> |
| 335 | _LIBCPP_HIDE_FROM_ABI constexpr auto | 337 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto subspan() const noexcept |
| 336 | subspan() const noexcept -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> { | 338 | -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> { |
| 337 | static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range"); | 339 | static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range"); |
| 338 | static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, | 340 | static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, |
| 339 | "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range"); | 341 | "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range"); |
| ... | @@ -342,7 +344,7 @@ public: | ... | @@ -342,7 +344,7 @@ public: |
| 342 | return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; | 344 | return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; |
| 343 | } | 345 | } |
| 344 | 346 | ||
| 345 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> | 347 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> |
| 346 | subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { | 348 | subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { |
| 347 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__offset <= size(), "span<T, N>::subspan(offset, count): offset out of range"); | 349 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__offset <= size(), "span<T, N>::subspan(offset, count): offset out of range"); |
| 348 | if (__count == dynamic_extent) | 350 | if (__count == dynamic_extent) |
| ... | @@ -352,52 +354,58 @@ public: | ... | @@ -352,52 +354,58 @@ public: |
| 352 | return {data() + __offset, __count}; | 354 | return {data() + __offset, __count}; |
| 353 | } | 355 | } |
| 354 | 356 | ||
| 355 | _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept { return _Extent; } | 357 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept { return _Extent; } |
| 356 | _LIBCPP_HIDE_FROM_ABI constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); } | 358 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_type size_bytes() const noexcept { |
| 359 | return _Extent * sizeof(element_type); | ||
| 360 | } | ||
| 357 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const noexcept { return _Extent == 0; } | 361 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const noexcept { return _Extent == 0; } |
| 358 | 362 | ||
| 359 | _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](size_type __idx) const noexcept { | 363 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](size_type __idx) const noexcept { |
| 360 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < size(), "span<T, N>::operator[](index): index out of range"); | 364 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < size(), "span<T, N>::operator[](index): index out of range"); |
| 361 | return __data_[__idx]; | 365 | return __data_[__idx]; |
| 362 | } | 366 | } |
| 363 | 367 | ||
| 364 | # if _LIBCPP_STD_VER >= 26 | 368 | # if _LIBCPP_STD_VER >= 26 |
| 365 | _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { | 369 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { |
| 366 | if (__index >= size()) | 370 | if (__index >= size()) |
| 367 | std::__throw_out_of_range("span"); | 371 | std::__throw_out_of_range("span"); |
| 368 | return __data_[__index]; | 372 | return __data_[__index]; |
| 369 | } | 373 | } |
| 370 | # endif | 374 | # endif |
| 371 | 375 | ||
| 372 | _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { | 376 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { |
| 373 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T, N>::front() on empty span"); | 377 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T, N>::front() on empty span"); |
| 374 | return __data_[0]; | 378 | return __data_[0]; |
| 375 | } | 379 | } |
| 376 | 380 | ||
| 377 | _LIBCPP_HIDE_FROM_ABI constexpr reference back() const noexcept { | 381 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference back() const noexcept { |
| 378 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T, N>::back() on empty span"); | 382 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T, N>::back() on empty span"); |
| 379 | return __data_[size() - 1]; | 383 | return __data_[size() - 1]; |
| 380 | } | 384 | } |
| 381 | 385 | ||
| 382 | _LIBCPP_HIDE_FROM_ABI constexpr pointer data() const noexcept { return __data_; } | 386 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr pointer data() const noexcept { return __data_; } |
| 383 | 387 | ||
| 384 | // [span.iter], span iterator support | 388 | // [span.iter], span iterator support |
| 385 | _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { | 389 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { |
| 386 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 390 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 387 | return std::__make_bounded_iter(data(), data(), data() + size()); | 391 | return std::__make_bounded_iter(data(), data(), data() + size()); |
| 388 | # else | 392 | # else |
| 389 | return iterator(data()); | 393 | return iterator(data()); |
| 390 | # endif | 394 | # endif |
| 391 | } | 395 | } |
| 392 | _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { | 396 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { |
| 393 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 397 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 394 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); | 398 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); |
| 395 | # else | 399 | # else |
| 396 | return iterator(data() + size()); | 400 | return iterator(data() + size()); |
| 397 | # endif | 401 | # endif |
| 398 | } | 402 | } |
| 399 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } | 403 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { |
| 400 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } | 404 | return reverse_iterator(end()); |
| 405 | } | ||
| 406 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { | ||
| 407 | return reverse_iterator(begin()); | ||
| 408 | } | ||
| 401 | 409 | ||
| 402 | _LIBCPP_HIDE_FROM_ABI span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept { | 410 | _LIBCPP_HIDE_FROM_ABI span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept { |
| 403 | return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte*>(data()), size_bytes()}; | 411 | return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte*>(data()), size_bytes()}; |
| ... | @@ -478,36 +486,38 @@ public: | ... | @@ -478,36 +486,38 @@ public: |
| 478 | : __data_{__other.data()}, __size_{__other.size()} {} | 486 | : __data_{__other.data()}, __size_{__other.size()} {} |
| 479 | 487 | ||
| 480 | template <size_t _Count> | 488 | template <size_t _Count> |
| 481 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> first() const noexcept { | 489 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> first() const noexcept { |
| 482 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Count <= size(), "span<T>::first<Count>(): Count out of range"); | 490 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Count <= size(), "span<T>::first<Count>(): Count out of range"); |
| 483 | return span<element_type, _Count>{data(), _Count}; | 491 | return span<element_type, _Count>{data(), _Count}; |
| 484 | } | 492 | } |
| 485 | 493 | ||
| 486 | template <size_t _Count> | 494 | template <size_t _Count> |
| 487 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> last() const noexcept { | 495 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> last() const noexcept { |
| 488 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Count <= size(), "span<T>::last<Count>(): Count out of range"); | 496 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Count <= size(), "span<T>::last<Count>(): Count out of range"); |
| 489 | return span<element_type, _Count>{data() + size() - _Count, _Count}; | 497 | return span<element_type, _Count>{data() + size() - _Count, _Count}; |
| 490 | } | 498 | } |
| 491 | 499 | ||
| 492 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept { | 500 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> |
| 501 | first(size_type __count) const noexcept { | ||
| 493 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T>::first(count): count out of range"); | 502 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T>::first(count): count out of range"); |
| 494 | return {data(), __count}; | 503 | return {data(), __count}; |
| 495 | } | 504 | } |
| 496 | 505 | ||
| 497 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept { | 506 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, dynamic_extent> |
| 507 | last(size_type __count) const noexcept { | ||
| 498 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T>::last(count): count out of range"); | 508 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count <= size(), "span<T>::last(count): count out of range"); |
| 499 | return {data() + size() - __count, __count}; | 509 | return {data() + size() - __count, __count}; |
| 500 | } | 510 | } |
| 501 | 511 | ||
| 502 | template <size_t _Offset, size_t _Count = dynamic_extent> | 512 | template <size_t _Offset, size_t _Count = dynamic_extent> |
| 503 | _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> subspan() const noexcept { | 513 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr span<element_type, _Count> subspan() const noexcept { |
| 504 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Offset <= size(), "span<T>::subspan<Offset, Count>(): Offset out of range"); | 514 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Offset <= size(), "span<T>::subspan<Offset, Count>(): Offset out of range"); |
| 505 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Count == dynamic_extent || _Count <= size() - _Offset, | 515 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Count == dynamic_extent || _Count <= size() - _Offset, |
| 506 | "span<T>::subspan<Offset, Count>(): Offset + Count out of range"); | 516 | "span<T>::subspan<Offset, Count>(): Offset + Count out of range"); |
| 507 | return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; | 517 | return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; |
| 508 | } | 518 | } |
| 509 | 519 | ||
| 510 | constexpr span<element_type, dynamic_extent> _LIBCPP_HIDE_FROM_ABI | 520 | [[nodiscard]] constexpr span<element_type, dynamic_extent> _LIBCPP_HIDE_FROM_ABI |
| 511 | subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { | 521 | subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { |
| 512 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__offset <= size(), "span<T>::subspan(offset, count): offset out of range"); | 522 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__offset <= size(), "span<T>::subspan(offset, count): offset out of range"); |
| 513 | if (__count == dynamic_extent) | 523 | if (__count == dynamic_extent) |
| ... | @@ -517,52 +527,58 @@ public: | ... | @@ -517,52 +527,58 @@ public: |
| 517 | return {data() + __offset, __count}; | 527 | return {data() + __offset, __count}; |
| 518 | } | 528 | } |
| 519 | 529 | ||
| 520 | _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept { return __size_; } | 530 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept { return __size_; } |
| 521 | _LIBCPP_HIDE_FROM_ABI constexpr size_type size_bytes() const noexcept { return __size_ * sizeof(element_type); } | 531 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_type size_bytes() const noexcept { |
| 532 | return __size_ * sizeof(element_type); | ||
| 533 | } | ||
| 522 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const noexcept { return __size_ == 0; } | 534 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const noexcept { return __size_ == 0; } |
| 523 | 535 | ||
| 524 | _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](size_type __idx) const noexcept { | 536 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](size_type __idx) const noexcept { |
| 525 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < size(), "span<T>::operator[](index): index out of range"); | 537 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < size(), "span<T>::operator[](index): index out of range"); |
| 526 | return __data_[__idx]; | 538 | return __data_[__idx]; |
| 527 | } | 539 | } |
| 528 | 540 | ||
| 529 | # if _LIBCPP_STD_VER >= 26 | 541 | # if _LIBCPP_STD_VER >= 26 |
| 530 | _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { | 542 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { |
| 531 | if (__index >= size()) | 543 | if (__index >= size()) |
| 532 | std::__throw_out_of_range("span"); | 544 | std::__throw_out_of_range("span"); |
| 533 | return __data_[__index]; | 545 | return __data_[__index]; |
| 534 | } | 546 | } |
| 535 | # endif | 547 | # endif |
| 536 | 548 | ||
| 537 | _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { | 549 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { |
| 538 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T>::front() on empty span"); | 550 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T>::front() on empty span"); |
| 539 | return __data_[0]; | 551 | return __data_[0]; |
| 540 | } | 552 | } |
| 541 | 553 | ||
| 542 | _LIBCPP_HIDE_FROM_ABI constexpr reference back() const noexcept { | 554 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference back() const noexcept { |
| 543 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T>::back() on empty span"); | 555 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T>::back() on empty span"); |
| 544 | return __data_[size() - 1]; | 556 | return __data_[size() - 1]; |
| 545 | } | 557 | } |
| 546 | 558 | ||
| 547 | _LIBCPP_HIDE_FROM_ABI constexpr pointer data() const noexcept { return __data_; } | 559 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr pointer data() const noexcept { return __data_; } |
| 548 | 560 | ||
| 549 | // [span.iter], span iterator support | 561 | // [span.iter], span iterator support |
| 550 | _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { | 562 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { |
| 551 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 563 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 552 | return std::__make_bounded_iter(data(), data(), data() + size()); | 564 | return std::__make_bounded_iter(data(), data(), data() + size()); |
| 553 | # else | 565 | # else |
| 554 | return iterator(data()); | 566 | return iterator(data()); |
| 555 | # endif | 567 | # endif |
| 556 | } | 568 | } |
| 557 | _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { | 569 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { |
| 558 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 570 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 559 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); | 571 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); |
| 560 | # else | 572 | # else |
| 561 | return iterator(data() + size()); | 573 | return iterator(data() + size()); |
| 562 | # endif | 574 | # endif |
| 563 | } | 575 | } |
| 564 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } | 576 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { |
| 565 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } | 577 | return reverse_iterator(end()); |
| 578 | } | ||
| 579 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { | ||
| 580 | return reverse_iterator(begin()); | ||
| 581 | } | ||
| 566 | 582 | ||
| 567 | _LIBCPP_HIDE_FROM_ABI span<const byte, dynamic_extent> __as_bytes() const noexcept { | 583 | _LIBCPP_HIDE_FROM_ABI span<const byte, dynamic_extent> __as_bytes() const noexcept { |
| 568 | return {reinterpret_cast<const byte*>(data()), size_bytes()}; | 584 | return {reinterpret_cast<const byte*>(data()), size_bytes()}; |
| ... | @@ -585,13 +601,13 @@ inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true; | ... | @@ -585,13 +601,13 @@ inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true; |
| 585 | 601 | ||
| 586 | // as_bytes & as_writable_bytes | 602 | // as_bytes & as_writable_bytes |
| 587 | template <class _Tp, size_t _Extent> | 603 | template <class _Tp, size_t _Extent> |
| 588 | _LIBCPP_HIDE_FROM_ABI auto as_bytes(span<_Tp, _Extent> __s) noexcept { | 604 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto as_bytes(span<_Tp, _Extent> __s) noexcept { |
| 589 | return __s.__as_bytes(); | 605 | return __s.__as_bytes(); |
| 590 | } | 606 | } |
| 591 | 607 | ||
| 592 | template <class _Tp, size_t _Extent> | 608 | template <class _Tp, size_t _Extent> |
| 593 | requires(!is_const_v<_Tp>) | 609 | requires(!is_const_v<_Tp>) |
| 594 | _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept { | 610 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept { |
| 595 | return __s.__as_writable_bytes(); | 611 | return __s.__as_writable_bytes(); |
| 596 | } | 612 | } |
| 597 | 613 |
lib/libcxx/include/sstream+34-28| ... | @@ -461,15 +461,15 @@ public: | ... | @@ -461,15 +461,15 @@ public: |
| 461 | // [stringbuf.members] Member functions: | 461 | // [stringbuf.members] Member functions: |
| 462 | 462 | ||
| 463 | # if _LIBCPP_STD_VER >= 20 | 463 | # if _LIBCPP_STD_VER >= 20 |
| 464 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); } | 464 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); } |
| 465 | # endif | 465 | # endif |
| 466 | 466 | ||
| 467 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 467 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 468 | string_type str() const; | 468 | [[__nodiscard__]] string_type str() const; |
| 469 | # else | 469 | # else |
| 470 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); } | 470 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); } |
| 471 | 471 | ||
| 472 | _LIBCPP_HIDE_FROM_ABI string_type str() && { | 472 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() && { |
| 473 | const basic_string_view<_CharT, _Traits> __view = view(); | 473 | const basic_string_view<_CharT, _Traits> __view = view(); |
| 474 | typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data(); | 474 | typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data(); |
| 475 | // In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator()); | 475 | // In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator()); |
| ... | @@ -484,12 +484,12 @@ public: | ... | @@ -484,12 +484,12 @@ public: |
| 484 | 484 | ||
| 485 | # if _LIBCPP_STD_VER >= 20 | 485 | # if _LIBCPP_STD_VER >= 20 |
| 486 | template <class _SAlloc> | 486 | template <class _SAlloc> |
| 487 | requires __is_allocator<_SAlloc>::value | 487 | requires __is_allocator_v<_SAlloc> |
| 488 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { | 488 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| 489 | return basic_string<_CharT, _Traits, _SAlloc>(view(), __sa); | 489 | return basic_string<_CharT, _Traits, _SAlloc>(view(), __sa); |
| 490 | } | 490 | } |
| 491 | 491 | ||
| 492 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept; | 492 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept; |
| 493 | # endif // _LIBCPP_STD_VER >= 20 | 493 | # endif // _LIBCPP_STD_VER >= 20 |
| 494 | 494 | ||
| 495 | void str(const string_type& __s) { | 495 | void str(const string_type& __s) { |
| ... | @@ -949,26 +949,28 @@ public: | ... | @@ -949,26 +949,28 @@ public: |
| 949 | } | 949 | } |
| 950 | 950 | ||
| 951 | // [istringstream.members] Member functions: | 951 | // [istringstream.members] Member functions: |
| 952 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { | 952 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { |
| 953 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); | 953 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); |
| 954 | } | 954 | } |
| 955 | 955 | ||
| 956 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 956 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 957 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } | 957 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 958 | # else | 958 | # else |
| 959 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } | 959 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 960 | 960 | ||
| 961 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } | 961 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 962 | # endif | 962 | # endif |
| 963 | 963 | ||
| 964 | # if _LIBCPP_STD_VER >= 20 | 964 | # if _LIBCPP_STD_VER >= 20 |
| 965 | template <class _SAlloc> | 965 | template <class _SAlloc> |
| 966 | requires __is_allocator<_SAlloc>::value | 966 | requires __is_allocator_v<_SAlloc> |
| 967 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { | 967 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| 968 | return __sb_.str(__sa); | 968 | return __sb_.str(__sa); |
| 969 | } | 969 | } |
| 970 | 970 | ||
| 971 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } | 971 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { |
| 972 | return __sb_.view(); | ||
| 973 | } | ||
| 972 | # endif // _LIBCPP_STD_VER >= 20 | 974 | # endif // _LIBCPP_STD_VER >= 20 |
| 973 | 975 | ||
| 974 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } | 976 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } |
| ... | @@ -1087,26 +1089,28 @@ public: | ... | @@ -1087,26 +1089,28 @@ public: |
| 1087 | } | 1089 | } |
| 1088 | 1090 | ||
| 1089 | // [ostringstream.members] Member functions: | 1091 | // [ostringstream.members] Member functions: |
| 1090 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { | 1092 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { |
| 1091 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); | 1093 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); |
| 1092 | } | 1094 | } |
| 1093 | 1095 | ||
| 1094 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 1096 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 1095 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } | 1097 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 1096 | # else | 1098 | # else |
| 1097 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } | 1099 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 1098 | 1100 | ||
| 1099 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } | 1101 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 1100 | # endif | 1102 | # endif |
| 1101 | 1103 | ||
| 1102 | # if _LIBCPP_STD_VER >= 20 | 1104 | # if _LIBCPP_STD_VER >= 20 |
| 1103 | template <class _SAlloc> | 1105 | template <class _SAlloc> |
| 1104 | requires __is_allocator<_SAlloc>::value | 1106 | requires __is_allocator_v<_SAlloc> |
| 1105 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { | 1107 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| 1106 | return __sb_.str(__sa); | 1108 | return __sb_.str(__sa); |
| 1107 | } | 1109 | } |
| 1108 | 1110 | ||
| 1109 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } | 1111 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { |
| 1112 | return __sb_.view(); | ||
| 1113 | } | ||
| 1110 | # endif // _LIBCPP_STD_VER >= 20 | 1114 | # endif // _LIBCPP_STD_VER >= 20 |
| 1111 | 1115 | ||
| 1112 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } | 1116 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } |
| ... | @@ -1227,26 +1231,28 @@ public: | ... | @@ -1227,26 +1231,28 @@ public: |
| 1227 | } | 1231 | } |
| 1228 | 1232 | ||
| 1229 | // [stringstream.members] Member functions: | 1233 | // [stringstream.members] Member functions: |
| 1230 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { | 1234 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { |
| 1231 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); | 1235 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); |
| 1232 | } | 1236 | } |
| 1233 | 1237 | ||
| 1234 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | 1238 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 1235 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } | 1239 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 1236 | # else | 1240 | # else |
| 1237 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } | 1241 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 1238 | 1242 | ||
| 1239 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } | 1243 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 1240 | # endif | 1244 | # endif |
| 1241 | 1245 | ||
| 1242 | # if _LIBCPP_STD_VER >= 20 | 1246 | # if _LIBCPP_STD_VER >= 20 |
| 1243 | template <class _SAlloc> | 1247 | template <class _SAlloc> |
| 1244 | requires __is_allocator<_SAlloc>::value | 1248 | requires __is_allocator_v<_SAlloc> |
| 1245 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { | 1249 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| 1246 | return __sb_.str(__sa); | 1250 | return __sb_.str(__sa); |
| 1247 | } | 1251 | } |
| 1248 | 1252 | ||
| 1249 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } | 1253 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { |
| 1254 | return __sb_.view(); | ||
| 1255 | } | ||
| 1250 | # endif // _LIBCPP_STD_VER >= 20 | 1256 | # endif // _LIBCPP_STD_VER >= 20 |
| 1251 | 1257 | ||
| 1252 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } | 1258 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } |
lib/libcxx/include/stack+13-15| ... | @@ -235,9 +235,9 @@ public: | ... | @@ -235,9 +235,9 @@ public: |
| 235 | # endif | 235 | # endif |
| 236 | 236 | ||
| 237 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | 237 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 238 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } | 238 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 239 | _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); } | 239 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); } |
| 240 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } | 240 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } |
| 241 | 241 | ||
| 242 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } | 242 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } |
| 243 | # ifndef _LIBCPP_CXX03_LANG | 243 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -294,19 +294,19 @@ public: | ... | @@ -294,19 +294,19 @@ public: |
| 294 | }; | 294 | }; |
| 295 | 295 | ||
| 296 | # if _LIBCPP_STD_VER >= 17 | 296 | # if _LIBCPP_STD_VER >= 17 |
| 297 | template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> > | 297 | template <class _Container, class = enable_if_t<!__is_allocator_v<_Container>>> |
| 298 | stack(_Container) -> stack<typename _Container::value_type, _Container>; | 298 | stack(_Container) -> stack<typename _Container::value_type, _Container>; |
| 299 | 299 | ||
| 300 | template <class _Container, | 300 | template <class _Container, |
| 301 | class _Alloc, | 301 | class _Alloc, |
| 302 | class = enable_if_t<!__is_allocator<_Container>::value>, | 302 | class = enable_if_t<!__is_allocator_v<_Container>>, |
| 303 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > | 303 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > |
| 304 | stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>; | 304 | stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>; |
| 305 | # endif | 305 | # endif |
| 306 | 306 | ||
| 307 | # if _LIBCPP_STD_VER >= 23 | 307 | # if _LIBCPP_STD_VER >= 23 |
| 308 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> | 308 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 309 | stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>; | 309 | stack(_InputIterator, _InputIterator) -> stack<__iterator_value_type<_InputIterator>>; |
| 310 | 310 | ||
| 311 | template <ranges::input_range _Range> | 311 | template <ranges::input_range _Range> |
| 312 | stack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>; | 312 | stack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>; |
| ... | @@ -314,15 +314,13 @@ stack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>; | ... | @@ -314,15 +314,13 @@ stack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>; |
| 314 | template <class _InputIterator, | 314 | template <class _InputIterator, |
| 315 | class _Alloc, | 315 | class _Alloc, |
| 316 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, | 316 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, |
| 317 | __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 317 | __enable_if_t<__is_allocator_v<_Alloc>, int> = 0> |
| 318 | stack(_InputIterator, | 318 | stack(_InputIterator, _InputIterator, _Alloc) |
| 319 | _InputIterator, | 319 | -> stack<__iterator_value_type<_InputIterator>, deque<__iterator_value_type<_InputIterator>, _Alloc>>; |
| 320 | _Alloc) -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | 320 | |
| 321 | 321 | template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator_v<_Alloc>, int> = 0> | |
| 322 | template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 322 | stack(from_range_t, _Range&&, _Alloc) |
| 323 | stack(from_range_t, | 323 | -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; |
| 324 | _Range&&, | ||
| 325 | _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; | ||
| 326 | 324 | ||
| 327 | # endif | 325 | # endif |
| 328 | 326 |
lib/libcxx/include/stddef.h+10-10| ... | @@ -25,24 +25,24 @@ Types: | ... | @@ -25,24 +25,24 @@ Types: |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 27 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 28 | # include <__cxx03/stddef.h> | 28 | # include <__cxx03/__config> |
| 29 | #else | 29 | #else |
| 30 | # include <__config> | 30 | # include <__config> |
| 31 | #endif | ||
| 31 | 32 | ||
| 32 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 33 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 33 | # pragma GCC system_header | 34 | # pragma GCC system_header |
| 34 | # endif | 35 | #endif |
| 35 | 36 | ||
| 36 | // Note: This include is outside of header guards because we sometimes get included multiple times | 37 | // Note: This include is outside of header guards because we sometimes get included multiple times |
| 37 | // with different defines and the underlying <stddef.h> will know how to deal with that. | 38 | // with different defines and the underlying <stddef.h> will know how to deal with that. |
| 38 | # include_next <stddef.h> | 39 | #include_next <stddef.h> |
| 39 | 40 | ||
| 40 | # ifndef _LIBCPP_STDDEF_H | 41 | #ifndef _LIBCPP_STDDEF_H |
| 41 | # define _LIBCPP_STDDEF_H | 42 | # define _LIBCPP_STDDEF_H |
| 42 | 43 | ||
| 43 | # ifdef __cplusplus | 44 | # ifdef __cplusplus |
| 44 | typedef decltype(nullptr) nullptr_t; | 45 | typedef decltype(nullptr) nullptr_t; |
| 45 | # endif | 46 | # endif |
| 46 | # endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 47 | 47 | ||
| 48 | #endif // _LIBCPP_STDDEF_H | 48 | #endif // _LIBCPP_STDDEF_H |
lib/libcxx/include/stdexcept+2-2| ... | @@ -91,7 +91,7 @@ public: | ... | @@ -91,7 +91,7 @@ public: |
| 91 | 91 | ||
| 92 | ~logic_error() _NOEXCEPT override; | 92 | ~logic_error() _NOEXCEPT override; |
| 93 | 93 | ||
| 94 | const char* what() const _NOEXCEPT override; | 94 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 95 | # else | 95 | # else |
| 96 | 96 | ||
| 97 | public: | 97 | public: |
| ... | @@ -115,7 +115,7 @@ public: | ... | @@ -115,7 +115,7 @@ public: |
| 115 | 115 | ||
| 116 | ~runtime_error() _NOEXCEPT override; | 116 | ~runtime_error() _NOEXCEPT override; |
| 117 | 117 | ||
| 118 | const char* what() const _NOEXCEPT override; | 118 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 119 | # else | 119 | # else |
| 120 | 120 | ||
| 121 | public: | 121 | public: |
lib/libcxx/include/stdio.h+20-21| ... | @@ -88,35 +88,34 @@ void perror(const char* s); | ... | @@ -88,35 +88,34 @@ void perror(const char* s); |
| 88 | */ | 88 | */ |
| 89 | 89 | ||
| 90 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 90 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 91 | # include <__cxx03/stdio.h> | 91 | # include <__cxx03/__config> |
| 92 | #else | 92 | #else |
| 93 | # include <__config> | 93 | # include <__config> |
| 94 | #endif | ||
| 94 | 95 | ||
| 95 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 96 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 96 | # pragma GCC system_header | 97 | # pragma GCC system_header |
| 97 | # endif | 98 | #endif |
| 98 | 99 | ||
| 99 | // The inclusion of the system's <stdio.h> is intentionally done once outside of any include | 100 | // The inclusion of the system's <stdio.h> is intentionally done once outside of any include |
| 100 | // guards because some code expects to be able to include the underlying system header multiple | 101 | // guards because some code expects to be able to include the underlying system header multiple |
| 101 | // times to get different definitions based on the macros that are set before inclusion. | 102 | // times to get different definitions based on the macros that are set before inclusion. |
| 102 | # if __has_include_next(<stdio.h>) | 103 | #if __has_include_next(<stdio.h>) |
| 103 | # include_next <stdio.h> | 104 | # include_next <stdio.h> |
| 104 | # endif | 105 | #endif |
| 105 | 106 | ||
| 106 | # ifndef _LIBCPP_STDIO_H | 107 | #ifndef _LIBCPP_STDIO_H |
| 107 | # define _LIBCPP_STDIO_H | 108 | # define _LIBCPP_STDIO_H |
| 108 | 109 | ||
| 109 | # ifdef __cplusplus | 110 | # ifdef __cplusplus |
| 110 | 111 | ||
| 111 | # undef getc | 112 | # undef getc |
| 112 | # undef putc | 113 | # undef putc |
| 113 | # undef clearerr | 114 | # undef clearerr |
| 114 | # undef feof | 115 | # undef feof |
| 115 | # undef ferror | 116 | # undef ferror |
| 116 | # undef putchar | 117 | # undef putchar |
| 117 | # undef getchar | 118 | # undef getchar |
| 118 | 119 | ||
| 119 | # endif // __cplusplus | 120 | # endif // __cplusplus |
| 120 | # endif // _LIBCPP_STDIO_H | 121 | #endif // _LIBCPP_STDIO_H |
| 121 | |||
| 122 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/streambuf+59-19| ... | @@ -119,6 +119,7 @@ protected: | ... | @@ -119,6 +119,7 @@ protected: |
| 119 | # include <__locale> | 119 | # include <__locale> |
| 120 | # include <__type_traits/is_same.h> | 120 | # include <__type_traits/is_same.h> |
| 121 | # include <__utility/is_valid_range.h> | 121 | # include <__utility/is_valid_range.h> |
| 122 | # include <__utility/scope_guard.h> | ||
| 122 | # include <climits> | 123 | # include <climits> |
| 123 | # include <ios> | 124 | # include <ios> |
| 124 | # include <iosfwd> | 125 | # include <iosfwd> |
| ... | @@ -149,47 +150,56 @@ public: | ... | @@ -149,47 +150,56 @@ public: |
| 149 | virtual ~basic_streambuf() {} | 150 | virtual ~basic_streambuf() {} |
| 150 | 151 | ||
| 151 | // 27.6.2.2.1 locales: | 152 | // 27.6.2.2.1 locales: |
| 152 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 locale pubimbue(const locale& __loc) { | 153 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 locale pubimbue(const locale& __loc) { |
| 153 | imbue(__loc); | 154 | imbue(__loc); |
| 154 | locale __r = __loc_; | 155 | locale __r = __loc_; |
| 155 | __loc_ = __loc; | 156 | __loc_ = __loc; |
| 156 | return __r; | 157 | return __r; |
| 157 | } | 158 | } |
| 158 | 159 | ||
| 159 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 locale getloc() const { return __loc_; } | 160 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 locale getloc() const { return __loc_; } |
| 160 | 161 | ||
| 161 | // 27.6.2.2.2 buffer and positioning: | 162 | // 27.6.2.2.2 buffer and positioning: |
| 162 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_streambuf* pubsetbuf(char_type* __s, streamsize __n) { | 163 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 basic_streambuf* pubsetbuf(char_type* __s, streamsize __n) { |
| 163 | return setbuf(__s, __n); | 164 | return setbuf(__s, __n); |
| 164 | } | 165 | } |
| 165 | 166 | ||
| 166 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type | 167 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 pos_type |
| 167 | pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) { | 168 | pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) { |
| 168 | return seekoff(__off, __way, __which); | 169 | return seekoff(__off, __way, __which); |
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type | 172 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 pos_type |
| 172 | pubseekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out) { | 173 | pubseekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out) { |
| 173 | return seekpos(__sp, __which); | 174 | return seekpos(__sp, __which); |
| 174 | } | 175 | } |
| 175 | 176 | ||
| 176 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int pubsync() { return sync(); } | 177 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 int pubsync() { return sync(); } |
| 177 | 178 | ||
| 178 | // Get and put areas: | 179 | // Get and put areas: |
| 179 | // 27.6.2.2.3 Get area: | 180 | // 27.6.2.2.3 Get area: |
| 180 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize in_avail() { | 181 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 streamsize in_avail() { |
| 182 | __check_invariants(); | ||
| 183 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 184 | |||
| 181 | if (gptr() < egptr()) | 185 | if (gptr() < egptr()) |
| 182 | return static_cast<streamsize>(egptr() - gptr()); | 186 | return static_cast<streamsize>(egptr() - gptr()); |
| 183 | return showmanyc(); | 187 | return showmanyc(); |
| 184 | } | 188 | } |
| 185 | 189 | ||
| 186 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type snextc() { | 190 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 int_type snextc() { |
| 191 | __check_invariants(); | ||
| 192 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 193 | |||
| 187 | if (sbumpc() == traits_type::eof()) | 194 | if (sbumpc() == traits_type::eof()) |
| 188 | return traits_type::eof(); | 195 | return traits_type::eof(); |
| 189 | return sgetc(); | 196 | return sgetc(); |
| 190 | } | 197 | } |
| 191 | 198 | ||
| 192 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sbumpc() { | 199 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 int_type sbumpc() { |
| 200 | __check_invariants(); | ||
| 201 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 202 | |||
| 193 | if (gptr() == egptr()) | 203 | if (gptr() == egptr()) |
| 194 | return uflow(); | 204 | return uflow(); |
| 195 | int_type __c = traits_type::to_int_type(*gptr()); | 205 | int_type __c = traits_type::to_int_type(*gptr()); |
| ... | @@ -197,23 +207,32 @@ public: | ... | @@ -197,23 +207,32 @@ public: |
| 197 | return __c; | 207 | return __c; |
| 198 | } | 208 | } |
| 199 | 209 | ||
| 200 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sgetc() { | 210 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 int_type sgetc() { |
| 211 | __check_invariants(); | ||
| 212 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 213 | |||
| 201 | if (gptr() == egptr()) | 214 | if (gptr() == egptr()) |
| 202 | return underflow(); | 215 | return underflow(); |
| 203 | return traits_type::to_int_type(*gptr()); | 216 | return traits_type::to_int_type(*gptr()); |
| 204 | } | 217 | } |
| 205 | 218 | ||
| 206 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sgetn(char_type* __s, streamsize __n) { return xsgetn(__s, __n); } | 219 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 streamsize sgetn(char_type* __s, streamsize __n) { return xsgetn(__s, __n); } |
| 207 | 220 | ||
| 208 | // 27.6.2.2.4 Putback: | 221 | // 27.6.2.2.4 Putback: |
| 209 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputbackc(char_type __c) { | 222 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 int_type sputbackc(char_type __c) { |
| 223 | __check_invariants(); | ||
| 224 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 225 | |||
| 210 | if (eback() == gptr() || !traits_type::eq(__c, *(gptr() - 1))) | 226 | if (eback() == gptr() || !traits_type::eq(__c, *(gptr() - 1))) |
| 211 | return pbackfail(traits_type::to_int_type(__c)); | 227 | return pbackfail(traits_type::to_int_type(__c)); |
| 212 | this->gbump(-1); | 228 | this->gbump(-1); |
| 213 | return traits_type::to_int_type(*gptr()); | 229 | return traits_type::to_int_type(*gptr()); |
| 214 | } | 230 | } |
| 215 | 231 | ||
| 216 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sungetc() { | 232 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 int_type sungetc() { |
| 233 | __check_invariants(); | ||
| 234 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 235 | |||
| 217 | if (eback() == gptr()) | 236 | if (eback() == gptr()) |
| 218 | return pbackfail(); | 237 | return pbackfail(); |
| 219 | this->gbump(-1); | 238 | this->gbump(-1); |
| ... | @@ -221,7 +240,10 @@ public: | ... | @@ -221,7 +240,10 @@ public: |
| 221 | } | 240 | } |
| 222 | 241 | ||
| 223 | // 27.6.2.2.5 Put area: | 242 | // 27.6.2.2.5 Put area: |
| 224 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputc(char_type __c) { | 243 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 int_type sputc(char_type __c) { |
| 244 | __check_invariants(); | ||
| 245 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 246 | |||
| 225 | if (pptr() == epptr()) | 247 | if (pptr() == epptr()) |
| 226 | return overflow(traits_type::to_int_type(__c)); | 248 | return overflow(traits_type::to_int_type(__c)); |
| 227 | *pptr() = __c; | 249 | *pptr() = __c; |
| ... | @@ -229,7 +251,7 @@ public: | ... | @@ -229,7 +251,7 @@ public: |
| 229 | return traits_type::to_int_type(__c); | 251 | return traits_type::to_int_type(__c); |
| 230 | } | 252 | } |
| 231 | 253 | ||
| 232 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sputn(const char_type* __s, streamsize __n) { | 254 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 streamsize sputn(const char_type* __s, streamsize __n) { |
| 233 | return xsputn(__s, __n); | 255 | return xsputn(__s, __n); |
| 234 | } | 256 | } |
| 235 | 257 | ||
| ... | @@ -270,12 +292,12 @@ protected: | ... | @@ -270,12 +292,12 @@ protected: |
| 270 | _LIBCPP_HIDE_FROM_ABI char_type* gptr() const { return __ninp_; } | 292 | _LIBCPP_HIDE_FROM_ABI char_type* gptr() const { return __ninp_; } |
| 271 | _LIBCPP_HIDE_FROM_ABI char_type* egptr() const { return __einp_; } | 293 | _LIBCPP_HIDE_FROM_ABI char_type* egptr() const { return __einp_; } |
| 272 | 294 | ||
| 273 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; } | 295 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 void gbump(int __n) { __ninp_ += __n; } |
| 274 | 296 | ||
| 275 | // gbump takes an int, so it might not be able to represent the offset we want to add. | 297 | // gbump takes an int, so it might not be able to represent the offset we want to add. |
| 276 | _LIBCPP_HIDE_FROM_ABI void __gbump_ptrdiff(ptrdiff_t __n) { __ninp_ += __n; } | 298 | _LIBCPP_HIDE_FROM_ABI void __gbump_ptrdiff(ptrdiff_t __n) { __ninp_ += __n; } |
| 277 | 299 | ||
| 278 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { | 300 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { |
| 279 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range"); | 301 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range"); |
| 280 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range"); | 302 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range"); |
| 281 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gnext, __gend), "[gnext, gend) must be a valid range"); | 303 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gnext, __gend), "[gnext, gend) must be a valid range"); |
| ... | @@ -289,11 +311,11 @@ protected: | ... | @@ -289,11 +311,11 @@ protected: |
| 289 | _LIBCPP_HIDE_FROM_ABI char_type* pptr() const { return __nout_; } | 311 | _LIBCPP_HIDE_FROM_ABI char_type* pptr() const { return __nout_; } |
| 290 | _LIBCPP_HIDE_FROM_ABI char_type* epptr() const { return __eout_; } | 312 | _LIBCPP_HIDE_FROM_ABI char_type* epptr() const { return __eout_; } |
| 291 | 313 | ||
| 292 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void pbump(int __n) { __nout_ += __n; } | 314 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 void pbump(int __n) { __nout_ += __n; } |
| 293 | 315 | ||
| 294 | _LIBCPP_HIDE_FROM_ABI void __pbump(streamsize __n) { __nout_ += __n; } | 316 | _LIBCPP_HIDE_FROM_ABI void __pbump(streamsize __n) { __nout_ += __n; } |
| 295 | 317 | ||
| 296 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setp(char_type* __pbeg, char_type* __pend) { | 318 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 void setp(char_type* __pbeg, char_type* __pend) { |
| 297 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__pbeg, __pend), "[pbeg, pend) must be a valid range"); | 319 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__pbeg, __pend), "[pbeg, pend) must be a valid range"); |
| 298 | __bout_ = __nout_ = __pbeg; | 320 | __bout_ = __nout_ = __pbeg; |
| 299 | __eout_ = __pend; | 321 | __eout_ = __pend; |
| ... | @@ -317,6 +339,9 @@ protected: | ... | @@ -317,6 +339,9 @@ protected: |
| 317 | virtual streamsize showmanyc() { return 0; } | 339 | virtual streamsize showmanyc() { return 0; } |
| 318 | 340 | ||
| 319 | virtual streamsize xsgetn(char_type* __s, streamsize __n) { | 341 | virtual streamsize xsgetn(char_type* __s, streamsize __n) { |
| 342 | __check_invariants(); | ||
| 343 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 344 | |||
| 320 | int_type __c; | 345 | int_type __c; |
| 321 | streamsize __i = 0; | 346 | streamsize __i = 0; |
| 322 | while (__i < __n) { | 347 | while (__i < __n) { |
| ... | @@ -338,6 +363,9 @@ protected: | ... | @@ -338,6 +363,9 @@ protected: |
| 338 | 363 | ||
| 339 | virtual int_type underflow() { return traits_type::eof(); } | 364 | virtual int_type underflow() { return traits_type::eof(); } |
| 340 | virtual int_type uflow() { | 365 | virtual int_type uflow() { |
| 366 | __check_invariants(); | ||
| 367 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 368 | |||
| 341 | if (underflow() == traits_type::eof()) | 369 | if (underflow() == traits_type::eof()) |
| 342 | return traits_type::eof(); | 370 | return traits_type::eof(); |
| 343 | int_type __c = traits_type::to_int_type(*gptr()); | 371 | int_type __c = traits_type::to_int_type(*gptr()); |
| ... | @@ -350,6 +378,9 @@ protected: | ... | @@ -350,6 +378,9 @@ protected: |
| 350 | 378 | ||
| 351 | // 27.6.2.4.5 Put area: | 379 | // 27.6.2.4.5 Put area: |
| 352 | virtual streamsize xsputn(const char_type* __s, streamsize __n) { | 380 | virtual streamsize xsputn(const char_type* __s, streamsize __n) { |
| 381 | __check_invariants(); | ||
| 382 | auto __guard = std::__make_scope_guard([this] { this->__check_invariants(); }); | ||
| 383 | |||
| 353 | streamsize __i = 0; | 384 | streamsize __i = 0; |
| 354 | while (__i < __n) { | 385 | while (__i < __n) { |
| 355 | if (pptr() >= epptr()) { | 386 | if (pptr() >= epptr()) { |
| ... | @@ -370,6 +401,15 @@ protected: | ... | @@ -370,6 +401,15 @@ protected: |
| 370 | 401 | ||
| 371 | virtual int_type overflow(int_type = traits_type::eof()) { return traits_type::eof(); } | 402 | virtual int_type overflow(int_type = traits_type::eof()) { return traits_type::eof(); } |
| 372 | 403 | ||
| 404 | // This function checks some invariants of the class (it isn't exhaustive). | ||
| 405 | _LIBCPP_HIDE_FROM_ABI void __check_invariants() const { | ||
| 406 | _LIBCPP_ASSERT_INTERNAL(pbase() <= pptr(), "this is an invariant of the class"); | ||
| 407 | _LIBCPP_ASSERT_INTERNAL(pptr() <= epptr(), "this is an invariant of the class"); | ||
| 408 | |||
| 409 | _LIBCPP_ASSERT_INTERNAL(eback() <= gptr(), "this is an invariant of the class"); | ||
| 410 | _LIBCPP_ASSERT_INTERNAL(gptr() <= egptr(), "this is an invariant of the class"); | ||
| 411 | } | ||
| 412 | |||
| 373 | private: | 413 | private: |
| 374 | locale __loc_; | 414 | locale __loc_; |
| 375 | char_type* __binp_ = nullptr; | 415 | char_type* __binp_ = nullptr; |
lib/libcxx/include/string+574-573| ... | @@ -280,6 +280,8 @@ public: | ... | @@ -280,6 +280,8 @@ public: |
| 280 | basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr in C++20, removed in C++23 | 280 | basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr in C++20, removed in C++23 |
| 281 | basic_string substr(size_type pos = 0, size_type n = npos) const&; // since C++23 | 281 | basic_string substr(size_type pos = 0, size_type n = npos) const&; // since C++23 |
| 282 | constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&; // since C++23 | 282 | constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&; // since C++23 |
| 283 | constexpr basic_string_view<charT, traits> subview(size_type pos = 0, | ||
| 284 | size_type n = npos) const; // since C++26 | ||
| 283 | void swap(basic_string& str) | 285 | void swap(basic_string& str) |
| 284 | noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || | 286 | noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || |
| 285 | allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20 | 287 | allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20 |
| ... | @@ -598,9 +600,9 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); | ... | @@ -598,9 +600,9 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 598 | # include <__debug_utils/sanitizers.h> | 600 | # include <__debug_utils/sanitizers.h> |
| 599 | # include <__format/enable_insertable.h> | 601 | # include <__format/enable_insertable.h> |
| 600 | # include <__functional/hash.h> | 602 | # include <__functional/hash.h> |
| 603 | # include <__functional/is_transparent.h> | ||
| 601 | # include <__functional/unary_function.h> | 604 | # include <__functional/unary_function.h> |
| 602 | # include <__fwd/string.h> | 605 | # include <__fwd/string.h> |
| 603 | # include <__ios/fpos.h> | ||
| 604 | # include <__iterator/bounded_iter.h> | 606 | # include <__iterator/bounded_iter.h> |
| 605 | # include <__iterator/distance.h> | 607 | # include <__iterator/distance.h> |
| 606 | # include <__iterator/iterator_traits.h> | 608 | # include <__iterator/iterator_traits.h> |
| ... | @@ -620,7 +622,6 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); | ... | @@ -620,7 +622,6 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 620 | # include <__ranges/concepts.h> | 622 | # include <__ranges/concepts.h> |
| 621 | # include <__ranges/container_compatible_range.h> | 623 | # include <__ranges/container_compatible_range.h> |
| 622 | # include <__ranges/from_range.h> | 624 | # include <__ranges/from_range.h> |
| 623 | # include <__ranges/size.h> | ||
| 624 | # include <__string/char_traits.h> | 625 | # include <__string/char_traits.h> |
| 625 | # include <__string/extern_template_lists.h> | 626 | # include <__string/extern_template_lists.h> |
| 626 | # include <__type_traits/conditional.h> | 627 | # include <__type_traits/conditional.h> |
| ... | @@ -628,24 +629,23 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); | ... | @@ -628,24 +629,23 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 628 | # include <__type_traits/is_allocator.h> | 629 | # include <__type_traits/is_allocator.h> |
| 629 | # include <__type_traits/is_array.h> | 630 | # include <__type_traits/is_array.h> |
| 630 | # include <__type_traits/is_convertible.h> | 631 | # include <__type_traits/is_convertible.h> |
| 632 | # include <__type_traits/is_generic_transparent_comparator.h> | ||
| 631 | # include <__type_traits/is_nothrow_assignable.h> | 633 | # include <__type_traits/is_nothrow_assignable.h> |
| 632 | # include <__type_traits/is_nothrow_constructible.h> | 634 | # include <__type_traits/is_nothrow_constructible.h> |
| 633 | # include <__type_traits/is_replaceable.h> | ||
| 634 | # include <__type_traits/is_same.h> | 635 | # include <__type_traits/is_same.h> |
| 635 | # include <__type_traits/is_standard_layout.h> | 636 | # include <__type_traits/is_standard_layout.h> |
| 636 | # include <__type_traits/is_trivially_constructible.h> | 637 | # include <__type_traits/is_trivially_constructible.h> |
| 637 | # include <__type_traits/is_trivially_copyable.h> | 638 | # include <__type_traits/is_trivially_copyable.h> |
| 638 | # include <__type_traits/is_trivially_relocatable.h> | 639 | # include <__type_traits/is_trivially_relocatable.h> |
| 639 | # include <__type_traits/remove_cvref.h> | 640 | # include <__type_traits/remove_cvref.h> |
| 640 | # include <__type_traits/void_t.h> | 641 | # include <__utility/default_three_way_comparator.h> |
| 641 | # include <__utility/auto_cast.h> | 642 | # include <__utility/exception_guard.h> |
| 642 | # include <__utility/declval.h> | ||
| 643 | # include <__utility/forward.h> | 643 | # include <__utility/forward.h> |
| 644 | # include <__utility/is_pointer_in_range.h> | 644 | # include <__utility/is_pointer_in_range.h> |
| 645 | # include <__utility/move.h> | 645 | # include <__utility/move.h> |
| 646 | # include <__utility/no_destroy.h> | ||
| 646 | # include <__utility/scope_guard.h> | 647 | # include <__utility/scope_guard.h> |
| 647 | # include <__utility/swap.h> | 648 | # include <__utility/swap.h> |
| 648 | # include <__utility/unreachable.h> | ||
| 649 | # include <climits> | 649 | # include <climits> |
| 650 | # include <cstdio> // EOF | 650 | # include <cstdio> // EOF |
| 651 | # include <cstring> | 651 | # include <cstring> |
| ... | @@ -700,18 +700,18 @@ __concatenate_strings(const _Allocator& __alloc, | ... | @@ -700,18 +700,18 @@ __concatenate_strings(const _Allocator& __alloc, |
| 700 | __type_identity_t<basic_string_view<_CharT, _Traits> > __str2); | 700 | __type_identity_t<basic_string_view<_CharT, _Traits> > __str2); |
| 701 | 701 | ||
| 702 | template <class _Iter> | 702 | template <class _Iter> |
| 703 | struct __string_is_trivial_iterator : public false_type {}; | 703 | inline const bool __string_is_trivial_iterator_v = false; |
| 704 | 704 | ||
| 705 | template <class _Tp> | 705 | template <class _Tp> |
| 706 | struct __string_is_trivial_iterator<_Tp*> : public is_arithmetic<_Tp> {}; | 706 | inline const bool __string_is_trivial_iterator_v<_Tp*> = is_arithmetic<_Tp>::value; |
| 707 | 707 | ||
| 708 | template <class _Iter> | 708 | template <class _Iter> |
| 709 | struct __string_is_trivial_iterator<__wrap_iter<_Iter> > : public __string_is_trivial_iterator<_Iter> {}; | 709 | inline const bool __string_is_trivial_iterator_v<__wrap_iter<_Iter> > = __string_is_trivial_iterator_v<_Iter>; |
| 710 | 710 | ||
| 711 | template <class _CharT, class _Traits, class _Tp> | 711 | template <class _CharT, class _Traits, class _Tp> |
| 712 | struct __can_be_converted_to_string_view | 712 | inline const bool __can_be_converted_to_string_view_v = |
| 713 | : public _BoolConstant< is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value && | 713 | is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value && |
| 714 | !is_convertible<const _Tp&, const _CharT*>::value > {}; | 714 | !is_convertible<const _Tp&, const _CharT*>::value; |
| 715 | 715 | ||
| 716 | struct __uninitialized_size_tag {}; | 716 | struct __uninitialized_size_tag {}; |
| 717 | struct __init_with_sentinel_tag {}; | 717 | struct __init_with_sentinel_tag {}; |
| ... | @@ -756,20 +756,13 @@ public: | ... | @@ -756,20 +756,13 @@ public: |
| 756 | // external memory. In such cases, the destructor is responsible for unpoisoning | 756 | // external memory. In such cases, the destructor is responsible for unpoisoning |
| 757 | // the memory to avoid triggering false positives. | 757 | // the memory to avoid triggering false positives. |
| 758 | // Therefore it's crucial to ensure the destructor is called. | 758 | // Therefore it's crucial to ensure the destructor is called. |
| 759 | // | 759 | using __trivially_relocatable _LIBCPP_NODEBUG = void; |
| 760 | // However, it is replaceable since implementing move-assignment as a destroy + move-construct | ||
| 761 | // will maintain the right ASAN state. | ||
| 762 | using __trivially_relocatable = void; | ||
| 763 | # else | 760 | # else |
| 764 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | 761 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< |
| 765 | __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value, | 762 | __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value, |
| 766 | basic_string, | 763 | basic_string, |
| 767 | void>; | 764 | void>; |
| 768 | # endif | 765 | # endif |
| 769 | using __replaceable _LIBCPP_NODEBUG = | ||
| 770 | __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value, | ||
| 771 | basic_string, | ||
| 772 | void>; | ||
| 773 | 766 | ||
| 774 | # if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN | 767 | # if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN |
| 775 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { | 768 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { |
| ... | @@ -819,12 +812,21 @@ public: | ... | @@ -819,12 +812,21 @@ public: |
| 819 | using reverse_iterator = std::reverse_iterator<iterator>; | 812 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 820 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | 813 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| 821 | 814 | ||
| 815 | using __alloc_result _LIBCPP_NODEBUG = __allocation_result<pointer, size_type>; | ||
| 816 | |||
| 822 | private: | 817 | private: |
| 823 | static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); | 818 | static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); |
| 824 | 819 | ||
| 825 | # ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | 820 | # ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
| 826 | 821 | ||
| 827 | struct __long { | 822 | struct __long { |
| 823 | __long() = default; | ||
| 824 | |||
| 825 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __long(__alloc_result __alloc, size_type __size) | ||
| 826 | : __data_(__alloc.ptr), __size_(__size), __cap_(__alloc.count / __endian_factor), __is_long_(true) { | ||
| 827 | _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__alloc.count), "Long capacity should always be larger than the SSO"); | ||
| 828 | } | ||
| 829 | |||
| 828 | pointer __data_; | 830 | pointer __data_; |
| 829 | size_type __size_; | 831 | size_type __size_; |
| 830 | size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; | 832 | size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; |
| ... | @@ -872,6 +874,13 @@ private: | ... | @@ -872,6 +874,13 @@ private: |
| 872 | // some platforms bit fields have a default size rather than the actual | 874 | // some platforms bit fields have a default size rather than the actual |
| 873 | // size used, e.g., it is 4 bytes on AIX. See D128285 for details. | 875 | // size used, e.g., it is 4 bytes on AIX. See D128285 for details. |
| 874 | struct __long { | 876 | struct __long { |
| 877 | __long() = default; | ||
| 878 | |||
| 879 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __long(__alloc_result __alloc, size_type __size) | ||
| 880 | : __is_long_(true), __cap_(__alloc.count / __endian_factor), __size_(__size), __data_(__alloc.ptr) { | ||
| 881 | _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__alloc.count), "Long capacity should always be larger than the SSO"); | ||
| 882 | } | ||
| 883 | |||
| 875 | struct _LIBCPP_PACKED { | 884 | struct _LIBCPP_PACKED { |
| 876 | size_type __is_long_ : 1; | 885 | size_type __is_long_ : 1; |
| 877 | size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; | 886 | size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; |
| ... | @@ -898,6 +907,11 @@ private: | ... | @@ -898,6 +907,11 @@ private: |
| 898 | union __rep { | 907 | union __rep { |
| 899 | __short __s; | 908 | __short __s; |
| 900 | __long __l; | 909 | __long __l; |
| 910 | |||
| 911 | __rep() = default; | ||
| 912 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__short __r) : __s(__r) {} | ||
| 913 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__long __r) : __l(__r) {} | ||
| 914 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __rep(__uninitialized_tag) {} | ||
| 901 | }; | 915 | }; |
| 902 | 916 | ||
| 903 | _LIBCPP_COMPRESSED_PAIR(__rep, __rep_, allocator_type, __alloc_); | 917 | _LIBCPP_COMPRESSED_PAIR(__rep, __rep_, allocator_type, __alloc_); |
| ... | @@ -917,20 +931,7 @@ private: | ... | @@ -917,20 +931,7 @@ private: |
| 917 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string( | 931 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string( |
| 918 | __uninitialized_size_tag, size_type __size, const allocator_type& __a) | 932 | __uninitialized_size_tag, size_type __size, const allocator_type& __a) |
| 919 | : __alloc_(__a) { | 933 | : __alloc_(__a) { |
| 920 | if (__size > max_size()) | 934 | __init_internal_buffer(__size); |
| 921 | this->__throw_length_error(); | ||
| 922 | if (__fits_in_sso(__size)) { | ||
| 923 | __rep_ = __rep(); | ||
| 924 | __set_short_size(__size); | ||
| 925 | } else { | ||
| 926 | auto __capacity = __recommend(__size) + 1; | ||
| 927 | auto __allocation = __alloc_traits::allocate(__alloc_, __capacity); | ||
| 928 | __begin_lifetime(__allocation, __capacity); | ||
| 929 | __set_long_cap(__capacity); | ||
| 930 | __set_long_pointer(__allocation); | ||
| 931 | __set_long_size(__size); | ||
| 932 | } | ||
| 933 | __annotate_new(__size); | ||
| 934 | } | 935 | } |
| 935 | 936 | ||
| 936 | template <class _Iter, class _Sent> | 937 | template <class _Iter, class _Sent> |
| ... | @@ -966,7 +967,7 @@ private: | ... | @@ -966,7 +967,7 @@ private: |
| 966 | std::__wrap_iter<const_pointer>(__get_pointer() + size())); | 967 | std::__wrap_iter<const_pointer>(__get_pointer() + size())); |
| 967 | # else | 968 | # else |
| 968 | return const_iterator(__p); | 969 | return const_iterator(__p); |
| 969 | # endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | 970 | # endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING |
| 970 | } | 971 | } |
| 971 | 972 | ||
| 972 | public: | 973 | public: |
| ... | @@ -1057,13 +1058,13 @@ public: | ... | @@ -1057,13 +1058,13 @@ public: |
| 1057 | } | 1058 | } |
| 1058 | # endif // _LIBCPP_CXX03_LANG | 1059 | # endif // _LIBCPP_CXX03_LANG |
| 1059 | 1060 | ||
| 1060 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | 1061 | template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0> |
| 1061 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) { | 1062 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) { |
| 1062 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr"); | 1063 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr"); |
| 1063 | __init(__s, traits_type::length(__s)); | 1064 | __init(__s, traits_type::length(__s)); |
| 1064 | } | 1065 | } |
| 1065 | 1066 | ||
| 1066 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | 1067 | template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0> |
| 1067 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1068 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1068 | basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, const _Allocator& __a) | 1069 | basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, const _Allocator& __a) |
| 1069 | : __alloc_(__a) { | 1070 | : __alloc_(__a) { |
| ... | @@ -1075,13 +1076,15 @@ public: | ... | @@ -1075,13 +1076,15 @@ public: |
| 1075 | basic_string(nullptr_t) = delete; | 1076 | basic_string(nullptr_t) = delete; |
| 1076 | # endif | 1077 | # endif |
| 1077 | 1078 | ||
| 1078 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) { | 1079 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) |
| 1080 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 1079 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); | 1081 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); |
| 1080 | __init(__s, __n); | 1082 | __init(__s, __n); |
| 1081 | } | 1083 | } |
| 1082 | 1084 | ||
| 1083 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1085 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1084 | basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) | 1086 | basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) |
| 1087 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") | ||
| 1085 | : __alloc_(__a) { | 1088 | : __alloc_(__a) { |
| 1086 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); | 1089 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); |
| 1087 | __init(__s, __n); | 1090 | __init(__s, __n); |
| ... | @@ -1110,7 +1113,7 @@ public: | ... | @@ -1110,7 +1113,7 @@ public: |
| 1110 | } | 1113 | } |
| 1111 | # endif | 1114 | # endif |
| 1112 | 1115 | ||
| 1113 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | 1116 | template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0> |
| 1114 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a) | 1117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a) |
| 1115 | : __alloc_(__a) { | 1118 | : __alloc_(__a) { |
| 1116 | __init(__n, __c); | 1119 | __init(__n, __c); |
| ... | @@ -1135,7 +1138,7 @@ public: | ... | @@ -1135,7 +1138,7 @@ public: |
| 1135 | } | 1138 | } |
| 1136 | 1139 | ||
| 1137 | template <class _Tp, | 1140 | template <class _Tp, |
| 1138 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1141 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1139 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1142 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1140 | int> = 0> | 1143 | int> = 0> |
| 1141 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1144 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| ... | @@ -1147,7 +1150,7 @@ public: | ... | @@ -1147,7 +1150,7 @@ public: |
| 1147 | } | 1150 | } |
| 1148 | 1151 | ||
| 1149 | template <class _Tp, | 1152 | template <class _Tp, |
| 1150 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1153 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1151 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1154 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1152 | int> = 0> | 1155 | int> = 0> |
| 1153 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) { | 1156 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) { |
| ... | @@ -1156,7 +1159,7 @@ public: | ... | @@ -1156,7 +1159,7 @@ public: |
| 1156 | } | 1159 | } |
| 1157 | 1160 | ||
| 1158 | template <class _Tp, | 1161 | template <class _Tp, |
| 1159 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1162 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1160 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1163 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1161 | int> = 0> | 1164 | int> = 0> |
| 1162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a) | 1165 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a) |
| ... | @@ -1201,11 +1204,10 @@ public: | ... | @@ -1201,11 +1204,10 @@ public: |
| 1201 | } | 1204 | } |
| 1202 | # endif // _LIBCPP_CXX03_LANG | 1205 | # endif // _LIBCPP_CXX03_LANG |
| 1203 | 1206 | ||
| 1204 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() { | 1207 | // TODO(boomanaiden154): Once we mark this in destructors as dead on return, |
| 1205 | __annotate_delete(); | 1208 | // we can use a normal call to __reset_internal_buffer and remove the extra |
| 1206 | if (__is_long()) | 1209 | // __rep constructor. |
| 1207 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | 1210 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() { __reset_internal_buffer(__rep(__uninitialized_tag())); } |
| 1208 | } | ||
| 1209 | 1211 | ||
| 1210 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT { | 1212 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT { |
| 1211 | return __self_view(typename __self_view::__assume_valid(), data(), size()); | 1213 | return __self_view(typename __self_view::__assume_valid(), data(), size()); |
| ... | @@ -1215,7 +1217,7 @@ public: | ... | @@ -1215,7 +1217,7 @@ public: |
| 1215 | operator=(const basic_string& __str); | 1217 | operator=(const basic_string& __str); |
| 1216 | 1218 | ||
| 1217 | template <class _Tp, | 1219 | template <class _Tp, |
| 1218 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1220 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1219 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1221 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1220 | int> = 0> | 1222 | int> = 0> |
| 1221 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) { | 1223 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) { |
| ... | @@ -1243,45 +1245,55 @@ public: | ... | @@ -1243,45 +1245,55 @@ public: |
| 1243 | # endif | 1245 | # endif |
| 1244 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); | 1246 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); |
| 1245 | 1247 | ||
| 1246 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { | 1248 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { |
| 1247 | return __make_iterator(__get_pointer()); | 1249 | return __make_iterator(__get_pointer()); |
| 1248 | } | 1250 | } |
| 1249 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { | 1251 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { |
| 1250 | return __make_const_iterator(__get_pointer()); | 1252 | return __make_const_iterator(__get_pointer()); |
| 1251 | } | 1253 | } |
| 1252 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { | 1254 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { |
| 1253 | return __make_iterator(__get_pointer() + size()); | 1255 | return __make_iterator(__get_pointer() + size()); |
| 1254 | } | 1256 | } |
| 1255 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT { | 1257 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT { |
| 1256 | return __make_const_iterator(__get_pointer() + size()); | 1258 | return __make_const_iterator(__get_pointer() + size()); |
| 1257 | } | 1259 | } |
| 1258 | 1260 | ||
| 1259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT { | 1261 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT { |
| 1260 | return reverse_iterator(end()); | 1262 | return reverse_iterator(end()); |
| 1261 | } | 1263 | } |
| 1262 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT { | 1264 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator |
| 1265 | rbegin() const _NOEXCEPT { | ||
| 1263 | return const_reverse_iterator(end()); | 1266 | return const_reverse_iterator(end()); |
| 1264 | } | 1267 | } |
| 1265 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT { | 1268 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT { |
| 1266 | return reverse_iterator(begin()); | 1269 | return reverse_iterator(begin()); |
| 1267 | } | 1270 | } |
| 1268 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT { | 1271 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT { |
| 1269 | return const_reverse_iterator(begin()); | 1272 | return const_reverse_iterator(begin()); |
| 1270 | } | 1273 | } |
| 1271 | 1274 | ||
| 1272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return begin(); } | 1275 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { |
| 1273 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT { return end(); } | 1276 | return begin(); |
| 1274 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT { | 1277 | } |
| 1278 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT { | ||
| 1279 | return end(); | ||
| 1280 | } | ||
| 1281 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator | ||
| 1282 | crbegin() const _NOEXCEPT { | ||
| 1275 | return rbegin(); | 1283 | return rbegin(); |
| 1276 | } | 1284 | } |
| 1277 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | 1285 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { |
| 1286 | return rend(); | ||
| 1287 | } | ||
| 1278 | 1288 | ||
| 1279 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { | 1289 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { |
| 1280 | return __is_long() ? __get_long_size() : __get_short_size(); | 1290 | return __is_long() ? __get_long_size() : __get_short_size(); |
| 1281 | } | 1291 | } |
| 1282 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); } | 1292 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { |
| 1293 | return size(); | ||
| 1294 | } | ||
| 1283 | 1295 | ||
| 1284 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT { | 1296 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT { |
| 1285 | if (size_type __m = __alloc_traits::max_size(__alloc_); __m <= std::numeric_limits<size_type>::max() / 2) { | 1297 | if (size_type __m = __alloc_traits::max_size(__alloc_); __m <= std::numeric_limits<size_type>::max() / 2) { |
| 1286 | size_type __res = __m - __alignment; | 1298 | size_type __res = __m - __alignment; |
| 1287 | 1299 | ||
| ... | @@ -1299,7 +1311,7 @@ public: | ... | @@ -1299,7 +1311,7 @@ public: |
| 1299 | } | 1311 | } |
| 1300 | } | 1312 | } |
| 1301 | 1313 | ||
| 1302 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT { | 1314 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT { |
| 1303 | return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1; | 1315 | return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1; |
| 1304 | } | 1316 | } |
| 1305 | 1317 | ||
| ... | @@ -1311,13 +1323,19 @@ public: | ... | @@ -1311,13 +1323,19 @@ public: |
| 1311 | # if _LIBCPP_STD_VER >= 23 | 1323 | # if _LIBCPP_STD_VER >= 23 |
| 1312 | template <class _Op> | 1324 | template <class _Op> |
| 1313 | _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) { | 1325 | _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) { |
| 1314 | __resize_default_init(__n); | 1326 | using __result_type = decltype(std::move(__op)(data(), auto(__n))); |
| 1315 | __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); | 1327 | static_assert(__integer_like<__result_type>, "Operation return type must be integer-like"); |
| 1328 | size_type __sz = size(); | ||
| 1329 | size_type __cap = capacity(); | ||
| 1330 | if (__n > __cap) | ||
| 1331 | __grow_by_without_replace(__cap, __n - __cap, __sz, __sz, 0); | ||
| 1332 | __annotate_delete(); | ||
| 1333 | __set_size(__n); | ||
| 1334 | __annotate_new(__n); | ||
| 1335 | __erase_to_end(std::move(__op)(data(), auto(__n))); | ||
| 1316 | } | 1336 | } |
| 1317 | # endif | 1337 | # endif |
| 1318 | 1338 | ||
| 1319 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n); | ||
| 1320 | |||
| 1321 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE) | 1339 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE) |
| 1322 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); } | 1340 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); } |
| 1323 | # endif | 1341 | # endif |
| ... | @@ -1328,7 +1346,8 @@ public: | ... | @@ -1328,7 +1346,8 @@ public: |
| 1328 | return size() == 0; | 1346 | return size() == 0; |
| 1329 | } | 1347 | } |
| 1330 | 1348 | ||
| 1331 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __pos) const _NOEXCEPT { | 1349 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference |
| 1350 | operator[](size_type __pos) const _NOEXCEPT { | ||
| 1332 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), "string index out of bounds"); | 1351 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), "string index out of bounds"); |
| 1333 | if (__builtin_constant_p(__pos) && !__fits_in_sso(__pos)) { | 1352 | if (__builtin_constant_p(__pos) && !__fits_in_sso(__pos)) { |
| 1334 | return *(__get_long_pointer() + __pos); | 1353 | return *(__get_long_pointer() + __pos); |
| ... | @@ -1336,7 +1355,8 @@ public: | ... | @@ -1336,7 +1355,8 @@ public: |
| 1336 | return *(data() + __pos); | 1355 | return *(data() + __pos); |
| 1337 | } | 1356 | } |
| 1338 | 1357 | ||
| 1339 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __pos) _NOEXCEPT { | 1358 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference |
| 1359 | operator[](size_type __pos) _NOEXCEPT { | ||
| 1340 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), "string index out of bounds"); | 1360 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), "string index out of bounds"); |
| 1341 | if (__builtin_constant_p(__pos) && !__fits_in_sso(__pos)) { | 1361 | if (__builtin_constant_p(__pos) && !__fits_in_sso(__pos)) { |
| 1342 | return *(__get_long_pointer() + __pos); | 1362 | return *(__get_long_pointer() + __pos); |
| ... | @@ -1344,15 +1364,15 @@ public: | ... | @@ -1344,15 +1364,15 @@ public: |
| 1344 | return *(__get_pointer() + __pos); | 1364 | return *(__get_pointer() + __pos); |
| 1345 | } | 1365 | } |
| 1346 | 1366 | ||
| 1347 | _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const; | 1367 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const; |
| 1348 | _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n); | 1368 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n); |
| 1349 | 1369 | ||
| 1350 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const basic_string& __str) { | 1370 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const basic_string& __str) { |
| 1351 | return append(__str); | 1371 | return append(__str); |
| 1352 | } | 1372 | } |
| 1353 | 1373 | ||
| 1354 | template <class _Tp, | 1374 | template <class _Tp, |
| 1355 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1375 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1356 | !is_same<__remove_cvref_t<_Tp>, basic_string >::value, | 1376 | !is_same<__remove_cvref_t<_Tp>, basic_string >::value, |
| 1357 | int> = 0> | 1377 | int> = 0> |
| 1358 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const _Tp& __t) { | 1378 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const _Tp& __t) { |
| ... | @@ -1381,7 +1401,7 @@ public: | ... | @@ -1381,7 +1401,7 @@ public: |
| 1381 | } | 1401 | } |
| 1382 | 1402 | ||
| 1383 | template <class _Tp, | 1403 | template <class _Tp, |
| 1384 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1404 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1385 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1405 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1386 | int> = 0> | 1406 | int> = 0> |
| 1387 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const _Tp& __t) { | 1407 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const _Tp& __t) { |
| ... | @@ -1392,7 +1412,7 @@ public: | ... | @@ -1392,7 +1412,7 @@ public: |
| 1392 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str, size_type __pos, size_type __n = npos); | 1412 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str, size_type __pos, size_type __n = npos); |
| 1393 | 1413 | ||
| 1394 | template <class _Tp, | 1414 | template <class _Tp, |
| 1395 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1415 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1396 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1416 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1397 | int> = 0> | 1417 | int> = 0> |
| 1398 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1418 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| ... | @@ -1404,12 +1424,11 @@ public: | ... | @@ -1404,12 +1424,11 @@ public: |
| 1404 | return append(__sv.data() + __pos, std::min(__n, __sz - __pos)); | 1424 | return append(__sv.data() + __pos, std::min(__n, __sz - __pos)); |
| 1405 | } | 1425 | } |
| 1406 | 1426 | ||
| 1407 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n); | 1427 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n) |
| 1428 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero"); | ||
| 1408 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); | 1429 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); |
| 1409 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c); | 1430 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c); |
| 1410 | 1431 | ||
| 1411 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append_default_init(size_type __n); | ||
| 1412 | |||
| 1413 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | 1432 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1414 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1433 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1415 | append(_InputIterator __first, _InputIterator __last) { | 1434 | append(_InputIterator __first, _InputIterator __last) { |
| ... | @@ -1424,20 +1443,21 @@ public: | ... | @@ -1424,20 +1443,21 @@ public: |
| 1424 | size_type __sz = size(); | 1443 | size_type __sz = size(); |
| 1425 | size_type __cap = capacity(); | 1444 | size_type __cap = capacity(); |
| 1426 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | 1445 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); |
| 1427 | if (__n) { | 1446 | if (__n == 0) |
| 1428 | if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) { | 1447 | return *this; |
| 1429 | if (__cap - __sz < __n) | 1448 | |
| 1430 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); | 1449 | if (__string_is_trivial_iterator_v<_ForwardIterator> && !__addr_in_range(*__first)) { |
| 1431 | __annotate_increase(__n); | 1450 | if (__cap - __sz < __n) |
| 1432 | auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz)); | 1451 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); |
| 1433 | traits_type::assign(*__end, value_type()); | 1452 | __annotate_increase(__n); |
| 1434 | __set_size(__sz + __n); | 1453 | auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz)); |
| 1435 | } else { | 1454 | traits_type::assign(*__end, value_type()); |
| 1436 | const basic_string __temp(__first, __last, __alloc_); | 1455 | __set_size(__sz + __n); |
| 1437 | append(__temp.data(), __temp.size()); | 1456 | return *this; |
| 1438 | } | 1457 | } else { |
| 1458 | const basic_string __temp(__first, __last, __alloc_); | ||
| 1459 | return append(__temp.data(), __temp.size()); | ||
| 1439 | } | 1460 | } |
| 1440 | return *this; | ||
| 1441 | } | 1461 | } |
| 1442 | 1462 | ||
| 1443 | # if _LIBCPP_STD_VER >= 23 | 1463 | # if _LIBCPP_STD_VER >= 23 |
| ... | @@ -1457,27 +1477,27 @@ public: | ... | @@ -1457,27 +1477,27 @@ public: |
| 1457 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c); | 1477 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c); |
| 1458 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back(); | 1478 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back(); |
| 1459 | 1479 | ||
| 1460 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() _NOEXCEPT { | 1480 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() _NOEXCEPT { |
| 1461 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::front(): string is empty"); | 1481 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::front(): string is empty"); |
| 1462 | return *__get_pointer(); | 1482 | return *__get_pointer(); |
| 1463 | } | 1483 | } |
| 1464 | 1484 | ||
| 1465 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const _NOEXCEPT { | 1485 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const _NOEXCEPT { |
| 1466 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::front(): string is empty"); | 1486 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::front(): string is empty"); |
| 1467 | return *data(); | 1487 | return *data(); |
| 1468 | } | 1488 | } |
| 1469 | 1489 | ||
| 1470 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() _NOEXCEPT { | 1490 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() _NOEXCEPT { |
| 1471 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::back(): string is empty"); | 1491 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::back(): string is empty"); |
| 1472 | return *(__get_pointer() + size() - 1); | 1492 | return *(__get_pointer() + size() - 1); |
| 1473 | } | 1493 | } |
| 1474 | 1494 | ||
| 1475 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const _NOEXCEPT { | 1495 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const _NOEXCEPT { |
| 1476 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::back(): string is empty"); | 1496 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string::back(): string is empty"); |
| 1477 | return *(data() + size() - 1); | 1497 | return *(data() + size() - 1); |
| 1478 | } | 1498 | } |
| 1479 | 1499 | ||
| 1480 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1500 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1481 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const _Tp& __t) { | 1501 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const _Tp& __t) { |
| 1482 | __self_view __sv = __t; | 1502 | __self_view __sv = __t; |
| 1483 | return assign(__sv.data(), __sv.size()); | 1503 | return assign(__sv.data(), __sv.size()); |
| ... | @@ -1519,7 +1539,7 @@ public: | ... | @@ -1519,7 +1539,7 @@ public: |
| 1519 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos); | 1539 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos); |
| 1520 | 1540 | ||
| 1521 | template <class _Tp, | 1541 | template <class _Tp, |
| 1522 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1542 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1523 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1543 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1524 | int> = 0> | 1544 | int> = 0> |
| 1525 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1545 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| ... | @@ -1531,8 +1551,9 @@ public: | ... | @@ -1531,8 +1551,9 @@ public: |
| 1531 | return assign(__sv.data() + __pos, std::min(__n, __sz - __pos)); | 1551 | return assign(__sv.data() + __pos, std::min(__n, __sz - __pos)); |
| 1532 | } | 1552 | } |
| 1533 | 1553 | ||
| 1534 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n); | 1554 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n) |
| 1535 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s); | 1555 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero"); |
| 1556 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); | ||
| 1536 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c); | 1557 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c); |
| 1537 | 1558 | ||
| 1538 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | 1559 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| ... | @@ -1545,7 +1566,7 @@ public: | ... | @@ -1545,7 +1566,7 @@ public: |
| 1545 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | 1566 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> |
| 1546 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1567 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1547 | assign(_ForwardIterator __first, _ForwardIterator __last) { | 1568 | assign(_ForwardIterator __first, _ForwardIterator __last) { |
| 1548 | if (__string_is_trivial_iterator<_ForwardIterator>::value) { | 1569 | if (__string_is_trivial_iterator_v<_ForwardIterator>) { |
| 1549 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | 1570 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); |
| 1550 | __assign_trivial(__first, __last, __n); | 1571 | __assign_trivial(__first, __last, __n); |
| 1551 | } else { | 1572 | } else { |
| ... | @@ -1558,7 +1579,7 @@ public: | ... | @@ -1558,7 +1579,7 @@ public: |
| 1558 | # if _LIBCPP_STD_VER >= 23 | 1579 | # if _LIBCPP_STD_VER >= 23 |
| 1559 | template <_ContainerCompatibleRange<_CharT> _Range> | 1580 | template <_ContainerCompatibleRange<_CharT> _Range> |
| 1560 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string& assign_range(_Range&& __range) { | 1581 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string& assign_range(_Range&& __range) { |
| 1561 | if constexpr (__string_is_trivial_iterator<ranges::iterator_t<_Range>>::value && | 1582 | if constexpr (__string_is_trivial_iterator_v<ranges::iterator_t<_Range>> && |
| 1562 | (ranges::forward_range<_Range> || ranges::sized_range<_Range>)) { | 1583 | (ranges::forward_range<_Range> || ranges::sized_range<_Range>)) { |
| 1563 | size_type __n = static_cast<size_type>(ranges::distance(__range)); | 1584 | size_type __n = static_cast<size_type>(ranges::distance(__range)); |
| 1564 | __assign_trivial(ranges::begin(__range), ranges::end(__range), __n); | 1585 | __assign_trivial(ranges::begin(__range), ranges::end(__range), __n); |
| ... | @@ -1582,14 +1603,14 @@ public: | ... | @@ -1582,14 +1603,14 @@ public: |
| 1582 | return insert(__pos1, __str.data(), __str.size()); | 1603 | return insert(__pos1, __str.data(), __str.size()); |
| 1583 | } | 1604 | } |
| 1584 | 1605 | ||
| 1585 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1606 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1586 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos1, const _Tp& __t) { | 1607 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos1, const _Tp& __t) { |
| 1587 | __self_view __sv = __t; | 1608 | __self_view __sv = __t; |
| 1588 | return insert(__pos1, __sv.data(), __sv.size()); | 1609 | return insert(__pos1, __sv.data(), __sv.size()); |
| 1589 | } | 1610 | } |
| 1590 | 1611 | ||
| 1591 | template <class _Tp, | 1612 | template <class _Tp, |
| 1592 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1613 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1593 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1614 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1594 | int> = 0> | 1615 | int> = 0> |
| 1595 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1616 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| ... | @@ -1603,7 +1624,8 @@ public: | ... | @@ -1603,7 +1624,8 @@ public: |
| 1603 | 1624 | ||
| 1604 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1625 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1605 | insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos); | 1626 | insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos); |
| 1606 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n); | 1627 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n) |
| 1628 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero"); | ||
| 1607 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); | 1629 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); |
| 1608 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c); | 1630 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c); |
| 1609 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c); | 1631 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c); |
| ... | @@ -1659,7 +1681,7 @@ public: | ... | @@ -1659,7 +1681,7 @@ public: |
| 1659 | return replace(__pos1, __n1, __str.data(), __str.size()); | 1681 | return replace(__pos1, __n1, __str.data(), __str.size()); |
| 1660 | } | 1682 | } |
| 1661 | 1683 | ||
| 1662 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1684 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1663 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1685 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1664 | replace(size_type __pos1, size_type __n1, const _Tp& __t) { | 1686 | replace(size_type __pos1, size_type __n1, const _Tp& __t) { |
| 1665 | __self_view __sv = __t; | 1687 | __self_view __sv = __t; |
| ... | @@ -1670,7 +1692,7 @@ public: | ... | @@ -1670,7 +1692,7 @@ public: |
| 1670 | replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos); | 1692 | replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos); |
| 1671 | 1693 | ||
| 1672 | template <class _Tp, | 1694 | template <class _Tp, |
| 1673 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1695 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 1674 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 1696 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1675 | int> = 0> | 1697 | int> = 0> |
| 1676 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| ... | @@ -1683,8 +1705,10 @@ public: | ... | @@ -1683,8 +1705,10 @@ public: |
| 1683 | } | 1705 | } |
| 1684 | 1706 | ||
| 1685 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1707 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1686 | replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); | 1708 | replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) |
| 1687 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); | 1709 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n2 != 0 && __s == nullptr, " if n2 is not zero"); |
| 1710 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | ||
| 1711 | replace(size_type __pos, size_type __n1, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); | ||
| 1688 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); | 1712 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); |
| 1689 | 1713 | ||
| 1690 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1714 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| ... | @@ -1693,7 +1717,7 @@ public: | ... | @@ -1693,7 +1717,7 @@ public: |
| 1693 | static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __str.data(), __str.size()); | 1717 | static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __str.data(), __str.size()); |
| 1694 | } | 1718 | } |
| 1695 | 1719 | ||
| 1696 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1720 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1697 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1721 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1698 | replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { | 1722 | replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { |
| 1699 | __self_view __sv = __t; | 1723 | __self_view __sv = __t; |
| ... | @@ -1741,19 +1765,24 @@ public: | ... | @@ -1741,19 +1765,24 @@ public: |
| 1741 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; | 1765 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; |
| 1742 | 1766 | ||
| 1743 | # if _LIBCPP_STD_VER <= 20 | 1767 | # if _LIBCPP_STD_VER <= 20 |
| 1744 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string | 1768 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI |
| 1745 | substr(size_type __pos = 0, size_type __n = npos) const { | 1769 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string substr(size_type __pos = 0, size_type __n = npos) const { |
| 1746 | return basic_string(*this, __pos, __n); | 1770 | return basic_string(*this, __pos, __n); |
| 1747 | } | 1771 | } |
| 1748 | # else | 1772 | # else |
| 1749 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& { | 1773 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& { |
| 1750 | return basic_string(*this, __pos, __n); | 1774 | return basic_string(*this, __pos, __n); |
| 1751 | } | 1775 | } |
| 1752 | 1776 | ||
| 1753 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && { | 1777 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && { |
| 1754 | return basic_string(std::move(*this), __pos, __n); | 1778 | return basic_string(std::move(*this), __pos, __n); |
| 1755 | } | 1779 | } |
| 1756 | # endif | 1780 | # endif |
| 1781 | # if _LIBCPP_STD_VER >= 26 | ||
| 1782 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __self_view subview(size_type __pos = 0, size_type __n = npos) const { | ||
| 1783 | return __self_view(*this).subview(__pos, __n); | ||
| 1784 | } | ||
| 1785 | # endif | ||
| 1757 | 1786 | ||
| 1758 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(basic_string& __str) | 1787 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(basic_string& __str) |
| 1759 | # if _LIBCPP_STD_VER >= 14 | 1788 | # if _LIBCPP_STD_VER >= 14 |
| ... | @@ -1765,225 +1794,238 @@ public: | ... | @@ -1765,225 +1794,238 @@ public: |
| 1765 | // [string.ops] | 1794 | // [string.ops] |
| 1766 | // ------------ | 1795 | // ------------ |
| 1767 | 1796 | ||
| 1768 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } | 1797 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { |
| 1769 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT { | 1798 | return data(); |
| 1799 | } | ||
| 1800 | |||
| 1801 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT { | ||
| 1770 | return std::__to_address(__get_pointer()); | 1802 | return std::__to_address(__get_pointer()); |
| 1771 | } | 1803 | } |
| 1772 | # if _LIBCPP_STD_VER >= 17 | 1804 | # if _LIBCPP_STD_VER >= 17 |
| 1773 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT { | 1805 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT { |
| 1774 | return std::__to_address(__get_pointer()); | 1806 | return std::__to_address(__get_pointer()); |
| 1775 | } | 1807 | } |
| 1776 | # endif | 1808 | # endif |
| 1777 | 1809 | ||
| 1778 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { | 1810 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { |
| 1779 | return __alloc_; | 1811 | return __alloc_; |
| 1780 | } | 1812 | } |
| 1781 | 1813 | ||
| 1782 | // find | 1814 | // find |
| 1783 | 1815 | ||
| 1784 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1816 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1785 | find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { | 1817 | find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { |
| 1786 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size()); | 1818 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size()); |
| 1787 | } | 1819 | } |
| 1788 | 1820 | ||
| 1789 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1821 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1790 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1822 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1791 | find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { | 1823 | find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { |
| 1792 | __self_view __sv = __t; | 1824 | __self_view __sv = __t; |
| 1793 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); | 1825 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); |
| 1794 | } | 1826 | } |
| 1795 | 1827 | ||
| 1796 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 1828 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1829 | find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT | ||
| 1830 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 1797 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr"); | 1831 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr"); |
| 1798 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 1832 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 1799 | } | 1833 | } |
| 1800 | 1834 | ||
| 1801 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1835 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1802 | find(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { | 1836 | find(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 1803 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr"); | 1837 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr"); |
| 1804 | return std::__str_find<value_type, size_type, traits_type, npos>( | 1838 | return std::__str_find<value_type, size_type, traits_type, npos>( |
| 1805 | data(), size(), __s, __pos, traits_type::length(__s)); | 1839 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 1806 | } | 1840 | } |
| 1807 | 1841 | ||
| 1808 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT { | 1842 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT { |
| 1809 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 1843 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 1810 | } | 1844 | } |
| 1811 | 1845 | ||
| 1812 | // rfind | 1846 | // rfind |
| 1813 | 1847 | ||
| 1814 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1848 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1815 | rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { | 1849 | rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { |
| 1816 | return std::__str_rfind<value_type, size_type, traits_type, npos>( | 1850 | return std::__str_rfind<value_type, size_type, traits_type, npos>( |
| 1817 | data(), size(), __str.data(), __pos, __str.size()); | 1851 | data(), size(), __str.data(), __pos, __str.size()); |
| 1818 | } | 1852 | } |
| 1819 | 1853 | ||
| 1820 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1854 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1821 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1855 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1822 | rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { | 1856 | rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { |
| 1823 | __self_view __sv = __t; | 1857 | __self_view __sv = __t; |
| 1824 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); | 1858 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); |
| 1825 | } | 1859 | } |
| 1826 | 1860 | ||
| 1827 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 1861 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1862 | rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT | ||
| 1863 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 1828 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); | 1864 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); |
| 1829 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 1865 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 1830 | } | 1866 | } |
| 1831 | 1867 | ||
| 1832 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1868 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1833 | rfind(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { | 1869 | rfind(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 1834 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr"); | 1870 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr"); |
| 1835 | return std::__str_rfind<value_type, size_type, traits_type, npos>( | 1871 | return std::__str_rfind<value_type, size_type, traits_type, npos>( |
| 1836 | data(), size(), __s, __pos, traits_type::length(__s)); | 1872 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 1837 | } | 1873 | } |
| 1838 | 1874 | ||
| 1839 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT { | 1875 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1876 | rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT { | ||
| 1840 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 1877 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 1841 | } | 1878 | } |
| 1842 | 1879 | ||
| 1843 | // find_first_of | 1880 | // find_first_of |
| 1844 | 1881 | ||
| 1845 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1882 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1846 | find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { | 1883 | find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { |
| 1847 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | 1884 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( |
| 1848 | data(), size(), __str.data(), __pos, __str.size()); | 1885 | data(), size(), __str.data(), __pos, __str.size()); |
| 1849 | } | 1886 | } |
| 1850 | 1887 | ||
| 1851 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1888 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1852 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1889 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1853 | find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { | 1890 | find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { |
| 1854 | __self_view __sv = __t; | 1891 | __self_view __sv = __t; |
| 1855 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | 1892 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( |
| 1856 | data(), size(), __sv.data(), __pos, __sv.size()); | 1893 | data(), size(), __sv.data(), __pos, __sv.size()); |
| 1857 | } | 1894 | } |
| 1858 | 1895 | ||
| 1859 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1896 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1860 | find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 1897 | find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 1898 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 1861 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); | 1899 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); |
| 1862 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 1900 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 1863 | } | 1901 | } |
| 1864 | 1902 | ||
| 1865 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1903 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1866 | find_first_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { | 1904 | find_first_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 1867 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr"); | 1905 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr"); |
| 1868 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | 1906 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( |
| 1869 | data(), size(), __s, __pos, traits_type::length(__s)); | 1907 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 1870 | } | 1908 | } |
| 1871 | 1909 | ||
| 1872 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1910 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1873 | find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { | 1911 | find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { |
| 1874 | return find(__c, __pos); | 1912 | return find(__c, __pos); |
| 1875 | } | 1913 | } |
| 1876 | 1914 | ||
| 1877 | // find_last_of | 1915 | // find_last_of |
| 1878 | 1916 | ||
| 1879 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1917 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1880 | find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { | 1918 | find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { |
| 1881 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | 1919 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( |
| 1882 | data(), size(), __str.data(), __pos, __str.size()); | 1920 | data(), size(), __str.data(), __pos, __str.size()); |
| 1883 | } | 1921 | } |
| 1884 | 1922 | ||
| 1885 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1923 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1886 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1924 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1887 | find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { | 1925 | find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { |
| 1888 | __self_view __sv = __t; | 1926 | __self_view __sv = __t; |
| 1889 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | 1927 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( |
| 1890 | data(), size(), __sv.data(), __pos, __sv.size()); | 1928 | data(), size(), __sv.data(), __pos, __sv.size()); |
| 1891 | } | 1929 | } |
| 1892 | 1930 | ||
| 1893 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1931 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1894 | find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 1932 | find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 1933 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 1895 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); | 1934 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); |
| 1896 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 1935 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 1897 | } | 1936 | } |
| 1898 | 1937 | ||
| 1899 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1938 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1900 | find_last_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { | 1939 | find_last_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 1901 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr"); | 1940 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr"); |
| 1902 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | 1941 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( |
| 1903 | data(), size(), __s, __pos, traits_type::length(__s)); | 1942 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 1904 | } | 1943 | } |
| 1905 | 1944 | ||
| 1906 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1945 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1907 | find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { | 1946 | find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { |
| 1908 | return rfind(__c, __pos); | 1947 | return rfind(__c, __pos); |
| 1909 | } | 1948 | } |
| 1910 | 1949 | ||
| 1911 | // find_first_not_of | 1950 | // find_first_not_of |
| 1912 | 1951 | ||
| 1913 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1952 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1914 | find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { | 1953 | find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { |
| 1915 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | 1954 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( |
| 1916 | data(), size(), __str.data(), __pos, __str.size()); | 1955 | data(), size(), __str.data(), __pos, __str.size()); |
| 1917 | } | 1956 | } |
| 1918 | 1957 | ||
| 1919 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1958 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1920 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1959 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1921 | find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { | 1960 | find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { |
| 1922 | __self_view __sv = __t; | 1961 | __self_view __sv = __t; |
| 1923 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | 1962 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( |
| 1924 | data(), size(), __sv.data(), __pos, __sv.size()); | 1963 | data(), size(), __sv.data(), __pos, __sv.size()); |
| 1925 | } | 1964 | } |
| 1926 | 1965 | ||
| 1927 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1966 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1928 | find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 1967 | find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 1968 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 1929 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); | 1969 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); |
| 1930 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 1970 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 1931 | } | 1971 | } |
| 1932 | 1972 | ||
| 1933 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1973 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1934 | find_first_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { | 1974 | find_first_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 1935 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr"); | 1975 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr"); |
| 1936 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | 1976 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( |
| 1937 | data(), size(), __s, __pos, traits_type::length(__s)); | 1977 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 1938 | } | 1978 | } |
| 1939 | 1979 | ||
| 1940 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1980 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1941 | find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { | 1981 | find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { |
| 1942 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 1982 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 1943 | } | 1983 | } |
| 1944 | 1984 | ||
| 1945 | // find_last_not_of | 1985 | // find_last_not_of |
| 1946 | 1986 | ||
| 1947 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1987 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1948 | find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { | 1988 | find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { |
| 1949 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | 1989 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( |
| 1950 | data(), size(), __str.data(), __pos, __str.size()); | 1990 | data(), size(), __str.data(), __pos, __str.size()); |
| 1951 | } | 1991 | } |
| 1952 | 1992 | ||
| 1953 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1993 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1954 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1994 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1955 | find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { | 1995 | find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { |
| 1956 | __self_view __sv = __t; | 1996 | __self_view __sv = __t; |
| 1957 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | 1997 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( |
| 1958 | data(), size(), __sv.data(), __pos, __sv.size()); | 1998 | data(), size(), __sv.data(), __pos, __sv.size()); |
| 1959 | } | 1999 | } |
| 1960 | 2000 | ||
| 1961 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 2001 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1962 | find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 2002 | find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 2003 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 1963 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); | 2004 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); |
| 1964 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 2005 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 1965 | } | 2006 | } |
| 1966 | 2007 | ||
| 1967 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 2008 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1968 | find_last_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { | 2009 | find_last_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 1969 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr"); | 2010 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr"); |
| 1970 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | 2011 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( |
| 1971 | data(), size(), __s, __pos, traits_type::length(__s)); | 2012 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 1972 | } | 2013 | } |
| 1973 | 2014 | ||
| 1974 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 2015 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1975 | find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { | 2016 | find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { |
| 1976 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 2017 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 1977 | } | 2018 | } |
| 1978 | 2019 | ||
| 1979 | // compare | 2020 | // compare |
| 1980 | 2021 | ||
| 1981 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT { | 2022 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2023 | compare(const basic_string& __str) const _NOEXCEPT { | ||
| 1982 | return compare(__self_view(__str)); | 2024 | return compare(__self_view(__str)); |
| 1983 | } | 2025 | } |
| 1984 | 2026 | ||
| 1985 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 2027 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 1986 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const _Tp& __t) const _NOEXCEPT { | 2028 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const _Tp& __t) const _NOEXCEPT { |
| 1987 | __self_view __sv = __t; | 2029 | __self_view __sv = __t; |
| 1988 | size_t __lhs_sz = size(); | 2030 | size_t __lhs_sz = size(); |
| 1989 | size_t __rhs_sz = __sv.size(); | 2031 | size_t __rhs_sz = __sv.size(); |
| ... | @@ -1997,73 +2039,77 @@ public: | ... | @@ -1997,73 +2039,77 @@ public: |
| 1997 | return 0; | 2039 | return 0; |
| 1998 | } | 2040 | } |
| 1999 | 2041 | ||
| 2000 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 2042 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0> |
| 2001 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2043 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2002 | compare(size_type __pos1, size_type __n1, const _Tp& __t) const { | 2044 | compare(size_type __pos1, size_type __n1, const _Tp& __t) const { |
| 2003 | __self_view __sv = __t; | 2045 | __self_view __sv = __t; |
| 2004 | return compare(__pos1, __n1, __sv.data(), __sv.size()); | 2046 | return compare(__pos1, __n1, __sv.data(), __sv.size()); |
| 2005 | } | 2047 | } |
| 2006 | 2048 | ||
| 2007 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2049 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2008 | compare(size_type __pos1, size_type __n1, const basic_string& __str) const { | 2050 | compare(size_type __pos1, size_type __n1, const basic_string& __str) const { |
| 2009 | return compare(__pos1, __n1, __str.data(), __str.size()); | 2051 | return compare(__pos1, __n1, __str.data(), __str.size()); |
| 2010 | } | 2052 | } |
| 2011 | 2053 | ||
| 2012 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2054 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2013 | compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const { | 2055 | compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const { |
| 2014 | return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); | 2056 | return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); |
| 2015 | } | 2057 | } |
| 2016 | 2058 | ||
| 2017 | template <class _Tp, | 2059 | template <class _Tp, |
| 2018 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 2060 | __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> && |
| 2019 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, | 2061 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 2020 | int> = 0> | 2062 | int> = 0> |
| 2021 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2063 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2022 | compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const { | 2064 | compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const { |
| 2023 | __self_view __sv = __t; | 2065 | __self_view __sv = __t; |
| 2024 | return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); | 2066 | return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); |
| 2025 | } | 2067 | } |
| 2026 | 2068 | ||
| 2027 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const _NOEXCEPT { | 2069 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2070 | compare(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const _NOEXCEPT { | ||
| 2028 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); | 2071 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); |
| 2029 | return compare(0, npos, __s, traits_type::length(__s)); | 2072 | return compare(0, npos, __s, traits_type::length(__s)); |
| 2030 | } | 2073 | } |
| 2031 | 2074 | ||
| 2032 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2075 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2033 | compare(size_type __pos1, size_type __n1, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const { | 2076 | compare(size_type __pos1, size_type __n1, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const { |
| 2034 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); | 2077 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); |
| 2035 | return compare(__pos1, __n1, __s, traits_type::length(__s)); | 2078 | return compare(__pos1, __n1, __s, traits_type::length(__s)); |
| 2036 | } | 2079 | } |
| 2037 | 2080 | ||
| 2038 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2081 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 2039 | compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; | 2082 | compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const |
| 2083 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n2 != 0 && __s == nullptr, " if n2 is not zero"); | ||
| 2040 | 2084 | ||
| 2041 | // starts_with | 2085 | // starts_with |
| 2042 | 2086 | ||
| 2043 | # if _LIBCPP_STD_VER >= 20 | 2087 | # if _LIBCPP_STD_VER >= 20 |
| 2044 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { | 2088 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { |
| 2045 | return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); | 2089 | return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); |
| 2046 | } | 2090 | } |
| 2047 | 2091 | ||
| 2048 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept { | 2092 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept { |
| 2049 | return !empty() && _Traits::eq(front(), __c); | 2093 | return !empty() && _Traits::eq(front(), __c); |
| 2050 | } | 2094 | } |
| 2051 | 2095 | ||
| 2052 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { | 2096 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool |
| 2097 | starts_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { | ||
| 2053 | return starts_with(__self_view(__s)); | 2098 | return starts_with(__self_view(__s)); |
| 2054 | } | 2099 | } |
| 2055 | 2100 | ||
| 2056 | // ends_with | 2101 | // ends_with |
| 2057 | 2102 | ||
| 2058 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { | 2103 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { |
| 2059 | return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv); | 2104 | return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv); |
| 2060 | } | 2105 | } |
| 2061 | 2106 | ||
| 2062 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept { | 2107 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept { |
| 2063 | return !empty() && _Traits::eq(back(), __c); | 2108 | return !empty() && _Traits::eq(back(), __c); |
| 2064 | } | 2109 | } |
| 2065 | 2110 | ||
| 2066 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { | 2111 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool |
| 2112 | ends_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { | ||
| 2067 | return ends_with(__self_view(__s)); | 2113 | return ends_with(__self_view(__s)); |
| 2068 | } | 2114 | } |
| 2069 | # endif | 2115 | # endif |
| ... | @@ -2071,15 +2117,16 @@ public: | ... | @@ -2071,15 +2117,16 @@ public: |
| 2071 | // contains | 2117 | // contains |
| 2072 | 2118 | ||
| 2073 | # if _LIBCPP_STD_VER >= 23 | 2119 | # if _LIBCPP_STD_VER >= 23 |
| 2074 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { | 2120 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { |
| 2075 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); | 2121 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); |
| 2076 | } | 2122 | } |
| 2077 | 2123 | ||
| 2078 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { | 2124 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { |
| 2079 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c); | 2125 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c); |
| 2080 | } | 2126 | } |
| 2081 | 2127 | ||
| 2082 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const { | 2128 | [[__nodiscard__]] constexpr _LIBCPP_HIDE_FROM_ABI bool |
| 2129 | contains(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const { | ||
| 2083 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s); | 2130 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s); |
| 2084 | } | 2131 | } |
| 2085 | # endif | 2132 | # endif |
| ... | @@ -2095,18 +2142,6 @@ private: | ... | @@ -2095,18 +2142,6 @@ private: |
| 2095 | return __rep_.__s.__is_long_; | 2142 | return __rep_.__s.__is_long_; |
| 2096 | } | 2143 | } |
| 2097 | 2144 | ||
| 2098 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) { | ||
| 2099 | # if _LIBCPP_STD_VER >= 20 | ||
| 2100 | if (__libcpp_is_constant_evaluated()) { | ||
| 2101 | for (size_type __i = 0; __i != __n; ++__i) | ||
| 2102 | std::construct_at(std::addressof(__begin[__i])); | ||
| 2103 | } | ||
| 2104 | # else | ||
| 2105 | (void)__begin; | ||
| 2106 | (void)__n; | ||
| 2107 | # endif // _LIBCPP_STD_VER >= 20 | ||
| 2108 | } | ||
| 2109 | |||
| 2110 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { return __sz < __min_cap; } | 2145 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { return __sz < __min_cap; } |
| 2111 | 2146 | ||
| 2112 | template <class _Iterator, class _Sentinel> | 2147 | template <class _Iterator, class _Sentinel> |
| ... | @@ -2165,6 +2200,9 @@ private: | ... | @@ -2165,6 +2200,9 @@ private: |
| 2165 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | 2200 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| 2166 | __insert_with_size(const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n); | 2201 | __insert_with_size(const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n); |
| 2167 | 2202 | ||
| 2203 | // internal buffer accessors | ||
| 2204 | // ------------------------- | ||
| 2205 | |||
| 2168 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void | 2206 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void |
| 2169 | __set_short_size(size_type __s) _NOEXCEPT { | 2207 | __set_short_size(size_type __s) _NOEXCEPT { |
| 2170 | _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, "__s should never be greater than or equal to the short string capacity"); | 2208 | _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, "__s should never be greater than or equal to the short string capacity"); |
| ... | @@ -2194,21 +2232,11 @@ private: | ... | @@ -2194,21 +2232,11 @@ private: |
| 2194 | __set_short_size(__s); | 2232 | __set_short_size(__s); |
| 2195 | } | 2233 | } |
| 2196 | 2234 | ||
| 2197 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_cap(size_type __s) _NOEXCEPT { | ||
| 2198 | _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__s), "Long capacity should always be larger than the SSO"); | ||
| 2199 | __rep_.__l.__cap_ = __s / __endian_factor; | ||
| 2200 | __rep_.__l.__is_long_ = true; | ||
| 2201 | } | ||
| 2202 | |||
| 2203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT { | 2235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT { |
| 2204 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long capacity"); | 2236 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long capacity"); |
| 2205 | return __rep_.__l.__cap_ * __endian_factor; | 2237 | return __rep_.__l.__cap_ * __endian_factor; |
| 2206 | } | 2238 | } |
| 2207 | 2239 | ||
| 2208 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_pointer(pointer __p) _NOEXCEPT { | ||
| 2209 | __rep_.__l.__data_ = __p; | ||
| 2210 | } | ||
| 2211 | |||
| 2212 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT { | 2240 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT { |
| 2213 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer"); | 2241 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer"); |
| 2214 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_); | 2242 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_); |
| ... | @@ -2236,6 +2264,58 @@ private: | ... | @@ -2236,6 +2264,58 @@ private: |
| 2236 | return __is_long() ? __get_long_pointer() : __get_short_pointer(); | 2264 | return __is_long() ? __get_long_pointer() : __get_short_pointer(); |
| 2237 | } | 2265 | } |
| 2238 | 2266 | ||
| 2267 | // Internal buffer management | ||
| 2268 | // -------------------------- | ||
| 2269 | // | ||
| 2270 | // These functions are only responsible for managing the buffer itself, not the value inside the buffer. As such, | ||
| 2271 | // none of these facilities ensure that there is a null terminator at `data()[size()]`. | ||
| 2272 | |||
| 2273 | // Allocate a buffer of __capacity size with __alloc and return it | ||
| 2274 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 __long | ||
| 2275 | __allocate_long_buffer(_Allocator& __alloc, size_type __capacity) { | ||
| 2276 | _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__capacity), | ||
| 2277 | "Trying to allocate long buffer for a capacity what would fit into the small buffer"); | ||
| 2278 | auto __buffer = std::__allocate_at_least(__alloc, __align_allocation_size(__capacity)); | ||
| 2279 | |||
| 2280 | if (__libcpp_is_constant_evaluated()) { | ||
| 2281 | for (size_type __i = 0; __i != __buffer.count; ++__i) | ||
| 2282 | std::__construct_at(std::addressof(__buffer.ptr[__i])); | ||
| 2283 | } | ||
| 2284 | |||
| 2285 | return __long(__buffer, __capacity); | ||
| 2286 | } | ||
| 2287 | |||
| 2288 | // Replace the current buffer with __new_rep. Deallocate the old long buffer if it exists. | ||
| 2289 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __reset_internal_buffer(__rep __new_rep = __short()) { | ||
| 2290 | __annotate_delete(); | ||
| 2291 | if (__is_long()) | ||
| 2292 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 2293 | __rep_ = __new_rep; | ||
| 2294 | } | ||
| 2295 | |||
| 2296 | // Initialize the internal buffer to hold __size elements | ||
| 2297 | // The elements and null terminator have to be set by the caller | ||
| 2298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __init_internal_buffer(size_type __size) { | ||
| 2299 | if (__libcpp_is_constant_evaluated()) | ||
| 2300 | __rep_ = __rep(); | ||
| 2301 | |||
| 2302 | if (__size > max_size()) | ||
| 2303 | __throw_length_error(); | ||
| 2304 | |||
| 2305 | if (__fits_in_sso(__size)) { | ||
| 2306 | __set_short_size(__size); | ||
| 2307 | __annotate_new(__size); | ||
| 2308 | return __get_short_pointer(); | ||
| 2309 | } else { | ||
| 2310 | __rep_.__l = __allocate_long_buffer(__alloc_, __size); | ||
| 2311 | __annotate_new(__size); | ||
| 2312 | return __get_long_pointer(); | ||
| 2313 | } | ||
| 2314 | } | ||
| 2315 | |||
| 2316 | // ASan annotation helpers | ||
| 2317 | // ----------------------- | ||
| 2318 | |||
| 2239 | // The following functions are no-ops outside of AddressSanitizer mode. | 2319 | // The following functions are no-ops outside of AddressSanitizer mode. |
| 2240 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 2320 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2241 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { | 2321 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { |
| ... | @@ -2243,7 +2323,7 @@ private: | ... | @@ -2243,7 +2323,7 @@ private: |
| 2243 | (void)__new_mid; | 2323 | (void)__new_mid; |
| 2244 | # if _LIBCPP_INSTRUMENTED_WITH_ASAN | 2324 | # if _LIBCPP_INSTRUMENTED_WITH_ASAN |
| 2245 | # if defined(__APPLE__) | 2325 | # if defined(__APPLE__) |
| 2246 | // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) | 2326 | // TODO: remove after addressing issue #96099 (https://llvm.org/PR96099) |
| 2247 | if (!__is_long()) | 2327 | if (!__is_long()) |
| 2248 | return; | 2328 | return; |
| 2249 | # endif | 2329 | # endif |
| ... | @@ -2287,19 +2367,36 @@ private: | ... | @@ -2287,19 +2367,36 @@ private: |
| 2287 | return (__s + (__a - 1)) & ~(__a - 1); | 2367 | return (__s + (__a - 1)) & ~(__a - 1); |
| 2288 | } | 2368 | } |
| 2289 | enum { __alignment = 8 }; | 2369 | enum { __alignment = 8 }; |
| 2290 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT { | 2370 | |
| 2291 | if (__s < __min_cap) { | 2371 | // This makes sure that we're using a capacity with some extra alignment, since allocators almost always over-align |
| 2292 | return static_cast<size_type>(__min_cap) - 1; | 2372 | // the allocations anyways, improving memory usage. More importantly, this ensures that the lowest bit is never set |
| 2293 | } | 2373 | // if __endian_factor == 2, allowing us to store whether we're in the long string inside the lowest bit. |
| 2374 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | ||
| 2375 | __align_allocation_size(size_type __size) _NOEXCEPT { | ||
| 2376 | _LIBCPP_ASSERT_INTERNAL( | ||
| 2377 | !__fits_in_sso(__size), "Trying to align allocation of a size which would fit into the SSO"); | ||
| 2294 | const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor; | 2378 | const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor; |
| 2295 | size_type __guess = __align_it<__boundary>(__s + 1) - 1; | 2379 | size_type __guess = __align_it<__boundary>(__size + 1); |
| 2296 | if (__guess == __min_cap) | 2380 | if (__guess == __min_cap + 1) |
| 2297 | __guess += __endian_factor; | 2381 | __guess += __endian_factor; |
| 2298 | 2382 | ||
| 2299 | _LIBCPP_ASSERT_INTERNAL(__guess >= __s, "recommendation is below the requested size"); | 2383 | _LIBCPP_ASSERT_INTERNAL(__guess >= __size, "aligned allocation size is below the requested size"); |
| 2300 | return __guess; | 2384 | return __guess; |
| 2301 | } | 2385 | } |
| 2302 | 2386 | ||
| 2387 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | ||
| 2388 | __get_amortized_growth_capacity(size_type __required_capacity) { | ||
| 2389 | size_type __max_size = max_size(); | ||
| 2390 | if (__required_capacity > __max_size) | ||
| 2391 | __throw_length_error(); | ||
| 2392 | size_type __current_cap = capacity(); | ||
| 2393 | _LIBCPP_ASSERT_INTERNAL( | ||
| 2394 | __current_cap < __required_capacity, "Trying to grow string even though there is enough capacity already?"); | ||
| 2395 | if (__current_cap > __max_size / 2 - __alignment) | ||
| 2396 | return __max_size; | ||
| 2397 | return std::max(__required_capacity, 2 * __current_cap); | ||
| 2398 | } | ||
| 2399 | |||
| 2303 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz); | 2400 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz); |
| 2304 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c); | 2401 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c); |
| 2305 | 2402 | ||
| ... | @@ -2366,7 +2463,8 @@ private: | ... | @@ -2366,7 +2463,8 @@ private: |
| 2366 | 2463 | ||
| 2367 | // __erase_external_with_move is invoked for erase() invocations where | 2464 | // __erase_external_with_move is invoked for erase() invocations where |
| 2368 | // `n ~= npos`, likely requiring memory moves on the string data. | 2465 | // `n ~= npos`, likely requiring memory moves on the string data. |
| 2369 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void __erase_external_with_move(size_type __pos, size_type __n); | 2466 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void |
| 2467 | __erase_external_with_move(size_type __pos, size_type __n) _NOEXCEPT; | ||
| 2370 | 2468 | ||
| 2371 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str) { | 2469 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str) { |
| 2372 | __copy_assign_alloc( | 2470 | __copy_assign_alloc( |
| ... | @@ -2378,24 +2476,14 @@ private: | ... | @@ -2378,24 +2476,14 @@ private: |
| 2378 | __alloc_ = __str.__alloc_; | 2476 | __alloc_ = __str.__alloc_; |
| 2379 | else { | 2477 | else { |
| 2380 | if (!__str.__is_long()) { | 2478 | if (!__str.__is_long()) { |
| 2381 | if (__is_long()) { | 2479 | __reset_internal_buffer(); |
| 2382 | __annotate_delete(); | ||
| 2383 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 2384 | __rep_ = __rep(); | ||
| 2385 | } | ||
| 2386 | __alloc_ = __str.__alloc_; | 2480 | __alloc_ = __str.__alloc_; |
| 2387 | } else { | 2481 | } else { |
| 2388 | __annotate_delete(); | 2482 | __annotate_delete(); |
| 2389 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | 2483 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); |
| 2390 | allocator_type __a = __str.__alloc_; | 2484 | auto __alloc = __str.__alloc_; |
| 2391 | auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); | 2485 | __reset_internal_buffer(__allocate_long_buffer(__alloc, __str.size())); |
| 2392 | __begin_lifetime(__allocation.ptr, __allocation.count); | 2486 | __alloc_ = std::move(__alloc); |
| 2393 | if (__is_long()) | ||
| 2394 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 2395 | __alloc_ = std::move(__a); | ||
| 2396 | __set_long_pointer(__allocation.ptr); | ||
| 2397 | __set_long_cap(__allocation.count); | ||
| 2398 | __set_long_size(__str.__get_long_size()); | ||
| 2399 | } | 2487 | } |
| 2400 | } | 2488 | } |
| 2401 | } | 2489 | } |
| ... | @@ -2507,26 +2595,55 @@ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) | ... | @@ -2507,26 +2595,55 @@ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) |
| 2507 | # endif | 2595 | # endif |
| 2508 | # undef _LIBCPP_DECLARE | 2596 | # undef _LIBCPP_DECLARE |
| 2509 | 2597 | ||
| 2598 | # if _LIBCPP_STD_VER <= 17 || !__has_builtin(__builtin_lt_synthesizes_from_spaceship) | ||
| 2599 | template <class _CharT, class _Traits, class _Alloc> | ||
| 2600 | struct __default_three_way_comparator<basic_string<_CharT, _Traits, _Alloc>, basic_string<_CharT, _Traits, _Alloc> > { | ||
| 2601 | using __string_t _LIBCPP_NODEBUG = basic_string<_CharT, _Traits, _Alloc>; | ||
| 2602 | |||
| 2603 | _LIBCPP_HIDE_FROM_ABI static int operator()(const __string_t& __lhs, const __string_t& __rhs) { | ||
| 2604 | auto __min_len = std::min(__lhs.size(), __rhs.size()); | ||
| 2605 | auto __ret = _Traits::compare(__lhs.data(), __rhs.data(), __min_len); | ||
| 2606 | if (__ret == 0) | ||
| 2607 | return __lhs.size() == __rhs.size() ? 0 : __lhs.size() < __rhs.size() ? -1 : 1; | ||
| 2608 | return __ret; | ||
| 2609 | } | ||
| 2610 | }; | ||
| 2611 | # endif | ||
| 2612 | |||
| 2613 | template <class _Comparator, class _CharT, class _Traits, class _Alloc> | ||
| 2614 | inline const bool __is_transparently_comparable_v<_Comparator, | ||
| 2615 | basic_string<_CharT, _Traits, _Alloc>, | ||
| 2616 | const _CharT*, | ||
| 2617 | __enable_if_t<__is_generic_transparent_comparator_v<_Comparator> > > = | ||
| 2618 | true; | ||
| 2619 | |||
| 2620 | template <class _Comparator, class _CharT, class _Traits, class _Alloc, size_t _Np> | ||
| 2621 | inline const bool __is_transparently_comparable_v<_Comparator, | ||
| 2622 | basic_string<_CharT, _Traits, _Alloc>, | ||
| 2623 | _CharT[_Np], | ||
| 2624 | __enable_if_t<__is_generic_transparent_comparator_v<_Comparator> > > = | ||
| 2625 | true; | ||
| 2626 | |||
| 2510 | # if _LIBCPP_STD_VER >= 17 | 2627 | # if _LIBCPP_STD_VER >= 17 |
| 2511 | template <class _InputIterator, | 2628 | template <class _InputIterator, |
| 2512 | class _CharT = __iter_value_type<_InputIterator>, | 2629 | class _CharT = __iterator_value_type<_InputIterator>, |
| 2513 | class _Allocator = allocator<_CharT>, | 2630 | class _Allocator = allocator<_CharT>, |
| 2514 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 2631 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 2515 | class = enable_if_t<__is_allocator<_Allocator>::value> > | 2632 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2516 | basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) | 2633 | basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) |
| 2517 | -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; | 2634 | -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; |
| 2518 | 2635 | ||
| 2519 | template <class _CharT, | 2636 | template <class _CharT, |
| 2520 | class _Traits, | 2637 | class _Traits, |
| 2521 | class _Allocator = allocator<_CharT>, | 2638 | class _Allocator = allocator<_CharT>, |
| 2522 | class = enable_if_t<__is_allocator<_Allocator>::value> > | 2639 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2523 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) | 2640 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) |
| 2524 | -> basic_string<_CharT, _Traits, _Allocator>; | 2641 | -> basic_string<_CharT, _Traits, _Allocator>; |
| 2525 | 2642 | ||
| 2526 | template <class _CharT, | 2643 | template <class _CharT, |
| 2527 | class _Traits, | 2644 | class _Traits, |
| 2528 | class _Allocator = allocator<_CharT>, | 2645 | class _Allocator = allocator<_CharT>, |
| 2529 | class = enable_if_t<__is_allocator<_Allocator>::value>, | 2646 | class = enable_if_t<__is_allocator_v<_Allocator>>, |
| 2530 | class _Sz = typename allocator_traits<_Allocator>::size_type > | 2647 | class _Sz = typename allocator_traits<_Allocator>::size_type > |
| 2531 | basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) | 2648 | basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) |
| 2532 | -> basic_string<_CharT, _Traits, _Allocator>; | 2649 | -> basic_string<_CharT, _Traits, _Allocator>; |
| ... | @@ -2535,7 +2652,7 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _ | ... | @@ -2535,7 +2652,7 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _ |
| 2535 | # if _LIBCPP_STD_VER >= 23 | 2652 | # if _LIBCPP_STD_VER >= 23 |
| 2536 | template <ranges::input_range _Range, | 2653 | template <ranges::input_range _Range, |
| 2537 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | 2654 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 2538 | class = enable_if_t<__is_allocator<_Allocator>::value> > | 2655 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2539 | basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) | 2656 | basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) |
| 2540 | -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>; | 2657 | -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>; |
| 2541 | # endif | 2658 | # endif |
| ... | @@ -2543,73 +2660,23 @@ basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) | ... | @@ -2543,73 +2660,23 @@ basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) |
| 2543 | template <class _CharT, class _Traits, class _Allocator> | 2660 | template <class _CharT, class _Traits, class _Allocator> |
| 2544 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 2661 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2545 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { | 2662 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { |
| 2546 | if (__libcpp_is_constant_evaluated()) | 2663 | pointer __p = __init_internal_buffer(__sz); |
| 2547 | __rep_ = __rep(); | ||
| 2548 | if (__sz > max_size()) | ||
| 2549 | this->__throw_length_error(); | ||
| 2550 | pointer __p; | ||
| 2551 | if (__fits_in_sso(__sz)) { | ||
| 2552 | __set_short_size(__sz); | ||
| 2553 | __p = __get_short_pointer(); | ||
| 2554 | } else { | ||
| 2555 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); | ||
| 2556 | __p = __allocation.ptr; | ||
| 2557 | __begin_lifetime(__p, __allocation.count); | ||
| 2558 | __set_long_pointer(__p); | ||
| 2559 | __set_long_cap(__allocation.count); | ||
| 2560 | __set_long_size(__sz); | ||
| 2561 | } | ||
| 2562 | traits_type::copy(std::__to_address(__p), __s, __sz); | 2664 | traits_type::copy(std::__to_address(__p), __s, __sz); |
| 2563 | traits_type::assign(__p[__sz], value_type()); | 2665 | traits_type::assign(__p[__sz], value_type()); |
| 2564 | __annotate_new(__sz); | ||
| 2565 | } | 2666 | } |
| 2566 | 2667 | ||
| 2567 | template <class _CharT, class _Traits, class _Allocator> | 2668 | template <class _CharT, class _Traits, class _Allocator> |
| 2568 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void | 2669 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void |
| 2569 | basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) { | 2670 | basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) { |
| 2570 | if (__libcpp_is_constant_evaluated()) | 2671 | pointer __p = __init_internal_buffer(__sz); |
| 2571 | __rep_ = __rep(); | ||
| 2572 | |||
| 2573 | pointer __p; | ||
| 2574 | if (__fits_in_sso(__sz)) { | ||
| 2575 | __p = __get_short_pointer(); | ||
| 2576 | __set_short_size(__sz); | ||
| 2577 | } else { | ||
| 2578 | if (__sz > max_size()) | ||
| 2579 | this->__throw_length_error(); | ||
| 2580 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); | ||
| 2581 | __p = __allocation.ptr; | ||
| 2582 | __begin_lifetime(__p, __allocation.count); | ||
| 2583 | __set_long_pointer(__p); | ||
| 2584 | __set_long_cap(__allocation.count); | ||
| 2585 | __set_long_size(__sz); | ||
| 2586 | } | ||
| 2587 | traits_type::copy(std::__to_address(__p), __s, __sz + 1); | 2672 | traits_type::copy(std::__to_address(__p), __s, __sz + 1); |
| 2588 | __annotate_new(__sz); | ||
| 2589 | } | 2673 | } |
| 2590 | 2674 | ||
| 2591 | template <class _CharT, class _Traits, class _Allocator> | 2675 | template <class _CharT, class _Traits, class _Allocator> |
| 2592 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) { | 2676 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) { |
| 2593 | if (__libcpp_is_constant_evaluated()) | 2677 | pointer __p = __init_internal_buffer(__n); |
| 2594 | __rep_ = __rep(); | ||
| 2595 | |||
| 2596 | if (__n > max_size()) | ||
| 2597 | this->__throw_length_error(); | ||
| 2598 | pointer __p; | ||
| 2599 | if (__fits_in_sso(__n)) { | ||
| 2600 | __set_short_size(__n); | ||
| 2601 | __p = __get_short_pointer(); | ||
| 2602 | } else { | ||
| 2603 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__n) + 1); | ||
| 2604 | __p = __allocation.ptr; | ||
| 2605 | __begin_lifetime(__p, __allocation.count); | ||
| 2606 | __set_long_pointer(__p); | ||
| 2607 | __set_long_cap(__allocation.count); | ||
| 2608 | __set_long_size(__n); | ||
| 2609 | } | ||
| 2610 | traits_type::assign(std::__to_address(__p), __n, __c); | 2678 | traits_type::assign(std::__to_address(__p), __n, __c); |
| 2611 | traits_type::assign(__p[__n], value_type()); | 2679 | traits_type::assign(__p[__n], value_type()); |
| 2612 | __annotate_new(__n); | ||
| 2613 | } | 2680 | } |
| 2614 | 2681 | ||
| 2615 | template <class _CharT, class _Traits, class _Allocator> | 2682 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -2626,19 +2693,10 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator _ | ... | @@ -2626,19 +2693,10 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator _ |
| 2626 | __rep_ = __rep(); | 2693 | __rep_ = __rep(); |
| 2627 | __annotate_new(0); | 2694 | __annotate_new(0); |
| 2628 | 2695 | ||
| 2629 | # if _LIBCPP_HAS_EXCEPTIONS | 2696 | auto __guard = std::__make_exception_guard([this] { __reset_internal_buffer(); }); |
| 2630 | try { | 2697 | for (; __first != __last; ++__first) |
| 2631 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2698 | push_back(*__first); |
| 2632 | for (; __first != __last; ++__first) | 2699 | __guard.__complete(); |
| 2633 | push_back(*__first); | ||
| 2634 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2635 | } catch (...) { | ||
| 2636 | __annotate_delete(); | ||
| 2637 | if (__is_long()) | ||
| 2638 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 2639 | throw; | ||
| 2640 | } | ||
| 2641 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2642 | } | 2700 | } |
| 2643 | 2701 | ||
| 2644 | template <class _CharT, class _Traits, class _Allocator> | 2702 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -2653,39 +2711,12 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -2653,39 +2711,12 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2653 | template <class _InputIterator, class _Sentinel> | 2711 | template <class _InputIterator, class _Sentinel> |
| 2654 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 2712 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2655 | basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz) { | 2713 | basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz) { |
| 2656 | if (__libcpp_is_constant_evaluated()) | 2714 | pointer __p = __init_internal_buffer(__sz); |
| 2657 | __rep_ = __rep(); | ||
| 2658 | 2715 | ||
| 2659 | if (__sz > max_size()) | 2716 | auto __guard = std::__make_exception_guard([this] { __reset_internal_buffer(); }); |
| 2660 | this->__throw_length_error(); | 2717 | auto __end = __copy_non_overlapping_range(std::move(__first), std::move(__last), std::__to_address(__p)); |
| 2661 | 2718 | traits_type::assign(*__end, value_type()); | |
| 2662 | pointer __p; | 2719 | __guard.__complete(); |
| 2663 | if (__fits_in_sso(__sz)) { | ||
| 2664 | __set_short_size(__sz); | ||
| 2665 | __p = __get_short_pointer(); | ||
| 2666 | |||
| 2667 | } else { | ||
| 2668 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); | ||
| 2669 | __p = __allocation.ptr; | ||
| 2670 | __begin_lifetime(__p, __allocation.count); | ||
| 2671 | __set_long_pointer(__p); | ||
| 2672 | __set_long_cap(__allocation.count); | ||
| 2673 | __set_long_size(__sz); | ||
| 2674 | } | ||
| 2675 | |||
| 2676 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2677 | try { | ||
| 2678 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2679 | auto __end = __copy_non_overlapping_range(std::move(__first), std::move(__last), std::__to_address(__p)); | ||
| 2680 | traits_type::assign(*__end, value_type()); | ||
| 2681 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2682 | } catch (...) { | ||
| 2683 | if (__is_long()) | ||
| 2684 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 2685 | throw; | ||
| 2686 | } | ||
| 2687 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2688 | __annotate_new(__sz); | ||
| 2689 | } | 2720 | } |
| 2690 | 2721 | ||
| 2691 | template <class _CharT, class _Traits, class _Allocator> | 2722 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -2697,32 +2728,22 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ | ... | @@ -2697,32 +2728,22 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2697 | size_type __n_del, | 2728 | size_type __n_del, |
| 2698 | size_type __n_add, | 2729 | size_type __n_add, |
| 2699 | const value_type* __p_new_stuff) { | 2730 | const value_type* __p_new_stuff) { |
| 2700 | size_type __ms = max_size(); | 2731 | __long __buffer = __allocate_long_buffer(__alloc_, __get_amortized_growth_capacity(__old_cap + __delta_cap)); |
| 2701 | if (__delta_cap > __ms - __old_cap) | ||
| 2702 | __throw_length_error(); | ||
| 2703 | pointer __old_p = __get_pointer(); | 2732 | pointer __old_p = __get_pointer(); |
| 2704 | size_type __cap = | ||
| 2705 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms; | ||
| 2706 | __annotate_delete(); | 2733 | __annotate_delete(); |
| 2707 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | 2734 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); |
| 2708 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); | ||
| 2709 | pointer __p = __allocation.ptr; | ||
| 2710 | __begin_lifetime(__p, __allocation.count); | ||
| 2711 | if (__n_copy != 0) | 2735 | if (__n_copy != 0) |
| 2712 | traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy); | 2736 | traits_type::copy(std::__to_address(__buffer.__data_), std::__to_address(__old_p), __n_copy); |
| 2713 | if (__n_add != 0) | 2737 | if (__n_add != 0) |
| 2714 | traits_type::copy(std::__to_address(__p) + __n_copy, __p_new_stuff, __n_add); | 2738 | traits_type::copy(std::__to_address(__buffer.__data_) + __n_copy, __p_new_stuff, __n_add); |
| 2715 | size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; | 2739 | size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; |
| 2716 | if (__sec_cp_sz != 0) | 2740 | if (__sec_cp_sz != 0) |
| 2717 | traits_type::copy( | 2741 | traits_type::copy(std::__to_address(__buffer.__data_) + __n_copy + __n_add, |
| 2718 | std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); | 2742 | std::__to_address(__old_p) + __n_copy + __n_del, |
| 2719 | if (__old_cap + 1 != __min_cap) | 2743 | __sec_cp_sz); |
| 2720 | __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1); | 2744 | __buffer.__size_ = __n_copy + __n_add + __sec_cp_sz; |
| 2721 | __set_long_pointer(__p); | 2745 | traits_type::assign(__buffer.__data_[__buffer.__size_], value_type()); |
| 2722 | __set_long_cap(__allocation.count); | 2746 | __reset_internal_buffer(__buffer); |
| 2723 | __old_sz = __n_copy + __n_add + __sec_cp_sz; | ||
| 2724 | __set_long_size(__old_sz); | ||
| 2725 | traits_type::assign(__p[__old_sz], value_type()); | ||
| 2726 | } | 2747 | } |
| 2727 | 2748 | ||
| 2728 | // __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it | 2749 | // __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it |
| ... | @@ -2740,25 +2761,20 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait | ... | @@ -2740,25 +2761,20 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait |
| 2740 | size_type __n_copy, | 2761 | size_type __n_copy, |
| 2741 | size_type __n_del, | 2762 | size_type __n_del, |
| 2742 | size_type __n_add) { | 2763 | size_type __n_add) { |
| 2743 | size_type __ms = max_size(); | 2764 | __long __buffer = __allocate_long_buffer(__alloc_, __get_amortized_growth_capacity(__old_cap + __delta_cap)); |
| 2744 | if (__delta_cap > __ms - __old_cap) | ||
| 2745 | this->__throw_length_error(); | ||
| 2746 | pointer __old_p = __get_pointer(); | 2765 | pointer __old_p = __get_pointer(); |
| 2747 | size_type __cap = | ||
| 2748 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms; | ||
| 2749 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); | ||
| 2750 | pointer __p = __allocation.ptr; | ||
| 2751 | __begin_lifetime(__p, __allocation.count); | ||
| 2752 | if (__n_copy != 0) | 2766 | if (__n_copy != 0) |
| 2753 | traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy); | 2767 | traits_type::copy(std::__to_address(__buffer.__data_), std::__to_address(__old_p), __n_copy); |
| 2754 | size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; | 2768 | size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; |
| 2755 | if (__sec_cp_sz != 0) | 2769 | if (__sec_cp_sz != 0) |
| 2756 | traits_type::copy( | 2770 | traits_type::copy(std::__to_address(__buffer.__data_) + __n_copy + __n_add, |
| 2757 | std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); | 2771 | std::__to_address(__old_p) + __n_copy + __n_del, |
| 2758 | if (__old_cap + 1 != __min_cap) | 2772 | __sec_cp_sz); |
| 2759 | __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1); | 2773 | |
| 2760 | __set_long_pointer(__p); | 2774 | // This is -1 to make sure the caller sets the size properly, since old versions of this function didn't set the size |
| 2761 | __set_long_cap(__allocation.count); | 2775 | // at all. |
| 2776 | __buffer.__size_ = -1; | ||
| 2777 | __reset_internal_buffer(__buffer); | ||
| 2762 | } | 2778 | } |
| 2763 | 2779 | ||
| 2764 | template <class _CharT, class _Traits, class _Allocator> | 2780 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -2775,6 +2791,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_without_replace( | ... | @@ -2775,6 +2791,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_without_replace( |
| 2775 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 2791 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 2776 | __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add); | 2792 | __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add); |
| 2777 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 2793 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 2794 | // Due to the ABI of __grow_by we have to set the size after calling it. | ||
| 2778 | __set_long_size(__old_sz - __n_del + __n_add); | 2795 | __set_long_size(__old_sz - __n_del + __n_add); |
| 2779 | } | 2796 | } |
| 2780 | 2797 | ||
| ... | @@ -2786,24 +2803,23 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Al | ... | @@ -2786,24 +2803,23 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Al |
| 2786 | basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) { | 2803 | basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) { |
| 2787 | const auto __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap(); | 2804 | const auto __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap(); |
| 2788 | const auto __size = __is_short ? __get_short_size() : __get_long_size(); | 2805 | const auto __size = __is_short ? __get_short_size() : __get_long_size(); |
| 2789 | if (__n < __cap) { | 2806 | if (__n >= __cap) { |
| 2790 | if (__n > __size) | ||
| 2791 | __annotate_increase(__n - __size); | ||
| 2792 | pointer __p; | ||
| 2793 | if (__is_short) { | ||
| 2794 | __p = __get_short_pointer(); | ||
| 2795 | __set_short_size(__n); | ||
| 2796 | } else { | ||
| 2797 | __p = __get_long_pointer(); | ||
| 2798 | __set_long_size(__n); | ||
| 2799 | } | ||
| 2800 | traits_type::copy(std::__to_address(__p), __s, __n); | ||
| 2801 | traits_type::assign(__p[__n], value_type()); | ||
| 2802 | if (__size > __n) | ||
| 2803 | __annotate_shrink(__size); | ||
| 2804 | } else { | ||
| 2805 | __grow_by_and_replace(__cap - 1, __n - __cap + 1, __size, 0, __size, __n, __s); | 2807 | __grow_by_and_replace(__cap - 1, __n - __cap + 1, __size, 0, __size, __n, __s); |
| 2808 | return *this; | ||
| 2806 | } | 2809 | } |
| 2810 | |||
| 2811 | __annotate_delete(); | ||
| 2812 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | ||
| 2813 | pointer __p; | ||
| 2814 | if (__is_short) { | ||
| 2815 | __p = __get_short_pointer(); | ||
| 2816 | __set_short_size(__n); | ||
| 2817 | } else { | ||
| 2818 | __p = __get_long_pointer(); | ||
| 2819 | __set_long_size(__n); | ||
| 2820 | } | ||
| 2821 | traits_type::copy(std::__to_address(__p), __s, __n); | ||
| 2822 | traits_type::assign(__p[__n], value_type()); | ||
| 2807 | return *this; | 2823 | return *this; |
| 2808 | } | 2824 | } |
| 2809 | 2825 | ||
| ... | @@ -2910,7 +2926,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr | ... | @@ -2910,7 +2926,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr |
| 2910 | { | 2926 | { |
| 2911 | __annotate_delete(); | 2927 | __annotate_delete(); |
| 2912 | if (__is_long()) { | 2928 | if (__is_long()) { |
| 2913 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | 2929 | __reset_internal_buffer(); |
| 2914 | # if _LIBCPP_STD_VER <= 14 | 2930 | # if _LIBCPP_STD_VER <= 14 |
| 2915 | if (!is_nothrow_move_assignable<allocator_type>::value) { | 2931 | if (!is_nothrow_move_assignable<allocator_type>::value) { |
| 2916 | __set_short_size(0); | 2932 | __set_short_size(0); |
| ... | @@ -2961,7 +2977,7 @@ template <class _Iterator, class _Sentinel> | ... | @@ -2961,7 +2977,7 @@ template <class _Iterator, class _Sentinel> |
| 2961 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 2977 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 2962 | basic_string<_CharT, _Traits, _Allocator>::__assign_trivial(_Iterator __first, _Sentinel __last, size_type __n) { | 2978 | basic_string<_CharT, _Traits, _Allocator>::__assign_trivial(_Iterator __first, _Sentinel __last, size_type __n) { |
| 2963 | _LIBCPP_ASSERT_INTERNAL( | 2979 | _LIBCPP_ASSERT_INTERNAL( |
| 2964 | __string_is_trivial_iterator<_Iterator>::value, "The iterator type given to `__assign_trivial` must be trivial"); | 2980 | __string_is_trivial_iterator_v<_Iterator>, "The iterator type given to `__assign_trivial` must be trivial"); |
| 2965 | 2981 | ||
| 2966 | size_type __old_size = size(); | 2982 | size_type __old_size = size(); |
| 2967 | size_type __cap = capacity(); | 2983 | size_type __cap = capacity(); |
| ... | @@ -3017,52 +3033,40 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty | ... | @@ -3017,52 +3033,40 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty |
| 3017 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::append received nullptr"); | 3033 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::append received nullptr"); |
| 3018 | size_type __cap = capacity(); | 3034 | size_type __cap = capacity(); |
| 3019 | size_type __sz = size(); | 3035 | size_type __sz = size(); |
| 3020 | if (__cap - __sz >= __n) { | 3036 | if (__cap - __sz < __n) { |
| 3021 | if (__n) { | ||
| 3022 | __annotate_increase(__n); | ||
| 3023 | value_type* __p = std::__to_address(__get_pointer()); | ||
| 3024 | traits_type::copy(__p + __sz, __s, __n); | ||
| 3025 | __sz += __n; | ||
| 3026 | __set_size(__sz); | ||
| 3027 | traits_type::assign(__p[__sz], value_type()); | ||
| 3028 | } | ||
| 3029 | } else | ||
| 3030 | __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); | 3037 | __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); |
| 3038 | return *this; | ||
| 3039 | } | ||
| 3040 | |||
| 3041 | if (__n == 0) | ||
| 3042 | return *this; | ||
| 3043 | |||
| 3044 | __annotate_increase(__n); | ||
| 3045 | value_type* __p = std::__to_address(__get_pointer()); | ||
| 3046 | traits_type::copy(__p + __sz, __s, __n); | ||
| 3047 | __sz += __n; | ||
| 3048 | __set_size(__sz); | ||
| 3049 | traits_type::assign(__p[__sz], value_type()); | ||
| 3031 | return *this; | 3050 | return *this; |
| 3032 | } | 3051 | } |
| 3033 | 3052 | ||
| 3034 | template <class _CharT, class _Traits, class _Allocator> | 3053 | template <class _CharT, class _Traits, class _Allocator> |
| 3035 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3054 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3036 | basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) { | 3055 | basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) { |
| 3037 | if (__n) { | 3056 | if (__n == 0) |
| 3038 | size_type __cap = capacity(); | 3057 | return *this; |
| 3039 | size_type __sz = size(); | ||
| 3040 | if (__cap - __sz < __n) | ||
| 3041 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); | ||
| 3042 | __annotate_increase(__n); | ||
| 3043 | pointer __p = __get_pointer(); | ||
| 3044 | traits_type::assign(std::__to_address(__p) + __sz, __n, __c); | ||
| 3045 | __sz += __n; | ||
| 3046 | __set_size(__sz); | ||
| 3047 | traits_type::assign(__p[__sz], value_type()); | ||
| 3048 | } | ||
| 3049 | return *this; | ||
| 3050 | } | ||
| 3051 | 3058 | ||
| 3052 | template <class _CharT, class _Traits, class _Allocator> | 3059 | size_type __cap = capacity(); |
| 3053 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void | 3060 | size_type __sz = size(); |
| 3054 | basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) { | 3061 | if (__cap - __sz < __n) |
| 3055 | if (__n) { | 3062 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); |
| 3056 | size_type __cap = capacity(); | 3063 | __annotate_increase(__n); |
| 3057 | size_type __sz = size(); | 3064 | pointer __p = __get_pointer(); |
| 3058 | if (__cap - __sz < __n) | 3065 | traits_type::assign(std::__to_address(__p) + __sz, __n, __c); |
| 3059 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); | 3066 | __sz += __n; |
| 3060 | __annotate_increase(__n); | 3067 | __set_size(__sz); |
| 3061 | pointer __p = __get_pointer(); | 3068 | traits_type::assign(__p[__sz], value_type()); |
| 3062 | __sz += __n; | 3069 | return *this; |
| 3063 | __set_size(__sz); | ||
| 3064 | traits_type::assign(__p[__sz], value_type()); | ||
| 3065 | } | ||
| 3066 | } | 3070 | } |
| 3067 | 3071 | ||
| 3068 | template <class _CharT, class _Traits, class _Allocator> | 3072 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3120,23 +3124,27 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t | ... | @@ -3120,23 +3124,27 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t |
| 3120 | if (__pos > __sz) | 3124 | if (__pos > __sz) |
| 3121 | this->__throw_out_of_range(); | 3125 | this->__throw_out_of_range(); |
| 3122 | size_type __cap = capacity(); | 3126 | size_type __cap = capacity(); |
| 3123 | if (__cap - __sz >= __n) { | 3127 | |
| 3124 | if (__n) { | 3128 | if (__cap - __sz < __n) { |
| 3125 | __annotate_increase(__n); | ||
| 3126 | value_type* __p = std::__to_address(__get_pointer()); | ||
| 3127 | size_type __n_move = __sz - __pos; | ||
| 3128 | if (__n_move != 0) { | ||
| 3129 | if (std::__is_pointer_in_range(__p + __pos, __p + __sz, __s)) | ||
| 3130 | __s += __n; | ||
| 3131 | traits_type::move(__p + __pos + __n, __p + __pos, __n_move); | ||
| 3132 | } | ||
| 3133 | traits_type::move(__p + __pos, __s, __n); | ||
| 3134 | __sz += __n; | ||
| 3135 | __set_size(__sz); | ||
| 3136 | traits_type::assign(__p[__sz], value_type()); | ||
| 3137 | } | ||
| 3138 | } else | ||
| 3139 | __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); | 3129 | __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); |
| 3130 | return *this; | ||
| 3131 | } | ||
| 3132 | |||
| 3133 | if (__n == 0) | ||
| 3134 | return *this; | ||
| 3135 | |||
| 3136 | __annotate_increase(__n); | ||
| 3137 | value_type* __p = std::__to_address(__get_pointer()); | ||
| 3138 | size_type __n_move = __sz - __pos; | ||
| 3139 | if (__n_move != 0) { | ||
| 3140 | if (std::__is_pointer_in_range(__p + __pos, __p + __sz, __s)) | ||
| 3141 | __s += __n; | ||
| 3142 | traits_type::move(__p + __pos + __n, __p + __pos, __n_move); | ||
| 3143 | } | ||
| 3144 | traits_type::move(__p + __pos, __s, __n); | ||
| 3145 | __sz += __n; | ||
| 3146 | __set_size(__sz); | ||
| 3147 | traits_type::assign(__p[__sz], value_type()); | ||
| 3140 | return *this; | 3148 | return *this; |
| 3141 | } | 3149 | } |
| 3142 | 3150 | ||
| ... | @@ -3146,24 +3154,26 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n | ... | @@ -3146,24 +3154,26 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 3146 | size_type __sz = size(); | 3154 | size_type __sz = size(); |
| 3147 | if (__pos > __sz) | 3155 | if (__pos > __sz) |
| 3148 | this->__throw_out_of_range(); | 3156 | this->__throw_out_of_range(); |
| 3149 | if (__n) { | 3157 | |
| 3150 | size_type __cap = capacity(); | 3158 | if (__n == 0) |
| 3151 | value_type* __p; | 3159 | return *this; |
| 3152 | if (__cap - __sz >= __n) { | 3160 | |
| 3153 | __annotate_increase(__n); | 3161 | size_type __cap = capacity(); |
| 3154 | __p = std::__to_address(__get_pointer()); | 3162 | value_type* __p; |
| 3155 | size_type __n_move = __sz - __pos; | 3163 | if (__cap - __sz >= __n) { |
| 3156 | if (__n_move != 0) | 3164 | __annotate_increase(__n); |
| 3157 | traits_type::move(__p + __pos + __n, __p + __pos, __n_move); | 3165 | __p = std::__to_address(__get_pointer()); |
| 3158 | } else { | 3166 | size_type __n_move = __sz - __pos; |
| 3159 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); | 3167 | if (__n_move != 0) |
| 3160 | __p = std::__to_address(__get_long_pointer()); | 3168 | traits_type::move(__p + __pos + __n, __p + __pos, __n_move); |
| 3161 | } | 3169 | } else { |
| 3162 | traits_type::assign(__p + __pos, __n, __c); | 3170 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); |
| 3163 | __sz += __n; | 3171 | __p = std::__to_address(__get_long_pointer()); |
| 3164 | __set_size(__sz); | ||
| 3165 | traits_type::assign(__p[__sz], value_type()); | ||
| 3166 | } | 3172 | } |
| 3173 | traits_type::assign(__p + __pos, __n, __c); | ||
| 3174 | __sz += __n; | ||
| 3175 | __set_size(__sz); | ||
| 3176 | traits_type::assign(__p[__sz], value_type()); | ||
| 3167 | return *this; | 3177 | return *this; |
| 3168 | } | 3178 | } |
| 3169 | 3179 | ||
| ... | @@ -3176,7 +3186,7 @@ basic_string<_CharT, _Traits, _Allocator>::__insert_with_size( | ... | @@ -3176,7 +3186,7 @@ basic_string<_CharT, _Traits, _Allocator>::__insert_with_size( |
| 3176 | if (__n == 0) | 3186 | if (__n == 0) |
| 3177 | return begin() + __ip; | 3187 | return begin() + __ip; |
| 3178 | 3188 | ||
| 3179 | if (__string_is_trivial_iterator<_Iterator>::value && !__addr_in_range(*__first)) { | 3189 | if (__string_is_trivial_iterator_v<_Iterator> && !__addr_in_range(*__first)) { |
| 3180 | return __insert_from_safe_copy(__n, __ip, std::move(__first), std::move(__last)); | 3190 | return __insert_from_safe_copy(__n, __ip, std::move(__first), std::move(__last)); |
| 3181 | } else { | 3191 | } else { |
| 3182 | const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_); | 3192 | const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_); |
| ... | @@ -3237,38 +3247,38 @@ basic_string<_CharT, _Traits, _Allocator>::replace( | ... | @@ -3237,38 +3247,38 @@ basic_string<_CharT, _Traits, _Allocator>::replace( |
| 3237 | this->__throw_out_of_range(); | 3247 | this->__throw_out_of_range(); |
| 3238 | __n1 = std::min(__n1, __sz - __pos); | 3248 | __n1 = std::min(__n1, __sz - __pos); |
| 3239 | size_type __cap = capacity(); | 3249 | size_type __cap = capacity(); |
| 3240 | if (__cap - __sz + __n1 >= __n2) { | 3250 | if (__cap - __sz + __n1 < __n2) { |
| 3241 | value_type* __p = std::__to_address(__get_pointer()); | 3251 | __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); |
| 3242 | if (__n1 != __n2) { | 3252 | return *this; |
| 3243 | if (__n2 > __n1) | 3253 | } |
| 3244 | __annotate_increase(__n2 - __n1); | 3254 | |
| 3245 | size_type __n_move = __sz - __pos - __n1; | 3255 | value_type* __p = std::__to_address(__get_pointer()); |
| 3246 | if (__n_move != 0) { | 3256 | if (__n1 != __n2) { |
| 3247 | if (__n1 > __n2) { | 3257 | if (__n2 > __n1) |
| 3248 | traits_type::move(__p + __pos, __s, __n2); | 3258 | __annotate_increase(__n2 - __n1); |
| 3249 | traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); | 3259 | size_type __n_move = __sz - __pos - __n1; |
| 3250 | return __null_terminate_at(__p, __sz + (__n2 - __n1)); | 3260 | if (__n_move != 0) { |
| 3251 | } | 3261 | if (__n1 > __n2) { |
| 3252 | if (std::__is_pointer_in_range(__p + __pos + 1, __p + __sz, __s)) { | 3262 | traits_type::move(__p + __pos, __s, __n2); |
| 3253 | if (__p + __pos + __n1 <= __s) | ||
| 3254 | __s += __n2 - __n1; | ||
| 3255 | else // __p + __pos < __s < __p + __pos + __n1 | ||
| 3256 | { | ||
| 3257 | traits_type::move(__p + __pos, __s, __n1); | ||
| 3258 | __pos += __n1; | ||
| 3259 | __s += __n2; | ||
| 3260 | __n2 -= __n1; | ||
| 3261 | __n1 = 0; | ||
| 3262 | } | ||
| 3263 | } | ||
| 3264 | traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); | 3263 | traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); |
| 3264 | return __null_terminate_at(__p, __sz + (__n2 - __n1)); | ||
| 3265 | } | ||
| 3266 | if (std::__is_pointer_in_range(__p + __pos + 1, __p + __sz, __s)) { | ||
| 3267 | if (__p + __pos + __n1 <= __s) { | ||
| 3268 | __s += __n2 - __n1; | ||
| 3269 | } else { // __p + __pos < __s < __p + __pos + __n1 | ||
| 3270 | traits_type::move(__p + __pos, __s, __n1); | ||
| 3271 | __pos += __n1; | ||
| 3272 | __s += __n2; | ||
| 3273 | __n2 -= __n1; | ||
| 3274 | __n1 = 0; | ||
| 3275 | } | ||
| 3265 | } | 3276 | } |
| 3277 | traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); | ||
| 3266 | } | 3278 | } |
| 3267 | traits_type::move(__p + __pos, __s, __n2); | 3279 | } |
| 3268 | return __null_terminate_at(__p, __sz + (__n2 - __n1)); | 3280 | traits_type::move(__p + __pos, __s, __n2); |
| 3269 | } else | 3281 | return __null_terminate_at(__p, __sz + (__n2 - __n1)); |
| 3270 | __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); | ||
| 3271 | return *this; | ||
| 3272 | } | 3282 | } |
| 3273 | 3283 | ||
| 3274 | template <class _CharT, class _Traits, class _Allocator> | 3284 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3320,16 +3330,17 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ | ... | @@ -3320,16 +3330,17 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3320 | // Does not check __pos against size() | 3330 | // Does not check __pos against size() |
| 3321 | template <class _CharT, class _Traits, class _Allocator> | 3331 | template <class _CharT, class _Traits, class _Allocator> |
| 3322 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void | 3332 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void |
| 3323 | basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(size_type __pos, size_type __n) { | 3333 | basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(size_type __pos, size_type __n) _NOEXCEPT { |
| 3324 | if (__n) { | 3334 | if (__n == 0) |
| 3325 | size_type __sz = size(); | 3335 | return; |
| 3326 | value_type* __p = std::__to_address(__get_pointer()); | 3336 | |
| 3327 | __n = std::min(__n, __sz - __pos); | 3337 | size_type __sz = size(); |
| 3328 | size_type __n_move = __sz - __pos - __n; | 3338 | value_type* __p = std::__to_address(__get_pointer()); |
| 3329 | if (__n_move != 0) | 3339 | __n = std::min(__n, __sz - __pos); |
| 3330 | traits_type::move(__p + __pos, __p + __pos + __n, __n_move); | 3340 | size_type __n_move = __sz - __pos - __n; |
| 3331 | __null_terminate_at(__p, __sz - __n); | 3341 | if (__n_move != 0) |
| 3332 | } | 3342 | traits_type::move(__p + __pos, __p + __pos + __n, __n_move); |
| 3343 | __null_terminate_at(__p, __sz - __n); | ||
| 3333 | } | 3344 | } |
| 3334 | 3345 | ||
| 3335 | template <class _CharT, class _Traits, class _Allocator> | 3346 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3396,16 +3407,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re | ... | @@ -3396,16 +3407,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re |
| 3396 | __erase_to_end(__n); | 3407 | __erase_to_end(__n); |
| 3397 | } | 3408 | } |
| 3398 | 3409 | ||
| 3399 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3400 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void | ||
| 3401 | basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) { | ||
| 3402 | size_type __sz = size(); | ||
| 3403 | if (__n > __sz) { | ||
| 3404 | __append_default_init(__n - __sz); | ||
| 3405 | } else | ||
| 3406 | __erase_to_end(__n); | ||
| 3407 | } | ||
| 3408 | |||
| 3409 | template <class _CharT, class _Traits, class _Allocator> | 3410 | template <class _CharT, class _Traits, class _Allocator> |
| 3410 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) { | 3411 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) { |
| 3411 | if (__requested_capacity > max_size()) | 3412 | if (__requested_capacity > max_size()) |
| ... | @@ -3418,31 +3419,23 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re | ... | @@ -3418,31 +3419,23 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re |
| 3418 | return; | 3419 | return; |
| 3419 | 3420 | ||
| 3420 | __annotation_guard __g(*this); | 3421 | __annotation_guard __g(*this); |
| 3421 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__requested_capacity) + 1); | 3422 | __long __buffer = __allocate_long_buffer(__alloc_, __requested_capacity); |
| 3422 | auto __size = size(); | 3423 | __buffer.__size_ = size(); |
| 3423 | __begin_lifetime(__allocation.ptr, __allocation.count); | 3424 | traits_type::copy(std::__to_address(__buffer.__data_), data(), __buffer.__size_ + 1); |
| 3424 | traits_type::copy(std::__to_address(__allocation.ptr), data(), __size + 1); | 3425 | __reset_internal_buffer(__buffer); |
| 3425 | if (__is_long()) | ||
| 3426 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 3427 | __set_long_cap(__allocation.count); | ||
| 3428 | __set_long_size(__size); | ||
| 3429 | __set_long_pointer(__allocation.ptr); | ||
| 3430 | } | 3426 | } |
| 3431 | 3427 | ||
| 3432 | template <class _CharT, class _Traits, class _Allocator> | 3428 | template <class _CharT, class _Traits, class _Allocator> |
| 3433 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT { | 3429 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT { |
| 3434 | size_type __target_capacity = __recommend(size()); | 3430 | if (!__is_long()) |
| 3435 | if (__target_capacity == capacity()) | ||
| 3436 | return; | 3431 | return; |
| 3437 | 3432 | ||
| 3438 | _LIBCPP_ASSERT_INTERNAL(__is_long(), "Trying to shrink small string"); | ||
| 3439 | |||
| 3440 | // We're a long string and we're shrinking into the small buffer. | ||
| 3441 | const auto __ptr = __get_long_pointer(); | 3433 | const auto __ptr = __get_long_pointer(); |
| 3442 | const auto __size = __get_long_size(); | 3434 | const auto __size = __get_long_size(); |
| 3443 | const auto __cap = __get_long_cap(); | 3435 | const auto __cap = __get_long_cap(); |
| 3444 | 3436 | ||
| 3445 | if (__fits_in_sso(__target_capacity)) { | 3437 | // We're a long string and we're shrinking into the small buffer. |
| 3438 | if (__fits_in_sso(__size)) { | ||
| 3446 | __annotation_guard __g(*this); | 3439 | __annotation_guard __g(*this); |
| 3447 | __set_short_size(__size); | 3440 | __set_short_size(__size); |
| 3448 | traits_type::copy(std::__to_address(__get_short_pointer()), std::__to_address(__ptr), __size + 1); | 3441 | traits_type::copy(std::__to_address(__get_short_pointer()), std::__to_address(__ptr), __size + 1); |
| ... | @@ -3450,25 +3443,25 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat | ... | @@ -3450,25 +3443,25 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat |
| 3450 | return; | 3443 | return; |
| 3451 | } | 3444 | } |
| 3452 | 3445 | ||
| 3446 | if (__align_allocation_size(__size) == __cap) | ||
| 3447 | return; | ||
| 3448 | |||
| 3453 | # if _LIBCPP_HAS_EXCEPTIONS | 3449 | # if _LIBCPP_HAS_EXCEPTIONS |
| 3454 | try { | 3450 | try { |
| 3455 | # endif // _LIBCPP_HAS_EXCEPTIONS | 3451 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 3456 | __annotation_guard __g(*this); | 3452 | __annotation_guard __g(*this); |
| 3457 | auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); | 3453 | __long __buffer = __allocate_long_buffer(__alloc_, __size); |
| 3458 | 3454 | ||
| 3459 | // The Standard mandates shrink_to_fit() does not increase the capacity. | 3455 | // The Standard mandates shrink_to_fit() does not increase the capacity. |
| 3460 | // With equal capacity keep the existing buffer. This avoids extra work | 3456 | // With equal capacity keep the existing buffer. This avoids extra work |
| 3461 | // due to swapping the elements. | 3457 | // due to swapping the elements. |
| 3462 | if (__allocation.count - 1 >= capacity()) { | 3458 | if (__buffer.__cap_ * __endian_factor - 1 >= capacity()) { |
| 3463 | __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count); | 3459 | __alloc_traits::deallocate(__alloc_, __buffer.__data_, __buffer.__cap_ * __endian_factor); |
| 3464 | return; | 3460 | return; |
| 3465 | } | 3461 | } |
| 3466 | 3462 | ||
| 3467 | __begin_lifetime(__allocation.ptr, __allocation.count); | 3463 | traits_type::copy(std::__to_address(__buffer.__data_), std::__to_address(__get_long_pointer()), __size + 1); |
| 3468 | traits_type::copy(std::__to_address(__allocation.ptr), std::__to_address(__ptr), __size + 1); | 3464 | __reset_internal_buffer(__buffer); |
| 3469 | __alloc_traits::deallocate(__alloc_, __ptr, __cap); | ||
| 3470 | __set_long_cap(__allocation.count); | ||
| 3471 | __set_long_pointer(__allocation.ptr); | ||
| 3472 | # if _LIBCPP_HAS_EXCEPTIONS | 3465 | # if _LIBCPP_HAS_EXCEPTIONS |
| 3473 | } catch (...) { | 3466 | } catch (...) { |
| 3474 | return; | 3467 | return; |
| ... | @@ -3574,7 +3567,8 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | ... | @@ -3574,7 +3567,8 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 3574 | 3567 | ||
| 3575 | template <class _CharT, class _Traits, class _Allocator> | 3568 | template <class _CharT, class _Traits, class _Allocator> |
| 3576 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool | 3569 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool |
| 3577 | operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { | 3570 | operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 3571 | const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __rhs) _NOEXCEPT { | ||
| 3578 | _LIBCPP_ASSERT_NON_NULL(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); | 3572 | _LIBCPP_ASSERT_NON_NULL(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); |
| 3579 | 3573 | ||
| 3580 | using _String = basic_string<_CharT, _Traits, _Allocator>; | 3574 | using _String = basic_string<_CharT, _Traits, _Allocator>; |
| ... | @@ -3858,46 +3852,52 @@ swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Tra | ... | @@ -3858,46 +3852,52 @@ swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Tra |
| 3858 | __lhs.swap(__rhs); | 3852 | __lhs.swap(__rhs); |
| 3859 | } | 3853 | } |
| 3860 | 3854 | ||
| 3861 | _LIBCPP_EXPORTED_FROM_ABI int stoi(const string& __str, size_t* __idx = nullptr, int __base = 10); | 3855 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI int stoi(const string& __str, size_t* __idx = nullptr, int __base = 10); |
| 3862 | _LIBCPP_EXPORTED_FROM_ABI long stol(const string& __str, size_t* __idx = nullptr, int __base = 10); | 3856 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI unsigned long |
| 3863 | _LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const string& __str, size_t* __idx = nullptr, int __base = 10); | 3857 | stoul(const string& __str, size_t* __idx = nullptr, int __base = 10); |
| 3864 | _LIBCPP_EXPORTED_FROM_ABI long long stoll(const string& __str, size_t* __idx = nullptr, int __base = 10); | 3858 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI long stol(const string& __str, size_t* __idx = nullptr, int __base = 10); |
| 3865 | _LIBCPP_EXPORTED_FROM_ABI unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10); | 3859 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI long long |
| 3866 | 3860 | stoll(const string& __str, size_t* __idx = nullptr, int __base = 10); | |
| 3867 | _LIBCPP_EXPORTED_FROM_ABI float stof(const string& __str, size_t* __idx = nullptr); | 3861 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI unsigned long long |
| 3868 | _LIBCPP_EXPORTED_FROM_ABI double stod(const string& __str, size_t* __idx = nullptr); | 3862 | stoull(const string& __str, size_t* __idx = nullptr, int __base = 10); |
| 3869 | _LIBCPP_EXPORTED_FROM_ABI long double stold(const string& __str, size_t* __idx = nullptr); | 3863 | |
| 3870 | 3864 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI float stof(const string& __str, size_t* __idx = nullptr); | |
| 3871 | _LIBCPP_EXPORTED_FROM_ABI string to_string(int __val); | 3865 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI double stod(const string& __str, size_t* __idx = nullptr); |
| 3872 | _LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned __val); | 3866 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI long double stold(const string& __str, size_t* __idx = nullptr); |
| 3873 | _LIBCPP_EXPORTED_FROM_ABI string to_string(long __val); | 3867 | |
| 3874 | _LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long __val); | 3868 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(int __val); |
| 3875 | _LIBCPP_EXPORTED_FROM_ABI string to_string(long long __val); | 3869 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned __val); |
| 3876 | _LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long long __val); | 3870 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(long __val); |
| 3877 | _LIBCPP_EXPORTED_FROM_ABI string to_string(float __val); | 3871 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long __val); |
| 3878 | _LIBCPP_EXPORTED_FROM_ABI string to_string(double __val); | 3872 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(long long __val); |
| 3879 | _LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val); | 3873 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(unsigned long long __val); |
| 3874 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(float __val); | ||
| 3875 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(double __val); | ||
| 3876 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val); | ||
| 3880 | 3877 | ||
| 3881 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 3878 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 3882 | _LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10); | 3879 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 3883 | _LIBCPP_EXPORTED_FROM_ABI long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10); | 3880 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 3884 | _LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10); | 3881 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI unsigned long |
| 3885 | _LIBCPP_EXPORTED_FROM_ABI long long stoll(const wstring& __str, size_t* __idx = nullptr, int __base = 10); | 3882 | stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 3886 | _LIBCPP_EXPORTED_FROM_ABI unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10); | 3883 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI long long |
| 3887 | 3884 | stoll(const wstring& __str, size_t* __idx = nullptr, int __base = 10); | |
| 3888 | _LIBCPP_EXPORTED_FROM_ABI float stof(const wstring& __str, size_t* __idx = nullptr); | 3885 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI unsigned long long |
| 3889 | _LIBCPP_EXPORTED_FROM_ABI double stod(const wstring& __str, size_t* __idx = nullptr); | 3886 | stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 3890 | _LIBCPP_EXPORTED_FROM_ABI long double stold(const wstring& __str, size_t* __idx = nullptr); | 3887 | |
| 3891 | 3888 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI float stof(const wstring& __str, size_t* __idx = nullptr); | |
| 3892 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(int __val); | 3889 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI double stod(const wstring& __str, size_t* __idx = nullptr); |
| 3893 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned __val); | 3890 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI long double stold(const wstring& __str, size_t* __idx = nullptr); |
| 3894 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long __val); | 3891 | |
| 3895 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long __val); | 3892 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(int __val); |
| 3896 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long long __val); | 3893 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned __val); |
| 3897 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val); | 3894 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long __val); |
| 3898 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val); | 3895 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long __val); |
| 3899 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val); | 3896 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long long __val); |
| 3900 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val); | 3897 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val); |
| 3898 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val); | ||
| 3899 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val); | ||
| 3900 | [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val); | ||
| 3901 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 3901 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 3902 | 3902 | ||
| 3903 | template <class _CharT, class _Traits, class _Allocator> | 3903 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3906,7 +3906,7 @@ _LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocato | ... | @@ -3906,7 +3906,7 @@ _LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocato |
| 3906 | 3906 | ||
| 3907 | template <class _CharT, class _Allocator> | 3907 | template <class _CharT, class _Allocator> |
| 3908 | struct __string_hash : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> { | 3908 | struct __string_hash : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> { |
| 3909 | _LIBCPP_HIDE_FROM_ABI size_t | 3909 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t |
| 3910 | operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT { | 3910 | operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT { |
| 3911 | return std::__do_string_hash(__val.data(), __val.data() + __val.size()); | 3911 | return std::__do_string_hash(__val.data(), __val.data() + __val.size()); |
| 3912 | } | 3912 | } |
| ... | @@ -3977,30 +3977,31 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { | ... | @@ -3977,30 +3977,31 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { |
| 3977 | // Literal suffixes for basic_string [basic.string.literals] | 3977 | // Literal suffixes for basic_string [basic.string.literals] |
| 3978 | inline namespace literals { | 3978 | inline namespace literals { |
| 3979 | inline namespace string_literals { | 3979 | inline namespace string_literals { |
| 3980 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char> | 3980 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char> |
| 3981 | operator""s(const char* __str, size_t __len) { | 3981 | operator""s(const char* __str, size_t __len) { |
| 3982 | return basic_string<char>(__str, __len); | 3982 | return basic_string<char>(__str, __len); |
| 3983 | } | 3983 | } |
| 3984 | 3984 | ||
| 3985 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 3985 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 3986 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<wchar_t> | 3986 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 3987 | operator""s(const wchar_t* __str, size_t __len) { | 3987 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<wchar_t> operator""s(const wchar_t* __str, size_t __len) { |
| 3988 | return basic_string<wchar_t>(__str, __len); | 3988 | return basic_string<wchar_t>(__str, __len); |
| 3989 | } | 3989 | } |
| 3990 | # endif | 3990 | # endif |
| 3991 | 3991 | ||
| 3992 | # if _LIBCPP_HAS_CHAR8_T | 3992 | # if _LIBCPP_HAS_CHAR8_T |
| 3993 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string<char8_t> operator""s(const char8_t* __str, size_t __len) { | 3993 | [[__nodiscard__]] inline |
| 3994 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<char8_t> operator""s(const char8_t* __str, size_t __len) { | ||
| 3994 | return basic_string<char8_t>(__str, __len); | 3995 | return basic_string<char8_t>(__str, __len); |
| 3995 | } | 3996 | } |
| 3996 | # endif | 3997 | # endif |
| 3997 | 3998 | ||
| 3998 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char16_t> | 3999 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 3999 | operator""s(const char16_t* __str, size_t __len) { | 4000 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char16_t> operator""s(const char16_t* __str, size_t __len) { |
| 4000 | return basic_string<char16_t>(__str, __len); | 4001 | return basic_string<char16_t>(__str, __len); |
| 4001 | } | 4002 | } |
| 4002 | 4003 | ||
| 4003 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char32_t> | 4004 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char32_t> |
| 4004 | operator""s(const char32_t* __str, size_t __len) { | 4005 | operator""s(const char32_t* __str, size_t __len) { |
| 4005 | return basic_string<char32_t>(__str, __len); | 4006 | return basic_string<char32_t>(__str, __len); |
| 4006 | } | 4007 | } |
lib/libcxx/include/string_view+113-89| ... | @@ -130,6 +130,8 @@ namespace std { | ... | @@ -130,6 +130,8 @@ namespace std { |
| 130 | size_type copy(charT* s, size_type n, size_type pos = 0) const; // constexpr in C++20 | 130 | size_type copy(charT* s, size_type n, size_type pos = 0) const; // constexpr in C++20 |
| 131 | 131 | ||
| 132 | constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; | 132 | constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; |
| 133 | constexpr basic_string_view subview(size_type pos = 0, | ||
| 134 | size_type n = npos) const; // freestanding-deleted, since C++26 | ||
| 133 | constexpr int compare(basic_string_view s) const noexcept; | 135 | constexpr int compare(basic_string_view s) const noexcept; |
| 134 | constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; | 136 | constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; |
| 135 | constexpr int compare(size_type pos1, size_type n1, | 137 | constexpr int compare(size_type pos1, size_type n1, |
| ... | @@ -318,9 +320,9 @@ public: | ... | @@ -318,9 +320,9 @@ public: |
| 318 | _LIBCPP_HIDE_FROM_ABI basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; | 320 | _LIBCPP_HIDE_FROM_ABI basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; |
| 319 | 321 | ||
| 320 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT | 322 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT |
| 321 | : __data_(__s), | 323 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__len != 0 && __s == nullptr, " if len is not zero") |
| 322 | __size_(__len) { | 324 | : __data_(__s), __size_(__len) { |
| 323 | # if _LIBCPP_STD_VER >= 14 | 325 | # if !defined(_LIBCPP_CXX03_LANG) && (!defined(_LIBCPP_COMPILER_GCC) || _LIBCPP_STD_VER >= 14) |
| 324 | // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input | 326 | // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input |
| 325 | // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently | 327 | // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently |
| 326 | // passed in a negative length. | 328 | // passed in a negative length. |
| ... | @@ -352,7 +354,7 @@ public: | ... | @@ -352,7 +354,7 @@ public: |
| 352 | : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {} | 354 | : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {} |
| 353 | # endif // _LIBCPP_STD_VER >= 23 | 355 | # endif // _LIBCPP_STD_VER >= 23 |
| 354 | 356 | ||
| 355 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s) | 357 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) |
| 356 | : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {} | 358 | : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {} |
| 357 | 359 | ||
| 358 | # if _LIBCPP_STD_VER >= 23 | 360 | # if _LIBCPP_STD_VER >= 23 |
| ... | @@ -360,11 +362,11 @@ public: | ... | @@ -360,11 +362,11 @@ public: |
| 360 | # endif | 362 | # endif |
| 361 | 363 | ||
| 362 | // [string.view.iterators], iterators | 364 | // [string.view.iterators], iterators |
| 363 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); } | 365 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); } |
| 364 | 366 | ||
| 365 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); } | 367 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); } |
| 366 | 368 | ||
| 367 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { | 369 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { |
| 368 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 370 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 369 | return std::__make_bounded_iter(data(), data(), data() + size()); | 371 | return std::__make_bounded_iter(data(), data(), data() + size()); |
| 370 | # else | 372 | # else |
| ... | @@ -372,7 +374,7 @@ public: | ... | @@ -372,7 +374,7 @@ public: |
| 372 | # endif | 374 | # endif |
| 373 | } | 375 | } |
| 374 | 376 | ||
| 375 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { | 377 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { |
| 376 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | 378 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS |
| 377 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); | 379 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); |
| 378 | # else | 380 | # else |
| ... | @@ -380,51 +382,54 @@ public: | ... | @@ -380,51 +382,54 @@ public: |
| 380 | # endif | 382 | # endif |
| 381 | } | 383 | } |
| 382 | 384 | ||
| 383 | _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { | 385 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator |
| 386 | rbegin() const _NOEXCEPT { | ||
| 384 | return const_reverse_iterator(cend()); | 387 | return const_reverse_iterator(cend()); |
| 385 | } | 388 | } |
| 386 | 389 | ||
| 387 | _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | 390 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { |
| 388 | return const_reverse_iterator(cbegin()); | 391 | return const_reverse_iterator(cbegin()); |
| 389 | } | 392 | } |
| 390 | 393 | ||
| 391 | _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { | 394 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator |
| 395 | crbegin() const _NOEXCEPT { | ||
| 392 | return const_reverse_iterator(cend()); | 396 | return const_reverse_iterator(cend()); |
| 393 | } | 397 | } |
| 394 | 398 | ||
| 395 | _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { | 399 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { |
| 396 | return const_reverse_iterator(cbegin()); | 400 | return const_reverse_iterator(cbegin()); |
| 397 | } | 401 | } |
| 398 | 402 | ||
| 399 | // [string.view.capacity], capacity | 403 | // [string.view.capacity], capacity |
| 400 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } | 404 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } |
| 401 | 405 | ||
| 402 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type length() const _NOEXCEPT { return __size_; } | 406 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type length() const _NOEXCEPT { return __size_; } |
| 403 | 407 | ||
| 404 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 408 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 405 | return numeric_limits<size_type>::max() / sizeof(value_type); | 409 | return numeric_limits<size_type>::max() / sizeof(value_type); |
| 406 | } | 410 | } |
| 407 | 411 | ||
| 408 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; } | 412 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; } |
| 409 | 413 | ||
| 410 | // [string.view.access], element access | 414 | // [string.view.access], element access |
| 411 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT { | 415 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference |
| 416 | operator[](size_type __pos) const _NOEXCEPT { | ||
| 412 | return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos < size(), "string_view[] index out of bounds"), __data_[__pos]; | 417 | return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos < size(), "string_view[] index out of bounds"), __data_[__pos]; |
| 413 | } | 418 | } |
| 414 | 419 | ||
| 415 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __pos) const { | 420 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __pos) const { |
| 416 | return __pos >= size() ? (__throw_out_of_range("string_view::at"), __data_[0]) : __data_[__pos]; | 421 | return __pos >= size() ? (__throw_out_of_range("string_view::at"), __data_[0]) : __data_[__pos]; |
| 417 | } | 422 | } |
| 418 | 423 | ||
| 419 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { | 424 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { |
| 420 | return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::front(): string is empty"), __data_[0]; | 425 | return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::front(): string is empty"), __data_[0]; |
| 421 | } | 426 | } |
| 422 | 427 | ||
| 423 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { | 428 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { |
| 424 | return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::back(): string is empty"), __data_[__size_ - 1]; | 429 | return _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "string_view::back(): string is empty"), __data_[__size_ - 1]; |
| 425 | } | 430 | } |
| 426 | 431 | ||
| 427 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_pointer data() const _NOEXCEPT { return __data_; } | 432 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_pointer data() const _NOEXCEPT { return __data_; } |
| 428 | 433 | ||
| 429 | // [string.view.modifiers], modifiers: | 434 | // [string.view.modifiers], modifiers: |
| 430 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void remove_prefix(size_type __n) _NOEXCEPT { | 435 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI void remove_prefix(size_type __n) _NOEXCEPT { |
| ... | @@ -457,15 +462,23 @@ public: | ... | @@ -457,15 +462,23 @@ public: |
| 457 | return __rlen; | 462 | return __rlen; |
| 458 | } | 463 | } |
| 459 | 464 | ||
| 460 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const { | 465 | [[__nodiscard__]] _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view |
| 466 | substr(size_type __pos = 0, size_type __n = npos) const { | ||
| 461 | // Use the `__assume_valid` form of the constructor to avoid an unnecessary check. Any substring of a view is a | 467 | // Use the `__assume_valid` form of the constructor to avoid an unnecessary check. Any substring of a view is a |
| 462 | // valid view. In particular, `size()` is known to be smaller than `numeric_limits<difference_type>::max()`, so the | 468 | // valid view. In particular, `size()` is known to be smaller than `numeric_limits<difference_type>::max()`, so the |
| 463 | // new size is also smaller. See also https://github.com/llvm/llvm-project/issues/91634. | 469 | // new size is also smaller. See also https://llvm.org/PR91634. |
| 464 | return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view()) | 470 | return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view()) |
| 465 | : basic_string_view(__assume_valid(), data() + __pos, std::min(__n, size() - __pos)); | 471 | : basic_string_view(__assume_valid(), data() + __pos, std::min(__n, size() - __pos)); |
| 466 | } | 472 | } |
| 467 | 473 | ||
| 468 | _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT { | 474 | # if _LIBCPP_STD_VER >= 26 |
| 475 | [[nodiscard]] | ||
| 476 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view subview(size_type __pos = 0, size_type __n = npos) const { | ||
| 477 | return substr(__pos, __n); | ||
| 478 | } | ||
| 479 | # endif | ||
| 480 | |||
| 481 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT { | ||
| 469 | size_type __rlen = std::min(size(), __sv.size()); | 482 | size_type __rlen = std::min(size(), __sv.size()); |
| 470 | int __retval = _Traits::compare(data(), __sv.data(), __rlen); | 483 | int __retval = _Traits::compare(data(), __sv.data(), __rlen); |
| 471 | if (__retval == 0) // first __rlen chars matched | 484 | if (__retval == 0) // first __rlen chars matched |
| ... | @@ -473,217 +486,226 @@ public: | ... | @@ -473,217 +486,226 @@ public: |
| 473 | return __retval; | 486 | return __retval; |
| 474 | } | 487 | } |
| 475 | 488 | ||
| 476 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int | 489 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int |
| 477 | compare(size_type __pos1, size_type __n1, basic_string_view __sv) const { | 490 | compare(size_type __pos1, size_type __n1, basic_string_view __sv) const { |
| 478 | return substr(__pos1, __n1).compare(__sv); | 491 | return substr(__pos1, __n1).compare(__sv); |
| 479 | } | 492 | } |
| 480 | 493 | ||
| 481 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int | 494 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int |
| 482 | compare(size_type __pos1, size_type __n1, basic_string_view __sv, size_type __pos2, size_type __n2) const { | 495 | compare(size_type __pos1, size_type __n1, basic_string_view __sv, size_type __pos2, size_type __n2) const { |
| 483 | return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); | 496 | return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); |
| 484 | } | 497 | } |
| 485 | 498 | ||
| 486 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int compare(const _CharT* __s) const _NOEXCEPT { | 499 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int |
| 500 | compare(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) const _NOEXCEPT { | ||
| 487 | return compare(basic_string_view(__s)); | 501 | return compare(basic_string_view(__s)); |
| 488 | } | 502 | } |
| 489 | 503 | ||
| 490 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int | 504 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int |
| 491 | compare(size_type __pos1, size_type __n1, const _CharT* __s) const { | 505 | compare(size_type __pos1, size_type __n1, const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) const { |
| 492 | return substr(__pos1, __n1).compare(basic_string_view(__s)); | 506 | return substr(__pos1, __n1).compare(basic_string_view(__s)); |
| 493 | } | 507 | } |
| 494 | 508 | ||
| 495 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int | 509 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI int |
| 496 | compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const { | 510 | compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const |
| 511 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n2 != 0 && __s == nullptr, " if n2 is not zero") { | ||
| 497 | return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); | 512 | return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); |
| 498 | } | 513 | } |
| 499 | 514 | ||
| 500 | // find | 515 | // find |
| 501 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 516 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 502 | find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { | 517 | find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { |
| 503 | _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); | ||
| 504 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size()); | 518 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size()); |
| 505 | } | 519 | } |
| 506 | 520 | ||
| 507 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT { | 521 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 522 | find(_CharT __c, size_type __pos = 0) const _NOEXCEPT { | ||
| 508 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 523 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 509 | } | 524 | } |
| 510 | 525 | ||
| 511 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 526 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 512 | find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 527 | find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 528 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 513 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find(): received nullptr"); | 529 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find(): received nullptr"); |
| 514 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 530 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 515 | } | 531 | } |
| 516 | 532 | ||
| 517 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 533 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 518 | find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT { | 534 | find(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 519 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find(): received nullptr"); | 535 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find(): received nullptr"); |
| 520 | return std::__str_find<value_type, size_type, traits_type, npos>( | 536 | return std::__str_find<value_type, size_type, traits_type, npos>( |
| 521 | data(), size(), __s, __pos, traits_type::length(__s)); | 537 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 522 | } | 538 | } |
| 523 | 539 | ||
| 524 | // rfind | 540 | // rfind |
| 525 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 541 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 526 | rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { | 542 | rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { |
| 527 | _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); | ||
| 528 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size()); | 543 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s.data(), __pos, __s.size()); |
| 529 | } | 544 | } |
| 530 | 545 | ||
| 531 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 546 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 532 | rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT { | 547 | rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT { |
| 533 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 548 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 534 | } | 549 | } |
| 535 | 550 | ||
| 536 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 551 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 537 | rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 552 | rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 553 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 538 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr"); | 554 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr"); |
| 539 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 555 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 540 | } | 556 | } |
| 541 | 557 | ||
| 542 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 558 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 543 | rfind(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT { | 559 | rfind(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 544 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::rfind(): received nullptr"); | 560 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::rfind(): received nullptr"); |
| 545 | return std::__str_rfind<value_type, size_type, traits_type, npos>( | 561 | return std::__str_rfind<value_type, size_type, traits_type, npos>( |
| 546 | data(), size(), __s, __pos, traits_type::length(__s)); | 562 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 547 | } | 563 | } |
| 548 | 564 | ||
| 549 | // find_first_of | 565 | // find_first_of |
| 550 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 566 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 551 | find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { | 567 | find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { |
| 552 | _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr"); | ||
| 553 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | 568 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( |
| 554 | data(), size(), __s.data(), __pos, __s.size()); | 569 | data(), size(), __s.data(), __pos, __s.size()); |
| 555 | } | 570 | } |
| 556 | 571 | ||
| 557 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 572 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 558 | find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT { | 573 | find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT { |
| 559 | return find(__c, __pos); | 574 | return find(__c, __pos); |
| 560 | } | 575 | } |
| 561 | 576 | ||
| 562 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 577 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 563 | find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 578 | find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 579 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 564 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr"); | 580 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr"); |
| 565 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 581 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 566 | } | 582 | } |
| 567 | 583 | ||
| 568 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 584 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 569 | find_first_of(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT { | 585 | find_first_of(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 570 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_of(): received nullptr"); | 586 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_of(): received nullptr"); |
| 571 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | 587 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( |
| 572 | data(), size(), __s, __pos, traits_type::length(__s)); | 588 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 573 | } | 589 | } |
| 574 | 590 | ||
| 575 | // find_last_of | 591 | // find_last_of |
| 576 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 592 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 577 | find_last_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { | 593 | find_last_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { |
| 578 | _LIBCPP_ASSERT_NON_NULL(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr"); | ||
| 579 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | 594 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( |
| 580 | data(), size(), __s.data(), __pos, __s.size()); | 595 | data(), size(), __s.data(), __pos, __s.size()); |
| 581 | } | 596 | } |
| 582 | 597 | ||
| 583 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 598 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 584 | find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT { | 599 | find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT { |
| 585 | return rfind(__c, __pos); | 600 | return rfind(__c, __pos); |
| 586 | } | 601 | } |
| 587 | 602 | ||
| 588 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 603 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 589 | find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 604 | find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 605 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 590 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr"); | 606 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr"); |
| 591 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 607 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 592 | } | 608 | } |
| 593 | 609 | ||
| 594 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 610 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 595 | find_last_of(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT { | 611 | find_last_of(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 596 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_of(): received nullptr"); | 612 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_of(): received nullptr"); |
| 597 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | 613 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( |
| 598 | data(), size(), __s, __pos, traits_type::length(__s)); | 614 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 599 | } | 615 | } |
| 600 | 616 | ||
| 601 | // find_first_not_of | 617 | // find_first_not_of |
| 602 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 618 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 603 | find_first_not_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { | 619 | find_first_not_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { |
| 604 | _LIBCPP_ASSERT_NON_NULL( | ||
| 605 | __s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr"); | ||
| 606 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | 620 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( |
| 607 | data(), size(), __s.data(), __pos, __s.size()); | 621 | data(), size(), __s.data(), __pos, __s.size()); |
| 608 | } | 622 | } |
| 609 | 623 | ||
| 610 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 624 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 611 | find_first_not_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT { | 625 | find_first_not_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT { |
| 612 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 626 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 613 | } | 627 | } |
| 614 | 628 | ||
| 615 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 629 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 616 | find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 630 | find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 631 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 617 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr"); | 632 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr"); |
| 618 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 633 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 619 | } | 634 | } |
| 620 | 635 | ||
| 621 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 636 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 622 | find_first_not_of(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT { | 637 | find_first_not_of(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 623 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_not_of(): received nullptr"); | 638 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_first_not_of(): received nullptr"); |
| 624 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | 639 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( |
| 625 | data(), size(), __s, __pos, traits_type::length(__s)); | 640 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 626 | } | 641 | } |
| 627 | 642 | ||
| 628 | // find_last_not_of | 643 | // find_last_not_of |
| 629 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 644 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 630 | find_last_not_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { | 645 | find_last_not_of(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { |
| 631 | _LIBCPP_ASSERT_NON_NULL( | ||
| 632 | __s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr"); | ||
| 633 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | 646 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( |
| 634 | data(), size(), __s.data(), __pos, __s.size()); | 647 | data(), size(), __s.data(), __pos, __s.size()); |
| 635 | } | 648 | } |
| 636 | 649 | ||
| 637 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 650 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 638 | find_last_not_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT { | 651 | find_last_not_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT { |
| 639 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | 652 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); |
| 640 | } | 653 | } |
| 641 | 654 | ||
| 642 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 655 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 643 | find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT { | 656 | find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT |
| 657 | _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") { | ||
| 644 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr"); | 658 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr"); |
| 645 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | 659 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); |
| 646 | } | 660 | } |
| 647 | 661 | ||
| 648 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type | 662 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI size_type |
| 649 | find_last_not_of(const _CharT* __s, size_type __pos = npos) const _NOEXCEPT { | 663 | find_last_not_of(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 650 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_not_of(): received nullptr"); | 664 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string_view::find_last_not_of(): received nullptr"); |
| 651 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | 665 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( |
| 652 | data(), size(), __s, __pos, traits_type::length(__s)); | 666 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 653 | } | 667 | } |
| 654 | 668 | ||
| 655 | # if _LIBCPP_STD_VER >= 20 | 669 | # if _LIBCPP_STD_VER >= 20 |
| 656 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept { | 670 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept { |
| 657 | return size() >= __s.size() && compare(0, __s.size(), __s) == 0; | 671 | return size() >= __s.size() && compare(0, __s.size(), __s) == 0; |
| 658 | } | 672 | } |
| 659 | 673 | ||
| 660 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept { | 674 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept { |
| 661 | return !empty() && _Traits::eq(front(), __c); | 675 | return !empty() && _Traits::eq(front(), __c); |
| 662 | } | 676 | } |
| 663 | 677 | ||
| 664 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* __s) const noexcept { | 678 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool |
| 679 | starts_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { | ||
| 665 | return starts_with(basic_string_view(__s)); | 680 | return starts_with(basic_string_view(__s)); |
| 666 | } | 681 | } |
| 667 | 682 | ||
| 668 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(basic_string_view __s) const noexcept { | 683 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(basic_string_view __s) const noexcept { |
| 669 | return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; | 684 | return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; |
| 670 | } | 685 | } |
| 671 | 686 | ||
| 672 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept { | 687 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept { |
| 673 | return !empty() && _Traits::eq(back(), __c); | 688 | return !empty() && _Traits::eq(back(), __c); |
| 674 | } | 689 | } |
| 675 | 690 | ||
| 676 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept { | 691 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool |
| 692 | ends_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { | ||
| 677 | return ends_with(basic_string_view(__s)); | 693 | return ends_with(basic_string_view(__s)); |
| 678 | } | 694 | } |
| 679 | # endif | 695 | # endif |
| 680 | 696 | ||
| 681 | # if _LIBCPP_STD_VER >= 23 | 697 | # if _LIBCPP_STD_VER >= 23 |
| 682 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; } | 698 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { |
| 699 | return find(__sv) != npos; | ||
| 700 | } | ||
| 683 | 701 | ||
| 684 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { return find(__c) != npos; } | 702 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { |
| 703 | return find(__c) != npos; | ||
| 704 | } | ||
| 685 | 705 | ||
| 686 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return find(__s) != npos; } | 706 | [[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const { |
| 707 | return find(__s) != npos; | ||
| 708 | } | ||
| 687 | # endif | 709 | # endif |
| 688 | 710 | ||
| 689 | private: | 711 | private: |
| ... | @@ -886,7 +908,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Trai | ... | @@ -886,7 +908,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Trai |
| 886 | // [string.view.hash] | 908 | // [string.view.hash] |
| 887 | template <class _CharT> | 909 | template <class _CharT> |
| 888 | struct __string_view_hash : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> { | 910 | struct __string_view_hash : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> { |
| 889 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT { | 911 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t |
| 912 | operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT { | ||
| 890 | return std::__do_string_hash(__val.data(), __val.data() + __val.size()); | 913 | return std::__do_string_hash(__val.data(), __val.data() + __val.size()); |
| 891 | } | 914 | } |
| 892 | }; | 915 | }; |
| ... | @@ -913,30 +936,31 @@ struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_ | ... | @@ -913,30 +936,31 @@ struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_ |
| 913 | # if _LIBCPP_STD_VER >= 14 | 936 | # if _LIBCPP_STD_VER >= 14 |
| 914 | inline namespace literals { | 937 | inline namespace literals { |
| 915 | inline namespace string_view_literals { | 938 | inline namespace string_view_literals { |
| 916 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept { | 939 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> |
| 940 | operator""sv(const char* __str, size_t __len) noexcept { | ||
| 917 | return basic_string_view<char>(__str, __len); | 941 | return basic_string_view<char>(__str, __len); |
| 918 | } | 942 | } |
| 919 | 943 | ||
| 920 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 944 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 921 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t> | 945 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t> |
| 922 | operator""sv(const wchar_t* __str, size_t __len) noexcept { | 946 | operator""sv(const wchar_t* __str, size_t __len) noexcept { |
| 923 | return basic_string_view<wchar_t>(__str, __len); | 947 | return basic_string_view<wchar_t>(__str, __len); |
| 924 | } | 948 | } |
| 925 | # endif | 949 | # endif |
| 926 | 950 | ||
| 927 | # if _LIBCPP_HAS_CHAR8_T | 951 | # if _LIBCPP_HAS_CHAR8_T |
| 928 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t> | 952 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t> |
| 929 | operator""sv(const char8_t* __str, size_t __len) noexcept { | 953 | operator""sv(const char8_t* __str, size_t __len) noexcept { |
| 930 | return basic_string_view<char8_t>(__str, __len); | 954 | return basic_string_view<char8_t>(__str, __len); |
| 931 | } | 955 | } |
| 932 | # endif | 956 | # endif |
| 933 | 957 | ||
| 934 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t> | 958 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t> |
| 935 | operator""sv(const char16_t* __str, size_t __len) noexcept { | 959 | operator""sv(const char16_t* __str, size_t __len) noexcept { |
| 936 | return basic_string_view<char16_t>(__str, __len); | 960 | return basic_string_view<char16_t>(__str, __len); |
| 937 | } | 961 | } |
| 938 | 962 | ||
| 939 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char32_t> | 963 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char32_t> |
| 940 | operator""sv(const char32_t* __str, size_t __len) noexcept { | 964 | operator""sv(const char32_t* __str, size_t __len) noexcept { |
| 941 | return basic_string_view<char32_t>(__str, __len); | 965 | return basic_string_view<char32_t>(__str, __len); |
| 942 | } | 966 | } |
lib/libcxx/include/strstream+10-10| ... | @@ -179,8 +179,8 @@ public: | ... | @@ -179,8 +179,8 @@ public: |
| 179 | void swap(strstreambuf& __rhs); | 179 | void swap(strstreambuf& __rhs); |
| 180 | 180 | ||
| 181 | void freeze(bool __freezefl = true); | 181 | void freeze(bool __freezefl = true); |
| 182 | char* str(); | 182 | [[__nodiscard__]] char* str(); |
| 183 | int pcount() const; | 183 | [[__nodiscard__]] int pcount() const; |
| 184 | 184 | ||
| 185 | protected: | 185 | protected: |
| 186 | int_type overflow(int_type __c = EOF) override; | 186 | int_type overflow(int_type __c = EOF) override; |
| ... | @@ -264,8 +264,8 @@ public: | ... | @@ -264,8 +264,8 @@ public: |
| 264 | __sb_.swap(__rhs.__sb_); | 264 | __sb_.swap(__rhs.__sb_); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); } | 267 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); } |
| 268 | _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); } | 268 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); } |
| 269 | 269 | ||
| 270 | private: | 270 | private: |
| 271 | strstreambuf __sb_; | 271 | strstreambuf __sb_; |
| ... | @@ -297,10 +297,10 @@ public: | ... | @@ -297,10 +297,10 @@ public: |
| 297 | __sb_.swap(__rhs.__sb_); | 297 | __sb_.swap(__rhs.__sb_); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); } | 300 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); } |
| 301 | _LIBCPP_HIDE_FROM_ABI void freeze(bool __freezefl = true) { __sb_.freeze(__freezefl); } | 301 | _LIBCPP_HIDE_FROM_ABI void freeze(bool __freezefl = true) { __sb_.freeze(__freezefl); } |
| 302 | _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); } | 302 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); } |
| 303 | _LIBCPP_HIDE_FROM_ABI int pcount() const { return __sb_.pcount(); } | 303 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int pcount() const { return __sb_.pcount(); } |
| 304 | 304 | ||
| 305 | private: | 305 | private: |
| 306 | strstreambuf __sb_; // exposition only | 306 | strstreambuf __sb_; // exposition only |
| ... | @@ -340,10 +340,10 @@ public: | ... | @@ -340,10 +340,10 @@ public: |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | // Members: | 342 | // Members: |
| 343 | _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); } | 343 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); } |
| 344 | _LIBCPP_HIDE_FROM_ABI void freeze(bool __freezefl = true) { __sb_.freeze(__freezefl); } | 344 | _LIBCPP_HIDE_FROM_ABI void freeze(bool __freezefl = true) { __sb_.freeze(__freezefl); } |
| 345 | _LIBCPP_HIDE_FROM_ABI int pcount() const { return __sb_.pcount(); } | 345 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int pcount() const { return __sb_.pcount(); } |
| 346 | _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); } | 346 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); } |
| 347 | 347 | ||
| 348 | private: | 348 | private: |
| 349 | strstreambuf __sb_; // exposition only | 349 | strstreambuf __sb_; // exposition only |
lib/libcxx/include/syncstream+4-4| ... | @@ -317,9 +317,9 @@ public: | ... | @@ -317,9 +317,9 @@ public: |
| 317 | 317 | ||
| 318 | _LIBCPP_HIDE_FROM_ABI bool emit() { return emit(false); } | 318 | _LIBCPP_HIDE_FROM_ABI bool emit() { return emit(false); } |
| 319 | 319 | ||
| 320 | _LIBCPP_HIDE_FROM_ABI streambuf_type* get_wrapped() const noexcept { return __wrapped_; } | 320 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI streambuf_type* get_wrapped() const noexcept { return __wrapped_; } |
| 321 | 321 | ||
| 322 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); } | 322 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); } |
| 323 | 323 | ||
| 324 | _LIBCPP_HIDE_FROM_ABI void set_emit_on_sync(bool __b) noexcept { __emit_on_sync_ = __b; } | 324 | _LIBCPP_HIDE_FROM_ABI void set_emit_on_sync(bool __b) noexcept { __emit_on_sync_ = __b; } |
| 325 | 325 | ||
| ... | @@ -496,9 +496,9 @@ public: | ... | @@ -496,9 +496,9 @@ public: |
| 496 | } | 496 | } |
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | _LIBCPP_HIDE_FROM_ABI streambuf_type* get_wrapped() const noexcept { return __sb_.get_wrapped(); } | 499 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI streambuf_type* get_wrapped() const noexcept { return __sb_.get_wrapped(); } |
| 500 | 500 | ||
| 501 | _LIBCPP_HIDE_FROM_ABI syncbuf_type* rdbuf() const noexcept { | 501 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI syncbuf_type* rdbuf() const noexcept { |
| 502 | return const_cast<syncbuf_type*>(std::addressof(__sb_)); | 502 | return const_cast<syncbuf_type*>(std::addressof(__sb_)); |
| 503 | } | 503 | } |
| 504 | 504 |
lib/libcxx/include/tgmath.h+12-12| ... | @@ -18,22 +18,22 @@ | ... | @@ -18,22 +18,22 @@ |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 20 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 21 | # include <__cxx03/tgmath.h> | 21 | # include <__cxx03/__config> |
| 22 | #else | 22 | #else |
| 23 | # include <__config> | 23 | # include <__config> |
| 24 | #endif | ||
| 24 | 25 | ||
| 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | # pragma GCC system_header | 27 | # pragma GCC system_header |
| 27 | # endif | 28 | #endif |
| 28 | 29 | ||
| 29 | # ifdef __cplusplus | 30 | #ifdef __cplusplus |
| 30 | # include <cmath> | 31 | # include <cmath> |
| 31 | # include <complex> | 32 | # include <complex> |
| 32 | # else | 33 | #else |
| 33 | # if __has_include_next(<tgmath.h>) | 34 | # if __has_include_next(<tgmath.h>) |
| 34 | # include_next <tgmath.h> | 35 | # include_next <tgmath.h> |
| 35 | # endif | ||
| 36 | # endif | 36 | # endif |
| 37 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 37 | #endif |
| 38 | 38 | ||
| 39 | #endif // _LIBCPP_TGMATH_H | 39 | #endif // _LIBCPP_TGMATH_H |
lib/libcxx/include/tuple+242-212| ... | @@ -106,6 +106,11 @@ public: | ... | @@ -106,6 +106,11 @@ public: |
| 106 | 106 | ||
| 107 | void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20 | 107 | void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20 |
| 108 | constexpr void swap(const tuple&) const noexcept(see-below); // C++23 | 108 | constexpr void swap(const tuple&) const noexcept(see-below); // C++23 |
| 109 | |||
| 110 | template<tuple-like UTuple> | ||
| 111 | friend constexpr bool operator==(const tuple& t, const UTuple& u); // C++23 | ||
| 112 | template<tuple-like UTuple> | ||
| 113 | friend constexpr auto operator<=>(const tuple& t, const UTuple& u); // C++23 | ||
| 109 | }; | 114 | }; |
| 110 | 115 | ||
| 111 | 116 | ||
| ... | @@ -220,19 +225,16 @@ template <class... Types> | ... | @@ -220,19 +225,16 @@ template <class... Types> |
| 220 | # include <__config> | 225 | # include <__config> |
| 221 | # include <__cstddef/size_t.h> | 226 | # include <__cstddef/size_t.h> |
| 222 | # include <__fwd/array.h> | 227 | # include <__fwd/array.h> |
| 228 | # include <__fwd/get.h> | ||
| 223 | # include <__fwd/pair.h> | 229 | # include <__fwd/pair.h> |
| 224 | # include <__fwd/tuple.h> | 230 | # include <__fwd/tuple.h> |
| 225 | # include <__memory/allocator_arg_t.h> | 231 | # include <__memory/allocator_arg_t.h> |
| 226 | # include <__memory/uses_allocator.h> | 232 | # include <__memory/uses_allocator.h> |
| 227 | # include <__tuple/find_index.h> | 233 | # include <__tuple/find_index.h> |
| 228 | # include <__tuple/ignore.h> | 234 | # include <__tuple/ignore.h> |
| 229 | # include <__tuple/make_tuple_types.h> | ||
| 230 | # include <__tuple/sfinae_helpers.h> | ||
| 231 | # include <__tuple/tuple_element.h> | 235 | # include <__tuple/tuple_element.h> |
| 232 | # include <__tuple/tuple_indices.h> | 236 | # include <__tuple/tuple_like.h> |
| 233 | # include <__tuple/tuple_like_ext.h> | ||
| 234 | # include <__tuple/tuple_size.h> | 237 | # include <__tuple/tuple_size.h> |
| 235 | # include <__tuple/tuple_types.h> | ||
| 236 | # include <__type_traits/common_reference.h> | 238 | # include <__type_traits/common_reference.h> |
| 237 | # include <__type_traits/common_type.h> | 239 | # include <__type_traits/common_type.h> |
| 238 | # include <__type_traits/conditional.h> | 240 | # include <__type_traits/conditional.h> |
| ... | @@ -241,7 +243,6 @@ template <class... Types> | ... | @@ -241,7 +243,6 @@ template <class... Types> |
| 241 | # include <__type_traits/disjunction.h> | 243 | # include <__type_traits/disjunction.h> |
| 242 | # include <__type_traits/enable_if.h> | 244 | # include <__type_traits/enable_if.h> |
| 243 | # include <__type_traits/invoke.h> | 245 | # include <__type_traits/invoke.h> |
| 244 | # include <__type_traits/is_arithmetic.h> | ||
| 245 | # include <__type_traits/is_assignable.h> | 246 | # include <__type_traits/is_assignable.h> |
| 246 | # include <__type_traits/is_constructible.h> | 247 | # include <__type_traits/is_constructible.h> |
| 247 | # include <__type_traits/is_convertible.h> | 248 | # include <__type_traits/is_convertible.h> |
| ... | @@ -251,7 +252,6 @@ template <class... Types> | ... | @@ -251,7 +252,6 @@ template <class... Types> |
| 251 | # include <__type_traits/is_nothrow_assignable.h> | 252 | # include <__type_traits/is_nothrow_assignable.h> |
| 252 | # include <__type_traits/is_nothrow_constructible.h> | 253 | # include <__type_traits/is_nothrow_constructible.h> |
| 253 | # include <__type_traits/is_reference.h> | 254 | # include <__type_traits/is_reference.h> |
| 254 | # include <__type_traits/is_replaceable.h> | ||
| 255 | # include <__type_traits/is_same.h> | 255 | # include <__type_traits/is_same.h> |
| 256 | # include <__type_traits/is_swappable.h> | 256 | # include <__type_traits/is_swappable.h> |
| 257 | # include <__type_traits/is_trivially_relocatable.h> | 257 | # include <__type_traits/is_trivially_relocatable.h> |
| ... | @@ -263,12 +263,12 @@ template <class... Types> | ... | @@ -263,12 +263,12 @@ template <class... Types> |
| 263 | # include <__type_traits/remove_cv.h> | 263 | # include <__type_traits/remove_cv.h> |
| 264 | # include <__type_traits/remove_cvref.h> | 264 | # include <__type_traits/remove_cvref.h> |
| 265 | # include <__type_traits/remove_reference.h> | 265 | # include <__type_traits/remove_reference.h> |
| 266 | # include <__type_traits/type_list.h> | ||
| 266 | # include <__type_traits/unwrap_ref.h> | 267 | # include <__type_traits/unwrap_ref.h> |
| 267 | # include <__utility/declval.h> | 268 | # include <__utility/declval.h> |
| 268 | # include <__utility/forward.h> | 269 | # include <__utility/forward.h> |
| 269 | # include <__utility/integer_sequence.h> | 270 | # include <__utility/integer_sequence.h> |
| 270 | # include <__utility/move.h> | 271 | # include <__utility/move.h> |
| 271 | # include <__utility/piecewise_construct.h> | ||
| 272 | # include <__utility/swap.h> | 272 | # include <__utility/swap.h> |
| 273 | # include <version> | 273 | # include <version> |
| 274 | 274 | ||
| ... | @@ -288,9 +288,65 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -288,9 +288,65 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 288 | 288 | ||
| 289 | # ifndef _LIBCPP_CXX03_LANG | 289 | # ifndef _LIBCPP_CXX03_LANG |
| 290 | 290 | ||
| 291 | template <size_t _Ip, class _Tp, class _Up> | ||
| 292 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __tuple_compare_equal(const _Tp& __x, const _Up& __y) { | ||
| 293 | if constexpr (_Ip == 0) | ||
| 294 | return true; | ||
| 295 | else | ||
| 296 | return std::__tuple_compare_equal<_Ip - 1>(__x, __y) && std::get<_Ip - 1>(__x) == std::get<_Ip - 1>(__y); | ||
| 297 | } | ||
| 298 | |||
| 299 | # if _LIBCPP_STD_VER >= 26 | ||
| 300 | template <class _Tp, class _Up, class _IndexSeq = make_index_sequence<tuple_size_v<_Tp>>> | ||
| 301 | inline constexpr bool __can_tuple_compare_equal = false; | ||
| 302 | |||
| 303 | // TODO(LLVM 23): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends | ||
| 304 | // because the resolution of CWG2369 landed in LLVM-21. | ||
| 305 | template <class _Tp, class _Up, size_t... _Is> | ||
| 306 | requires(tuple_size_v<_Tp> == tuple_size_v<_Up>) | ||
| 307 | inline constexpr bool __can_tuple_compare_equal<_Tp, _Up, index_sequence<_Is...>> = | ||
| 308 | __all<requires(const tuple_element_t<_Is, _Tp>& __t, const tuple_element_t<_Is, _Up>& __u) { | ||
| 309 | { __t == __u } -> __boolean_testable; | ||
| 310 | }...>::value; | ||
| 311 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 312 | |||
| 313 | # if _LIBCPP_STD_VER >= 20 | ||
| 314 | template <class _Ret, class _Tp, class _Up, size_t... _Is> | ||
| 315 | _LIBCPP_HIDE_FROM_ABI constexpr _Ret __tuple_compare_three_way(const _Tp& __x, const _Up& __y, index_sequence<_Is...>) { | ||
| 316 | _Ret __result = strong_ordering::equal; | ||
| 317 | static_cast<void>( | ||
| 318 | ((__result = std::__synth_three_way(std::get<_Is>(__x), std::get<_Is>(__y)), __result != 0) || ...)); | ||
| 319 | return __result; | ||
| 320 | } | ||
| 321 | # endif // _LIBCPP_STD_VER >= 20 | ||
| 322 | |||
| 323 | # if _LIBCPP_STD_VER >= 23 | ||
| 324 | template <class _Tp> | ||
| 325 | concept __tuple_like_no_tuple = __tuple_like<_Tp> && !__is_tuple_v<_Tp>; | ||
| 326 | |||
| 327 | template <class _Tp, class _Up, class _IndexSeq> | ||
| 328 | struct __tuple_common_comparison_category_impl {}; | ||
| 329 | |||
| 330 | // TODO(LLVM 23): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends | ||
| 331 | // because the resolution of CWG2369 landed in LLVM-21. | ||
| 332 | template <class _Tp, class _Up, size_t... _Is> | ||
| 333 | requires(tuple_size_v<_Tp> == tuple_size_v<_Up>) && requires { | ||
| 334 | typename common_comparison_category_t< | ||
| 335 | __synth_three_way_result<tuple_element_t<_Is, _Tp>, tuple_element_t<_Is, _Up>>...>; | ||
| 336 | } | ||
| 337 | struct __tuple_common_comparison_category_impl<_Tp, _Up, index_sequence<_Is...>> { | ||
| 338 | using type _LIBCPP_NODEBUG = | ||
| 339 | common_comparison_category_t<__synth_three_way_result<tuple_element_t<_Is, _Tp>, tuple_element_t<_Is, _Up>>...>; | ||
| 340 | }; | ||
| 341 | |||
| 342 | template <__tuple_like _Tp, __tuple_like _Up> | ||
| 343 | using __tuple_common_comparison_category _LIBCPP_NODEBUG = | ||
| 344 | __tuple_common_comparison_category_impl<_Tp, _Up, make_index_sequence<tuple_size_v<_Tp>>>::type; | ||
| 345 | # endif // _LIBCPP_STD_VER >= 23 | ||
| 346 | |||
| 291 | // __tuple_leaf | 347 | // __tuple_leaf |
| 292 | 348 | ||
| 293 | template <size_t _Ip, class _Hp, bool = is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value > | 349 | template <size_t _Ip, class _Hp, bool = is_empty<_Hp>::value && !__is_final_v<_Hp> > |
| 294 | class __tuple_leaf; | 350 | class __tuple_leaf; |
| 295 | 351 | ||
| 296 | template <size_t _Ip, class _Hp, bool _Ep> | 352 | template <size_t _Ip, class _Hp, bool _Ep> |
| ... | @@ -444,62 +500,52 @@ public: | ... | @@ -444,62 +500,52 @@ public: |
| 444 | template <class... _Tp> | 500 | template <class... _Tp> |
| 445 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swallow(_Tp&&...) _NOEXCEPT {} | 501 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swallow(_Tp&&...) _NOEXCEPT {} |
| 446 | 502 | ||
| 447 | template <class _Tp> | ||
| 448 | struct __all_default_constructible; | ||
| 449 | |||
| 450 | template <class... _Tp> | ||
| 451 | struct __all_default_constructible<__tuple_types<_Tp...>> : __all<is_default_constructible<_Tp>::value...> {}; | ||
| 452 | |||
| 453 | // __tuple_impl | 503 | // __tuple_impl |
| 454 | 504 | ||
| 455 | template <class _Indx, class... _Tp> | 505 | template <class _Indx, class... _Tp> |
| 456 | struct __tuple_impl; | 506 | struct __tuple_impl; |
| 457 | 507 | ||
| 508 | struct __forward_args {}; | ||
| 509 | struct __value_init {}; | ||
| 510 | struct __from_tuple {}; | ||
| 511 | |||
| 458 | template <size_t... _Indx, class... _Tp> | 512 | template <size_t... _Indx, class... _Tp> |
| 459 | struct _LIBCPP_DECLSPEC_EMPTY_BASES | 513 | struct _LIBCPP_DECLSPEC_EMPTY_BASES |
| 460 | __tuple_impl<__tuple_indices<_Indx...>, _Tp...> : public __tuple_leaf<_Indx, _Tp>... { | 514 | __tuple_impl<__index_sequence<_Indx...>, _Tp...> : public __tuple_leaf<_Indx, _Tp>... { |
| 461 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept( | 515 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept( |
| 462 | __all<is_nothrow_default_constructible<_Tp>::value...>::value) {} | 516 | __all<is_nothrow_default_constructible<_Tp>::value...>::value) {} |
| 463 | 517 | ||
| 464 | template <size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up> | 518 | template <class... _Args> |
| 465 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl( | 519 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl(__forward_args, _Args&&... __args) |
| 466 | __tuple_indices<_Uf...>, | 520 | : __tuple_leaf<_Indx, _Tp>(std::forward<_Args>(__args))... {} |
| 467 | __tuple_types<_Tf...>, | 521 | |
| 468 | __tuple_indices<_Ul...>, | 522 | template <class _Alloc> |
| 469 | __tuple_types<_Tl...>, | 523 | _LIBCPP_HIDE_FROM_ABI |
| 470 | _Up&&... __u) noexcept(__all<is_nothrow_constructible<_Tf, _Up>::value...>::value && | 524 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl(allocator_arg_t, const _Alloc& __alloc, __value_init) |
| 471 | __all<is_nothrow_default_constructible<_Tl>::value...>::value) | 525 | : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc>(), __alloc)... {} |
| 472 | : __tuple_leaf<_Uf, _Tf>(std::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>()... {} | 526 | |
| 473 | 527 | template <class _Alloc, class... _Args> | |
| 474 | template <class _Alloc, size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up> | ||
| 475 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl( | 528 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl( |
| 476 | allocator_arg_t, | 529 | allocator_arg_t, const _Alloc& __alloc, __forward_args, _Args&&... __args) |
| 477 | const _Alloc& __a, | 530 | : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, _Args>(), __alloc, std::forward<_Args>(__args))... {} |
| 478 | __tuple_indices<_Uf...>, | 531 | |
| 479 | __tuple_types<_Tf...>, | 532 | template <class _Tuple> |
| 480 | __tuple_indices<_Ul...>, | 533 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(__from_tuple, _Tuple&& __t) noexcept( |
| 481 | __tuple_types<_Tl...>, | 534 | (__all<is_nothrow_constructible<_Tp, __copy_cvref_t<_Tuple, __tuple_element_t<_Indx, __remove_cvref_t<_Tuple>>>>:: |
| 482 | _Up&&... __u) | 535 | value...>::value)) |
| 483 | : __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, std::forward<_Up>(__u))..., | ||
| 484 | __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... {} | ||
| 485 | |||
| 486 | template <class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0> | ||
| 487 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) noexcept( | ||
| 488 | (__all<is_nothrow_constructible< | ||
| 489 | _Tp, | ||
| 490 | typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>::value...>::value)) | ||
| 491 | : __tuple_leaf<_Indx, _Tp>( | 536 | : __tuple_leaf<_Indx, _Tp>( |
| 492 | std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>( | 537 | std::forward<__copy_cvref_t<_Tuple, __tuple_element_t<_Indx, __remove_cvref_t<_Tuple>>>>( |
| 493 | std::get<_Indx>(__t)))... {} | 538 | std::get<_Indx>(__t)))... {} |
| 494 | 539 | ||
| 495 | template <class _Alloc, class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0> | 540 | template <class _Alloc, class _Tuple> |
| 496 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) | 541 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 542 | __tuple_impl(allocator_arg_t, const _Alloc& __a, __from_tuple, _Tuple&& __t) | ||
| 497 | : __tuple_leaf<_Indx, _Tp>( | 543 | : __tuple_leaf<_Indx, _Tp>( |
| 498 | __uses_alloc_ctor<_Tp, | 544 | __uses_alloc_ctor<_Tp, |
| 499 | _Alloc, | 545 | _Alloc, |
| 500 | typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(), | 546 | __copy_cvref_t<_Tuple, __tuple_element_t<_Indx, __remove_cvref_t<_Tuple>>>>(), |
| 501 | __a, | 547 | __a, |
| 502 | std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>( | 548 | std::forward<__copy_cvref_t<_Tuple, __tuple_element_t<_Indx, __remove_cvref_t<_Tuple>>>>( |
| 503 | std::get<_Indx>(__t)))... {} | 549 | std::get<_Indx>(__t)))... {} |
| 504 | 550 | ||
| 505 | __tuple_impl(const __tuple_impl&) = default; | 551 | __tuple_impl(const __tuple_impl&) = default; |
| ... | @@ -518,19 +564,19 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES | ... | @@ -518,19 +564,19 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES |
| 518 | 564 | ||
| 519 | template <class _Dest, class _Source, size_t... _Np> | 565 | template <class _Dest, class _Source, size_t... _Np> |
| 520 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 566 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 521 | __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) { | 567 | __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __index_sequence<_Np...>) { |
| 522 | std::__swallow(((std::get<_Np>(__dest) = std::get<_Np>(__source)), void(), 0)...); | 568 | std::__swallow(((std::get<_Np>(__dest) = std::get<_Np>(__source)), void(), 0)...); |
| 523 | } | 569 | } |
| 524 | 570 | ||
| 525 | template <class _Dest, class _Source, class... _Up, size_t... _Np> | 571 | template <class _Dest, class _Source, class... _Up, size_t... _Np> |
| 526 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | 572 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 527 | __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) { | 573 | __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __type_list<_Up...>, __index_sequence<_Np...>) { |
| 528 | std::__swallow(((std::get<_Np>(__dest) = std::forward<_Up>(std::get<_Np>(__source))), void(), 0)...); | 574 | std::__swallow(((std::get<_Np>(__dest) = std::forward<_Up>(std::get<_Np>(__source))), void(), 0)...); |
| 529 | } | 575 | } |
| 530 | 576 | ||
| 531 | template <class... _Tp> | 577 | template <class... _Tp> |
| 532 | class _LIBCPP_NO_SPECIALIZATIONS tuple { | 578 | class _LIBCPP_NO_SPECIALIZATIONS tuple { |
| 533 | typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT; | 579 | typedef __tuple_impl<__index_sequence_for<_Tp...>, _Tp...> _BaseT; |
| 534 | 580 | ||
| 535 | _BaseT __base_; | 581 | _BaseT __base_; |
| 536 | 582 | ||
| ... | @@ -549,7 +595,6 @@ class _LIBCPP_NO_SPECIALIZATIONS tuple { | ... | @@ -549,7 +595,6 @@ class _LIBCPP_NO_SPECIALIZATIONS tuple { |
| 549 | public: | 595 | public: |
| 550 | using __trivially_relocatable _LIBCPP_NODEBUG = | 596 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 551 | __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>; | 597 | __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>; |
| 552 | using __replaceable _LIBCPP_NODEBUG = __conditional_t<_And<__is_replaceable<_Tp>...>::value, tuple, void>; | ||
| 553 | 598 | ||
| 554 | // [tuple.cnstr] | 599 | // [tuple.cnstr] |
| 555 | 600 | ||
| ... | @@ -566,12 +611,7 @@ public: | ... | @@ -566,12 +611,7 @@ public: |
| 566 | __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0> | 611 | __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0> |
| 567 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) | 612 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) |
| 568 | tuple(allocator_arg_t, _Alloc const& __a) | 613 | tuple(allocator_arg_t, _Alloc const& __a) |
| 569 | : __base_(allocator_arg_t(), | 614 | : __base_(allocator_arg_t(), __a, __value_init{}) {} |
| 570 | __a, | ||
| 571 | __tuple_indices<>(), | ||
| 572 | __tuple_types<>(), | ||
| 573 | typename __make_tuple_indices<sizeof...(_Tp), 0>::type(), | ||
| 574 | __tuple_types<_Tp...>()) {} | ||
| 575 | 615 | ||
| 576 | // tuple(const T&...) constructors (including allocator_arg_t variants) | 616 | // tuple(const T&...) constructors (including allocator_arg_t variants) |
| 577 | template <template <class...> class _And = _And, | 617 | template <template <class...> class _And = _And, |
| ... | @@ -579,11 +619,7 @@ public: | ... | @@ -579,11 +619,7 @@ public: |
| 579 | _LIBCPP_HIDE_FROM_ABI | 619 | _LIBCPP_HIDE_FROM_ABI |
| 580 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) | 620 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) |
| 581 | tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value) | 621 | tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value) |
| 582 | : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), | 622 | : __base_(__forward_args{}, __t...) {} |
| 583 | typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), | ||
| 584 | typename __make_tuple_indices<0>::type(), | ||
| 585 | typename __make_tuple_types<tuple, 0>::type(), | ||
| 586 | __t...) {} | ||
| 587 | 623 | ||
| 588 | template <class _Alloc, | 624 | template <class _Alloc, |
| 589 | template <class...> class _And = _And, | 625 | template <class...> class _And = _And, |
| ... | @@ -591,13 +627,7 @@ public: | ... | @@ -591,13 +627,7 @@ public: |
| 591 | _LIBCPP_HIDE_FROM_ABI | 627 | _LIBCPP_HIDE_FROM_ABI |
| 592 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) | 628 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) |
| 593 | tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t) | 629 | tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t) |
| 594 | : __base_(allocator_arg_t(), | 630 | : __base_(allocator_arg_t(), __a, __forward_args{}, __t...) {} |
| 595 | __a, | ||
| 596 | typename __make_tuple_indices<sizeof...(_Tp)>::type(), | ||
| 597 | typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), | ||
| 598 | typename __make_tuple_indices<0>::type(), | ||
| 599 | typename __make_tuple_types<tuple, 0>::type(), | ||
| 600 | __t...) {} | ||
| 601 | 631 | ||
| 602 | // tuple(U&& ...) constructors (including allocator_arg_t variants) | 632 | // tuple(U&& ...) constructors (including allocator_arg_t variants) |
| 603 | template <class... _Up> | 633 | template <class... _Up> |
| ... | @@ -616,11 +646,7 @@ public: | ... | @@ -616,11 +646,7 @@ public: |
| 616 | int> = 0> | 646 | int> = 0> |
| 617 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) | 647 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) |
| 618 | tuple(_Up&&... __u) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value) | 648 | tuple(_Up&&... __u) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value) |
| 619 | : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), | 649 | : __base_(__forward_args{}, std::forward<_Up>(__u)...) {} |
| 620 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), | ||
| 621 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), | ||
| 622 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), | ||
| 623 | std::forward<_Up>(__u)...) {} | ||
| 624 | 650 | ||
| 625 | template <class _Alloc, | 651 | template <class _Alloc, |
| 626 | class... _Up, | 652 | class... _Up, |
| ... | @@ -628,13 +654,7 @@ public: | ... | @@ -628,13 +654,7 @@ public: |
| 628 | int> = 0> | 654 | int> = 0> |
| 629 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) | 655 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) |
| 630 | tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) | 656 | tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) |
| 631 | : __base_(allocator_arg_t(), | 657 | : __base_(allocator_arg_t(), __a, __forward_args{}, std::forward<_Up>(__u)...) {} |
| 632 | __a, | ||
| 633 | typename __make_tuple_indices<sizeof...(_Up)>::type(), | ||
| 634 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), | ||
| 635 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), | ||
| 636 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), | ||
| 637 | std::forward<_Up>(__u)...) {} | ||
| 638 | 658 | ||
| 639 | // Copy and move constructors (including the allocator_arg_t variants) | 659 | // Copy and move constructors (including the allocator_arg_t variants) |
| 640 | tuple(const tuple&) = default; | 660 | tuple(const tuple&) = default; |
| ... | @@ -644,13 +664,13 @@ public: | ... | @@ -644,13 +664,13 @@ public: |
| 644 | template <class...> class _And = _And, | 664 | template <class...> class _And = _And, |
| 645 | __enable_if_t< _And<is_copy_constructible<_Tp>...>::value, int> = 0> | 665 | __enable_if_t< _And<is_copy_constructible<_Tp>...>::value, int> = 0> |
| 646 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t) | 666 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t) |
| 647 | : __base_(allocator_arg_t(), __alloc, __t) {} | 667 | : __base_(allocator_arg_t(), __alloc, __from_tuple(), __t) {} |
| 648 | 668 | ||
| 649 | template <class _Alloc, | 669 | template <class _Alloc, |
| 650 | template <class...> class _And = _And, | 670 | template <class...> class _And = _And, |
| 651 | __enable_if_t< _And<is_move_constructible<_Tp>...>::value, int> = 0> | 671 | __enable_if_t< _And<is_move_constructible<_Tp>...>::value, int> = 0> |
| 652 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t) | 672 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t) |
| 653 | : __base_(allocator_arg_t(), __alloc, std::move(__t)) {} | 673 | : __base_(allocator_arg_t(), __alloc, __from_tuple(), std::move(__t)) {} |
| 654 | 674 | ||
| 655 | // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants) | 675 | // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants) |
| 656 | 676 | ||
| ... | @@ -683,7 +703,7 @@ public: | ... | @@ -683,7 +703,7 @@ public: |
| 683 | _LIBCPP_HIDE_FROM_ABI | 703 | _LIBCPP_HIDE_FROM_ABI |
| 684 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) | 704 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) |
| 685 | tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value) | 705 | tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value) |
| 686 | : __base_(__t) {} | 706 | : __base_(__from_tuple(), __t) {} |
| 687 | 707 | ||
| 688 | template <class... _Up, | 708 | template <class... _Up, |
| 689 | class _Alloc, | 709 | class _Alloc, |
| ... | @@ -691,33 +711,33 @@ public: | ... | @@ -691,33 +711,33 @@ public: |
| 691 | _LIBCPP_HIDE_FROM_ABI | 711 | _LIBCPP_HIDE_FROM_ABI |
| 692 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) | 712 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) |
| 693 | tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) | 713 | tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) |
| 694 | : __base_(allocator_arg_t(), __a, __t) {} | 714 | : __base_(allocator_arg_t(), __a, __from_tuple(), __t) {} |
| 695 | 715 | ||
| 696 | # if _LIBCPP_STD_VER >= 23 | 716 | # if _LIBCPP_STD_VER >= 23 |
| 697 | // tuple(tuple<U...>&) constructors (including allocator_arg_t variants) | 717 | // tuple(tuple<U...>&) constructors (including allocator_arg_t variants) |
| 698 | 718 | ||
| 699 | template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> | 719 | template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> |
| 700 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t) | 720 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t) |
| 701 | : __base_(__t) {} | 721 | : __base_(__from_tuple(), __t) {} |
| 702 | 722 | ||
| 703 | template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> | 723 | template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> |
| 704 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) | 724 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) |
| 705 | tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) | 725 | tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) |
| 706 | : __base_(allocator_arg_t(), __alloc, __t) {} | 726 | : __base_(allocator_arg_t(), __alloc, __from_tuple(), __t) {} |
| 707 | # endif // _LIBCPP_STD_VER >= 23 | 727 | # endif // _LIBCPP_STD_VER >= 23 |
| 708 | 728 | ||
| 709 | // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants) | 729 | // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants) |
| 710 | template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0> | 730 | template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0> |
| 711 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) | 731 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) |
| 712 | tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value) | 732 | tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value) |
| 713 | : __base_(std::move(__t)) {} | 733 | : __base_(__from_tuple(), std::move(__t)) {} |
| 714 | 734 | ||
| 715 | template <class _Alloc, | 735 | template <class _Alloc, |
| 716 | class... _Up, | 736 | class... _Up, |
| 717 | __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0> | 737 | __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0> |
| 718 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) | 738 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) |
| 719 | tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) | 739 | tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) |
| 720 | : __base_(allocator_arg_t(), __a, std::move(__t)) {} | 740 | : __base_(allocator_arg_t(), __a, __from_tuple(), std::move(__t)) {} |
| 721 | 741 | ||
| 722 | # if _LIBCPP_STD_VER >= 23 | 742 | # if _LIBCPP_STD_VER >= 23 |
| 723 | // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants) | 743 | // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants) |
| ... | @@ -725,14 +745,14 @@ public: | ... | @@ -725,14 +745,14 @@ public: |
| 725 | template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> | 745 | template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> |
| 726 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value) | 746 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value) |
| 727 | tuple(const tuple<_Up...>&& __t) | 747 | tuple(const tuple<_Up...>&& __t) |
| 728 | : __base_(std::move(__t)) {} | 748 | : __base_(__from_tuple(), std::move(__t)) {} |
| 729 | 749 | ||
| 730 | template <class _Alloc, | 750 | template <class _Alloc, |
| 731 | class... _Up, | 751 | class... _Up, |
| 732 | enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> | 752 | enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> |
| 733 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value) | 753 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value) |
| 734 | tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t) | 754 | tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t) |
| 735 | : __base_(allocator_arg_t(), __alloc, std::move(__t)) {} | 755 | : __base_(allocator_arg_t(), __alloc, __from_tuple(), std::move(__t)) {} |
| 736 | # endif // _LIBCPP_STD_VER >= 23 | 756 | # endif // _LIBCPP_STD_VER >= 23 |
| 737 | 757 | ||
| 738 | // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants) | 758 | // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants) |
| ... | @@ -767,7 +787,7 @@ public: | ... | @@ -767,7 +787,7 @@ public: |
| 767 | _LIBCPP_HIDE_FROM_ABI | 787 | _LIBCPP_HIDE_FROM_ABI |
| 768 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) | 788 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) |
| 769 | tuple(const pair<_Up1, _Up2>& __p) noexcept(_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value) | 789 | tuple(const pair<_Up1, _Up2>& __p) noexcept(_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value) |
| 770 | : __base_(__p) {} | 790 | : __base_(__from_tuple(), __p) {} |
| 771 | 791 | ||
| 772 | template <class _Alloc, | 792 | template <class _Alloc, |
| 773 | class _Up1, | 793 | class _Up1, |
| ... | @@ -777,7 +797,7 @@ public: | ... | @@ -777,7 +797,7 @@ public: |
| 777 | _LIBCPP_HIDE_FROM_ABI | 797 | _LIBCPP_HIDE_FROM_ABI |
| 778 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) | 798 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) |
| 779 | tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) | 799 | tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) |
| 780 | : __base_(allocator_arg_t(), __a, __p) {} | 800 | : __base_(allocator_arg_t(), __a, __from_tuple(), __p) {} |
| 781 | 801 | ||
| 782 | # if _LIBCPP_STD_VER >= 23 | 802 | # if _LIBCPP_STD_VER >= 23 |
| 783 | // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants) | 803 | // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants) |
| ... | @@ -785,7 +805,7 @@ public: | ... | @@ -785,7 +805,7 @@ public: |
| 785 | template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr> | 805 | template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr> |
| 786 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value) | 806 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value) |
| 787 | tuple(pair<_U1, _U2>& __p) | 807 | tuple(pair<_U1, _U2>& __p) |
| 788 | : __base_(__p) {} | 808 | : __base_(__from_tuple(), __p) {} |
| 789 | 809 | ||
| 790 | template <class _Alloc, | 810 | template <class _Alloc, |
| 791 | class _U1, | 811 | class _U1, |
| ... | @@ -793,7 +813,7 @@ public: | ... | @@ -793,7 +813,7 @@ public: |
| 793 | enable_if_t< _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr> | 813 | enable_if_t< _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr> |
| 794 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value) | 814 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value) |
| 795 | tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) | 815 | tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) |
| 796 | : __base_(allocator_arg_t(), __alloc, __p) {} | 816 | : __base_(allocator_arg_t(), __alloc, __from_tuple(), __p) {} |
| 797 | # endif | 817 | # endif |
| 798 | 818 | ||
| 799 | // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants) | 819 | // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants) |
| ... | @@ -805,7 +825,7 @@ public: | ... | @@ -805,7 +825,7 @@ public: |
| 805 | _LIBCPP_HIDE_FROM_ABI | 825 | _LIBCPP_HIDE_FROM_ABI |
| 806 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) | 826 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) |
| 807 | tuple(pair<_Up1, _Up2>&& __p) noexcept(_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value) | 827 | tuple(pair<_Up1, _Up2>&& __p) noexcept(_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value) |
| 808 | : __base_(std::move(__p)) {} | 828 | : __base_(__from_tuple(), std::move(__p)) {} |
| 809 | 829 | ||
| 810 | template <class _Alloc, | 830 | template <class _Alloc, |
| 811 | class _Up1, | 831 | class _Up1, |
| ... | @@ -815,7 +835,7 @@ public: | ... | @@ -815,7 +835,7 @@ public: |
| 815 | _LIBCPP_HIDE_FROM_ABI | 835 | _LIBCPP_HIDE_FROM_ABI |
| 816 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) | 836 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) |
| 817 | tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) | 837 | tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) |
| 818 | : __base_(allocator_arg_t(), __a, std::move(__p)) {} | 838 | : __base_(allocator_arg_t(), __a, __from_tuple(), std::move(__p)) {} |
| 819 | 839 | ||
| 820 | # if _LIBCPP_STD_VER >= 23 | 840 | # if _LIBCPP_STD_VER >= 23 |
| 821 | // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants) | 841 | // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants) |
| ... | @@ -823,7 +843,7 @@ public: | ... | @@ -823,7 +843,7 @@ public: |
| 823 | template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr> | 843 | template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr> |
| 824 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value) | 844 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value) |
| 825 | tuple(const pair<_U1, _U2>&& __p) | 845 | tuple(const pair<_U1, _U2>&& __p) |
| 826 | : __base_(std::move(__p)) {} | 846 | : __base_(__from_tuple(), std::move(__p)) {} |
| 827 | 847 | ||
| 828 | template <class _Alloc, | 848 | template <class _Alloc, |
| 829 | class _U1, | 849 | class _U1, |
| ... | @@ -831,14 +851,14 @@ public: | ... | @@ -831,14 +851,14 @@ public: |
| 831 | enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr> | 851 | enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr> |
| 832 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value) | 852 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value) |
| 833 | tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p) | 853 | tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p) |
| 834 | : __base_(allocator_arg_t(), __alloc, std::move(__p)) {} | 854 | : __base_(allocator_arg_t(), __alloc, __from_tuple(), std::move(__p)) {} |
| 835 | # endif // _LIBCPP_STD_VER >= 23 | 855 | # endif // _LIBCPP_STD_VER >= 23 |
| 836 | 856 | ||
| 837 | // [tuple.assign] | 857 | // [tuple.assign] |
| 838 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 858 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 839 | operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept( | 859 | operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept( |
| 840 | _And<is_nothrow_copy_assignable<_Tp>...>::value) { | 860 | _And<is_nothrow_copy_assignable<_Tp>...>::value) { |
| 841 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 861 | std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>()); |
| 842 | return *this; | 862 | return *this; |
| 843 | } | 863 | } |
| 844 | 864 | ||
| ... | @@ -846,15 +866,14 @@ public: | ... | @@ -846,15 +866,14 @@ public: |
| 846 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const | 866 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const |
| 847 | requires(_And<is_copy_assignable<const _Tp>...>::value) | 867 | requires(_And<is_copy_assignable<const _Tp>...>::value) |
| 848 | { | 868 | { |
| 849 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 869 | std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>()); |
| 850 | return *this; | 870 | return *this; |
| 851 | } | 871 | } |
| 852 | 872 | ||
| 853 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple&& __tuple) const | 873 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple&& __tuple) const |
| 854 | requires(_And<is_assignable<const _Tp&, _Tp>...>::value) | 874 | requires(_And<is_assignable<const _Tp&, _Tp>...>::value) |
| 855 | { | 875 | { |
| 856 | std::__memberwise_forward_assign( | 876 | std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Tp...>(), __index_sequence_for<_Tp...>()); |
| 857 | *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); | ||
| 858 | return *this; | 877 | return *this; |
| 859 | } | 878 | } |
| 860 | # endif // _LIBCPP_STD_VER >= 23 | 879 | # endif // _LIBCPP_STD_VER >= 23 |
| ... | @@ -862,8 +881,7 @@ public: | ... | @@ -862,8 +881,7 @@ public: |
| 862 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 881 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 863 | operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept( | 882 | operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept( |
| 864 | _And<is_nothrow_move_assignable<_Tp>...>::value) { | 883 | _And<is_nothrow_move_assignable<_Tp>...>::value) { |
| 865 | std::__memberwise_forward_assign( | 884 | std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Tp...>(), __index_sequence_for<_Tp...>()); |
| 866 | *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); | ||
| 867 | return *this; | 885 | return *this; |
| 868 | } | 886 | } |
| 869 | 887 | ||
| ... | @@ -873,7 +891,7 @@ public: | ... | @@ -873,7 +891,7 @@ public: |
| 873 | int> = 0> | 891 | int> = 0> |
| 874 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 892 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 875 | operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { | 893 | operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { |
| 876 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 894 | std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>()); |
| 877 | return *this; | 895 | return *this; |
| 878 | } | 896 | } |
| 879 | 897 | ||
| ... | @@ -882,8 +900,7 @@ public: | ... | @@ -882,8 +900,7 @@ public: |
| 882 | int> = 0> | 900 | int> = 0> |
| 883 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 901 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 884 | operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { | 902 | operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { |
| 885 | std::__memberwise_forward_assign( | 903 | std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Up...>(), __index_sequence_for<_Tp...>()); |
| 886 | *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); | ||
| 887 | return *this; | 904 | return *this; |
| 888 | } | 905 | } |
| 889 | 906 | ||
| ... | @@ -892,7 +909,7 @@ public: | ... | @@ -892,7 +909,7 @@ public: |
| 892 | enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>, | 909 | enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>, |
| 893 | is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr> | 910 | is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr> |
| 894 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const tuple<_UTypes...>& __u) const { | 911 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const tuple<_UTypes...>& __u) const { |
| 895 | std::__memberwise_copy_assign(*this, __u, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 912 | std::__memberwise_copy_assign(*this, __u, index_sequence_for<_Tp...>()); |
| 896 | return *this; | 913 | return *this; |
| 897 | } | 914 | } |
| 898 | 915 | ||
| ... | @@ -900,8 +917,7 @@ public: | ... | @@ -900,8 +917,7 @@ public: |
| 900 | enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>, | 917 | enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>, |
| 901 | is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr> | 918 | is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr> |
| 902 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple<_UTypes...>&& __u) const { | 919 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple<_UTypes...>&& __u) const { |
| 903 | std::__memberwise_forward_assign( | 920 | std::__memberwise_forward_assign(*this, __u, __type_list<_UTypes...>(), index_sequence_for<_Tp...>()); |
| 904 | *this, __u, __tuple_types<_UTypes...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); | ||
| 905 | return *this; | 921 | return *this; |
| 906 | } | 922 | } |
| 907 | # endif // _LIBCPP_STD_VER >= 23 | 923 | # endif // _LIBCPP_STD_VER >= 23 |
| ... | @@ -967,7 +983,7 @@ public: | ... | @@ -967,7 +983,7 @@ public: |
| 967 | __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0> | 983 | __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0> |
| 968 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 984 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 969 | operator=(array<_Up, _Np> const& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { | 985 | operator=(array<_Up, _Np> const& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { |
| 970 | std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | 986 | std::__memberwise_copy_assign(*this, __array, __index_sequence_for<_Tp...>()); |
| 971 | return *this; | 987 | return *this; |
| 972 | } | 988 | } |
| 973 | 989 | ||
| ... | @@ -979,10 +995,7 @@ public: | ... | @@ -979,10 +995,7 @@ public: |
| 979 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | 995 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 980 | operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { | 996 | operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { |
| 981 | std::__memberwise_forward_assign( | 997 | std::__memberwise_forward_assign( |
| 982 | *this, | 998 | *this, std::move(__array), __type_list<_If<true, _Up, _Tp>...>(), __index_sequence_for<_Tp...>()); |
| 983 | std::move(__array), | ||
| 984 | __tuple_types<_If<true, _Up, _Tp>...>(), | ||
| 985 | typename __make_tuple_indices<sizeof...(_Tp)>::type()); | ||
| 986 | return *this; | 999 | return *this; |
| 987 | } | 1000 | } |
| 988 | 1001 | ||
| ... | @@ -997,7 +1010,24 @@ public: | ... | @@ -997,7 +1010,24 @@ public: |
| 997 | noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) { | 1010 | noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) { |
| 998 | __base_.swap(__t.__base_); | 1011 | __base_.swap(__t.__base_); |
| 999 | } | 1012 | } |
| 1000 | # endif // _LIBCPP_STD_VER >= 23 | 1013 | |
| 1014 | template <__tuple_like_no_tuple _UTuple> | ||
| 1015 | # if _LIBCPP_STD_VER >= 26 | ||
| 1016 | requires __can_tuple_compare_equal<tuple, _UTuple> && (sizeof...(_Tp) == tuple_size_v<_UTuple>) | ||
| 1017 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 1018 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const tuple& __x, const _UTuple& __y) { | ||
| 1019 | static_assert(sizeof...(_Tp) == tuple_size_v<_UTuple>, "Can't compare tuple-like values of different sizes"); | ||
| 1020 | return std::__tuple_compare_equal<sizeof...(_Tp)>(__x, __y); | ||
| 1021 | } | ||
| 1022 | |||
| 1023 | template <__tuple_like_no_tuple _UTuple> | ||
| 1024 | requires(sizeof...(_Tp) == tuple_size_v<_UTuple>) | ||
| 1025 | _LIBCPP_HIDE_FROM_ABI friend constexpr __tuple_common_comparison_category<tuple, _UTuple> | ||
| 1026 | operator<=>(const tuple& __x, const _UTuple& __y) { | ||
| 1027 | return std::__tuple_compare_three_way<__tuple_common_comparison_category<tuple, _UTuple>>( | ||
| 1028 | __x, __y, index_sequence_for<_Tp...>{}); | ||
| 1029 | } | ||
| 1030 | # endif // _LIBCPP_STD_VER >= 23 | ||
| 1001 | }; | 1031 | }; |
| 1002 | 1032 | ||
| 1003 | _LIBCPP_DIAGNOSTIC_PUSH | 1033 | _LIBCPP_DIAGNOSTIC_PUSH |
| ... | @@ -1019,6 +1049,21 @@ public: | ... | @@ -1019,6 +1049,21 @@ public: |
| 1019 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple&) _NOEXCEPT {} | 1049 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple&) _NOEXCEPT {} |
| 1020 | # if _LIBCPP_STD_VER >= 23 | 1050 | # if _LIBCPP_STD_VER >= 23 |
| 1021 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {} | 1051 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {} |
| 1052 | |||
| 1053 | template <__tuple_like_no_tuple _UTuple> | ||
| 1054 | # if _LIBCPP_STD_VER >= 26 | ||
| 1055 | requires(tuple_size_v<_UTuple> == 0) | ||
| 1056 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 1057 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const tuple&, const _UTuple&) { | ||
| 1058 | static_assert(tuple_size_v<_UTuple> == 0, "Can't compare tuple-like values of different sizes"); | ||
| 1059 | return true; | ||
| 1060 | } | ||
| 1061 | |||
| 1062 | template <__tuple_like_no_tuple _UTuple> | ||
| 1063 | requires(tuple_size_v<_UTuple> == 0) | ||
| 1064 | _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(const tuple&, const _UTuple&) { | ||
| 1065 | return strong_ordering::equal; | ||
| 1066 | } | ||
| 1022 | # endif | 1067 | # endif |
| 1023 | }; | 1068 | }; |
| 1024 | _LIBCPP_DIAGNOSTIC_POP | 1069 | _LIBCPP_DIAGNOSTIC_POP |
| ... | @@ -1068,28 +1113,32 @@ swap(const tuple<_Tp...>& __lhs, | ... | @@ -1068,28 +1113,32 @@ swap(const tuple<_Tp...>& __lhs, |
| 1068 | // get | 1113 | // get |
| 1069 | 1114 | ||
| 1070 | template <size_t _Ip, class... _Tp> | 1115 | template <size_t _Ip, class... _Tp> |
| 1071 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type& | 1116 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 1117 | typename tuple_element<_Ip, tuple<_Tp...> >::type& | ||
| 1072 | get(tuple<_Tp...>& __t) _NOEXCEPT { | 1118 | get(tuple<_Tp...>& __t) _NOEXCEPT { |
| 1073 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | 1119 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; |
| 1074 | return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get(); | 1120 | return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get(); |
| 1075 | } | 1121 | } |
| 1076 | 1122 | ||
| 1077 | template <size_t _Ip, class... _Tp> | 1123 | template <size_t _Ip, class... _Tp> |
| 1078 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type& | 1124 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 1125 | _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type& | ||
| 1079 | get(const tuple<_Tp...>& __t) _NOEXCEPT { | 1126 | get(const tuple<_Tp...>& __t) _NOEXCEPT { |
| 1080 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | 1127 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; |
| 1081 | return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get(); | 1128 | return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get(); |
| 1082 | } | 1129 | } |
| 1083 | 1130 | ||
| 1084 | template <size_t _Ip, class... _Tp> | 1131 | template <size_t _Ip, class... _Tp> |
| 1085 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&& | 1132 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 1133 | typename tuple_element<_Ip, tuple<_Tp...> >::type&& | ||
| 1086 | get(tuple<_Tp...>&& __t) _NOEXCEPT { | 1134 | get(tuple<_Tp...>&& __t) _NOEXCEPT { |
| 1087 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | 1135 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; |
| 1088 | return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get()); | 1136 | return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get()); |
| 1089 | } | 1137 | } |
| 1090 | 1138 | ||
| 1091 | template <size_t _Ip, class... _Tp> | 1139 | template <size_t _Ip, class... _Tp> |
| 1092 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&& | 1140 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 1141 | _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&& | ||
| 1093 | get(const tuple<_Tp...>&& __t) _NOEXCEPT { | 1142 | get(const tuple<_Tp...>&& __t) _NOEXCEPT { |
| 1094 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | 1143 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; |
| 1095 | return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get()); | 1144 | return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get()); |
| ... | @@ -1098,22 +1147,22 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT { | ... | @@ -1098,22 +1147,22 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT { |
| 1098 | # if _LIBCPP_STD_VER >= 14 | 1147 | # if _LIBCPP_STD_VER >= 14 |
| 1099 | 1148 | ||
| 1100 | template <class _T1, class... _Args> | 1149 | template <class _T1, class... _Args> |
| 1101 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept { | 1150 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept { |
| 1102 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); | 1151 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); |
| 1103 | } | 1152 | } |
| 1104 | 1153 | ||
| 1105 | template <class _T1, class... _Args> | 1154 | template <class _T1, class... _Args> |
| 1106 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept { | 1155 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept { |
| 1107 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); | 1156 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); |
| 1108 | } | 1157 | } |
| 1109 | 1158 | ||
| 1110 | template <class _T1, class... _Args> | 1159 | template <class _T1, class... _Args> |
| 1111 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept { | 1160 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept { |
| 1112 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup)); | 1161 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup)); |
| 1113 | } | 1162 | } |
| 1114 | 1163 | ||
| 1115 | template <class _T1, class... _Args> | 1164 | template <class _T1, class... _Args> |
| 1116 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept { | 1165 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept { |
| 1117 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup)); | 1166 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup)); |
| 1118 | } | 1167 | } |
| 1119 | 1168 | ||
| ... | @@ -1122,37 +1171,22 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& _ | ... | @@ -1122,37 +1171,22 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& _ |
| 1122 | // tie | 1171 | // tie |
| 1123 | 1172 | ||
| 1124 | template <class... _Tp> | 1173 | template <class... _Tp> |
| 1125 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_Tp&... __t) _NOEXCEPT { | 1174 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_Tp&... __t) _NOEXCEPT { |
| 1126 | return tuple<_Tp&...>(__t...); | 1175 | return tuple<_Tp&...>(__t...); |
| 1127 | } | 1176 | } |
| 1128 | 1177 | ||
| 1129 | template <class... _Tp> | 1178 | template <class... _Tp> |
| 1130 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...> | 1179 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...> |
| 1131 | make_tuple(_Tp&&... __t) { | 1180 | make_tuple(_Tp&&... __t) { |
| 1132 | return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...); | 1181 | return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...); |
| 1133 | } | 1182 | } |
| 1134 | 1183 | ||
| 1135 | template <class... _Tp> | 1184 | template <class... _Tp> |
| 1136 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&&...> forward_as_tuple(_Tp&&... __t) _NOEXCEPT { | 1185 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&&...> |
| 1186 | forward_as_tuple(_Tp&&... __t) _NOEXCEPT { | ||
| 1137 | return tuple<_Tp&&...>(std::forward<_Tp>(__t)...); | 1187 | return tuple<_Tp&&...>(std::forward<_Tp>(__t)...); |
| 1138 | } | 1188 | } |
| 1139 | 1189 | ||
| 1140 | template <size_t _Ip> | ||
| 1141 | struct __tuple_equal { | ||
| 1142 | template <class _Tp, class _Up> | ||
| 1143 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __x, const _Up& __y) { | ||
| 1144 | return __tuple_equal<_Ip - 1>()(__x, __y) && std::get<_Ip - 1>(__x) == std::get<_Ip - 1>(__y); | ||
| 1145 | } | ||
| 1146 | }; | ||
| 1147 | |||
| 1148 | template <> | ||
| 1149 | struct __tuple_equal<0> { | ||
| 1150 | template <class _Tp, class _Up> | ||
| 1151 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp&, const _Up&) { | ||
| 1152 | return true; | ||
| 1153 | } | ||
| 1154 | }; | ||
| 1155 | |||
| 1156 | template <class... _Tp, class... _Up> | 1190 | template <class... _Tp, class... _Up> |
| 1157 | # if _LIBCPP_STD_VER >= 26 | 1191 | # if _LIBCPP_STD_VER >= 26 |
| 1158 | requires(__all<requires(const _Tp& __t, const _Up& __u) { | 1192 | requires(__all<requires(const _Tp& __t, const _Up& __u) { |
| ... | @@ -1162,27 +1196,19 @@ template <class... _Tp, class... _Up> | ... | @@ -1162,27 +1196,19 @@ template <class... _Tp, class... _Up> |
| 1162 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | 1196 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool |
| 1163 | operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { | 1197 | operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { |
| 1164 | static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes"); | 1198 | static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes"); |
| 1165 | return __tuple_equal<sizeof...(_Tp)>()(__x, __y); | 1199 | return std::__tuple_compare_equal<sizeof...(_Tp)>(__x, __y); |
| 1166 | } | 1200 | } |
| 1167 | 1201 | ||
| 1168 | # if _LIBCPP_STD_VER >= 20 | 1202 | # if _LIBCPP_STD_VER >= 20 |
| 1169 | 1203 | ||
| 1170 | // operator<=> | 1204 | // operator<=> |
| 1171 | 1205 | ||
| 1172 | template <class... _Tp, class... _Up, size_t... _Is> | ||
| 1173 | _LIBCPP_HIDE_FROM_ABI constexpr auto | ||
| 1174 | __tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) { | ||
| 1175 | common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal; | ||
| 1176 | static_cast<void>( | ||
| 1177 | ((__result = std::__synth_three_way(std::get<_Is>(__x), std::get<_Is>(__y)), __result != 0) || ...)); | ||
| 1178 | return __result; | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | template <class... _Tp, class... _Up> | 1206 | template <class... _Tp, class... _Up> |
| 1182 | requires(sizeof...(_Tp) == sizeof...(_Up)) | 1207 | requires(sizeof...(_Tp) == sizeof...(_Up)) |
| 1183 | _LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> | 1208 | _LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> |
| 1184 | operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { | 1209 | operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { |
| 1185 | return std::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{}); | 1210 | return std::__tuple_compare_three_way<common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>>( |
| 1211 | __x, __y, index_sequence_for<_Tp...>{}); | ||
| 1186 | } | 1212 | } |
| 1187 | 1213 | ||
| 1188 | # else // _LIBCPP_STD_VER >= 20 | 1214 | # else // _LIBCPP_STD_VER >= 20 |
| ... | @@ -1243,65 +1269,59 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { | ... | @@ -1243,65 +1269,59 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { |
| 1243 | 1269 | ||
| 1244 | // tuple_cat | 1270 | // tuple_cat |
| 1245 | 1271 | ||
| 1246 | template <class _Tp, class _Up> | 1272 | template <class... _Tuples> |
| 1247 | struct __tuple_cat_type; | 1273 | struct __tuple_cat_return_impl; |
| 1248 | 1274 | ||
| 1249 | template <class... _Ttypes, class... _Utypes> | 1275 | template <class... _Types> |
| 1250 | struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > { | 1276 | struct __tuple_cat_return_impl<tuple<_Types...>> { |
| 1251 | using type _LIBCPP_NODEBUG = tuple<_Ttypes..., _Utypes...>; | 1277 | using type _LIBCPP_NODEBUG = tuple<_Types...>; |
| 1252 | }; | 1278 | }; |
| 1253 | 1279 | ||
| 1254 | template <class _ResultTuple, bool _Is_Tuple0TupleLike, class... _Tuples> | 1280 | template <class... _Types0, class... _Types1, class... _Tuples> |
| 1255 | struct __tuple_cat_return_1 {}; | 1281 | struct __tuple_cat_return_impl<tuple<_Types0...>, tuple<_Types1...>, _Tuples...> |
| 1282 | : __tuple_cat_return_impl<tuple<_Types0..., _Types1...>, _Tuples...> {}; | ||
| 1256 | 1283 | ||
| 1257 | template <class... _Types, class _Tuple0> | 1284 | template <class... _Types0, class _Tp, class _Up, class... _Tuples> |
| 1258 | struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0> { | 1285 | struct __tuple_cat_return_impl<tuple<_Types0...>, pair<_Tp, _Up>, _Tuples...> |
| 1259 | using type _LIBCPP_NODEBUG = | 1286 | : __tuple_cat_return_impl<tuple<_Types0..., _Tp, _Up>, _Tuples...> {}; |
| 1260 | typename __tuple_cat_type< tuple<_Types...>, | ||
| 1261 | typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type >::type; | ||
| 1262 | }; | ||
| 1263 | |||
| 1264 | template <class... _Types, class _Tuple0, class _Tuple1, class... _Tuples> | ||
| 1265 | struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...> | ||
| 1266 | : public __tuple_cat_return_1< | ||
| 1267 | typename __tuple_cat_type< tuple<_Types...>, | ||
| 1268 | typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type >::type, | ||
| 1269 | __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value, | ||
| 1270 | _Tuple1, | ||
| 1271 | _Tuples...> {}; | ||
| 1272 | 1287 | ||
| 1273 | template <class... _Tuples> | 1288 | template <class, class, class> |
| 1274 | struct __tuple_cat_return; | 1289 | struct __tuple_cat_array; |
| 1275 | 1290 | ||
| 1276 | template <class _Tuple0, class... _Tuples> | 1291 | template <class... _Types, class _ValueT, size_t... _Indices> |
| 1277 | struct __tuple_cat_return<_Tuple0, _Tuples...> | 1292 | struct __tuple_cat_array<tuple<_Types...>, _ValueT, __index_sequence<_Indices...>> { |
| 1278 | : public __tuple_cat_return_1<tuple<>, | 1293 | template <size_t> |
| 1279 | __tuple_like_ext<__libcpp_remove_reference_t<_Tuple0> >::value, | 1294 | using __value_type _LIBCPP_NODEBUG = _ValueT; |
| 1280 | _Tuple0, | ||
| 1281 | _Tuples...> {}; | ||
| 1282 | 1295 | ||
| 1283 | template <> | 1296 | using type _LIBCPP_NODEBUG = tuple<_Types..., __value_type<_Indices>...>; |
| 1284 | struct __tuple_cat_return<> { | ||
| 1285 | using type _LIBCPP_NODEBUG = tuple<>; | ||
| 1286 | }; | 1297 | }; |
| 1287 | 1298 | ||
| 1288 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<> tuple_cat() { return tuple<>(); } | 1299 | template <class... _Types, class _ValueT, size_t _Np, class... _Tuples> |
| 1300 | struct __tuple_cat_return_impl<tuple<_Types...>, array<_ValueT, _Np>, _Tuples...> | ||
| 1301 | : __tuple_cat_return_impl<typename __tuple_cat_array<tuple<_Types...>, _ValueT, __make_index_sequence<_Np>>::type, | ||
| 1302 | _Tuples...> {}; | ||
| 1303 | |||
| 1304 | template <class... _Tuples> | ||
| 1305 | using __tuple_cat_return_t _LIBCPP_NODEBUG = | ||
| 1306 | typename __tuple_cat_return_impl<tuple<>, __remove_cvref_t<_Tuples>...>::type; | ||
| 1307 | |||
| 1308 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<> tuple_cat() { return tuple<>(); } | ||
| 1289 | 1309 | ||
| 1290 | template <class _Rp, class _Indices, class _Tuple0, class... _Tuples> | 1310 | template <class _Rp, class _Indices, class _Tuple0, class... _Tuples> |
| 1291 | struct __tuple_cat_return_ref_imp; | 1311 | struct __tuple_cat_return_ref_imp; |
| 1292 | 1312 | ||
| 1293 | template <class... _Types, size_t... _I0, class _Tuple0> | 1313 | template <class... _Types, size_t... _I0, class _Tuple0> |
| 1294 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> { | 1314 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __index_sequence<_I0...>, _Tuple0> { |
| 1295 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; | 1315 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; |
| 1296 | typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type; | 1316 | typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type; |
| 1297 | }; | 1317 | }; |
| 1298 | 1318 | ||
| 1299 | template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples> | 1319 | template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples> |
| 1300 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...> | 1320 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __index_sequence<_I0...>, _Tuple0, _Tuple1, _Tuples...> |
| 1301 | : public __tuple_cat_return_ref_imp< | 1321 | : public __tuple_cat_return_ref_imp< |
| 1302 | tuple<_Types..., | 1322 | tuple<_Types..., |
| 1303 | __copy_cvref_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>, | 1323 | __copy_cvref_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>, |
| 1304 | typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type, | 1324 | __make_index_sequence<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>, |
| 1305 | _Tuple1, | 1325 | _Tuple1, |
| 1306 | _Tuples...> {}; | 1326 | _Tuples...> {}; |
| 1307 | 1327 | ||
| ... | @@ -1309,7 +1329,7 @@ template <class _Tuple0, class... _Tuples> | ... | @@ -1309,7 +1329,7 @@ template <class _Tuple0, class... _Tuples> |
| 1309 | struct __tuple_cat_return_ref | 1329 | struct __tuple_cat_return_ref |
| 1310 | : public __tuple_cat_return_ref_imp< | 1330 | : public __tuple_cat_return_ref_imp< |
| 1311 | tuple<>, | 1331 | tuple<>, |
| 1312 | typename __make_tuple_indices< tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value >::type, | 1332 | __make_index_sequence< tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value >, |
| 1313 | _Tuple0, | 1333 | _Tuple0, |
| 1314 | _Tuples...> {}; | 1334 | _Tuples...> {}; |
| 1315 | 1335 | ||
| ... | @@ -1317,7 +1337,7 @@ template <class _Types, class _I0, class _J0> | ... | @@ -1317,7 +1337,7 @@ template <class _Types, class _I0, class _J0> |
| 1317 | struct __tuple_cat; | 1337 | struct __tuple_cat; |
| 1318 | 1338 | ||
| 1319 | template <class... _Types, size_t... _I0, size_t... _J0> | 1339 | template <class... _Types, size_t... _I0, size_t... _J0> |
| 1320 | struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > { | 1340 | struct __tuple_cat<tuple<_Types...>, __index_sequence<_I0...>, __index_sequence<_J0...>> { |
| 1321 | template <class _Tuple0> | 1341 | template <class _Tuple0> |
| 1322 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | 1342 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 1323 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type | 1343 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type |
| ... | @@ -1335,8 +1355,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J | ... | @@ -1335,8 +1355,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1335 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; | 1355 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; |
| 1336 | using _T1 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple1>; | 1356 | using _T1 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple1>; |
| 1337 | return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>, | 1357 | return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>, |
| 1338 | typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type, | 1358 | __make_index_sequence<sizeof...(_Types) + tuple_size<_T0>::value>, |
| 1339 | typename __make_tuple_indices<tuple_size<_T1>::value>::type>()( | 1359 | __make_index_sequence<tuple_size<_T1>::value>>()( |
| 1340 | std::forward_as_tuple( | 1360 | std::forward_as_tuple( |
| 1341 | std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...), | 1361 | std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...), |
| 1342 | std::forward<_Tuple1>(__t1), | 1362 | std::forward<_Tuple1>(__t1), |
| ... | @@ -1346,21 +1366,21 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J | ... | @@ -1346,21 +1366,21 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1346 | 1366 | ||
| 1347 | template <class _TupleDst, class _TupleSrc, size_t... _Indices> | 1367 | template <class _TupleDst, class _TupleSrc, size_t... _Indices> |
| 1348 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _TupleDst | 1368 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _TupleDst |
| 1349 | __tuple_cat_select_element_wise(_TupleSrc&& __src, __tuple_indices<_Indices...>) { | 1369 | __tuple_cat_select_element_wise(_TupleSrc&& __src, __index_sequence<_Indices...>) { |
| 1350 | static_assert(tuple_size<_TupleDst>::value == tuple_size<_TupleSrc>::value, | 1370 | static_assert(tuple_size<_TupleDst>::value == tuple_size<_TupleSrc>::value, |
| 1351 | "misuse of __tuple_cat_select_element_wise with tuples of different sizes"); | 1371 | "misuse of __tuple_cat_select_element_wise with tuples of different sizes"); |
| 1352 | return _TupleDst(std::get<_Indices>(std::forward<_TupleSrc>(__src))...); | 1372 | return _TupleDst(std::get<_Indices>(std::forward<_TupleSrc>(__src))...); |
| 1353 | } | 1373 | } |
| 1354 | 1374 | ||
| 1355 | template <class _Tuple0, class... _Tuples> | 1375 | template <class _Tuple0, class... _Tuples> |
| 1356 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __tuple_cat_return<_Tuple0, _Tuples...>::type | 1376 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_cat_return_t<_Tuple0, _Tuples...> |
| 1357 | tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { | 1377 | tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { |
| 1358 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; | 1378 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; |
| 1359 | using _TRet _LIBCPP_NODEBUG = typename __tuple_cat_return<_Tuple0, _Tuples...>::type; | 1379 | using _TRet _LIBCPP_NODEBUG = __tuple_cat_return_t<_Tuple0, _Tuples...>; |
| 1360 | using _T0Indices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_T0>::value>::type; | 1380 | using _T0Indices _LIBCPP_NODEBUG = __make_index_sequence<tuple_size<_T0>::value>; |
| 1361 | using _TRetIndices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_TRet>::value>::type; | 1381 | using _TRetIndices _LIBCPP_NODEBUG = __make_index_sequence<tuple_size<_TRet>::value>; |
| 1362 | return std::__tuple_cat_select_element_wise<_TRet>( | 1382 | return std::__tuple_cat_select_element_wise<_TRet>( |
| 1363 | __tuple_cat<tuple<>, __tuple_indices<>, _T0Indices>()( | 1383 | __tuple_cat<tuple<>, __index_sequence<>, _T0Indices>()( |
| 1364 | tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...), | 1384 | tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...), |
| 1365 | _TRetIndices()); | 1385 | _TRetIndices()); |
| 1366 | } | 1386 | } |
| ... | @@ -1376,7 +1396,7 @@ struct uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; | ... | @@ -1376,7 +1396,7 @@ struct uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; |
| 1376 | // clang-format off | 1396 | // clang-format off |
| 1377 | template <class _Fn, class _Tuple, size_t... _Id> | 1397 | template <class _Fn, class _Tuple, size_t... _Id> |
| 1378 | inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) | 1398 | inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) |
| 1379 | __apply_tuple_impl(_Fn&& __f, _Tuple&& __t, __tuple_indices<_Id...>) | 1399 | __apply_tuple_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Id...>) |
| 1380 | _LIBCPP_NOEXCEPT_RETURN(std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...)) | 1400 | _LIBCPP_NOEXCEPT_RETURN(std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...)) |
| 1381 | 1401 | ||
| 1382 | template <class _Fn, class _Tuple> | 1402 | template <class _Fn, class _Tuple> |
| ... | @@ -1384,28 +1404,29 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& | ... | @@ -1384,28 +1404,29 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& |
| 1384 | _LIBCPP_NOEXCEPT_RETURN(std::__apply_tuple_impl( | 1404 | _LIBCPP_NOEXCEPT_RETURN(std::__apply_tuple_impl( |
| 1385 | std::forward<_Fn>(__f), | 1405 | std::forward<_Fn>(__f), |
| 1386 | std::forward<_Tuple>(__t), | 1406 | std::forward<_Tuple>(__t), |
| 1387 | typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})) | 1407 | make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>())) |
| 1388 | 1408 | ||
| 1389 | #if _LIBCPP_STD_VER >= 20 | 1409 | #if _LIBCPP_STD_VER >= 20 |
| 1390 | template <class _Tp, class _Tuple, size_t... _Idx> | 1410 | template <class _Tp, class _Tuple, size_t... _Idx> |
| 1391 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) | 1411 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>) |
| 1392 | noexcept(noexcept(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))) | 1412 | noexcept(noexcept(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))) |
| 1393 | requires is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...> { | 1413 | requires is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...> { |
| 1394 | return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); | 1414 | return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); |
| 1395 | } | 1415 | } |
| 1396 | #else | 1416 | #else |
| 1397 | template <class _Tp, class _Tuple, size_t... _Idx> | 1417 | template <class _Tp, class _Tuple, size_t... _Idx> |
| 1398 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>, | 1418 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>, |
| 1399 | enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...>> * = nullptr) | 1419 | enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...>> * = nullptr) |
| 1400 | _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)) | 1420 | _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)) |
| 1401 | #endif // _LIBCPP_STD_VER >= 20 | 1421 | #endif // _LIBCPP_STD_VER >= 20 |
| 1422 | #undef _LIBCPP_NOEXCEPT_RETURN | ||
| 1402 | 1423 | ||
| 1403 | template <class _Tp, class _Tuple, | 1424 | template <class _Tp, class _Tuple, |
| 1404 | class _Seq = typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type, class = void> | 1425 | class _Seq = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>, class = void> |
| 1405 | inline constexpr bool __can_make_from_tuple = false; | 1426 | inline constexpr bool __can_make_from_tuple = false; |
| 1406 | 1427 | ||
| 1407 | template <class _Tp, class _Tuple, size_t... _Idx> | 1428 | template <class _Tp, class _Tuple, size_t... _Idx> |
| 1408 | inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, __tuple_indices<_Idx...>, | 1429 | inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, index_sequence<_Idx...>, |
| 1409 | enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::declval<_Tuple>()))...>>> = true; | 1430 | enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::declval<_Tuple>()))...>>> = true; |
| 1410 | 1431 | ||
| 1411 | // Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9, | 1432 | // Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9, |
| ... | @@ -1418,10 +1439,19 @@ template <class _Tp, class _Tuple> | ... | @@ -1418,10 +1439,19 @@ template <class _Tp, class _Tuple> |
| 1418 | #else | 1439 | #else |
| 1419 | template <class _Tp, class _Tuple, class = enable_if_t<__can_make_from_tuple<_Tp, _Tuple>>> // strengthen | 1440 | template <class _Tp, class _Tuple, class = enable_if_t<__can_make_from_tuple<_Tp, _Tuple>>> // strengthen |
| 1420 | #endif // _LIBCPP_STD_VER >= 20 | 1441 | #endif // _LIBCPP_STD_VER >= 20 |
| 1421 | inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t) | 1442 | |
| 1422 | _LIBCPP_NOEXCEPT_RETURN(std::__make_from_tuple_impl<_Tp>( | 1443 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t) |
| 1423 | std::forward<_Tuple>(__t), typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})) | 1444 | noexcept(noexcept(std::__make_from_tuple_impl<_Tp>(std::forward<_Tuple>(__t), |
| 1424 | # undef _LIBCPP_NOEXCEPT_RETURN | 1445 | make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>()))) { |
| 1446 | #if _LIBCPP_STD_VER >= 23 | ||
| 1447 | if constexpr (tuple_size_v<remove_reference_t<_Tuple>> == 1) { | ||
| 1448 | static_assert(!std::reference_constructs_from_temporary_v<_Tp, decltype(std::get<0>(std::declval<_Tuple>()))>, | ||
| 1449 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); | ||
| 1450 | } | ||
| 1451 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 1452 | return std::__make_from_tuple_impl<_Tp>( | ||
| 1453 | std::forward<_Tuple>(__t), make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>()); | ||
| 1454 | } | ||
| 1425 | 1455 | ||
| 1426 | # endif // _LIBCPP_STD_VER >= 17 | 1456 | # endif // _LIBCPP_STD_VER >= 17 |
| 1427 | 1457 |
lib/libcxx/include/type_traits+8-2| ... | @@ -454,6 +454,10 @@ namespace std | ... | @@ -454,6 +454,10 @@ namespace std |
| 454 | template<class B> inline constexpr bool negation_v | 454 | template<class B> inline constexpr bool negation_v |
| 455 | = negation<B>::value; // since C++17 | 455 | = negation<B>::value; // since C++17 |
| 456 | 456 | ||
| 457 | // [meta.const.eval], constant evaluation context | ||
| 458 | constexpr bool is_constant_evaluated() noexcept; // C++20 | ||
| 459 | template<class T> | ||
| 460 | consteval bool is_within_lifetime(const T*) noexcept; // C++26 | ||
| 457 | } | 461 | } |
| 458 | 462 | ||
| 459 | */ | 463 | */ |
| ... | @@ -546,9 +550,7 @@ namespace std | ... | @@ -546,9 +550,7 @@ namespace std |
| 546 | 550 | ||
| 547 | # if _LIBCPP_STD_VER >= 20 | 551 | # if _LIBCPP_STD_VER >= 20 |
| 548 | # include <__type_traits/common_reference.h> | 552 | # include <__type_traits/common_reference.h> |
| 549 | # include <__type_traits/is_bounded_array.h> | ||
| 550 | # include <__type_traits/is_constant_evaluated.h> | 553 | # include <__type_traits/is_constant_evaluated.h> |
| 551 | # include <__type_traits/is_unbounded_array.h> | ||
| 552 | # include <__type_traits/type_identity.h> | 554 | # include <__type_traits/type_identity.h> |
| 553 | # include <__type_traits/unwrap_ref.h> | 555 | # include <__type_traits/unwrap_ref.h> |
| 554 | # endif | 556 | # endif |
| ... | @@ -559,6 +561,10 @@ namespace std | ... | @@ -559,6 +561,10 @@ namespace std |
| 559 | # include <__type_traits/reference_converts_from_temporary.h> | 561 | # include <__type_traits/reference_converts_from_temporary.h> |
| 560 | # endif | 562 | # endif |
| 561 | 563 | ||
| 564 | # if _LIBCPP_STD_VER >= 26 | ||
| 565 | # include <__type_traits/is_within_lifetime.h> | ||
| 566 | # endif | ||
| 567 | |||
| 562 | # include <version> | 568 | # include <version> |
| 563 | 569 | ||
| 564 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 570 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/typeindex+5-3| ... | @@ -86,8 +86,8 @@ public: | ... | @@ -86,8 +86,8 @@ public: |
| 86 | } | 86 | } |
| 87 | # endif | 87 | # endif |
| 88 | 88 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __t_->hash_code(); } | 89 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __t_->hash_code(); } |
| 90 | _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __t_->name(); } | 90 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __t_->name(); } |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | template <class _Tp> | 93 | template <class _Tp> |
| ... | @@ -95,7 +95,9 @@ struct hash; | ... | @@ -95,7 +95,9 @@ struct hash; |
| 95 | 95 | ||
| 96 | template <> | 96 | template <> |
| 97 | struct hash<type_index> : public __unary_function<type_index, size_t> { | 97 | struct hash<type_index> : public __unary_function<type_index, size_t> { |
| 98 | _LIBCPP_HIDE_FROM_ABI size_t operator()(type_index __index) const _NOEXCEPT { return __index.hash_code(); } | 98 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t operator()(type_index __index) const _NOEXCEPT { |
| 99 | return __index.hash_code(); | ||
| 100 | } | ||
| 99 | }; | 101 | }; |
| 100 | 102 | ||
| 101 | _LIBCPP_END_NAMESPACE_STD | 103 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/typeinfo+92-89| ... | @@ -95,11 +95,13 @@ class _LIBCPP_EXPORTED_FROM_ABI type_info { | ... | @@ -95,11 +95,13 @@ class _LIBCPP_EXPORTED_FROM_ABI type_info { |
| 95 | public: | 95 | public: |
| 96 | virtual ~type_info(); | 96 | virtual ~type_info(); |
| 97 | 97 | ||
| 98 | const char* name() const _NOEXCEPT; | 98 | [[__nodiscard__]] const char* name() const _NOEXCEPT; |
| 99 | 99 | ||
| 100 | _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT { return __compare(__arg) < 0; } | 100 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT { |
| 101 | return __compare(__arg) < 0; | ||
| 102 | } | ||
| 101 | 103 | ||
| 102 | size_t hash_code() const _NOEXCEPT; | 104 | [[__nodiscard__]] size_t hash_code() const _NOEXCEPT; |
| 103 | 105 | ||
| 104 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT { | 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT { |
| 105 | // When evaluated in a constant expression, both type infos simply can't come | 107 | // When evaluated in a constant expression, both type infos simply can't come |
| ... | @@ -186,99 +188,99 @@ public: | ... | @@ -186,99 +188,99 @@ public: |
| 186 | # endif | 188 | # endif |
| 187 | # endif | 189 | # endif |
| 188 | 190 | ||
| 189 | struct __type_info_implementations { | 191 | namespace __type_info_implementations { |
| 190 | struct __string_impl_base { | 192 | struct __string_impl_base { |
| 191 | typedef const char* __type_name_t; | 193 | typedef const char* __type_name_t; |
| 192 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char* | 194 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char* |
| 193 | __type_name_to_string(__type_name_t __v) _NOEXCEPT { | 195 | __type_name_to_string(__type_name_t __v) _NOEXCEPT { |
| 194 | return __v; | 196 | return __v; |
| 195 | } | 197 | } |
| 196 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t | 198 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t |
| 197 | __string_to_type_name(const char* __v) _NOEXCEPT { | 199 | __string_to_type_name(const char* __v) _NOEXCEPT { |
| 198 | return __v; | 200 | return __v; |
| 199 | } | 201 | } |
| 200 | }; | 202 | }; |
| 201 | 203 | ||
| 202 | struct __unique_impl : __string_impl_base { | 204 | struct __unique_impl : __string_impl_base { |
| 203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT { | 205 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT { |
| 204 | return reinterpret_cast<size_t>(__v); | 206 | return reinterpret_cast<size_t>(__v); |
| 205 | } | 207 | } |
| 206 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | 208 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { |
| 207 | return __lhs == __rhs; | 209 | return __lhs == __rhs; |
| 208 | } | 210 | } |
| 209 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | 211 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { |
| 210 | return __lhs < __rhs; | 212 | return __lhs < __rhs; |
| 211 | } | 213 | } |
| 212 | }; | 214 | }; |
| 213 | |||
| 214 | struct __non_unique_impl : __string_impl_base { | ||
| 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT { | ||
| 216 | size_t __hash = 5381; | ||
| 217 | while (unsigned char __c = static_cast<unsigned char>(*__ptr++)) | ||
| 218 | __hash = (__hash * 33) ^ __c; | ||
| 219 | return __hash; | ||
| 220 | } | ||
| 221 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | ||
| 222 | return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0; | ||
| 223 | } | ||
| 224 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | ||
| 225 | return __builtin_strcmp(__lhs, __rhs) < 0; | ||
| 226 | } | ||
| 227 | }; | ||
| 228 | 215 | ||
| 229 | struct __non_unique_arm_rtti_bit_impl { | 216 | struct __non_unique_impl : __string_impl_base { |
| 230 | typedef uintptr_t __type_name_t; | 217 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT { |
| 218 | size_t __hash = 5381; | ||
| 219 | while (unsigned char __c = static_cast<unsigned char>(*__ptr++)) | ||
| 220 | __hash = (__hash * 33) ^ __c; | ||
| 221 | return __hash; | ||
| 222 | } | ||
| 223 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | ||
| 224 | return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0; | ||
| 225 | } | ||
| 226 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | ||
| 227 | return __builtin_strcmp(__lhs, __rhs) < 0; | ||
| 228 | } | ||
| 229 | }; | ||
| 231 | 230 | ||
| 232 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT { | 231 | struct __non_unique_arm_rtti_bit_impl { |
| 233 | return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value); | 232 | typedef uintptr_t __type_name_t; |
| 234 | } | ||
| 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT { | ||
| 236 | return reinterpret_cast<__type_name_t>(__v); | ||
| 237 | } | ||
| 238 | 233 | ||
| 239 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT { | 234 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT { |
| 240 | if (__is_type_name_unique(__v)) | 235 | return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value); |
| 241 | return __v; | 236 | } |
| 242 | return __non_unique_impl::__hash(__type_name_to_string(__v)); | 237 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT { |
| 243 | } | 238 | return reinterpret_cast<__type_name_t>(__v); |
| 244 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | 239 | } |
| 245 | if (__lhs == __rhs) | ||
| 246 | return true; | ||
| 247 | if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs)) | ||
| 248 | // Either both are unique and have a different address, or one of them | ||
| 249 | // is unique and the other one isn't. In both cases they are unequal. | ||
| 250 | return false; | ||
| 251 | return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0; | ||
| 252 | } | ||
| 253 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | ||
| 254 | if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs)) | ||
| 255 | return __lhs < __rhs; | ||
| 256 | return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0; | ||
| 257 | } | ||
| 258 | 240 | ||
| 259 | private: | 241 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT { |
| 260 | // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when | 242 | if (__is_type_name_unique(__v)) |
| 261 | // this implementation is actually used. | 243 | return __v; |
| 262 | typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))> | 244 | return __non_unique_impl::__hash(__type_name_to_string(__v)); |
| 263 | __non_unique_rtti_bit; | 245 | } |
| 246 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | ||
| 247 | if (__lhs == __rhs) | ||
| 248 | return true; | ||
| 249 | if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs)) | ||
| 250 | // Either both are unique and have a different address, or one of them | ||
| 251 | // is unique and the other one isn't. In both cases they are unequal. | ||
| 252 | return false; | ||
| 253 | return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0; | ||
| 254 | } | ||
| 255 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT { | ||
| 256 | if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs)) | ||
| 257 | return __lhs < __rhs; | ||
| 258 | return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0; | ||
| 259 | } | ||
| 264 | 260 | ||
| 265 | _LIBCPP_HIDE_FROM_ABI static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT { | 261 | private: |
| 266 | return !(__lhs & __non_unique_rtti_bit::value); | 262 | // The unique bit is the top bit. It is expected that __type_name_t is 64 bits when |
| 267 | } | 263 | // this implementation is actually used. |
| 268 | }; | 264 | typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))> |
| 265 | __non_unique_rtti_bit; | ||
| 266 | |||
| 267 | _LIBCPP_HIDE_FROM_ABI static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT { | ||
| 268 | return !(__lhs & __non_unique_rtti_bit::value); | ||
| 269 | } | ||
| 270 | }; | ||
| 269 | 271 | ||
| 270 | typedef | 272 | typedef |
| 271 | # if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1 | 273 | # if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1 |
| 272 | __unique_impl | 274 | __unique_impl |
| 273 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2 | 275 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2 |
| 274 | __non_unique_impl | 276 | __non_unique_impl |
| 275 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3 | 277 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3 |
| 276 | __non_unique_arm_rtti_bit_impl | 278 | __non_unique_arm_rtti_bit_impl |
| 277 | # else | 279 | # else |
| 278 | # error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION | 280 | # error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION |
| 279 | # endif | 281 | # endif |
| 280 | __impl; | 282 | __impl; |
| 281 | }; | 283 | } // namespace __type_info_implementations |
| 282 | 284 | ||
| 283 | # if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__) | 285 | # if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__) |
| 284 | # if __has_feature(ptrauth_type_info_vtable_pointer_discrimination) | 286 | # if __has_feature(ptrauth_type_info_vtable_pointer_discrimination) |
| ... | @@ -306,14 +308,15 @@ protected: | ... | @@ -306,14 +308,15 @@ protected: |
| 306 | 308 | ||
| 307 | public: | 309 | public: |
| 308 | virtual ~type_info(); | 310 | virtual ~type_info(); |
| 311 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { | ||
| 312 | return __impl::__type_name_to_string(__type_name); | ||
| 313 | } | ||
| 309 | 314 | ||
| 310 | _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __impl::__type_name_to_string(__type_name); } | 315 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT { |
| 311 | |||
| 312 | _LIBCPP_HIDE_FROM_ABI bool before(const type_info& __arg) const _NOEXCEPT { | ||
| 313 | return __impl::__lt(__type_name, __arg.__type_name); | 316 | return __impl::__lt(__type_name, __arg.__type_name); |
| 314 | } | 317 | } |
| 315 | 318 | ||
| 316 | _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); } | 319 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); } |
| 317 | 320 | ||
| 318 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT { | 321 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT { |
| 319 | // When evaluated in a constant expression, both type infos simply can't come | 322 | // When evaluated in a constant expression, both type infos simply can't come |
| ... | @@ -336,7 +339,7 @@ public: | ... | @@ -336,7 +339,7 @@ public: |
| 336 | _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default; | 339 | _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default; |
| 337 | _LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default; | 340 | _LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default; |
| 338 | ~bad_cast() _NOEXCEPT override; | 341 | ~bad_cast() _NOEXCEPT override; |
| 339 | const char* what() const _NOEXCEPT override; | 342 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 340 | }; | 343 | }; |
| 341 | 344 | ||
| 342 | class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception { | 345 | class _LIBCPP_EXPORTED_FROM_ABI bad_typeid : public exception { |
| ... | @@ -345,7 +348,7 @@ public: | ... | @@ -345,7 +348,7 @@ public: |
| 345 | _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default; | 348 | _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default; |
| 346 | _LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default; | 349 | _LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default; |
| 347 | ~bad_typeid() _NOEXCEPT override; | 350 | ~bad_typeid() _NOEXCEPT override; |
| 348 | const char* what() const _NOEXCEPT override; | 351 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 349 | }; | 352 | }; |
| 350 | 353 | ||
| 351 | } // namespace std | 354 | } // namespace std |
lib/libcxx/include/unordered_map+179-304| ... | @@ -600,6 +600,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> | ... | @@ -600,6 +600,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 600 | # include <__memory/addressof.h> | 600 | # include <__memory/addressof.h> |
| 601 | # include <__memory/allocator.h> | 601 | # include <__memory/allocator.h> |
| 602 | # include <__memory/allocator_traits.h> | 602 | # include <__memory/allocator_traits.h> |
| 603 | # include <__memory/compressed_pair.h> | ||
| 603 | # include <__memory/pointer_traits.h> | 604 | # include <__memory/pointer_traits.h> |
| 604 | # include <__memory/unique_ptr.h> | 605 | # include <__memory/unique_ptr.h> |
| 605 | # include <__memory_resource/polymorphic_allocator.h> | 606 | # include <__memory_resource/polymorphic_allocator.h> |
| ... | @@ -643,34 +644,9 @@ _LIBCPP_PUSH_MACROS | ... | @@ -643,34 +644,9 @@ _LIBCPP_PUSH_MACROS |
| 643 | 644 | ||
| 644 | _LIBCPP_BEGIN_NAMESPACE_STD | 645 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 645 | 646 | ||
| 646 | template <class _Key, | ||
| 647 | class _Cp, | ||
| 648 | class _Hash, | ||
| 649 | class _Pred, | ||
| 650 | bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value> | ||
| 651 | class __unordered_map_hasher : private _Hash { | ||
| 652 | public: | ||
| 653 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher() _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) : _Hash() {} | ||
| 654 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) | ||
| 655 | : _Hash(__h) {} | ||
| 656 | _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return *this; } | ||
| 657 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return static_cast<const _Hash&>(*this)(__x.first); } | ||
| 658 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); } | ||
| 659 | # if _LIBCPP_STD_VER >= 20 | ||
| 660 | template <typename _K2> | ||
| 661 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const { | ||
| 662 | return static_cast<const _Hash&>(*this)(__x); | ||
| 663 | } | ||
| 664 | # endif | ||
| 665 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) { | ||
| 666 | using std::swap; | ||
| 667 | swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y)); | ||
| 668 | } | ||
| 669 | }; | ||
| 670 | |||
| 671 | template <class _Key, class _Cp, class _Hash, class _Pred> | 647 | template <class _Key, class _Cp, class _Hash, class _Pred> |
| 672 | class __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false> { | 648 | class __unordered_map_hasher { |
| 673 | _Hash __hash_; | 649 | _LIBCPP_COMPRESSED_ELEMENT(_Hash, __hash_); |
| 674 | 650 | ||
| 675 | public: | 651 | public: |
| 676 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher() _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) | 652 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher() _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) |
| ... | @@ -692,60 +668,16 @@ public: | ... | @@ -692,60 +668,16 @@ public: |
| 692 | } | 668 | } |
| 693 | }; | 669 | }; |
| 694 | 670 | ||
| 695 | template <class _Key, class _Cp, class _Hash, class _Pred, bool __b> | 671 | template <class _Key, class _Cp, class _Hash, class _Pred> |
| 696 | inline _LIBCPP_HIDE_FROM_ABI void | 672 | inline _LIBCPP_HIDE_FROM_ABI void |
| 697 | swap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x, | 673 | swap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred>& __x, __unordered_map_hasher<_Key, _Cp, _Hash, _Pred>& __y) |
| 698 | __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 674 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 699 | __x.swap(__y); | 675 | __x.swap(__y); |
| 700 | } | 676 | } |
| 701 | 677 | ||
| 702 | template <class _Key, | ||
| 703 | class _Cp, | ||
| 704 | class _Pred, | ||
| 705 | class _Hash, | ||
| 706 | bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value> | ||
| 707 | class __unordered_map_equal : private _Pred { | ||
| 708 | public: | ||
| 709 | _LIBCPP_HIDE_FROM_ABI __unordered_map_equal() _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) : _Pred() {} | ||
| 710 | _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value) | ||
| 711 | : _Pred(__p) {} | ||
| 712 | _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return *this; } | ||
| 713 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { | ||
| 714 | return static_cast<const _Pred&>(*this)(__x.first, __y.first); | ||
| 715 | } | ||
| 716 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { | ||
| 717 | return static_cast<const _Pred&>(*this)(__x.first, __y); | ||
| 718 | } | ||
| 719 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { | ||
| 720 | return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first); | ||
| 721 | } | ||
| 722 | # if _LIBCPP_STD_VER >= 20 | ||
| 723 | template <typename _K2> | ||
| 724 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const { | ||
| 725 | return static_cast<const _Pred&>(*this)(__x.first, __y); | ||
| 726 | } | ||
| 727 | template <typename _K2> | ||
| 728 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const { | ||
| 729 | return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first); | ||
| 730 | } | ||
| 731 | template <typename _K2> | ||
| 732 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _K2& __y) const { | ||
| 733 | return static_cast<const _Pred&>(*this)(__x, __y); | ||
| 734 | } | ||
| 735 | template <typename _K2> | ||
| 736 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const { | ||
| 737 | return static_cast<const _Pred&>(*this)(__x, __y); | ||
| 738 | } | ||
| 739 | # endif | ||
| 740 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) { | ||
| 741 | using std::swap; | ||
| 742 | swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y)); | ||
| 743 | } | ||
| 744 | }; | ||
| 745 | |||
| 746 | template <class _Key, class _Cp, class _Pred, class _Hash> | 678 | template <class _Key, class _Cp, class _Pred, class _Hash> |
| 747 | class __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false> { | 679 | class __unordered_map_equal { |
| 748 | _Pred __pred_; | 680 | _LIBCPP_COMPRESSED_ELEMENT(_Pred, __pred_); |
| 749 | 681 | ||
| 750 | public: | 682 | public: |
| 751 | _LIBCPP_HIDE_FROM_ABI __unordered_map_equal() _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) | 683 | _LIBCPP_HIDE_FROM_ABI __unordered_map_equal() _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) |
| ... | @@ -780,9 +712,9 @@ public: | ... | @@ -780,9 +712,9 @@ public: |
| 780 | } | 712 | } |
| 781 | }; | 713 | }; |
| 782 | 714 | ||
| 783 | template <class _Key, class _Cp, class _Pred, class _Hash, bool __b> | 715 | template <class _Key, class _Cp, class _Pred, class _Hash> |
| 784 | inline _LIBCPP_HIDE_FROM_ABI void | 716 | inline _LIBCPP_HIDE_FROM_ABI void |
| 785 | swap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x, __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y) | 717 | swap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash>& __x, __unordered_map_equal<_Key, _Cp, _Pred, _Hash>& __y) |
| 786 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 718 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 787 | __x.swap(__y); | 719 | __x.swap(__y); |
| 788 | } | 720 | } |
| ... | @@ -844,10 +776,10 @@ class __hash_map_iterator { | ... | @@ -844,10 +776,10 @@ class __hash_map_iterator { |
| 844 | 776 | ||
| 845 | public: | 777 | public: |
| 846 | typedef forward_iterator_tag iterator_category; | 778 | typedef forward_iterator_tag iterator_category; |
| 847 | typedef typename _NodeTypes::__map_value_type value_type; | 779 | using value_type = typename _HashIterator::value_type; |
| 848 | typedef typename _NodeTypes::difference_type difference_type; | 780 | using difference_type = ptrdiff_t; |
| 849 | typedef value_type& reference; | 781 | typedef value_type& reference; |
| 850 | typedef typename _NodeTypes::__map_value_type_pointer pointer; | 782 | using pointer = typename _HashIterator::pointer; |
| 851 | 783 | ||
| 852 | _LIBCPP_HIDE_FROM_ABI __hash_map_iterator() _NOEXCEPT {} | 784 | _LIBCPP_HIDE_FROM_ABI __hash_map_iterator() _NOEXCEPT {} |
| 853 | 785 | ||
| ... | @@ -895,10 +827,10 @@ class __hash_map_const_iterator { | ... | @@ -895,10 +827,10 @@ class __hash_map_const_iterator { |
| 895 | 827 | ||
| 896 | public: | 828 | public: |
| 897 | typedef forward_iterator_tag iterator_category; | 829 | typedef forward_iterator_tag iterator_category; |
| 898 | typedef typename _NodeTypes::__map_value_type value_type; | 830 | using value_type = typename _HashIterator::value_type; |
| 899 | typedef typename _NodeTypes::difference_type difference_type; | 831 | using difference_type = ptrdiff_t; |
| 900 | typedef const value_type& reference; | 832 | typedef const value_type& reference; |
| 901 | typedef typename _NodeTypes::__const_map_value_type_pointer pointer; | 833 | using pointer = typename _HashIterator::pointer; |
| 902 | 834 | ||
| 903 | _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator() _NOEXCEPT {} | 835 | _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator() _NOEXCEPT {} |
| 904 | 836 | ||
| ... | @@ -972,9 +904,6 @@ private: | ... | @@ -972,9 +904,6 @@ private: |
| 972 | 904 | ||
| 973 | __table __table_; | 905 | __table __table_; |
| 974 | 906 | ||
| 975 | typedef typename __table::_NodeTypes _NodeTypes; | ||
| 976 | typedef typename __table::__node_pointer __node_pointer; | ||
| 977 | typedef typename __table::__node_const_pointer __node_const_pointer; | ||
| 978 | typedef typename __table::__node_traits __node_traits; | 907 | typedef typename __table::__node_traits __node_traits; |
| 979 | typedef typename __table::__node_allocator __node_allocator; | 908 | typedef typename __table::__node_allocator __node_allocator; |
| 980 | typedef typename __table::__node __node; | 909 | typedef typename __table::__node __node; |
| ... | @@ -1046,10 +975,10 @@ public: | ... | @@ -1046,10 +975,10 @@ public: |
| 1046 | # endif | 975 | # endif |
| 1047 | 976 | ||
| 1048 | _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a); | 977 | _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a); |
| 1049 | _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u); | 978 | _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u) = default; |
| 1050 | _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a); | 979 | _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a); |
| 1051 | # ifndef _LIBCPP_CXX03_LANG | 980 | # ifndef _LIBCPP_CXX03_LANG |
| 1052 | _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); | 981 | _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u) = default; |
| 1053 | _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u, const allocator_type& __a); | 982 | _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u, const allocator_type& __a); |
| 1054 | _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il); | 983 | _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il); |
| 1055 | _LIBCPP_HIDE_FROM_ABI | 984 | _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -1099,41 +1028,26 @@ public: | ... | @@ -1099,41 +1028,26 @@ public: |
| 1099 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); | 1028 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); |
| 1100 | } | 1029 | } |
| 1101 | 1030 | ||
| 1102 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(const unordered_map& __u) { | 1031 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(const unordered_map& __u) = default; |
| 1103 | # ifndef _LIBCPP_CXX03_LANG | ||
| 1104 | __table_ = __u.__table_; | ||
| 1105 | # else | ||
| 1106 | if (this != std::addressof(__u)) { | ||
| 1107 | __table_.clear(); | ||
| 1108 | __table_.hash_function() = __u.__table_.hash_function(); | ||
| 1109 | __table_.key_eq() = __u.__table_.key_eq(); | ||
| 1110 | __table_.max_load_factor() = __u.__table_.max_load_factor(); | ||
| 1111 | __table_.__copy_assign_alloc(__u.__table_); | ||
| 1112 | insert(__u.begin(), __u.end()); | ||
| 1113 | } | ||
| 1114 | # endif | ||
| 1115 | return *this; | ||
| 1116 | } | ||
| 1117 | # ifndef _LIBCPP_CXX03_LANG | 1032 | # ifndef _LIBCPP_CXX03_LANG |
| 1118 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(unordered_map&& __u) | 1033 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(unordered_map&& __u) = default; |
| 1119 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); | ||
| 1120 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(initializer_list<value_type> __il); | 1034 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(initializer_list<value_type> __il); |
| 1121 | # endif // _LIBCPP_CXX03_LANG | 1035 | # endif // _LIBCPP_CXX03_LANG |
| 1122 | 1036 | ||
| 1123 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | 1037 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 1124 | return allocator_type(__table_.__node_alloc()); | 1038 | return allocator_type(__table_.__node_alloc()); |
| 1125 | } | 1039 | } |
| 1126 | 1040 | ||
| 1127 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 1041 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 1128 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 1042 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 1129 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 1043 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 1130 | 1044 | ||
| 1131 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } | 1045 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } |
| 1132 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } | 1046 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } |
| 1133 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } | 1047 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } |
| 1134 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } | 1048 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } |
| 1135 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } | 1049 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 1136 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } | 1050 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 1137 | 1051 | ||
| 1138 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__emplace_unique(__x); } | 1052 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__emplace_unique(__x); } |
| 1139 | 1053 | ||
| ... | @@ -1187,14 +1101,13 @@ public: | ... | @@ -1187,14 +1101,13 @@ public: |
| 1187 | # if _LIBCPP_STD_VER >= 17 | 1101 | # if _LIBCPP_STD_VER >= 17 |
| 1188 | template <class... _Args> | 1102 | template <class... _Args> |
| 1189 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) { | 1103 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) { |
| 1190 | return __table_.__emplace_unique_key_args( | 1104 | return __table_.__emplace_unique( |
| 1191 | __k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple(std::forward<_Args>(__args)...)); | 1105 | piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple(std::forward<_Args>(__args)...)); |
| 1192 | } | 1106 | } |
| 1193 | 1107 | ||
| 1194 | template <class... _Args> | 1108 | template <class... _Args> |
| 1195 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) { | 1109 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) { |
| 1196 | return __table_.__emplace_unique_key_args( | 1110 | return __table_.__emplace_unique( |
| 1197 | __k, | ||
| 1198 | piecewise_construct, | 1111 | piecewise_construct, |
| 1199 | std::forward_as_tuple(std::move(__k)), | 1112 | std::forward_as_tuple(std::move(__k)), |
| 1200 | std::forward_as_tuple(std::forward<_Args>(__args)...)); | 1113 | std::forward_as_tuple(std::forward<_Args>(__args)...)); |
| ... | @@ -1212,7 +1125,7 @@ public: | ... | @@ -1212,7 +1125,7 @@ public: |
| 1212 | 1125 | ||
| 1213 | template <class _Vp> | 1126 | template <class _Vp> |
| 1214 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) { | 1127 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) { |
| 1215 | pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k, __k, std::forward<_Vp>(__v)); | 1128 | pair<iterator, bool> __res = __table_.__emplace_unique(__k, std::forward<_Vp>(__v)); |
| 1216 | if (!__res.second) { | 1129 | if (!__res.second) { |
| 1217 | __res.first->second = std::forward<_Vp>(__v); | 1130 | __res.first->second = std::forward<_Vp>(__v); |
| 1218 | } | 1131 | } |
| ... | @@ -1221,7 +1134,7 @@ public: | ... | @@ -1221,7 +1134,7 @@ public: |
| 1221 | 1134 | ||
| 1222 | template <class _Vp> | 1135 | template <class _Vp> |
| 1223 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) { | 1136 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) { |
| 1224 | pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k, std::move(__k), std::forward<_Vp>(__v)); | 1137 | pair<iterator, bool> __res = __table_.__emplace_unique(std::move(__k), std::forward<_Vp>(__v)); |
| 1225 | if (!__res.second) { | 1138 | if (!__res.second) { |
| 1226 | __res.first->second = std::forward<_Vp>(__v); | 1139 | __res.first->second = std::forward<_Vp>(__v); |
| 1227 | } | 1140 | } |
| ... | @@ -1258,10 +1171,10 @@ public: | ... | @@ -1258,10 +1171,10 @@ public: |
| 1258 | "node_type with incompatible allocator passed to unordered_map::insert()"); | 1171 | "node_type with incompatible allocator passed to unordered_map::insert()"); |
| 1259 | return __table_.template __node_handle_insert_unique<node_type>(__hint.__i_, std::move(__nh)); | 1172 | return __table_.template __node_handle_insert_unique<node_type>(__hint.__i_, std::move(__nh)); |
| 1260 | } | 1173 | } |
| 1261 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 1174 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 1262 | return __table_.template __node_handle_extract<node_type>(__key); | 1175 | return __table_.template __node_handle_extract<node_type>(__key); |
| 1263 | } | 1176 | } |
| 1264 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { | 1177 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { |
| 1265 | return __table_.template __node_handle_extract<node_type>(__it.__i_); | 1178 | return __table_.template __node_handle_extract<node_type>(__it.__i_); |
| 1266 | } | 1179 | } |
| 1267 | 1180 | ||
| ... | @@ -1295,52 +1208,56 @@ public: | ... | @@ -1295,52 +1208,56 @@ public: |
| 1295 | __table_.swap(__u.__table_); | 1208 | __table_.swap(__u.__table_); |
| 1296 | } | 1209 | } |
| 1297 | 1210 | ||
| 1298 | _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function().hash_function(); } | 1211 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { |
| 1299 | _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); } | 1212 | return __table_.hash_function().hash_function(); |
| 1213 | } | ||
| 1214 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); } | ||
| 1300 | 1215 | ||
| 1301 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 1216 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 1302 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 1217 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 1303 | # if _LIBCPP_STD_VER >= 20 | 1218 | # if _LIBCPP_STD_VER >= 20 |
| 1304 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1219 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1305 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1220 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1306 | return __table_.find(__k); | 1221 | return __table_.find(__k); |
| 1307 | } | 1222 | } |
| 1308 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1223 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1309 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1224 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1310 | return __table_.find(__k); | 1225 | return __table_.find(__k); |
| 1311 | } | 1226 | } |
| 1312 | # endif // _LIBCPP_STD_VER >= 20 | 1227 | # endif // _LIBCPP_STD_VER >= 20 |
| 1313 | 1228 | ||
| 1314 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } | 1229 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 1230 | return __table_.__count_unique(__k); | ||
| 1231 | } | ||
| 1315 | # if _LIBCPP_STD_VER >= 20 | 1232 | # if _LIBCPP_STD_VER >= 20 |
| 1316 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1233 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1317 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1234 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1318 | return __table_.__count_unique(__k); | 1235 | return __table_.__count_unique(__k); |
| 1319 | } | 1236 | } |
| 1320 | # endif // _LIBCPP_STD_VER >= 20 | 1237 | # endif // _LIBCPP_STD_VER >= 20 |
| 1321 | 1238 | ||
| 1322 | # if _LIBCPP_STD_VER >= 20 | 1239 | # if _LIBCPP_STD_VER >= 20 |
| 1323 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1240 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1324 | 1241 | ||
| 1325 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1242 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1326 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1243 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1327 | return find(__k) != end(); | 1244 | return find(__k) != end(); |
| 1328 | } | 1245 | } |
| 1329 | # endif // _LIBCPP_STD_VER >= 20 | 1246 | # endif // _LIBCPP_STD_VER >= 20 |
| 1330 | 1247 | ||
| 1331 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 1248 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1332 | return __table_.__equal_range_unique(__k); | 1249 | return __table_.__equal_range_unique(__k); |
| 1333 | } | 1250 | } |
| 1334 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 1251 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1335 | return __table_.__equal_range_unique(__k); | 1252 | return __table_.__equal_range_unique(__k); |
| 1336 | } | 1253 | } |
| 1337 | # if _LIBCPP_STD_VER >= 20 | 1254 | # if _LIBCPP_STD_VER >= 20 |
| 1338 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1255 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1339 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1256 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1340 | return __table_.__equal_range_unique(__k); | 1257 | return __table_.__equal_range_unique(__k); |
| 1341 | } | 1258 | } |
| 1342 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1259 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1343 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1260 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1344 | return __table_.__equal_range_unique(__k); | 1261 | return __table_.__equal_range_unique(__k); |
| 1345 | } | 1262 | } |
| 1346 | # endif // _LIBCPP_STD_VER >= 20 | 1263 | # endif // _LIBCPP_STD_VER >= 20 |
| ... | @@ -1350,24 +1267,32 @@ public: | ... | @@ -1350,24 +1267,32 @@ public: |
| 1350 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); | 1267 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); |
| 1351 | # endif | 1268 | # endif |
| 1352 | 1269 | ||
| 1353 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); | 1270 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); |
| 1354 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; | 1271 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; |
| 1355 | 1272 | ||
| 1356 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } | 1273 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } |
| 1357 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } | 1274 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { |
| 1275 | return __table_.max_bucket_count(); | ||
| 1276 | } | ||
| 1358 | 1277 | ||
| 1359 | _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); } | 1278 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { |
| 1360 | _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | 1279 | return __table_.bucket_size(__n); |
| 1280 | } | ||
| 1281 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | ||
| 1361 | 1282 | ||
| 1362 | _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } | 1283 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } |
| 1363 | _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } | 1284 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } |
| 1364 | _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); } | 1285 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { |
| 1365 | _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } | 1286 | return __table_.cbegin(__n); |
| 1366 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); } | 1287 | } |
| 1367 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | 1288 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } |
| 1289 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { | ||
| 1290 | return __table_.cbegin(__n); | ||
| 1291 | } | ||
| 1292 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | ||
| 1368 | 1293 | ||
| 1369 | _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } | 1294 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } |
| 1370 | _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } | 1295 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } |
| 1371 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } | 1296 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } |
| 1372 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); } | 1297 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); } |
| 1373 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); } | 1298 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); } |
| ... | @@ -1384,10 +1309,10 @@ template <class _InputIterator, | ... | @@ -1384,10 +1309,10 @@ template <class _InputIterator, |
| 1384 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, | 1309 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, |
| 1385 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, | 1310 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 1386 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1311 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1387 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1312 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1388 | class = enable_if_t<!is_integral<_Hash>::value>, | 1313 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1389 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 1314 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 1390 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1315 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1391 | unordered_map(_InputIterator, | 1316 | unordered_map(_InputIterator, |
| 1392 | _InputIterator, | 1317 | _InputIterator, |
| 1393 | typename allocator_traits<_Allocator>::size_type = 0, | 1318 | typename allocator_traits<_Allocator>::size_type = 0, |
| ... | @@ -1401,10 +1326,10 @@ template <ranges::input_range _Range, | ... | @@ -1401,10 +1326,10 @@ template <ranges::input_range _Range, |
| 1401 | class _Hash = hash<__range_key_type<_Range>>, | 1326 | class _Hash = hash<__range_key_type<_Range>>, |
| 1402 | class _Pred = equal_to<__range_key_type<_Range>>, | 1327 | class _Pred = equal_to<__range_key_type<_Range>>, |
| 1403 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, | 1328 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, |
| 1404 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1329 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1405 | class = enable_if_t<!is_integral<_Hash>::value>, | 1330 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1406 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 1331 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 1407 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1332 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1408 | unordered_map(from_range_t, | 1333 | unordered_map(from_range_t, |
| 1409 | _Range&&, | 1334 | _Range&&, |
| 1410 | typename allocator_traits<_Allocator>::size_type = 0, | 1335 | typename allocator_traits<_Allocator>::size_type = 0, |
| ... | @@ -1419,10 +1344,10 @@ template <class _Key, | ... | @@ -1419,10 +1344,10 @@ template <class _Key, |
| 1419 | class _Hash = hash<remove_const_t<_Key>>, | 1344 | class _Hash = hash<remove_const_t<_Key>>, |
| 1420 | class _Pred = equal_to<remove_const_t<_Key>>, | 1345 | class _Pred = equal_to<remove_const_t<_Key>>, |
| 1421 | class _Allocator = allocator<pair<const _Key, _Tp>>, | 1346 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 1422 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1347 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1423 | class = enable_if_t<!is_integral<_Hash>::value>, | 1348 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1424 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 1349 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 1425 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1350 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1426 | unordered_map(initializer_list<pair<_Key, _Tp>>, | 1351 | unordered_map(initializer_list<pair<_Key, _Tp>>, |
| 1427 | typename allocator_traits<_Allocator>::size_type = 0, | 1352 | typename allocator_traits<_Allocator>::size_type = 0, |
| 1428 | _Hash = _Hash(), | 1353 | _Hash = _Hash(), |
| ... | @@ -1432,7 +1357,7 @@ unordered_map(initializer_list<pair<_Key, _Tp>>, | ... | @@ -1432,7 +1357,7 @@ unordered_map(initializer_list<pair<_Key, _Tp>>, |
| 1432 | template <class _InputIterator, | 1357 | template <class _InputIterator, |
| 1433 | class _Allocator, | 1358 | class _Allocator, |
| 1434 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1359 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1435 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1360 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1436 | unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) | 1361 | unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1437 | -> unordered_map<__iter_key_type<_InputIterator>, | 1362 | -> unordered_map<__iter_key_type<_InputIterator>, |
| 1438 | __iter_mapped_type<_InputIterator>, | 1363 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -1443,7 +1368,7 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat | ... | @@ -1443,7 +1368,7 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat |
| 1443 | template <class _InputIterator, | 1368 | template <class _InputIterator, |
| 1444 | class _Allocator, | 1369 | class _Allocator, |
| 1445 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1370 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1446 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1371 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1447 | unordered_map(_InputIterator, _InputIterator, _Allocator) | 1372 | unordered_map(_InputIterator, _InputIterator, _Allocator) |
| 1448 | -> unordered_map<__iter_key_type<_InputIterator>, | 1373 | -> unordered_map<__iter_key_type<_InputIterator>, |
| 1449 | __iter_mapped_type<_InputIterator>, | 1374 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -1455,9 +1380,9 @@ template <class _InputIterator, | ... | @@ -1455,9 +1380,9 @@ template <class _InputIterator, |
| 1455 | class _Hash, | 1380 | class _Hash, |
| 1456 | class _Allocator, | 1381 | class _Allocator, |
| 1457 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1382 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1458 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1383 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1459 | class = enable_if_t<!is_integral<_Hash>::value>, | 1384 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1460 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1385 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1461 | unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1386 | unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1462 | -> unordered_map<__iter_key_type<_InputIterator>, | 1387 | -> unordered_map<__iter_key_type<_InputIterator>, |
| 1463 | __iter_mapped_type<_InputIterator>, | 1388 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -1467,7 +1392,7 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat | ... | @@ -1467,7 +1392,7 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat |
| 1467 | 1392 | ||
| 1468 | # if _LIBCPP_STD_VER >= 23 | 1393 | # if _LIBCPP_STD_VER >= 23 |
| 1469 | 1394 | ||
| 1470 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1395 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1471 | unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) | 1396 | unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1472 | -> unordered_map<__range_key_type<_Range>, | 1397 | -> unordered_map<__range_key_type<_Range>, |
| 1473 | __range_mapped_type<_Range>, | 1398 | __range_mapped_type<_Range>, |
| ... | @@ -1475,7 +1400,7 @@ unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::siz | ... | @@ -1475,7 +1400,7 @@ unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::siz |
| 1475 | equal_to<__range_key_type<_Range>>, | 1400 | equal_to<__range_key_type<_Range>>, |
| 1476 | _Allocator>; | 1401 | _Allocator>; |
| 1477 | 1402 | ||
| 1478 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1403 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1479 | unordered_map(from_range_t, _Range&&, _Allocator) | 1404 | unordered_map(from_range_t, _Range&&, _Allocator) |
| 1480 | -> unordered_map<__range_key_type<_Range>, | 1405 | -> unordered_map<__range_key_type<_Range>, |
| 1481 | __range_mapped_type<_Range>, | 1406 | __range_mapped_type<_Range>, |
| ... | @@ -1486,9 +1411,9 @@ unordered_map(from_range_t, _Range&&, _Allocator) | ... | @@ -1486,9 +1411,9 @@ unordered_map(from_range_t, _Range&&, _Allocator) |
| 1486 | template <ranges::input_range _Range, | 1411 | template <ranges::input_range _Range, |
| 1487 | class _Hash, | 1412 | class _Hash, |
| 1488 | class _Allocator, | 1413 | class _Allocator, |
| 1489 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1414 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1490 | class = enable_if_t<!is_integral<_Hash>::value>, | 1415 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1491 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1416 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1492 | unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1417 | unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1493 | -> unordered_map<__range_key_type<_Range>, | 1418 | -> unordered_map<__range_key_type<_Range>, |
| 1494 | __range_mapped_type<_Range>, | 1419 | __range_mapped_type<_Range>, |
| ... | @@ -1498,11 +1423,11 @@ unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::siz | ... | @@ -1498,11 +1423,11 @@ unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::siz |
| 1498 | 1423 | ||
| 1499 | # endif | 1424 | # endif |
| 1500 | 1425 | ||
| 1501 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1426 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1502 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) | 1427 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1503 | -> unordered_map<remove_const_t<_Key>, _Tp, hash<remove_const_t<_Key>>, equal_to<remove_const_t<_Key>>, _Allocator>; | 1428 | -> unordered_map<remove_const_t<_Key>, _Tp, hash<remove_const_t<_Key>>, equal_to<remove_const_t<_Key>>, _Allocator>; |
| 1504 | 1429 | ||
| 1505 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1430 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1506 | unordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator) | 1431 | unordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 1507 | -> unordered_map<remove_const_t<_Key>, _Tp, hash<remove_const_t<_Key>>, equal_to<remove_const_t<_Key>>, _Allocator>; | 1432 | -> unordered_map<remove_const_t<_Key>, _Tp, hash<remove_const_t<_Key>>, equal_to<remove_const_t<_Key>>, _Allocator>; |
| 1508 | 1433 | ||
| ... | @@ -1510,9 +1435,9 @@ template <class _Key, | ... | @@ -1510,9 +1435,9 @@ template <class _Key, |
| 1510 | class _Tp, | 1435 | class _Tp, |
| 1511 | class _Hash, | 1436 | class _Hash, |
| 1512 | class _Allocator, | 1437 | class _Allocator, |
| 1513 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1438 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1514 | class = enable_if_t<!is_integral<_Hash>::value>, | 1439 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1515 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1440 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1516 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1441 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1517 | -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>; | 1442 | -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>; |
| 1518 | # endif | 1443 | # endif |
| ... | @@ -1563,12 +1488,6 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( | ... | @@ -1563,12 +1488,6 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1563 | insert(__first, __last); | 1488 | insert(__first, __last); |
| 1564 | } | 1489 | } |
| 1565 | 1490 | ||
| 1566 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ||
| 1567 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_map& __u) : __table_(__u.__table_) { | ||
| 1568 | __table_.__rehash_unique(__u.bucket_count()); | ||
| 1569 | insert(__u.begin(), __u.end()); | ||
| 1570 | } | ||
| 1571 | |||
| 1572 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1491 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1573 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_map& __u, const allocator_type& __a) | 1492 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_map& __u, const allocator_type& __a) |
| 1574 | : __table_(__u.__table_, typename __table::allocator_type(__a)) { | 1493 | : __table_(__u.__table_, typename __table::allocator_type(__a)) { |
| ... | @@ -1578,11 +1497,6 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_ma | ... | @@ -1578,11 +1497,6 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_ma |
| 1578 | 1497 | ||
| 1579 | # ifndef _LIBCPP_CXX03_LANG | 1498 | # ifndef _LIBCPP_CXX03_LANG |
| 1580 | 1499 | ||
| 1581 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ||
| 1582 | inline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u) | ||
| 1583 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) | ||
| 1584 | : __table_(std::move(__u.__table_)) {} | ||
| 1585 | |||
| 1586 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1500 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1587 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u, const allocator_type& __a) | 1501 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u, const allocator_type& __a) |
| 1588 | : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) { | 1502 | : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) { |
| ... | @@ -1618,14 +1532,6 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( | ... | @@ -1618,14 +1532,6 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1618 | insert(__il.begin(), __il.end()); | 1532 | insert(__il.begin(), __il.end()); |
| 1619 | } | 1533 | } |
| 1620 | 1534 | ||
| 1621 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ||
| 1622 | inline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& | ||
| 1623 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u) | ||
| 1624 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) { | ||
| 1625 | __table_ = std::move(__u.__table_); | ||
| 1626 | return *this; | ||
| 1627 | } | ||
| 1628 | |||
| 1629 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1535 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1630 | inline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& | 1536 | inline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& |
| 1631 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { | 1537 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { |
| ... | @@ -1646,16 +1552,13 @@ inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterato | ... | @@ -1646,16 +1552,13 @@ inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterato |
| 1646 | 1552 | ||
| 1647 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1553 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1648 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) { | 1554 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) { |
| 1649 | return __table_ | 1555 | return __table_.__emplace_unique(piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) |
| 1650 | .__emplace_unique_key_args(__k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) | ||
| 1651 | .first->second; | 1556 | .first->second; |
| 1652 | } | 1557 | } |
| 1653 | 1558 | ||
| 1654 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1559 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1655 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) { | 1560 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) { |
| 1656 | return __table_ | 1561 | return __table_.__emplace_unique(piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) |
| 1657 | .__emplace_unique_key_args( | ||
| 1658 | __k, piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) | ||
| 1659 | .first->second; | 1562 | .first->second; |
| 1660 | } | 1563 | } |
| 1661 | # else // _LIBCPP_CXX03_LANG | 1564 | # else // _LIBCPP_CXX03_LANG |
| ... | @@ -1781,12 +1684,8 @@ private: | ... | @@ -1781,12 +1684,8 @@ private: |
| 1781 | 1684 | ||
| 1782 | __table __table_; | 1685 | __table __table_; |
| 1783 | 1686 | ||
| 1784 | typedef typename __table::_NodeTypes _NodeTypes; | ||
| 1785 | typedef typename __table::__node_traits __node_traits; | 1687 | typedef typename __table::__node_traits __node_traits; |
| 1786 | typedef typename __table::__node_allocator __node_allocator; | ||
| 1787 | typedef typename __table::__node __node; | 1688 | typedef typename __table::__node __node; |
| 1788 | typedef __hash_map_node_destructor<__node_allocator> _Dp; | ||
| 1789 | typedef unique_ptr<__node, _Dp> __node_holder; | ||
| 1790 | typedef allocator_traits<allocator_type> __alloc_traits; | 1689 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1791 | static_assert(is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value, | 1690 | static_assert(is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value, |
| 1792 | "Allocator uses different size_type for different types"); | 1691 | "Allocator uses different size_type for different types"); |
| ... | @@ -1852,11 +1751,10 @@ public: | ... | @@ -1852,11 +1751,10 @@ public: |
| 1852 | # endif | 1751 | # endif |
| 1853 | 1752 | ||
| 1854 | _LIBCPP_HIDE_FROM_ABI explicit unordered_multimap(const allocator_type& __a); | 1753 | _LIBCPP_HIDE_FROM_ABI explicit unordered_multimap(const allocator_type& __a); |
| 1855 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u); | 1754 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u) = default; |
| 1856 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a); | 1755 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a); |
| 1857 | # ifndef _LIBCPP_CXX03_LANG | 1756 | # ifndef _LIBCPP_CXX03_LANG |
| 1858 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u) | 1757 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u) = default; |
| 1859 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); | ||
| 1860 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u, const allocator_type& __a); | 1758 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u, const allocator_type& __a); |
| 1861 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il); | 1759 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il); |
| 1862 | _LIBCPP_HIDE_FROM_ABI unordered_multimap( | 1760 | _LIBCPP_HIDE_FROM_ABI unordered_multimap( |
| ... | @@ -1906,41 +1804,26 @@ public: | ... | @@ -1906,41 +1804,26 @@ public: |
| 1906 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); | 1804 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); |
| 1907 | } | 1805 | } |
| 1908 | 1806 | ||
| 1909 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(const unordered_multimap& __u) { | 1807 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(const unordered_multimap& __u) = default; |
| 1910 | # ifndef _LIBCPP_CXX03_LANG | ||
| 1911 | __table_ = __u.__table_; | ||
| 1912 | # else | ||
| 1913 | if (this != std::addressof(__u)) { | ||
| 1914 | __table_.clear(); | ||
| 1915 | __table_.hash_function() = __u.__table_.hash_function(); | ||
| 1916 | __table_.key_eq() = __u.__table_.key_eq(); | ||
| 1917 | __table_.max_load_factor() = __u.__table_.max_load_factor(); | ||
| 1918 | __table_.__copy_assign_alloc(__u.__table_); | ||
| 1919 | insert(__u.begin(), __u.end()); | ||
| 1920 | } | ||
| 1921 | # endif | ||
| 1922 | return *this; | ||
| 1923 | } | ||
| 1924 | # ifndef _LIBCPP_CXX03_LANG | 1808 | # ifndef _LIBCPP_CXX03_LANG |
| 1925 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(unordered_multimap&& __u) | 1809 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(unordered_multimap&& __u) = default; |
| 1926 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); | ||
| 1927 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(initializer_list<value_type> __il); | 1810 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(initializer_list<value_type> __il); |
| 1928 | # endif // _LIBCPP_CXX03_LANG | 1811 | # endif // _LIBCPP_CXX03_LANG |
| 1929 | 1812 | ||
| 1930 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | 1813 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 1931 | return allocator_type(__table_.__node_alloc()); | 1814 | return allocator_type(__table_.__node_alloc()); |
| 1932 | } | 1815 | } |
| 1933 | 1816 | ||
| 1934 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 1817 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 1935 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 1818 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 1936 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 1819 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 1937 | 1820 | ||
| 1938 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } | 1821 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } |
| 1939 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } | 1822 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } |
| 1940 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } | 1823 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } |
| 1941 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } | 1824 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } |
| 1942 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } | 1825 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 1943 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } | 1826 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 1944 | 1827 | ||
| 1945 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); } | 1828 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); } |
| 1946 | 1829 | ||
| ... | @@ -2008,10 +1891,10 @@ public: | ... | @@ -2008,10 +1891,10 @@ public: |
| 2008 | "node_type with incompatible allocator passed to unordered_multimap::insert()"); | 1891 | "node_type with incompatible allocator passed to unordered_multimap::insert()"); |
| 2009 | return __table_.template __node_handle_insert_multi<node_type>(__hint.__i_, std::move(__nh)); | 1892 | return __table_.template __node_handle_insert_multi<node_type>(__hint.__i_, std::move(__nh)); |
| 2010 | } | 1893 | } |
| 2011 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 1894 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 2012 | return __table_.template __node_handle_extract<node_type>(__key); | 1895 | return __table_.template __node_handle_extract<node_type>(__key); |
| 2013 | } | 1896 | } |
| 2014 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { | 1897 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { |
| 2015 | return __table_.template __node_handle_extract<node_type>(__it.__i_); | 1898 | return __table_.template __node_handle_extract<node_type>(__it.__i_); |
| 2016 | } | 1899 | } |
| 2017 | 1900 | ||
| ... | @@ -2045,71 +1928,83 @@ public: | ... | @@ -2045,71 +1928,83 @@ public: |
| 2045 | __table_.swap(__u.__table_); | 1928 | __table_.swap(__u.__table_); |
| 2046 | } | 1929 | } |
| 2047 | 1930 | ||
| 2048 | _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function().hash_function(); } | 1931 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { |
| 2049 | _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); } | 1932 | return __table_.hash_function().hash_function(); |
| 1933 | } | ||
| 1934 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); } | ||
| 2050 | 1935 | ||
| 2051 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 1936 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 2052 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 1937 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 2053 | # if _LIBCPP_STD_VER >= 20 | 1938 | # if _LIBCPP_STD_VER >= 20 |
| 2054 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1939 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2055 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1940 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 2056 | return __table_.find(__k); | 1941 | return __table_.find(__k); |
| 2057 | } | 1942 | } |
| 2058 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1943 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2059 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1944 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 2060 | return __table_.find(__k); | 1945 | return __table_.find(__k); |
| 2061 | } | 1946 | } |
| 2062 | # endif // _LIBCPP_STD_VER >= 20 | 1947 | # endif // _LIBCPP_STD_VER >= 20 |
| 2063 | 1948 | ||
| 2064 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } | 1949 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 1950 | return __table_.__count_multi(__k); | ||
| 1951 | } | ||
| 2065 | # if _LIBCPP_STD_VER >= 20 | 1952 | # if _LIBCPP_STD_VER >= 20 |
| 2066 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1953 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2067 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1954 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 2068 | return __table_.__count_multi(__k); | 1955 | return __table_.__count_multi(__k); |
| 2069 | } | 1956 | } |
| 2070 | # endif // _LIBCPP_STD_VER >= 20 | 1957 | # endif // _LIBCPP_STD_VER >= 20 |
| 2071 | 1958 | ||
| 2072 | # if _LIBCPP_STD_VER >= 20 | 1959 | # if _LIBCPP_STD_VER >= 20 |
| 2073 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1960 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 2074 | 1961 | ||
| 2075 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1962 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2076 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1963 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 2077 | return find(__k) != end(); | 1964 | return find(__k) != end(); |
| 2078 | } | 1965 | } |
| 2079 | # endif // _LIBCPP_STD_VER >= 20 | 1966 | # endif // _LIBCPP_STD_VER >= 20 |
| 2080 | 1967 | ||
| 2081 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 1968 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 2082 | return __table_.__equal_range_multi(__k); | 1969 | return __table_.__equal_range_multi(__k); |
| 2083 | } | 1970 | } |
| 2084 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 1971 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 2085 | return __table_.__equal_range_multi(__k); | 1972 | return __table_.__equal_range_multi(__k); |
| 2086 | } | 1973 | } |
| 2087 | # if _LIBCPP_STD_VER >= 20 | 1974 | # if _LIBCPP_STD_VER >= 20 |
| 2088 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1975 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2089 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1976 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 2090 | return __table_.__equal_range_multi(__k); | 1977 | return __table_.__equal_range_multi(__k); |
| 2091 | } | 1978 | } |
| 2092 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1979 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2093 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1980 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 2094 | return __table_.__equal_range_multi(__k); | 1981 | return __table_.__equal_range_multi(__k); |
| 2095 | } | 1982 | } |
| 2096 | # endif // _LIBCPP_STD_VER >= 20 | 1983 | # endif // _LIBCPP_STD_VER >= 20 |
| 2097 | 1984 | ||
| 2098 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } | 1985 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } |
| 2099 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } | 1986 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { |
| 1987 | return __table_.max_bucket_count(); | ||
| 1988 | } | ||
| 2100 | 1989 | ||
| 2101 | _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); } | 1990 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { |
| 2102 | _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | 1991 | return __table_.bucket_size(__n); |
| 1992 | } | ||
| 1993 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | ||
| 2103 | 1994 | ||
| 2104 | _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } | 1995 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } |
| 2105 | _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } | 1996 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } |
| 2106 | _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); } | 1997 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { |
| 2107 | _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } | 1998 | return __table_.cbegin(__n); |
| 2108 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); } | 1999 | } |
| 2109 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | 2000 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } |
| 2001 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { | ||
| 2002 | return __table_.cbegin(__n); | ||
| 2003 | } | ||
| 2004 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | ||
| 2110 | 2005 | ||
| 2111 | _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } | 2006 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } |
| 2112 | _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } | 2007 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } |
| 2113 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } | 2008 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } |
| 2114 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); } | 2009 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); } |
| 2115 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); } | 2010 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); } |
| ... | @@ -2121,10 +2016,10 @@ template <class _InputIterator, | ... | @@ -2121,10 +2016,10 @@ template <class _InputIterator, |
| 2121 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, | 2016 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, |
| 2122 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, | 2017 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 2123 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 2018 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 2124 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 2019 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 2125 | class = enable_if_t<!is_integral<_Hash>::value>, | 2020 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 2126 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 2021 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 2127 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2022 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2128 | unordered_multimap(_InputIterator, | 2023 | unordered_multimap(_InputIterator, |
| 2129 | _InputIterator, | 2024 | _InputIterator, |
| 2130 | typename allocator_traits<_Allocator>::size_type = 0, | 2025 | typename allocator_traits<_Allocator>::size_type = 0, |
| ... | @@ -2142,10 +2037,10 @@ template <ranges::input_range _Range, | ... | @@ -2142,10 +2037,10 @@ template <ranges::input_range _Range, |
| 2142 | class _Hash = hash<__range_key_type<_Range>>, | 2037 | class _Hash = hash<__range_key_type<_Range>>, |
| 2143 | class _Pred = equal_to<__range_key_type<_Range>>, | 2038 | class _Pred = equal_to<__range_key_type<_Range>>, |
| 2144 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, | 2039 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, |
| 2145 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 2040 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 2146 | class = enable_if_t<!is_integral<_Hash>::value>, | 2041 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 2147 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 2042 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 2148 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2043 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2149 | unordered_multimap(from_range_t, | 2044 | unordered_multimap(from_range_t, |
| 2150 | _Range&&, | 2045 | _Range&&, |
| 2151 | typename allocator_traits<_Allocator>::size_type = 0, | 2046 | typename allocator_traits<_Allocator>::size_type = 0, |
| ... | @@ -2160,21 +2055,21 @@ template <class _Key, | ... | @@ -2160,21 +2055,21 @@ template <class _Key, |
| 2160 | class _Hash = hash<remove_const_t<_Key>>, | 2055 | class _Hash = hash<remove_const_t<_Key>>, |
| 2161 | class _Pred = equal_to<remove_const_t<_Key>>, | 2056 | class _Pred = equal_to<remove_const_t<_Key>>, |
| 2162 | class _Allocator = allocator<pair<const _Key, _Tp>>, | 2057 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 2163 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 2058 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 2164 | class = enable_if_t<!is_integral<_Hash>::value>, | 2059 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 2165 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 2060 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 2166 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2061 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2167 | unordered_multimap( | 2062 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, |
| 2168 | initializer_list<pair<_Key, _Tp>>, | 2063 | typename allocator_traits<_Allocator>::size_type = 0, |
| 2169 | typename allocator_traits<_Allocator>::size_type = 0, | 2064 | _Hash = _Hash(), |
| 2170 | _Hash = _Hash(), | 2065 | _Pred = _Pred(), |
| 2171 | _Pred = _Pred(), | 2066 | _Allocator = _Allocator()) |
| 2172 | _Allocator = _Allocator()) -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; | 2067 | -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; |
| 2173 | 2068 | ||
| 2174 | template <class _InputIterator, | 2069 | template <class _InputIterator, |
| 2175 | class _Allocator, | 2070 | class _Allocator, |
| 2176 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 2071 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 2177 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2072 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2178 | unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) | 2073 | unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 2179 | -> unordered_multimap<__iter_key_type<_InputIterator>, | 2074 | -> unordered_multimap<__iter_key_type<_InputIterator>, |
| 2180 | __iter_mapped_type<_InputIterator>, | 2075 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -2185,7 +2080,7 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al | ... | @@ -2185,7 +2080,7 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al |
| 2185 | template <class _InputIterator, | 2080 | template <class _InputIterator, |
| 2186 | class _Allocator, | 2081 | class _Allocator, |
| 2187 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 2082 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 2188 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2083 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2189 | unordered_multimap(_InputIterator, _InputIterator, _Allocator) | 2084 | unordered_multimap(_InputIterator, _InputIterator, _Allocator) |
| 2190 | -> unordered_multimap<__iter_key_type<_InputIterator>, | 2085 | -> unordered_multimap<__iter_key_type<_InputIterator>, |
| 2191 | __iter_mapped_type<_InputIterator>, | 2086 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -2197,9 +2092,9 @@ template <class _InputIterator, | ... | @@ -2197,9 +2092,9 @@ template <class _InputIterator, |
| 2197 | class _Hash, | 2092 | class _Hash, |
| 2198 | class _Allocator, | 2093 | class _Allocator, |
| 2199 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 2094 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 2200 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 2095 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 2201 | class = enable_if_t<!is_integral<_Hash>::value>, | 2096 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 2202 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2097 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2203 | unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 2098 | unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 2204 | -> unordered_multimap<__iter_key_type<_InputIterator>, | 2099 | -> unordered_multimap<__iter_key_type<_InputIterator>, |
| 2205 | __iter_mapped_type<_InputIterator>, | 2100 | __iter_mapped_type<_InputIterator>, |
| ... | @@ -2209,7 +2104,7 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al | ... | @@ -2209,7 +2104,7 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al |
| 2209 | 2104 | ||
| 2210 | # if _LIBCPP_STD_VER >= 23 | 2105 | # if _LIBCPP_STD_VER >= 23 |
| 2211 | 2106 | ||
| 2212 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 2107 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2213 | unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) | 2108 | unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 2214 | -> unordered_multimap<__range_key_type<_Range>, | 2109 | -> unordered_multimap<__range_key_type<_Range>, |
| 2215 | __range_mapped_type<_Range>, | 2110 | __range_mapped_type<_Range>, |
| ... | @@ -2217,7 +2112,7 @@ unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator> | ... | @@ -2217,7 +2112,7 @@ unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator> |
| 2217 | equal_to<__range_key_type<_Range>>, | 2112 | equal_to<__range_key_type<_Range>>, |
| 2218 | _Allocator>; | 2113 | _Allocator>; |
| 2219 | 2114 | ||
| 2220 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 2115 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2221 | unordered_multimap(from_range_t, _Range&&, _Allocator) | 2116 | unordered_multimap(from_range_t, _Range&&, _Allocator) |
| 2222 | -> unordered_multimap<__range_key_type<_Range>, | 2117 | -> unordered_multimap<__range_key_type<_Range>, |
| 2223 | __range_mapped_type<_Range>, | 2118 | __range_mapped_type<_Range>, |
| ... | @@ -2228,9 +2123,9 @@ unordered_multimap(from_range_t, _Range&&, _Allocator) | ... | @@ -2228,9 +2123,9 @@ unordered_multimap(from_range_t, _Range&&, _Allocator) |
| 2228 | template <ranges::input_range _Range, | 2123 | template <ranges::input_range _Range, |
| 2229 | class _Hash, | 2124 | class _Hash, |
| 2230 | class _Allocator, | 2125 | class _Allocator, |
| 2231 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 2126 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 2232 | class = enable_if_t<!is_integral<_Hash>::value>, | 2127 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 2233 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2128 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2234 | unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 2129 | unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 2235 | -> unordered_multimap<__range_key_type<_Range>, | 2130 | -> unordered_multimap<__range_key_type<_Range>, |
| 2236 | __range_mapped_type<_Range>, | 2131 | __range_mapped_type<_Range>, |
| ... | @@ -2240,7 +2135,7 @@ unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator> | ... | @@ -2240,7 +2135,7 @@ unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator> |
| 2240 | 2135 | ||
| 2241 | # endif | 2136 | # endif |
| 2242 | 2137 | ||
| 2243 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 2138 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2244 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) | 2139 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 2245 | -> unordered_multimap<remove_const_t<_Key>, | 2140 | -> unordered_multimap<remove_const_t<_Key>, |
| 2246 | _Tp, | 2141 | _Tp, |
| ... | @@ -2248,7 +2143,7 @@ unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits< | ... | @@ -2248,7 +2143,7 @@ unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits< |
| 2248 | equal_to<remove_const_t<_Key>>, | 2143 | equal_to<remove_const_t<_Key>>, |
| 2249 | _Allocator>; | 2144 | _Allocator>; |
| 2250 | 2145 | ||
| 2251 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 2146 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2252 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) | 2147 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 2253 | -> unordered_multimap<remove_const_t<_Key>, | 2148 | -> unordered_multimap<remove_const_t<_Key>, |
| 2254 | _Tp, | 2149 | _Tp, |
| ... | @@ -2260,9 +2155,9 @@ template <class _Key, | ... | @@ -2260,9 +2155,9 @@ template <class _Key, |
| 2260 | class _Tp, | 2155 | class _Tp, |
| 2261 | class _Hash, | 2156 | class _Hash, |
| 2262 | class _Allocator, | 2157 | class _Allocator, |
| 2263 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 2158 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 2264 | class = enable_if_t<!is_integral<_Hash>::value>, | 2159 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 2265 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 2160 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 2266 | unordered_multimap( | 2161 | unordered_multimap( |
| 2267 | initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 2162 | initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 2268 | -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>; | 2163 | -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>; |
| ... | @@ -2315,13 +2210,6 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -2315,13 +2210,6 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2315 | inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const allocator_type& __a) | 2210 | inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const allocator_type& __a) |
| 2316 | : __table_(typename __table::allocator_type(__a)) {} | 2211 | : __table_(typename __table::allocator_type(__a)) {} |
| 2317 | 2212 | ||
| 2318 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ||
| 2319 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const unordered_multimap& __u) | ||
| 2320 | : __table_(__u.__table_) { | ||
| 2321 | __table_.__rehash_multi(__u.bucket_count()); | ||
| 2322 | insert(__u.begin(), __u.end()); | ||
| 2323 | } | ||
| 2324 | |||
| 2325 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2213 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2326 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( | 2214 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2327 | const unordered_multimap& __u, const allocator_type& __a) | 2215 | const unordered_multimap& __u, const allocator_type& __a) |
| ... | @@ -2332,11 +2220,6 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( | ... | @@ -2332,11 +2220,6 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2332 | 2220 | ||
| 2333 | # ifndef _LIBCPP_CXX03_LANG | 2221 | # ifndef _LIBCPP_CXX03_LANG |
| 2334 | 2222 | ||
| 2335 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ||
| 2336 | inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(unordered_multimap&& __u) | ||
| 2337 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) | ||
| 2338 | : __table_(std::move(__u.__table_)) {} | ||
| 2339 | |||
| 2340 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2223 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2341 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( | 2224 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2342 | unordered_multimap&& __u, const allocator_type& __a) | 2225 | unordered_multimap&& __u, const allocator_type& __a) |
| ... | @@ -2373,14 +2256,6 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( | ... | @@ -2373,14 +2256,6 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2373 | insert(__il.begin(), __il.end()); | 2256 | insert(__il.begin(), __il.end()); |
| 2374 | } | 2257 | } |
| 2375 | 2258 | ||
| 2376 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ||
| 2377 | inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& | ||
| 2378 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u) | ||
| 2379 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) { | ||
| 2380 | __table_ = std::move(__u.__table_); | ||
| 2381 | return *this; | ||
| 2382 | } | ||
| 2383 | |||
| 2384 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2259 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2385 | inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& | 2260 | inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& |
| 2386 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { | 2261 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { |
lib/libcxx/include/unordered_set+168-195| ... | @@ -544,8 +544,6 @@ template <class Value, class Hash, class Pred, class Alloc> | ... | @@ -544,8 +544,6 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 544 | # include <__iterator/distance.h> | 544 | # include <__iterator/distance.h> |
| 545 | # include <__iterator/erase_if_container.h> | 545 | # include <__iterator/erase_if_container.h> |
| 546 | # include <__iterator/iterator_traits.h> | 546 | # include <__iterator/iterator_traits.h> |
| 547 | # include <__iterator/ranges_iterator_traits.h> | ||
| 548 | # include <__memory/addressof.h> | ||
| 549 | # include <__memory/allocator.h> | 547 | # include <__memory/allocator.h> |
| 550 | # include <__memory/allocator_traits.h> | 548 | # include <__memory/allocator_traits.h> |
| 551 | # include <__memory_resource/polymorphic_allocator.h> | 549 | # include <__memory_resource/polymorphic_allocator.h> |
| ... | @@ -558,7 +556,6 @@ template <class Value, class Hash, class Pred, class Alloc> | ... | @@ -558,7 +556,6 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 558 | # include <__type_traits/invoke.h> | 556 | # include <__type_traits/invoke.h> |
| 559 | # include <__type_traits/is_allocator.h> | 557 | # include <__type_traits/is_allocator.h> |
| 560 | # include <__type_traits/is_integral.h> | 558 | # include <__type_traits/is_integral.h> |
| 561 | # include <__type_traits/is_nothrow_assignable.h> | ||
| 562 | # include <__type_traits/is_nothrow_constructible.h> | 559 | # include <__type_traits/is_nothrow_constructible.h> |
| 563 | # include <__type_traits/is_same.h> | 560 | # include <__type_traits/is_same.h> |
| 564 | # include <__type_traits/is_swappable.h> | 561 | # include <__type_traits/is_swappable.h> |
| ... | @@ -703,10 +700,10 @@ public: | ... | @@ -703,10 +700,10 @@ public: |
| 703 | # endif | 700 | # endif |
| 704 | 701 | ||
| 705 | _LIBCPP_HIDE_FROM_ABI explicit unordered_set(const allocator_type& __a); | 702 | _LIBCPP_HIDE_FROM_ABI explicit unordered_set(const allocator_type& __a); |
| 706 | _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u); | 703 | _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u) = default; |
| 707 | _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a); | 704 | _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a); |
| 708 | # ifndef _LIBCPP_CXX03_LANG | 705 | # ifndef _LIBCPP_CXX03_LANG |
| 709 | _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); | 706 | _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u) = default; |
| 710 | _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a); | 707 | _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a); |
| 711 | _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il); | 708 | _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il); |
| 712 | _LIBCPP_HIDE_FROM_ABI | 709 | _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -733,30 +730,26 @@ public: | ... | @@ -733,30 +730,26 @@ public: |
| 733 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); | 730 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); |
| 734 | } | 731 | } |
| 735 | 732 | ||
| 736 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(const unordered_set& __u) { | 733 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(const unordered_set& __u) = default; |
| 737 | __table_ = __u.__table_; | ||
| 738 | return *this; | ||
| 739 | } | ||
| 740 | # ifndef _LIBCPP_CXX03_LANG | 734 | # ifndef _LIBCPP_CXX03_LANG |
| 741 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(unordered_set&& __u) | 735 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(unordered_set&& __u) = default; |
| 742 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); | ||
| 743 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(initializer_list<value_type> __il); | 736 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(initializer_list<value_type> __il); |
| 744 | # endif // _LIBCPP_CXX03_LANG | 737 | # endif // _LIBCPP_CXX03_LANG |
| 745 | 738 | ||
| 746 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | 739 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 747 | return allocator_type(__table_.__node_alloc()); | 740 | return allocator_type(__table_.__node_alloc()); |
| 748 | } | 741 | } |
| 749 | 742 | ||
| 750 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 743 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 751 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 744 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 752 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 745 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 753 | 746 | ||
| 754 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } | 747 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } |
| 755 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } | 748 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } |
| 756 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } | 749 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } |
| 757 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } | 750 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } |
| 758 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } | 751 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 759 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } | 752 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 760 | 753 | ||
| 761 | # ifndef _LIBCPP_CXX03_LANG | 754 | # ifndef _LIBCPP_CXX03_LANG |
| 762 | template <class... _Args> | 755 | template <class... _Args> |
| ... | @@ -808,10 +801,10 @@ public: | ... | @@ -808,10 +801,10 @@ public: |
| 808 | "node_type with incompatible allocator passed to unordered_set::insert()"); | 801 | "node_type with incompatible allocator passed to unordered_set::insert()"); |
| 809 | return __table_.template __node_handle_insert_unique<node_type>(__h, std::move(__nh)); | 802 | return __table_.template __node_handle_insert_unique<node_type>(__h, std::move(__nh)); |
| 810 | } | 803 | } |
| 811 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 804 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 812 | return __table_.template __node_handle_extract<node_type>(__key); | 805 | return __table_.template __node_handle_extract<node_type>(__key); |
| 813 | } | 806 | } |
| 814 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { | 807 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { |
| 815 | return __table_.template __node_handle_extract<node_type>(__it); | 808 | return __table_.template __node_handle_extract<node_type>(__it); |
| 816 | } | 809 | } |
| 817 | 810 | ||
| ... | @@ -845,71 +838,81 @@ public: | ... | @@ -845,71 +838,81 @@ public: |
| 845 | __table_.swap(__u.__table_); | 838 | __table_.swap(__u.__table_); |
| 846 | } | 839 | } |
| 847 | 840 | ||
| 848 | _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); } | 841 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); } |
| 849 | _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); } | 842 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); } |
| 850 | 843 | ||
| 851 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 844 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 852 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 845 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 853 | # if _LIBCPP_STD_VER >= 20 | 846 | # if _LIBCPP_STD_VER >= 20 |
| 854 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 847 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 855 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 848 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 856 | return __table_.find(__k); | 849 | return __table_.find(__k); |
| 857 | } | 850 | } |
| 858 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 851 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 859 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 852 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 860 | return __table_.find(__k); | 853 | return __table_.find(__k); |
| 861 | } | 854 | } |
| 862 | # endif // _LIBCPP_STD_VER >= 20 | 855 | # endif // _LIBCPP_STD_VER >= 20 |
| 863 | 856 | ||
| 864 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } | 857 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 858 | return __table_.__count_unique(__k); | ||
| 859 | } | ||
| 865 | # if _LIBCPP_STD_VER >= 20 | 860 | # if _LIBCPP_STD_VER >= 20 |
| 866 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 861 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 867 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 862 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 868 | return __table_.__count_unique(__k); | 863 | return __table_.__count_unique(__k); |
| 869 | } | 864 | } |
| 870 | # endif // _LIBCPP_STD_VER >= 20 | 865 | # endif // _LIBCPP_STD_VER >= 20 |
| 871 | 866 | ||
| 872 | # if _LIBCPP_STD_VER >= 20 | 867 | # if _LIBCPP_STD_VER >= 20 |
| 873 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 868 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 874 | 869 | ||
| 875 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 870 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 876 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 871 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 877 | return find(__k) != end(); | 872 | return find(__k) != end(); |
| 878 | } | 873 | } |
| 879 | # endif // _LIBCPP_STD_VER >= 20 | 874 | # endif // _LIBCPP_STD_VER >= 20 |
| 880 | 875 | ||
| 881 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 876 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 882 | return __table_.__equal_range_unique(__k); | 877 | return __table_.__equal_range_unique(__k); |
| 883 | } | 878 | } |
| 884 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 879 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 885 | return __table_.__equal_range_unique(__k); | 880 | return __table_.__equal_range_unique(__k); |
| 886 | } | 881 | } |
| 887 | # if _LIBCPP_STD_VER >= 20 | 882 | # if _LIBCPP_STD_VER >= 20 |
| 888 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 883 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 889 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 884 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 890 | return __table_.__equal_range_unique(__k); | 885 | return __table_.__equal_range_unique(__k); |
| 891 | } | 886 | } |
| 892 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 887 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 893 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 888 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 894 | return __table_.__equal_range_unique(__k); | 889 | return __table_.__equal_range_unique(__k); |
| 895 | } | 890 | } |
| 896 | # endif // _LIBCPP_STD_VER >= 20 | 891 | # endif // _LIBCPP_STD_VER >= 20 |
| 897 | 892 | ||
| 898 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } | 893 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } |
| 899 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } | 894 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { |
| 895 | return __table_.max_bucket_count(); | ||
| 896 | } | ||
| 900 | 897 | ||
| 901 | _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); } | 898 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { |
| 902 | _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | 899 | return __table_.bucket_size(__n); |
| 900 | } | ||
| 901 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | ||
| 903 | 902 | ||
| 904 | _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } | 903 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } |
| 905 | _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } | 904 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } |
| 906 | _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); } | 905 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { |
| 907 | _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } | 906 | return __table_.cbegin(__n); |
| 908 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); } | 907 | } |
| 909 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | 908 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } |
| 909 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { | ||
| 910 | return __table_.cbegin(__n); | ||
| 911 | } | ||
| 912 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | ||
| 910 | 913 | ||
| 911 | _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } | 914 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } |
| 912 | _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } | 915 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } |
| 913 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } | 916 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } |
| 914 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); } | 917 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); } |
| 915 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); } | 918 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); } |
| ... | @@ -917,47 +920,48 @@ public: | ... | @@ -917,47 +920,48 @@ public: |
| 917 | 920 | ||
| 918 | # if _LIBCPP_STD_VER >= 17 | 921 | # if _LIBCPP_STD_VER >= 17 |
| 919 | template <class _InputIterator, | 922 | template <class _InputIterator, |
| 920 | class _Hash = hash<__iter_value_type<_InputIterator>>, | 923 | class _Hash = hash<__iterator_value_type<_InputIterator>>, |
| 921 | class _Pred = equal_to<__iter_value_type<_InputIterator>>, | 924 | class _Pred = equal_to<__iterator_value_type<_InputIterator>>, |
| 922 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, | 925 | class _Allocator = allocator<__iterator_value_type<_InputIterator>>, |
| 923 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 926 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 924 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 927 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 925 | class = enable_if_t<!is_integral<_Hash>::value>, | 928 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 926 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 929 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 927 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 930 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 928 | unordered_set(_InputIterator, | 931 | unordered_set(_InputIterator, |
| 929 | _InputIterator, | 932 | _InputIterator, |
| 930 | typename allocator_traits<_Allocator>::size_type = 0, | 933 | typename allocator_traits<_Allocator>::size_type = 0, |
| 931 | _Hash = _Hash(), | 934 | _Hash = _Hash(), |
| 932 | _Pred = _Pred(), | 935 | _Pred = _Pred(), |
| 933 | _Allocator = _Allocator()) -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; | 936 | _Allocator = _Allocator()) |
| 937 | -> unordered_set<__iterator_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; | ||
| 934 | 938 | ||
| 935 | # if _LIBCPP_STD_VER >= 23 | 939 | # if _LIBCPP_STD_VER >= 23 |
| 936 | template <ranges::input_range _Range, | 940 | template <ranges::input_range _Range, |
| 937 | class _Hash = hash<ranges::range_value_t<_Range>>, | 941 | class _Hash = hash<ranges::range_value_t<_Range>>, |
| 938 | class _Pred = equal_to<ranges::range_value_t<_Range>>, | 942 | class _Pred = equal_to<ranges::range_value_t<_Range>>, |
| 939 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | 943 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 940 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 944 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 941 | class = enable_if_t<!is_integral<_Hash>::value>, | 945 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 942 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 946 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 943 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 947 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 944 | unordered_set( | 948 | unordered_set(from_range_t, |
| 945 | from_range_t, | 949 | _Range&&, |
| 946 | _Range&&, | 950 | typename allocator_traits<_Allocator>::size_type = 0, |
| 947 | typename allocator_traits<_Allocator>::size_type = 0, | 951 | _Hash = _Hash(), |
| 948 | _Hash = _Hash(), | 952 | _Pred = _Pred(), |
| 949 | _Pred = _Pred(), | 953 | _Allocator = _Allocator()) |
| 950 | _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 | 954 | -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 |
| 951 | # endif | 955 | # endif |
| 952 | 956 | ||
| 953 | template <class _Tp, | 957 | template <class _Tp, |
| 954 | class _Hash = hash<_Tp>, | 958 | class _Hash = hash<_Tp>, |
| 955 | class _Pred = equal_to<_Tp>, | 959 | class _Pred = equal_to<_Tp>, |
| 956 | class _Allocator = allocator<_Tp>, | 960 | class _Allocator = allocator<_Tp>, |
| 957 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 961 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 958 | class = enable_if_t<!is_integral<_Hash>::value>, | 962 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 959 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 963 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 960 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 964 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 961 | unordered_set(initializer_list<_Tp>, | 965 | unordered_set(initializer_list<_Tp>, |
| 962 | typename allocator_traits<_Allocator>::size_type = 0, | 966 | typename allocator_traits<_Allocator>::size_type = 0, |
| 963 | _Hash = _Hash(), | 967 | _Hash = _Hash(), |
| ... | @@ -967,33 +971,36 @@ unordered_set(initializer_list<_Tp>, | ... | @@ -967,33 +971,36 @@ unordered_set(initializer_list<_Tp>, |
| 967 | template <class _InputIterator, | 971 | template <class _InputIterator, |
| 968 | class _Allocator, | 972 | class _Allocator, |
| 969 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 973 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 970 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 974 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 971 | unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) | 975 | unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 972 | -> unordered_set<__iter_value_type<_InputIterator>, | 976 | -> unordered_set<__iterator_value_type<_InputIterator>, |
| 973 | hash<__iter_value_type<_InputIterator>>, | 977 | hash<__iterator_value_type<_InputIterator>>, |
| 974 | equal_to<__iter_value_type<_InputIterator>>, | 978 | equal_to<__iterator_value_type<_InputIterator>>, |
| 975 | _Allocator>; | 979 | _Allocator>; |
| 976 | 980 | ||
| 977 | template <class _InputIterator, | 981 | template <class _InputIterator, |
| 978 | class _Hash, | 982 | class _Hash, |
| 979 | class _Allocator, | 983 | class _Allocator, |
| 980 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 984 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 981 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 985 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 982 | class = enable_if_t<!is_integral<_Hash>::value>, | 986 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 983 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 987 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 984 | unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 988 | unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 985 | -> unordered_set<__iter_value_type<_InputIterator>, _Hash, equal_to<__iter_value_type<_InputIterator>>, _Allocator>; | 989 | -> unordered_set<__iterator_value_type<_InputIterator>, |
| 990 | _Hash, | ||
| 991 | equal_to<__iterator_value_type<_InputIterator>>, | ||
| 992 | _Allocator>; | ||
| 986 | 993 | ||
| 987 | # if _LIBCPP_STD_VER >= 23 | 994 | # if _LIBCPP_STD_VER >= 23 |
| 988 | 995 | ||
| 989 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 996 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 990 | unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) | 997 | unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 991 | -> unordered_set<ranges::range_value_t<_Range>, | 998 | -> unordered_set<ranges::range_value_t<_Range>, |
| 992 | hash<ranges::range_value_t<_Range>>, | 999 | hash<ranges::range_value_t<_Range>>, |
| 993 | equal_to<ranges::range_value_t<_Range>>, | 1000 | equal_to<ranges::range_value_t<_Range>>, |
| 994 | _Allocator>; | 1001 | _Allocator>; |
| 995 | 1002 | ||
| 996 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1003 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 997 | unordered_set(from_range_t, _Range&&, _Allocator) | 1004 | unordered_set(from_range_t, _Range&&, _Allocator) |
| 998 | -> unordered_set<ranges::range_value_t<_Range>, | 1005 | -> unordered_set<ranges::range_value_t<_Range>, |
| 999 | hash<ranges::range_value_t<_Range>>, | 1006 | hash<ranges::range_value_t<_Range>>, |
| ... | @@ -1003,24 +1010,24 @@ unordered_set(from_range_t, _Range&&, _Allocator) | ... | @@ -1003,24 +1010,24 @@ unordered_set(from_range_t, _Range&&, _Allocator) |
| 1003 | template <ranges::input_range _Range, | 1010 | template <ranges::input_range _Range, |
| 1004 | class _Hash, | 1011 | class _Hash, |
| 1005 | class _Allocator, | 1012 | class _Allocator, |
| 1006 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1013 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1007 | class = enable_if_t<!is_integral<_Hash>::value>, | 1014 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1008 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1015 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1009 | unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1016 | unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1010 | -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; | 1017 | -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; |
| 1011 | 1018 | ||
| 1012 | # endif | 1019 | # endif |
| 1013 | 1020 | ||
| 1014 | template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1021 | template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1015 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) | 1022 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1016 | -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; | 1023 | -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; |
| 1017 | 1024 | ||
| 1018 | template <class _Tp, | 1025 | template <class _Tp, |
| 1019 | class _Hash, | 1026 | class _Hash, |
| 1020 | class _Allocator, | 1027 | class _Allocator, |
| 1021 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1028 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1022 | class = enable_if_t<!is_integral<_Hash>::value>, | 1029 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1023 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1030 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1024 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1031 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1025 | -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; | 1032 | -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; |
| 1026 | # endif | 1033 | # endif |
| ... | @@ -1070,12 +1077,6 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( | ... | @@ -1070,12 +1077,6 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1070 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1077 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1071 | inline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const allocator_type& __a) : __table_(__a) {} | 1078 | inline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const allocator_type& __a) : __table_(__a) {} |
| 1072 | 1079 | ||
| 1073 | template <class _Value, class _Hash, class _Pred, class _Alloc> | ||
| 1074 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& __u) : __table_(__u.__table_) { | ||
| 1075 | __table_.__rehash_unique(__u.bucket_count()); | ||
| 1076 | insert(__u.begin(), __u.end()); | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1080 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1080 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& __u, const allocator_type& __a) | 1081 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& __u, const allocator_type& __a) |
| 1081 | : __table_(__u.__table_, __a) { | 1082 | : __table_(__u.__table_, __a) { |
| ... | @@ -1085,11 +1086,6 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& | ... | @@ -1085,11 +1086,6 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& |
| 1085 | 1086 | ||
| 1086 | # ifndef _LIBCPP_CXX03_LANG | 1087 | # ifndef _LIBCPP_CXX03_LANG |
| 1087 | 1088 | ||
| 1088 | template <class _Value, class _Hash, class _Pred, class _Alloc> | ||
| 1089 | inline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u) | ||
| 1090 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) | ||
| 1091 | : __table_(std::move(__u.__table_)) {} | ||
| 1092 | |||
| 1093 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1089 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1094 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u, const allocator_type& __a) | 1090 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u, const allocator_type& __a) |
| 1095 | : __table_(std::move(__u.__table_), __a) { | 1091 | : __table_(std::move(__u.__table_), __a) { |
| ... | @@ -1125,14 +1121,6 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( | ... | @@ -1125,14 +1121,6 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1125 | insert(__il.begin(), __il.end()); | 1121 | insert(__il.begin(), __il.end()); |
| 1126 | } | 1122 | } |
| 1127 | 1123 | ||
| 1128 | template <class _Value, class _Hash, class _Pred, class _Alloc> | ||
| 1129 | inline unordered_set<_Value, _Hash, _Pred, _Alloc>& | ||
| 1130 | unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u) | ||
| 1131 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) { | ||
| 1132 | __table_ = std::move(__u.__table_); | ||
| 1133 | return *this; | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1124 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1137 | inline unordered_set<_Value, _Hash, _Pred, _Alloc>& | 1125 | inline unordered_set<_Value, _Hash, _Pred, _Alloc>& |
| 1138 | unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { | 1126 | unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { |
| ... | @@ -1308,11 +1296,10 @@ public: | ... | @@ -1308,11 +1296,10 @@ public: |
| 1308 | # endif | 1296 | # endif |
| 1309 | 1297 | ||
| 1310 | _LIBCPP_HIDE_FROM_ABI explicit unordered_multiset(const allocator_type& __a); | 1298 | _LIBCPP_HIDE_FROM_ABI explicit unordered_multiset(const allocator_type& __a); |
| 1311 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u); | 1299 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u) = default; |
| 1312 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); | 1300 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); |
| 1313 | # ifndef _LIBCPP_CXX03_LANG | 1301 | # ifndef _LIBCPP_CXX03_LANG |
| 1314 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u) | 1302 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u) = default; |
| 1315 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); | ||
| 1316 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a); | 1303 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a); |
| 1317 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(initializer_list<value_type> __il); | 1304 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(initializer_list<value_type> __il); |
| 1318 | _LIBCPP_HIDE_FROM_ABI unordered_multiset( | 1305 | _LIBCPP_HIDE_FROM_ABI unordered_multiset( |
| ... | @@ -1339,30 +1326,26 @@ public: | ... | @@ -1339,30 +1326,26 @@ public: |
| 1339 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); | 1326 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); |
| 1340 | } | 1327 | } |
| 1341 | 1328 | ||
| 1342 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(const unordered_multiset& __u) { | 1329 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(const unordered_multiset& __u) = default; |
| 1343 | __table_ = __u.__table_; | ||
| 1344 | return *this; | ||
| 1345 | } | ||
| 1346 | # ifndef _LIBCPP_CXX03_LANG | 1330 | # ifndef _LIBCPP_CXX03_LANG |
| 1347 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(unordered_multiset&& __u) | 1331 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(unordered_multiset&& __u) = default; |
| 1348 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); | ||
| 1349 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il); | 1332 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il); |
| 1350 | # endif // _LIBCPP_CXX03_LANG | 1333 | # endif // _LIBCPP_CXX03_LANG |
| 1351 | 1334 | ||
| 1352 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | 1335 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 1353 | return allocator_type(__table_.__node_alloc()); | 1336 | return allocator_type(__table_.__node_alloc()); |
| 1354 | } | 1337 | } |
| 1355 | 1338 | ||
| 1356 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | 1339 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } |
| 1357 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } | 1340 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 1358 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } | 1341 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 1359 | 1342 | ||
| 1360 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } | 1343 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); } |
| 1361 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } | 1344 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); } |
| 1362 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } | 1345 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); } |
| 1363 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } | 1346 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); } |
| 1364 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } | 1347 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 1365 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } | 1348 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 1366 | 1349 | ||
| 1367 | # ifndef _LIBCPP_CXX03_LANG | 1350 | # ifndef _LIBCPP_CXX03_LANG |
| 1368 | template <class... _Args> | 1351 | template <class... _Args> |
| ... | @@ -1410,10 +1393,10 @@ public: | ... | @@ -1410,10 +1393,10 @@ public: |
| 1410 | "node_type with incompatible allocator passed to unordered_multiset::insert()"); | 1393 | "node_type with incompatible allocator passed to unordered_multiset::insert()"); |
| 1411 | return __table_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh)); | 1394 | return __table_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh)); |
| 1412 | } | 1395 | } |
| 1413 | _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __position) { | 1396 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __position) { |
| 1414 | return __table_.template __node_handle_extract<node_type>(__position); | 1397 | return __table_.template __node_handle_extract<node_type>(__position); |
| 1415 | } | 1398 | } |
| 1416 | _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { | 1399 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) { |
| 1417 | return __table_.template __node_handle_extract<node_type>(__key); | 1400 | return __table_.template __node_handle_extract<node_type>(__key); |
| 1418 | } | 1401 | } |
| 1419 | 1402 | ||
| ... | @@ -1454,71 +1437,81 @@ public: | ... | @@ -1454,71 +1437,81 @@ public: |
| 1454 | __table_.swap(__u.__table_); | 1437 | __table_.swap(__u.__table_); |
| 1455 | } | 1438 | } |
| 1456 | 1439 | ||
| 1457 | _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); } | 1440 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); } |
| 1458 | _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); } | 1441 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); } |
| 1459 | 1442 | ||
| 1460 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } | 1443 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 1461 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } | 1444 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 1462 | # if _LIBCPP_STD_VER >= 20 | 1445 | # if _LIBCPP_STD_VER >= 20 |
| 1463 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1446 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1464 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { | 1447 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1465 | return __table_.find(__k); | 1448 | return __table_.find(__k); |
| 1466 | } | 1449 | } |
| 1467 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1450 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1468 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { | 1451 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1469 | return __table_.find(__k); | 1452 | return __table_.find(__k); |
| 1470 | } | 1453 | } |
| 1471 | # endif // _LIBCPP_STD_VER >= 20 | 1454 | # endif // _LIBCPP_STD_VER >= 20 |
| 1472 | 1455 | ||
| 1473 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } | 1456 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { |
| 1457 | return __table_.__count_multi(__k); | ||
| 1458 | } | ||
| 1474 | # if _LIBCPP_STD_VER >= 20 | 1459 | # if _LIBCPP_STD_VER >= 20 |
| 1475 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1460 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1476 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { | 1461 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1477 | return __table_.__count_multi(__k); | 1462 | return __table_.__count_multi(__k); |
| 1478 | } | 1463 | } |
| 1479 | # endif // _LIBCPP_STD_VER >= 20 | 1464 | # endif // _LIBCPP_STD_VER >= 20 |
| 1480 | 1465 | ||
| 1481 | # if _LIBCPP_STD_VER >= 20 | 1466 | # if _LIBCPP_STD_VER >= 20 |
| 1482 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } | 1467 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1483 | 1468 | ||
| 1484 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1469 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1485 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { | 1470 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1486 | return find(__k) != end(); | 1471 | return find(__k) != end(); |
| 1487 | } | 1472 | } |
| 1488 | # endif // _LIBCPP_STD_VER >= 20 | 1473 | # endif // _LIBCPP_STD_VER >= 20 |
| 1489 | 1474 | ||
| 1490 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { | 1475 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1491 | return __table_.__equal_range_multi(__k); | 1476 | return __table_.__equal_range_multi(__k); |
| 1492 | } | 1477 | } |
| 1493 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { | 1478 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1494 | return __table_.__equal_range_multi(__k); | 1479 | return __table_.__equal_range_multi(__k); |
| 1495 | } | 1480 | } |
| 1496 | # if _LIBCPP_STD_VER >= 20 | 1481 | # if _LIBCPP_STD_VER >= 20 |
| 1497 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1482 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1498 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { | 1483 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1499 | return __table_.__equal_range_multi(__k); | 1484 | return __table_.__equal_range_multi(__k); |
| 1500 | } | 1485 | } |
| 1501 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> | 1486 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1502 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { | 1487 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1503 | return __table_.__equal_range_multi(__k); | 1488 | return __table_.__equal_range_multi(__k); |
| 1504 | } | 1489 | } |
| 1505 | # endif // _LIBCPP_STD_VER >= 20 | 1490 | # endif // _LIBCPP_STD_VER >= 20 |
| 1506 | 1491 | ||
| 1507 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } | 1492 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } |
| 1508 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } | 1493 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { |
| 1494 | return __table_.max_bucket_count(); | ||
| 1495 | } | ||
| 1509 | 1496 | ||
| 1510 | _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); } | 1497 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { |
| 1511 | _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | 1498 | return __table_.bucket_size(__n); |
| 1499 | } | ||
| 1500 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); } | ||
| 1512 | 1501 | ||
| 1513 | _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } | 1502 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); } |
| 1514 | _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } | 1503 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); } |
| 1515 | _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); } | 1504 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { |
| 1516 | _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } | 1505 | return __table_.cbegin(__n); |
| 1517 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); } | 1506 | } |
| 1518 | _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | 1507 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); } |
| 1508 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { | ||
| 1509 | return __table_.cbegin(__n); | ||
| 1510 | } | ||
| 1511 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); } | ||
| 1519 | 1512 | ||
| 1520 | _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } | 1513 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); } |
| 1521 | _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } | 1514 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); } |
| 1522 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } | 1515 | _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); } |
| 1523 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); } | 1516 | _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); } |
| 1524 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); } | 1517 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); } |
| ... | @@ -1526,31 +1519,31 @@ public: | ... | @@ -1526,31 +1519,31 @@ public: |
| 1526 | 1519 | ||
| 1527 | # if _LIBCPP_STD_VER >= 17 | 1520 | # if _LIBCPP_STD_VER >= 17 |
| 1528 | template <class _InputIterator, | 1521 | template <class _InputIterator, |
| 1529 | class _Hash = hash<__iter_value_type<_InputIterator>>, | 1522 | class _Hash = hash<__iterator_value_type<_InputIterator>>, |
| 1530 | class _Pred = equal_to<__iter_value_type<_InputIterator>>, | 1523 | class _Pred = equal_to<__iterator_value_type<_InputIterator>>, |
| 1531 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, | 1524 | class _Allocator = allocator<__iterator_value_type<_InputIterator>>, |
| 1532 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1525 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1533 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1526 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1534 | class = enable_if_t<!is_integral<_Hash>::value>, | 1527 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1535 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 1528 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 1536 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1529 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1537 | unordered_multiset( | 1530 | unordered_multiset( |
| 1538 | _InputIterator, | 1531 | _InputIterator, |
| 1539 | _InputIterator, | 1532 | _InputIterator, |
| 1540 | typename allocator_traits<_Allocator>::size_type = 0, | 1533 | typename allocator_traits<_Allocator>::size_type = 0, |
| 1541 | _Hash = _Hash(), | 1534 | _Hash = _Hash(), |
| 1542 | _Pred = _Pred(), | 1535 | _Pred = _Pred(), |
| 1543 | _Allocator = _Allocator()) -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; | 1536 | _Allocator = _Allocator()) -> unordered_multiset<__iterator_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| 1544 | 1537 | ||
| 1545 | # if _LIBCPP_STD_VER >= 23 | 1538 | # if _LIBCPP_STD_VER >= 23 |
| 1546 | template <ranges::input_range _Range, | 1539 | template <ranges::input_range _Range, |
| 1547 | class _Hash = hash<ranges::range_value_t<_Range>>, | 1540 | class _Hash = hash<ranges::range_value_t<_Range>>, |
| 1548 | class _Pred = equal_to<ranges::range_value_t<_Range>>, | 1541 | class _Pred = equal_to<ranges::range_value_t<_Range>>, |
| 1549 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | 1542 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 1550 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1543 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1551 | class = enable_if_t<!is_integral<_Hash>::value>, | 1544 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1552 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 1545 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 1553 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1546 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1554 | unordered_multiset( | 1547 | unordered_multiset( |
| 1555 | from_range_t, | 1548 | from_range_t, |
| 1556 | _Range&&, | 1549 | _Range&&, |
| ... | @@ -1564,10 +1557,10 @@ template <class _Tp, | ... | @@ -1564,10 +1557,10 @@ template <class _Tp, |
| 1564 | class _Hash = hash<_Tp>, | 1557 | class _Hash = hash<_Tp>, |
| 1565 | class _Pred = equal_to<_Tp>, | 1558 | class _Pred = equal_to<_Tp>, |
| 1566 | class _Allocator = allocator<_Tp>, | 1559 | class _Allocator = allocator<_Tp>, |
| 1567 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1560 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1568 | class = enable_if_t<!is_integral<_Hash>::value>, | 1561 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1569 | class = enable_if_t<!__is_allocator<_Pred>::value>, | 1562 | class = enable_if_t<!__is_allocator_v<_Pred>>, |
| 1570 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1563 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1571 | unordered_multiset(initializer_list<_Tp>, | 1564 | unordered_multiset(initializer_list<_Tp>, |
| 1572 | typename allocator_traits<_Allocator>::size_type = 0, | 1565 | typename allocator_traits<_Allocator>::size_type = 0, |
| 1573 | _Hash = _Hash(), | 1566 | _Hash = _Hash(), |
| ... | @@ -1577,36 +1570,36 @@ unordered_multiset(initializer_list<_Tp>, | ... | @@ -1577,36 +1570,36 @@ unordered_multiset(initializer_list<_Tp>, |
| 1577 | template <class _InputIterator, | 1570 | template <class _InputIterator, |
| 1578 | class _Allocator, | 1571 | class _Allocator, |
| 1579 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1572 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1580 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1573 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1581 | unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) | 1574 | unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1582 | -> unordered_multiset<__iter_value_type<_InputIterator>, | 1575 | -> unordered_multiset<__iterator_value_type<_InputIterator>, |
| 1583 | hash<__iter_value_type<_InputIterator>>, | 1576 | hash<__iterator_value_type<_InputIterator>>, |
| 1584 | equal_to<__iter_value_type<_InputIterator>>, | 1577 | equal_to<__iterator_value_type<_InputIterator>>, |
| 1585 | _Allocator>; | 1578 | _Allocator>; |
| 1586 | 1579 | ||
| 1587 | template <class _InputIterator, | 1580 | template <class _InputIterator, |
| 1588 | class _Hash, | 1581 | class _Hash, |
| 1589 | class _Allocator, | 1582 | class _Allocator, |
| 1590 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | 1583 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1591 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1584 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1592 | class = enable_if_t<!is_integral<_Hash>::value>, | 1585 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1593 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1586 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1594 | unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1587 | unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1595 | -> unordered_multiset<__iter_value_type<_InputIterator>, | 1588 | -> unordered_multiset<__iterator_value_type<_InputIterator>, |
| 1596 | _Hash, | 1589 | _Hash, |
| 1597 | equal_to<__iter_value_type<_InputIterator>>, | 1590 | equal_to<__iterator_value_type<_InputIterator>>, |
| 1598 | _Allocator>; | 1591 | _Allocator>; |
| 1599 | 1592 | ||
| 1600 | # if _LIBCPP_STD_VER >= 23 | 1593 | # if _LIBCPP_STD_VER >= 23 |
| 1601 | 1594 | ||
| 1602 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1595 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1603 | unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) | 1596 | unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1604 | -> unordered_multiset<ranges::range_value_t<_Range>, | 1597 | -> unordered_multiset<ranges::range_value_t<_Range>, |
| 1605 | hash<ranges::range_value_t<_Range>>, | 1598 | hash<ranges::range_value_t<_Range>>, |
| 1606 | equal_to<ranges::range_value_t<_Range>>, | 1599 | equal_to<ranges::range_value_t<_Range>>, |
| 1607 | _Allocator>; | 1600 | _Allocator>; |
| 1608 | 1601 | ||
| 1609 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1602 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1610 | unordered_multiset(from_range_t, _Range&&, _Allocator) | 1603 | unordered_multiset(from_range_t, _Range&&, _Allocator) |
| 1611 | -> unordered_multiset<ranges::range_value_t<_Range>, | 1604 | -> unordered_multiset<ranges::range_value_t<_Range>, |
| 1612 | hash<ranges::range_value_t<_Range>>, | 1605 | hash<ranges::range_value_t<_Range>>, |
| ... | @@ -1616,24 +1609,24 @@ unordered_multiset(from_range_t, _Range&&, _Allocator) | ... | @@ -1616,24 +1609,24 @@ unordered_multiset(from_range_t, _Range&&, _Allocator) |
| 1616 | template <ranges::input_range _Range, | 1609 | template <ranges::input_range _Range, |
| 1617 | class _Hash, | 1610 | class _Hash, |
| 1618 | class _Allocator, | 1611 | class _Allocator, |
| 1619 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1612 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1620 | class = enable_if_t<!is_integral<_Hash>::value>, | 1613 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1621 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1614 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1622 | unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1615 | unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1623 | -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; | 1616 | -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; |
| 1624 | 1617 | ||
| 1625 | # endif | 1618 | # endif |
| 1626 | 1619 | ||
| 1627 | template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> | 1620 | template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1628 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) | 1621 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1629 | -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; | 1622 | -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; |
| 1630 | 1623 | ||
| 1631 | template <class _Tp, | 1624 | template <class _Tp, |
| 1632 | class _Hash, | 1625 | class _Hash, |
| 1633 | class _Allocator, | 1626 | class _Allocator, |
| 1634 | class = enable_if_t<!__is_allocator<_Hash>::value>, | 1627 | class = enable_if_t<!__is_allocator_v<_Hash>>, |
| 1635 | class = enable_if_t<!is_integral<_Hash>::value>, | 1628 | class = enable_if_t<!is_integral<_Hash>::value>, |
| 1636 | class = enable_if_t<__is_allocator<_Allocator>::value>> | 1629 | class = enable_if_t<__is_allocator_v<_Allocator>>> |
| 1637 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) | 1630 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1638 | -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; | 1631 | -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; |
| 1639 | # endif | 1632 | # endif |
| ... | @@ -1685,13 +1678,6 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> | ... | @@ -1685,13 +1678,6 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1685 | inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(const allocator_type& __a) | 1678 | inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(const allocator_type& __a) |
| 1686 | : __table_(__a) {} | 1679 | : __table_(__a) {} |
| 1687 | 1680 | ||
| 1688 | template <class _Value, class _Hash, class _Pred, class _Alloc> | ||
| 1689 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(const unordered_multiset& __u) | ||
| 1690 | : __table_(__u.__table_) { | ||
| 1691 | __table_.__rehash_multi(__u.bucket_count()); | ||
| 1692 | insert(__u.begin(), __u.end()); | ||
| 1693 | } | ||
| 1694 | |||
| 1695 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1681 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1696 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( | 1682 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1697 | const unordered_multiset& __u, const allocator_type& __a) | 1683 | const unordered_multiset& __u, const allocator_type& __a) |
| ... | @@ -1702,11 +1688,6 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( | ... | @@ -1702,11 +1688,6 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1702 | 1688 | ||
| 1703 | # ifndef _LIBCPP_CXX03_LANG | 1689 | # ifndef _LIBCPP_CXX03_LANG |
| 1704 | 1690 | ||
| 1705 | template <class _Value, class _Hash, class _Pred, class _Alloc> | ||
| 1706 | inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(unordered_multiset&& __u) | ||
| 1707 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) | ||
| 1708 | : __table_(std::move(__u.__table_)) {} | ||
| 1709 | |||
| 1710 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1691 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1711 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( | 1692 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1712 | unordered_multiset&& __u, const allocator_type& __a) | 1693 | unordered_multiset&& __u, const allocator_type& __a) |
| ... | @@ -1743,14 +1724,6 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( | ... | @@ -1743,14 +1724,6 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1743 | insert(__il.begin(), __il.end()); | 1724 | insert(__il.begin(), __il.end()); |
| 1744 | } | 1725 | } |
| 1745 | 1726 | ||
| 1746 | template <class _Value, class _Hash, class _Pred, class _Alloc> | ||
| 1747 | inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>& | ||
| 1748 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_multiset&& __u) | ||
| 1749 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) { | ||
| 1750 | __table_ = std::move(__u.__table_); | ||
| 1751 | return *this; | ||
| 1752 | } | ||
| 1753 | |||
| 1754 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1727 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1755 | inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>& | 1728 | inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>& |
| 1756 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { | 1729 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) { |
lib/libcxx/include/utility+12| ... | @@ -216,6 +216,18 @@ template<size_t N> | ... | @@ -216,6 +216,18 @@ template<size_t N> |
| 216 | template<class... T> | 216 | template<class... T> |
| 217 | using index_sequence_for = make_index_sequence<sizeof...(T)>; | 217 | using index_sequence_for = make_index_sequence<sizeof...(T)>; |
| 218 | 218 | ||
| 219 | template<class T, T... Values> // C++26 | ||
| 220 | struct tuple_size<integer_sequence<T, Values...>>; | ||
| 221 | |||
| 222 | template<size_t I, class T, T... Values> // C++26 | ||
| 223 | struct tuple_element<I, integer_sequence<T, Values...>>; | ||
| 224 | |||
| 225 | template<size_t I, class T, T... Values> // C++26 | ||
| 226 | struct tuple_element<I, const integer_sequence<T, Values...>>; | ||
| 227 | |||
| 228 | template<size_t I, class T, T... Values> // C++26 | ||
| 229 | constexpr T get(integer_sequence<T, Values...>) noexcept; | ||
| 230 | |||
| 219 | template<class T, class U=T> | 231 | template<class T, class U=T> |
| 220 | constexpr T exchange(T& obj, U&& new_value) // constexpr in C++17, noexcept in C++23 | 232 | constexpr T exchange(T& obj, U&& new_value) // constexpr in C++17, noexcept in C++23 |
| 221 | noexcept(is_nothrow_move_constructible<T>::value && is_nothrow_assignable<T&, U>::value); | 233 | noexcept(is_nothrow_move_constructible<T>::value && is_nothrow_assignable<T&, U>::value); |
lib/libcxx/include/valarray+106-161| ... | @@ -362,6 +362,7 @@ template <class T> unspecified2 end(const valarray<T>& v); | ... | @@ -362,6 +362,7 @@ template <class T> unspecified2 end(const valarray<T>& v); |
| 362 | # include <__memory/uninitialized_algorithms.h> | 362 | # include <__memory/uninitialized_algorithms.h> |
| 363 | # include <__type_traits/decay.h> | 363 | # include <__type_traits/decay.h> |
| 364 | # include <__type_traits/remove_reference.h> | 364 | # include <__type_traits/remove_reference.h> |
| 365 | # include <__utility/exception_guard.h> | ||
| 365 | # include <__utility/move.h> | 366 | # include <__utility/move.h> |
| 366 | # include <__utility/swap.h> | 367 | # include <__utility/swap.h> |
| 367 | # include <cmath> | 368 | # include <cmath> |
| ... | @@ -395,9 +396,9 @@ public: | ... | @@ -395,9 +396,9 @@ public: |
| 395 | _LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride) | 396 | _LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride) |
| 396 | : __start_(__start), __size_(__size), __stride_(__stride) {} | 397 | : __start_(__start), __size_(__size), __stride_(__stride) {} |
| 397 | 398 | ||
| 398 | _LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; } | 399 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; } |
| 399 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } | 400 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
| 400 | _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; } | 401 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; } |
| 401 | 402 | ||
| 402 | # if _LIBCPP_STD_VER >= 20 | 403 | # if _LIBCPP_STD_VER >= 20 |
| 403 | 404 | ||
| ... | @@ -792,7 +793,7 @@ private: | ... | @@ -792,7 +793,7 @@ private: |
| 792 | public: | 793 | public: |
| 793 | // construct/destroy: | 794 | // construct/destroy: |
| 794 | _LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {} | 795 | _LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {} |
| 795 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit valarray(size_t __n); | 796 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 explicit valarray(size_t __n); |
| 796 | _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n); | 797 | _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n); |
| 797 | valarray(const value_type* __p, size_t __n); | 798 | valarray(const value_type* __p, size_t __n); |
| 798 | valarray(const valarray& __v); | 799 | valarray(const valarray& __v); |
| ... | @@ -804,7 +805,7 @@ public: | ... | @@ -804,7 +805,7 @@ public: |
| 804 | valarray(const gslice_array<value_type>& __ga); | 805 | valarray(const gslice_array<value_type>& __ga); |
| 805 | valarray(const mask_array<value_type>& __ma); | 806 | valarray(const mask_array<value_type>& __ma); |
| 806 | valarray(const indirect_array<value_type>& __ia); | 807 | valarray(const indirect_array<value_type>& __ia); |
| 807 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 ~valarray(); | 808 | inline _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8 ~valarray(); |
| 808 | 809 | ||
| 809 | // assignment: | 810 | // assignment: |
| 810 | valarray& operator=(const valarray& __v); | 811 | valarray& operator=(const valarray& __v); |
| ... | @@ -821,36 +822,41 @@ public: | ... | @@ -821,36 +822,41 @@ public: |
| 821 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v); | 822 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v); |
| 822 | 823 | ||
| 823 | // element access: | 824 | // element access: |
| 824 | _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { | 825 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { |
| 825 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds"); | 826 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds"); |
| 826 | return __begin_[__i]; | 827 | return __begin_[__i]; |
| 827 | } | 828 | } |
| 828 | 829 | ||
| 829 | _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { | 830 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { |
| 830 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds"); | 831 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds"); |
| 831 | return __begin_[__i]; | 832 | return __begin_[__i]; |
| 832 | } | 833 | } |
| 833 | 834 | ||
| 834 | // subset operations: | 835 | // subset operations: |
| 835 | _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; | 836 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; |
| 836 | _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s); | 837 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s); |
| 837 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; | 838 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > |
| 838 | _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs); | 839 | operator[](const gslice& __gs) const; |
| 840 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs); | ||
| 839 | # ifndef _LIBCPP_CXX03_LANG | 841 | # ifndef _LIBCPP_CXX03_LANG |
| 840 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; | 842 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; |
| 841 | _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs); | 843 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs); |
| 842 | # endif // _LIBCPP_CXX03_LANG | 844 | # endif // _LIBCPP_CXX03_LANG |
| 845 | [[__nodiscard__]] | ||
| 843 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; | 846 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; |
| 844 | _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb); | 847 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb); |
| 845 | # ifndef _LIBCPP_CXX03_LANG | 848 | # ifndef _LIBCPP_CXX03_LANG |
| 849 | [[__nodiscard__]] | ||
| 846 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; | 850 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; |
| 847 | _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb); | 851 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb); |
| 848 | # endif // _LIBCPP_CXX03_LANG | 852 | # endif // _LIBCPP_CXX03_LANG |
| 853 | [[__nodiscard__]] | ||
| 849 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; | 854 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; |
| 850 | _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs); | 855 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs); |
| 851 | # ifndef _LIBCPP_CXX03_LANG | 856 | # ifndef _LIBCPP_CXX03_LANG |
| 857 | [[__nodiscard__]] | ||
| 852 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; | 858 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; |
| 853 | _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs); | 859 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs); |
| 854 | # endif // _LIBCPP_CXX03_LANG | 860 | # endif // _LIBCPP_CXX03_LANG |
| 855 | 861 | ||
| 856 | // unary operators: | 862 | // unary operators: |
| ... | @@ -904,16 +910,16 @@ public: | ... | @@ -904,16 +910,16 @@ public: |
| 904 | // member functions: | 910 | // member functions: |
| 905 | _LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT; | 911 | _LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT; |
| 906 | 912 | ||
| 907 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); } | 913 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); } |
| 908 | 914 | ||
| 909 | _LIBCPP_HIDE_FROM_ABI value_type sum() const; | 915 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_type sum() const; |
| 910 | _LIBCPP_HIDE_FROM_ABI value_type min() const; | 916 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_type min() const; |
| 911 | _LIBCPP_HIDE_FROM_ABI value_type max() const; | 917 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_type max() const; |
| 912 | 918 | ||
| 913 | valarray shift(int __i) const; | 919 | [[__nodiscard__]] valarray shift(int __i) const; |
| 914 | valarray cshift(int __i) const; | 920 | [[__nodiscard__]] valarray cshift(int __i) const; |
| 915 | valarray apply(value_type __f(value_type)) const; | 921 | [[__nodiscard__]] valarray apply(value_type __f(value_type)) const; |
| 916 | valarray apply(value_type __f(const value_type&)) const; | 922 | [[__nodiscard__]] valarray apply(value_type __f(const value_type&)) const; |
| 917 | void resize(size_t __n, value_type __x = value_type()); | 923 | void resize(size_t __n, value_type __x = value_type()); |
| 918 | 924 | ||
| 919 | private: | 925 | private: |
| ... | @@ -1248,11 +1254,11 @@ public: | ... | @@ -1248,11 +1254,11 @@ public: |
| 1248 | 1254 | ||
| 1249 | # endif // _LIBCPP_CXX03_LANG | 1255 | # endif // _LIBCPP_CXX03_LANG |
| 1250 | 1256 | ||
| 1251 | _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; } | 1257 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; } |
| 1252 | 1258 | ||
| 1253 | _LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; } | 1259 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; } |
| 1254 | 1260 | ||
| 1255 | _LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; } | 1261 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; } |
| 1256 | 1262 | ||
| 1257 | private: | 1263 | private: |
| 1258 | void __init(size_t __start); | 1264 | void __init(size_t __start); |
| ... | @@ -1992,17 +1998,10 @@ template <class _Tp> | ... | @@ -1992,17 +1998,10 @@ template <class _Tp> |
| 1992 | inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) { | 1998 | inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) { |
| 1993 | if (__n) { | 1999 | if (__n) { |
| 1994 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2000 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 1995 | # if _LIBCPP_HAS_EXCEPTIONS | 2001 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 1996 | try { | 2002 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
| 1997 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2003 | ::new ((void*)__end_) value_type(); |
| 1998 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) | 2004 | __guard.__complete(); |
| 1999 | ::new ((void*)__end_) value_type(); | ||
| 2000 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2001 | } catch (...) { | ||
| 2002 | __clear(__n); | ||
| 2003 | throw; | ||
| 2004 | } | ||
| 2005 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2006 | } | 2005 | } |
| 2007 | } | 2006 | } |
| 2008 | 2007 | ||
| ... | @@ -2015,17 +2014,10 @@ template <class _Tp> | ... | @@ -2015,17 +2014,10 @@ template <class _Tp> |
| 2015 | valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) { | 2014 | valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) { |
| 2016 | if (__n) { | 2015 | if (__n) { |
| 2017 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2016 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2018 | # if _LIBCPP_HAS_EXCEPTIONS | 2017 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 2019 | try { | 2018 | for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) |
| 2020 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2019 | ::new ((void*)__end_) value_type(*__p); |
| 2021 | for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) | 2020 | __guard.__complete(); |
| 2022 | ::new ((void*)__end_) value_type(*__p); | ||
| 2023 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2024 | } catch (...) { | ||
| 2025 | __clear(__n); | ||
| 2026 | throw; | ||
| 2027 | } | ||
| 2028 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2029 | } | 2021 | } |
| 2030 | } | 2022 | } |
| 2031 | 2023 | ||
| ... | @@ -2033,17 +2025,10 @@ template <class _Tp> | ... | @@ -2033,17 +2025,10 @@ template <class _Tp> |
| 2033 | valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) { | 2025 | valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) { |
| 2034 | if (__v.size()) { | 2026 | if (__v.size()) { |
| 2035 | __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); | 2027 | __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); |
| 2036 | # if _LIBCPP_HAS_EXCEPTIONS | 2028 | auto __guard = std::__make_exception_guard([&] { __clear(__v.size()); }); |
| 2037 | try { | 2029 | for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) |
| 2038 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2030 | ::new ((void*)__end_) value_type(*__p); |
| 2039 | for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) | 2031 | __guard.__complete(); |
| 2040 | ::new ((void*)__end_) value_type(*__p); | ||
| 2041 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2042 | } catch (...) { | ||
| 2043 | __clear(__v.size()); | ||
| 2044 | throw; | ||
| 2045 | } | ||
| 2046 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2047 | } | 2032 | } |
| 2048 | } | 2033 | } |
| 2049 | 2034 | ||
| ... | @@ -2059,18 +2044,11 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr), | ... | @@ -2059,18 +2044,11 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr), |
| 2059 | const size_t __n = __il.size(); | 2044 | const size_t __n = __il.size(); |
| 2060 | if (__n) { | 2045 | if (__n) { |
| 2061 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2046 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2062 | # if _LIBCPP_HAS_EXCEPTIONS | 2047 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 2063 | try { | 2048 | size_t __n_left = __n; |
| 2064 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2049 | for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) |
| 2065 | size_t __n_left = __n; | 2050 | ::new ((void*)__end_) value_type(*__p); |
| 2066 | for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) | 2051 | __guard.__complete(); |
| 2067 | ::new ((void*)__end_) value_type(*__p); | ||
| 2068 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2069 | } catch (...) { | ||
| 2070 | __clear(__n); | ||
| 2071 | throw; | ||
| 2072 | } | ||
| 2073 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2074 | } | 2052 | } |
| 2075 | } | 2053 | } |
| 2076 | 2054 | ||
| ... | @@ -2081,18 +2059,11 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr) | ... | @@ -2081,18 +2059,11 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr) |
| 2081 | const size_t __n = __sa.__size_; | 2059 | const size_t __n = __sa.__size_; |
| 2082 | if (__n) { | 2060 | if (__n) { |
| 2083 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2061 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2084 | # if _LIBCPP_HAS_EXCEPTIONS | 2062 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 2085 | try { | 2063 | size_t __n_left = __n; |
| 2086 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2064 | for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) |
| 2087 | size_t __n_left = __n; | 2065 | ::new ((void*)__end_) value_type(*__p); |
| 2088 | for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) | 2066 | __guard.__complete(); |
| 2089 | ::new ((void*)__end_) value_type(*__p); | ||
| 2090 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2091 | } catch (...) { | ||
| 2092 | __clear(__n); | ||
| 2093 | throw; | ||
| 2094 | } | ||
| 2095 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2096 | } | 2067 | } |
| 2097 | } | 2068 | } |
| 2098 | 2069 | ||
| ... | @@ -2101,19 +2072,12 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr | ... | @@ -2101,19 +2072,12 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr |
| 2101 | const size_t __n = __ga.__1d_.size(); | 2072 | const size_t __n = __ga.__1d_.size(); |
| 2102 | if (__n) { | 2073 | if (__n) { |
| 2103 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2074 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2104 | # if _LIBCPP_HAS_EXCEPTIONS | 2075 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 2105 | try { | 2076 | typedef const size_t* _Ip; |
| 2106 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2077 | const value_type* __s = __ga.__vp_; |
| 2107 | typedef const size_t* _Ip; | 2078 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2108 | const value_type* __s = __ga.__vp_; | 2079 | ::new ((void*)__end_) value_type(__s[*__i]); |
| 2109 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) | 2080 | __guard.__complete(); |
| 2110 | ::new ((void*)__end_) value_type(__s[*__i]); | ||
| 2111 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2112 | } catch (...) { | ||
| 2113 | __clear(__n); | ||
| 2114 | throw; | ||
| 2115 | } | ||
| 2116 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2117 | } | 2081 | } |
| 2118 | } | 2082 | } |
| 2119 | 2083 | ||
| ... | @@ -2122,19 +2086,12 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), | ... | @@ -2122,19 +2086,12 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), |
| 2122 | const size_t __n = __ma.__1d_.size(); | 2086 | const size_t __n = __ma.__1d_.size(); |
| 2123 | if (__n) { | 2087 | if (__n) { |
| 2124 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2088 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2125 | # if _LIBCPP_HAS_EXCEPTIONS | 2089 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 2126 | try { | 2090 | typedef const size_t* _Ip; |
| 2127 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2091 | const value_type* __s = __ma.__vp_; |
| 2128 | typedef const size_t* _Ip; | 2092 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2129 | const value_type* __s = __ma.__vp_; | 2093 | ::new ((void*)__end_) value_type(__s[*__i]); |
| 2130 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) | 2094 | __guard.__complete(); |
| 2131 | ::new ((void*)__end_) value_type(__s[*__i]); | ||
| 2132 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2133 | } catch (...) { | ||
| 2134 | __clear(__n); | ||
| 2135 | throw; | ||
| 2136 | } | ||
| 2137 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2138 | } | 2095 | } |
| 2139 | } | 2096 | } |
| 2140 | 2097 | ||
| ... | @@ -2143,19 +2100,12 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullp | ... | @@ -2143,19 +2100,12 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullp |
| 2143 | const size_t __n = __ia.__1d_.size(); | 2100 | const size_t __n = __ia.__1d_.size(); |
| 2144 | if (__n) { | 2101 | if (__n) { |
| 2145 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2102 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2146 | # if _LIBCPP_HAS_EXCEPTIONS | 2103 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 2147 | try { | 2104 | typedef const size_t* _Ip; |
| 2148 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2105 | const value_type* __s = __ia.__vp_; |
| 2149 | typedef const size_t* _Ip; | 2106 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2150 | const value_type* __s = __ia.__vp_; | 2107 | ::new ((void*)__end_) value_type(__s[*__i]); |
| 2151 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) | 2108 | __guard.__complete(); |
| 2152 | ::new ((void*)__end_) value_type(__s[*__i]); | ||
| 2153 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2154 | } catch (...) { | ||
| 2155 | __clear(__n); | ||
| 2156 | throw; | ||
| 2157 | } | ||
| 2158 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2159 | } | 2109 | } |
| 2160 | } | 2110 | } |
| 2161 | 2111 | ||
| ... | @@ -2644,17 +2594,10 @@ void valarray<_Tp>::resize(size_t __n, value_type __x) { | ... | @@ -2644,17 +2594,10 @@ void valarray<_Tp>::resize(size_t __n, value_type __x) { |
| 2644 | __clear(size()); | 2594 | __clear(size()); |
| 2645 | if (__n) { | 2595 | if (__n) { |
| 2646 | __begin_ = __end_ = allocator<value_type>().allocate(__n); | 2596 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2647 | # if _LIBCPP_HAS_EXCEPTIONS | 2597 | auto __guard = std::__make_exception_guard([&] { __clear(__n); }); |
| 2648 | try { | 2598 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
| 2649 | # endif // _LIBCPP_HAS_EXCEPTIONS | 2599 | ::new ((void*)__end_) value_type(__x); |
| 2650 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) | 2600 | __guard.__complete(); |
| 2651 | ::new ((void*)__end_) value_type(__x); | ||
| 2652 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 2653 | } catch (...) { | ||
| 2654 | __clear(__n); | ||
| 2655 | throw; | ||
| 2656 | } | ||
| 2657 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 2658 | } | 2601 | } |
| 2659 | } | 2602 | } |
| 2660 | 2603 | ||
| ... | @@ -3168,7 +3111,7 @@ operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { | ... | @@ -3168,7 +3111,7 @@ operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3168 | } | 3111 | } |
| 3169 | 3112 | ||
| 3170 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3113 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3171 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > | 3114 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > |
| 3172 | abs(const _Expr& __x) { | 3115 | abs(const _Expr& __x) { |
| 3173 | typedef typename _Expr::value_type value_type; | 3116 | typedef typename _Expr::value_type value_type; |
| 3174 | typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; | 3117 | typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; |
| ... | @@ -3176,7 +3119,7 @@ abs(const _Expr& __x) { | ... | @@ -3176,7 +3119,7 @@ abs(const _Expr& __x) { |
| 3176 | } | 3119 | } |
| 3177 | 3120 | ||
| 3178 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3121 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3179 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > | 3122 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > |
| 3180 | acos(const _Expr& __x) { | 3123 | acos(const _Expr& __x) { |
| 3181 | typedef typename _Expr::value_type value_type; | 3124 | typedef typename _Expr::value_type value_type; |
| 3182 | typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; | 3125 | typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; |
| ... | @@ -3184,7 +3127,7 @@ acos(const _Expr& __x) { | ... | @@ -3184,7 +3127,7 @@ acos(const _Expr& __x) { |
| 3184 | } | 3127 | } |
| 3185 | 3128 | ||
| 3186 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3129 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3187 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > | 3130 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > |
| 3188 | asin(const _Expr& __x) { | 3131 | asin(const _Expr& __x) { |
| 3189 | typedef typename _Expr::value_type value_type; | 3132 | typedef typename _Expr::value_type value_type; |
| 3190 | typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; | 3133 | typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; |
| ... | @@ -3192,7 +3135,7 @@ asin(const _Expr& __x) { | ... | @@ -3192,7 +3135,7 @@ asin(const _Expr& __x) { |
| 3192 | } | 3135 | } |
| 3193 | 3136 | ||
| 3194 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3137 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3195 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > | 3138 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > |
| 3196 | atan(const _Expr& __x) { | 3139 | atan(const _Expr& __x) { |
| 3197 | typedef typename _Expr::value_type value_type; | 3140 | typedef typename _Expr::value_type value_type; |
| 3198 | typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; | 3141 | typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; |
| ... | @@ -3202,15 +3145,16 @@ atan(const _Expr& __x) { | ... | @@ -3202,15 +3145,16 @@ atan(const _Expr& __x) { |
| 3202 | template <class _Expr1, | 3145 | template <class _Expr1, |
| 3203 | class _Expr2, | 3146 | class _Expr2, |
| 3204 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> | 3147 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 3205 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > | 3148 | [[__nodiscard__]] inline |
| 3206 | atan2(const _Expr1& __x, const _Expr2& __y) { | 3149 | _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3150 | atan2(const _Expr1& __x, const _Expr2& __y) { | ||
| 3207 | typedef typename _Expr1::value_type value_type; | 3151 | typedef typename _Expr1::value_type value_type; |
| 3208 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; | 3152 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; |
| 3209 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); | 3153 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); |
| 3210 | } | 3154 | } |
| 3211 | 3155 | ||
| 3212 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3156 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3213 | inline _LIBCPP_HIDE_FROM_ABI | 3157 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 3214 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3158 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3215 | atan2(const _Expr& __x, const typename _Expr::value_type& __y) { | 3159 | atan2(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3216 | typedef typename _Expr::value_type value_type; | 3160 | typedef typename _Expr::value_type value_type; |
| ... | @@ -3219,7 +3163,7 @@ atan2(const _Expr& __x, const typename _Expr::value_type& __y) { | ... | @@ -3219,7 +3163,7 @@ atan2(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3219 | } | 3163 | } |
| 3220 | 3164 | ||
| 3221 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3165 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3222 | inline _LIBCPP_HIDE_FROM_ABI | 3166 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 3223 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3167 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3224 | atan2(const typename _Expr::value_type& __x, const _Expr& __y) { | 3168 | atan2(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3225 | typedef typename _Expr::value_type value_type; | 3169 | typedef typename _Expr::value_type value_type; |
| ... | @@ -3228,7 +3172,7 @@ atan2(const typename _Expr::value_type& __x, const _Expr& __y) { | ... | @@ -3228,7 +3172,7 @@ atan2(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3228 | } | 3172 | } |
| 3229 | 3173 | ||
| 3230 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3174 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3231 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > | 3175 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > |
| 3232 | cos(const _Expr& __x) { | 3176 | cos(const _Expr& __x) { |
| 3233 | typedef typename _Expr::value_type value_type; | 3177 | typedef typename _Expr::value_type value_type; |
| 3234 | typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; | 3178 | typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; |
| ... | @@ -3236,7 +3180,7 @@ cos(const _Expr& __x) { | ... | @@ -3236,7 +3180,7 @@ cos(const _Expr& __x) { |
| 3236 | } | 3180 | } |
| 3237 | 3181 | ||
| 3238 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3182 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3239 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > | 3183 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > |
| 3240 | cosh(const _Expr& __x) { | 3184 | cosh(const _Expr& __x) { |
| 3241 | typedef typename _Expr::value_type value_type; | 3185 | typedef typename _Expr::value_type value_type; |
| 3242 | typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; | 3186 | typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; |
| ... | @@ -3244,7 +3188,7 @@ cosh(const _Expr& __x) { | ... | @@ -3244,7 +3188,7 @@ cosh(const _Expr& __x) { |
| 3244 | } | 3188 | } |
| 3245 | 3189 | ||
| 3246 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3190 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3247 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > | 3191 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > |
| 3248 | exp(const _Expr& __x) { | 3192 | exp(const _Expr& __x) { |
| 3249 | typedef typename _Expr::value_type value_type; | 3193 | typedef typename _Expr::value_type value_type; |
| 3250 | typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; | 3194 | typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; |
| ... | @@ -3252,7 +3196,7 @@ exp(const _Expr& __x) { | ... | @@ -3252,7 +3196,7 @@ exp(const _Expr& __x) { |
| 3252 | } | 3196 | } |
| 3253 | 3197 | ||
| 3254 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3198 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3255 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > | 3199 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > |
| 3256 | log(const _Expr& __x) { | 3200 | log(const _Expr& __x) { |
| 3257 | typedef typename _Expr::value_type value_type; | 3201 | typedef typename _Expr::value_type value_type; |
| 3258 | typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; | 3202 | typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; |
| ... | @@ -3260,7 +3204,7 @@ log(const _Expr& __x) { | ... | @@ -3260,7 +3204,7 @@ log(const _Expr& __x) { |
| 3260 | } | 3204 | } |
| 3261 | 3205 | ||
| 3262 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3206 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3263 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > | 3207 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > |
| 3264 | log10(const _Expr& __x) { | 3208 | log10(const _Expr& __x) { |
| 3265 | typedef typename _Expr::value_type value_type; | 3209 | typedef typename _Expr::value_type value_type; |
| 3266 | typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; | 3210 | typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; |
| ... | @@ -3270,15 +3214,16 @@ log10(const _Expr& __x) { | ... | @@ -3270,15 +3214,16 @@ log10(const _Expr& __x) { |
| 3270 | template <class _Expr1, | 3214 | template <class _Expr1, |
| 3271 | class _Expr2, | 3215 | class _Expr2, |
| 3272 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> | 3216 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
| 3273 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > | 3217 | [[__nodiscard__]] inline |
| 3274 | pow(const _Expr1& __x, const _Expr2& __y) { | 3218 | _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
| 3219 | pow(const _Expr1& __x, const _Expr2& __y) { | ||
| 3275 | typedef typename _Expr1::value_type value_type; | 3220 | typedef typename _Expr1::value_type value_type; |
| 3276 | typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; | 3221 | typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; |
| 3277 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); | 3222 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); |
| 3278 | } | 3223 | } |
| 3279 | 3224 | ||
| 3280 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3225 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3281 | inline _LIBCPP_HIDE_FROM_ABI | 3226 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 3282 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > | 3227 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
| 3283 | pow(const _Expr& __x, const typename _Expr::value_type& __y) { | 3228 | pow(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3284 | typedef typename _Expr::value_type value_type; | 3229 | typedef typename _Expr::value_type value_type; |
| ... | @@ -3287,7 +3232,7 @@ pow(const _Expr& __x, const typename _Expr::value_type& __y) { | ... | @@ -3287,7 +3232,7 @@ pow(const _Expr& __x, const typename _Expr::value_type& __y) { |
| 3287 | } | 3232 | } |
| 3288 | 3233 | ||
| 3289 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3234 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3290 | inline _LIBCPP_HIDE_FROM_ABI | 3235 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI |
| 3291 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > | 3236 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
| 3292 | pow(const typename _Expr::value_type& __x, const _Expr& __y) { | 3237 | pow(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3293 | typedef typename _Expr::value_type value_type; | 3238 | typedef typename _Expr::value_type value_type; |
| ... | @@ -3296,7 +3241,7 @@ pow(const typename _Expr::value_type& __x, const _Expr& __y) { | ... | @@ -3296,7 +3241,7 @@ pow(const typename _Expr::value_type& __x, const _Expr& __y) { |
| 3296 | } | 3241 | } |
| 3297 | 3242 | ||
| 3298 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3243 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3299 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > | 3244 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > |
| 3300 | sin(const _Expr& __x) { | 3245 | sin(const _Expr& __x) { |
| 3301 | typedef typename _Expr::value_type value_type; | 3246 | typedef typename _Expr::value_type value_type; |
| 3302 | typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; | 3247 | typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; |
| ... | @@ -3304,7 +3249,7 @@ sin(const _Expr& __x) { | ... | @@ -3304,7 +3249,7 @@ sin(const _Expr& __x) { |
| 3304 | } | 3249 | } |
| 3305 | 3250 | ||
| 3306 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3251 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3307 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > | 3252 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > |
| 3308 | sinh(const _Expr& __x) { | 3253 | sinh(const _Expr& __x) { |
| 3309 | typedef typename _Expr::value_type value_type; | 3254 | typedef typename _Expr::value_type value_type; |
| 3310 | typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; | 3255 | typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; |
| ... | @@ -3312,7 +3257,7 @@ sinh(const _Expr& __x) { | ... | @@ -3312,7 +3257,7 @@ sinh(const _Expr& __x) { |
| 3312 | } | 3257 | } |
| 3313 | 3258 | ||
| 3314 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3259 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3315 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > | 3260 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > |
| 3316 | sqrt(const _Expr& __x) { | 3261 | sqrt(const _Expr& __x) { |
| 3317 | typedef typename _Expr::value_type value_type; | 3262 | typedef typename _Expr::value_type value_type; |
| 3318 | typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; | 3263 | typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; |
| ... | @@ -3320,7 +3265,7 @@ sqrt(const _Expr& __x) { | ... | @@ -3320,7 +3265,7 @@ sqrt(const _Expr& __x) { |
| 3320 | } | 3265 | } |
| 3321 | 3266 | ||
| 3322 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3267 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3323 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > | 3268 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > |
| 3324 | tan(const _Expr& __x) { | 3269 | tan(const _Expr& __x) { |
| 3325 | typedef typename _Expr::value_type value_type; | 3270 | typedef typename _Expr::value_type value_type; |
| 3326 | typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; | 3271 | typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; |
| ... | @@ -3328,7 +3273,7 @@ tan(const _Expr& __x) { | ... | @@ -3328,7 +3273,7 @@ tan(const _Expr& __x) { |
| 3328 | } | 3273 | } |
| 3329 | 3274 | ||
| 3330 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> | 3275 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
| 3331 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > | 3276 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > |
| 3332 | tanh(const _Expr& __x) { | 3277 | tanh(const _Expr& __x) { |
| 3333 | typedef typename _Expr::value_type value_type; | 3278 | typedef typename _Expr::value_type value_type; |
| 3334 | typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; | 3279 | typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; |
| ... | @@ -3336,22 +3281,22 @@ tanh(const _Expr& __x) { | ... | @@ -3336,22 +3281,22 @@ tanh(const _Expr& __x) { |
| 3336 | } | 3281 | } |
| 3337 | 3282 | ||
| 3338 | template <class _Tp> | 3283 | template <class _Tp> |
| 3339 | inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) { | 3284 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) { |
| 3340 | return __v.__begin_; | 3285 | return __v.__begin_; |
| 3341 | } | 3286 | } |
| 3342 | 3287 | ||
| 3343 | template <class _Tp> | 3288 | template <class _Tp> |
| 3344 | inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) { | 3289 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) { |
| 3345 | return __v.__begin_; | 3290 | return __v.__begin_; |
| 3346 | } | 3291 | } |
| 3347 | 3292 | ||
| 3348 | template <class _Tp> | 3293 | template <class _Tp> |
| 3349 | inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) { | 3294 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) { |
| 3350 | return __v.__end_; | 3295 | return __v.__end_; |
| 3351 | } | 3296 | } |
| 3352 | 3297 | ||
| 3353 | template <class _Tp> | 3298 | template <class _Tp> |
| 3354 | inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) { | 3299 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) { |
| 3355 | return __v.__end_; | 3300 | return __v.__end_; |
| 3356 | } | 3301 | } |
| 3357 | 3302 |
lib/libcxx/include/variant+25-33| ... | @@ -247,7 +247,6 @@ namespace std { | ... | @@ -247,7 +247,6 @@ namespace std { |
| 247 | # include <__type_traits/is_nothrow_assignable.h> | 247 | # include <__type_traits/is_nothrow_assignable.h> |
| 248 | # include <__type_traits/is_nothrow_constructible.h> | 248 | # include <__type_traits/is_nothrow_constructible.h> |
| 249 | # include <__type_traits/is_reference.h> | 249 | # include <__type_traits/is_reference.h> |
| 250 | # include <__type_traits/is_replaceable.h> | ||
| 251 | # include <__type_traits/is_same.h> | 250 | # include <__type_traits/is_same.h> |
| 252 | # include <__type_traits/is_swappable.h> | 251 | # include <__type_traits/is_swappable.h> |
| 253 | # include <__type_traits/is_trivially_assignable.h> | 252 | # include <__type_traits/is_trivially_assignable.h> |
| ... | @@ -289,7 +288,7 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD | ... | @@ -289,7 +288,7 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 289 | 288 | ||
| 290 | class _LIBCPP_EXPORTED_FROM_ABI bad_variant_access : public exception { | 289 | class _LIBCPP_EXPORTED_FROM_ABI bad_variant_access : public exception { |
| 291 | public: | 290 | public: |
| 292 | const char* what() const _NOEXCEPT override; | 291 | [[__nodiscard__]] const char* what() const _NOEXCEPT override; |
| 293 | }; | 292 | }; |
| 294 | 293 | ||
| 295 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD | 294 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| ... | @@ -918,18 +917,10 @@ protected: | ... | @@ -918,18 +917,10 @@ protected: |
| 918 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) { | 917 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) { |
| 919 | if (this->index() == _Ip) { | 918 | if (this->index() == _Ip) { |
| 920 | __a.__value = std::forward<_Arg>(__arg); | 919 | __a.__value = std::forward<_Arg>(__arg); |
| 920 | } else if constexpr (is_nothrow_constructible_v<_Tp, _Arg> || !is_nothrow_move_constructible_v<_Tp>) { | ||
| 921 | this->__emplace<_Ip>(std::forward<_Arg>(__arg)); | ||
| 921 | } else { | 922 | } else { |
| 922 | struct { | 923 | this->__emplace<_Ip>(_Tp(std::forward<_Arg>(__arg))); |
| 923 | _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()(true_type) const { | ||
| 924 | __this->__emplace<_Ip>(std::forward<_Arg>(__arg)); | ||
| 925 | } | ||
| 926 | _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()(false_type) const { | ||
| 927 | __this->__emplace<_Ip>(_Tp(std::forward<_Arg>(__arg))); | ||
| 928 | } | ||
| 929 | __assignment* __this; | ||
| 930 | _Arg&& __arg; | ||
| 931 | } __impl{this, std::forward<_Arg>(__arg)}; | ||
| 932 | __impl(bool_constant < is_nothrow_constructible_v<_Tp, _Arg> || !is_nothrow_move_constructible_v < _Tp >> {}); | ||
| 933 | } | 924 | } |
| 934 | } | 925 | } |
| 935 | 926 | ||
| ... | @@ -1127,14 +1118,14 @@ template <class _IdxSeq> | ... | @@ -1127,14 +1118,14 @@ template <class _IdxSeq> |
| 1127 | struct __make_overloads_imp; | 1118 | struct __make_overloads_imp; |
| 1128 | 1119 | ||
| 1129 | template <size_t... _Idx> | 1120 | template <size_t... _Idx> |
| 1130 | struct __make_overloads_imp<__tuple_indices<_Idx...> > { | 1121 | struct __make_overloads_imp<index_sequence<_Idx...> > { |
| 1131 | template <class... _Types> | 1122 | template <class... _Types> |
| 1132 | using _Apply _LIBCPP_NODEBUG = __all_overloads<__overload<_Types, _Idx>...>; | 1123 | using _Apply _LIBCPP_NODEBUG = __all_overloads<__overload<_Types, _Idx>...>; |
| 1133 | }; | 1124 | }; |
| 1134 | 1125 | ||
| 1135 | template <class... _Types> | 1126 | template <class... _Types> |
| 1136 | using _MakeOverloads _LIBCPP_NODEBUG = | 1127 | using _MakeOverloads _LIBCPP_NODEBUG = |
| 1137 | typename __make_overloads_imp< __make_indices_imp<sizeof...(_Types), 0> >::template _Apply<_Types...>; | 1128 | typename __make_overloads_imp<make_index_sequence<sizeof...(_Types)>>::template _Apply<_Types...>; |
| 1138 | 1129 | ||
| 1139 | template <class _Tp, class... _Types> | 1130 | template <class _Tp, class... _Types> |
| 1140 | using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type; | 1131 | using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type; |
| ... | @@ -1172,7 +1163,6 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant | ... | @@ -1172,7 +1163,6 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant |
| 1172 | public: | 1163 | public: |
| 1173 | using __trivially_relocatable _LIBCPP_NODEBUG = | 1164 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 1174 | conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>; | 1165 | conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>; |
| 1175 | using __replaceable _LIBCPP_NODEBUG = conditional_t<_And<__is_replaceable<_Types>...>::value, variant, void>; | ||
| 1176 | 1166 | ||
| 1177 | template <bool _Dummy = true, | 1167 | template <bool _Dummy = true, |
| 1178 | enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0> | 1168 | enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0> |
| ... | @@ -1284,11 +1274,11 @@ public: | ... | @@ -1284,11 +1274,11 @@ public: |
| 1284 | return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...); | 1274 | return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...); |
| 1285 | } | 1275 | } |
| 1286 | 1276 | ||
| 1287 | _LIBCPP_HIDE_FROM_ABI constexpr bool valueless_by_exception() const noexcept { | 1277 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool valueless_by_exception() const noexcept { |
| 1288 | return __impl_.valueless_by_exception(); | 1278 | return __impl_.valueless_by_exception(); |
| 1289 | } | 1279 | } |
| 1290 | 1280 | ||
| 1291 | _LIBCPP_HIDE_FROM_ABI constexpr size_t index() const noexcept { return __impl_.index(); } | 1281 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t index() const noexcept { return __impl_.index(); } |
| 1292 | 1282 | ||
| 1293 | template < bool _Dummy = true, | 1283 | template < bool _Dummy = true, |
| 1294 | enable_if_t< __all<(__dependent_type<is_move_constructible<_Types>, _Dummy>::value && | 1284 | enable_if_t< __all<(__dependent_type<is_move_constructible<_Types>, _Dummy>::value && |
| ... | @@ -1299,7 +1289,7 @@ public: | ... | @@ -1299,7 +1289,7 @@ public: |
| 1299 | __impl_.__swap(__that.__impl_); | 1289 | __impl_.__swap(__that.__impl_); |
| 1300 | } | 1290 | } |
| 1301 | 1291 | ||
| 1302 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | 1292 | # if _LIBCPP_STD_VER >= 26 |
| 1303 | // Helper class to implement [variant.visit]/10 | 1293 | // Helper class to implement [variant.visit]/10 |
| 1304 | // Constraints: The call to visit does not use an explicit template-argument-list | 1294 | // Constraints: The call to visit does not use an explicit template-argument-list |
| 1305 | // that begins with a type template-argument. | 1295 | // that begins with a type template-argument. |
| ... | @@ -1331,7 +1321,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __holds_alternative(const variant<_Types... | ... | @@ -1331,7 +1321,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __holds_alternative(const variant<_Types... |
| 1331 | } | 1321 | } |
| 1332 | 1322 | ||
| 1333 | template <class _Tp, class... _Types> | 1323 | template <class _Tp, class... _Types> |
| 1334 | _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept { | 1324 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept { |
| 1335 | return std::__holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v); | 1325 | return std::__holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1336 | } | 1326 | } |
| 1337 | 1327 | ||
| ... | @@ -1345,21 +1335,23 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto&& __generic_get(_Vp&& __v) { | ... | @@ -1345,21 +1335,23 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto&& __generic_get(_Vp&& __v) { |
| 1345 | } | 1335 | } |
| 1346 | 1336 | ||
| 1347 | template <size_t _Ip, class... _Types> | 1337 | template <size_t _Ip, class... _Types> |
| 1348 | _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(variant<_Types...>& __v) { | 1338 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& |
| 1339 | get(variant<_Types...>& __v) { | ||
| 1349 | static_assert(_Ip < sizeof...(_Types)); | 1340 | static_assert(_Ip < sizeof...(_Types)); |
| 1350 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1341 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1351 | return std::__generic_get<_Ip>(__v); | 1342 | return std::__generic_get<_Ip>(__v); |
| 1352 | } | 1343 | } |
| 1353 | 1344 | ||
| 1354 | template <size_t _Ip, class... _Types> | 1345 | template <size_t _Ip, class... _Types> |
| 1355 | _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(variant<_Types...>&& __v) { | 1346 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& |
| 1347 | get(variant<_Types...>&& __v) { | ||
| 1356 | static_assert(_Ip < sizeof...(_Types)); | 1348 | static_assert(_Ip < sizeof...(_Types)); |
| 1357 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1349 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1358 | return std::__generic_get<_Ip>(std::move(__v)); | 1350 | return std::__generic_get<_Ip>(std::move(__v)); |
| 1359 | } | 1351 | } |
| 1360 | 1352 | ||
| 1361 | template <size_t _Ip, class... _Types> | 1353 | template <size_t _Ip, class... _Types> |
| 1362 | _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>& | 1354 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>& |
| 1363 | get(const variant<_Types...>& __v) { | 1355 | get(const variant<_Types...>& __v) { |
| 1364 | static_assert(_Ip < sizeof...(_Types)); | 1356 | static_assert(_Ip < sizeof...(_Types)); |
| 1365 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1357 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| ... | @@ -1367,7 +1359,7 @@ get(const variant<_Types...>& __v) { | ... | @@ -1367,7 +1359,7 @@ get(const variant<_Types...>& __v) { |
| 1367 | } | 1359 | } |
| 1368 | 1360 | ||
| 1369 | template <size_t _Ip, class... _Types> | 1361 | template <size_t _Ip, class... _Types> |
| 1370 | _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& | 1362 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& |
| 1371 | get(const variant<_Types...>&& __v) { | 1363 | get(const variant<_Types...>&& __v) { |
| 1372 | static_assert(_Ip < sizeof...(_Types)); | 1364 | static_assert(_Ip < sizeof...(_Types)); |
| 1373 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1365 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| ... | @@ -1375,25 +1367,25 @@ get(const variant<_Types...>&& __v) { | ... | @@ -1375,25 +1367,25 @@ get(const variant<_Types...>&& __v) { |
| 1375 | } | 1367 | } |
| 1376 | 1368 | ||
| 1377 | template <class _Tp, class... _Types> | 1369 | template <class _Tp, class... _Types> |
| 1378 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>& __v) { | 1370 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>& __v) { |
| 1379 | static_assert(!is_void_v<_Tp>); | 1371 | static_assert(!is_void_v<_Tp>); |
| 1380 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); | 1372 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1381 | } | 1373 | } |
| 1382 | 1374 | ||
| 1383 | template <class _Tp, class... _Types> | 1375 | template <class _Tp, class... _Types> |
| 1384 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&& __v) { | 1376 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&& __v) { |
| 1385 | static_assert(!is_void_v<_Tp>); | 1377 | static_assert(!is_void_v<_Tp>); |
| 1386 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); | 1378 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); |
| 1387 | } | 1379 | } |
| 1388 | 1380 | ||
| 1389 | template <class _Tp, class... _Types> | 1381 | template <class _Tp, class... _Types> |
| 1390 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>& __v) { | 1382 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>& __v) { |
| 1391 | static_assert(!is_void_v<_Tp>); | 1383 | static_assert(!is_void_v<_Tp>); |
| 1392 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); | 1384 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1393 | } | 1385 | } |
| 1394 | 1386 | ||
| 1395 | template <class _Tp, class... _Types> | 1387 | template <class _Tp, class... _Types> |
| 1396 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&& __v) { | 1388 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&& __v) { |
| 1397 | static_assert(!is_void_v<_Tp>); | 1389 | static_assert(!is_void_v<_Tp>); |
| 1398 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); | 1390 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); |
| 1399 | } | 1391 | } |
| ... | @@ -1405,7 +1397,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto* __generic_get_if(_Vp* __v) noexcept { | ... | @@ -1405,7 +1397,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto* __generic_get_if(_Vp* __v) noexcept { |
| 1405 | } | 1397 | } |
| 1406 | 1398 | ||
| 1407 | template <size_t _Ip, class... _Types> | 1399 | template <size_t _Ip, class... _Types> |
| 1408 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<variant_alternative_t<_Ip, variant<_Types...>>> | 1400 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<variant_alternative_t<_Ip, variant<_Types...>>> |
| 1409 | get_if(variant<_Types...>* __v) noexcept { | 1401 | get_if(variant<_Types...>* __v) noexcept { |
| 1410 | static_assert(_Ip < sizeof...(_Types)); | 1402 | static_assert(_Ip < sizeof...(_Types)); |
| 1411 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1403 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| ... | @@ -1413,7 +1405,7 @@ get_if(variant<_Types...>* __v) noexcept { | ... | @@ -1413,7 +1405,7 @@ get_if(variant<_Types...>* __v) noexcept { |
| 1413 | } | 1405 | } |
| 1414 | 1406 | ||
| 1415 | template <size_t _Ip, class... _Types> | 1407 | template <size_t _Ip, class... _Types> |
| 1416 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<const variant_alternative_t<_Ip, variant<_Types...>>> | 1408 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<const variant_alternative_t<_Ip, variant<_Types...>>> |
| 1417 | get_if(const variant<_Types...>* __v) noexcept { | 1409 | get_if(const variant<_Types...>* __v) noexcept { |
| 1418 | static_assert(_Ip < sizeof...(_Types)); | 1410 | static_assert(_Ip < sizeof...(_Types)); |
| 1419 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1411 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| ... | @@ -1421,13 +1413,13 @@ get_if(const variant<_Types...>* __v) noexcept { | ... | @@ -1421,13 +1413,13 @@ get_if(const variant<_Types...>* __v) noexcept { |
| 1421 | } | 1413 | } |
| 1422 | 1414 | ||
| 1423 | template <class _Tp, class... _Types> | 1415 | template <class _Tp, class... _Types> |
| 1424 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> get_if(variant<_Types...>* __v) noexcept { | 1416 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> get_if(variant<_Types...>* __v) noexcept { |
| 1425 | static_assert(!is_void_v<_Tp>); | 1417 | static_assert(!is_void_v<_Tp>); |
| 1426 | return std::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v); | 1418 | return std::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1427 | } | 1419 | } |
| 1428 | 1420 | ||
| 1429 | template <class _Tp, class... _Types> | 1421 | template <class _Tp, class... _Types> |
| 1430 | _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<const _Tp> get_if(const variant<_Types...>* __v) noexcept { | 1422 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<const _Tp> get_if(const variant<_Types...>* __v) noexcept { |
| 1431 | static_assert(!is_void_v<_Tp>); | 1423 | static_assert(!is_void_v<_Tp>); |
| 1432 | return std::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v); | 1424 | return std::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1433 | } | 1425 | } |
| ... | @@ -1608,7 +1600,7 @@ struct hash< __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...> | ... | @@ -1608,7 +1600,7 @@ struct hash< __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...> |
| 1608 | using result_type _LIBCPP_DEPRECATED_IN_CXX17 = size_t; | 1600 | using result_type _LIBCPP_DEPRECATED_IN_CXX17 = size_t; |
| 1609 | # endif | 1601 | # endif |
| 1610 | 1602 | ||
| 1611 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const variant<_Types...>& __v) const { | 1603 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t operator()(const variant<_Types...>& __v) const { |
| 1612 | using __variant_detail::__visitation::__variant; | 1604 | using __variant_detail::__visitation::__variant; |
| 1613 | size_t __res = | 1605 | size_t __res = |
| 1614 | __v.valueless_by_exception() | 1606 | __v.valueless_by_exception() |
lib/libcxx/include/version+41-24| ... | @@ -37,7 +37,8 @@ __cpp_lib_atomic_float 201711L <atomic> | ... | @@ -37,7 +37,8 @@ __cpp_lib_atomic_float 201711L <atomic> |
| 37 | __cpp_lib_atomic_is_always_lock_free 201603L <atomic> | 37 | __cpp_lib_atomic_is_always_lock_free 201603L <atomic> |
| 38 | __cpp_lib_atomic_lock_free_type_aliases 201907L <atomic> | 38 | __cpp_lib_atomic_lock_free_type_aliases 201907L <atomic> |
| 39 | __cpp_lib_atomic_min_max 202403L <atomic> | 39 | __cpp_lib_atomic_min_max 202403L <atomic> |
| 40 | __cpp_lib_atomic_ref 201806L <atomic> | 40 | __cpp_lib_atomic_ref 202411L <atomic> |
| 41 | 201806L // C++20 | ||
| 41 | __cpp_lib_atomic_shared_ptr 201711L <atomic> | 42 | __cpp_lib_atomic_shared_ptr 201711L <atomic> |
| 42 | __cpp_lib_atomic_value_initialization 201911L <atomic> <memory> | 43 | __cpp_lib_atomic_value_initialization 201911L <atomic> <memory> |
| 43 | __cpp_lib_atomic_wait 201907L <atomic> | 44 | __cpp_lib_atomic_wait 201907L <atomic> |
| ... | @@ -62,7 +63,7 @@ __cpp_lib_clamp 201603L <algorithm> | ... | @@ -62,7 +63,7 @@ __cpp_lib_clamp 201603L <algorithm> |
| 62 | __cpp_lib_common_reference 202302L <type_traits> | 63 | __cpp_lib_common_reference 202302L <type_traits> |
| 63 | __cpp_lib_common_reference_wrapper 202302L <functional> | 64 | __cpp_lib_common_reference_wrapper 202302L <functional> |
| 64 | __cpp_lib_complex_udls 201309L <complex> | 65 | __cpp_lib_complex_udls 201309L <complex> |
| 65 | __cpp_lib_concepts 202002L <concepts> | 66 | __cpp_lib_concepts 202207L <concepts> |
| 66 | __cpp_lib_constexpr_algorithms 202306L <algorithm> <utility> | 67 | __cpp_lib_constexpr_algorithms 202306L <algorithm> <utility> |
| 67 | 201806L // C++20 | 68 | 201806L // C++20 |
| 68 | __cpp_lib_constexpr_bitset 202207L <bitset> | 69 | __cpp_lib_constexpr_bitset 202207L <bitset> |
| ... | @@ -70,6 +71,8 @@ __cpp_lib_constexpr_charconv 202207L <charconv> | ... | @@ -70,6 +71,8 @@ __cpp_lib_constexpr_charconv 202207L <charconv> |
| 70 | __cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib> | 71 | __cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib> |
| 71 | __cpp_lib_constexpr_complex 201711L <complex> | 72 | __cpp_lib_constexpr_complex 201711L <complex> |
| 72 | __cpp_lib_constexpr_dynamic_alloc 201907L <memory> | 73 | __cpp_lib_constexpr_dynamic_alloc 201907L <memory> |
| 74 | __cpp_lib_constexpr_flat_map 202502L <flat_map> | ||
| 75 | __cpp_lib_constexpr_flat_set 202502L <flat_set> | ||
| 73 | __cpp_lib_constexpr_forward_list 202502L <forward_list> | 76 | __cpp_lib_constexpr_forward_list 202502L <forward_list> |
| 74 | __cpp_lib_constexpr_functional 201907L <functional> | 77 | __cpp_lib_constexpr_functional 201907L <functional> |
| 75 | __cpp_lib_constexpr_iterator 201811L <iterator> | 78 | __cpp_lib_constexpr_iterator 201811L <iterator> |
| ... | @@ -108,8 +111,8 @@ __cpp_lib_execution 201902L <execution> | ... | @@ -108,8 +111,8 @@ __cpp_lib_execution 201902L <execution> |
| 108 | 201603L // C++17 | 111 | 201603L // C++17 |
| 109 | __cpp_lib_expected 202211L <expected> | 112 | __cpp_lib_expected 202211L <expected> |
| 110 | __cpp_lib_filesystem 201703L <filesystem> | 113 | __cpp_lib_filesystem 201703L <filesystem> |
| 111 | __cpp_lib_flat_map 202207L <flat_map> | 114 | __cpp_lib_flat_map 202511L <flat_map> |
| 112 | __cpp_lib_flat_set 202207L <flat_set> | 115 | __cpp_lib_flat_set 202511L <flat_set> |
| 113 | __cpp_lib_format 202110L <format> | 116 | __cpp_lib_format 202110L <format> |
| 114 | __cpp_lib_format_path 202403L <filesystem> | 117 | __cpp_lib_format_path 202403L <filesystem> |
| 115 | __cpp_lib_format_ranges 202207L <format> | 118 | __cpp_lib_format_ranges 202207L <format> |
| ... | @@ -138,7 +141,8 @@ __cpp_lib_incomplete_container_elements 201505L <forward_list> < | ... | @@ -138,7 +141,8 @@ __cpp_lib_incomplete_container_elements 201505L <forward_list> < |
| 138 | __cpp_lib_inplace_vector 202406L <inplace_vector> | 141 | __cpp_lib_inplace_vector 202406L <inplace_vector> |
| 139 | __cpp_lib_int_pow2 202002L <bit> | 142 | __cpp_lib_int_pow2 202002L <bit> |
| 140 | __cpp_lib_integer_comparison_functions 202002L <utility> | 143 | __cpp_lib_integer_comparison_functions 202002L <utility> |
| 141 | __cpp_lib_integer_sequence 201304L <utility> | 144 | __cpp_lib_integer_sequence 202511L <utility> |
| 145 | 201304L // C++14 | ||
| 142 | __cpp_lib_integral_constant_callable 201304L <type_traits> | 146 | __cpp_lib_integral_constant_callable 201304L <type_traits> |
| 143 | __cpp_lib_interpolate 201902L <cmath> <numeric> | 147 | __cpp_lib_interpolate 201902L <cmath> <numeric> |
| 144 | __cpp_lib_invoke 201411L <functional> | 148 | __cpp_lib_invoke 201411L <functional> |
| ... | @@ -184,7 +188,8 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque> | ... | @@ -184,7 +188,8 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque> |
| 184 | __cpp_lib_not_fn 202306L <functional> | 188 | __cpp_lib_not_fn 202306L <functional> |
| 185 | 201603L // C++17 | 189 | 201603L // C++17 |
| 186 | __cpp_lib_null_iterators 201304L <iterator> | 190 | __cpp_lib_null_iterators 201304L <iterator> |
| 187 | __cpp_lib_optional 202110L <optional> | 191 | __cpp_lib_optional 202506L <optional> |
| 192 | 202110L // C++23 | ||
| 188 | 202106L // C++20 | 193 | 202106L // C++20 |
| 189 | 201606L // C++17 | 194 | 201606L // C++17 |
| 190 | __cpp_lib_optional_range_support 202406L <optional> | 195 | __cpp_lib_optional_range_support 202406L <optional> |
| ... | @@ -205,6 +210,7 @@ __cpp_lib_ranges_chunk_by 202202L <ranges> | ... | @@ -205,6 +210,7 @@ __cpp_lib_ranges_chunk_by 202202L <ranges> |
| 205 | __cpp_lib_ranges_concat 202403L <ranges> | 210 | __cpp_lib_ranges_concat 202403L <ranges> |
| 206 | __cpp_lib_ranges_contains 202207L <algorithm> | 211 | __cpp_lib_ranges_contains 202207L <algorithm> |
| 207 | __cpp_lib_ranges_find_last 202207L <algorithm> | 212 | __cpp_lib_ranges_find_last 202207L <algorithm> |
| 213 | __cpp_lib_ranges_indices 202506L <ranges> | ||
| 208 | __cpp_lib_ranges_iota 202202L <numeric> | 214 | __cpp_lib_ranges_iota 202202L <numeric> |
| 209 | __cpp_lib_ranges_join_with 202202L <ranges> | 215 | __cpp_lib_ranges_join_with 202202L <ranges> |
| 210 | __cpp_lib_ranges_repeat 202207L <ranges> | 216 | __cpp_lib_ranges_repeat 202207L <ranges> |
| ... | @@ -245,6 +251,7 @@ __cpp_lib_starts_ends_with 201711L <string> <string | ... | @@ -245,6 +251,7 @@ __cpp_lib_starts_ends_with 201711L <string> <string |
| 245 | __cpp_lib_stdatomic_h 202011L <stdatomic.h> | 251 | __cpp_lib_stdatomic_h 202011L <stdatomic.h> |
| 246 | __cpp_lib_string_contains 202011L <string> <string_view> | 252 | __cpp_lib_string_contains 202011L <string> <string_view> |
| 247 | __cpp_lib_string_resize_and_overwrite 202110L <string> | 253 | __cpp_lib_string_resize_and_overwrite 202110L <string> |
| 254 | __cpp_lib_string_subview 202506L <string> <string_view> | ||
| 248 | __cpp_lib_string_udls 201304L <string> | 255 | __cpp_lib_string_udls 201304L <string> |
| 249 | __cpp_lib_string_view 202403L <string> <string_view> | 256 | __cpp_lib_string_view 202403L <string> <string_view> |
| 250 | 201803L // C++20 | 257 | 201803L // C++20 |
| ... | @@ -333,13 +340,11 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -333,13 +340,11 @@ __cpp_lib_void_t 201411L <type_traits> |
| 333 | # define __cpp_lib_clamp 201603L | 340 | # define __cpp_lib_clamp 201603L |
| 334 | # define __cpp_lib_enable_shared_from_this 201603L | 341 | # define __cpp_lib_enable_shared_from_this 201603L |
| 335 | // # define __cpp_lib_execution 201603L | 342 | // # define __cpp_lib_execution 201603L |
| 336 | # if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY | 343 | # if _LIBCPP_HAS_FILESYSTEM |
| 337 | # define __cpp_lib_filesystem 201703L | 344 | # define __cpp_lib_filesystem 201703L |
| 338 | # endif | 345 | # endif |
| 339 | # define __cpp_lib_gcd_lcm 201606L | 346 | # define __cpp_lib_gcd_lcm 201606L |
| 340 | # if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | 347 | # define __cpp_lib_hardware_interference_size 201703L |
| 341 | # define __cpp_lib_hardware_interference_size 201703L | ||
| 342 | # endif | ||
| 343 | # define __cpp_lib_has_unique_object_representations 201606L | 348 | # define __cpp_lib_has_unique_object_representations 201606L |
| 344 | # define __cpp_lib_hypot 201603L | 349 | # define __cpp_lib_hypot 201603L |
| 345 | # define __cpp_lib_incomplete_container_elements 201505L | 350 | # define __cpp_lib_incomplete_container_elements 201505L |
| ... | @@ -391,10 +396,8 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -391,10 +396,8 @@ __cpp_lib_void_t 201411L <type_traits> |
| 391 | # define __cpp_lib_atomic_ref 201806L | 396 | # define __cpp_lib_atomic_ref 201806L |
| 392 | // # define __cpp_lib_atomic_shared_ptr 201711L | 397 | // # define __cpp_lib_atomic_shared_ptr 201711L |
| 393 | # define __cpp_lib_atomic_value_initialization 201911L | 398 | # define __cpp_lib_atomic_value_initialization 201911L |
| 394 | # if _LIBCPP_AVAILABILITY_HAS_SYNC | 399 | # define __cpp_lib_atomic_wait 201907L |
| 395 | # define __cpp_lib_atomic_wait 201907L | 400 | # if _LIBCPP_HAS_THREADS |
| 396 | # endif | ||
| 397 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | ||
| 398 | # define __cpp_lib_barrier 201907L | 401 | # define __cpp_lib_barrier 201907L |
| 399 | # endif | 402 | # endif |
| 400 | # define __cpp_lib_bind_front 201907L | 403 | # define __cpp_lib_bind_front 201907L |
| ... | @@ -406,7 +409,7 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -406,7 +409,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 406 | # endif | 409 | # endif |
| 407 | # define __cpp_lib_common_reference 202302L | 410 | # define __cpp_lib_common_reference 202302L |
| 408 | # define __cpp_lib_common_reference_wrapper 202302L | 411 | # define __cpp_lib_common_reference_wrapper 202302L |
| 409 | # define __cpp_lib_concepts 202002L | 412 | # define __cpp_lib_concepts 202207L |
| 410 | # define __cpp_lib_constexpr_algorithms 201806L | 413 | # define __cpp_lib_constexpr_algorithms 201806L |
| 411 | # define __cpp_lib_constexpr_complex 201711L | 414 | # define __cpp_lib_constexpr_complex 201711L |
| 412 | # define __cpp_lib_constexpr_dynamic_alloc 201907L | 415 | # define __cpp_lib_constexpr_dynamic_alloc 201907L |
| ... | @@ -439,10 +442,10 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -439,10 +442,10 @@ __cpp_lib_void_t 201411L <type_traits> |
| 439 | // # define __cpp_lib_is_layout_compatible 201907L | 442 | // # define __cpp_lib_is_layout_compatible 201907L |
| 440 | # define __cpp_lib_is_nothrow_convertible 201806L | 443 | # define __cpp_lib_is_nothrow_convertible 201806L |
| 441 | // # define __cpp_lib_is_pointer_interconvertible 201907L | 444 | // # define __cpp_lib_is_pointer_interconvertible 201907L |
| 442 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | 445 | # if _LIBCPP_HAS_THREADS |
| 443 | # define __cpp_lib_jthread 201911L | 446 | # define __cpp_lib_jthread 201911L |
| 444 | # endif | 447 | # endif |
| 445 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | 448 | # if _LIBCPP_HAS_THREADS |
| 446 | # define __cpp_lib_latch 201907L | 449 | # define __cpp_lib_latch 201907L |
| 447 | # endif | 450 | # endif |
| 448 | # define __cpp_lib_list_remove_return_type 201806L | 451 | # define __cpp_lib_list_remove_return_type 201806L |
| ... | @@ -455,7 +458,7 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -455,7 +458,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 455 | # endif | 458 | # endif |
| 456 | # define __cpp_lib_ranges 202110L | 459 | # define __cpp_lib_ranges 202110L |
| 457 | # define __cpp_lib_remove_cvref 201711L | 460 | # define __cpp_lib_remove_cvref 201711L |
| 458 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | 461 | # if _LIBCPP_HAS_THREADS |
| 459 | # define __cpp_lib_semaphore 201907L | 462 | # define __cpp_lib_semaphore 201907L |
| 460 | # endif | 463 | # endif |
| 461 | # undef __cpp_lib_shared_ptr_arrays | 464 | # undef __cpp_lib_shared_ptr_arrays |
| ... | @@ -494,8 +497,8 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -494,8 +497,8 @@ __cpp_lib_void_t 201411L <type_traits> |
| 494 | # define __cpp_lib_constexpr_typeinfo 202106L | 497 | # define __cpp_lib_constexpr_typeinfo 202106L |
| 495 | # define __cpp_lib_containers_ranges 202202L | 498 | # define __cpp_lib_containers_ranges 202202L |
| 496 | # define __cpp_lib_expected 202211L | 499 | # define __cpp_lib_expected 202211L |
| 497 | # define __cpp_lib_flat_map 202207L | 500 | # define __cpp_lib_flat_map 202511L |
| 498 | # define __cpp_lib_flat_set 202207L | 501 | # define __cpp_lib_flat_set 202511L |
| 499 | # define __cpp_lib_format_ranges 202207L | 502 | # define __cpp_lib_format_ranges 202207L |
| 500 | // # define __cpp_lib_formatters 202302L | 503 | // # define __cpp_lib_formatters 202302L |
| 501 | # define __cpp_lib_forward_like 202207L | 504 | # define __cpp_lib_forward_like 202207L |
| ... | @@ -528,7 +531,7 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -528,7 +531,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 528 | // # define __cpp_lib_ranges_slide 202202L | 531 | // # define __cpp_lib_ranges_slide 202202L |
| 529 | # define __cpp_lib_ranges_starts_ends_with 202106L | 532 | # define __cpp_lib_ranges_starts_ends_with 202106L |
| 530 | # define __cpp_lib_ranges_to_container 202202L | 533 | # define __cpp_lib_ranges_to_container 202202L |
| 531 | // # define __cpp_lib_ranges_zip 202110L | 534 | # define __cpp_lib_ranges_zip 202110L |
| 532 | // # define __cpp_lib_reference_from_temporary 202202L | 535 | // # define __cpp_lib_reference_from_temporary 202202L |
| 533 | // # define __cpp_lib_spanstream 202106L | 536 | // # define __cpp_lib_spanstream 202106L |
| 534 | // # define __cpp_lib_stacktrace 202011L | 537 | // # define __cpp_lib_stacktrace 202011L |
| ... | @@ -544,18 +547,22 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -544,18 +547,22 @@ __cpp_lib_void_t 201411L <type_traits> |
| 544 | # define __cpp_lib_aligned_accessor 202411L | 547 | # define __cpp_lib_aligned_accessor 202411L |
| 545 | // # define __cpp_lib_associative_heterogeneous_insertion 202306L | 548 | // # define __cpp_lib_associative_heterogeneous_insertion 202306L |
| 546 | // # define __cpp_lib_atomic_min_max 202403L | 549 | // # define __cpp_lib_atomic_min_max 202403L |
| 550 | # undef __cpp_lib_atomic_ref | ||
| 551 | # define __cpp_lib_atomic_ref 202411L | ||
| 547 | # undef __cpp_lib_bind_front | 552 | # undef __cpp_lib_bind_front |
| 548 | # define __cpp_lib_bind_front 202306L | 553 | # define __cpp_lib_bind_front 202306L |
| 549 | # define __cpp_lib_bitset 202306L | 554 | # define __cpp_lib_bitset 202306L |
| 550 | # undef __cpp_lib_constexpr_algorithms | 555 | # undef __cpp_lib_constexpr_algorithms |
| 551 | # define __cpp_lib_constexpr_algorithms 202306L | 556 | # define __cpp_lib_constexpr_algorithms 202306L |
| 557 | # define __cpp_lib_constexpr_flat_map 202502L | ||
| 558 | # define __cpp_lib_constexpr_flat_set 202502L | ||
| 552 | # define __cpp_lib_constexpr_forward_list 202502L | 559 | # define __cpp_lib_constexpr_forward_list 202502L |
| 553 | # define __cpp_lib_constexpr_list 202502L | 560 | # define __cpp_lib_constexpr_list 202502L |
| 554 | # if !defined(_LIBCPP_ABI_VCRUNTIME) | 561 | # if !defined(_LIBCPP_ABI_VCRUNTIME) |
| 555 | # define __cpp_lib_constexpr_new 202406L | 562 | # define __cpp_lib_constexpr_new 202406L |
| 556 | # endif | 563 | # endif |
| 557 | # define __cpp_lib_constexpr_queue 202502L | 564 | # define __cpp_lib_constexpr_queue 202502L |
| 558 | // # define __cpp_lib_constrained_equality 202411L | 565 | # define __cpp_lib_constrained_equality 202411L |
| 559 | // # define __cpp_lib_copyable_function 202306L | 566 | // # define __cpp_lib_copyable_function 202306L |
| 560 | // # define __cpp_lib_debugging 202311L | 567 | // # define __cpp_lib_debugging 202311L |
| 561 | // # define __cpp_lib_default_template_type_for_algorithm_values 202403L | 568 | // # define __cpp_lib_default_template_type_for_algorithm_values 202403L |
| ... | @@ -575,21 +582,30 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -575,21 +582,30 @@ __cpp_lib_void_t 201411L <type_traits> |
| 575 | // # define __cpp_lib_generate_random 202403L | 582 | // # define __cpp_lib_generate_random 202403L |
| 576 | // # define __cpp_lib_hazard_pointer 202306L | 583 | // # define __cpp_lib_hazard_pointer 202306L |
| 577 | // # define __cpp_lib_inplace_vector 202406L | 584 | // # define __cpp_lib_inplace_vector 202406L |
| 585 | # undef __cpp_lib_integer_sequence | ||
| 586 | # define __cpp_lib_integer_sequence 202511L | ||
| 578 | # define __cpp_lib_is_sufficiently_aligned 202411L | 587 | # define __cpp_lib_is_sufficiently_aligned 202411L |
| 579 | # if __has_builtin(__builtin_is_virtual_base_of) | 588 | # if __has_builtin(__builtin_is_virtual_base_of) |
| 580 | # define __cpp_lib_is_virtual_base_of 202406L | 589 | # define __cpp_lib_is_virtual_base_of 202406L |
| 581 | # endif | 590 | # endif |
| 582 | // # define __cpp_lib_is_within_lifetime 202306L | 591 | # if __has_builtin(__builtin_is_within_lifetime) |
| 592 | # define __cpp_lib_is_within_lifetime 202306L | ||
| 593 | # endif | ||
| 583 | // # define __cpp_lib_linalg 202311L | 594 | // # define __cpp_lib_linalg 202311L |
| 584 | # undef __cpp_lib_mdspan | 595 | # undef __cpp_lib_mdspan |
| 585 | # define __cpp_lib_mdspan 202406L | 596 | # define __cpp_lib_mdspan 202406L |
| 586 | # undef __cpp_lib_not_fn | 597 | # undef __cpp_lib_not_fn |
| 587 | # define __cpp_lib_not_fn 202306L | 598 | # define __cpp_lib_not_fn 202306L |
| 588 | // # define __cpp_lib_optional_range_support 202406L | 599 | # undef __cpp_lib_optional |
| 600 | # define __cpp_lib_optional 202506L | ||
| 601 | # if _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR | ||
| 602 | # define __cpp_lib_optional_range_support 202406L | ||
| 603 | # endif | ||
| 589 | # undef __cpp_lib_out_ptr | 604 | # undef __cpp_lib_out_ptr |
| 590 | # define __cpp_lib_out_ptr 202311L | 605 | # define __cpp_lib_out_ptr 202311L |
| 591 | // # define __cpp_lib_philox_engine 202406L | 606 | // # define __cpp_lib_philox_engine 202406L |
| 592 | // # define __cpp_lib_ranges_concat 202403L | 607 | // # define __cpp_lib_ranges_concat 202403L |
| 608 | # define __cpp_lib_ranges_indices 202506L | ||
| 593 | # define __cpp_lib_ratio 202306L | 609 | # define __cpp_lib_ratio 202306L |
| 594 | // # define __cpp_lib_rcu 202306L | 610 | // # define __cpp_lib_rcu 202306L |
| 595 | # define __cpp_lib_reference_wrapper 202403L | 611 | # define __cpp_lib_reference_wrapper 202403L |
| ... | @@ -599,6 +615,7 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -599,6 +615,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 599 | # define __cpp_lib_span_at 202311L | 615 | # define __cpp_lib_span_at 202311L |
| 600 | # define __cpp_lib_span_initializer_list 202311L | 616 | # define __cpp_lib_span_initializer_list 202311L |
| 601 | # define __cpp_lib_sstream_from_string_view 202306L | 617 | # define __cpp_lib_sstream_from_string_view 202306L |
| 618 | # define __cpp_lib_string_subview 202506L | ||
| 602 | # undef __cpp_lib_string_view | 619 | # undef __cpp_lib_string_view |
| 603 | # define __cpp_lib_string_view 202403L | 620 | # define __cpp_lib_string_view 202403L |
| 604 | // # define __cpp_lib_submdspan 202306L | 621 | // # define __cpp_lib_submdspan 202306L |
lib/libcxx/include/wctype.h+29-29| ... | @@ -45,13 +45,14 @@ wctrans_t wctrans(const char* property); | ... | @@ -45,13 +45,14 @@ wctrans_t wctrans(const char* property); |
| 45 | */ | 45 | */ |
| 46 | 46 | ||
| 47 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 47 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 48 | # include <__cxx03/wctype.h> | 48 | # include <__cxx03/__config> |
| 49 | #else | 49 | #else |
| 50 | # include <__config> | 50 | # include <__config> |
| 51 | #endif | ||
| 51 | 52 | ||
| 52 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 53 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 53 | # pragma GCC system_header | 54 | # pragma GCC system_header |
| 54 | # endif | 55 | #endif |
| 55 | 56 | ||
| 56 | // TODO: | 57 | // TODO: |
| 57 | // In the future, we should unconditionally include_next <wctype.h> here and instead | 58 | // In the future, we should unconditionally include_next <wctype.h> here and instead |
| ... | @@ -62,33 +63,32 @@ wctrans_t wctrans(const char* property); | ... | @@ -62,33 +63,32 @@ wctrans_t wctrans(const char* property); |
| 62 | // nothing (with using_if_exists), and if we include another header that defines one | 63 | // nothing (with using_if_exists), and if we include another header that defines one |
| 63 | // of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists | 64 | // of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists |
| 64 | // will fail because it does not refer to the same declaration. | 65 | // will fail because it does not refer to the same declaration. |
| 65 | # if __has_include_next(<wctype.h>) | 66 | #if __has_include_next(<wctype.h>) |
| 66 | # include_next <wctype.h> | 67 | # include_next <wctype.h> |
| 67 | # define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H | 68 | # define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H |
| 68 | # endif | 69 | #endif |
| 69 | 70 | ||
| 70 | # ifdef __cplusplus | 71 | #ifdef __cplusplus |
| 71 | 72 | ||
| 72 | # undef iswalnum | 73 | # undef iswalnum |
| 73 | # undef iswalpha | 74 | # undef iswalpha |
| 74 | # undef iswblank | 75 | # undef iswblank |
| 75 | # undef iswcntrl | 76 | # undef iswcntrl |
| 76 | # undef iswdigit | 77 | # undef iswdigit |
| 77 | # undef iswgraph | 78 | # undef iswgraph |
| 78 | # undef iswlower | 79 | # undef iswlower |
| 79 | # undef iswprint | 80 | # undef iswprint |
| 80 | # undef iswpunct | 81 | # undef iswpunct |
| 81 | # undef iswspace | 82 | # undef iswspace |
| 82 | # undef iswupper | 83 | # undef iswupper |
| 83 | # undef iswxdigit | 84 | # undef iswxdigit |
| 84 | # undef iswctype | 85 | # undef iswctype |
| 85 | # undef wctype | 86 | # undef wctype |
| 86 | # undef towlower | 87 | # undef towlower |
| 87 | # undef towupper | 88 | # undef towupper |
| 88 | # undef towctrans | 89 | # undef towctrans |
| 89 | # undef wctrans | 90 | # undef wctrans |
| 90 | 91 | ||
| 91 | # endif // __cplusplus | 92 | #endif // __cplusplus |
| 92 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 93 | 93 | ||
| 94 | #endif // _LIBCPP_WCTYPE_H | 94 | #endif // _LIBCPP_WCTYPE_H |
lib/libcxx/src/any.cpp+4| ... | @@ -14,6 +14,8 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; } | ... | @@ -14,6 +14,8 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; } |
| 14 | 14 | ||
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | 16 | ||
| 17 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 7 | ||
| 18 | |||
| 17 | // Preserve std::experimental::any_bad_cast for ABI compatibility | 19 | // Preserve std::experimental::any_bad_cast for ABI compatibility |
| 18 | // Even though it no longer exists in a header file | 20 | // Even though it no longer exists in a header file |
| 19 | _LIBCPP_BEGIN_NAMESPACE_LFTS | 21 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| ... | @@ -25,4 +27,6 @@ public: | ... | @@ -25,4 +27,6 @@ public: |
| 25 | 27 | ||
| 26 | const char* bad_any_cast::what() const noexcept { return "bad any cast"; } | 28 | const char* bad_any_cast::what() const noexcept { return "bad any cast"; } |
| 27 | 29 | ||
| 30 | #endif | ||
| 31 | |||
| 28 | _LIBCPP_END_NAMESPACE_LFTS | 32 | _LIBCPP_END_NAMESPACE_LFTS |
lib/libcxx/src/atomic.cpp+365-80| ... | @@ -9,8 +9,13 @@ | ... | @@ -9,8 +9,13 @@ |
| 9 | #include <__thread/timed_backoff_policy.h> | 9 | #include <__thread/timed_backoff_policy.h> |
| 10 | #include <atomic> | 10 | #include <atomic> |
| 11 | #include <climits> | 11 | #include <climits> |
| 12 | #include <cstddef> | ||
| 13 | #include <cstdint> | ||
| 14 | #include <cstring> | ||
| 12 | #include <functional> | 15 | #include <functional> |
| 16 | #include <new> | ||
| 13 | #include <thread> | 17 | #include <thread> |
| 18 | #include <type_traits> | ||
| 14 | 19 | ||
| 15 | #include "include/apple_availability.h" | 20 | #include "include/apple_availability.h" |
| 16 | 21 | ||
| ... | @@ -41,6 +46,11 @@ | ... | @@ -41,6 +46,11 @@ |
| 41 | // OpenBSD has no indirect syscalls | 46 | // OpenBSD has no indirect syscalls |
| 42 | # define _LIBCPP_FUTEX(...) futex(__VA_ARGS__) | 47 | # define _LIBCPP_FUTEX(...) futex(__VA_ARGS__) |
| 43 | 48 | ||
| 49 | #elif defined(_WIN32) | ||
| 50 | |||
| 51 | # include <memory> | ||
| 52 | # include <windows.h> | ||
| 53 | |||
| 44 | #else // <- Add other operating systems here | 54 | #else // <- Add other operating systems here |
| 45 | 55 | ||
| 46 | // Baseline needs no new headers | 56 | // Baseline needs no new headers |
| ... | @@ -49,17 +59,34 @@ | ... | @@ -49,17 +59,34 @@ |
| 49 | 59 | ||
| 50 | #endif | 60 | #endif |
| 51 | 61 | ||
| 62 | _LIBCPP_PUSH_MACROS | ||
| 63 | #include <__undef_macros> | ||
| 64 | |||
| 52 | _LIBCPP_BEGIN_NAMESPACE_STD | 65 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 53 | 66 | ||
| 67 | struct NoTimeout {}; | ||
| 68 | |||
| 54 | #ifdef __linux__ | 69 | #ifdef __linux__ |
| 55 | 70 | ||
| 56 | static void | 71 | template <std::size_t _Size, class MaybeTimeout> |
| 57 | __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { | 72 | static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) { |
| 58 | static constexpr timespec __timeout = {2, 0}; | 73 | static_assert(_Size == 4, "Can only wait on 4 bytes value"); |
| 59 | _LIBCPP_FUTEX(__ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0); | 74 | alignas(__cxx_contention_t) char buffer[_Size]; |
| 75 | std::memcpy(&buffer, const_cast<const void*>(__val), _Size); | ||
| 76 | static constexpr timespec __default_timeout = {2, 0}; | ||
| 77 | timespec __timeout; | ||
| 78 | if constexpr (is_same_v<MaybeTimeout, NoTimeout>) { | ||
| 79 | __timeout = __default_timeout; | ||
| 80 | } else { | ||
| 81 | __timeout.tv_sec = maybe_timeout_ns / 1'000'000'000; | ||
| 82 | __timeout.tv_nsec = maybe_timeout_ns % 1'000'000'000; | ||
| 83 | } | ||
| 84 | _LIBCPP_FUTEX(__ptr, FUTEX_WAIT_PRIVATE, *reinterpret_cast<__cxx_contention_t const*>(&buffer), &__timeout, 0, 0); | ||
| 60 | } | 85 | } |
| 61 | 86 | ||
| 62 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { | 87 | template <std::size_t _Size> |
| 88 | static void __platform_wake_by_address(void const* __ptr, bool __notify_one) { | ||
| 89 | static_assert(_Size == 4, "Can only wake up on 4 bytes value"); | ||
| 63 | _LIBCPP_FUTEX(__ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0); | 90 | _LIBCPP_FUTEX(__ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0); |
| 64 | } | 91 | } |
| 65 | 92 | ||
| ... | @@ -70,19 +97,41 @@ extern "C" int __ulock_wait( | ... | @@ -70,19 +97,41 @@ extern "C" int __ulock_wait( |
| 70 | extern "C" int __ulock_wake(uint32_t operation, void* addr, uint64_t wake_value); | 97 | extern "C" int __ulock_wake(uint32_t operation, void* addr, uint64_t wake_value); |
| 71 | 98 | ||
| 72 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/ulock.h#L82 | 99 | // https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/ulock.h#L82 |
| 100 | # define UL_COMPARE_AND_WAIT 1 | ||
| 73 | # define UL_COMPARE_AND_WAIT64 5 | 101 | # define UL_COMPARE_AND_WAIT64 5 |
| 74 | # define ULF_WAKE_ALL 0x00000100 | 102 | # define ULF_WAKE_ALL 0x00000100 |
| 75 | 103 | ||
| 76 | static void | 104 | template <std::size_t _Size, class MaybeTimeout> |
| 77 | __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { | 105 | static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) { |
| 78 | static_assert(sizeof(__cxx_atomic_contention_t) == 8, "Waiting on 8 bytes value"); | 106 | static_assert(_Size == 8 || _Size == 4, "Can only wait on 8 bytes or 4 bytes value"); |
| 79 | __ulock_wait(UL_COMPARE_AND_WAIT64, const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0); | 107 | auto __timeout_us = [&] { |
| 108 | if constexpr (is_same_v<MaybeTimeout, NoTimeout>) { | ||
| 109 | return uint32_t(0); | ||
| 110 | } else { | ||
| 111 | return std::max(static_cast<uint32_t>(maybe_timeout_ns / 1000), uint32_t(1)); | ||
| 112 | } | ||
| 113 | }(); | ||
| 114 | if constexpr (_Size == 4) { | ||
| 115 | alignas(uint32_t) char buffer[_Size]; | ||
| 116 | std::memcpy(&buffer, const_cast<const void*>(__val), _Size); | ||
| 117 | __ulock_wait( | ||
| 118 | UL_COMPARE_AND_WAIT, const_cast<void*>(__ptr), *reinterpret_cast<uint32_t const*>(&buffer), __timeout_us); | ||
| 119 | } else { | ||
| 120 | alignas(uint64_t) char buffer[_Size]; | ||
| 121 | std::memcpy(&buffer, const_cast<const void*>(__val), _Size); | ||
| 122 | __ulock_wait( | ||
| 123 | UL_COMPARE_AND_WAIT64, const_cast<void*>(__ptr), *reinterpret_cast<uint64_t const*>(&buffer), __timeout_us); | ||
| 124 | } | ||
| 80 | } | 125 | } |
| 81 | 126 | ||
| 82 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { | 127 | template <std::size_t _Size> |
| 83 | static_assert(sizeof(__cxx_atomic_contention_t) == 8, "Waking up on 8 bytes value"); | 128 | static void __platform_wake_by_address(void const* __ptr, bool __notify_one) { |
| 84 | __ulock_wake( | 129 | static_assert(_Size == 8 || _Size == 4, "Can only wake up on 8 bytes or 4 bytes value"); |
| 85 | UL_COMPARE_AND_WAIT64 | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<__cxx_atomic_contention_t*>(__ptr), 0); | 130 | |
| 131 | if constexpr (_Size == 4) | ||
| 132 | __ulock_wake(UL_COMPARE_AND_WAIT | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<void*>(__ptr), 0); | ||
| 133 | else | ||
| 134 | __ulock_wake(UL_COMPARE_AND_WAIT64 | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<void*>(__ptr), 0); | ||
| 86 | } | 135 | } |
| 87 | 136 | ||
| 88 | #elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8 | 137 | #elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8 |
| ... | @@ -92,119 +141,355 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo | ... | @@ -92,119 +141,355 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo |
| 92 | * limit its use to architectures where long and int64_t are synonyms. | 141 | * limit its use to architectures where long and int64_t are synonyms. |
| 93 | */ | 142 | */ |
| 94 | 143 | ||
| 95 | static void | 144 | template <std::size_t _Size, class MaybeTimeout> |
| 96 | __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { | 145 | static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) { |
| 97 | _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, nullptr, nullptr); | 146 | static_assert(_Size == 8, "Can only wait on 8 bytes value"); |
| 147 | // At the moment, FreeBSD is stuck on stable ABI, which only supports platform wait with __cxx_contention_t | ||
| 148 | // It is safe to reinterpret_cast the val as it is ever going to be passed a __cxx_contention_t under this ABI | ||
| 149 | // If in the future FreeBSD decides to experiment unstable ABI to support more types, this cast will no longer be | ||
| 150 | // safe. | ||
| 151 | __cxx_contention_t value = *reinterpret_cast<const __cxx_contention_t*>(__val); | ||
| 152 | if constexpr (is_same_v<MaybeTimeout, NoTimeout>) { | ||
| 153 | _umtx_op(const_cast<void*>(__ptr), UMTX_OP_WAIT, value, nullptr, nullptr); | ||
| 154 | } else { | ||
| 155 | timespec timeout{}; | ||
| 156 | timeout.tv_sec = maybe_timeout_ns / 1'000'000'000; | ||
| 157 | timeout.tv_nsec = maybe_timeout_ns % 1'000'000'000; | ||
| 158 | |||
| 159 | _umtx_op(const_cast<void*>(__ptr), | ||
| 160 | UMTX_OP_WAIT, | ||
| 161 | value, | ||
| 162 | reinterpret_cast<void*>(static_cast<uintptr_t>(sizeof(timeout))), | ||
| 163 | &timeout); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | template <std::size_t _Size> | ||
| 168 | static void __platform_wake_by_address(void const* __ptr, bool __notify_one) { | ||
| 169 | static_assert(_Size == 8, "Can only wake up on 8 bytes value"); | ||
| 170 | _umtx_op(const_cast<void*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr); | ||
| 171 | } | ||
| 172 | |||
| 173 | #elif defined(_WIN32) | ||
| 174 | |||
| 175 | static void* win32_get_synch_api_function(const char* function_name) { | ||
| 176 | // Attempt to load the API set. Note that as per the Microsoft STL implementation, we assume this API is already | ||
| 177 | // loaded and accessible. While this isn't explicitly guaranteed by publicly available Win32 API documentation, it is | ||
| 178 | // true in practice, and may be guaranteed by internal documentation not released publicly. In any case the fact that | ||
| 179 | // the Microsoft STL made this assumption is reasonable basis to say that we can too. The alternative to this would be | ||
| 180 | // to use LoadLibrary, but then leak the module handle. We can't call FreeLibrary, as this would have to be triggered | ||
| 181 | // by a global static destructor, which would hang off DllMain, and calling FreeLibrary from DllMain is explicitly | ||
| 182 | // mentioned as not being allowed: | ||
| 183 | // https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain | ||
| 184 | // Given the range of bad options here, we have chosen to mirror what Microsoft did, as it seems fair to assume that | ||
| 185 | // Microsoft will guarantee compatibility for us, as we are exposed to the same conditions as all existing Windows | ||
| 186 | // apps using the Microsoft STL VS2015/2017/2019/2022 runtimes, where Windows 7 support has not been excluded at | ||
| 187 | // compile time. | ||
| 188 | static auto module_handle = GetModuleHandleW(L"api-ms-win-core-synch-l1-2-0.dll"); | ||
| 189 | if (module_handle == nullptr) { | ||
| 190 | return nullptr; | ||
| 191 | } | ||
| 192 | |||
| 193 | // Attempt to locate the function in the API and return the result to the caller. Note that the NULL return from this | ||
| 194 | // method is documented as being interchangeable with nullptr. | ||
| 195 | // https://devblogs.microsoft.com/oldnewthing/20180307-00/?p=98175 | ||
| 196 | return reinterpret_cast<void*>(GetProcAddress(module_handle, function_name)); | ||
| 98 | } | 197 | } |
| 99 | 198 | ||
| 100 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { | 199 | template <std::size_t _Size, class MaybeTimeout> |
| 101 | _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr); | 200 | static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) { |
| 201 | static_assert(_Size == 8, "Can only wait on 8 bytes value"); | ||
| 202 | // WaitOnAddress was added in Windows 8 (build 9200) | ||
| 203 | static auto wait_on_address = | ||
| 204 | reinterpret_cast<BOOL(WINAPI*)(void*, PVOID, SIZE_T, DWORD)>(win32_get_synch_api_function("WaitOnAddress")); | ||
| 205 | if (wait_on_address != nullptr) { | ||
| 206 | auto timeout_ms = [&]() -> DWORD { | ||
| 207 | if constexpr (is_same_v<MaybeTimeout, NoTimeout>) { | ||
| 208 | return INFINITE; | ||
| 209 | } else { | ||
| 210 | uint64_t ms = maybe_timeout_ns / 1'000'000; | ||
| 211 | if (ms == 0 && maybe_timeout_ns > 100'000) | ||
| 212 | // Round up to 1ms if requested between 100us - 1ms | ||
| 213 | return 1; | ||
| 214 | |||
| 215 | return static_cast<DWORD>(std::min(static_cast<uint64_t>(INFINITE), ms)); | ||
| 216 | } | ||
| 217 | }(); | ||
| 218 | wait_on_address(const_cast<void*>(__ptr), const_cast<void*>(__val), _Size, timeout_ms); | ||
| 219 | } else { | ||
| 220 | std::chrono::nanoseconds timeout = std::chrono::nanoseconds(0); | ||
| 221 | if constexpr (!is_same_v<MaybeTimeout, NoTimeout>) { | ||
| 222 | timeout = std::chrono::nanoseconds(maybe_timeout_ns); | ||
| 223 | } | ||
| 224 | __libcpp_thread_poll_with_backoff( | ||
| 225 | [=]() -> bool { return std::memcmp(const_cast<const void*>(__ptr), __val, _Size) != 0; }, | ||
| 226 | __libcpp_timed_backoff_policy(), | ||
| 227 | timeout); | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | template <std::size_t _Size> | ||
| 232 | static void __platform_wake_by_address(void const* __ptr, bool __notify_one) { | ||
| 233 | static_assert(_Size == 8, "Can only wake up on 8 bytes value"); | ||
| 234 | if (__notify_one) { | ||
| 235 | // WakeByAddressSingle was added in Windows 8 (build 9200) | ||
| 236 | static auto wake_by_address_single = | ||
| 237 | reinterpret_cast<void(WINAPI*)(PVOID)>(win32_get_synch_api_function("WakeByAddressSingle")); | ||
| 238 | if (wake_by_address_single != nullptr) { | ||
| 239 | wake_by_address_single(const_cast<void*>(__ptr)); | ||
| 240 | } else { | ||
| 241 | // The fallback implementation of waking does nothing, as the fallback wait implementation just does polling, so | ||
| 242 | // there's nothing to do here. | ||
| 243 | } | ||
| 244 | } else { | ||
| 245 | // WakeByAddressAll was added in Windows 8 (build 9200) | ||
| 246 | static auto wake_by_address_all = | ||
| 247 | reinterpret_cast<void(WINAPI*)(PVOID)>(win32_get_synch_api_function("WakeByAddressAll")); | ||
| 248 | if (wake_by_address_all != nullptr) { | ||
| 249 | wake_by_address_all(const_cast<void*>(__ptr)); | ||
| 250 | } else { | ||
| 251 | // The fallback implementation of waking does nothing, as the fallback wait implementation just does polling, so | ||
| 252 | // there's nothing to do here. | ||
| 253 | } | ||
| 254 | } | ||
| 102 | } | 255 | } |
| 103 | 256 | ||
| 104 | #else // <- Add other operating systems here | 257 | #else // <- Add other operating systems here |
| 105 | 258 | ||
| 106 | // Baseline is just a timed backoff | 259 | // Baseline is just a timed backoff |
| 107 | 260 | ||
| 108 | static void | 261 | template <std::size_t _Size, class MaybeTimeout> |
| 109 | __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { | 262 | static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) { |
| 263 | std::chrono::nanoseconds timeout = std::chrono::nanoseconds(0); | ||
| 264 | if constexpr (!is_same_v<MaybeTimeout, NoTimeout>) { | ||
| 265 | timeout = std::chrono::nanoseconds(maybe_timeout_ns); | ||
| 266 | } | ||
| 110 | __libcpp_thread_poll_with_backoff( | 267 | __libcpp_thread_poll_with_backoff( |
| 111 | [=]() -> bool { return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__ptr, memory_order_relaxed), __val); }, | 268 | [=]() -> bool { return std::memcmp(const_cast<const void*>(__ptr), __val, _Size) != 0; }, |
| 112 | __libcpp_timed_backoff_policy()); | 269 | __libcpp_timed_backoff_policy(), |
| 270 | timeout); | ||
| 113 | } | 271 | } |
| 114 | 272 | ||
| 115 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile*, bool) {} | 273 | template <std::size_t _Size> |
| 274 | static void __platform_wake_by_address(void const*, bool) {} | ||
| 116 | 275 | ||
| 117 | #endif // __linux__ | 276 | #endif // __linux__ |
| 118 | 277 | ||
| 119 | static constexpr size_t __libcpp_contention_table_size = (1 << 8); /* < there's no magic in this number */ | 278 | // ============================= |
| 120 | 279 | // Local hidden helper functions | |
| 121 | struct alignas(64) /* aim to avoid false sharing */ __libcpp_contention_table_entry { | 280 | // ============================= |
| 122 | __cxx_atomic_contention_t __contention_state; | ||
| 123 | __cxx_atomic_contention_t __platform_state; | ||
| 124 | inline constexpr __libcpp_contention_table_entry() : __contention_state(0), __platform_state(0) {} | ||
| 125 | }; | ||
| 126 | |||
| 127 | static __libcpp_contention_table_entry __libcpp_contention_table[__libcpp_contention_table_size]; | ||
| 128 | |||
| 129 | static hash<void const volatile*> __libcpp_contention_hasher; | ||
| 130 | |||
| 131 | static __libcpp_contention_table_entry* __libcpp_contention_state(void const volatile* p) { | ||
| 132 | return &__libcpp_contention_table[__libcpp_contention_hasher(p) & (__libcpp_contention_table_size - 1)]; | ||
| 133 | } | ||
| 134 | 281 | ||
| 135 | /* Given an atomic to track contention and an atomic to actually wait on, which may be | 282 | /* Given an atomic to track contention and an atomic to actually wait on, which may be |
| 136 | the same atomic, we try to detect contention to avoid spuriously calling the platform. */ | 283 | the same atomic, we try to detect contention to avoid spuriously calling the platform. */ |
| 137 | 284 | ||
| 138 | static void __libcpp_contention_notify(__cxx_atomic_contention_t volatile* __contention_state, | 285 | template <std::size_t _Size> |
| 139 | __cxx_atomic_contention_t const volatile* __platform_state, | 286 | static void |
| 140 | bool __notify_one) { | 287 | __contention_notify(__cxx_atomic_contention_t* __waiter_count, void const* __address_to_notify, bool __notify_one) { |
| 141 | if (0 != __cxx_atomic_load(__contention_state, memory_order_seq_cst)) | 288 | if (0 != __cxx_atomic_load(__waiter_count, memory_order_seq_cst)) |
| 142 | // We only call 'wake' if we consumed a contention bit here. | 289 | // We only call 'wake' if we consumed a contention bit here. |
| 143 | __libcpp_platform_wake_by_address(__platform_state, __notify_one); | 290 | __platform_wake_by_address<_Size>(__address_to_notify, __notify_one); |
| 144 | } | 291 | } |
| 145 | static __cxx_contention_t | 292 | |
| 146 | __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__contention_state*/, | 293 | template <std::size_t _Size, class MaybeTimeout> |
| 147 | __cxx_atomic_contention_t const volatile* __platform_state) { | 294 | static void __contention_wait(__cxx_atomic_contention_t* __waiter_count, |
| 148 | // We will monitor this value. | 295 | void const* __address_to_wait, |
| 149 | return __cxx_atomic_load(__platform_state, memory_order_acquire); | 296 | void const* __old_value, |
| 150 | } | 297 | MaybeTimeout maybe_timeout_ns) { |
| 151 | static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state, | 298 | __cxx_atomic_fetch_add(__waiter_count, __cxx_contention_t(1), memory_order_relaxed); |
| 152 | __cxx_atomic_contention_t const volatile* __platform_state, | 299 | // https://llvm.org/PR109290 |
| 153 | __cxx_contention_t __old_value) { | ||
| 154 | __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_relaxed); | ||
| 155 | // https://github.com/llvm/llvm-project/issues/109290 | ||
| 156 | // There are no platform guarantees of a memory barrier in the platform wait implementation | 300 | // There are no platform guarantees of a memory barrier in the platform wait implementation |
| 157 | __cxx_atomic_thread_fence(memory_order_seq_cst); | 301 | __cxx_atomic_thread_fence(memory_order_seq_cst); |
| 158 | // We sleep as long as the monitored value hasn't changed. | 302 | // We sleep as long as the monitored value hasn't changed. |
| 159 | __libcpp_platform_wait_on_address(__platform_state, __old_value); | 303 | __platform_wait_on_address<_Size>(__address_to_wait, __old_value, maybe_timeout_ns); |
| 160 | __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release); | 304 | __cxx_atomic_fetch_sub(__waiter_count, __cxx_contention_t(1), memory_order_release); |
| 305 | } | ||
| 306 | |||
| 307 | static constexpr size_t __contention_table_size = (1 << 8); /* < there's no magic in this number */ | ||
| 308 | |||
| 309 | static constexpr hash<void const*> __contention_hasher; | ||
| 310 | |||
| 311 | // Waiter count table for all atomics with the correct size that use itself as the wait/notify address. | ||
| 312 | |||
| 313 | struct alignas( | ||
| 314 | std::hardware_constructive_interference_size) /* aim to avoid false sharing */ __contention_state_native { | ||
| 315 | __cxx_atomic_contention_t __waiter_count; | ||
| 316 | constexpr __contention_state_native() : __waiter_count(0) {} | ||
| 317 | }; | ||
| 318 | |||
| 319 | static __contention_state_native __contention_table_native[__contention_table_size]; | ||
| 320 | |||
| 321 | static __cxx_atomic_contention_t* __get_native_waiter_count(void const* p) { | ||
| 322 | return &__contention_table_native[__contention_hasher(p) & (__contention_table_size - 1)].__waiter_count; | ||
| 323 | } | ||
| 324 | |||
| 325 | // Global contention table for all atomics with the wrong size that use the global table's atomic as wait/notify | ||
| 326 | // address. | ||
| 327 | |||
| 328 | struct alignas( | ||
| 329 | std::hardware_constructive_interference_size) /* aim to avoid false sharing */ __contention_state_global { | ||
| 330 | __cxx_atomic_contention_t __waiter_count; | ||
| 331 | __cxx_atomic_contention_t __platform_state; | ||
| 332 | constexpr __contention_state_global() : __waiter_count(0), __platform_state(0) {} | ||
| 333 | }; | ||
| 334 | |||
| 335 | static __contention_state_global __contention_table_global[__contention_table_size]; | ||
| 336 | |||
| 337 | static __contention_state_global* __get_global_contention_state(void const* p) { | ||
| 338 | return &__contention_table_global[__contention_hasher(p) & (__contention_table_size - 1)]; | ||
| 161 | } | 339 | } |
| 162 | 340 | ||
| 163 | /* When the incoming atomic is the wrong size for the platform wait size, need to | 341 | /* When the incoming atomic is the wrong size for the platform wait size, need to |
| 164 | launder the value sequence through an atomic from our table. */ | 342 | launder the value sequence through an atomic from our table. */ |
| 165 | 343 | ||
| 166 | static void __libcpp_atomic_notify(void const volatile* __location) { | 344 | static void __atomic_notify_global_table(void const* __location) { |
| 167 | auto const __entry = __libcpp_contention_state(__location); | 345 | auto const __entry = __get_global_contention_state(__location); |
| 168 | // The value sequence laundering happens on the next line below. | 346 | // The value sequence laundering happens on the next line below. |
| 169 | __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_seq_cst); | 347 | __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_seq_cst); |
| 170 | __libcpp_contention_notify( | 348 | __contention_notify<sizeof(__cxx_atomic_contention_t)>( |
| 171 | &__entry->__contention_state, | 349 | &__entry->__waiter_count, &__entry->__platform_state, false /* when laundering, we can't handle notify_one */); |
| 172 | &__entry->__platform_state, | 350 | } |
| 173 | false /* when laundering, we can't handle notify_one */); | 351 | |
| 352 | // ============================= | ||
| 353 | // New dylib exported symbols | ||
| 354 | // ============================= | ||
| 355 | |||
| 356 | // global | ||
| 357 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __atomic_monitor_global(void const* __location) noexcept { | ||
| 358 | auto const __entry = __get_global_contention_state(__location); | ||
| 359 | return __cxx_atomic_load(&__entry->__platform_state, memory_order_acquire); | ||
| 360 | } | ||
| 361 | |||
| 362 | _LIBCPP_EXPORTED_FROM_ABI void | ||
| 363 | __atomic_wait_global_table(void const* __location, __cxx_contention_t __old_value) noexcept { | ||
| 364 | auto const __entry = __get_global_contention_state(__location); | ||
| 365 | __contention_wait<sizeof(__cxx_atomic_contention_t)>( | ||
| 366 | &__entry->__waiter_count, &__entry->__platform_state, &__old_value, NoTimeout{}); | ||
| 367 | } | ||
| 368 | |||
| 369 | _LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_global_table_with_timeout( | ||
| 370 | void const* __location, __cxx_contention_t __old_value, uint64_t __timeout_ns) _NOEXCEPT { | ||
| 371 | auto const __entry = __get_global_contention_state(__location); | ||
| 372 | __contention_wait<sizeof(__cxx_atomic_contention_t)>( | ||
| 373 | &__entry->__waiter_count, &__entry->__platform_state, &__old_value, __timeout_ns); | ||
| 374 | } | ||
| 375 | |||
| 376 | _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one_global_table(void const* __location) noexcept { | ||
| 377 | __atomic_notify_global_table(__location); | ||
| 378 | } | ||
| 379 | |||
| 380 | _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_global_table(void const* __location) noexcept { | ||
| 381 | __atomic_notify_global_table(__location); | ||
| 382 | } | ||
| 383 | |||
| 384 | // native | ||
| 385 | |||
| 386 | template <std::size_t _Size> | ||
| 387 | _LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_native(void const* __address, void const* __old_value) noexcept { | ||
| 388 | __contention_wait<_Size>(__get_native_waiter_count(__address), __address, __old_value, NoTimeout{}); | ||
| 174 | } | 389 | } |
| 390 | |||
| 391 | template <std::size_t _Size> | ||
| 392 | _LIBCPP_EXPORTED_FROM_ABI void | ||
| 393 | __atomic_wait_native_with_timeout(void const* __address, void const* __old_value, uint64_t __timeout_ns) noexcept { | ||
| 394 | __contention_wait<_Size>(__get_native_waiter_count(__address), __address, __old_value, __timeout_ns); | ||
| 395 | } | ||
| 396 | |||
| 397 | template <std::size_t _Size> | ||
| 398 | _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one_native(void const* __location) noexcept { | ||
| 399 | __contention_notify<_Size>(__get_native_waiter_count(__location), __location, true); | ||
| 400 | } | ||
| 401 | |||
| 402 | template <std::size_t _Size> | ||
| 403 | _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_native(void const* __location) noexcept { | ||
| 404 | __contention_notify<_Size>(__get_native_waiter_count(__location), __location, false); | ||
| 405 | } | ||
| 406 | |||
| 407 | // ================================================== | ||
| 408 | // Instantiation of the templates with supported size | ||
| 409 | // ================================================== | ||
| 410 | |||
| 411 | #if defined(_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE) | ||
| 412 | |||
| 413 | # define _INSTANTIATE(_SIZE) \ | ||
| 414 | template _LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_native<_SIZE>(void const*, void const*) noexcept; \ | ||
| 415 | template _LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_native_with_timeout<_SIZE>( \ | ||
| 416 | void const*, void const*, uint64_t) noexcept; \ | ||
| 417 | template _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one_native<_SIZE>(void const*) noexcept; \ | ||
| 418 | template _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_native<_SIZE>(void const*) noexcept; | ||
| 419 | |||
| 420 | _LIBCPP_NATIVE_PLATFORM_WAIT_SIZES(_INSTANTIATE) | ||
| 421 | |||
| 422 | # undef _INSTANTIATE | ||
| 423 | |||
| 424 | #else // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE | ||
| 425 | |||
| 426 | template _LIBCPP_EXPORTED_FROM_ABI void | ||
| 427 | __atomic_wait_native<sizeof(__cxx_contention_t)>(void const* __address, void const* __old_value) noexcept; | ||
| 428 | |||
| 429 | template _LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_native_with_timeout<sizeof(__cxx_contention_t)>( | ||
| 430 | void const* __address, void const* __old_value, uint64_t) noexcept; | ||
| 431 | |||
| 432 | template _LIBCPP_EXPORTED_FROM_ABI void | ||
| 433 | __atomic_notify_one_native<sizeof(__cxx_contention_t)>(void const* __location) noexcept; | ||
| 434 | |||
| 435 | template _LIBCPP_EXPORTED_FROM_ABI void | ||
| 436 | __atomic_notify_all_native<sizeof(__cxx_contention_t)>(void const* __location) noexcept; | ||
| 437 | |||
| 438 | #endif // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE | ||
| 439 | |||
| 440 | // ============================================================= | ||
| 441 | // Old dylib exported symbols, for backwards compatibility | ||
| 442 | // ============================================================= | ||
| 443 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 444 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") | ||
| 445 | |||
| 175 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) noexcept { | 446 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) noexcept { |
| 176 | __libcpp_atomic_notify(__location); | 447 | __atomic_notify_global_table(const_cast<void const*>(__location)); |
| 177 | } | 448 | } |
| 449 | |||
| 178 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) noexcept { | 450 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) noexcept { |
| 179 | __libcpp_atomic_notify(__location); | 451 | __atomic_notify_global_table(const_cast<void const*>(__location)); |
| 180 | } | 452 | } |
| 453 | |||
| 181 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) noexcept { | 454 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) noexcept { |
| 182 | auto const __entry = __libcpp_contention_state(__location); | 455 | auto const __entry = __get_global_contention_state(const_cast<void const*>(__location)); |
| 183 | return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state); | 456 | return __cxx_atomic_load(&__entry->__platform_state, memory_order_acquire); |
| 184 | } | 457 | } |
| 458 | |||
| 185 | _LIBCPP_EXPORTED_FROM_ABI void | 459 | _LIBCPP_EXPORTED_FROM_ABI void |
| 186 | __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) noexcept { | 460 | __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) noexcept { |
| 187 | auto const __entry = __libcpp_contention_state(__location); | 461 | auto const __entry = __get_global_contention_state(const_cast<void const*>(__location)); |
| 188 | __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value); | 462 | __contention_wait<sizeof(__cxx_atomic_contention_t)>( |
| 463 | &__entry->__waiter_count, &__entry->__platform_state, &__old_value, NoTimeout{}); | ||
| 189 | } | 464 | } |
| 190 | 465 | ||
| 191 | /* When the incoming atomic happens to be the platform wait size, we still need to use the | ||
| 192 | table for the contention detection, but we can use the atomic directly for the wait. */ | ||
| 193 | |||
| 194 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) noexcept { | 466 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) noexcept { |
| 195 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true); | 467 | auto __location_cast = const_cast<const void*>(static_cast<const volatile void*>(__location)); |
| 468 | __contention_notify<sizeof(__cxx_atomic_contention_t)>( | ||
| 469 | __get_native_waiter_count(__location_cast), __location_cast, true); | ||
| 196 | } | 470 | } |
| 471 | |||
| 197 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) noexcept { | 472 | _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) noexcept { |
| 198 | __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false); | 473 | auto __location_cast = const_cast<const void*>(static_cast<const volatile void*>(__location)); |
| 199 | } | 474 | __contention_notify<sizeof(__cxx_atomic_contention_t)>( |
| 200 | // This function is never used, but still exported for ABI compatibility. | 475 | __get_native_waiter_count(__location_cast), __location_cast, false); |
| 201 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t | ||
| 202 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) noexcept { | ||
| 203 | return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location); | ||
| 204 | } | 476 | } |
| 477 | |||
| 205 | _LIBCPP_EXPORTED_FROM_ABI void | 478 | _LIBCPP_EXPORTED_FROM_ABI void |
| 206 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) noexcept { | 479 | __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) noexcept { |
| 207 | __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value); | 480 | auto __location_cast = const_cast<const void*>(static_cast<const volatile void*>(__location)); |
| 481 | __contention_wait<sizeof(__cxx_atomic_contention_t)>( | ||
| 482 | __get_native_waiter_count(__location_cast), __location_cast, &__old_value, NoTimeout{}); | ||
| 208 | } | 483 | } |
| 209 | 484 | ||
| 485 | // this function is even unused in the old ABI | ||
| 486 | _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t | ||
| 487 | __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) noexcept { | ||
| 488 | return __cxx_atomic_load(__location, memory_order_acquire); | ||
| 489 | } | ||
| 490 | |||
| 491 | _LIBCPP_DIAGNOSTIC_POP | ||
| 492 | |||
| 210 | _LIBCPP_END_NAMESPACE_STD | 493 | _LIBCPP_END_NAMESPACE_STD |
| 494 | |||
| 495 | _LIBCPP_POP_MACROS |
lib/libcxx/src/barrier.cpp+4-3| ... | @@ -60,11 +60,12 @@ public: | ... | @@ -60,11 +60,12 @@ public: |
| 60 | _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected) { | 60 | _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected) { |
| 61 | return new __barrier_algorithm_base(__expected); | 61 | return new __barrier_algorithm_base(__expected); |
| 62 | } | 62 | } |
| 63 | _LIBCPP_EXPORTED_FROM_ABI bool | 63 | _LIBCPP_EXPORTED_FROM_ABI bool __arrive_barrier_algorithm_base( |
| 64 | __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept { | 64 | _LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept { |
| 65 | return __barrier->__arrive(__old_phase); | 65 | return __barrier->__arrive(__old_phase); |
| 66 | } | 66 | } |
| 67 | _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept { | 67 | _LIBCPP_EXPORTED_FROM_ABI void |
| 68 | __destroy_barrier_algorithm_base(_LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier) noexcept { | ||
| 68 | delete __barrier; | 69 | delete __barrier; |
| 69 | } | 70 | } |
| 70 | 71 |
lib/libcxx/src/charconv.cpp+6-3| ... | @@ -14,17 +14,20 @@ | ... | @@ -14,17 +14,20 @@ |
| 14 | 14 | ||
| 15 | _LIBCPP_BEGIN_NAMESPACE_STD | 15 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 16 | 16 | ||
| 17 | #ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | 17 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 15 |
| 18 | 18 | ||
| 19 | namespace __itoa { | 19 | namespace __itoa { |
| 20 | 20 | ||
| 21 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 22 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") | ||
| 23 | // These functions exist for ABI compatibility, so we don't ever want a declaration prior to the definition. | ||
| 21 | _LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); } | 24 | _LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); } |
| 22 | |||
| 23 | _LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); } | 25 | _LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); } |
| 26 | _LIBCPP_DIAGNOSTIC_POP | ||
| 24 | 27 | ||
| 25 | } // namespace __itoa | 28 | } // namespace __itoa |
| 26 | 29 | ||
| 27 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | 30 | #endif // _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 15 |
| 28 | 31 | ||
| 29 | // The original version of floating-point to_chars was written by Microsoft and | 32 | // The original version of floating-point to_chars was written by Microsoft and |
| 30 | // contributed with the following license. | 33 | // contributed with the following license. |
lib/libcxx/src/condition_variable_destructor.cpp+1-1| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__thread/support.h> | 15 | #include <__thread/support.h> |
| 16 | 16 | ||
| 17 | #if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | 17 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 9 || !_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION |
| 18 | # define NEEDS_CONDVAR_DESTRUCTOR | 18 | # define NEEDS_CONDVAR_DESTRUCTOR |
| 19 | #endif | 19 | #endif |
| 20 | 20 |
lib/libcxx/src/error_category.cpp+3-1| ... | @@ -8,7 +8,9 @@ | ... | @@ -8,7 +8,9 @@ |
| 8 | 8 | ||
| 9 | #include <__config> | 9 | #include <__config> |
| 10 | 10 | ||
| 11 | #ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | 11 | // This has technically been removed in LLVM 3.4 |
| 12 | #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) && !defined(_LIBCPP_OBJECT_FORMAT_XCOFF) && \ | ||
| 13 | _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 4 | ||
| 12 | # define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS | 14 | # define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS |
| 13 | #endif | 15 | #endif |
| 14 | 16 |
lib/libcxx/src/exception.cpp+2-10| ... | @@ -9,20 +9,12 @@ | ... | @@ -9,20 +9,12 @@ |
| 9 | #define _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION | 9 | #define _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION |
| 10 | #define _LIBCPP_DISABLE_DEPRECATION_WARNINGS | 10 | #define _LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 11 | 11 | ||
| 12 | #include <exception> | 12 | #include <__config> |
| 13 | #include <new> | ||
| 14 | #include <typeinfo> | ||
| 15 | |||
| 16 | #if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) | ||
| 17 | # include <cxxabi.h> | ||
| 18 | using namespace __cxxabiv1; | ||
| 19 | # define HAVE_DEPENDENT_EH_ABI 1 | ||
| 20 | #endif | ||
| 21 | 13 | ||
| 22 | #if defined(_LIBCPP_ABI_MICROSOFT) | 14 | #if defined(_LIBCPP_ABI_MICROSOFT) |
| 23 | # include "support/runtime/exception_msvc.ipp" | 15 | # include "support/runtime/exception_msvc.ipp" |
| 24 | # include "support/runtime/exception_pointer_msvc.ipp" | 16 | # include "support/runtime/exception_pointer_msvc.ipp" |
| 25 | #elif defined(_LIBCPPABI_VERSION) | 17 | #elif defined(LIBCXX_BUILDING_LIBCXXABI) |
| 26 | # include "support/runtime/exception_libcxxabi.ipp" | 18 | # include "support/runtime/exception_libcxxabi.ipp" |
| 27 | # include "support/runtime/exception_pointer_cxxabi.ipp" | 19 | # include "support/runtime/exception_pointer_cxxabi.ipp" |
| 28 | #elif defined(LIBCXXRT) | 20 | #elif defined(LIBCXXRT) |
lib/libcxx/src/experimental/time_zone.cpp+1-1| ... | @@ -720,7 +720,7 @@ __get_sys_info(sys_seconds __time, | ... | @@ -720,7 +720,7 @@ __get_sys_info(sys_seconds __time, |
| 720 | // Iff the "offsets" are the same '__current.__end' is replaced with | 720 | // Iff the "offsets" are the same '__current.__end' is replaced with |
| 721 | // '__next.__end', which effectively merges the two objects in one object. The | 721 | // '__next.__end', which effectively merges the two objects in one object. The |
| 722 | // function returns true if a merge occurred. | 722 | // function returns true if a merge occurred. |
| 723 | [[nodiscard]] bool __merge_continuation(sys_info& __current, const sys_info& __next) { | 723 | [[nodiscard]] static bool __merge_continuation(sys_info& __current, const sys_info& __next) { |
| 724 | if (__current.end != __next.begin) | 724 | if (__current.end != __next.begin) |
| 725 | return false; | 725 | return false; |
| 726 | 726 |
lib/libcxx/src/experimental/tzdb.cpp+4-1| ... | @@ -49,6 +49,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -49,6 +49,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 49 | 49 | ||
| 50 | namespace chrono { | 50 | namespace chrono { |
| 51 | 51 | ||
| 52 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 53 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") | ||
| 52 | // This function is weak so it can be overriden in the tests. The | 54 | // This function is weak so it can be overriden in the tests. The |
| 53 | // declaration is in the test header test/support/test_tzdb.h | 55 | // declaration is in the test header test/support/test_tzdb.h |
| 54 | _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { | 56 | _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { |
| ... | @@ -59,6 +61,7 @@ _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { | ... | @@ -59,6 +61,7 @@ _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { |
| 59 | abort(); | 61 | abort(); |
| 60 | #endif | 62 | #endif |
| 61 | } | 63 | } |
| 64 | _LIBCPP_DIAGNOSTIC_POP | ||
| 62 | 65 | ||
| 63 | //===----------------------------------------------------------------------===// | 66 | //===----------------------------------------------------------------------===// |
| 64 | // Details | 67 | // Details |
| ... | @@ -767,7 +770,7 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { | ... | @@ -767,7 +770,7 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { |
| 767 | // On Linux systems it seems /etc/timezone is deprecated and being phased out. | 770 | // On Linux systems it seems /etc/timezone is deprecated and being phased out. |
| 768 | // This file is used when /etc/localtime does not exist, or when it exists but | 771 | // This file is used when /etc/localtime does not exist, or when it exists but |
| 769 | // is not a symlink. For more information and links see | 772 | // is not a symlink. For more information and links see |
| 770 | // https://github.com/llvm/llvm-project/issues/105634 | 773 | // https://llvm.org/PR105634 |
| 771 | 774 | ||
| 772 | string __name = chrono::__current_zone_environment(); | 775 | string __name = chrono::__current_zone_environment(); |
| 773 | 776 |
lib/libcxx/src/filesystem/error.h+4-22| ... | @@ -128,17 +128,8 @@ struct ErrorHandler { | ... | @@ -128,17 +128,8 @@ struct ErrorHandler { |
| 128 | T report(const error_code& ec, const char* msg, ...) const { | 128 | T report(const error_code& ec, const char* msg, ...) const { |
| 129 | va_list ap; | 129 | va_list ap; |
| 130 | va_start(ap, msg); | 130 | va_start(ap, msg); |
| 131 | #if _LIBCPP_HAS_EXCEPTIONS | 131 | __scope_guard guard([&] { va_end(ap); }); |
| 132 | try { | 132 | report_impl(ec, msg, ap); |
| 133 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 134 | report_impl(ec, msg, ap); | ||
| 135 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 136 | } catch (...) { | ||
| 137 | va_end(ap); | ||
| 138 | throw; | ||
| 139 | } | ||
| 140 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 141 | va_end(ap); | ||
| 142 | return error_value<T>(); | 133 | return error_value<T>(); |
| 143 | } | 134 | } |
| 144 | 135 | ||
| ... | @@ -148,17 +139,8 @@ struct ErrorHandler { | ... | @@ -148,17 +139,8 @@ struct ErrorHandler { |
| 148 | T report(errc const& err, const char* msg, ...) const { | 139 | T report(errc const& err, const char* msg, ...) const { |
| 149 | va_list ap; | 140 | va_list ap; |
| 150 | va_start(ap, msg); | 141 | va_start(ap, msg); |
| 151 | #if _LIBCPP_HAS_EXCEPTIONS | 142 | __scope_guard guard([&] { va_end(ap); }); |
| 152 | try { | 143 | report_impl(make_error_code(err), msg, ap); |
| 153 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 154 | report_impl(make_error_code(err), msg, ap); | ||
| 155 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 156 | } catch (...) { | ||
| 157 | va_end(ap); | ||
| 158 | throw; | ||
| 159 | } | ||
| 160 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 161 | va_end(ap); | ||
| 162 | return error_value<T>(); | 144 | return error_value<T>(); |
| 163 | } | 145 | } |
| 164 | 146 |
lib/libcxx/src/filesystem/format_string.h+9-18| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__assert> | 12 | #include <__assert> |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__utility/scope_guard.h> | ||
| 14 | #include <array> | 15 | #include <array> |
| 15 | #include <cstdarg> | 16 | #include <cstdarg> |
| 16 | #include <cstddef> | 17 | #include <cstddef> |
| ... | @@ -34,20 +35,19 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 0) string vformat_string(const ch | ... | @@ -34,20 +35,19 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 0) string vformat_string(const ch |
| 34 | 35 | ||
| 35 | va_list apcopy; | 36 | va_list apcopy; |
| 36 | va_copy(apcopy, ap); | 37 | va_copy(apcopy, ap); |
| 37 | int ret = ::vsnprintf(buf.data(), buf.size(), msg, apcopy); | 38 | int size = ::vsnprintf(buf.data(), buf.size(), msg, apcopy); |
| 38 | va_end(apcopy); | 39 | va_end(apcopy); |
| 39 | 40 | ||
| 40 | string result; | 41 | string result; |
| 41 | if (static_cast<size_t>(ret) < buf.size()) { | 42 | if (static_cast<size_t>(size) < buf.size()) { |
| 42 | result.assign(buf.data(), static_cast<size_t>(ret)); | 43 | result.assign(buf.data(), static_cast<size_t>(size)); |
| 43 | } else { | 44 | } else { |
| 44 | // we did not provide a long enough buffer on our first attempt. The | 45 | // we did not provide a long enough buffer on our first attempt. The |
| 45 | // return value is the number of bytes (excluding the null byte) that are | 46 | // return value is the number of bytes (excluding the null byte) that are |
| 46 | // needed for formatting. | 47 | // needed for formatting. |
| 47 | size_t size_with_null = static_cast<size_t>(ret) + 1; | 48 | result.resize_and_overwrite(size, [&](char* res, size_t n) { return ::vsnprintf(res, n, msg, ap); }); |
| 48 | result.__resize_default_init(size_with_null - 1); | 49 | _LIBCPP_ASSERT_INTERNAL(static_cast<size_t>(size) == result.size(), |
| 49 | ret = ::vsnprintf(&result[0], size_with_null, msg, ap); | 50 | "vsnprintf did not result in the same number of characters as the first attempt?"); |
| 50 | _LIBCPP_ASSERT_INTERNAL(static_cast<size_t>(ret) == (size_with_null - 1), "TODO"); | ||
| 51 | } | 51 | } |
| 52 | return result; | 52 | return result; |
| 53 | } | 53 | } |
| ... | @@ -56,17 +56,8 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string format_string(const cha | ... | @@ -56,17 +56,8 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string format_string(const cha |
| 56 | string ret; | 56 | string ret; |
| 57 | va_list ap; | 57 | va_list ap; |
| 58 | va_start(ap, msg); | 58 | va_start(ap, msg); |
| 59 | #if _LIBCPP_HAS_EXCEPTIONS | 59 | __scope_guard guard([&] { va_end(ap); }); |
| 60 | try { | 60 | ret = detail::vformat_string(msg, ap); |
| 61 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 62 | ret = detail::vformat_string(msg, ap); | ||
| 63 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 64 | } catch (...) { | ||
| 65 | va_end(ap); | ||
| 66 | throw; | ||
| 67 | } | ||
| 68 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 69 | va_end(ap); | ||
| 70 | return ret; | 61 | return ret; |
| 71 | } | 62 | } |
| 72 | 63 |
lib/libcxx/src/filesystem/int128_builtins.cpp+2| ... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <climits> | 17 | #include <climits> |
| 18 | 18 | ||
| 19 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") // See the FIXME above | ||
| 20 | |||
| 19 | #if _LIBCPP_HAS_INT128 | 21 | #if _LIBCPP_HAS_INT128 |
| 20 | 22 | ||
| 21 | extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t | 23 | extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t |
lib/libcxx/src/filesystem/operations.cpp+2-9| ... | @@ -41,17 +41,10 @@ | ... | @@ -41,17 +41,10 @@ |
| 41 | #include <time.h> | 41 | #include <time.h> |
| 42 | 42 | ||
| 43 | // since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl | 43 | // since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl |
| 44 | #if defined(__linux__) | 44 | #if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__) |
| 45 | # if defined(_LIBCPP_GLIBC_PREREQ) | ||
| 46 | # if _LIBCPP_GLIBC_PREREQ(2, 27) | ||
| 47 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE | ||
| 48 | # endif | ||
| 49 | # elif _LIBCPP_HAS_MUSL_LIBC | ||
| 50 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE | ||
| 51 | # endif | ||
| 52 | #elif defined(__FreeBSD__) | ||
| 53 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE | 45 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE |
| 54 | #endif | 46 | #endif |
| 47 | |||
| 55 | #if __has_include(<sys/sendfile.h>) | 48 | #if __has_include(<sys/sendfile.h>) |
| 56 | # include <sys/sendfile.h> | 49 | # include <sys/sendfile.h> |
| 57 | # define _LIBCPP_FILESYSTEM_USE_SENDFILE | 50 | # define _LIBCPP_FILESYSTEM_USE_SENDFILE |
lib/libcxx/src/filesystem/path.cpp+3-1| ... | @@ -292,7 +292,9 @@ path path::lexically_relative(const path& base) const { | ... | @@ -292,7 +292,9 @@ path path::lexically_relative(const path& base) const { |
| 292 | // return a path constructed with 'n' dot-dot elements, followed by the | 292 | // return a path constructed with 'n' dot-dot elements, followed by the |
| 293 | // elements of '*this' after the mismatch. | 293 | // elements of '*this' after the mismatch. |
| 294 | path Result; | 294 | path Result; |
| 295 | // FIXME: Reserve enough room in Result that it won't have to re-allocate. | 295 | constexpr size_t ElemSize = 2; // ".." |
| 296 | constexpr size_t SeparatorSize = 1; // separator is always a single char | ||
| 297 | Result.__reserve(ElemCount * (ElemSize + SeparatorSize) + SeparatorSize + PP.Path.size()); | ||
| 296 | while (ElemCount--) | 298 | while (ElemCount--) |
| 297 | Result /= PATHSTR(".."); | 299 | Result /= PATHSTR(".."); |
| 298 | for (; PP; ++PP) | 300 | for (; PP; ++PP) |
lib/libcxx/src/include/aligned_alloc.h created+65| ... | @@ -0,0 +1,65 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP_SRC_ALIGNED_ALLOC_H | ||
| 10 | #define _LIBCPP_SRC_ALIGNED_ALLOC_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <cstdlib> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION | ||
| 22 | |||
| 23 | // Low-level helpers to call the aligned allocation and deallocation functions | ||
| 24 | // on the target platform. This is used to implement libc++'s own memory | ||
| 25 | // allocation routines -- if you need to allocate memory inside the library, | ||
| 26 | // chances are that you want to use `__libcpp_allocate` instead. | ||
| 27 | // | ||
| 28 | // Returns the allocated memory, or `nullptr` on failure. | ||
| 29 | inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) { | ||
| 30 | # if defined(_LIBCPP_MSVCRT_LIKE) | ||
| 31 | return ::_aligned_malloc(__size, __alignment); | ||
| 32 | |||
| 33 | // Android only provides aligned_alloc when targeting API 28 or higher. | ||
| 34 | # elif !defined(__ANDROID__) || __ANDROID_API__ >= 28 | ||
| 35 | // aligned_alloc() requires that __size is a multiple of __alignment, | ||
| 36 | // but for C++ [new.delete.general], only states "if the value of an | ||
| 37 | // alignment argument passed to any of these functions is not a valid | ||
| 38 | // alignment value, the behavior is undefined". | ||
| 39 | // To handle calls such as ::operator new(1, std::align_val_t(128)), we | ||
| 40 | // round __size up to the next multiple of __alignment. | ||
| 41 | size_t __rounded_size = (__size + __alignment - 1) & ~(__alignment - 1); | ||
| 42 | // Rounding up could have wrapped around to zero, so we have to add another | ||
| 43 | // max() ternary to the actual call site to avoid succeeded in that case. | ||
| 44 | return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size); | ||
| 45 | # else | ||
| 46 | void* __result = nullptr; | ||
| 47 | (void)::posix_memalign(&__result, __alignment, __size); | ||
| 48 | // If posix_memalign fails, __result is unmodified so we still return `nullptr`. | ||
| 49 | return __result; | ||
| 50 | # endif | ||
| 51 | } | ||
| 52 | |||
| 53 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) { | ||
| 54 | # if defined(_LIBCPP_MSVCRT_LIKE) | ||
| 55 | ::_aligned_free(__ptr); | ||
| 56 | # else | ||
| 57 | ::free(__ptr); | ||
| 58 | # endif | ||
| 59 | } | ||
| 60 | |||
| 61 | #endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION | ||
| 62 | |||
| 63 | _LIBCPP_END_NAMESPACE_STD | ||
| 64 | |||
| 65 | #endif // _LIBCPP_SRC_ALIGNED_ALLOC_H | ||
lib/libcxx/src/include/config_elast.h+1-1| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | # define _LIBCPP_ELAST ELAST | 23 | # define _LIBCPP_ELAST ELAST |
| 24 | #elif defined(__LLVM_LIBC__) | 24 | #elif defined(__LLVM_LIBC__) |
| 25 | // No _LIBCPP_ELAST needed for LLVM libc | 25 | // No _LIBCPP_ELAST needed for LLVM libc |
| 26 | #elif defined(_NEWLIB_VERSION) | 26 | #elif _LIBCPP_LIBC_NEWLIB |
| 27 | # define _LIBCPP_ELAST __ELASTERROR | 27 | # define _LIBCPP_ELAST __ELASTERROR |
| 28 | #elif defined(__NuttX__) | 28 | #elif defined(__NuttX__) |
| 29 | // No _LIBCPP_ELAST needed on NuttX | 29 | // No _LIBCPP_ELAST needed on NuttX |
lib/libcxx/src/include/from_chars_floating_point.h+11-7| ... | @@ -9,11 +9,6 @@ | ... | @@ -9,11 +9,6 @@ |
| 9 | #ifndef _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H | 9 | #ifndef _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H |
| 10 | #define _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H | 10 | #define _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H |
| 11 | 11 | ||
| 12 | // These headers are in the shared LLVM-libc header library. | ||
| 13 | #include "shared/fp_bits.h" | ||
| 14 | #include "shared/str_to_float.h" | ||
| 15 | #include "shared/str_to_integer.h" | ||
| 16 | |||
| 17 | #include <__assert> | 12 | #include <__assert> |
| 18 | #include <__config> | 13 | #include <__config> |
| 19 | #include <cctype> | 14 | #include <cctype> |
| ... | @@ -21,6 +16,15 @@ | ... | @@ -21,6 +16,15 @@ |
| 21 | #include <concepts> | 16 | #include <concepts> |
| 22 | #include <limits> | 17 | #include <limits> |
| 23 | 18 | ||
| 19 | // Make sure we use libc++'s assertion machinery within the shared code we use | ||
| 20 | // from LLVM libc. | ||
| 21 | #define LIBC_ASSERT(cond) _LIBCPP_ASSERT((cond), _LIBCPP_TOSTRING(cond)) | ||
| 22 | |||
| 23 | // These headers are in the shared LLVM-libc header library. | ||
| 24 | #include "shared/fp_bits.h" | ||
| 25 | #include "shared/str_to_float.h" | ||
| 26 | #include "shared/str_to_integer.h" | ||
| 27 | |||
| 24 | // Included for the _Floating_type_traits class | 28 | // Included for the _Floating_type_traits class |
| 25 | #include "to_chars_floating_point.h" | 29 | #include "to_chars_floating_point.h" |
| 26 | 30 | ||
| ... | @@ -193,7 +197,7 @@ struct __exponent_result { | ... | @@ -193,7 +197,7 @@ struct __exponent_result { |
| 193 | // __offset, 0, false. This allows using the results unconditionally, the | 197 | // __offset, 0, false. This allows using the results unconditionally, the |
| 194 | // __present is important for the scientific notation, where the value is | 198 | // __present is important for the scientific notation, where the value is |
| 195 | // mandatory. | 199 | // mandatory. |
| 196 | __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) { | 200 | static __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) { |
| 197 | if (__offset + 1 < __n && // an exponent always needs at least one digit. | 201 | if (__offset + 1 < __n && // an exponent always needs at least one digit. |
| 198 | std::tolower(__input[__offset]) == __marker && // | 202 | std::tolower(__input[__offset]) == __marker && // |
| 199 | !std::isspace(__input[__offset + 1]) // leading whitespace is not allowed. | 203 | !std::isspace(__input[__offset + 1]) // leading whitespace is not allowed. |
| ... | @@ -213,7 +217,7 @@ __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __off | ... | @@ -213,7 +217,7 @@ __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __off |
| 213 | } | 217 | } |
| 214 | 218 | ||
| 215 | // Here we do this operation as int64 to avoid overflow. | 219 | // Here we do this operation as int64 to avoid overflow. |
| 216 | int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) { | 220 | static int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) { |
| 217 | int64_t __sum = __fractional + __exponent; | 221 | int64_t __sum = __fractional + __exponent; |
| 218 | 222 | ||
| 219 | if (__sum > __max_biased_exponent) | 223 | if (__sum > __max_biased_exponent) |
lib/libcxx/src/include/overridable_function.h+8-10| ... | @@ -29,12 +29,12 @@ | ... | @@ -29,12 +29,12 @@ |
| 29 | // This is a low-level utility which does not work on all platforms, since it needs | 29 | // This is a low-level utility which does not work on all platforms, since it needs |
| 30 | // to make assumptions about the object file format in use. Furthermore, it requires | 30 | // to make assumptions about the object file format in use. Furthermore, it requires |
| 31 | // the "base definition" of the function (the one we want to check whether it has been | 31 | // the "base definition" of the function (the one we want to check whether it has been |
| 32 | // overridden) to be defined using the _LIBCPP_OVERRIDABLE_FUNCTION macro. | 32 | // overridden) to be defined using the OVERRIDABLE_FUNCTION macro. |
| 33 | // | 33 | // |
| 34 | // This currently works with Mach-O files (used on Darwin) and with ELF files (used on Linux | 34 | // This currently works with Mach-O files (used on Darwin) and with ELF files (used on Linux |
| 35 | // and others). On platforms where we know how to implement this detection, the macro | 35 | // and others). On platforms where we know how to implement this detection, the macro |
| 36 | // _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION is defined to 1, and it is defined to 0 on | 36 | // _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION is defined to 1, and it is defined to 0 on |
| 37 | // other platforms. The _LIBCPP_OVERRIDABLE_FUNCTION macro is defined to perform a normal | 37 | // other platforms. The OVERRIDABLE_FUNCTION macro is defined to perform a normal |
| 38 | // function definition on unsupported platforms so that it can be used to define functions | 38 | // function definition on unsupported platforms so that it can be used to define functions |
| 39 | // regardless of whether detection is actually supported. | 39 | // regardless of whether detection is actually supported. |
| 40 | // | 40 | // |
| ... | @@ -44,7 +44,7 @@ | ... | @@ -44,7 +44,7 @@ |
| 44 | // Let's say we want to check whether a weak function `f` has been overridden by the user. | 44 | // Let's say we want to check whether a weak function `f` has been overridden by the user. |
| 45 | // The general mechanism works by placing `f`'s definition (in the libc++ built library) | 45 | // The general mechanism works by placing `f`'s definition (in the libc++ built library) |
| 46 | // inside a special section, which we do using the `__section__` attribute via the | 46 | // inside a special section, which we do using the `__section__` attribute via the |
| 47 | // _LIBCPP_OVERRIDABLE_FUNCTION macro. | 47 | // OVERRIDABLE_FUNCTION macro. |
| 48 | // | 48 | // |
| 49 | // Then, when comes the time to check whether the function has been overridden, we take | 49 | // Then, when comes the time to check whether the function has been overridden, we take |
| 50 | // the address of the function and we check whether it falls inside the special function | 50 | // the address of the function and we check whether it falls inside the special function |
| ... | @@ -66,11 +66,10 @@ | ... | @@ -66,11 +66,10 @@ |
| 66 | #if defined(_LIBCPP_OBJECT_FORMAT_MACHO) | 66 | #if defined(_LIBCPP_OBJECT_FORMAT_MACHO) |
| 67 | 67 | ||
| 68 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 | 68 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 |
| 69 | # define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) \ | 69 | # define OVERRIDABLE_FUNCTION \ |
| 70 | __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions"))) _LIBCPP_WEAK type name arglist | 70 | __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions"))) _LIBCPP_WEAK |
| 71 | 71 | ||
| 72 | _LIBCPP_BEGIN_NAMESPACE_STD | 72 | _LIBCPP_BEGIN_NAMESPACE_STD template <typename T, T* _Func> |
| 73 | template <typename T, T* _Func> | ||
| 74 | _LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept { | 73 | _LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept { |
| 75 | // Declare two dummy bytes and give them these special `__asm` values. These values are | 74 | // Declare two dummy bytes and give them these special `__asm` values. These values are |
| 76 | // defined by the linker, which means that referring to `&__lcxx_override_start` will | 75 | // defined by the linker, which means that referring to `&__lcxx_override_start` will |
| ... | @@ -100,8 +99,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -100,8 +99,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 100 | #elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__) | 99 | #elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__) |
| 101 | 100 | ||
| 102 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 | 101 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 |
| 103 | # define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) \ | 102 | # define OVERRIDABLE_FUNCTION __attribute__((__section__("__lcxx_override"))) _LIBCPP_WEAK |
| 104 | __attribute__((__section__("__lcxx_override"))) _LIBCPP_WEAK type name arglist | ||
| 105 | 103 | ||
| 106 | // This is very similar to what we do for Mach-O above. The ELF linker will implicitly define | 104 | // This is very similar to what we do for Mach-O above. The ELF linker will implicitly define |
| 107 | // variables with those names corresponding to the start and the end of the section. | 105 | // variables with those names corresponding to the start and the end of the section. |
| ... | @@ -129,7 +127,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -129,7 +127,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 129 | #else | 127 | #else |
| 130 | 128 | ||
| 131 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 0 | 129 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 0 |
| 132 | # define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) _LIBCPP_WEAK type name arglist | 130 | # define OVERRIDABLE_FUNCTION _LIBCPP_WEAK |
| 133 | 131 | ||
| 134 | #endif | 132 | #endif |
| 135 | 133 |
lib/libcxx/src/iostream.cpp+56-37| ... | @@ -16,24 +16,40 @@ | ... | @@ -16,24 +16,40 @@ |
| 16 | 16 | ||
| 17 | _LIBCPP_BEGIN_NAMESPACE_STD | 17 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 18 | 18 | ||
| 19 | // This file implements the various stream objects provided inside <iostream>. We're doing some ODR violations in here, | ||
| 20 | // so this quite fragile. Specifically, the size of the stream objects (i.e. cout, cin etc.) needs to stay the same. | ||
| 21 | // For that reason, we have `stream` and `stream_data` separated into two objects. The public `stream` objects only | ||
| 22 | // contain the actual stream, while the private `stream_data` objects contains the `basic_streambuf` we're using as well | ||
| 23 | // as the mbstate_t. `stream_data` objects are only accessible within the library, so they aren't ABI sensitive and we | ||
| 24 | // can change them as we want. | ||
| 25 | |||
| 26 | template <class StreamT> | ||
| 27 | union stream { | ||
| 28 | constexpr stream() {} | ||
| 29 | stream(const stream&) = delete; | ||
| 30 | stream& operator=(const stream&) = delete; | ||
| 31 | constexpr ~stream() {} | ||
| 32 | |||
| 33 | StreamT value; | ||
| 34 | }; | ||
| 35 | |||
| 19 | template <class StreamT, class BufferT> | 36 | template <class StreamT, class BufferT> |
| 20 | union stream_data { | 37 | union stream_data { |
| 21 | constexpr stream_data() {} | 38 | constexpr stream_data() {} |
| 22 | constexpr ~stream_data() {} | 39 | constexpr ~stream_data() {} |
| 23 | struct { | 40 | struct { |
| 24 | // The stream has to be the first element, since that's referenced by the stream declarations in <iostream> | ||
| 25 | StreamT stream; | ||
| 26 | BufferT buffer; | 41 | BufferT buffer; |
| 27 | mbstate_t mb; | 42 | mbstate_t mb; |
| 28 | }; | 43 | }; |
| 29 | |||
| 30 | void init(FILE* stdstream) { | ||
| 31 | mb = {}; | ||
| 32 | std::construct_at(&buffer, stdstream, &mb); | ||
| 33 | std::construct_at(&stream, &buffer); | ||
| 34 | } | ||
| 35 | }; | 44 | }; |
| 36 | 45 | ||
| 46 | template <class StreamT, class BufferT> | ||
| 47 | void init_stream(FILE* stdstream, stream<StreamT>& stream, stream_data<StreamT, BufferT>& data) { | ||
| 48 | data.mb = {}; | ||
| 49 | std::construct_at(&data.buffer, stdstream, &data.mb); | ||
| 50 | std::construct_at(&stream.value, &data.buffer); | ||
| 51 | } | ||
| 52 | |||
| 37 | #define CHAR_MANGLING_char "D" | 53 | #define CHAR_MANGLING_char "D" |
| 38 | #define CHAR_MANGLING_wchar_t "_W" | 54 | #define CHAR_MANGLING_wchar_t "_W" |
| 39 | #define CHAR_MANGLING(CharT) CHAR_MANGLING_##CharT | 55 | #define CHAR_MANGLING(CharT) CHAR_MANGLING_##CharT |
| ... | @@ -46,25 +62,28 @@ union stream_data { | ... | @@ -46,25 +62,28 @@ union stream_data { |
| 46 | 62 | ||
| 47 | #ifdef _LIBCPP_ABI_MICROSOFT | 63 | #ifdef _LIBCPP_ABI_MICROSOFT |
| 48 | # define STREAM(StreamT, BufferT, CharT, var) \ | 64 | # define STREAM(StreamT, BufferT, CharT, var) \ |
| 49 | STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var __asm__( \ | 65 | STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var##_data; \ |
| 66 | _LIBCPP_EXPORTED_FROM_ABI STRING_DATA_CONSTINIT stream<StreamT<CharT>> var __asm__( \ | ||
| 50 | "?" #var "@" ABI_NAMESPACE_STR "@std@@3V?$" #StreamT \ | 67 | "?" #var "@" ABI_NAMESPACE_STR "@std@@3V?$" #StreamT \ |
| 51 | "@" CHAR_MANGLING(CharT) "U?$char_traits@" CHAR_MANGLING(CharT) "@" ABI_NAMESPACE_STR "@std@@@12@A") | 68 | "@" CHAR_MANGLING(CharT) "U?$char_traits@" CHAR_MANGLING(CharT) "@" ABI_NAMESPACE_STR "@std@@@12@A") |
| 52 | #else | 69 | #else |
| 53 | # define STREAM(StreamT, BufferT, CharT, var) STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var | 70 | # define STREAM(StreamT, BufferT, CharT, var) \ |
| 71 | STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var##_data; \ | ||
| 72 | _LIBCPP_EXPORTED_FROM_ABI STRING_DATA_CONSTINIT stream<StreamT<CharT>> var | ||
| 54 | #endif | 73 | #endif |
| 55 | 74 | ||
| 56 | // These definitions and the declarations in <iostream> technically cause ODR violations, since they have different | 75 | // These definitions and the declarations in <iostream> technically cause ODR violations, since they have different |
| 57 | // types (stream_data and {i,o}stream respectively). This means that <iostream> should never be included in this TU. | 76 | // types (stream_data and {i,o}stream respectively). This means that <iostream> should never be included in this TU. |
| 58 | 77 | ||
| 59 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, char, cin); | 78 | STREAM(basic_istream, __stdinbuf, char, cin); |
| 60 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cout); | 79 | STREAM(basic_ostream, __stdoutbuf, char, cout); |
| 61 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cerr); | 80 | STREAM(basic_ostream, __stdoutbuf, char, cerr); |
| 62 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, clog); | 81 | STREAM(basic_ostream, __stdoutbuf, char, clog); |
| 63 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 82 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 64 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, wchar_t, wcin); | 83 | STREAM(basic_istream, __stdinbuf, wchar_t, wcin); |
| 65 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcout); | 84 | STREAM(basic_ostream, __stdoutbuf, wchar_t, wcout); |
| 66 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcerr); | 85 | STREAM(basic_ostream, __stdoutbuf, wchar_t, wcerr); |
| 67 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wclog); | 86 | STREAM(basic_ostream, __stdoutbuf, wchar_t, wclog); |
| 68 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 87 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 69 | 88 | ||
| 70 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority | 89 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority |
| ... | @@ -98,34 +117,34 @@ public: | ... | @@ -98,34 +117,34 @@ public: |
| 98 | DoIOSInit::DoIOSInit() { | 117 | DoIOSInit::DoIOSInit() { |
| 99 | force_locale_initialization(); | 118 | force_locale_initialization(); |
| 100 | 119 | ||
| 101 | cin.init(stdin); | 120 | init_stream(stdin, cin, cin_data); |
| 102 | cout.init(stdout); | 121 | init_stream(stdout, cout, cout_data); |
| 103 | cerr.init(stderr); | 122 | init_stream(stderr, cerr, cerr_data); |
| 104 | clog.init(stderr); | 123 | init_stream(stderr, clog, clog_data); |
| 105 | 124 | ||
| 106 | cin.stream.tie(&cout.stream); | 125 | cin.value.tie(&cout.value); |
| 107 | std::unitbuf(cerr.stream); | 126 | std::unitbuf(cerr.value); |
| 108 | cerr.stream.tie(&cout.stream); | 127 | cerr.value.tie(&cout.value); |
| 109 | 128 | ||
| 110 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 129 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 111 | wcin.init(stdin); | 130 | init_stream(stdin, wcin, wcin_data); |
| 112 | wcout.init(stdout); | 131 | init_stream(stdout, wcout, wcout_data); |
| 113 | wcerr.init(stderr); | 132 | init_stream(stderr, wcerr, wcerr_data); |
| 114 | wclog.init(stderr); | 133 | init_stream(stderr, wclog, wclog_data); |
| 115 | 134 | ||
| 116 | wcin.stream.tie(&wcout.stream); | 135 | wcin.value.tie(&wcout.value); |
| 117 | std::unitbuf(wcerr.stream); | 136 | std::unitbuf(wcerr.value); |
| 118 | wcerr.stream.tie(&wcout.stream); | 137 | wcerr.value.tie(&wcout.value); |
| 119 | #endif | 138 | #endif |
| 120 | } | 139 | } |
| 121 | 140 | ||
| 122 | DoIOSInit::~DoIOSInit() { | 141 | DoIOSInit::~DoIOSInit() { |
| 123 | cout.stream.flush(); | 142 | cout.value.flush(); |
| 124 | clog.stream.flush(); | 143 | clog.value.flush(); |
| 125 | 144 | ||
| 126 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 145 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 127 | wcout.stream.flush(); | 146 | wcout.value.flush(); |
| 128 | wclog.stream.flush(); | 147 | wclog.value.flush(); |
| 129 | #endif | 148 | #endif |
| 130 | } | 149 | } |
| 131 | 150 |
lib/libcxx/src/locale.cpp+213-196| ... | @@ -60,9 +60,8 @@ struct __libcpp_unique_locale { | ... | @@ -60,9 +60,8 @@ struct __libcpp_unique_locale { |
| 60 | 60 | ||
| 61 | __locale::__locale_t __loc_; | 61 | __locale::__locale_t __loc_; |
| 62 | 62 | ||
| 63 | private: | 63 | __libcpp_unique_locale(__libcpp_unique_locale const&) = delete; |
| 64 | __libcpp_unique_locale(__libcpp_unique_locale const&); | 64 | __libcpp_unique_locale& operator=(__libcpp_unique_locale const&) = delete; |
| 65 | __libcpp_unique_locale& operator=(__libcpp_unique_locale const&); | ||
| 66 | }; | 65 | }; |
| 67 | 66 | ||
| 68 | #ifdef __cloc_defined | 67 | #ifdef __cloc_defined |
| ... | @@ -88,16 +87,6 @@ T& make(Args... args) { | ... | @@ -88,16 +87,6 @@ T& make(Args... args) { |
| 88 | return *obj; | 87 | return *obj; |
| 89 | } | 88 | } |
| 90 | 89 | ||
| 91 | template <typename T, size_t N> | ||
| 92 | inline constexpr size_t countof(const T (&)[N]) { | ||
| 93 | return N; | ||
| 94 | } | ||
| 95 | |||
| 96 | template <typename T> | ||
| 97 | inline constexpr size_t countof(const T* const begin, const T* const end) { | ||
| 98 | return static_cast<size_t>(end - begin); | ||
| 99 | } | ||
| 100 | |||
| 101 | string build_name(const string& other, const string& one, locale::category c) { | 90 | string build_name(const string& other, const string& one, locale::category c) { |
| 102 | if (other == "*" || one == "*") | 91 | if (other == "*" || one == "*") |
| 103 | return "*"; | 92 | return "*"; |
| ... | @@ -215,63 +204,58 @@ locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") { | ... | @@ -215,63 +204,58 @@ locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") { |
| 215 | } | 204 | } |
| 216 | 205 | ||
| 217 | locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), name_(name) { | 206 | locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), name_(name) { |
| 218 | #if _LIBCPP_HAS_EXCEPTIONS | 207 | __exception_guard guard([&] { |
| 219 | try { | ||
| 220 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 221 | facets_ = locale::classic().__locale_->facets_; | ||
| 222 | for (unsigned i = 0; i < facets_.size(); ++i) | 208 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 223 | if (facets_[i]) | 209 | if (facets_[i]) |
| 224 | facets_[i]->__add_shared(); | 210 | facets_[i]->__release_shared(); |
| 225 | install(new collate_byname<char>(name_)); | 211 | }); |
| 212 | facets_ = locale::classic().__locale_->facets_; | ||
| 213 | for (unsigned i = 0; i < facets_.size(); ++i) | ||
| 214 | if (facets_[i]) | ||
| 215 | facets_[i]->__add_shared(); | ||
| 216 | install(new collate_byname<char>(name_)); | ||
| 226 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 217 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 227 | install(new collate_byname<wchar_t>(name_)); | 218 | install(new collate_byname<wchar_t>(name_)); |
| 228 | #endif | 219 | #endif |
| 229 | install(new ctype_byname<char>(name_)); | 220 | install(new ctype_byname<char>(name_)); |
| 230 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 221 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 231 | install(new ctype_byname<wchar_t>(name_)); | 222 | install(new ctype_byname<wchar_t>(name_)); |
| 232 | #endif | 223 | #endif |
| 233 | install(new codecvt_byname<char, char, mbstate_t>(name_)); | 224 | install(new codecvt_byname<char, char, mbstate_t>(name_)); |
| 234 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 225 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 235 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name_)); | 226 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name_)); |
| 236 | #endif | 227 | #endif |
| 237 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 228 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 238 | install(new codecvt_byname<char16_t, char, mbstate_t>(name_)); | 229 | install(new codecvt_byname<char16_t, char, mbstate_t>(name_)); |
| 239 | install(new codecvt_byname<char32_t, char, mbstate_t>(name_)); | 230 | install(new codecvt_byname<char32_t, char, mbstate_t>(name_)); |
| 240 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 231 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 241 | #if _LIBCPP_HAS_CHAR8_T | 232 | #if _LIBCPP_HAS_CHAR8_T |
| 242 | install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_)); | 233 | install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_)); |
| 243 | install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_)); | 234 | install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_)); |
| 244 | #endif | 235 | #endif |
| 245 | install(new numpunct_byname<char>(name_)); | 236 | install(new numpunct_byname<char>(name_)); |
| 246 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 237 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 247 | install(new numpunct_byname<wchar_t>(name_)); | 238 | install(new numpunct_byname<wchar_t>(name_)); |
| 248 | #endif | 239 | #endif |
| 249 | install(new moneypunct_byname<char, false>(name_)); | 240 | install(new moneypunct_byname<char, false>(name_)); |
| 250 | install(new moneypunct_byname<char, true>(name_)); | 241 | install(new moneypunct_byname<char, true>(name_)); |
| 251 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 242 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 252 | install(new moneypunct_byname<wchar_t, false>(name_)); | 243 | install(new moneypunct_byname<wchar_t, false>(name_)); |
| 253 | install(new moneypunct_byname<wchar_t, true>(name_)); | 244 | install(new moneypunct_byname<wchar_t, true>(name_)); |
| 254 | #endif | 245 | #endif |
| 255 | install(new time_get_byname<char>(name_)); | 246 | install(new time_get_byname<char>(name_)); |
| 256 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 247 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 257 | install(new time_get_byname<wchar_t>(name_)); | 248 | install(new time_get_byname<wchar_t>(name_)); |
| 258 | #endif | 249 | #endif |
| 259 | install(new time_put_byname<char>(name_)); | 250 | install(new time_put_byname<char>(name_)); |
| 260 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 251 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 261 | install(new time_put_byname<wchar_t>(name_)); | 252 | install(new time_put_byname<wchar_t>(name_)); |
| 262 | #endif | 253 | #endif |
| 263 | install(new messages_byname<char>(name_)); | 254 | install(new messages_byname<char>(name_)); |
| 264 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 255 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 265 | install(new messages_byname<wchar_t>(name_)); | 256 | install(new messages_byname<wchar_t>(name_)); |
| 266 | #endif | 257 | #endif |
| 267 | #if _LIBCPP_HAS_EXCEPTIONS | 258 | guard.__complete(); |
| 268 | } catch (...) { | ||
| 269 | for (unsigned i = 0; i < facets_.size(); ++i) | ||
| 270 | if (facets_[i]) | ||
| 271 | facets_[i]->__release_shared(); | ||
| 272 | throw; | ||
| 273 | } | ||
| 274 | #endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 275 | } | 259 | } |
| 276 | 260 | ||
| 277 | locale::__imp::__imp(const __imp& other) : facets_(max<size_t>(N, other.facets_.size())), name_(other.name_) { | 261 | locale::__imp::__imp(const __imp& other) : facets_(max<size_t>(N, other.facets_.size())), name_(other.name_) { |
| ... | @@ -287,71 +271,66 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) | ... | @@ -287,71 +271,66 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) |
| 287 | for (unsigned i = 0; i < facets_.size(); ++i) | 271 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 288 | if (facets_[i]) | 272 | if (facets_[i]) |
| 289 | facets_[i]->__add_shared(); | 273 | facets_[i]->__add_shared(); |
| 290 | #if _LIBCPP_HAS_EXCEPTIONS | 274 | __exception_guard guard([&] { |
| 291 | try { | 275 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 292 | #endif // _LIBCPP_HAS_EXCEPTIONS | 276 | if (facets_[i]) |
| 293 | if (c & locale::collate) { | 277 | facets_[i]->__release_shared(); |
| 294 | install(new collate_byname<char>(name)); | 278 | }); |
| 279 | if (c & locale::collate) { | ||
| 280 | install(new collate_byname<char>(name)); | ||
| 295 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 281 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 296 | install(new collate_byname<wchar_t>(name)); | 282 | install(new collate_byname<wchar_t>(name)); |
| 297 | #endif | 283 | #endif |
| 298 | } | 284 | } |
| 299 | if (c & locale::ctype) { | 285 | if (c & locale::ctype) { |
| 300 | install(new ctype_byname<char>(name)); | 286 | install(new ctype_byname<char>(name)); |
| 301 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 287 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 302 | install(new ctype_byname<wchar_t>(name)); | 288 | install(new ctype_byname<wchar_t>(name)); |
| 303 | #endif | 289 | #endif |
| 304 | install(new codecvt_byname<char, char, mbstate_t>(name)); | 290 | install(new codecvt_byname<char, char, mbstate_t>(name)); |
| 305 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 291 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 306 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name)); | 292 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name)); |
| 307 | #endif | 293 | #endif |
| 308 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 294 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 309 | install(new codecvt_byname<char16_t, char, mbstate_t>(name)); | 295 | install(new codecvt_byname<char16_t, char, mbstate_t>(name)); |
| 310 | install(new codecvt_byname<char32_t, char, mbstate_t>(name)); | 296 | install(new codecvt_byname<char32_t, char, mbstate_t>(name)); |
| 311 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 297 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 312 | #if _LIBCPP_HAS_CHAR8_T | 298 | #if _LIBCPP_HAS_CHAR8_T |
| 313 | install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name)); | 299 | install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name)); |
| 314 | install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name)); | 300 | install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name)); |
| 315 | #endif | 301 | #endif |
| 316 | } | 302 | } |
| 317 | if (c & locale::monetary) { | 303 | if (c & locale::monetary) { |
| 318 | install(new moneypunct_byname<char, false>(name)); | 304 | install(new moneypunct_byname<char, false>(name)); |
| 319 | install(new moneypunct_byname<char, true>(name)); | 305 | install(new moneypunct_byname<char, true>(name)); |
| 320 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 306 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 321 | install(new moneypunct_byname<wchar_t, false>(name)); | 307 | install(new moneypunct_byname<wchar_t, false>(name)); |
| 322 | install(new moneypunct_byname<wchar_t, true>(name)); | 308 | install(new moneypunct_byname<wchar_t, true>(name)); |
| 323 | #endif | 309 | #endif |
| 324 | } | 310 | } |
| 325 | if (c & locale::numeric) { | 311 | if (c & locale::numeric) { |
| 326 | install(new numpunct_byname<char>(name)); | 312 | install(new numpunct_byname<char>(name)); |
| 327 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 313 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 328 | install(new numpunct_byname<wchar_t>(name)); | 314 | install(new numpunct_byname<wchar_t>(name)); |
| 329 | #endif | 315 | #endif |
| 330 | } | 316 | } |
| 331 | if (c & locale::time) { | 317 | if (c & locale::time) { |
| 332 | install(new time_get_byname<char>(name)); | 318 | install(new time_get_byname<char>(name)); |
| 333 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 319 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 334 | install(new time_get_byname<wchar_t>(name)); | 320 | install(new time_get_byname<wchar_t>(name)); |
| 335 | #endif | 321 | #endif |
| 336 | install(new time_put_byname<char>(name)); | 322 | install(new time_put_byname<char>(name)); |
| 337 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 323 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 338 | install(new time_put_byname<wchar_t>(name)); | 324 | install(new time_put_byname<wchar_t>(name)); |
| 339 | #endif | 325 | #endif |
| 340 | } | 326 | } |
| 341 | if (c & locale::messages) { | 327 | if (c & locale::messages) { |
| 342 | install(new messages_byname<char>(name)); | 328 | install(new messages_byname<char>(name)); |
| 343 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 329 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 344 | install(new messages_byname<wchar_t>(name)); | 330 | install(new messages_byname<wchar_t>(name)); |
| 345 | #endif | 331 | #endif |
| 346 | } | ||
| 347 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 348 | } catch (...) { | ||
| 349 | for (unsigned i = 0; i < facets_.size(); ++i) | ||
| 350 | if (facets_[i]) | ||
| 351 | facets_[i]->__release_shared(); | ||
| 352 | throw; | ||
| 353 | } | 332 | } |
| 354 | #endif // _LIBCPP_HAS_EXCEPTIONS | 333 | guard.__complete(); |
| 355 | } | 334 | } |
| 356 | 335 | ||
| 357 | template <class F> | 336 | template <class F> |
| ... | @@ -366,87 +345,83 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) | ... | @@ -366,87 +345,83 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) |
| 366 | for (unsigned i = 0; i < facets_.size(); ++i) | 345 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 367 | if (facets_[i]) | 346 | if (facets_[i]) |
| 368 | facets_[i]->__add_shared(); | 347 | facets_[i]->__add_shared(); |
| 369 | #if _LIBCPP_HAS_EXCEPTIONS | 348 | __exception_guard guard([&] { |
| 370 | try { | 349 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 371 | #endif // _LIBCPP_HAS_EXCEPTIONS | 350 | if (facets_[i]) |
| 372 | if (c & locale::collate) { | 351 | facets_[i]->__release_shared(); |
| 373 | install_from<std::collate<char> >(one); | 352 | }); |
| 353 | |||
| 354 | if (c & locale::collate) { | ||
| 355 | install_from<std::collate<char> >(one); | ||
| 374 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 356 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 375 | install_from<std::collate<wchar_t> >(one); | 357 | install_from<std::collate<wchar_t> >(one); |
| 376 | #endif | 358 | #endif |
| 377 | } | 359 | } |
| 378 | if (c & locale::ctype) { | 360 | if (c & locale::ctype) { |
| 379 | install_from<std::ctype<char> >(one); | 361 | install_from<std::ctype<char> >(one); |
| 380 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 362 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 381 | install_from<std::ctype<wchar_t> >(one); | 363 | install_from<std::ctype<wchar_t> >(one); |
| 382 | #endif | 364 | #endif |
| 383 | install_from<std::codecvt<char, char, mbstate_t> >(one); | 365 | install_from<std::codecvt<char, char, mbstate_t> >(one); |
| 384 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 366 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 385 | install_from<std::codecvt<char16_t, char, mbstate_t> >(one); | 367 | install_from<std::codecvt<char16_t, char, mbstate_t> >(one); |
| 386 | install_from<std::codecvt<char32_t, char, mbstate_t> >(one); | 368 | install_from<std::codecvt<char32_t, char, mbstate_t> >(one); |
| 387 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 369 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 388 | #if _LIBCPP_HAS_CHAR8_T | 370 | #if _LIBCPP_HAS_CHAR8_T |
| 389 | install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one); | 371 | install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one); |
| 390 | install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one); | 372 | install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one); |
| 391 | #endif | 373 | #endif |
| 392 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 374 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 393 | install_from<std::codecvt<wchar_t, char, mbstate_t> >(one); | 375 | install_from<std::codecvt<wchar_t, char, mbstate_t> >(one); |
| 394 | #endif | 376 | #endif |
| 395 | } | 377 | } |
| 396 | if (c & locale::monetary) { | 378 | if (c & locale::monetary) { |
| 397 | install_from<moneypunct<char, false> >(one); | 379 | install_from<moneypunct<char, false> >(one); |
| 398 | install_from<moneypunct<char, true> >(one); | 380 | install_from<moneypunct<char, true> >(one); |
| 399 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 381 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 400 | install_from<moneypunct<wchar_t, false> >(one); | 382 | install_from<moneypunct<wchar_t, false> >(one); |
| 401 | install_from<moneypunct<wchar_t, true> >(one); | 383 | install_from<moneypunct<wchar_t, true> >(one); |
| 402 | #endif | 384 | #endif |
| 403 | install_from<money_get<char> >(one); | 385 | install_from<money_get<char> >(one); |
| 404 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 386 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 405 | install_from<money_get<wchar_t> >(one); | 387 | install_from<money_get<wchar_t> >(one); |
| 406 | #endif | 388 | #endif |
| 407 | install_from<money_put<char> >(one); | 389 | install_from<money_put<char> >(one); |
| 408 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 390 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 409 | install_from<money_put<wchar_t> >(one); | 391 | install_from<money_put<wchar_t> >(one); |
| 410 | #endif | 392 | #endif |
| 411 | } | 393 | } |
| 412 | if (c & locale::numeric) { | 394 | if (c & locale::numeric) { |
| 413 | install_from<numpunct<char> >(one); | 395 | install_from<numpunct<char> >(one); |
| 414 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 396 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 415 | install_from<numpunct<wchar_t> >(one); | 397 | install_from<numpunct<wchar_t> >(one); |
| 416 | #endif | 398 | #endif |
| 417 | install_from<num_get<char> >(one); | 399 | install_from<num_get<char> >(one); |
| 418 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 400 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 419 | install_from<num_get<wchar_t> >(one); | 401 | install_from<num_get<wchar_t> >(one); |
| 420 | #endif | 402 | #endif |
| 421 | install_from<num_put<char> >(one); | 403 | install_from<num_put<char> >(one); |
| 422 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 404 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 423 | install_from<num_put<wchar_t> >(one); | 405 | install_from<num_put<wchar_t> >(one); |
| 424 | #endif | 406 | #endif |
| 425 | } | 407 | } |
| 426 | if (c & locale::time) { | 408 | if (c & locale::time) { |
| 427 | install_from<time_get<char> >(one); | 409 | install_from<time_get<char> >(one); |
| 428 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 410 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 429 | install_from<time_get<wchar_t> >(one); | 411 | install_from<time_get<wchar_t> >(one); |
| 430 | #endif | 412 | #endif |
| 431 | install_from<time_put<char> >(one); | 413 | install_from<time_put<char> >(one); |
| 432 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 414 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 433 | install_from<time_put<wchar_t> >(one); | 415 | install_from<time_put<wchar_t> >(one); |
| 434 | #endif | 416 | #endif |
| 435 | } | 417 | } |
| 436 | if (c & locale::messages) { | 418 | if (c & locale::messages) { |
| 437 | install_from<std::messages<char> >(one); | 419 | install_from<std::messages<char> >(one); |
| 438 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 420 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 439 | install_from<std::messages<wchar_t> >(one); | 421 | install_from<std::messages<wchar_t> >(one); |
| 440 | #endif | 422 | #endif |
| 441 | } | ||
| 442 | #if _LIBCPP_HAS_EXCEPTIONS | ||
| 443 | } catch (...) { | ||
| 444 | for (unsigned i = 0; i < facets_.size(); ++i) | ||
| 445 | if (facets_[i]) | ||
| 446 | facets_[i]->__release_shared(); | ||
| 447 | throw; | ||
| 448 | } | 423 | } |
| 449 | #endif // _LIBCPP_HAS_EXCEPTIONS | 424 | guard.__complete(); |
| 450 | } | 425 | } |
| 451 | 426 | ||
| 452 | locale::__imp::__imp(const __imp& other, facet* f, long id) | 427 | locale::__imp::__imp(const __imp& other, facet* f, long id) |
| ... | @@ -933,7 +908,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept { | ... | @@ -933,7 +908,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept { |
| 933 | return __pctype_func(); | 908 | return __pctype_func(); |
| 934 | # elif defined(__EMSCRIPTEN__) | 909 | # elif defined(__EMSCRIPTEN__) |
| 935 | return *__ctype_b_loc(); | 910 | return *__ctype_b_loc(); |
| 936 | # elif defined(_NEWLIB_VERSION) | 911 | # elif _LIBCPP_LIBC_NEWLIB |
| 937 | // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1]. | 912 | // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1]. |
| 938 | return _ctype_ + 1; | 913 | return _ctype_ + 1; |
| 939 | # elif defined(_AIX) | 914 | # elif defined(_AIX) |
| ... | @@ -3961,13 +3936,7 @@ wstring numpunct<wchar_t>::do_falsename() const { return L"false"; } | ... | @@ -3961,13 +3936,7 @@ wstring numpunct<wchar_t>::do_falsename() const { return L"false"; } |
| 3961 | 3936 | ||
| 3962 | // numpunct_byname<char> | 3937 | // numpunct_byname<char> |
| 3963 | 3938 | ||
| 3964 | numpunct_byname<char>::numpunct_byname(const char* nm, size_t refs) : numpunct<char>(refs) { __init(nm); } | 3939 | numpunct_byname<char>::numpunct_byname(const char* nm, size_t refs) : numpunct<char>(refs) { |
| 3965 | |||
| 3966 | numpunct_byname<char>::numpunct_byname(const string& nm, size_t refs) : numpunct<char>(refs) { __init(nm.c_str()); } | ||
| 3967 | |||
| 3968 | numpunct_byname<char>::~numpunct_byname() {} | ||
| 3969 | |||
| 3970 | void numpunct_byname<char>::__init(const char* nm) { | ||
| 3971 | typedef numpunct<char> base; | 3940 | typedef numpunct<char> base; |
| 3972 | if (strcmp(nm, "C") != 0) { | 3941 | if (strcmp(nm, "C") != 0) { |
| 3973 | __libcpp_unique_locale loc(nm); | 3942 | __libcpp_unique_locale loc(nm); |
| ... | @@ -3988,18 +3957,14 @@ void numpunct_byname<char>::__init(const char* nm) { | ... | @@ -3988,18 +3957,14 @@ void numpunct_byname<char>::__init(const char* nm) { |
| 3988 | } | 3957 | } |
| 3989 | } | 3958 | } |
| 3990 | 3959 | ||
| 3991 | // numpunct_byname<wchar_t> | 3960 | numpunct_byname<char>::numpunct_byname(const string& nm, size_t refs) : numpunct_byname<char>(nm.c_str(), refs) {} |
| 3992 | |||
| 3993 | #if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 3994 | numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs) : numpunct<wchar_t>(refs) { __init(nm); } | ||
| 3995 | 3961 | ||
| 3996 | numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs) : numpunct<wchar_t>(refs) { | 3962 | numpunct_byname<char>::~numpunct_byname() {} |
| 3997 | __init(nm.c_str()); | ||
| 3998 | } | ||
| 3999 | 3963 | ||
| 4000 | numpunct_byname<wchar_t>::~numpunct_byname() {} | 3964 | // numpunct_byname<wchar_t> |
| 4001 | 3965 | ||
| 4002 | void numpunct_byname<wchar_t>::__init(const char* nm) { | 3966 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 3967 | numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs) : numpunct<wchar_t>(refs) { | ||
| 4003 | if (strcmp(nm, "C") != 0) { | 3968 | if (strcmp(nm, "C") != 0) { |
| 4004 | __libcpp_unique_locale loc(nm); | 3969 | __libcpp_unique_locale loc(nm); |
| 4005 | if (!loc) | 3970 | if (!loc) |
| ... | @@ -4016,6 +3981,10 @@ void numpunct_byname<wchar_t>::__init(const char* nm) { | ... | @@ -4016,6 +3981,10 @@ void numpunct_byname<wchar_t>::__init(const char* nm) { |
| 4016 | // localization for truename and falsename is not available | 3981 | // localization for truename and falsename is not available |
| 4017 | } | 3982 | } |
| 4018 | } | 3983 | } |
| 3984 | |||
| 3985 | numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs) : numpunct_byname<wchar_t>(nm.c_str(), refs) {} | ||
| 3986 | |||
| 3987 | numpunct_byname<wchar_t>::~numpunct_byname() {} | ||
| 4019 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 3988 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 4020 | 3989 | ||
| 4021 | // num_get helpers | 3990 | // num_get helpers |
| ... | @@ -4383,7 +4352,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) { | ... | @@ -4383,7 +4352,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) { |
| 4383 | char f[3] = {0}; | 4352 | char f[3] = {0}; |
| 4384 | f[0] = '%'; | 4353 | f[0] = '%'; |
| 4385 | f[1] = fmt; | 4354 | f[1] = fmt; |
| 4386 | size_t n = __locale::__strftime(buf, countof(buf), f, &t, __loc_); | 4355 | size_t n = __locale::__strftime(buf, std::size(buf), f, &t, __loc_); |
| 4387 | char* bb = buf; | 4356 | char* bb = buf; |
| 4388 | char* be = buf + n; | 4357 | char* be = buf + n; |
| 4389 | string result; | 4358 | string result; |
| ... | @@ -4514,12 +4483,12 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c | ... | @@ -4514,12 +4483,12 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c |
| 4514 | char f[3] = {0}; | 4483 | char f[3] = {0}; |
| 4515 | f[0] = '%'; | 4484 | f[0] = '%'; |
| 4516 | f[1] = fmt; | 4485 | f[1] = fmt; |
| 4517 | __locale::__strftime(buf, countof(buf), f, &t, __loc_); | 4486 | __locale::__strftime(buf, std::size(buf), f, &t, __loc_); |
| 4518 | wchar_t wbuf[100]; | 4487 | wchar_t wbuf[100]; |
| 4519 | wchar_t* wbb = wbuf; | 4488 | wchar_t* wbb = wbuf; |
| 4520 | mbstate_t mb = {0}; | 4489 | mbstate_t mb = {0}; |
| 4521 | const char* bb = buf; | 4490 | const char* bb = buf; |
| 4522 | size_t j = __locale::__mbsrtowcs(wbb, &bb, countof(wbuf), &mb, __loc_); | 4491 | size_t j = __locale::__mbsrtowcs(wbb, &bb, std::size(wbuf), &mb, __loc_); |
| 4523 | if (j == size_t(-1)) | 4492 | if (j == size_t(-1)) |
| 4524 | std::__throw_runtime_error("locale not supported"); | 4493 | std::__throw_runtime_error("locale not supported"); |
| 4525 | wchar_t* wbe = wbb + j; | 4494 | wchar_t* wbe = wbb + j; |
| ... | @@ -4640,25 +4609,25 @@ void __time_get_storage<char>::init(const ctype<char>& ct) { | ... | @@ -4640,25 +4609,25 @@ void __time_get_storage<char>::init(const ctype<char>& ct) { |
| 4640 | // __weeks_ | 4609 | // __weeks_ |
| 4641 | for (int i = 0; i < 7; ++i) { | 4610 | for (int i = 0; i < 7; ++i) { |
| 4642 | t.tm_wday = i; | 4611 | t.tm_wday = i; |
| 4643 | __locale::__strftime(buf, countof(buf), "%A", &t, __loc_); | 4612 | __locale::__strftime(buf, std::size(buf), "%A", &t, __loc_); |
| 4644 | __weeks_[i] = buf; | 4613 | __weeks_[i] = buf; |
| 4645 | __locale::__strftime(buf, countof(buf), "%a", &t, __loc_); | 4614 | __locale::__strftime(buf, std::size(buf), "%a", &t, __loc_); |
| 4646 | __weeks_[i + 7] = buf; | 4615 | __weeks_[i + 7] = buf; |
| 4647 | } | 4616 | } |
| 4648 | // __months_ | 4617 | // __months_ |
| 4649 | for (int i = 0; i < 12; ++i) { | 4618 | for (int i = 0; i < 12; ++i) { |
| 4650 | t.tm_mon = i; | 4619 | t.tm_mon = i; |
| 4651 | __locale::__strftime(buf, countof(buf), "%B", &t, __loc_); | 4620 | __locale::__strftime(buf, std::size(buf), "%B", &t, __loc_); |
| 4652 | __months_[i] = buf; | 4621 | __months_[i] = buf; |
| 4653 | __locale::__strftime(buf, countof(buf), "%b", &t, __loc_); | 4622 | __locale::__strftime(buf, std::size(buf), "%b", &t, __loc_); |
| 4654 | __months_[i + 12] = buf; | 4623 | __months_[i + 12] = buf; |
| 4655 | } | 4624 | } |
| 4656 | // __am_pm_ | 4625 | // __am_pm_ |
| 4657 | t.tm_hour = 1; | 4626 | t.tm_hour = 1; |
| 4658 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | 4627 | __locale::__strftime(buf, std::size(buf), "%p", &t, __loc_); |
| 4659 | __am_pm_[0] = buf; | 4628 | __am_pm_[0] = buf; |
| 4660 | t.tm_hour = 13; | 4629 | t.tm_hour = 13; |
| 4661 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | 4630 | __locale::__strftime(buf, std::size(buf), "%p", &t, __loc_); |
| 4662 | __am_pm_[1] = buf; | 4631 | __am_pm_[1] = buf; |
| 4663 | __c_ = __analyze('c', ct); | 4632 | __c_ = __analyze('c', ct); |
| 4664 | __r_ = __analyze('r', ct); | 4633 | __r_ = __analyze('r', ct); |
| ... | @@ -4677,18 +4646,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4677,18 +4646,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4677 | // __weeks_ | 4646 | // __weeks_ |
| 4678 | for (int i = 0; i < 7; ++i) { | 4647 | for (int i = 0; i < 7; ++i) { |
| 4679 | t.tm_wday = i; | 4648 | t.tm_wday = i; |
| 4680 | __locale::__strftime(buf, countof(buf), "%A", &t, __loc_); | 4649 | __locale::__strftime(buf, std::size(buf), "%A", &t, __loc_); |
| 4681 | mb = mbstate_t(); | 4650 | mb = mbstate_t(); |
| 4682 | const char* bb = buf; | 4651 | const char* bb = buf; |
| 4683 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4652 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, __loc_); |
| 4684 | if (j == size_t(-1) || j == 0) | 4653 | if (j == size_t(-1) || j == 0) |
| 4685 | std::__throw_runtime_error("locale not supported"); | 4654 | std::__throw_runtime_error("locale not supported"); |
| 4686 | wbe = wbuf + j; | 4655 | wbe = wbuf + j; |
| 4687 | __weeks_[i].assign(wbuf, wbe); | 4656 | __weeks_[i].assign(wbuf, wbe); |
| 4688 | __locale::__strftime(buf, countof(buf), "%a", &t, __loc_); | 4657 | __locale::__strftime(buf, std::size(buf), "%a", &t, __loc_); |
| 4689 | mb = mbstate_t(); | 4658 | mb = mbstate_t(); |
| 4690 | bb = buf; | 4659 | bb = buf; |
| 4691 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4660 | j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, __loc_); |
| 4692 | if (j == size_t(-1) || j == 0) | 4661 | if (j == size_t(-1) || j == 0) |
| 4693 | std::__throw_runtime_error("locale not supported"); | 4662 | std::__throw_runtime_error("locale not supported"); |
| 4694 | wbe = wbuf + j; | 4663 | wbe = wbuf + j; |
| ... | @@ -4697,18 +4666,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4697,18 +4666,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4697 | // __months_ | 4666 | // __months_ |
| 4698 | for (int i = 0; i < 12; ++i) { | 4667 | for (int i = 0; i < 12; ++i) { |
| 4699 | t.tm_mon = i; | 4668 | t.tm_mon = i; |
| 4700 | __locale::__strftime(buf, countof(buf), "%B", &t, __loc_); | 4669 | __locale::__strftime(buf, std::size(buf), "%B", &t, __loc_); |
| 4701 | mb = mbstate_t(); | 4670 | mb = mbstate_t(); |
| 4702 | const char* bb = buf; | 4671 | const char* bb = buf; |
| 4703 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4672 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, __loc_); |
| 4704 | if (j == size_t(-1) || j == 0) | 4673 | if (j == size_t(-1) || j == 0) |
| 4705 | std::__throw_runtime_error("locale not supported"); | 4674 | std::__throw_runtime_error("locale not supported"); |
| 4706 | wbe = wbuf + j; | 4675 | wbe = wbuf + j; |
| 4707 | __months_[i].assign(wbuf, wbe); | 4676 | __months_[i].assign(wbuf, wbe); |
| 4708 | __locale::__strftime(buf, countof(buf), "%b", &t, __loc_); | 4677 | __locale::__strftime(buf, std::size(buf), "%b", &t, __loc_); |
| 4709 | mb = mbstate_t(); | 4678 | mb = mbstate_t(); |
| 4710 | bb = buf; | 4679 | bb = buf; |
| 4711 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4680 | j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, __loc_); |
| 4712 | if (j == size_t(-1) || j == 0) | 4681 | if (j == size_t(-1) || j == 0) |
| 4713 | std::__throw_runtime_error("locale not supported"); | 4682 | std::__throw_runtime_error("locale not supported"); |
| 4714 | wbe = wbuf + j; | 4683 | wbe = wbuf + j; |
| ... | @@ -4716,19 +4685,19 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4716,19 +4685,19 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4716 | } | 4685 | } |
| 4717 | // __am_pm_ | 4686 | // __am_pm_ |
| 4718 | t.tm_hour = 1; | 4687 | t.tm_hour = 1; |
| 4719 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | 4688 | __locale::__strftime(buf, std::size(buf), "%p", &t, __loc_); |
| 4720 | mb = mbstate_t(); | 4689 | mb = mbstate_t(); |
| 4721 | const char* bb = buf; | 4690 | const char* bb = buf; |
| 4722 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4691 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, __loc_); |
| 4723 | if (j == size_t(-1)) | 4692 | if (j == size_t(-1)) |
| 4724 | std::__throw_runtime_error("locale not supported"); | 4693 | std::__throw_runtime_error("locale not supported"); |
| 4725 | wbe = wbuf + j; | 4694 | wbe = wbuf + j; |
| 4726 | __am_pm_[0].assign(wbuf, wbe); | 4695 | __am_pm_[0].assign(wbuf, wbe); |
| 4727 | t.tm_hour = 13; | 4696 | t.tm_hour = 13; |
| 4728 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | 4697 | __locale::__strftime(buf, std::size(buf), "%p", &t, __loc_); |
| 4729 | mb = mbstate_t(); | 4698 | mb = mbstate_t(); |
| 4730 | bb = buf; | 4699 | bb = buf; |
| 4731 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4700 | j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, __loc_); |
| 4732 | if (j == size_t(-1)) | 4701 | if (j == size_t(-1)) |
| 4733 | std::__throw_runtime_error("locale not supported"); | 4702 | std::__throw_runtime_error("locale not supported"); |
| 4734 | wbe = wbuf + j; | 4703 | wbe = wbuf + j; |
| ... | @@ -4957,7 +4926,7 @@ void __time_put::__do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, c | ... | @@ -4957,7 +4926,7 @@ void __time_put::__do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, c |
| 4957 | char fmt[] = {'%', __fmt, __mod, 0}; | 4926 | char fmt[] = {'%', __fmt, __mod, 0}; |
| 4958 | if (__mod != 0) | 4927 | if (__mod != 0) |
| 4959 | swap(fmt[1], fmt[2]); | 4928 | swap(fmt[1], fmt[2]); |
| 4960 | size_t n = __locale::__strftime(__nb, countof(__nb, __ne), fmt, __tm, __loc_); | 4929 | size_t n = __locale::__strftime(__nb, std::distance(__nb, __ne), fmt, __tm, __loc_); |
| 4961 | __ne = __nb + n; | 4930 | __ne = __nb + n; |
| 4962 | } | 4931 | } |
| 4963 | 4932 | ||
| ... | @@ -4968,7 +4937,7 @@ void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __ | ... | @@ -4968,7 +4937,7 @@ void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __ |
| 4968 | __do_put(__nar, __ne, __tm, __fmt, __mod); | 4937 | __do_put(__nar, __ne, __tm, __fmt, __mod); |
| 4969 | mbstate_t mb = {0}; | 4938 | mbstate_t mb = {0}; |
| 4970 | const char* __nb = __nar; | 4939 | const char* __nb = __nar; |
| 4971 | size_t j = __locale::__mbsrtowcs(__wb, &__nb, countof(__wb, __we), &mb, __loc_); | 4940 | size_t j = __locale::__mbsrtowcs(__wb, &__nb, std::distance(__wb, __we), &mb, __loc_); |
| 4972 | if (j == size_t(-1)) | 4941 | if (j == size_t(-1)) |
| 4973 | std::__throw_runtime_error("locale not supported"); | 4942 | std::__throw_runtime_error("locale not supported"); |
| 4974 | __we = __wb + j; | 4943 | __we = __wb + j; |
| ... | @@ -5443,7 +5412,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { | ... | @@ -5443,7 +5412,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5443 | wchar_t wbuf[100]; | 5412 | wchar_t wbuf[100]; |
| 5444 | mbstate_t mb = {0}; | 5413 | mbstate_t mb = {0}; |
| 5445 | const char* bb = lc->currency_symbol; | 5414 | const char* bb = lc->currency_symbol; |
| 5446 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5415 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, loc.get()); |
| 5447 | if (j == size_t(-1)) | 5416 | if (j == size_t(-1)) |
| 5448 | std::__throw_runtime_error("locale not supported"); | 5417 | std::__throw_runtime_error("locale not supported"); |
| 5449 | wchar_t* wbe = wbuf + j; | 5418 | wchar_t* wbe = wbuf + j; |
| ... | @@ -5457,7 +5426,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { | ... | @@ -5457,7 +5426,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5457 | else { | 5426 | else { |
| 5458 | mb = mbstate_t(); | 5427 | mb = mbstate_t(); |
| 5459 | bb = lc->positive_sign; | 5428 | bb = lc->positive_sign; |
| 5460 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5429 | j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, loc.get()); |
| 5461 | if (j == size_t(-1)) | 5430 | if (j == size_t(-1)) |
| 5462 | std::__throw_runtime_error("locale not supported"); | 5431 | std::__throw_runtime_error("locale not supported"); |
| 5463 | wbe = wbuf + j; | 5432 | wbe = wbuf + j; |
| ... | @@ -5468,7 +5437,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { | ... | @@ -5468,7 +5437,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5468 | else { | 5437 | else { |
| 5469 | mb = mbstate_t(); | 5438 | mb = mbstate_t(); |
| 5470 | bb = lc->negative_sign; | 5439 | bb = lc->negative_sign; |
| 5471 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5440 | j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, loc.get()); |
| 5472 | if (j == size_t(-1)) | 5441 | if (j == size_t(-1)) |
| 5473 | std::__throw_runtime_error("locale not supported"); | 5442 | std::__throw_runtime_error("locale not supported"); |
| 5474 | wbe = wbuf + j; | 5443 | wbe = wbuf + j; |
| ... | @@ -5498,7 +5467,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5498,7 +5467,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5498 | wchar_t wbuf[100]; | 5467 | wchar_t wbuf[100]; |
| 5499 | mbstate_t mb = {0}; | 5468 | mbstate_t mb = {0}; |
| 5500 | const char* bb = lc->int_curr_symbol; | 5469 | const char* bb = lc->int_curr_symbol; |
| 5501 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5470 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, loc.get()); |
| 5502 | if (j == size_t(-1)) | 5471 | if (j == size_t(-1)) |
| 5503 | std::__throw_runtime_error("locale not supported"); | 5472 | std::__throw_runtime_error("locale not supported"); |
| 5504 | wchar_t* wbe = wbuf + j; | 5473 | wchar_t* wbe = wbuf + j; |
| ... | @@ -5516,7 +5485,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5516,7 +5485,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5516 | else { | 5485 | else { |
| 5517 | mb = mbstate_t(); | 5486 | mb = mbstate_t(); |
| 5518 | bb = lc->positive_sign; | 5487 | bb = lc->positive_sign; |
| 5519 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5488 | j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, loc.get()); |
| 5520 | if (j == size_t(-1)) | 5489 | if (j == size_t(-1)) |
| 5521 | std::__throw_runtime_error("locale not supported"); | 5490 | std::__throw_runtime_error("locale not supported"); |
| 5522 | wbe = wbuf + j; | 5491 | wbe = wbuf + j; |
| ... | @@ -5531,7 +5500,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5531,7 +5500,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5531 | else { | 5500 | else { |
| 5532 | mb = mbstate_t(); | 5501 | mb = mbstate_t(); |
| 5533 | bb = lc->negative_sign; | 5502 | bb = lc->negative_sign; |
| 5534 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5503 | j = __locale::__mbsrtowcs(wbuf, &bb, std::size(wbuf), &mb, loc.get()); |
| 5535 | if (j == size_t(-1)) | 5504 | if (j == size_t(-1)) |
| 5536 | std::__throw_runtime_error("locale not supported"); | 5505 | std::__throw_runtime_error("locale not supported"); |
| 5537 | wbe = wbuf + j; | 5506 | wbe = wbuf + j; |
| ... | @@ -5571,6 +5540,54 @@ string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _C | ... | @@ -5571,6 +5540,54 @@ string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _C |
| 5571 | return __np.grouping(); | 5540 | return __np.grouping(); |
| 5572 | } | 5541 | } |
| 5573 | 5542 | ||
| 5543 | template <class _CharT> | ||
| 5544 | int __num_get<_CharT>::__stage2_int_loop( | ||
| 5545 | _CharT __ct, | ||
| 5546 | int __base, | ||
| 5547 | char* __a, | ||
| 5548 | char*& __a_end, | ||
| 5549 | unsigned& __dc, | ||
| 5550 | _CharT __thousands_sep, | ||
| 5551 | const string& __grouping, | ||
| 5552 | unsigned* __g, | ||
| 5553 | unsigned*& __g_end, | ||
| 5554 | _CharT* __atoms) { | ||
| 5555 | if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { | ||
| 5556 | *__a_end++ = __ct == __atoms[24] ? '+' : '-'; | ||
| 5557 | __dc = 0; | ||
| 5558 | return 0; | ||
| 5559 | } | ||
| 5560 | if (__grouping.size() != 0 && __ct == __thousands_sep) { | ||
| 5561 | if (__g_end - __g < __num_get_buf_sz) { | ||
| 5562 | *__g_end++ = __dc; | ||
| 5563 | __dc = 0; | ||
| 5564 | } | ||
| 5565 | return 0; | ||
| 5566 | } | ||
| 5567 | ptrdiff_t __f = __atoms_offset(__atoms, __ct); | ||
| 5568 | if (__f >= 24) | ||
| 5569 | return -1; | ||
| 5570 | switch (__base) { | ||
| 5571 | case 8: | ||
| 5572 | case 10: | ||
| 5573 | if (__f >= __base) | ||
| 5574 | return -1; | ||
| 5575 | break; | ||
| 5576 | case 16: | ||
| 5577 | if (__f < 22) | ||
| 5578 | break; | ||
| 5579 | if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0') { | ||
| 5580 | __dc = 0; | ||
| 5581 | *__a_end++ = __src[__f]; | ||
| 5582 | return 0; | ||
| 5583 | } | ||
| 5584 | return -1; | ||
| 5585 | } | ||
| 5586 | *__a_end++ = __src[__f]; | ||
| 5587 | ++__dc; | ||
| 5588 | return 0; | ||
| 5589 | } | ||
| 5590 | |||
| 5574 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>; | 5591 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>; |
| 5575 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;) | 5592 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;) |
| 5576 | 5593 |
lib/libcxx/src/memory.cpp+12-14| ... | @@ -7,7 +7,8 @@ | ... | @@ -7,7 +7,8 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__config> | 9 | #include <__config> |
| 10 | #ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | 10 | #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) && !defined(_LIBCPP_OBJECT_FORMAT_XCOFF) && \ |
| 11 | _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 5 | ||
| 11 | # define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS | 12 | # define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS |
| 12 | #endif | 13 | #endif |
| 13 | 14 | ||
| ... | @@ -132,19 +133,16 @@ __sp_mut& __get_sp_mut(const void* p) { | ... | @@ -132,19 +133,16 @@ __sp_mut& __get_sp_mut(const void* p) { |
| 132 | 133 | ||
| 133 | #endif // _LIBCPP_HAS_THREADS | 134 | #endif // _LIBCPP_HAS_THREADS |
| 134 | 135 | ||
| 135 | void* align(size_t alignment, size_t size, void*& ptr, size_t& space) { | 136 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 21 |
| 136 | void* r = nullptr; | 137 | |
| 137 | if (size <= space) { | 138 | _LIBCPP_DIAGNOSTIC_PUSH |
| 138 | char* p1 = static_cast<char*>(ptr); | 139 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") |
| 139 | char* p2 = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(p1 + (alignment - 1)) & -alignment); | 140 | // This function only exists for ABI compatibility and we therefore don't provide a declaration in the headers |
| 140 | size_t d = static_cast<size_t>(p2 - p1); | 141 | _LIBCPP_EXPORTED_FROM_ABI void* align(size_t alignment, size_t size, void*& ptr, size_t& space) { |
| 141 | if (d <= space - size) { | 142 | return __align_inline::align(alignment, size, ptr, space); |
| 142 | r = p2; | ||
| 143 | ptr = r; | ||
| 144 | space -= d; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | return r; | ||
| 148 | } | 143 | } |
| 144 | _LIBCPP_DIAGNOSTIC_POP | ||
| 145 | |||
| 146 | #endif | ||
| 149 | 147 | ||
| 150 | _LIBCPP_END_NAMESPACE_STD | 148 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/mutex_destructor.cpp+1-1| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | #include <__config> | 19 | #include <__config> |
| 20 | #include <__thread/support.h> | 20 | #include <__thread/support.h> |
| 21 | 21 | ||
| 22 | #if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION | 22 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 9 || !_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION |
| 23 | # define NEEDS_MUTEX_DESTRUCTOR | 23 | # define NEEDS_MUTEX_DESTRUCTOR |
| 24 | #endif | 24 | #endif |
| 25 | 25 |
lib/libcxx/src/new.cpp+5-5| ... | @@ -6,9 +6,9 @@ | ... | @@ -6,9 +6,9 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include "include/aligned_alloc.h" | ||
| 9 | #include "include/overridable_function.h" | 10 | #include "include/overridable_function.h" |
| 10 | #include <__assert> | 11 | #include <__assert> |
| 11 | #include <__memory/aligned_alloc.h> | ||
| 12 | #include <cstddef> | 12 | #include <cstddef> |
| 13 | #include <cstdlib> | 13 | #include <cstdlib> |
| 14 | #include <new> | 14 | #include <new> |
| ... | @@ -43,7 +43,7 @@ static void* operator_new_impl(std::size_t size) { | ... | @@ -43,7 +43,7 @@ static void* operator_new_impl(std::size_t size) { |
| 43 | return p; | 43 | return p; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size)) _THROW_BAD_ALLOC { | 46 | OVERRIDABLE_FUNCTION void* operator new(std::size_t size) _THROW_BAD_ALLOC { |
| 47 | void* p = operator_new_impl(size); | 47 | void* p = operator_new_impl(size); |
| 48 | if (p == nullptr) | 48 | if (p == nullptr) |
| 49 | __throw_bad_alloc_shim(); | 49 | __throw_bad_alloc_shim(); |
| ... | @@ -74,7 +74,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { | ... | @@ -74,7 +74,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { |
| 74 | # endif | 74 | # endif |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size)) _THROW_BAD_ALLOC { return ::operator new(size); } | 77 | OVERRIDABLE_FUNCTION void* operator new[](size_t size) _THROW_BAD_ALLOC { return ::operator new(size); } |
| 78 | 78 | ||
| 79 | _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { | 79 | _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { |
| 80 | # if !_LIBCPP_HAS_EXCEPTIONS | 80 | # if !_LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -134,7 +134,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm | ... | @@ -134,7 +134,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm |
| 134 | return p; | 134 | return p; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC { | 137 | OVERRIDABLE_FUNCTION void* operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { |
| 138 | void* p = operator_new_aligned_impl(size, alignment); | 138 | void* p = operator_new_aligned_impl(size, alignment); |
| 139 | if (p == nullptr) | 139 | if (p == nullptr) |
| 140 | __throw_bad_alloc_shim(); | 140 | __throw_bad_alloc_shim(); |
| ... | @@ -165,7 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s | ... | @@ -165,7 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s |
| 165 | # endif | 165 | # endif |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC { | 168 | OVERRIDABLE_FUNCTION void* operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { |
| 169 | return ::operator new(size, alignment); | 169 | return ::operator new(size, alignment); |
| 170 | } | 170 | } |
| 171 | 171 |
lib/libcxx/src/optional.cpp+4| ... | @@ -19,6 +19,8 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac | ... | @@ -19,6 +19,8 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac |
| 19 | 19 | ||
| 20 | #include <__config> | 20 | #include <__config> |
| 21 | 21 | ||
| 22 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 7 | ||
| 23 | |||
| 22 | // Preserve std::experimental::bad_optional_access for ABI compatibility | 24 | // Preserve std::experimental::bad_optional_access for ABI compatibility |
| 23 | // Even though it no longer exists in a header file | 25 | // Even though it no longer exists in a header file |
| 24 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL | 26 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL |
| ... | @@ -34,3 +36,5 @@ public: | ... | @@ -34,3 +36,5 @@ public: |
| 34 | bad_optional_access::~bad_optional_access() noexcept = default; | 36 | bad_optional_access::~bad_optional_access() noexcept = default; |
| 35 | 37 | ||
| 36 | _LIBCPP_END_NAMESPACE_EXPERIMENTAL | 38 | _LIBCPP_END_NAMESPACE_EXPERIMENTAL |
| 39 | |||
| 40 | #endif // _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 7 |
lib/libcxx/src/print.cpp+9-1| ... | @@ -22,6 +22,14 @@ | ... | @@ -22,6 +22,14 @@ |
| 22 | # include <windows.h> | 22 | # include <windows.h> |
| 23 | #elif __has_include(<unistd.h>) | 23 | #elif __has_include(<unistd.h>) |
| 24 | # include <unistd.h> | 24 | # include <unistd.h> |
| 25 | # if defined(_NEWLIB_VERSION) | ||
| 26 | # if defined(_POSIX_C_SOURCE) && __has_include(<stdio.h>) | ||
| 27 | # include <stdio.h> | ||
| 28 | # define HAS_FILENO_AND_ISATTY | ||
| 29 | # endif | ||
| 30 | # else | ||
| 31 | # define HAS_FILENO_AND_ISATTY | ||
| 32 | # endif | ||
| 25 | #endif | 33 | #endif |
| 26 | 34 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | @@ -56,7 +64,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst | ... | @@ -56,7 +64,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst |
| 56 | } | 64 | } |
| 57 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 65 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 58 | 66 | ||
| 59 | #elif __has_include(<unistd.h>) // !_LIBCPP_WIN32API | 67 | #elif defined(HAS_FILENO_AND_ISATTY) // !_LIBCPP_WIN32API |
| 60 | 68 | ||
| 61 | _LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream) { return isatty(fileno(__stream)); } | 69 | _LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream) { return isatty(fileno(__stream)); } |
| 62 | #endif | 70 | #endif |
lib/libcxx/src/random.cpp-26| ... | @@ -31,8 +31,6 @@ | ... | @@ -31,8 +31,6 @@ |
| 31 | # include <linux/random.h> | 31 | # include <linux/random.h> |
| 32 | # include <sys/ioctl.h> | 32 | # include <sys/ioctl.h> |
| 33 | # endif | 33 | # endif |
| 34 | #elif defined(_LIBCPP_USING_NACL_RANDOM) | ||
| 35 | # include <nacl/nacl_random.h> | ||
| 36 | #elif defined(_LIBCPP_USING_FUCHSIA_CPRNG) | 34 | #elif defined(_LIBCPP_USING_FUCHSIA_CPRNG) |
| 37 | # include <zircon/syscalls.h> | 35 | # include <zircon/syscalls.h> |
| 38 | #endif | 36 | #endif |
| ... | @@ -93,30 +91,6 @@ unsigned random_device::operator()() { | ... | @@ -93,30 +91,6 @@ unsigned random_device::operator()() { |
| 93 | return r; | 91 | return r; |
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | #elif defined(_LIBCPP_USING_NACL_RANDOM) | ||
| 97 | |||
| 98 | random_device::random_device(const string& __token) { | ||
| 99 | if (__token != "/dev/urandom") | ||
| 100 | std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); | ||
| 101 | int error = nacl_secure_random_init(); | ||
| 102 | if (error) | ||
| 103 | std::__throw_system_error(error, ("random device failed to open " + __token).c_str()); | ||
| 104 | } | ||
| 105 | |||
| 106 | random_device::~random_device() {} | ||
| 107 | |||
| 108 | unsigned random_device::operator()() { | ||
| 109 | unsigned r; | ||
| 110 | size_t n = sizeof(r); | ||
| 111 | size_t bytes_written; | ||
| 112 | int error = nacl_secure_random(&r, n, &bytes_written); | ||
| 113 | if (error != 0) | ||
| 114 | std::__throw_system_error(error, "random_device failed getting bytes"); | ||
| 115 | else if (bytes_written != n) | ||
| 116 | std::__throw_runtime_error("random_device failed to obtain enough bytes"); | ||
| 117 | return r; | ||
| 118 | } | ||
| 119 | |||
| 120 | #elif defined(_LIBCPP_USING_WIN32_RANDOM) | 94 | #elif defined(_LIBCPP_USING_WIN32_RANDOM) |
| 121 | 95 | ||
| 122 | random_device::random_device(const string& __token) { | 96 | random_device::random_device(const string& __token) { |
lib/libcxx/src/string.cpp+10-25| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | #ifndef _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | 23 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 14 |
| 24 | 24 | ||
| 25 | template <bool> | 25 | template <bool> |
| 26 | struct __basic_string_common; | 26 | struct __basic_string_common; |
| ... | @@ -35,45 +35,30 @@ struct __basic_string_common<true> { | ... | @@ -35,45 +35,30 @@ struct __basic_string_common<true> { |
| 35 | void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); } | 35 | void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); } |
| 36 | void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_out_of_range("basic_string"); } | 36 | void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_out_of_range("basic_string"); } |
| 37 | 37 | ||
| 38 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | 38 | #endif // _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 14 |
| 39 | 39 | ||
| 40 | // Define legacy ABI functions | 40 | // Define legacy ABI functions |
| 41 | // --------------------------- | 41 | // --------------------------- |
| 42 | 42 | ||
| 43 | #ifndef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | 43 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 21 |
| 44 | 44 | ||
| 45 | // This initializes the string with [__s, __s + __sz), but capacity() == __reserve. Assumes that __reserve >= __sz. | ||
| 45 | template <class _CharT, class _Traits, class _Allocator> | 46 | template <class _CharT, class _Traits, class _Allocator> |
| 46 | void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) { | 47 | void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) { |
| 47 | if (__libcpp_is_constant_evaluated()) | 48 | pointer __p = __init_internal_buffer(__reserve); |
| 48 | __rep_ = __rep(); | 49 | __annotate_delete(); |
| 49 | if (__reserve > max_size()) | 50 | __set_size(__sz); |
| 50 | __throw_length_error(); | ||
| 51 | pointer __p; | ||
| 52 | if (__fits_in_sso(__reserve)) { | ||
| 53 | __set_short_size(__sz); | ||
| 54 | __p = __get_short_pointer(); | ||
| 55 | } else { | ||
| 56 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1); | ||
| 57 | __p = __allocation.ptr; | ||
| 58 | __begin_lifetime(__p, __allocation.count); | ||
| 59 | __set_long_pointer(__p); | ||
| 60 | __set_long_cap(__allocation.count); | ||
| 61 | __set_long_size(__sz); | ||
| 62 | } | ||
| 63 | traits_type::copy(std::__to_address(__p), __s, __sz); | 51 | traits_type::copy(std::__to_address(__p), __s, __sz); |
| 64 | traits_type::assign(__p[__sz], value_type()); | 52 | traits_type::assign(__p[__sz], value_type()); |
| 65 | __annotate_new(__sz); | 53 | __annotate_new(__sz); |
| 66 | } | 54 | } |
| 67 | 55 | ||
| 68 | # define STRING_LEGACY_API(CharT) \ | 56 | template _LIBCPP_EXPORTED_FROM_ABI void basic_string<char>::__init(const value_type*, size_type, size_type); |
| 69 | template _LIBCPP_EXPORTED_FROM_ABI void basic_string<CharT>::__init(const value_type*, size_type, size_type) | ||
| 70 | |||
| 71 | STRING_LEGACY_API(char); | ||
| 72 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 57 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 73 | STRING_LEGACY_API(wchar_t); | 58 | template _LIBCPP_EXPORTED_FROM_ABI void basic_string<wchar_t>::__init(const value_type*, size_type, size_type); |
| 74 | # endif | 59 | # endif |
| 75 | 60 | ||
| 76 | #endif // _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | 61 | #endif // _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 21 |
| 77 | 62 | ||
| 78 | #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template _LIBCPP_EXPORTED_FROM_ABI __VA_ARGS__; | 63 | #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template _LIBCPP_EXPORTED_FROM_ABI __VA_ARGS__; |
| 79 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | 64 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
lib/libcxx/src/support/runtime/exception_fallback.ipp+2| ... | @@ -8,6 +8,8 @@ | ... | @@ -8,6 +8,8 @@ |
| 8 | //===----------------------------------------------------------------------===// | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | ||
| 10 | #include <__verbose_abort> | 10 | #include <__verbose_abort> |
| 11 | #include <exception> | ||
| 12 | #include "include/atomic_support.h" | ||
| 11 | 13 | ||
| 12 | namespace std { | 14 | namespace std { |
| 13 | 15 |
lib/libcxx/src/support/runtime/exception_glibcxx.ipp+3| ... | @@ -11,6 +11,9 @@ | ... | @@ -11,6 +11,9 @@ |
| 11 | # error header can only be used when targeting libstdc++ or libsupc++ | 11 | # error header can only be used when targeting libstdc++ or libsupc++ |
| 12 | #endif | 12 | #endif |
| 13 | 13 | ||
| 14 | #include <exception> | ||
| 15 | #include <new> | ||
| 16 | |||
| 14 | namespace std { | 17 | namespace std { |
| 15 | 18 | ||
| 16 | bad_alloc::bad_alloc() noexcept {} | 19 | bad_alloc::bad_alloc() noexcept {} |
lib/libcxx/src/support/runtime/exception_libcxxabi.ipp+6-2| ... | @@ -7,6 +7,10 @@ | ... | @@ -7,6 +7,10 @@ |
| 7 | // | 7 | // |
| 8 | //===----------------------------------------------------------------------===// | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | ||
| 10 | #include <exception> | ||
| 11 | |||
| 12 | #include <cxxabi.h> | ||
| 13 | |||
| 10 | #ifndef _LIBCPPABI_VERSION | 14 | #ifndef _LIBCPPABI_VERSION |
| 11 | # error this header can only be used with libc++abi | 15 | # error this header can only be used with libc++abi |
| 12 | #endif | 16 | #endif |
| ... | @@ -17,9 +21,9 @@ bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } | ... | @@ -17,9 +21,9 @@ bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } |
| 17 | 21 | ||
| 18 | int uncaught_exceptions() noexcept { | 22 | int uncaught_exceptions() noexcept { |
| 19 | #if _LIBCPPABI_VERSION > 1001 | 23 | #if _LIBCPPABI_VERSION > 1001 |
| 20 | return __cxa_uncaught_exceptions(); | 24 | return abi::__cxa_uncaught_exceptions(); |
| 21 | #else | 25 | #else |
| 22 | return __cxa_uncaught_exception() ? 1 : 0; | 26 | return abi::__cxa_uncaught_exception() ? 1 : 0; |
| 23 | #endif | 27 | #endif |
| 24 | } | 28 | } |
| 25 | 29 |
lib/libcxx/src/support/runtime/exception_libcxxrt.ipp+2| ... | @@ -11,6 +11,8 @@ | ... | @@ -11,6 +11,8 @@ |
| 11 | # error this header may only be used when targeting libcxxrt | 11 | # error this header may only be used when targeting libcxxrt |
| 12 | #endif | 12 | #endif |
| 13 | 13 | ||
| 14 | #include <exception> | ||
| 15 | |||
| 14 | namespace std { | 16 | namespace std { |
| 15 | 17 | ||
| 16 | bad_exception::~bad_exception() noexcept {} | 18 | bad_exception::~bad_exception() noexcept {} |
lib/libcxx/src/support/runtime/exception_msvc.ipp+2| ... | @@ -12,6 +12,8 @@ | ... | @@ -12,6 +12,8 @@ |
| 12 | #endif | 12 | #endif |
| 13 | 13 | ||
| 14 | #include <__verbose_abort> | 14 | #include <__verbose_abort> |
| 15 | #include <exception> | ||
| 16 | #include <new> | ||
| 15 | 17 | ||
| 16 | extern "C" { | 18 | extern "C" { |
| 17 | typedef void(__cdecl* terminate_handler)(); | 19 | typedef void(__cdecl* terminate_handler)(); |
lib/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp+9-10| ... | @@ -7,22 +7,21 @@ | ... | @@ -7,22 +7,21 @@ |
| 7 | // | 7 | // |
| 8 | //===----------------------------------------------------------------------===// | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | ||
| 10 | #ifndef HAVE_DEPENDENT_EH_ABI | 10 | #include <cxxabi.h> |
| 11 | # error this header may only be used with libc++abi or libcxxrt | 11 | #include <exception> |
| 12 | #endif | ||
| 13 | 12 | ||
| 14 | namespace std { | 13 | namespace std { |
| 15 | 14 | ||
| 16 | exception_ptr::~exception_ptr() noexcept { __cxa_decrement_exception_refcount(__ptr_); } | 15 | exception_ptr::~exception_ptr() noexcept { abi::__cxa_decrement_exception_refcount(__ptr_); } |
| 17 | 16 | ||
| 18 | exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) { | 17 | exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) { |
| 19 | __cxa_increment_exception_refcount(__ptr_); | 18 | abi::__cxa_increment_exception_refcount(__ptr_); |
| 20 | } | 19 | } |
| 21 | 20 | ||
| 22 | exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept { | 21 | exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept { |
| 23 | if (__ptr_ != other.__ptr_) { | 22 | if (__ptr_ != other.__ptr_) { |
| 24 | __cxa_increment_exception_refcount(other.__ptr_); | 23 | abi::__cxa_increment_exception_refcount(other.__ptr_); |
| 25 | __cxa_decrement_exception_refcount(__ptr_); | 24 | abi::__cxa_decrement_exception_refcount(__ptr_); |
| 26 | __ptr_ = other.__ptr_; | 25 | __ptr_ = other.__ptr_; |
| 27 | } | 26 | } |
| 28 | return *this; | 27 | return *this; |
| ... | @@ -31,7 +30,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept { | ... | @@ -31,7 +30,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept { |
| 31 | exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept { | 30 | exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept { |
| 32 | exception_ptr ptr; | 31 | exception_ptr ptr; |
| 33 | ptr.__ptr_ = __e; | 32 | ptr.__ptr_ = __e; |
| 34 | __cxa_increment_exception_refcount(ptr.__ptr_); | 33 | abi::__cxa_increment_exception_refcount(ptr.__ptr_); |
| 35 | 34 | ||
| 36 | return ptr; | 35 | return ptr; |
| 37 | } | 36 | } |
| ... | @@ -51,12 +50,12 @@ exception_ptr current_exception() noexcept { | ... | @@ -51,12 +50,12 @@ exception_ptr current_exception() noexcept { |
| 51 | // this whole function would be just: | 50 | // this whole function would be just: |
| 52 | // return exception_ptr(__cxa_current_primary_exception()); | 51 | // return exception_ptr(__cxa_current_primary_exception()); |
| 53 | exception_ptr ptr; | 52 | exception_ptr ptr; |
| 54 | ptr.__ptr_ = __cxa_current_primary_exception(); | 53 | ptr.__ptr_ = abi::__cxa_current_primary_exception(); |
| 55 | return ptr; | 54 | return ptr; |
| 56 | } | 55 | } |
| 57 | 56 | ||
| 58 | void rethrow_exception(exception_ptr p) { | 57 | void rethrow_exception(exception_ptr p) { |
| 59 | __cxa_rethrow_primary_exception(p.__ptr_); | 58 | abi::__cxa_rethrow_primary_exception(p.__ptr_); |
| 60 | // if p.__ptr_ is NULL, above returns so we terminate | 59 | // if p.__ptr_ is NULL, above returns so we terminate |
| 61 | terminate(); | 60 | terminate(); |
| 62 | } | 61 | } |
lib/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp+2| ... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
| 16 | // stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) | 16 | // stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) |
| 17 | // function. | 17 | // function. |
| 18 | 18 | ||
| 19 | #include <exception> | ||
| 20 | |||
| 19 | namespace std { | 21 | namespace std { |
| 20 | 22 | ||
| 21 | namespace __exception_ptr { | 23 | namespace __exception_ptr { |
lib/libcxx/src/support/runtime/exception_pointer_msvc.ipp+1| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | // | 7 | // |
| 8 | //===----------------------------------------------------------------------===// | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | ||
| 10 | #include <exception> | ||
| 10 | #include <stdio.h> | 11 | #include <stdio.h> |
| 11 | #include <stdlib.h> | 12 | #include <stdlib.h> |
| 12 | 13 |
lib/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp+1| ... | @@ -8,6 +8,7 @@ | ... | @@ -8,6 +8,7 @@ |
| 8 | //===----------------------------------------------------------------------===// | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | ||
| 10 | #include <__verbose_abort> | 10 | #include <__verbose_abort> |
| 11 | #include <exception> | ||
| 11 | 12 | ||
| 12 | namespace std { | 13 | namespace std { |
| 13 | 14 |
lib/libcxx/src/support/win32/locale_win32.cpp+1-1| ... | @@ -144,7 +144,7 @@ int __snprintf(char* ret, size_t n, __locale_t loc, const char* format, ...) { | ... | @@ -144,7 +144,7 @@ int __snprintf(char* ret, size_t n, __locale_t loc, const char* format, ...) { |
| 144 | // Like sprintf, but when return value >= 0 it returns | 144 | // Like sprintf, but when return value >= 0 it returns |
| 145 | // a pointer to a malloc'd string in *sptr. | 145 | // a pointer to a malloc'd string in *sptr. |
| 146 | // If return >= 0, use free to delete *sptr. | 146 | // If return >= 0, use free to delete *sptr. |
| 147 | int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) { | 147 | static int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) { |
| 148 | *sptr = nullptr; | 148 | *sptr = nullptr; |
| 149 | // Query the count required. | 149 | // Query the count required. |
| 150 | va_list ap_copy; | 150 | va_list ap_copy; |
lib/libcxx/src/system_error.cpp+2| ... | @@ -95,6 +95,8 @@ std::optional<errc> __win_err_to_errc(int err) { | ... | @@ -95,6 +95,8 @@ std::optional<errc> __win_err_to_errc(int err) { |
| 95 | return errc::no_lock_available; | 95 | return errc::no_lock_available; |
| 96 | case ERROR_NEGATIVE_SEEK: | 96 | case ERROR_NEGATIVE_SEEK: |
| 97 | return errc::invalid_argument; | 97 | return errc::invalid_argument; |
| 98 | case ERROR_NETNAME_DELETED: | ||
| 99 | return errc::no_such_file_or_directory; | ||
| 98 | case ERROR_NOACCESS: | 100 | case ERROR_NOACCESS: |
| 99 | return errc::permission_denied; | 101 | return errc::permission_denied; |
| 100 | case ERROR_NOT_ENOUGH_MEMORY: | 102 | case ERROR_NOT_ENOUGH_MEMORY: |
lib/libcxx/src/thread.cpp+1-3| ... | @@ -74,9 +74,7 @@ unsigned thread::hardware_concurrency() noexcept { | ... | @@ -74,9 +74,7 @@ unsigned thread::hardware_concurrency() noexcept { |
| 74 | return 0; | 74 | return 0; |
| 75 | return static_cast<unsigned>(result); | 75 | return static_cast<unsigned>(result); |
| 76 | #elif defined(_LIBCPP_WIN32API) | 76 | #elif defined(_LIBCPP_WIN32API) |
| 77 | SYSTEM_INFO info; | 77 | return static_cast<unsigned>(GetActiveProcessorCount(ALL_PROCESSOR_GROUPS)); |
| 78 | GetSystemInfo(&info); | ||
| 79 | return info.dwNumberOfProcessors; | ||
| 80 | #else // defined(CTL_HW) && defined(HW_NCPU) | 78 | #else // defined(CTL_HW) && defined(HW_NCPU) |
| 81 | // TODO: grovel through /proc or check cpuid on x86 and similar | 79 | // TODO: grovel through /proc or check cpuid on x86 and similar |
| 82 | // instructions on other architectures. | 80 | // instructions on other architectures. |
lib/libcxx/src/valarray.cpp+1-2| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | 10 | ||
| 11 | _LIBCPP_BEGIN_NAMESPACE_STD | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | ||
| 13 | // These two symbols are part of the v1 ABI but not part of the >=v2 ABI. | 13 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 9 |
| 14 | #if _LIBCPP_ABI_VERSION == 1 | ||
| 15 | template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::valarray(size_t); | 14 | template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::valarray(size_t); |
| 16 | template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::~valarray(); | 15 | template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::~valarray(); |
| 17 | #endif | 16 | #endif |
lib/libcxx/src/vector.cpp+2-2| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | ||
| 11 | _LIBCPP_BEGIN_NAMESPACE_STD | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | ||
| 13 | #ifndef _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | 13 | #if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 15 |
| 14 | 14 | ||
| 15 | template <bool> | 15 | template <bool> |
| 16 | struct __vector_base_common; | 16 | struct __vector_base_common; |
| ... | @@ -25,6 +25,6 @@ void __vector_base_common<true>::__throw_length_error() const { std::__throw_len | ... | @@ -25,6 +25,6 @@ void __vector_base_common<true>::__throw_length_error() const { std::__throw_len |
| 25 | 25 | ||
| 26 | void __vector_base_common<true>::__throw_out_of_range() const { std::__throw_out_of_range("vector"); } | 26 | void __vector_base_common<true>::__throw_out_of_range() const { std::__throw_out_of_range("vector"); } |
| 27 | 27 | ||
| 28 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | 28 | #endif // _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 15 |
| 29 | 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | 30 | _LIBCPP_END_NAMESPACE_STD |
src/libs/libcxx.zig+14-5| ... | @@ -538,11 +538,20 @@ pub fn addCxxArgs( | ... | @@ -538,11 +538,20 @@ pub fn addCxxArgs( |
| 538 | // Compilation.addCCArgs. This option makes it use serial backend which | 538 | // Compilation.addCCArgs. This option makes it use serial backend which |
| 539 | // is simple and works everywhere. | 539 | // is simple and works everywhere. |
| 540 | try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL"); | 540 | try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL"); |
| 541 | try cflags.append(switch (optimize_mode) { | 541 | switch (optimize_mode) { |
| 542 | .Debug => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG", | 542 | .Debug => { |
| 543 | .ReleaseFast, .ReleaseSmall => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE", | 543 | try cflags.append("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG"); |
| 544 | .ReleaseSafe => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST", | 544 | try cflags.append("-D_LIBCPP_ASSERTION_SEMANTIC_DEFAULT=_LIBCPP_ASSERTION_SEMANTIC_ENFORCE"); |
| 545 | }); | 545 | }, |
| 546 | .ReleaseFast, .ReleaseSmall => { | ||
| 547 | try cflags.append("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE"); | ||
| 548 | try cflags.append("-D_LIBCPP_ASSERTION_SEMANTIC_DEFAULT=_LIBCPP_ASSERTION_SEMANTIC_IGNORE"); | ||
| 549 | }, | ||
| 550 | .ReleaseSafe => { | ||
| 551 | try cflags.append("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST"); | ||
| 552 | try cflags.append("-D_LIBCPP_ASSERTION_SEMANTIC_DEFAULT=_LIBCPP_ASSERTION_SEMANTIC_ENFORCE"); | ||
| 553 | }, | ||
| 554 | } | ||
| 546 | if (target.isGnuLibC()) { | 555 | if (target.isGnuLibC()) { |
| 547 | // glibc 2.16 introduced aligned_alloc | 556 | // glibc 2.16 introduced aligned_alloc |
| 548 | if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) { | 557 | if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) { |