| author | |
| committer | |
| log | d9f0fbf9838060b1e8c2ec0df21b43e75430350f |
| tree | 1ad5976b5e0233a964a7c7381b3ccac8bbc9697e |
| parent | e84e9d3a01e4332ad6b7a239c74d823f283d7f8f |
| signature |
563 files changed, 16838 insertions(+), 12945 deletions(-)
lib/libcxx/include/__algorithm/copy.h+133-1| ... | @@ -13,8 +13,10 @@ | ... | @@ -13,8 +13,10 @@ |
| 13 | #include <__algorithm/for_each_segment.h> | 13 | #include <__algorithm/for_each_segment.h> |
| 14 | #include <__algorithm/min.h> | 14 | #include <__algorithm/min.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__fwd/bit_reference.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__iterator/segmented_iterator.h> | 18 | #include <__iterator/segmented_iterator.h> |
| 19 | #include <__memory/pointer_traits.h> | ||
| 18 | #include <__type_traits/common_type.h> | 20 | #include <__type_traits/common_type.h> |
| 19 | #include <__type_traits/enable_if.h> | 21 | #include <__type_traits/enable_if.h> |
| 20 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| ... | @@ -29,9 +31,129 @@ _LIBCPP_PUSH_MACROS | ... | @@ -29,9 +31,129 @@ _LIBCPP_PUSH_MACROS |
| 29 | 31 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 33 | ||
| 34 | template <class _InputIterator, class _OutputIterator> | ||
| 35 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | ||
| 36 | copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result); | ||
| 37 | |||
| 32 | template <class _InIter, class _Sent, class _OutIter> | 38 | template <class _InIter, class _Sent, class _OutIter> |
| 33 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); | 39 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); |
| 34 | 40 | ||
| 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 | |||
| 35 | struct __copy_impl { | 157 | struct __copy_impl { |
| 36 | template <class _InIter, class _Sent, class _OutIter> | 158 | template <class _InIter, class _Sent, class _OutIter> |
| 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | 159 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| ... | @@ -95,6 +217,16 @@ struct __copy_impl { | ... | @@ -95,6 +217,16 @@ struct __copy_impl { |
| 95 | } | 217 | } |
| 96 | } | 218 | } |
| 97 | 219 | ||
| 220 | template <class _Cp, bool _IsConst> | ||
| 221 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> > | ||
| 222 | operator()(__bit_iterator<_Cp, _IsConst> __first, | ||
| 223 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 224 | __bit_iterator<_Cp, false> __result) const { | ||
| 225 | if (__first.__ctz_ == __result.__ctz_) | ||
| 226 | return std::make_pair(__last, std::__copy_aligned(__first, __last, __result)); | ||
| 227 | return std::make_pair(__last, std::__copy_unaligned(__first, __last, __result)); | ||
| 228 | } | ||
| 229 | |||
| 98 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 230 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. |
| 99 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> | 231 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> |
| 100 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | 232 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
| ... | @@ -110,7 +242,7 @@ __copy(_InIter __first, _Sent __last, _OutIter __result) { | ... | @@ -110,7 +242,7 @@ __copy(_InIter __first, _Sent __last, _OutIter __result) { |
| 110 | } | 242 | } |
| 111 | 243 | ||
| 112 | template <class _InputIterator, class _OutputIterator> | 244 | template <class _InputIterator, class _OutputIterator> |
| 113 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | 245 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 114 | copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | 246 | copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { |
| 115 | return std::__copy(__first, __last, __result).second; | 247 | return std::__copy(__first, __last, __result).second; |
| 116 | } | 248 | } |
lib/libcxx/include/__algorithm/copy_backward.h+131| ... | @@ -10,11 +10,14 @@ | ... | @@ -10,11 +10,14 @@ |
| 10 | #define _LIBCPP___ALGORITHM_COPY_BACKWARD_H | 10 | #define _LIBCPP___ALGORITHM_COPY_BACKWARD_H |
| 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/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 14 | #include <__algorithm/min.h> | 15 | #include <__algorithm/min.h> |
| 15 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__fwd/bit_reference.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__iterator/segmented_iterator.h> | 19 | #include <__iterator/segmented_iterator.h> |
| 20 | #include <__memory/pointer_traits.h> | ||
| 18 | #include <__type_traits/common_type.h> | 21 | #include <__type_traits/common_type.h> |
| 19 | #include <__type_traits/enable_if.h> | 22 | #include <__type_traits/enable_if.h> |
| 20 | #include <__type_traits/is_constructible.h> | 23 | #include <__type_traits/is_constructible.h> |
| ... | @@ -34,6 +37,124 @@ template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> | ... | @@ -34,6 +37,124 @@ template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> |
| 34 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter> | 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter> |
| 35 | __copy_backward(_InIter __first, _Sent __last, _OutIter __result); | 38 | __copy_backward(_InIter __first, _Sent __last, _OutIter __result); |
| 36 | 39 | ||
| 40 | template <class _Cp, bool _IsConst> | ||
| 41 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_aligned( | ||
| 42 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 43 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 44 | using difference_type = typename _In::difference_type; | ||
| 45 | using __storage_type = typename _In::__storage_type; | ||
| 46 | |||
| 47 | const int __bits_per_word = _In::__bits_per_word; | ||
| 48 | difference_type __n = __last - __first; | ||
| 49 | if (__n > 0) { | ||
| 50 | // do first word | ||
| 51 | if (__last.__ctz_ != 0) { | ||
| 52 | difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n); | ||
| 53 | __n -= __dn; | ||
| 54 | unsigned __clz = __bits_per_word - __last.__ctz_; | ||
| 55 | __storage_type __m = std::__middle_mask<__storage_type>(__clz, __last.__ctz_ - __dn); | ||
| 56 | __storage_type __b = *__last.__seg_ & __m; | ||
| 57 | *__result.__seg_ &= ~__m; | ||
| 58 | *__result.__seg_ |= __b; | ||
| 59 | __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); | ||
| 60 | // __last.__ctz_ = 0 | ||
| 61 | } | ||
| 62 | // __last.__ctz_ == 0 || __n == 0 | ||
| 63 | // __result.__ctz_ == 0 || __n == 0 | ||
| 64 | // do middle words | ||
| 65 | __storage_type __nw = __n / __bits_per_word; | ||
| 66 | __result.__seg_ -= __nw; | ||
| 67 | __last.__seg_ -= __nw; | ||
| 68 | std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_)); | ||
| 69 | __n -= __nw * __bits_per_word; | ||
| 70 | // do last word | ||
| 71 | if (__n > 0) { | ||
| 72 | __storage_type __m = std::__leading_mask<__storage_type>(__bits_per_word - __n); | ||
| 73 | __storage_type __b = *--__last.__seg_ & __m; | ||
| 74 | *--__result.__seg_ &= ~__m; | ||
| 75 | *__result.__seg_ |= __b; | ||
| 76 | __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | return __result; | ||
| 80 | } | ||
| 81 | |||
| 82 | template <class _Cp, bool _IsConst> | ||
| 83 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_unaligned( | ||
| 84 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 85 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 86 | using difference_type = typename _In::difference_type; | ||
| 87 | using __storage_type = typename _In::__storage_type; | ||
| 88 | |||
| 89 | const int __bits_per_word = _In::__bits_per_word; | ||
| 90 | difference_type __n = __last - __first; | ||
| 91 | if (__n > 0) { | ||
| 92 | // do first word | ||
| 93 | if (__last.__ctz_ != 0) { | ||
| 94 | difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n); | ||
| 95 | __n -= __dn; | ||
| 96 | unsigned __clz_l = __bits_per_word - __last.__ctz_; | ||
| 97 | __storage_type __m = std::__middle_mask<__storage_type>(__clz_l, __last.__ctz_ - __dn); | ||
| 98 | __storage_type __b = *__last.__seg_ & __m; | ||
| 99 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 100 | __storage_type __ddn = std::min(__dn, static_cast<difference_type>(__result.__ctz_)); | ||
| 101 | if (__ddn > 0) { | ||
| 102 | __m = std::__middle_mask<__storage_type>(__clz_r, __result.__ctz_ - __ddn); | ||
| 103 | *__result.__seg_ &= ~__m; | ||
| 104 | if (__result.__ctz_ > __last.__ctz_) | ||
| 105 | *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); | ||
| 106 | else | ||
| 107 | *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_); | ||
| 108 | __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); | ||
| 109 | __dn -= __ddn; | ||
| 110 | } | ||
| 111 | if (__dn > 0) { | ||
| 112 | // __result.__ctz_ == 0 | ||
| 113 | --__result.__seg_; | ||
| 114 | __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1)); | ||
| 115 | __m = std::__leading_mask<__storage_type>(__result.__ctz_); | ||
| 116 | *__result.__seg_ &= ~__m; | ||
| 117 | __last.__ctz_ -= __dn + __ddn; | ||
| 118 | *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); | ||
| 119 | } | ||
| 120 | // __last.__ctz_ = 0 | ||
| 121 | } | ||
| 122 | // __last.__ctz_ == 0 || __n == 0 | ||
| 123 | // __result.__ctz_ != 0 || __n == 0 | ||
| 124 | // do middle words | ||
| 125 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 126 | __storage_type __m = std::__trailing_mask<__storage_type>(__clz_r); | ||
| 127 | for (; __n >= __bits_per_word; __n -= __bits_per_word) { | ||
| 128 | __storage_type __b = *--__last.__seg_; | ||
| 129 | *__result.__seg_ &= ~__m; | ||
| 130 | *__result.__seg_ |= __b >> __clz_r; | ||
| 131 | *--__result.__seg_ &= __m; | ||
| 132 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 133 | } | ||
| 134 | // do last word | ||
| 135 | if (__n > 0) { | ||
| 136 | __m = std::__leading_mask<__storage_type>(__bits_per_word - __n); | ||
| 137 | __storage_type __b = *--__last.__seg_ & __m; | ||
| 138 | __clz_r = __bits_per_word - __result.__ctz_; | ||
| 139 | __storage_type __dn = std::min(__n, static_cast<difference_type>(__result.__ctz_)); | ||
| 140 | __m = std::__middle_mask<__storage_type>(__clz_r, __result.__ctz_ - __dn); | ||
| 141 | *__result.__seg_ &= ~__m; | ||
| 142 | *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_); | ||
| 143 | __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); | ||
| 144 | __n -= __dn; | ||
| 145 | if (__n > 0) { | ||
| 146 | // __result.__ctz_ == 0 | ||
| 147 | --__result.__seg_; | ||
| 148 | __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); | ||
| 149 | __m = std::__leading_mask<__storage_type>(__result.__ctz_); | ||
| 150 | *__result.__seg_ &= ~__m; | ||
| 151 | *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn)); | ||
| 152 | } | ||
| 153 | } | ||
| 154 | } | ||
| 155 | return __result; | ||
| 156 | } | ||
| 157 | |||
| 37 | template <class _AlgPolicy> | 158 | template <class _AlgPolicy> |
| 38 | struct __copy_backward_impl { | 159 | struct __copy_backward_impl { |
| 39 | template <class _InIter, class _Sent, class _OutIter> | 160 | template <class _InIter, class _Sent, class _OutIter> |
| ... | @@ -107,6 +228,16 @@ struct __copy_backward_impl { | ... | @@ -107,6 +228,16 @@ struct __copy_backward_impl { |
| 107 | } | 228 | } |
| 108 | } | 229 | } |
| 109 | 230 | ||
| 231 | template <class _Cp, bool _IsConst> | ||
| 232 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> > | ||
| 233 | operator()(__bit_iterator<_Cp, _IsConst> __first, | ||
| 234 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 235 | __bit_iterator<_Cp, false> __result) { | ||
| 236 | if (__last.__ctz_ == __result.__ctz_) | ||
| 237 | return std::make_pair(__last, std::__copy_backward_aligned(__first, __last, __result)); | ||
| 238 | return std::make_pair(__last, std::__copy_backward_unaligned(__first, __last, __result)); | ||
| 239 | } | ||
| 240 | |||
| 110 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 241 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. |
| 111 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> | 242 | template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> |
| 112 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | 243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
lib/libcxx/include/__algorithm/count.h+5-5| ... | @@ -55,18 +55,18 @@ __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_t | ... | @@ -55,18 +55,18 @@ __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_t |
| 55 | if (__first.__ctz_ != 0) { | 55 | if (__first.__ctz_ != 0) { |
| 56 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); | 56 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); |
| 57 | __storage_type __dn = std::min(__clz_f, __n); | 57 | __storage_type __dn = std::min(__clz_f, __n); |
| 58 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | 58 | __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first.__ctz_); |
| 59 | __r = std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m); | 59 | __r = std::__popcount(__storage_type(std::__invert_if<!_ToCount>(*__first.__seg_) & __m)); |
| 60 | __n -= __dn; | 60 | __n -= __dn; |
| 61 | ++__first.__seg_; | 61 | ++__first.__seg_; |
| 62 | } | 62 | } |
| 63 | // do middle whole words | 63 | // do middle whole words |
| 64 | for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) | 64 | for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) |
| 65 | __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_)); | 65 | __r += std::__popcount(std::__invert_if<!_ToCount>(*__first.__seg_)); |
| 66 | // do last partial word | 66 | // do last partial word |
| 67 | if (__n > 0) { | 67 | if (__n > 0) { |
| 68 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | 68 | __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); |
| 69 | __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m); | 69 | __r += std::__popcount(__storage_type(std::__invert_if<!_ToCount>(*__first.__seg_) & __m)); |
| 70 | } | 70 | } |
| 71 | return __r; | 71 | return __r; |
| 72 | } | 72 | } |
lib/libcxx/include/__algorithm/equal.h+160| ... | @@ -11,16 +11,20 @@ | ... | @@ -11,16 +11,20 @@ |
| 11 | #define _LIBCPP___ALGORITHM_EQUAL_H | 11 | #define _LIBCPP___ALGORITHM_EQUAL_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/comp.h> | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/min.h> | ||
| 14 | #include <__algorithm/unwrap_iter.h> | 15 | #include <__algorithm/unwrap_iter.h> |
| 15 | #include <__config> | 16 | #include <__config> |
| 16 | #include <__functional/identity.h> | 17 | #include <__functional/identity.h> |
| 18 | #include <__fwd/bit_reference.h> | ||
| 17 | #include <__iterator/distance.h> | 19 | #include <__iterator/distance.h> |
| 18 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__memory/pointer_traits.h> | ||
| 19 | #include <__string/constexpr_c_functions.h> | 22 | #include <__string/constexpr_c_functions.h> |
| 20 | #include <__type_traits/desugars_to.h> | 23 | #include <__type_traits/desugars_to.h> |
| 21 | #include <__type_traits/enable_if.h> | 24 | #include <__type_traits/enable_if.h> |
| 22 | #include <__type_traits/invoke.h> | 25 | #include <__type_traits/invoke.h> |
| 23 | #include <__type_traits/is_equality_comparable.h> | 26 | #include <__type_traits/is_equality_comparable.h> |
| 27 | #include <__type_traits/is_same.h> | ||
| 24 | #include <__type_traits/is_volatile.h> | 28 | #include <__type_traits/is_volatile.h> |
| 25 | #include <__utility/move.h> | 29 | #include <__utility/move.h> |
| 26 | 30 | ||
| ... | @@ -33,6 +37,140 @@ _LIBCPP_PUSH_MACROS | ... | @@ -33,6 +37,140 @@ _LIBCPP_PUSH_MACROS |
| 33 | 37 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | 38 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 39 | ||
| 40 | template <class _Cp, bool _IsConst1, bool _IsConst2> | ||
| 41 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool | ||
| 42 | __equal_unaligned(__bit_iterator<_Cp, _IsConst1> __first1, | ||
| 43 | __bit_iterator<_Cp, _IsConst1> __last1, | ||
| 44 | __bit_iterator<_Cp, _IsConst2> __first2) { | ||
| 45 | using _It = __bit_iterator<_Cp, _IsConst1>; | ||
| 46 | using difference_type = typename _It::difference_type; | ||
| 47 | using __storage_type = typename _It::__storage_type; | ||
| 48 | |||
| 49 | const int __bits_per_word = _It::__bits_per_word; | ||
| 50 | difference_type __n = __last1 - __first1; | ||
| 51 | if (__n > 0) { | ||
| 52 | // do first word | ||
| 53 | if (__first1.__ctz_ != 0) { | ||
| 54 | unsigned __clz_f = __bits_per_word - __first1.__ctz_; | ||
| 55 | difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); | ||
| 56 | __n -= __dn; | ||
| 57 | __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first1.__ctz_); | ||
| 58 | __storage_type __b = *__first1.__seg_ & __m; | ||
| 59 | unsigned __clz_r = __bits_per_word - __first2.__ctz_; | ||
| 60 | __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); | ||
| 61 | __m = std::__middle_mask<__storage_type>(__clz_r - __ddn, __first2.__ctz_); | ||
| 62 | if (__first2.__ctz_ > __first1.__ctz_) { | ||
| 63 | if (static_cast<__storage_type>(*__first2.__seg_ & __m) != | ||
| 64 | static_cast<__storage_type>(__b << (__first2.__ctz_ - __first1.__ctz_))) | ||
| 65 | return false; | ||
| 66 | } else { | ||
| 67 | if (static_cast<__storage_type>(*__first2.__seg_ & __m) != | ||
| 68 | static_cast<__storage_type>(__b >> (__first1.__ctz_ - __first2.__ctz_))) | ||
| 69 | return false; | ||
| 70 | } | ||
| 71 | __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word; | ||
| 72 | __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_) % __bits_per_word); | ||
| 73 | __dn -= __ddn; | ||
| 74 | if (__dn > 0) { | ||
| 75 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 76 | if (static_cast<__storage_type>(*__first2.__seg_ & __m) != | ||
| 77 | static_cast<__storage_type>(__b >> (__first1.__ctz_ + __ddn))) | ||
| 78 | return false; | ||
| 79 | __first2.__ctz_ = static_cast<unsigned>(__dn); | ||
| 80 | } | ||
| 81 | ++__first1.__seg_; | ||
| 82 | // __first1.__ctz_ = 0; | ||
| 83 | } | ||
| 84 | // __first1.__ctz_ == 0; | ||
| 85 | // do middle words | ||
| 86 | unsigned __clz_r = __bits_per_word - __first2.__ctz_; | ||
| 87 | __storage_type __m = std::__leading_mask<__storage_type>(__first2.__ctz_); | ||
| 88 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) { | ||
| 89 | __storage_type __b = *__first1.__seg_; | ||
| 90 | if (static_cast<__storage_type>(*__first2.__seg_ & __m) != static_cast<__storage_type>(__b << __first2.__ctz_)) | ||
| 91 | return false; | ||
| 92 | ++__first2.__seg_; | ||
| 93 | if (static_cast<__storage_type>(*__first2.__seg_ & static_cast<__storage_type>(~__m)) != | ||
| 94 | static_cast<__storage_type>(__b >> __clz_r)) | ||
| 95 | return false; | ||
| 96 | } | ||
| 97 | // do last word | ||
| 98 | if (__n > 0) { | ||
| 99 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 100 | __storage_type __b = *__first1.__seg_ & __m; | ||
| 101 | __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r)); | ||
| 102 | __m = std::__middle_mask<__storage_type>(__clz_r - __dn, __first2.__ctz_); | ||
| 103 | if (static_cast<__storage_type>(*__first2.__seg_ & __m) != static_cast<__storage_type>(__b << __first2.__ctz_)) | ||
| 104 | return false; | ||
| 105 | __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word; | ||
| 106 | __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_) % __bits_per_word); | ||
| 107 | __n -= __dn; | ||
| 108 | if (__n > 0) { | ||
| 109 | __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 110 | if (static_cast<__storage_type>(*__first2.__seg_ & __m) != static_cast<__storage_type>(__b >> __dn)) | ||
| 111 | return false; | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
| 115 | return true; | ||
| 116 | } | ||
| 117 | |||
| 118 | template <class _Cp, bool _IsConst1, bool _IsConst2> | ||
| 119 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool | ||
| 120 | __equal_aligned(__bit_iterator<_Cp, _IsConst1> __first1, | ||
| 121 | __bit_iterator<_Cp, _IsConst1> __last1, | ||
| 122 | __bit_iterator<_Cp, _IsConst2> __first2) { | ||
| 123 | using _It = __bit_iterator<_Cp, _IsConst1>; | ||
| 124 | using difference_type = typename _It::difference_type; | ||
| 125 | using __storage_type = typename _It::__storage_type; | ||
| 126 | |||
| 127 | const int __bits_per_word = _It::__bits_per_word; | ||
| 128 | difference_type __n = __last1 - __first1; | ||
| 129 | if (__n > 0) { | ||
| 130 | // do first word | ||
| 131 | if (__first1.__ctz_ != 0) { | ||
| 132 | unsigned __clz = __bits_per_word - __first1.__ctz_; | ||
| 133 | difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); | ||
| 134 | __n -= __dn; | ||
| 135 | __storage_type __m = std::__middle_mask<__storage_type>(__clz - __dn, __first1.__ctz_); | ||
| 136 | if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) | ||
| 137 | return false; | ||
| 138 | ++__first2.__seg_; | ||
| 139 | ++__first1.__seg_; | ||
| 140 | // __first1.__ctz_ = 0; | ||
| 141 | // __first2.__ctz_ = 0; | ||
| 142 | } | ||
| 143 | // __first1.__ctz_ == 0; | ||
| 144 | // __first2.__ctz_ == 0; | ||
| 145 | // do middle words | ||
| 146 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_) | ||
| 147 | if (*__first2.__seg_ != *__first1.__seg_) | ||
| 148 | return false; | ||
| 149 | // do last word | ||
| 150 | if (__n > 0) { | ||
| 151 | __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); | ||
| 152 | if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) | ||
| 153 | return false; | ||
| 154 | } | ||
| 155 | } | ||
| 156 | return true; | ||
| 157 | } | ||
| 158 | |||
| 159 | template <class _Cp, | ||
| 160 | bool _IsConst1, | ||
| 161 | bool _IsConst2, | ||
| 162 | class _BinaryPredicate, | ||
| 163 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, int> = 0> | ||
| 164 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( | ||
| 165 | __bit_iterator<_Cp, _IsConst1> __first1, | ||
| 166 | __bit_iterator<_Cp, _IsConst1> __last1, | ||
| 167 | __bit_iterator<_Cp, _IsConst2> __first2, | ||
| 168 | _BinaryPredicate) { | ||
| 169 | if (__first1.__ctz_ == __first2.__ctz_) | ||
| 170 | return std::__equal_aligned(__first1, __last1, __first2); | ||
| 171 | return std::__equal_unaligned(__first1, __last1, __first2); | ||
| 172 | } | ||
| 173 | |||
| 36 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 174 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( | 175 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( |
| 38 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) { | 176 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) { |
| ... | @@ -94,6 +232,28 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, | ... | @@ -94,6 +232,28 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, |
| 94 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); | 232 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); |
| 95 | } | 233 | } |
| 96 | 234 | ||
| 235 | template <class _Cp, | ||
| 236 | bool _IsConst1, | ||
| 237 | bool _IsConst2, | ||
| 238 | class _Pred, | ||
| 239 | class _Proj1, | ||
| 240 | class _Proj2, | ||
| 241 | __enable_if_t<__desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value && | ||
| 242 | __is_identity<_Proj2>::value, | ||
| 243 | int> = 0> | ||
| 244 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( | ||
| 245 | __bit_iterator<_Cp, _IsConst1> __first1, | ||
| 246 | __bit_iterator<_Cp, _IsConst1> __last1, | ||
| 247 | __bit_iterator<_Cp, _IsConst2> __first2, | ||
| 248 | __bit_iterator<_Cp, _IsConst2>, | ||
| 249 | _Pred&, | ||
| 250 | _Proj1&, | ||
| 251 | _Proj2&) { | ||
| 252 | if (__first1.__ctz_ == __first2.__ctz_) | ||
| 253 | return std::__equal_aligned(__first1, __last1, __first2); | ||
| 254 | return std::__equal_unaligned(__first1, __last1, __first2); | ||
| 255 | } | ||
| 256 | |||
| 97 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | 257 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 98 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | 258 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 99 | equal(_InputIterator1 __first1, | 259 | equal(_InputIterator1 __first1, |
lib/libcxx/include/__algorithm/fill_n.h+2-10| ... | @@ -41,11 +41,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ | ... | @@ -41,11 +41,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ |
| 41 | if (__first.__ctz_ != 0) { | 41 | if (__first.__ctz_ != 0) { |
| 42 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); | 42 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); |
| 43 | __storage_type __dn = std::min(__clz_f, __n); | 43 | __storage_type __dn = std::min(__clz_f, __n); |
| 44 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | 44 | std::__fill_masked_range(std::__to_address(__first.__seg_), __clz_f - __dn, __first.__ctz_, _FillVal); |
| 45 | if (_FillVal) | ||
| 46 | *__first.__seg_ |= __m; | ||
| 47 | else | ||
| 48 | *__first.__seg_ &= ~__m; | ||
| 49 | __n -= __dn; | 45 | __n -= __dn; |
| 50 | ++__first.__seg_; | 46 | ++__first.__seg_; |
| 51 | } | 47 | } |
| ... | @@ -56,11 +52,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ | ... | @@ -56,11 +52,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ |
| 56 | // do last partial word | 52 | // do last partial word |
| 57 | if (__n > 0) { | 53 | if (__n > 0) { |
| 58 | __first.__seg_ += __nw; | 54 | __first.__seg_ += __nw; |
| 59 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | 55 | std::__fill_masked_range(std::__to_address(__first.__seg_), __bits_per_word - __n, 0u, _FillVal); |
| 60 | if (_FillVal) | ||
| 61 | *__first.__seg_ |= __m; | ||
| 62 | else | ||
| 63 | *__first.__seg_ &= ~__m; | ||
| 64 | } | 56 | } |
| 65 | } | 57 | } |
| 66 | 58 |
lib/libcxx/include/__algorithm/find.h+5-5| ... | @@ -106,10 +106,10 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty | ... | @@ -106,10 +106,10 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty |
| 106 | if (__first.__ctz_ != 0) { | 106 | if (__first.__ctz_ != 0) { |
| 107 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); | 107 | __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); |
| 108 | __storage_type __dn = std::min(__clz_f, __n); | 108 | __storage_type __dn = std::min(__clz_f, __n); |
| 109 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | 109 | __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first.__ctz_); |
| 110 | __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m; | 110 | __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m; |
| 111 | if (__b) | 111 | if (__b) |
| 112 | return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b))); | 112 | return _It(__first.__seg_, static_cast<unsigned>(std::__countr_zero(__b))); |
| 113 | if (__n == __dn) | 113 | if (__n == __dn) |
| 114 | return __first + __n; | 114 | return __first + __n; |
| 115 | __n -= __dn; | 115 | __n -= __dn; |
| ... | @@ -119,14 +119,14 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty | ... | @@ -119,14 +119,14 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty |
| 119 | for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) { | 119 | for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) { |
| 120 | __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_); | 120 | __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_); |
| 121 | if (__b) | 121 | if (__b) |
| 122 | return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b))); | 122 | return _It(__first.__seg_, static_cast<unsigned>(std::__countr_zero(__b))); |
| 123 | } | 123 | } |
| 124 | // do last partial word | 124 | // do last partial word |
| 125 | if (__n > 0) { | 125 | if (__n > 0) { |
| 126 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | 126 | __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n); |
| 127 | __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m; | 127 | __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m; |
| 128 | if (__b) | 128 | if (__b) |
| 129 | return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b))); | 129 | return _It(__first.__seg_, static_cast<unsigned>(std::__countr_zero(__b))); |
| 130 | } | 130 | } |
| 131 | return _It(__first.__seg_, static_cast<unsigned>(__n)); | 131 | return _It(__first.__seg_, static_cast<unsigned>(__n)); |
| 132 | } | 132 | } |
lib/libcxx/include/__algorithm/for_each.h+28-19| ... | @@ -12,9 +12,10 @@ | ... | @@ -12,9 +12,10 @@ |
| 12 | 12 | ||
| 13 | #include <__algorithm/for_each_segment.h> | 13 | #include <__algorithm/for_each_segment.h> |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | ||
| 15 | #include <__iterator/segmented_iterator.h> | 16 | #include <__iterator/segmented_iterator.h> |
| 16 | #include <__ranges/movable_box.h> | 17 | #include <__type_traits/enable_if.h> |
| 17 | #include <__utility/in_place.h> | 18 | #include <__type_traits/invoke.h> |
| 18 | #include <__utility/move.h> | 19 | #include <__utility/move.h> |
| 19 | 20 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -26,28 +27,36 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,28 +27,36 @@ _LIBCPP_PUSH_MACROS |
| 26 | 27 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 29 | ||
| 29 | template <class _InputIterator, class _Function> | 30 | template <class _InputIterator, class _Sent, class _Func, class _Proj> |
| 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function | 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator |
| 31 | for_each(_InputIterator __first, _InputIterator __last, _Function __f) { | 32 | __for_each(_InputIterator __first, _Sent __last, _Func& __f, _Proj& __proj) { |
| 32 | for (; __first != __last; ++__first) | 33 | for (; __first != __last; ++__first) |
| 33 | __f(*__first); | 34 | std::__invoke(__f, std::__invoke(__proj, *__first)); |
| 34 | return __f; | 35 | return __first; |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | // __movable_box is available in C++20, but is actually a copyable-box, so optimization is only correct in C++23 | 38 | #ifndef _LIBCPP_CXX03_LANG |
| 38 | #if _LIBCPP_STD_VER >= 23 | 39 | template <class _SegmentedIterator, |
| 39 | template <class _SegmentedIterator, class _Function> | 40 | class _Func, |
| 40 | requires __is_segmented_iterator<_SegmentedIterator>::value | 41 | class _Proj, |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr _Function | 42 | __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> |
| 42 | for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) { | 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _SegmentedIterator |
| 43 | ranges::__movable_box<_Function> __wrapped_func(in_place, std::move(__func)); | 44 | __for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Func& __func, _Proj& __proj) { |
| 44 | std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) { | 45 | using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator; |
| 45 | __wrapped_func = | 46 | std::__for_each_segment(__first, __last, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) { |
| 46 | ranges::__movable_box<_Function>(in_place, std::for_each(__lfirst, __llast, std::move(*__wrapped_func))); | 47 | std::__for_each(__lfirst, __llast, __func, __proj); |
| 47 | }); | 48 | }); |
| 48 | return std::move(*__wrapped_func); | 49 | return __last; |
| 50 | } | ||
| 51 | #endif // !_LIBCPP_CXX03_LANG | ||
| 52 | |||
| 53 | template <class _InputIterator, class _Func> | ||
| 54 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Func | ||
| 55 | for_each(_InputIterator __first, _InputIterator __last, _Func __f) { | ||
| 56 | __identity __proj; | ||
| 57 | std::__for_each(__first, __last, __f, __proj); | ||
| 58 | return __f; | ||
| 49 | } | 59 | } |
| 50 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 51 | 60 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | 61 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 62 |
lib/libcxx/include/__algorithm/for_each_n.h+69-8| ... | @@ -10,32 +10,93 @@ | ... | @@ -10,32 +10,93 @@ |
| 10 | #ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_H | 10 | #ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_H |
| 11 | #define _LIBCPP___ALGORITHM_FOR_EACH_N_H | 11 | #define _LIBCPP___ALGORITHM_FOR_EACH_N_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/for_each.h> | ||
| 14 | #include <__algorithm/for_each_n_segment.h> | ||
| 13 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__functional/identity.h> | ||
| 17 | #include <__iterator/iterator_traits.h> | ||
| 18 | #include <__iterator/segmented_iterator.h> | ||
| 19 | #include <__type_traits/disjunction.h> | ||
| 20 | #include <__type_traits/enable_if.h> | ||
| 21 | #include <__type_traits/invoke.h> | ||
| 22 | #include <__type_traits/negation.h> | ||
| 14 | #include <__utility/convert_to_integral.h> | 23 | #include <__utility/convert_to_integral.h> |
| 24 | #include <__utility/move.h> | ||
| 15 | 25 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 27 | # pragma GCC system_header |
| 18 | #endif | 28 | #endif |
| 19 | 29 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 30 | _LIBCPP_PUSH_MACROS |
| 31 | #include <__undef_macros> | ||
| 21 | 32 | ||
| 22 | #if _LIBCPP_STD_VER >= 17 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 34 | ||
| 24 | template <class _InputIterator, class _Size, class _Function> | 35 | template <class _InputIterator, |
| 25 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | 36 | class _Size, |
| 26 | for_each_n(_InputIterator __first, _Size __orig_n, _Function __f) { | 37 | class _Func, |
| 38 | class _Proj, | ||
| 39 | __enable_if_t<!__has_random_access_iterator_category<_InputIterator>::value && | ||
| 40 | _Or< _Not<__is_segmented_iterator<_InputIterator> >, | ||
| 41 | _Not<__has_random_access_local_iterator<_InputIterator> > >::value, | ||
| 42 | int> = 0> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | ||
| 44 | __for_each_n(_InputIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) { | ||
| 27 | typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize; | 45 | typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize; |
| 28 | _IntegralSize __n = __orig_n; | 46 | _IntegralSize __n = __orig_n; |
| 29 | while (__n > 0) { | 47 | while (__n > 0) { |
| 30 | __f(*__first); | 48 | std::__invoke(__f, std::__invoke(__proj, *__first)); |
| 31 | ++__first; | 49 | ++__first; |
| 32 | --__n; | 50 | --__n; |
| 33 | } | 51 | } |
| 34 | return __first; | 52 | return std::move(__first); |
| 35 | } | 53 | } |
| 36 | 54 | ||
| 37 | #endif | 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 | |||
| 68 | #ifndef _LIBCPP_CXX03_LANG | ||
| 69 | template <class _SegmentedIterator, | ||
| 70 | class _Size, | ||
| 71 | class _Func, | ||
| 72 | class _Proj, | ||
| 73 | __enable_if_t<!__has_random_access_iterator_category<_SegmentedIterator>::value && | ||
| 74 | __is_segmented_iterator<_SegmentedIterator>::value && | ||
| 75 | __has_random_access_iterator_category< | ||
| 76 | typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value, | ||
| 77 | int> = 0> | ||
| 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _SegmentedIterator | ||
| 79 | __for_each_n(_SegmentedIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) { | ||
| 80 | using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator; | ||
| 81 | return std::__for_each_n_segment(__first, __orig_n, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) { | ||
| 82 | std::__for_each(__lfirst, __llast, __f, __proj); | ||
| 83 | }); | ||
| 84 | } | ||
| 85 | #endif // !_LIBCPP_CXX03_LANG | ||
| 86 | |||
| 87 | #if _LIBCPP_STD_VER >= 17 | ||
| 88 | |||
| 89 | template <class _InputIterator, class _Size, class _Func> | ||
| 90 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | ||
| 91 | for_each_n(_InputIterator __first, _Size __orig_n, _Func __f) { | ||
| 92 | __identity __proj; | ||
| 93 | return std::__for_each_n(__first, __orig_n, __f, __proj); | ||
| 94 | } | ||
| 95 | |||
| 96 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 38 | 97 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | 98 | _LIBCPP_END_NAMESPACE_STD |
| 40 | 99 | ||
| 100 | _LIBCPP_POP_MACROS | ||
| 101 | |||
| 41 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H | 102 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H |
lib/libcxx/include/__algorithm/for_each_n_segment.h created+63| ... | @@ -0,0 +1,63 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_SEGMENT_H | ||
| 10 | #define _LIBCPP___ALGORITHM_FOR_EACH_N_SEGMENT_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__iterator/iterator_traits.h> | ||
| 14 | #include <__iterator/segmented_iterator.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | // __for_each_n_segment optimizes linear iteration over segmented iterators. It processes a segmented | ||
| 23 | // input range [__first, __first + __n) by applying the functor __func to each element within the segment. | ||
| 24 | // The return value of __func is ignored, and the function returns an iterator pointing to one past the | ||
| 25 | // last processed element in the input range. | ||
| 26 | |||
| 27 | template <class _SegmentedIterator, class _Size, class _Functor> | ||
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator | ||
| 29 | __for_each_n_segment(_SegmentedIterator __first, _Size __orig_n, _Functor __func) { | ||
| 30 | static_assert(__is_segmented_iterator<_SegmentedIterator>::value && | ||
| 31 | __has_random_access_iterator_category< | ||
| 32 | typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value, | ||
| 33 | "__for_each_n_segment only works with segmented iterators with random-access local iterators"); | ||
| 34 | if (__orig_n <= 0) | ||
| 35 | return __first; | ||
| 36 | |||
| 37 | using _Traits = __segmented_iterator_traits<_SegmentedIterator>; | ||
| 38 | using __local_iter_t = typename _Traits::__local_iterator; | ||
| 39 | using __difference_t = typename std::iterator_traits<__local_iter_t>::difference_type; | ||
| 40 | __difference_t __n = __orig_n; | ||
| 41 | auto __seg = _Traits::__segment(__first); | ||
| 42 | auto __local_first = _Traits::__local(__first); | ||
| 43 | __local_iter_t __local_last; | ||
| 44 | |||
| 45 | while (__n > 0) { | ||
| 46 | __local_last = _Traits::__end(__seg); | ||
| 47 | auto __seg_size = __local_last - __local_first; | ||
| 48 | if (__n <= __seg_size) { | ||
| 49 | __local_last = __local_first + __n; | ||
| 50 | __func(__local_first, __local_last); | ||
| 51 | break; | ||
| 52 | } | ||
| 53 | __func(__local_first, __local_last); | ||
| 54 | __n -= __seg_size; | ||
| 55 | __local_first = _Traits::__begin(++__seg); | ||
| 56 | } | ||
| 57 | |||
| 58 | return _Traits::__compose(__seg, __local_last); | ||
| 59 | } | ||
| 60 | |||
| 61 | _LIBCPP_END_NAMESPACE_STD | ||
| 62 | |||
| 63 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_N_SEGMENT_H | ||
lib/libcxx/include/__algorithm/inplace_merge.h+6-5| ... | @@ -22,6 +22,7 @@ | ... | @@ -22,6 +22,7 @@ |
| 22 | #include <__functional/identity.h> | 22 | #include <__functional/identity.h> |
| 23 | #include <__iterator/iterator_traits.h> | 23 | #include <__iterator/iterator_traits.h> |
| 24 | #include <__iterator/reverse_iterator.h> | 24 | #include <__iterator/reverse_iterator.h> |
| 25 | #include <__memory/construct_at.h> | ||
| 25 | #include <__memory/destruct_n.h> | 26 | #include <__memory/destruct_n.h> |
| 26 | #include <__memory/unique_ptr.h> | 27 | #include <__memory/unique_ptr.h> |
| 27 | #include <__memory/unique_temporary_buffer.h> | 28 | #include <__memory/unique_temporary_buffer.h> |
| ... | @@ -106,13 +107,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __buffered_inplace_merg | ... | @@ -106,13 +107,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __buffered_inplace_merg |
| 106 | value_type* __p = __buff; | 107 | value_type* __p = __buff; |
| 107 | for (_BidirectionalIterator __i = __first; __i != __middle; | 108 | for (_BidirectionalIterator __i = __first; __i != __middle; |
| 108 | __d.template __incr<value_type>(), (void)++__i, (void)++__p) | 109 | __d.template __incr<value_type>(), (void)++__i, (void)++__p) |
| 109 | ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); | 110 | std::__construct_at(__p, _IterOps<_AlgPolicy>::__iter_move(__i)); |
| 110 | std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp); | 111 | std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp); |
| 111 | } else { | 112 | } else { |
| 112 | value_type* __p = __buff; | 113 | value_type* __p = __buff; |
| 113 | for (_BidirectionalIterator __i = __middle; __i != __last; | 114 | for (_BidirectionalIterator __i = __middle; __i != __last; |
| 114 | __d.template __incr<value_type>(), (void)++__i, (void)++__p) | 115 | __d.template __incr<value_type>(), (void)++__i, (void)++__p) |
| 115 | ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); | 116 | std::__construct_at(__p, _IterOps<_AlgPolicy>::__iter_move(__i)); |
| 116 | typedef reverse_iterator<_BidirectionalIterator> _RBi; | 117 | typedef reverse_iterator<_BidirectionalIterator> _RBi; |
| 117 | typedef reverse_iterator<value_type*> _Rv; | 118 | typedef reverse_iterator<value_type*> _Rv; |
| 118 | typedef __invert<_Compare> _Inverted; | 119 | typedef __invert<_Compare> _Inverted; |
| ... | @@ -203,7 +204,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge( | ... | @@ -203,7 +204,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge( |
| 203 | } | 204 | } |
| 204 | 205 | ||
| 205 | template <class _AlgPolicy, class _BidirectionalIterator, class _Compare> | 206 | template <class _AlgPolicy, class _BidirectionalIterator, class _Compare> |
| 206 | _LIBCPP_HIDE_FROM_ABI void __inplace_merge( | 207 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge( |
| 207 | _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) { | 208 | _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) { |
| 208 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | 209 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; |
| 209 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; | 210 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; |
| ... | @@ -223,14 +224,14 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge( | ... | @@ -223,14 +224,14 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge( |
| 223 | } | 224 | } |
| 224 | 225 | ||
| 225 | template <class _BidirectionalIterator, class _Compare> | 226 | template <class _BidirectionalIterator, class _Compare> |
| 226 | inline _LIBCPP_HIDE_FROM_ABI void inplace_merge( | 227 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void inplace_merge( |
| 227 | _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) { | 228 | _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) { |
| 228 | std::__inplace_merge<_ClassicAlgPolicy>( | 229 | std::__inplace_merge<_ClassicAlgPolicy>( |
| 229 | std::move(__first), std::move(__middle), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp)); | 230 | std::move(__first), std::move(__middle), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp)); |
| 230 | } | 231 | } |
| 231 | 232 | ||
| 232 | template <class _BidirectionalIterator> | 233 | template <class _BidirectionalIterator> |
| 233 | inline _LIBCPP_HIDE_FROM_ABI void | 234 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 234 | inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) { | 235 | inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) { |
| 235 | std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last), __less<>()); | 236 | std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last), __less<>()); |
| 236 | } | 237 | } |
lib/libcxx/include/__algorithm/min_element.h+1-1| ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | ||
| 30 | template <class _Comp, class _Iter, class _Sent, class _Proj> | 30 | template <class _Comp, class _Iter, class _Sent, class _Proj> |
| 31 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter | 31 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter |
| 32 | __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) { | 32 | __min_element(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| 33 | if (__first == __last) | 33 | if (__first == __last) |
| 34 | return __first; | 34 | return __first; |
| 35 | 35 |
lib/libcxx/include/__algorithm/move.h+10| ... | @@ -9,11 +9,13 @@ | ... | @@ -9,11 +9,13 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_H | 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_H |
| 10 | #define _LIBCPP___ALGORITHM_MOVE_H | 10 | #define _LIBCPP___ALGORITHM_MOVE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy.h> | ||
| 12 | #include <__algorithm/copy_move_common.h> | 13 | #include <__algorithm/copy_move_common.h> |
| 13 | #include <__algorithm/for_each_segment.h> | 14 | #include <__algorithm/for_each_segment.h> |
| 14 | #include <__algorithm/iterator_operations.h> | 15 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/min.h> | 16 | #include <__algorithm/min.h> |
| 16 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__fwd/bit_reference.h> | ||
| 17 | #include <__iterator/iterator_traits.h> | 19 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__iterator/segmented_iterator.h> | 20 | #include <__iterator/segmented_iterator.h> |
| 19 | #include <__type_traits/common_type.h> | 21 | #include <__type_traits/common_type.h> |
| ... | @@ -98,6 +100,14 @@ struct __move_impl { | ... | @@ -98,6 +100,14 @@ struct __move_impl { |
| 98 | } | 100 | } |
| 99 | } | 101 | } |
| 100 | 102 | ||
| 103 | template <class _Cp, bool _IsConst> | ||
| 104 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> > | ||
| 105 | operator()(__bit_iterator<_Cp, _IsConst> __first, | ||
| 106 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 107 | __bit_iterator<_Cp, false> __result) { | ||
| 108 | return std::__copy(__first, __last, __result); | ||
| 109 | } | ||
| 110 | |||
| 101 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 111 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. |
| 102 | template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0> | 112 | template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0> |
| 103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
lib/libcxx/include/__algorithm/move_backward.h+10| ... | @@ -9,10 +9,12 @@ | ... | @@ -9,10 +9,12 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H | 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
| 10 | #define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H | 10 | #define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy_backward.h> | ||
| 12 | #include <__algorithm/copy_move_common.h> | 13 | #include <__algorithm/copy_move_common.h> |
| 13 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 14 | #include <__algorithm/min.h> | 15 | #include <__algorithm/min.h> |
| 15 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__fwd/bit_reference.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__iterator/segmented_iterator.h> | 19 | #include <__iterator/segmented_iterator.h> |
| 18 | #include <__type_traits/common_type.h> | 20 | #include <__type_traits/common_type.h> |
| ... | @@ -107,6 +109,14 @@ struct __move_backward_impl { | ... | @@ -107,6 +109,14 @@ struct __move_backward_impl { |
| 107 | } | 109 | } |
| 108 | } | 110 | } |
| 109 | 111 | ||
| 112 | template <class _Cp, bool _IsConst> | ||
| 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> > | ||
| 114 | operator()(__bit_iterator<_Cp, _IsConst> __first, | ||
| 115 | __bit_iterator<_Cp, _IsConst> __last, | ||
| 116 | __bit_iterator<_Cp, false> __result) { | ||
| 117 | return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result); | ||
| 118 | } | ||
| 119 | |||
| 110 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | 120 | // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. |
| 111 | template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0> | 121 | template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0> |
| 112 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | 122 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> |
lib/libcxx/include/__algorithm/out_value_result.h created+56| ... | @@ -0,0 +1,56 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H | ||
| 11 | #define _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H | ||
| 12 | |||
| 13 | #include <__concepts/convertible_to.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__utility/move.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_PUSH_MACROS | ||
| 22 | #include <__undef_macros> | ||
| 23 | |||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 25 | |||
| 26 | #if _LIBCPP_STD_VER >= 23 | ||
| 27 | |||
| 28 | namespace ranges { | ||
| 29 | |||
| 30 | template <class _OutIter1, class _ValType1> | ||
| 31 | struct out_value_result { | ||
| 32 | _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out; | ||
| 33 | _LIBCPP_NO_UNIQUE_ADDRESS _ValType1 value; | ||
| 34 | |||
| 35 | template <class _OutIter2, class _ValType2> | ||
| 36 | requires convertible_to<const _OutIter1&, _OutIter2> && convertible_to<const _ValType1&, _ValType2> | ||
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr operator out_value_result<_OutIter2, _ValType2>() const& { | ||
| 38 | return {out, value}; | ||
| 39 | } | ||
| 40 | |||
| 41 | template <class _OutIter2, class _ValType2> | ||
| 42 | requires convertible_to<_OutIter1, _OutIter2> && convertible_to<_ValType1, _ValType2> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr operator out_value_result<_OutIter2, _ValType2>() && { | ||
| 44 | return {std::move(out), std::move(value)}; | ||
| 45 | } | ||
| 46 | }; | ||
| 47 | |||
| 48 | } // namespace ranges | ||
| 49 | |||
| 50 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 51 | |||
| 52 | _LIBCPP_END_NAMESPACE_STD | ||
| 53 | |||
| 54 | _LIBCPP_POP_MACROS | ||
| 55 | |||
| 56 | #endif // _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H | ||
lib/libcxx/include/__algorithm/radix_sort.h+111-14| ... | @@ -29,10 +29,12 @@ | ... | @@ -29,10 +29,12 @@ |
| 29 | 29 | ||
| 30 | #include <__algorithm/for_each.h> | 30 | #include <__algorithm/for_each.h> |
| 31 | #include <__algorithm/move.h> | 31 | #include <__algorithm/move.h> |
| 32 | #include <__bit/bit_cast.h> | ||
| 32 | #include <__bit/bit_log2.h> | 33 | #include <__bit/bit_log2.h> |
| 33 | #include <__bit/countl.h> | ||
| 34 | #include <__config> | 34 | #include <__config> |
| 35 | #include <__cstddef/size_t.h> | ||
| 35 | #include <__functional/identity.h> | 36 | #include <__functional/identity.h> |
| 37 | #include <__iterator/access.h> | ||
| 36 | #include <__iterator/distance.h> | 38 | #include <__iterator/distance.h> |
| 37 | #include <__iterator/iterator_traits.h> | 39 | #include <__iterator/iterator_traits.h> |
| 38 | #include <__iterator/move_iterator.h> | 40 | #include <__iterator/move_iterator.h> |
| ... | @@ -43,9 +45,12 @@ | ... | @@ -43,9 +45,12 @@ |
| 43 | #include <__type_traits/enable_if.h> | 45 | #include <__type_traits/enable_if.h> |
| 44 | #include <__type_traits/invoke.h> | 46 | #include <__type_traits/invoke.h> |
| 45 | #include <__type_traits/is_assignable.h> | 47 | #include <__type_traits/is_assignable.h> |
| 48 | #include <__type_traits/is_enum.h> | ||
| 46 | #include <__type_traits/is_integral.h> | 49 | #include <__type_traits/is_integral.h> |
| 47 | #include <__type_traits/is_unsigned.h> | 50 | #include <__type_traits/is_unsigned.h> |
| 48 | #include <__type_traits/make_unsigned.h> | 51 | #include <__type_traits/make_unsigned.h> |
| 52 | #include <__type_traits/void_t.h> | ||
| 53 | #include <__utility/declval.h> | ||
| 49 | #include <__utility/forward.h> | 54 | #include <__utility/forward.h> |
| 50 | #include <__utility/integer_sequence.h> | 55 | #include <__utility/integer_sequence.h> |
| 51 | #include <__utility/move.h> | 56 | #include <__utility/move.h> |
| ... | @@ -67,7 +72,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -67,7 +72,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 67 | #if _LIBCPP_STD_VER >= 14 | 72 | #if _LIBCPP_STD_VER >= 14 |
| 68 | 73 | ||
| 69 | template <class _InputIterator, class _OutputIterator> | 74 | template <class _InputIterator, class _OutputIterator> |
| 70 | _LIBCPP_HIDE_FROM_ABI pair<_OutputIterator, __iter_value_type<_InputIterator>> | 75 | _LIBCPP_HIDE_FROM_ABI constexpr pair<_OutputIterator, __iter_value_type<_InputIterator>> |
| 71 | __partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | 76 | __partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { |
| 72 | if (__first == __last) | 77 | if (__first == __last) |
| 73 | return {__result, 0}; | 78 | return {__result, 0}; |
| ... | @@ -109,7 +114,7 @@ struct __counting_sort_traits { | ... | @@ -109,7 +114,7 @@ struct __counting_sort_traits { |
| 109 | }; | 114 | }; |
| 110 | 115 | ||
| 111 | template <class _Radix, class _Integer> | 116 | template <class _Radix, class _Integer> |
| 112 | _LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _Integer __n) { | 117 | _LIBCPP_HIDE_FROM_ABI constexpr auto __nth_radix(size_t __radix_number, _Radix __radix, _Integer __n) { |
| 113 | static_assert(is_unsigned<_Integer>::value); | 118 | static_assert(is_unsigned<_Integer>::value); |
| 114 | using __traits = __counting_sort_traits<_Integer, _Radix>; | 119 | using __traits = __counting_sort_traits<_Integer, _Radix>; |
| 115 | 120 | ||
| ... | @@ -117,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _I | ... | @@ -117,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _I |
| 117 | } | 122 | } |
| 118 | 123 | ||
| 119 | template <class _ForwardIterator, class _Map, class _RandomAccessIterator> | 124 | template <class _ForwardIterator, class _Map, class _RandomAccessIterator> |
| 120 | _LIBCPP_HIDE_FROM_ABI void | 125 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 121 | __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) { | 126 | __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) { |
| 122 | using __value_type = __iter_value_type<_ForwardIterator>; | 127 | using __value_type = __iter_value_type<_ForwardIterator>; |
| 123 | using __traits = __counting_sort_traits<__value_type, _Map>; | 128 | using __traits = __counting_sort_traits<__value_type, _Map>; |
| ... | @@ -129,7 +134,7 @@ __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _Random | ... | @@ -129,7 +134,7 @@ __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _Random |
| 129 | } | 134 | } |
| 130 | 135 | ||
| 131 | template <class _ForwardIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2> | 136 | template <class _ForwardIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2> |
| 132 | _LIBCPP_HIDE_FROM_ABI void | 137 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 133 | __dispose(_ForwardIterator __first, | 138 | __dispose(_ForwardIterator __first, |
| 134 | _ForwardIterator __last, | 139 | _ForwardIterator __last, |
| 135 | _RandomAccessIterator1 __result, | 140 | _RandomAccessIterator1 __result, |
| ... | @@ -147,7 +152,7 @@ template <class _ForwardIterator, | ... | @@ -147,7 +152,7 @@ template <class _ForwardIterator, |
| 147 | class _RandomAccessIterator1, | 152 | class _RandomAccessIterator1, |
| 148 | class _RandomAccessIterator2, | 153 | class _RandomAccessIterator2, |
| 149 | size_t... _Radices> | 154 | size_t... _Radices> |
| 150 | _LIBCPP_HIDE_FROM_ABI bool __collect_impl( | 155 | _LIBCPP_HIDE_FROM_ABI constexpr bool __collect_impl( |
| 151 | _ForwardIterator __first, | 156 | _ForwardIterator __first, |
| 152 | _ForwardIterator __last, | 157 | _ForwardIterator __last, |
| 153 | _Map __map, | 158 | _Map __map, |
| ... | @@ -177,7 +182,7 @@ _LIBCPP_HIDE_FROM_ABI bool __collect_impl( | ... | @@ -177,7 +182,7 @@ _LIBCPP_HIDE_FROM_ABI bool __collect_impl( |
| 177 | } | 182 | } |
| 178 | 183 | ||
| 179 | template <class _ForwardIterator, class _Map, class _Radix, class _RandomAccessIterator1, class _RandomAccessIterator2> | 184 | template <class _ForwardIterator, class _Map, class _Radix, class _RandomAccessIterator1, class _RandomAccessIterator2> |
| 180 | _LIBCPP_HIDE_FROM_ABI bool | 185 | _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 181 | __collect(_ForwardIterator __first, | 186 | __collect(_ForwardIterator __first, |
| 182 | _ForwardIterator __last, | 187 | _ForwardIterator __last, |
| 183 | _Map __map, | 188 | _Map __map, |
| ... | @@ -191,7 +196,7 @@ __collect(_ForwardIterator __first, | ... | @@ -191,7 +196,7 @@ __collect(_ForwardIterator __first, |
| 191 | } | 196 | } |
| 192 | 197 | ||
| 193 | template <class _BidirectionalIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2> | 198 | template <class _BidirectionalIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2> |
| 194 | _LIBCPP_HIDE_FROM_ABI void __dispose_backward( | 199 | _LIBCPP_HIDE_FROM_ABI constexpr void __dispose_backward( |
| 195 | _BidirectionalIterator __first, | 200 | _BidirectionalIterator __first, |
| 196 | _BidirectionalIterator __last, | 201 | _BidirectionalIterator __last, |
| 197 | _RandomAccessIterator1 __result, | 202 | _RandomAccessIterator1 __result, |
| ... | @@ -206,7 +211,7 @@ _LIBCPP_HIDE_FROM_ABI void __dispose_backward( | ... | @@ -206,7 +211,7 @@ _LIBCPP_HIDE_FROM_ABI void __dispose_backward( |
| 206 | } | 211 | } |
| 207 | 212 | ||
| 208 | template <class _ForwardIterator, class _RandomAccessIterator, class _Map> | 213 | template <class _ForwardIterator, class _RandomAccessIterator, class _Map> |
| 209 | _LIBCPP_HIDE_FROM_ABI _RandomAccessIterator | 214 | _LIBCPP_HIDE_FROM_ABI constexpr _RandomAccessIterator |
| 210 | __counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) { | 215 | __counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) { |
| 211 | using __value_type = __iter_value_type<_ForwardIterator>; | 216 | using __value_type = __iter_value_type<_ForwardIterator>; |
| 212 | using __traits = __counting_sort_traits<__value_type, _Map>; | 217 | using __traits = __counting_sort_traits<__value_type, _Map>; |
| ... | @@ -225,7 +230,7 @@ template <class _RandomAccessIterator1, | ... | @@ -225,7 +230,7 @@ template <class _RandomAccessIterator1, |
| 225 | class _Radix, | 230 | class _Radix, |
| 226 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1, | 231 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1, |
| 227 | int> = 0> | 232 | int> = 0> |
| 228 | _LIBCPP_HIDE_FROM_ABI void __radix_sort_impl( | 233 | _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( |
| 229 | _RandomAccessIterator1 __first, | 234 | _RandomAccessIterator1 __first, |
| 230 | _RandomAccessIterator1 __last, | 235 | _RandomAccessIterator1 __last, |
| 231 | _RandomAccessIterator2 __buffer, | 236 | _RandomAccessIterator2 __buffer, |
| ... | @@ -245,7 +250,7 @@ template < | ... | @@ -245,7 +250,7 @@ template < |
| 245 | class _Radix, | 250 | class _Radix, |
| 246 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0, | 251 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0, |
| 247 | int> = 0 > | 252 | int> = 0 > |
| 248 | _LIBCPP_HIDE_FROM_ABI void __radix_sort_impl( | 253 | _LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl( |
| 249 | _RandomAccessIterator1 __first, | 254 | _RandomAccessIterator1 __first, |
| 250 | _RandomAccessIterator1 __last, | 255 | _RandomAccessIterator1 __last, |
| 251 | _RandomAccessIterator2 __buffer_begin, | 256 | _RandomAccessIterator2 __buffer_begin, |
| ... | @@ -297,6 +302,96 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(_Ip __n) { | ... | @@ -297,6 +302,96 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(_Ip __n) { |
| 297 | return static_cast<make_unsigned_t<_Ip> >(__n ^ __min_value); | 302 | return static_cast<make_unsigned_t<_Ip> >(__n ^ __min_value); |
| 298 | } | 303 | } |
| 299 | 304 | ||
| 305 | template <size_t _Size> | ||
| 306 | struct __unsigned_integer_of_size; | ||
| 307 | |||
| 308 | template <> | ||
| 309 | struct __unsigned_integer_of_size<1> { | ||
| 310 | using type _LIBCPP_NODEBUG = uint8_t; | ||
| 311 | }; | ||
| 312 | |||
| 313 | template <> | ||
| 314 | struct __unsigned_integer_of_size<2> { | ||
| 315 | using type _LIBCPP_NODEBUG = uint16_t; | ||
| 316 | }; | ||
| 317 | |||
| 318 | template <> | ||
| 319 | struct __unsigned_integer_of_size<4> { | ||
| 320 | using type _LIBCPP_NODEBUG = uint32_t; | ||
| 321 | }; | ||
| 322 | |||
| 323 | template <> | ||
| 324 | struct __unsigned_integer_of_size<8> { | ||
| 325 | using type _LIBCPP_NODEBUG = uint64_t; | ||
| 326 | }; | ||
| 327 | |||
| 328 | # if _LIBCPP_HAS_INT128 | ||
| 329 | template <> | ||
| 330 | struct __unsigned_integer_of_size<16> { | ||
| 331 | using type _LIBCPP_NODEBUG = unsigned __int128; | ||
| 332 | }; | ||
| 333 | # endif | ||
| 334 | |||
| 335 | template <size_t _Size> | ||
| 336 | using __unsigned_integer_of_size_t _LIBCPP_NODEBUG = typename __unsigned_integer_of_size<_Size>::type; | ||
| 337 | |||
| 338 | template <class _Sc> | ||
| 339 | using __unsigned_representation_for_t _LIBCPP_NODEBUG = __unsigned_integer_of_size_t<sizeof(_Sc)>; | ||
| 340 | |||
| 341 | // The function `__to_ordered_integral` is defined for integers and IEEE 754 floating-point numbers. | ||
| 342 | // Returns an integer representation such that for any `x` and `y` such that `x < y`, the expression | ||
| 343 | // `__to_ordered_integral(x) < __to_ordered_integral(y)` is true, where `x`, `y` are integers or IEEE 754 floats. | ||
| 344 | template <class _Integral, enable_if_t< is_integral<_Integral>::value, int> = 0> | ||
| 345 | _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Integral __n) { | ||
| 346 | return __n; | ||
| 347 | } | ||
| 348 | |||
| 349 | // An overload for IEEE 754 floating-point numbers | ||
| 350 | |||
| 351 | // For the floats conforming to IEEE 754 (IEC 559) standard, we know that: | ||
| 352 | // 1. The bit representation of positive floats directly reflects their order: | ||
| 353 | // When comparing floats by magnitude, the number with the larger exponent is greater, and if the exponents are | ||
| 354 | // equal, the one with the larger mantissa is greater. | ||
| 355 | // 2. The bit representation of negative floats reflects their reverse order (for the same reasons). | ||
| 356 | // 3. The most significant bit (sign bit) is zero for positive floats and one for negative floats. Therefore, in the raw | ||
| 357 | // bit representation, any negative number will be greater than any positive number. | ||
| 358 | |||
| 359 | // The only exception from this rule is `NaN`, which is unordered by definition. | ||
| 360 | |||
| 361 | // Based on the above, to obtain correctly ordered integral representation of floating-point numbers, we need to: | ||
| 362 | // 1. Invert the bit representation (including the sign bit) of negative floats to switch from reverse order to direct | ||
| 363 | // order; | ||
| 364 | // 2. Invert the sign bit for positive floats. | ||
| 365 | |||
| 366 | // Thus, in final integral representation, we have reversed the order for negative floats and made all negative floats | ||
| 367 | // smaller than all positive numbers (by inverting the sign bit). | ||
| 368 | template <class _Floating, enable_if_t< numeric_limits<_Floating>::is_iec559, int> = 0> | ||
| 369 | _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Floating __f) { | ||
| 370 | using __integral_type = __unsigned_representation_for_t<_Floating>; | ||
| 371 | constexpr auto __bit_count = std::numeric_limits<__integral_type>::digits; | ||
| 372 | constexpr auto __sign_bit_mask = static_cast<__integral_type>(__integral_type{1} << (__bit_count - 1)); | ||
| 373 | |||
| 374 | const auto __u = std::__bit_cast<__integral_type>(__f); | ||
| 375 | |||
| 376 | return static_cast<__integral_type>(__u & __sign_bit_mask ? ~__u : __u ^ __sign_bit_mask); | ||
| 377 | } | ||
| 378 | |||
| 379 | // There may exist user-defined comparison for enum, so we cannot compare enums just like integers. | ||
| 380 | template <class _Enum, enable_if_t< is_enum<_Enum>::value, int> = 0> | ||
| 381 | _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Enum __e) = delete; | ||
| 382 | |||
| 383 | // `long double` varies significantly across platforms and compilers, making it practically | ||
| 384 | // impossible to determine its actual bit width for conversion to an ordered integer. | ||
| 385 | inline _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(long double) = delete; | ||
| 386 | |||
| 387 | template <class _Tp, class = void> | ||
| 388 | inline const bool __is_ordered_integer_representable_v = false; | ||
| 389 | |||
| 390 | template <class _Tp> | ||
| 391 | inline const bool | ||
| 392 | __is_ordered_integer_representable_v<_Tp, __void_t<decltype(std::__to_ordered_integral(std::declval<_Tp>()))>> = | ||
| 393 | true; | ||
| 394 | |||
| 300 | struct __low_byte_fn { | 395 | struct __low_byte_fn { |
| 301 | template <class _Ip> | 396 | template <class _Ip> |
| 302 | _LIBCPP_HIDE_FROM_ABI constexpr uint8_t operator()(_Ip __integer) const { | 397 | _LIBCPP_HIDE_FROM_ABI constexpr uint8_t operator()(_Ip __integer) const { |
| ... | @@ -307,18 +402,20 @@ struct __low_byte_fn { | ... | @@ -307,18 +402,20 @@ struct __low_byte_fn { |
| 307 | }; | 402 | }; |
| 308 | 403 | ||
| 309 | template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _Map, class _Radix> | 404 | template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _Map, class _Radix> |
| 310 | _LIBCPP_HIDE_FROM_ABI void | 405 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 311 | __radix_sort(_RandomAccessIterator1 __first, | 406 | __radix_sort(_RandomAccessIterator1 __first, |
| 312 | _RandomAccessIterator1 __last, | 407 | _RandomAccessIterator1 __last, |
| 313 | _RandomAccessIterator2 __buffer, | 408 | _RandomAccessIterator2 __buffer, |
| 314 | _Map __map, | 409 | _Map __map, |
| 315 | _Radix __radix) { | 410 | _Radix __radix) { |
| 316 | auto __map_to_unsigned = [__map = std::move(__map)](const auto& __x) { return std::__shift_to_unsigned(__map(__x)); }; | 411 | auto __map_to_unsigned = [__map = std::move(__map)](const auto& __x) { |
| 412 | return std::__shift_to_unsigned(__map(std::__to_ordered_integral(__x))); | ||
| 413 | }; | ||
| 317 | std::__radix_sort_impl(__first, __last, __buffer, __map_to_unsigned, __radix); | 414 | std::__radix_sort_impl(__first, __last, __buffer, __map_to_unsigned, __radix); |
| 318 | } | 415 | } |
| 319 | 416 | ||
| 320 | template <class _RandomAccessIterator1, class _RandomAccessIterator2> | 417 | template <class _RandomAccessIterator1, class _RandomAccessIterator2> |
| 321 | _LIBCPP_HIDE_FROM_ABI void | 418 | _LIBCPP_HIDE_FROM_ABI constexpr void |
| 322 | __radix_sort(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __buffer) { | 419 | __radix_sort(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __buffer) { |
| 323 | std::__radix_sort(__first, __last, __buffer, __identity{}, __low_byte_fn{}); | 420 | std::__radix_sort(__first, __last, __buffer, __identity{}, __low_byte_fn{}); |
| 324 | } | 421 | } |
lib/libcxx/include/__algorithm/ranges_for_each.h+14-4| ... | @@ -9,10 +9,12 @@ | ... | @@ -9,10 +9,12 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/for_each.h> | ||
| 13 | #include <__algorithm/for_each_n.h> | ||
| 12 | #include <__algorithm/in_fun_result.h> | 14 | #include <__algorithm/in_fun_result.h> |
| 15 | #include <__concepts/assignable.h> | ||
| 13 | #include <__config> | 16 | #include <__config> |
| 14 | #include <__functional/identity.h> | 17 | #include <__functional/identity.h> |
| 15 | #include <__functional/invoke.h> | ||
| 16 | #include <__iterator/concepts.h> | 18 | #include <__iterator/concepts.h> |
| 17 | #include <__iterator/projected.h> | 19 | #include <__iterator/projected.h> |
| 18 | #include <__ranges/access.h> | 20 | #include <__ranges/access.h> |
| ... | @@ -41,9 +43,17 @@ private: | ... | @@ -41,9 +43,17 @@ private: |
| 41 | template <class _Iter, class _Sent, class _Proj, class _Func> | 43 | template <class _Iter, class _Sent, class _Proj, class _Func> |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func> | 44 | _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func> |
| 43 | __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) { | 45 | __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) { |
| 44 | for (; __first != __last; ++__first) | 46 | // In the case where we have different iterator and sentinel types, the segmented iterator optimization |
| 45 | std::invoke(__func, std::invoke(__proj, *__first)); | 47 | // in std::for_each will not kick in. Therefore, we prefer std::for_each_n in that case (whenever we can |
| 46 | return {std::move(__first), std::move(__func)}; | 48 | // obtain the `n`). |
| 49 | if constexpr (!std::assignable_from<_Iter&, _Sent> && std::sized_sentinel_for<_Sent, _Iter>) { | ||
| 50 | auto __n = __last - __first; | ||
| 51 | auto __end = std::__for_each_n(std::move(__first), __n, __func, __proj); | ||
| 52 | return {std::move(__end), std::move(__func)}; | ||
| 53 | } else { | ||
| 54 | auto __end = std::__for_each(std::move(__first), std::move(__last), __func, __proj); | ||
| 55 | return {std::move(__end), std::move(__func)}; | ||
| 56 | } | ||
| 47 | } | 57 | } |
| 48 | 58 | ||
| 49 | public: | 59 | public: |
lib/libcxx/include/__algorithm/ranges_for_each_n.h+3-6| ... | @@ -9,10 +9,10 @@ | ... | @@ -9,10 +9,10 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/for_each_n.h> | ||
| 12 | #include <__algorithm/in_fun_result.h> | 13 | #include <__algorithm/in_fun_result.h> |
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__functional/identity.h> | 15 | #include <__functional/identity.h> |
| 15 | #include <__functional/invoke.h> | ||
| 16 | #include <__iterator/concepts.h> | 16 | #include <__iterator/concepts.h> |
| 17 | #include <__iterator/incrementable_traits.h> | 17 | #include <__iterator/incrementable_traits.h> |
| 18 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| ... | @@ -40,11 +40,8 @@ struct __for_each_n { | ... | @@ -40,11 +40,8 @@ struct __for_each_n { |
| 40 | template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> | 40 | template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func> | 41 | _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func> |
| 42 | operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const { | 42 | operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const { |
| 43 | while (__count-- > 0) { | 43 | auto __last = std::__for_each_n(std::move(__first), __count, __func, __proj); |
| 44 | std::invoke(__func, std::invoke(__proj, *__first)); | 44 | return {std::move(__last), std::move(__func)}; |
| 45 | ++__first; | ||
| 46 | } | ||
| 47 | return {std::move(__first), std::move(__func)}; | ||
| 48 | } | 45 | } |
| 49 | }; | 46 | }; |
| 50 | 47 |
lib/libcxx/include/__algorithm/ranges_inplace_merge.h+3-3| ... | @@ -41,7 +41,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -41,7 +41,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | namespace ranges { | 41 | namespace ranges { |
| 42 | struct __inplace_merge { | 42 | struct __inplace_merge { |
| 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> | 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 44 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | 44 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX26 auto |
| 45 | __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) { | 45 | __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) { |
| 46 | auto __last_iter = ranges::next(__middle, __last); | 46 | auto __last_iter = ranges::next(__middle, __last); |
| 47 | std::__inplace_merge<_RangeAlgPolicy>( | 47 | std::__inplace_merge<_RangeAlgPolicy>( |
| ... | @@ -51,7 +51,7 @@ struct __inplace_merge { | ... | @@ -51,7 +51,7 @@ struct __inplace_merge { |
| 51 | 51 | ||
| 52 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | 52 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> |
| 53 | requires sortable<_Iter, _Comp, _Proj> | 53 | requires sortable<_Iter, _Comp, _Proj> |
| 54 | _LIBCPP_HIDE_FROM_ABI _Iter | 54 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Iter |
| 55 | operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | 55 | operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 56 | return __inplace_merge_impl( | 56 | return __inplace_merge_impl( |
| 57 | std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj)); | 57 | std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj)); |
| ... | @@ -59,7 +59,7 @@ struct __inplace_merge { | ... | @@ -59,7 +59,7 @@ struct __inplace_merge { |
| 59 | 59 | ||
| 60 | template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity> | 60 | template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity> |
| 61 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | 61 | requires sortable<iterator_t<_Range>, _Comp, _Proj> |
| 62 | _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range> | 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_Range> |
| 63 | operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const { | 63 | operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const { |
| 64 | return __inplace_merge_impl( | 64 | return __inplace_merge_impl( |
| 65 | ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj)); | 65 | ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj)); |
lib/libcxx/include/__algorithm/ranges_iterator_concept.h+1-1| ... | @@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() { | ... | @@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() { |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | template <class _Iter> | 46 | template <class _Iter> |
| 47 | using __iterator_concept _LIBCPP_NODEBUG = decltype(__get_iterator_concept<_Iter>()); | 47 | using __iterator_concept _LIBCPP_NODEBUG = decltype(ranges::__get_iterator_concept<_Iter>()); |
| 48 | 48 | ||
| 49 | } // namespace ranges | 49 | } // namespace ranges |
| 50 | _LIBCPP_END_NAMESPACE_STD | 50 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/ranges_max.h+3-3| ... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MAX_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MAX_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MAX_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_MAX_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/ranges_min_element.h> | 12 | #include <__algorithm/min_element.h> |
| 13 | #include <__assert> | 13 | #include <__assert> |
| 14 | #include <__concepts/copyable.h> | 14 | #include <__concepts/copyable.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| ... | @@ -57,7 +57,7 @@ struct __max { | ... | @@ -57,7 +57,7 @@ struct __max { |
| 57 | __il.begin() != __il.end(), "initializer_list must contain at least one element"); | 57 | __il.begin() != __il.end(), "initializer_list must contain at least one element"); |
| 58 | 58 | ||
| 59 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; | 59 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; |
| 60 | return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj); | 60 | return *std::__min_element(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | template <input_range _Rp, | 63 | template <input_range _Rp, |
| ... | @@ -75,7 +75,7 @@ struct __max { | ... | @@ -75,7 +75,7 @@ struct __max { |
| 75 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { | 75 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { |
| 76 | return std::invoke(__comp, __rhs, __lhs); | 76 | return std::invoke(__comp, __rhs, __lhs); |
| 77 | }; | 77 | }; |
| 78 | return *ranges::__min_element_impl(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj); | 78 | return *std::__min_element(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj); |
| 79 | } else { | 79 | } else { |
| 80 | range_value_t<_Rp> __result = *__first; | 80 | range_value_t<_Rp> __result = *__first; |
| 81 | while (++__first != __last) { | 81 | while (++__first != __last) { |
lib/libcxx/include/__algorithm/ranges_max_element.h+3-3| ... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/ranges_min_element.h> | 12 | #include <__algorithm/min_element.h> |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__functional/identity.h> | 14 | #include <__functional/identity.h> |
| 15 | #include <__functional/invoke.h> | 15 | #include <__functional/invoke.h> |
| ... | @@ -40,7 +40,7 @@ struct __max_element { | ... | @@ -40,7 +40,7 @@ struct __max_element { |
| 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip |
| 41 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | 41 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 42 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; | 42 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; |
| 43 | return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj); | 43 | return std::__min_element(__first, __last, __comp_lhs_rhs_swapped, __proj); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | template <forward_range _Rp, | 46 | template <forward_range _Rp, |
| ... | @@ -49,7 +49,7 @@ struct __max_element { | ... | @@ -49,7 +49,7 @@ struct __max_element { |
| 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> |
| 50 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 50 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 51 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; | 51 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); }; |
| 52 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); | 52 | return std::__min_element(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); |
| 53 | } | 53 | } |
| 54 | }; | 54 | }; |
| 55 | 55 |
lib/libcxx/include/__algorithm/ranges_min.h+3-3| ... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MIN_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MIN_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MIN_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_MIN_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/ranges_min_element.h> | 12 | #include <__algorithm/min_element.h> |
| 13 | #include <__assert> | 13 | #include <__assert> |
| 14 | #include <__concepts/copyable.h> | 14 | #include <__concepts/copyable.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| ... | @@ -54,7 +54,7 @@ struct __min { | ... | @@ -54,7 +54,7 @@ struct __min { |
| 54 | operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { | 54 | operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { |
| 55 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | 55 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( |
| 56 | __il.begin() != __il.end(), "initializer_list must contain at least one element"); | 56 | __il.begin() != __il.end(), "initializer_list must contain at least one element"); |
| 57 | return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj); | 57 | return *std::__min_element(__il.begin(), __il.end(), __comp, __proj); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | template <input_range _Rp, | 60 | template <input_range _Rp, |
| ... | @@ -67,7 +67,7 @@ struct __min { | ... | @@ -67,7 +67,7 @@ struct __min { |
| 67 | auto __last = ranges::end(__r); | 67 | auto __last = ranges::end(__r); |
| 68 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element"); | 68 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element"); |
| 69 | if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) { | 69 | if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) { |
| 70 | return *ranges::__min_element_impl(__first, __last, __comp, __proj); | 70 | return *std::__min_element(__first, __last, __comp, __proj); |
| 71 | } else { | 71 | } else { |
| 72 | range_value_t<_Rp> __result = *__first; | 72 | range_value_t<_Rp> __result = *__first; |
| 73 | while (++__first != __last) { | 73 | while (++__first != __last) { |
lib/libcxx/include/__algorithm/ranges_min_element.h+3-16| ... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/min_element.h> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 13 | #include <__functional/identity.h> | 14 | #include <__functional/identity.h> |
| 14 | #include <__functional/invoke.h> | 15 | #include <__functional/invoke.h> |
| ... | @@ -32,20 +33,6 @@ _LIBCPP_PUSH_MACROS | ... | @@ -32,20 +33,6 @@ _LIBCPP_PUSH_MACROS |
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 34 | ||
| 34 | namespace ranges { | 35 | namespace ranges { |
| 35 | |||
| 36 | // TODO(ranges): `ranges::min_element` can now simply delegate to `std::__min_element`. | ||
| 37 | template <class _Ip, class _Sp, class _Proj, class _Comp> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip __min_element_impl(_Ip __first, _Sp __last, _Comp& __comp, _Proj& __proj) { | ||
| 39 | if (__first == __last) | ||
| 40 | return __first; | ||
| 41 | |||
| 42 | _Ip __i = __first; | ||
| 43 | while (++__i != __last) | ||
| 44 | if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first))) | ||
| 45 | __first = __i; | ||
| 46 | return __first; | ||
| 47 | } | ||
| 48 | |||
| 49 | struct __min_element { | 36 | struct __min_element { |
| 50 | template <forward_iterator _Ip, | 37 | template <forward_iterator _Ip, |
| 51 | sentinel_for<_Ip> _Sp, | 38 | sentinel_for<_Ip> _Sp, |
| ... | @@ -53,7 +40,7 @@ struct __min_element { | ... | @@ -53,7 +40,7 @@ struct __min_element { |
| 53 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> | 40 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> |
| 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip | 41 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip |
| 55 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | 42 | operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { |
| 56 | return ranges::__min_element_impl(__first, __last, __comp, __proj); | 43 | return std::__min_element(__first, __last, __comp, __proj); |
| 57 | } | 44 | } |
| 58 | 45 | ||
| 59 | template <forward_range _Rp, | 46 | template <forward_range _Rp, |
| ... | @@ -61,7 +48,7 @@ struct __min_element { | ... | @@ -61,7 +48,7 @@ struct __min_element { |
| 61 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | 48 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> |
| 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> |
| 63 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 50 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 64 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | 51 | return std::__min_element(ranges::begin(__r), ranges::end(__r), __comp, __proj); |
| 65 | } | 52 | } |
| 66 | }; | 53 | }; |
| 67 | 54 |
lib/libcxx/include/__algorithm/ranges_stable_partition.h+4-3| ... | @@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 44 | namespace ranges { | 44 | namespace ranges { |
| 45 | struct __stable_partition { | 45 | struct __stable_partition { |
| 46 | template <class _Iter, class _Sent, class _Proj, class _Pred> | 46 | template <class _Iter, class _Sent, class _Proj, class _Pred> |
| 47 | _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>> | 47 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX26 subrange<__remove_cvref_t<_Iter>> |
| 48 | __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { | 48 | __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { |
| 49 | auto __last_iter = ranges::next(__first, __last); | 49 | auto __last_iter = ranges::next(__first, __last); |
| 50 | 50 | ||
| ... | @@ -60,7 +60,8 @@ struct __stable_partition { | ... | @@ -60,7 +60,8 @@ struct __stable_partition { |
| 60 | class _Proj = identity, | 60 | class _Proj = identity, |
| 61 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | 61 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
| 62 | requires permutable<_Iter> | 62 | requires permutable<_Iter> |
| 63 | _LIBCPP_HIDE_FROM_ABI subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 subrange<_Iter> |
| 64 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | ||
| 64 | return __stable_partition_fn_impl(__first, __last, __pred, __proj); | 65 | return __stable_partition_fn_impl(__first, __last, __pred, __proj); |
| 65 | } | 66 | } |
| 66 | 67 | ||
| ... | @@ -68,7 +69,7 @@ struct __stable_partition { | ... | @@ -68,7 +69,7 @@ struct __stable_partition { |
| 68 | class _Proj = identity, | 69 | class _Proj = identity, |
| 69 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | 70 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 70 | requires permutable<iterator_t<_Range>> | 71 | requires permutable<iterator_t<_Range>> |
| 71 | _LIBCPP_HIDE_FROM_ABI borrowed_subrange_t<_Range> | 72 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_subrange_t<_Range> |
| 72 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | 73 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 73 | return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | 74 | return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 74 | } | 75 | } |
lib/libcxx/include/__algorithm/ranges_stable_sort.h+5-3| ... | @@ -41,7 +41,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -41,7 +41,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | namespace ranges { | 41 | namespace ranges { |
| 42 | struct __stable_sort { | 42 | struct __stable_sort { |
| 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> | 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 44 | _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | 44 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX26 _Iter |
| 45 | __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | ||
| 45 | auto __last_iter = ranges::next(__first, __last); | 46 | auto __last_iter = ranges::next(__first, __last); |
| 46 | 47 | ||
| 47 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | 48 | auto&& __projected_comp = std::__make_projected(__comp, __proj); |
| ... | @@ -52,13 +53,14 @@ struct __stable_sort { | ... | @@ -52,13 +53,14 @@ struct __stable_sort { |
| 52 | 53 | ||
| 53 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | 54 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> |
| 54 | requires sortable<_Iter, _Comp, _Proj> | 55 | requires sortable<_Iter, _Comp, _Proj> |
| 55 | _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | 56 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Iter |
| 57 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | ||
| 56 | return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | 58 | return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj); |
| 57 | } | 59 | } |
| 58 | 60 | ||
| 59 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | 61 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> |
| 60 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | 62 | requires sortable<iterator_t<_Range>, _Comp, _Proj> |
| 61 | _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range> | 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_Range> |
| 62 | operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | 64 | operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { |
| 63 | return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | 65 | return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); |
| 64 | } | 66 | } |
lib/libcxx/include/__algorithm/rotate.h+45| ... | @@ -9,12 +9,19 @@ | ... | @@ -9,12 +9,19 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_ROTATE_H | 9 | #ifndef _LIBCPP___ALGORITHM_ROTATE_H |
| 10 | #define _LIBCPP___ALGORITHM_ROTATE_H | 10 | #define _LIBCPP___ALGORITHM_ROTATE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy.h> | ||
| 13 | #include <__algorithm/copy_backward.h> | ||
| 12 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| 13 | #include <__algorithm/move.h> | 15 | #include <__algorithm/move.h> |
| 14 | #include <__algorithm/move_backward.h> | 16 | #include <__algorithm/move_backward.h> |
| 15 | #include <__algorithm/swap_ranges.h> | 17 | #include <__algorithm/swap_ranges.h> |
| 16 | #include <__config> | 18 | #include <__config> |
| 19 | #include <__cstddef/size_t.h> | ||
| 20 | #include <__fwd/bit_reference.h> | ||
| 17 | #include <__iterator/iterator_traits.h> | 21 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__memory/construct_at.h> | ||
| 23 | #include <__memory/pointer_traits.h> | ||
| 24 | #include <__type_traits/is_constant_evaluated.h> | ||
| 18 | #include <__type_traits/is_trivially_assignable.h> | 25 | #include <__type_traits/is_trivially_assignable.h> |
| 19 | #include <__utility/move.h> | 26 | #include <__utility/move.h> |
| 20 | #include <__utility/pair.h> | 27 | #include <__utility/pair.h> |
| ... | @@ -185,6 +192,44 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) { | ... | @@ -185,6 +192,44 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) { |
| 185 | return _Ret(std::move(__result), std::move(__last_iter)); | 192 | return _Ret(std::move(__result), std::move(__last_iter)); |
| 186 | } | 193 | } |
| 187 | 194 | ||
| 195 | template <class, class _Cp> | ||
| 196 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, false>, __bit_iterator<_Cp, false> > | ||
| 197 | __rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) { | ||
| 198 | using _I1 = __bit_iterator<_Cp, false>; | ||
| 199 | using difference_type = typename _I1::difference_type; | ||
| 200 | difference_type __d1 = __middle - __first; | ||
| 201 | difference_type __d2 = __last - __middle; | ||
| 202 | _I1 __r = __first + __d2; | ||
| 203 | while (__d1 != 0 && __d2 != 0) { | ||
| 204 | if (__d1 <= __d2) { | ||
| 205 | if (__d1 <= __bit_array<_Cp>::capacity()) { | ||
| 206 | __bit_array<_Cp> __b(__d1); | ||
| 207 | std::copy(__first, __middle, __b.begin()); | ||
| 208 | std::copy(__b.begin(), __b.end(), std::copy(__middle, __last, __first)); | ||
| 209 | break; | ||
| 210 | } else { | ||
| 211 | __bit_iterator<_Cp, false> __mp = std::swap_ranges(__first, __middle, __middle); | ||
| 212 | __first = __middle; | ||
| 213 | __middle = __mp; | ||
| 214 | __d2 -= __d1; | ||
| 215 | } | ||
| 216 | } else { | ||
| 217 | if (__d2 <= __bit_array<_Cp>::capacity()) { | ||
| 218 | __bit_array<_Cp> __b(__d2); | ||
| 219 | std::copy(__middle, __last, __b.begin()); | ||
| 220 | std::copy_backward(__b.begin(), __b.end(), std::copy_backward(__first, __middle, __last)); | ||
| 221 | break; | ||
| 222 | } else { | ||
| 223 | __bit_iterator<_Cp, false> __mp = __first + __d2; | ||
| 224 | std::swap_ranges(__first, __mp, __middle); | ||
| 225 | __first = __mp; | ||
| 226 | __d1 -= __d2; | ||
| 227 | } | ||
| 228 | } | ||
| 229 | } | ||
| 230 | return std::make_pair(__r, __last); | ||
| 231 | } | ||
| 232 | |||
| 188 | template <class _ForwardIterator> | 233 | template <class _ForwardIterator> |
| 189 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | 234 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator |
| 190 | rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) { | 235 | rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) { |
lib/libcxx/include/__algorithm/simd_utils.h+8-8| ... | @@ -15,8 +15,6 @@ | ... | @@ -15,8 +15,6 @@ |
| 15 | #include <__bit/countr.h> | 15 | #include <__bit/countr.h> |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__cstddef/size_t.h> | 17 | #include <__cstddef/size_t.h> |
| 18 | #include <__type_traits/is_arithmetic.h> | ||
| 19 | #include <__type_traits/is_same.h> | ||
| 20 | #include <__utility/integer_sequence.h> | 18 | #include <__utility/integer_sequence.h> |
| 21 | #include <cstdint> | 19 | #include <cstdint> |
| 22 | 20 | ||
| ... | @@ -28,7 +26,9 @@ _LIBCPP_PUSH_MACROS | ... | @@ -28,7 +26,9 @@ _LIBCPP_PUSH_MACROS |
| 28 | #include <__undef_macros> | 26 | #include <__undef_macros> |
| 29 | 27 | ||
| 30 | // TODO: Find out how altivec changes things and allow vectorizations there too. | 28 | // TODO: Find out how altivec changes things and allow vectorizations there too. |
| 31 | #if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_CLANG_VER) && !defined(__ALTIVEC__) | 29 | // TODO: Simplify this condition once we stop building with AppleClang 15 in the CI. |
| 30 | #if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(__ALTIVEC__) && \ | ||
| 31 | !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600) | ||
| 32 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1 | 32 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1 |
| 33 | #else | 33 | #else |
| 34 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0 | 34 | # define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0 |
| ... | @@ -53,20 +53,20 @@ struct __get_as_integer_type_impl; | ... | @@ -53,20 +53,20 @@ struct __get_as_integer_type_impl; |
| 53 | 53 | ||
| 54 | template <> | 54 | template <> |
| 55 | struct __get_as_integer_type_impl<1> { | 55 | struct __get_as_integer_type_impl<1> { |
| 56 | using type = uint8_t; | 56 | using type _LIBCPP_NODEBUG = uint8_t; |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | template <> | 59 | template <> |
| 60 | struct __get_as_integer_type_impl<2> { | 60 | struct __get_as_integer_type_impl<2> { |
| 61 | using type = uint16_t; | 61 | using type _LIBCPP_NODEBUG = uint16_t; |
| 62 | }; | 62 | }; |
| 63 | template <> | 63 | template <> |
| 64 | struct __get_as_integer_type_impl<4> { | 64 | struct __get_as_integer_type_impl<4> { |
| 65 | using type = uint32_t; | 65 | using type _LIBCPP_NODEBUG = uint32_t; |
| 66 | }; | 66 | }; |
| 67 | template <> | 67 | template <> |
| 68 | struct __get_as_integer_type_impl<8> { | 68 | struct __get_as_integer_type_impl<8> { |
| 69 | using type = uint64_t; | 69 | using type _LIBCPP_NODEBUG = uint64_t; |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | template <class _Tp> | 72 | template <class _Tp> |
| ... | @@ -78,7 +78,7 @@ using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_i | ... | @@ -78,7 +78,7 @@ using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_i |
| 78 | # if defined(__AVX__) || defined(__MVS__) | 78 | # if defined(__AVX__) || defined(__MVS__) |
| 79 | template <class _Tp> | 79 | template <class _Tp> |
| 80 | inline constexpr size_t __native_vector_size = 32 / sizeof(_Tp); | 80 | inline constexpr size_t __native_vector_size = 32 / sizeof(_Tp); |
| 81 | # elif defined(__SSE__) || defined(__ARM_NEON__) | 81 | # elif defined(__SSE__) || defined(__ARM_NEON) |
| 82 | template <class _Tp> | 82 | template <class _Tp> |
| 83 | inline constexpr size_t __native_vector_size = 16 / sizeof(_Tp); | 83 | inline constexpr size_t __native_vector_size = 16 / sizeof(_Tp); |
| 84 | # elif defined(__MMX__) | 84 | # elif defined(__MMX__) |
lib/libcxx/include/__algorithm/sort.h+10-29| ... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
| 17 | #include <__algorithm/partial_sort.h> | 17 | #include <__algorithm/partial_sort.h> |
| 18 | #include <__algorithm/unwrap_iter.h> | 18 | #include <__algorithm/unwrap_iter.h> |
| 19 | #include <__assert> | 19 | #include <__assert> |
| 20 | #include <__bit/bit_log2.h> | ||
| 20 | #include <__bit/blsr.h> | 21 | #include <__bit/blsr.h> |
| 21 | #include <__bit/countl.h> | 22 | #include <__bit/countl.h> |
| 22 | #include <__bit/countr.h> | 23 | #include <__bit/countr.h> |
| ... | @@ -34,7 +35,7 @@ | ... | @@ -34,7 +35,7 @@ |
| 34 | #include <__type_traits/is_constant_evaluated.h> | 35 | #include <__type_traits/is_constant_evaluated.h> |
| 35 | #include <__type_traits/is_same.h> | 36 | #include <__type_traits/is_same.h> |
| 36 | #include <__type_traits/is_trivially_copyable.h> | 37 | #include <__type_traits/is_trivially_copyable.h> |
| 37 | #include <__type_traits/remove_cvref.h> | 38 | #include <__type_traits/make_unsigned.h> |
| 38 | #include <__utility/move.h> | 39 | #include <__utility/move.h> |
| 39 | #include <__utility/pair.h> | 40 | #include <__utility/pair.h> |
| 40 | #include <climits> | 41 | #include <climits> |
| ... | @@ -52,8 +53,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -52,8 +53,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 52 | template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type> | 53 | template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type> |
| 53 | inline const bool __use_branchless_sort = | 54 | inline const bool __use_branchless_sort = |
| 54 | __libcpp_is_contiguous_iterator<_Iter>::value && __is_cheap_to_copy<_Tp> && is_arithmetic<_Tp>::value && | 55 | __libcpp_is_contiguous_iterator<_Iter>::value && __is_cheap_to_copy<_Tp> && is_arithmetic<_Tp>::value && |
| 55 | (__desugars_to_v<__less_tag, __remove_cvref_t<_Compare>, _Tp, _Tp> || | 56 | (__desugars_to_v<__less_tag, _Compare, _Tp, _Tp> || __desugars_to_v<__greater_tag, _Compare, _Tp, _Tp>); |
| 56 | __desugars_to_v<__greater_tag, __remove_cvref_t<_Compare>, _Tp, _Tp>); | ||
| 57 | 57 | ||
| 58 | namespace __detail { | 58 | namespace __detail { |
| 59 | 59 | ||
| ... | @@ -359,10 +359,10 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos( | ... | @@ -359,10 +359,10 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos( |
| 359 | // Swap one pair on each iteration as long as both bitsets have at least one | 359 | // Swap one pair on each iteration as long as both bitsets have at least one |
| 360 | // element for swapping. | 360 | // element for swapping. |
| 361 | while (__left_bitset != 0 && __right_bitset != 0) { | 361 | while (__left_bitset != 0 && __right_bitset != 0) { |
| 362 | difference_type __tz_left = __libcpp_ctz(__left_bitset); | 362 | difference_type __tz_left = std::__countr_zero(__left_bitset); |
| 363 | __left_bitset = __libcpp_blsr(__left_bitset); | 363 | __left_bitset = std::__libcpp_blsr(__left_bitset); |
| 364 | difference_type __tz_right = __libcpp_ctz(__right_bitset); | 364 | difference_type __tz_right = std::__countr_zero(__right_bitset); |
| 365 | __right_bitset = __libcpp_blsr(__right_bitset); | 365 | __right_bitset = std::__libcpp_blsr(__right_bitset); |
| 366 | _Ops::iter_swap(__first + __tz_left, __last - __tz_right); | 366 | _Ops::iter_swap(__first + __tz_left, __last - __tz_right); |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| ... | @@ -458,7 +458,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within( | ... | @@ -458,7 +458,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within( |
| 458 | // Swap within the left side. Need to find set positions in the reverse | 458 | // Swap within the left side. Need to find set positions in the reverse |
| 459 | // order. | 459 | // order. |
| 460 | while (__left_bitset != 0) { | 460 | while (__left_bitset != 0) { |
| 461 | difference_type __tz_left = __detail::__block_size - 1 - __libcpp_clz(__left_bitset); | 461 | difference_type __tz_left = __detail::__block_size - 1 - std::__countl_zero(__left_bitset); |
| 462 | __left_bitset &= (static_cast<uint64_t>(1) << __tz_left) - 1; | 462 | __left_bitset &= (static_cast<uint64_t>(1) << __tz_left) - 1; |
| 463 | _RandomAccessIterator __it = __first + __tz_left; | 463 | _RandomAccessIterator __it = __first + __tz_left; |
| 464 | if (__it != __lm1) { | 464 | if (__it != __lm1) { |
| ... | @@ -471,7 +471,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within( | ... | @@ -471,7 +471,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within( |
| 471 | // Swap within the right side. Need to find set positions in the reverse | 471 | // Swap within the right side. Need to find set positions in the reverse |
| 472 | // order. | 472 | // order. |
| 473 | while (__right_bitset != 0) { | 473 | while (__right_bitset != 0) { |
| 474 | difference_type __tz_right = __detail::__block_size - 1 - __libcpp_clz(__right_bitset); | 474 | difference_type __tz_right = __detail::__block_size - 1 - std::__countl_zero(__right_bitset); |
| 475 | __right_bitset &= (static_cast<uint64_t>(1) << __tz_right) - 1; | 475 | __right_bitset &= (static_cast<uint64_t>(1) << __tz_right) - 1; |
| 476 | _RandomAccessIterator __it = __lm1 - __tz_right; | 476 | _RandomAccessIterator __it = __lm1 - __tz_right; |
| 477 | if (__it != __first) { | 477 | if (__it != __first) { |
| ... | @@ -828,25 +828,6 @@ void __introsort(_RandomAccessIterator __first, | ... | @@ -828,25 +828,6 @@ void __introsort(_RandomAccessIterator __first, |
| 828 | } | 828 | } |
| 829 | } | 829 | } |
| 830 | 830 | ||
| 831 | template <typename _Number> | ||
| 832 | inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) { | ||
| 833 | if (__n == 0) | ||
| 834 | return 0; | ||
| 835 | if (sizeof(__n) <= sizeof(unsigned)) | ||
| 836 | return sizeof(unsigned) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned>(__n)); | ||
| 837 | if (sizeof(__n) <= sizeof(unsigned long)) | ||
| 838 | return sizeof(unsigned long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long>(__n)); | ||
| 839 | if (sizeof(__n) <= sizeof(unsigned long long)) | ||
| 840 | return sizeof(unsigned long long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long long>(__n)); | ||
| 841 | |||
| 842 | _Number __log2 = 0; | ||
| 843 | while (__n > 1) { | ||
| 844 | __log2++; | ||
| 845 | __n >>= 1; | ||
| 846 | } | ||
| 847 | return __log2; | ||
| 848 | } | ||
| 849 | |||
| 850 | template <class _Comp, class _RandomAccessIterator> | 831 | template <class _Comp, class _RandomAccessIterator> |
| 851 | void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp); | 832 | void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp); |
| 852 | 833 | ||
| ... | @@ -880,7 +861,7 @@ template <class _AlgPolicy, class _RandomAccessIterator, class _Comp> | ... | @@ -880,7 +861,7 @@ template <class _AlgPolicy, class _RandomAccessIterator, class _Comp> |
| 880 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 861 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 881 | __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) { | 862 | __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) { |
| 882 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | 863 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 883 | difference_type __depth_limit = 2 * std::__log2i(__last - __first); | 864 | difference_type __depth_limit = 2 * std::__bit_log2(std::__to_unsigned_like(__last - __first)); |
| 884 | 865 | ||
| 885 | // Only use bitset partitioning for arithmetic types. We should also check | 866 | // Only use bitset partitioning for arithmetic types. We should also check |
| 886 | // that the default comparator is in use so that we are sure that there are no | 867 | // that the default comparator is in use so that we are sure that there are no |
lib/libcxx/include/__algorithm/stable_partition.h+11-10| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | #include <__iterator/advance.h> | 16 | #include <__iterator/advance.h> |
| 17 | #include <__iterator/distance.h> | 17 | #include <__iterator/distance.h> |
| 18 | #include <__iterator/iterator_traits.h> | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__memory/construct_at.h> | ||
| 19 | #include <__memory/destruct_n.h> | 20 | #include <__memory/destruct_n.h> |
| 20 | #include <__memory/unique_ptr.h> | 21 | #include <__memory/unique_ptr.h> |
| 21 | #include <__memory/unique_temporary_buffer.h> | 22 | #include <__memory/unique_temporary_buffer.h> |
| ... | @@ -33,7 +34,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -33,7 +34,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 35 | ||
| 35 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair> | 36 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair> |
| 36 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl( | 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator __stable_partition_impl( |
| 37 | _ForwardIterator __first, | 38 | _ForwardIterator __first, |
| 38 | _ForwardIterator __last, | 39 | _ForwardIterator __last, |
| 39 | _Predicate __pred, | 40 | _Predicate __pred, |
| ... | @@ -61,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl( | ... | @@ -61,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl( |
| 61 | // Move the falses into the temporary buffer, and the trues to the front of the line | 62 | // Move the falses into the temporary buffer, and the trues to the front of the line |
| 62 | // Update __first to always point to the end of the trues | 63 | // Update __first to always point to the end of the trues |
| 63 | value_type* __t = __p.first; | 64 | value_type* __t = __p.first; |
| 64 | ::new ((void*)__t) value_type(_Ops::__iter_move(__first)); | 65 | std::__construct_at(__t, _Ops::__iter_move(__first)); |
| 65 | __d.template __incr<value_type>(); | 66 | __d.template __incr<value_type>(); |
| 66 | ++__t; | 67 | ++__t; |
| 67 | _ForwardIterator __i = __first; | 68 | _ForwardIterator __i = __first; |
| ... | @@ -70,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl( | ... | @@ -70,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl( |
| 70 | *__first = _Ops::__iter_move(__i); | 71 | *__first = _Ops::__iter_move(__i); |
| 71 | ++__first; | 72 | ++__first; |
| 72 | } else { | 73 | } else { |
| 73 | ::new ((void*)__t) value_type(_Ops::__iter_move(__i)); | 74 | std::__construct_at(__t, _Ops::__iter_move(__i)); |
| 74 | __d.template __incr<value_type>(); | 75 | __d.template __incr<value_type>(); |
| 75 | ++__t; | 76 | ++__t; |
| 76 | } | 77 | } |
| ... | @@ -116,7 +117,7 @@ __second_half_done: | ... | @@ -116,7 +117,7 @@ __second_half_done: |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 118 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator> | 119 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator> |
| 119 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 120 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator |
| 120 | __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) { | 121 | __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) { |
| 121 | typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; | 122 | typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; |
| 122 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 123 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; |
| ... | @@ -145,7 +146,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred | ... | @@ -145,7 +146,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred |
| 145 | } | 146 | } |
| 146 | 147 | ||
| 147 | template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair> | 148 | template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair> |
| 148 | _BidirectionalIterator __stable_partition_impl( | 149 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _BidirectionalIterator __stable_partition_impl( |
| 149 | _BidirectionalIterator __first, | 150 | _BidirectionalIterator __first, |
| 150 | _BidirectionalIterator __last, | 151 | _BidirectionalIterator __last, |
| 151 | _Predicate __pred, | 152 | _Predicate __pred, |
| ... | @@ -179,7 +180,7 @@ _BidirectionalIterator __stable_partition_impl( | ... | @@ -179,7 +180,7 @@ _BidirectionalIterator __stable_partition_impl( |
| 179 | // Move the falses into the temporary buffer, and the trues to the front of the line | 180 | // Move the falses into the temporary buffer, and the trues to the front of the line |
| 180 | // Update __first to always point to the end of the trues | 181 | // Update __first to always point to the end of the trues |
| 181 | value_type* __t = __p.first; | 182 | value_type* __t = __p.first; |
| 182 | ::new ((void*)__t) value_type(_Ops::__iter_move(__first)); | 183 | std::__construct_at(__t, _Ops::__iter_move(__first)); |
| 183 | __d.template __incr<value_type>(); | 184 | __d.template __incr<value_type>(); |
| 184 | ++__t; | 185 | ++__t; |
| 185 | _BidirectionalIterator __i = __first; | 186 | _BidirectionalIterator __i = __first; |
| ... | @@ -188,7 +189,7 @@ _BidirectionalIterator __stable_partition_impl( | ... | @@ -188,7 +189,7 @@ _BidirectionalIterator __stable_partition_impl( |
| 188 | *__first = _Ops::__iter_move(__i); | 189 | *__first = _Ops::__iter_move(__i); |
| 189 | ++__first; | 190 | ++__first; |
| 190 | } else { | 191 | } else { |
| 191 | ::new ((void*)__t) value_type(_Ops::__iter_move(__i)); | 192 | std::__construct_at(__t, _Ops::__iter_move(__i)); |
| 192 | __d.template __incr<value_type>(); | 193 | __d.template __incr<value_type>(); |
| 193 | ++__t; | 194 | ++__t; |
| 194 | } | 195 | } |
| ... | @@ -247,7 +248,7 @@ __second_half_done: | ... | @@ -247,7 +248,7 @@ __second_half_done: |
| 247 | } | 248 | } |
| 248 | 249 | ||
| 249 | template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator> | 250 | template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator> |
| 250 | _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl( | 251 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _BidirectionalIterator __stable_partition_impl( |
| 251 | _BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) { | 252 | _BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) { |
| 252 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; | 253 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; |
| 253 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | 254 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; |
| ... | @@ -283,14 +284,14 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl( | ... | @@ -283,14 +284,14 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl( |
| 283 | } | 284 | } |
| 284 | 285 | ||
| 285 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _IterCategory> | 286 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _IterCategory> |
| 286 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition( | 287 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator __stable_partition( |
| 287 | _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) { | 288 | _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) { |
| 288 | return std::__stable_partition_impl<_AlgPolicy, __remove_cvref_t<_Predicate>&>( | 289 | return std::__stable_partition_impl<_AlgPolicy, __remove_cvref_t<_Predicate>&>( |
| 289 | std::move(__first), std::move(__last), __pred, __iter_category); | 290 | std::move(__first), std::move(__last), __pred, __iter_category); |
| 290 | } | 291 | } |
| 291 | 292 | ||
| 292 | template <class _ForwardIterator, class _Predicate> | 293 | template <class _ForwardIterator, class _Predicate> |
| 293 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator | 294 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator |
| 294 | stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { | 295 | stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { |
| 295 | using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category; | 296 | using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category; |
| 296 | return std::__stable_partition<_ClassicAlgPolicy, _Predicate&>( | 297 | return std::__stable_partition<_ClassicAlgPolicy, _Predicate&>( |
lib/libcxx/include/__algorithm/stable_sort.h+16-12| ... | @@ -25,10 +25,9 @@ | ... | @@ -25,10 +25,9 @@ |
| 25 | #include <__memory/unique_temporary_buffer.h> | 25 | #include <__memory/unique_temporary_buffer.h> |
| 26 | #include <__type_traits/desugars_to.h> | 26 | #include <__type_traits/desugars_to.h> |
| 27 | #include <__type_traits/enable_if.h> | 27 | #include <__type_traits/enable_if.h> |
| 28 | #include <__type_traits/is_integral.h> | 28 | #include <__type_traits/is_constant_evaluated.h> |
| 29 | #include <__type_traits/is_same.h> | 29 | #include <__type_traits/is_same.h> |
| 30 | #include <__type_traits/is_trivially_assignable.h> | 30 | #include <__type_traits/is_trivially_assignable.h> |
| 31 | #include <__type_traits/remove_cvref.h> | ||
| 32 | #include <__utility/move.h> | 31 | #include <__utility/move.h> |
| 33 | #include <__utility/pair.h> | 32 | #include <__utility/pair.h> |
| 34 | 33 | ||
| ... | @@ -201,7 +200,7 @@ struct __stable_sort_switch { | ... | @@ -201,7 +200,7 @@ struct __stable_sort_switch { |
| 201 | #if _LIBCPP_STD_VER >= 17 | 200 | #if _LIBCPP_STD_VER >= 17 |
| 202 | template <class _Tp> | 201 | template <class _Tp> |
| 203 | _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() { | 202 | _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() { |
| 204 | static_assert(is_integral<_Tp>::value); | 203 | static_assert(__is_ordered_integer_representable_v<_Tp>); |
| 205 | if constexpr (sizeof(_Tp) == 1) { | 204 | if constexpr (sizeof(_Tp) == 1) { |
| 206 | return 1 << 8; | 205 | return 1 << 8; |
| 207 | } | 206 | } |
| ... | @@ -211,7 +210,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() { | ... | @@ -211,7 +210,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() { |
| 211 | 210 | ||
| 212 | template <class _Tp> | 211 | template <class _Tp> |
| 213 | _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_max_bound() { | 212 | _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_max_bound() { |
| 214 | static_assert(is_integral<_Tp>::value); | 213 | static_assert(__is_ordered_integer_representable_v<_Tp>); |
| 215 | if constexpr (sizeof(_Tp) >= 8) { | 214 | if constexpr (sizeof(_Tp) >= 8) { |
| 216 | return 1 << 15; | 215 | return 1 << 15; |
| 217 | } | 216 | } |
| ... | @@ -245,14 +244,19 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort( | ... | @@ -245,14 +244,19 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort( |
| 245 | } | 244 | } |
| 246 | 245 | ||
| 247 | #if _LIBCPP_STD_VER >= 17 | 246 | #if _LIBCPP_STD_VER >= 17 |
| 248 | constexpr auto __default_comp = | 247 | constexpr auto __default_comp = __desugars_to_v<__less_tag, _Compare, value_type, value_type >; |
| 249 | __desugars_to_v<__totally_ordered_less_tag, __remove_cvref_t<_Compare>, value_type, value_type >; | 248 | constexpr auto __radix_sortable = |
| 250 | constexpr auto __integral_value = | 249 | __is_ordered_integer_representable_v<value_type> && |
| 251 | is_integral_v<value_type > && is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>; | 250 | is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>; |
| 252 | constexpr auto __allowed_radix_sort = __default_comp && __integral_value; | 251 | if constexpr (__default_comp && __radix_sortable) { |
| 253 | if constexpr (__allowed_radix_sort) { | 252 | if (__len <= __buff_size && __len >= static_cast<difference_type>(std::__radix_sort_min_bound<value_type>()) && |
| 254 | if (__len <= __buff_size && __len >= static_cast<difference_type>(__radix_sort_min_bound<value_type>()) && | 253 | __len <= static_cast<difference_type>(std::__radix_sort_max_bound<value_type>())) { |
| 255 | __len <= static_cast<difference_type>(__radix_sort_max_bound<value_type>())) { | 254 | if (__libcpp_is_constant_evaluated()) { |
| 255 | for (auto* __p = __buff; __p < __buff + __buff_size; ++__p) { | ||
| 256 | std::__construct_at(__p); | ||
| 257 | } | ||
| 258 | } | ||
| 259 | |||
| 256 | std::__radix_sort(__first, __last, __buff); | 260 | std::__radix_sort(__first, __last, __buff); |
| 257 | return; | 261 | return; |
| 258 | } | 262 | } |
lib/libcxx/include/__algorithm/swap_ranges.h+162| ... | @@ -10,9 +10,12 @@ | ... | @@ -10,9 +10,12 @@ |
| 10 | #define _LIBCPP___ALGORITHM_SWAP_RANGES_H | 10 | #define _LIBCPP___ALGORITHM_SWAP_RANGES_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | 12 | #include <__algorithm/iterator_operations.h> |
| 13 | #include <__algorithm/min.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__fwd/bit_reference.h> | ||
| 14 | #include <__utility/move.h> | 16 | #include <__utility/move.h> |
| 15 | #include <__utility/pair.h> | 17 | #include <__utility/pair.h> |
| 18 | #include <__utility/swap.h> | ||
| 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 |
| ... | @@ -23,6 +26,165 @@ _LIBCPP_PUSH_MACROS | ... | @@ -23,6 +26,165 @@ _LIBCPP_PUSH_MACROS |
| 23 | 26 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 28 | ||
| 29 | template <class _Cl, class _Cr> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cr, false> __swap_ranges_aligned( | ||
| 31 | __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) { | ||
| 32 | using _I1 = __bit_iterator<_Cl, false>; | ||
| 33 | using difference_type = typename _I1::difference_type; | ||
| 34 | using __storage_type = typename _I1::__storage_type; | ||
| 35 | |||
| 36 | const int __bits_per_word = _I1::__bits_per_word; | ||
| 37 | difference_type __n = __last - __first; | ||
| 38 | if (__n > 0) { | ||
| 39 | // do first word | ||
| 40 | if (__first.__ctz_ != 0) { | ||
| 41 | unsigned __clz = __bits_per_word - __first.__ctz_; | ||
| 42 | difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); | ||
| 43 | __n -= __dn; | ||
| 44 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); | ||
| 45 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 46 | *__first.__seg_ &= ~__m; | ||
| 47 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 48 | *__result.__seg_ &= ~__m; | ||
| 49 | *__result.__seg_ |= __b1; | ||
| 50 | *__first.__seg_ |= __b2; | ||
| 51 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 52 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 53 | ++__first.__seg_; | ||
| 54 | // __first.__ctz_ = 0; | ||
| 55 | } | ||
| 56 | // __first.__ctz_ == 0; | ||
| 57 | // do middle words | ||
| 58 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_) | ||
| 59 | swap(*__first.__seg_, *__result.__seg_); | ||
| 60 | // do last word | ||
| 61 | if (__n > 0) { | ||
| 62 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 63 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 64 | *__first.__seg_ &= ~__m; | ||
| 65 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 66 | *__result.__seg_ &= ~__m; | ||
| 67 | *__result.__seg_ |= __b1; | ||
| 68 | *__first.__seg_ |= __b2; | ||
| 69 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | return __result; | ||
| 73 | } | ||
| 74 | |||
| 75 | template <class _Cl, class _Cr> | ||
| 76 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cr, false> __swap_ranges_unaligned( | ||
| 77 | __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) { | ||
| 78 | using _I1 = __bit_iterator<_Cl, false>; | ||
| 79 | using difference_type = typename _I1::difference_type; | ||
| 80 | using __storage_type = typename _I1::__storage_type; | ||
| 81 | |||
| 82 | const int __bits_per_word = _I1::__bits_per_word; | ||
| 83 | difference_type __n = __last - __first; | ||
| 84 | if (__n > 0) { | ||
| 85 | // do first word | ||
| 86 | if (__first.__ctz_ != 0) { | ||
| 87 | unsigned __clz_f = __bits_per_word - __first.__ctz_; | ||
| 88 | difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); | ||
| 89 | __n -= __dn; | ||
| 90 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | ||
| 91 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 92 | *__first.__seg_ &= ~__m; | ||
| 93 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 94 | __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); | ||
| 95 | __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); | ||
| 96 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 97 | *__result.__seg_ &= ~__m; | ||
| 98 | if (__result.__ctz_ > __first.__ctz_) { | ||
| 99 | unsigned __s = __result.__ctz_ - __first.__ctz_; | ||
| 100 | *__result.__seg_ |= __b1 << __s; | ||
| 101 | *__first.__seg_ |= __b2 >> __s; | ||
| 102 | } else { | ||
| 103 | unsigned __s = __first.__ctz_ - __result.__ctz_; | ||
| 104 | *__result.__seg_ |= __b1 >> __s; | ||
| 105 | *__first.__seg_ |= __b2 << __s; | ||
| 106 | } | ||
| 107 | __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; | ||
| 108 | __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); | ||
| 109 | __dn -= __ddn; | ||
| 110 | if (__dn > 0) { | ||
| 111 | __m = ~__storage_type(0) >> (__bits_per_word - __dn); | ||
| 112 | __b2 = *__result.__seg_ & __m; | ||
| 113 | *__result.__seg_ &= ~__m; | ||
| 114 | unsigned __s = __first.__ctz_ + __ddn; | ||
| 115 | *__result.__seg_ |= __b1 >> __s; | ||
| 116 | *__first.__seg_ |= __b2 << __s; | ||
| 117 | __result.__ctz_ = static_cast<unsigned>(__dn); | ||
| 118 | } | ||
| 119 | ++__first.__seg_; | ||
| 120 | // __first.__ctz_ = 0; | ||
| 121 | } | ||
| 122 | // __first.__ctz_ == 0; | ||
| 123 | // do middle words | ||
| 124 | __storage_type __m = ~__storage_type(0) << __result.__ctz_; | ||
| 125 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 126 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) { | ||
| 127 | __storage_type __b1 = *__first.__seg_; | ||
| 128 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 129 | *__result.__seg_ &= ~__m; | ||
| 130 | *__result.__seg_ |= __b1 << __result.__ctz_; | ||
| 131 | *__first.__seg_ = __b2 >> __result.__ctz_; | ||
| 132 | ++__result.__seg_; | ||
| 133 | __b2 = *__result.__seg_ & ~__m; | ||
| 134 | *__result.__seg_ &= __m; | ||
| 135 | *__result.__seg_ |= __b1 >> __clz_r; | ||
| 136 | *__first.__seg_ |= __b2 << __clz_r; | ||
| 137 | } | ||
| 138 | // do last word | ||
| 139 | if (__n > 0) { | ||
| 140 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 141 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 142 | *__first.__seg_ &= ~__m; | ||
| 143 | __storage_type __dn = std::min<__storage_type>(__n, __clz_r); | ||
| 144 | __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); | ||
| 145 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 146 | *__result.__seg_ &= ~__m; | ||
| 147 | *__result.__seg_ |= __b1 << __result.__ctz_; | ||
| 148 | *__first.__seg_ |= __b2 >> __result.__ctz_; | ||
| 149 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 150 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 151 | __n -= __dn; | ||
| 152 | if (__n > 0) { | ||
| 153 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 154 | __b2 = *__result.__seg_ & __m; | ||
| 155 | *__result.__seg_ &= ~__m; | ||
| 156 | *__result.__seg_ |= __b1 >> __dn; | ||
| 157 | *__first.__seg_ |= __b2 << __dn; | ||
| 158 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | } | ||
| 162 | return __result; | ||
| 163 | } | ||
| 164 | |||
| 165 | // 2+1 iterators: size2 >= size1; used by std::swap_ranges. | ||
| 166 | template <class, class _Cl, class _Cr> | ||
| 167 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> > | ||
| 168 | __swap_ranges(__bit_iterator<_Cl, false> __first1, | ||
| 169 | __bit_iterator<_Cl, false> __last1, | ||
| 170 | __bit_iterator<_Cr, false> __first2) { | ||
| 171 | if (__first1.__ctz_ == __first2.__ctz_) | ||
| 172 | return std::make_pair(__last1, std::__swap_ranges_aligned(__first1, __last1, __first2)); | ||
| 173 | return std::make_pair(__last1, std::__swap_ranges_unaligned(__first1, __last1, __first2)); | ||
| 174 | } | ||
| 175 | |||
| 176 | // 2+2 iterators: used by std::ranges::swap_ranges. | ||
| 177 | template <class _AlgPolicy, class _Cl, class _Cr> | ||
| 178 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> > | ||
| 179 | __swap_ranges(__bit_iterator<_Cl, false> __first1, | ||
| 180 | __bit_iterator<_Cl, false> __last1, | ||
| 181 | __bit_iterator<_Cr, false> __first2, | ||
| 182 | __bit_iterator<_Cr, false> __last2) { | ||
| 183 | if (__last1 - __first1 < __last2 - __first2) | ||
| 184 | return std::make_pair(__last1, std::__swap_ranges<_AlgPolicy>(__first1, __last1, __first2).second); | ||
| 185 | return std::make_pair(std::__swap_ranges<_AlgPolicy>(__first2, __last2, __first1).second, __last2); | ||
| 186 | } | ||
| 187 | |||
| 26 | // 2+2 iterators: the shorter size will be used. | 188 | // 2+2 iterators: the shorter size will be used. |
| 27 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2> | 189 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2> |
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2> | 190 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2> |
lib/libcxx/include/__assert+2-2| ... | @@ -20,8 +20,8 @@ | ... | @@ -20,8 +20,8 @@ |
| 20 | #define _LIBCPP_ASSERT(expression, message) \ | 20 | #define _LIBCPP_ASSERT(expression, message) \ |
| 21 | (__builtin_expect(static_cast<bool>(expression), 1) \ | 21 | (__builtin_expect(static_cast<bool>(expression), 1) \ |
| 22 | ? (void)0 \ | 22 | ? (void)0 \ |
| 23 | : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \ | 23 | : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING( \ |
| 24 | expression) " failed: " message "\n")) | 24 | __LINE__) ": libc++ Hardening assertion " _LIBCPP_TOSTRING(expression) " failed: " message "\n")) |
| 25 | 25 | ||
| 26 | // WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear | 26 | // WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear |
| 27 | // optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a | 27 | // optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a |
lib/libcxx/include/__assertion_handler+3-12| ... | @@ -13,9 +13,11 @@ | ... | @@ -13,9 +13,11 @@ |
| 13 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 13 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 14 | # include <__cxx03/__config> | 14 | # include <__cxx03/__config> |
| 15 | # include <__cxx03/__verbose_abort> | 15 | # include <__cxx03/__verbose_abort> |
| 16 | # include <__cxx03/__verbose_trap> | ||
| 16 | #else | 17 | #else |
| 17 | # include <__config> | 18 | # include <__config> |
| 18 | # include <__verbose_abort> | 19 | # include <__verbose_abort> |
| 20 | # include <__verbose_trap> | ||
| 19 | #endif | 21 | #endif |
| 20 | 22 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -28,18 +30,7 @@ | ... | @@ -28,18 +30,7 @@ |
| 28 | 30 | ||
| 29 | #else | 31 | #else |
| 30 | 32 | ||
| 31 | # if __has_builtin(__builtin_verbose_trap) | 33 | # define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message) |
| 32 | // AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream | ||
| 33 | // version before upstream Clang actually got the builtin. | ||
| 34 | // TODO: Remove once AppleClang supports the two-arguments version of the builtin. | ||
| 35 | # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700 | ||
| 36 | # define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message) | ||
| 37 | # else | ||
| 38 | # define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message) | ||
| 39 | # endif | ||
| 40 | # else | ||
| 41 | # define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap()) | ||
| 42 | # endif | ||
| 43 | 34 | ||
| 44 | #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG | 35 | #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG |
| 45 | 36 |
lib/libcxx/include/__atomic/atomic.h+15-6| ... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
| 23 | #include <__type_traits/is_integral.h> | 23 | #include <__type_traits/is_integral.h> |
| 24 | #include <__type_traits/is_nothrow_constructible.h> | 24 | #include <__type_traits/is_nothrow_constructible.h> |
| 25 | #include <__type_traits/is_same.h> | 25 | #include <__type_traits/is_same.h> |
| 26 | #include <__type_traits/is_trivially_copyable.h> | ||
| 26 | #include <__type_traits/remove_const.h> | 27 | #include <__type_traits/remove_const.h> |
| 27 | #include <__type_traits/remove_pointer.h> | 28 | #include <__type_traits/remove_pointer.h> |
| 28 | #include <__type_traits/remove_volatile.h> | 29 | #include <__type_traits/remove_volatile.h> |
| ... | @@ -40,6 +41,8 @@ struct __atomic_base // false | ... | @@ -40,6 +41,8 @@ struct __atomic_base // false |
| 40 | { | 41 | { |
| 41 | mutable __cxx_atomic_impl<_Tp> __a_; | 42 | mutable __cxx_atomic_impl<_Tp> __a_; |
| 42 | 43 | ||
| 44 | using value_type = _Tp; | ||
| 45 | |||
| 43 | #if _LIBCPP_STD_VER >= 17 | 46 | #if _LIBCPP_STD_VER >= 17 |
| 44 | static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; | 47 | static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; |
| 45 | #endif | 48 | #endif |
| ... | @@ -145,6 +148,8 @@ template <class _Tp> | ... | @@ -145,6 +148,8 @@ template <class _Tp> |
| 145 | struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { | 148 | struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { |
| 146 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp, false>; | 149 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp, false>; |
| 147 | 150 | ||
| 151 | using difference_type = typename __base::value_type; | ||
| 152 | |||
| 148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default; | 153 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default; |
| 149 | 154 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} | 155 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} |
| ... | @@ -226,11 +231,15 @@ struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { | ... | @@ -226,11 +231,15 @@ struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { |
| 226 | } | 231 | } |
| 227 | }; | 232 | }; |
| 228 | 233 | ||
| 234 | template <typename _Tp> | ||
| 235 | struct __check_atomic_mandates { | ||
| 236 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 237 | static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type"); | ||
| 238 | }; | ||
| 239 | |||
| 229 | template <class _Tp> | 240 | template <class _Tp> |
| 230 | struct atomic : public __atomic_base<_Tp> { | 241 | struct atomic : public __atomic_base<typename __check_atomic_mandates<_Tp>::type> { |
| 231 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>; | 242 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>; |
| 232 | using value_type = _Tp; | ||
| 233 | using difference_type = value_type; | ||
| 234 | 243 | ||
| 235 | #if _LIBCPP_STD_VER >= 20 | 244 | #if _LIBCPP_STD_VER >= 20 |
| 236 | _LIBCPP_HIDE_FROM_ABI atomic() = default; | 245 | _LIBCPP_HIDE_FROM_ABI atomic() = default; |
| ... | @@ -258,8 +267,8 @@ struct atomic : public __atomic_base<_Tp> { | ... | @@ -258,8 +267,8 @@ struct atomic : public __atomic_base<_Tp> { |
| 258 | template <class _Tp> | 267 | template <class _Tp> |
| 259 | struct atomic<_Tp*> : public __atomic_base<_Tp*> { | 268 | struct atomic<_Tp*> : public __atomic_base<_Tp*> { |
| 260 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp*>; | 269 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp*>; |
| 261 | using value_type = _Tp*; | 270 | |
| 262 | using difference_type = ptrdiff_t; | 271 | using difference_type = ptrdiff_t; |
| 263 | 272 | ||
| 264 | _LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default; | 273 | _LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default; |
| 265 | 274 | ||
| ... | @@ -361,7 +370,7 @@ private: | ... | @@ -361,7 +370,7 @@ private: |
| 361 | // https://github.com/llvm/llvm-project/issues/47978 | 370 | // https://github.com/llvm/llvm-project/issues/47978 |
| 362 | // clang bug: __old is not updated on failure for atomic<long double>::compare_exchange_weak | 371 | // clang bug: __old is not updated on failure for atomic<long double>::compare_exchange_weak |
| 363 | // Note __old = __self.load(memory_order_relaxed) will not work | 372 | // Note __old = __self.load(memory_order_relaxed) will not work |
| 364 | std::__cxx_atomic_load_inplace(std::addressof(__self.__a_), &__old, memory_order_relaxed); | 373 | std::__cxx_atomic_load_inplace(std::addressof(__self.__a_), std::addressof(__old), memory_order_relaxed); |
| 365 | } | 374 | } |
| 366 | # endif | 375 | # endif |
| 367 | __new = __operation(__old, __operand); | 376 | __new = __operation(__old, __operand); |
lib/libcxx/include/__atomic/atomic_ref.h+1-1| ... | @@ -119,7 +119,7 @@ public: | ... | @@ -119,7 +119,7 @@ public: |
| 119 | // that the pointer is going to be aligned properly at runtime because that is a (checked) precondition | 119 | // that the pointer is going to be aligned properly at runtime because that is a (checked) precondition |
| 120 | // of atomic_ref's constructor. | 120 | // of atomic_ref's constructor. |
| 121 | static constexpr bool is_always_lock_free = | 121 | static constexpr bool is_always_lock_free = |
| 122 | __atomic_always_lock_free(sizeof(_Tp), &__get_aligner_instance<required_alignment>::__instance); | 122 | __atomic_always_lock_free(sizeof(_Tp), std::addressof(__get_aligner_instance<required_alignment>::__instance)); |
| 123 | 123 | ||
| 124 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); } | 124 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); } |
| 125 | 125 |
lib/libcxx/include/__atomic/memory_order.h+2-2| ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | // to pin the underlying type in C++20. | 24 | // to pin the underlying type in C++20. |
| 25 | enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst }; | 25 | enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst }; |
| 26 | 26 | ||
| 27 | using __memory_order_underlying_t _LIBCPP_NODEBUG = underlying_type<__legacy_memory_order>::type; | 27 | using __memory_order_underlying_t _LIBCPP_NODEBUG = __underlying_type_t<__legacy_memory_order>; |
| 28 | 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 20 | 29 | #if _LIBCPP_STD_VER >= 20 |
| 30 | 30 | ||
| ... | @@ -37,7 +37,7 @@ enum class memory_order : __memory_order_underlying_t { | ... | @@ -37,7 +37,7 @@ enum class memory_order : __memory_order_underlying_t { |
| 37 | seq_cst = __mo_seq_cst | 37 | seq_cst = __mo_seq_cst |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | static_assert(is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value, | 40 | static_assert(is_same<__underlying_type_t<memory_order>, __memory_order_underlying_t>::value, |
| 41 | "unexpected underlying type for std::memory_order"); | 41 | "unexpected underlying type for std::memory_order"); |
| 42 | 42 | ||
| 43 | inline constexpr auto memory_order_relaxed = memory_order::relaxed; | 43 | inline constexpr auto memory_order_relaxed = memory_order::relaxed; |
lib/libcxx/include/__atomic/support.h-3| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #define _LIBCPP___ATOMIC_SUPPORT_H | 10 | #define _LIBCPP___ATOMIC_SUPPORT_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/is_trivially_copyable.h> | ||
| 14 | 13 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -113,8 +112,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -113,8 +112,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 113 | 112 | ||
| 114 | template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> > | 113 | template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> > |
| 115 | struct __cxx_atomic_impl : public _Base { | 114 | struct __cxx_atomic_impl : public _Base { |
| 116 | static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type"); | ||
| 117 | |||
| 118 | _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default; | 115 | _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default; |
| 119 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {} | 116 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {} |
| 120 | }; | 117 | }; |
lib/libcxx/include/__atomic/support/c11.h+1-1| ... | @@ -35,7 +35,7 @@ struct __cxx_atomic_base_impl { | ... | @@ -35,7 +35,7 @@ struct __cxx_atomic_base_impl { |
| 35 | } | 35 | } |
| 36 | #endif // _LIBCPP_CXX03_LANG | 36 | #endif // _LIBCPP_CXX03_LANG |
| 37 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {} | 37 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {} |
| 38 | _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value; | 38 | _Atomic(_Tp) __a_value; |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | #define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s) | 41 | #define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s) |
lib/libcxx/include/__bit/bit_ceil.h+2-2| ... | @@ -11,8 +11,8 @@ | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | ||
| 12 | #include <__assert> | 12 | #include <__assert> |
| 13 | #include <__bit/countl.h> | 13 | #include <__bit/countl.h> |
| 14 | #include <__concepts/arithmetic.h> | ||
| 15 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__type_traits/integer_traits.h> | ||
| 16 | #include <limits> | 16 | #include <limits> |
| 17 | 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -41,7 +41,7 @@ template <class _Tp> | ... | @@ -41,7 +41,7 @@ template <class _Tp> |
| 41 | 41 | ||
| 42 | # if _LIBCPP_STD_VER >= 20 | 42 | # if _LIBCPP_STD_VER >= 20 |
| 43 | 43 | ||
| 44 | template <__libcpp_unsigned_integer _Tp> | 44 | template <__unsigned_integer _Tp> |
| 45 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { | 45 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { |
| 46 | return std::__bit_ceil(__t); | 46 | return std::__bit_ceil(__t); |
| 47 | } | 47 | } |
lib/libcxx/include/__bit/bit_floor.h+2-3| ... | @@ -10,9 +10,8 @@ | ... | @@ -10,9 +10,8 @@ |
| 10 | #define _LIBCPP___BIT_BIT_FLOOR_H | 10 | #define _LIBCPP___BIT_BIT_FLOOR_H |
| 11 | 11 | ||
| 12 | #include <__bit/bit_log2.h> | 12 | #include <__bit/bit_log2.h> |
| 13 | #include <__concepts/arithmetic.h> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <limits> | 14 | #include <__type_traits/integer_traits.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| ... | @@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 21 | ||
| 23 | #if _LIBCPP_STD_VER >= 20 | 22 | #if _LIBCPP_STD_VER >= 20 |
| 24 | 23 | ||
| 25 | template <__libcpp_unsigned_integer _Tp> | 24 | template <__unsigned_integer _Tp> |
| 26 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept { | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept { |
| 27 | return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t); | 26 | return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t); |
| 28 | } | 27 | } |
lib/libcxx/include/__bit/bit_log2.h+3-7| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__bit/countl.h> | 12 | #include <__bit/countl.h> |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/is_unsigned_integer.h> | 14 | #include <__type_traits/integer_traits.h> |
| 15 | #include <limits> | 15 | #include <limits> |
| 16 | 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -20,16 +20,12 @@ | ... | @@ -20,16 +20,12 @@ |
| 20 | 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | #if _LIBCPP_STD_VER >= 14 | ||
| 24 | |||
| 25 | template <class _Tp> | 23 | template <class _Tp> |
| 26 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept { | 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __bit_log2(_Tp __t) _NOEXCEPT { |
| 27 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type"); | 25 | static_assert(__is_unsigned_integer_v<_Tp>, "__bit_log2 requires an unsigned integer type"); |
| 28 | return numeric_limits<_Tp>::digits - 1 - std::__countl_zero(__t); | 26 | return numeric_limits<_Tp>::digits - 1 - std::__countl_zero(__t); |
| 29 | } | 27 | } |
| 30 | 28 | ||
| 31 | #endif // _LIBCPP_STD_VER >= 14 | ||
| 32 | |||
| 33 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 30 | ||
| 35 | #endif // _LIBCPP___BIT_BIT_LOG2_H | 31 | #endif // _LIBCPP___BIT_BIT_LOG2_H |
lib/libcxx/include/__bit/bit_width.h+2-2| ... | @@ -10,8 +10,8 @@ | ... | @@ -10,8 +10,8 @@ |
| 10 | #define _LIBCPP___BIT_BIT_WIDTH_H | 10 | #define _LIBCPP___BIT_BIT_WIDTH_H |
| 11 | 11 | ||
| 12 | #include <__bit/bit_log2.h> | 12 | #include <__bit/bit_log2.h> |
| 13 | #include <__concepts/arithmetic.h> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/integer_traits.h> | ||
| 15 | 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| ... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | template <__libcpp_unsigned_integer _Tp> | 24 | template <__unsigned_integer _Tp> |
| 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept { | 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept { |
| 26 | return __t == 0 ? 0 : std::__bit_log2(__t) + 1; | 26 | return __t == 0 ? 0 : std::__bit_log2(__t) + 1; |
| 27 | } | 27 | } |
lib/libcxx/include/__bit/countl.h+4-68| ... | @@ -6,16 +6,11 @@ | ... | @@ -6,16 +6,11 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | // TODO: __builtin_clzg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can | ||
| 10 | // refactor this code to exclusively use __builtin_clzg. | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___BIT_COUNTL_H | 9 | #ifndef _LIBCPP___BIT_COUNTL_H |
| 13 | #define _LIBCPP___BIT_COUNTL_H | 10 | #define _LIBCPP___BIT_COUNTL_H |
| 14 | 11 | ||
| 15 | #include <__bit/rotate.h> | ||
| 16 | #include <__concepts/arithmetic.h> | ||
| 17 | #include <__config> | 12 | #include <__config> |
| 18 | #include <__type_traits/is_unsigned_integer.h> | 13 | #include <__type_traits/integer_traits.h> |
| 19 | #include <limits> | 14 | #include <limits> |
| 20 | 15 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -27,79 +22,20 @@ _LIBCPP_PUSH_MACROS | ... | @@ -27,79 +22,20 @@ _LIBCPP_PUSH_MACROS |
| 27 | 22 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 24 | ||
| 30 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT { | ||
| 31 | return __builtin_clz(__x); | ||
| 32 | } | ||
| 33 | |||
| 34 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT { | ||
| 35 | return __builtin_clzl(__x); | ||
| 36 | } | ||
| 37 | |||
| 38 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT { | ||
| 39 | return __builtin_clzll(__x); | ||
| 40 | } | ||
| 41 | |||
| 42 | #if _LIBCPP_HAS_INT128 | ||
| 43 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT { | ||
| 44 | # if __has_builtin(__builtin_clzg) | ||
| 45 | return __builtin_clzg(__x); | ||
| 46 | # else | ||
| 47 | // The function is written in this form due to C++ constexpr limitations. | ||
| 48 | // The algorithm: | ||
| 49 | // - Test whether any bit in the high 64-bits is set | ||
| 50 | // - No bits set: | ||
| 51 | // - The high 64-bits contain 64 leading zeros, | ||
| 52 | // - Add the result of the low 64-bits. | ||
| 53 | // - Any bits set: | ||
| 54 | // - The number of leading zeros of the input is the number of leading | ||
| 55 | // zeros in the high 64-bits. | ||
| 56 | return ((__x >> 64) == 0) ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x))) | ||
| 57 | : __builtin_clzll(static_cast<unsigned long long>(__x >> 64)); | ||
| 58 | # endif | ||
| 59 | } | ||
| 60 | #endif // _LIBCPP_HAS_INT128 | ||
| 61 | |||
| 62 | template <class _Tp> | 25 | template <class _Tp> |
| 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { | 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { |
| 64 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type"); | 27 | static_assert(__is_unsigned_integer_v<_Tp>, "__countl_zero requires an unsigned integer type"); |
| 65 | #if __has_builtin(__builtin_clzg) | ||
| 66 | return __builtin_clzg(__t, numeric_limits<_Tp>::digits); | 28 | return __builtin_clzg(__t, numeric_limits<_Tp>::digits); |
| 67 | #else // __has_builtin(__builtin_clzg) | ||
| 68 | if (__t == 0) | ||
| 69 | return numeric_limits<_Tp>::digits; | ||
| 70 | |||
| 71 | if (sizeof(_Tp) <= sizeof(unsigned int)) | ||
| 72 | return std::__libcpp_clz(static_cast<unsigned int>(__t)) - | ||
| 73 | (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits); | ||
| 74 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | ||
| 75 | return std::__libcpp_clz(static_cast<unsigned long>(__t)) - | ||
| 76 | (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits); | ||
| 77 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) | ||
| 78 | return std::__libcpp_clz(static_cast<unsigned long long>(__t)) - | ||
| 79 | (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits); | ||
| 80 | else { | ||
| 81 | int __ret = 0; | ||
| 82 | int __iter = 0; | ||
| 83 | const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; | ||
| 84 | while (true) { | ||
| 85 | __t = std::__rotl(__t, __ulldigits); | ||
| 86 | if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits) | ||
| 87 | break; | ||
| 88 | __ret += __iter; | ||
| 89 | } | ||
| 90 | return __ret + __iter; | ||
| 91 | } | ||
| 92 | #endif // __has_builtin(__builtin_clzg) | ||
| 93 | } | 29 | } |
| 94 | 30 | ||
| 95 | #if _LIBCPP_STD_VER >= 20 | 31 | #if _LIBCPP_STD_VER >= 20 |
| 96 | 32 | ||
| 97 | template <__libcpp_unsigned_integer _Tp> | 33 | template <__unsigned_integer _Tp> |
| 98 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept { | 34 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept { |
| 99 | return std::__countl_zero(__t); | 35 | return std::__countl_zero(__t); |
| 100 | } | 36 | } |
| 101 | 37 | ||
| 102 | template <__libcpp_unsigned_integer _Tp> | 38 | template <__unsigned_integer _Tp> |
| 103 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { | 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { |
| 104 | return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | 40 | return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; |
| 105 | } | 41 | } |
lib/libcxx/include/__bit/countr.h+5-40| ... | @@ -6,15 +6,11 @@ | ... | @@ -6,15 +6,11 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | // TODO: __builtin_ctzg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can | ||
| 10 | // refactor this code to exclusively use __builtin_ctzg. | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___BIT_COUNTR_H | 9 | #ifndef _LIBCPP___BIT_COUNTR_H |
| 13 | #define _LIBCPP___BIT_COUNTR_H | 10 | #define _LIBCPP___BIT_COUNTR_H |
| 14 | 11 | ||
| 15 | #include <__bit/rotate.h> | ||
| 16 | #include <__concepts/arithmetic.h> | ||
| 17 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integer_traits.h> | ||
| 18 | #include <limits> | 14 | #include <limits> |
| 19 | 15 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -26,51 +22,20 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,51 +22,20 @@ _LIBCPP_PUSH_MACROS |
| 26 | 22 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 24 | ||
| 29 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT { | ||
| 30 | return __builtin_ctz(__x); | ||
| 31 | } | ||
| 32 | |||
| 33 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT { | ||
| 34 | return __builtin_ctzl(__x); | ||
| 35 | } | ||
| 36 | |||
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { | ||
| 38 | return __builtin_ctzll(__x); | ||
| 39 | } | ||
| 40 | |||
| 41 | template <class _Tp> | 25 | template <class _Tp> |
| 42 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT { | 26 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT { |
| 43 | #if __has_builtin(__builtin_ctzg) | 27 | static_assert(__is_unsigned_integer_v<_Tp>, "__countr_zero only works with unsigned types"); |
| 44 | return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); | 28 | return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); |
| 45 | #else // __has_builtin(__builtin_ctzg) | ||
| 46 | if (__t == 0) | ||
| 47 | return numeric_limits<_Tp>::digits; | ||
| 48 | if (sizeof(_Tp) <= sizeof(unsigned int)) | ||
| 49 | return std::__libcpp_ctz(static_cast<unsigned int>(__t)); | ||
| 50 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | ||
| 51 | return std::__libcpp_ctz(static_cast<unsigned long>(__t)); | ||
| 52 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) | ||
| 53 | return std::__libcpp_ctz(static_cast<unsigned long long>(__t)); | ||
| 54 | else { | ||
| 55 | int __ret = 0; | ||
| 56 | const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; | ||
| 57 | while (static_cast<unsigned long long>(__t) == 0uLL) { | ||
| 58 | __ret += __ulldigits; | ||
| 59 | __t >>= __ulldigits; | ||
| 60 | } | ||
| 61 | return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t)); | ||
| 62 | } | ||
| 63 | #endif // __has_builtin(__builtin_ctzg) | ||
| 64 | } | 29 | } |
| 65 | 30 | ||
| 66 | #if _LIBCPP_STD_VER >= 20 | 31 | #if _LIBCPP_STD_VER >= 20 |
| 67 | 32 | ||
| 68 | template <__libcpp_unsigned_integer _Tp> | 33 | template <__unsigned_integer _Tp> |
| 69 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept { | 34 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept { |
| 70 | return std::__countr_zero(__t); | 35 | return std::__countr_zero(__t); |
| 71 | } | 36 | } |
| 72 | 37 | ||
| 73 | template <__libcpp_unsigned_integer _Tp> | 38 | template <__unsigned_integer _Tp> |
| 74 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { | 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { |
| 75 | return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | 40 | return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; |
| 76 | } | 41 | } |
lib/libcxx/include/__bit/has_single_bit.h+2-2| ... | @@ -9,8 +9,8 @@ | ... | @@ -9,8 +9,8 @@ |
| 9 | #ifndef _LIBCPP___BIT_HAS_SINGLE_BIT_H | 9 | #ifndef _LIBCPP___BIT_HAS_SINGLE_BIT_H |
| 10 | #define _LIBCPP___BIT_HAS_SINGLE_BIT_H | 10 | #define _LIBCPP___BIT_HAS_SINGLE_BIT_H |
| 11 | 11 | ||
| 12 | #include <__concepts/arithmetic.h> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integer_traits.h> | ||
| 14 | 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS |
| 23 | 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | template <__libcpp_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 __t != 0 && (((__t & (__t - 1)) == 0)); |
| 29 | } | 29 | } |
lib/libcxx/include/__bit/popcount.h+8-36| ... | @@ -6,16 +6,11 @@ | ... | @@ -6,16 +6,11 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | // TODO: __builtin_popcountg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can | ||
| 10 | // refactor this code to exclusively use __builtin_popcountg. | ||
| 11 | |||
| 12 | #ifndef _LIBCPP___BIT_POPCOUNT_H | 9 | #ifndef _LIBCPP___BIT_POPCOUNT_H |
| 13 | #define _LIBCPP___BIT_POPCOUNT_H | 10 | #define _LIBCPP___BIT_POPCOUNT_H |
| 14 | 11 | ||
| 15 | #include <__bit/rotate.h> | ||
| 16 | #include <__concepts/arithmetic.h> | ||
| 17 | #include <__config> | 12 | #include <__config> |
| 18 | #include <limits> | 13 | #include <__type_traits/integer_traits.h> |
| 19 | 14 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -26,43 +21,20 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,43 +21,20 @@ _LIBCPP_PUSH_MACROS |
| 26 | 21 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 23 | ||
| 29 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned __x) _NOEXCEPT { | 24 | template <class _Tp> |
| 30 | return __builtin_popcount(__x); | 25 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT { |
| 31 | } | 26 | static_assert(__is_unsigned_integer_v<_Tp>, "__popcount only works with unsigned types"); |
| 32 | 27 | return __builtin_popcountg(__t); | |
| 33 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned long __x) _NOEXCEPT { | ||
| 34 | return __builtin_popcountl(__x); | ||
| 35 | } | ||
| 36 | |||
| 37 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { | ||
| 38 | return __builtin_popcountll(__x); | ||
| 39 | } | 28 | } |
| 40 | 29 | ||
| 41 | #if _LIBCPP_STD_VER >= 20 | 30 | #if _LIBCPP_STD_VER >= 20 |
| 42 | 31 | ||
| 43 | template <__libcpp_unsigned_integer _Tp> | 32 | template <__unsigned_integer _Tp> |
| 44 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept { | 33 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept { |
| 45 | # if __has_builtin(__builtin_popcountg) | 34 | return std::__popcount(__t); |
| 46 | return __builtin_popcountg(__t); | ||
| 47 | # else // __has_builtin(__builtin_popcountg) | ||
| 48 | if (sizeof(_Tp) <= sizeof(unsigned int)) | ||
| 49 | return std::__libcpp_popcount(static_cast<unsigned int>(__t)); | ||
| 50 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | ||
| 51 | return std::__libcpp_popcount(static_cast<unsigned long>(__t)); | ||
| 52 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) | ||
| 53 | return std::__libcpp_popcount(static_cast<unsigned long long>(__t)); | ||
| 54 | else { | ||
| 55 | int __ret = 0; | ||
| 56 | while (__t != 0) { | ||
| 57 | __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t)); | ||
| 58 | __t >>= numeric_limits<unsigned long long>::digits; | ||
| 59 | } | ||
| 60 | return __ret; | ||
| 61 | } | ||
| 62 | # endif // __has_builtin(__builtin_popcountg) | ||
| 63 | } | 35 | } |
| 64 | 36 | ||
| 65 | #endif // _LIBCPP_STD_VER >= 20 | 37 | #endif |
| 66 | 38 | ||
| 67 | _LIBCPP_END_NAMESPACE_STD | 39 | _LIBCPP_END_NAMESPACE_STD |
| 68 | 40 |
lib/libcxx/include/__bit/rotate.h+5-6| ... | @@ -9,9 +9,8 @@ | ... | @@ -9,9 +9,8 @@ |
| 9 | #ifndef _LIBCPP___BIT_ROTATE_H | 9 | #ifndef _LIBCPP___BIT_ROTATE_H |
| 10 | #define _LIBCPP___BIT_ROTATE_H | 10 | #define _LIBCPP___BIT_ROTATE_H |
| 11 | 11 | ||
| 12 | #include <__concepts/arithmetic.h> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 14 | #include <__type_traits/is_unsigned_integer.h> | 13 | #include <__type_traits/integer_traits.h> |
| 15 | #include <limits> | 14 | #include <limits> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -25,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -25,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | // the rotr function becomes the ROR instruction. | 24 | // the rotr function becomes the ROR instruction. |
| 26 | template <class _Tp> | 25 | template <class _Tp> |
| 27 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT { | 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT { |
| 28 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type"); | 27 | static_assert(__is_unsigned_integer_v<_Tp>, "__rotl requires an unsigned integer type"); |
| 29 | const int __n = numeric_limits<_Tp>::digits; | 28 | const int __n = numeric_limits<_Tp>::digits; |
| 30 | int __r = __s % __n; | 29 | int __r = __s % __n; |
| 31 | 30 | ||
| ... | @@ -40,7 +39,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) | ... | @@ -40,7 +39,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) |
| 40 | 39 | ||
| 41 | template <class _Tp> | 40 | template <class _Tp> |
| 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT { | 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT { |
| 43 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); | 42 | static_assert(__is_unsigned_integer_v<_Tp>, "__rotr requires an unsigned integer type"); |
| 44 | const int __n = numeric_limits<_Tp>::digits; | 43 | const int __n = numeric_limits<_Tp>::digits; |
| 45 | int __r = __s % __n; | 44 | int __r = __s % __n; |
| 46 | 45 | ||
| ... | @@ -55,12 +54,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) | ... | @@ -55,12 +54,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) |
| 55 | 54 | ||
| 56 | #if _LIBCPP_STD_VER >= 20 | 55 | #if _LIBCPP_STD_VER >= 20 |
| 57 | 56 | ||
| 58 | template <__libcpp_unsigned_integer _Tp> | 57 | template <__unsigned_integer _Tp> |
| 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept { | 58 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept { |
| 60 | return std::__rotl(__t, __cnt); | 59 | return std::__rotl(__t, __cnt); |
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | template <__libcpp_unsigned_integer _Tp> | 62 | template <__unsigned_integer _Tp> |
| 64 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept { | 63 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept { |
| 65 | return std::__rotr(__t, __cnt); | 64 | return std::__rotr(__t, __cnt); |
| 66 | } | 65 | } |
lib/libcxx/include/__bit_reference+109-599| ... | @@ -10,21 +10,35 @@ | ... | @@ -10,21 +10,35 @@ |
| 10 | #ifndef _LIBCPP___BIT_REFERENCE | 10 | #ifndef _LIBCPP___BIT_REFERENCE |
| 11 | #define _LIBCPP___BIT_REFERENCE | 11 | #define _LIBCPP___BIT_REFERENCE |
| 12 | 12 | ||
| 13 | #include <__algorithm/comp.h> | ||
| 14 | #include <__algorithm/copy.h> | ||
| 15 | #include <__algorithm/copy_backward.h> | ||
| 13 | #include <__algorithm/copy_n.h> | 16 | #include <__algorithm/copy_n.h> |
| 17 | #include <__algorithm/equal.h> | ||
| 14 | #include <__algorithm/min.h> | 18 | #include <__algorithm/min.h> |
| 19 | #include <__algorithm/rotate.h> | ||
| 20 | #include <__algorithm/swap_ranges.h> | ||
| 21 | #include <__assert> | ||
| 15 | #include <__bit/countr.h> | 22 | #include <__bit/countr.h> |
| 16 | #include <__compare/ordering.h> | 23 | #include <__compare/ordering.h> |
| 17 | #include <__config> | 24 | #include <__config> |
| 18 | #include <__cstddef/ptrdiff_t.h> | 25 | #include <__cstddef/ptrdiff_t.h> |
| 19 | #include <__cstddef/size_t.h> | 26 | #include <__cstddef/size_t.h> |
| 27 | #include <__functional/identity.h> | ||
| 20 | #include <__fwd/bit_reference.h> | 28 | #include <__fwd/bit_reference.h> |
| 21 | #include <__iterator/iterator_traits.h> | 29 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__memory/construct_at.h> | 30 | #include <__memory/construct_at.h> |
| 23 | #include <__memory/pointer_traits.h> | 31 | #include <__memory/pointer_traits.h> |
| 24 | #include <__type_traits/conditional.h> | 32 | #include <__type_traits/conditional.h> |
| 33 | #include <__type_traits/desugars_to.h> | ||
| 34 | #include <__type_traits/enable_if.h> | ||
| 25 | #include <__type_traits/is_constant_evaluated.h> | 35 | #include <__type_traits/is_constant_evaluated.h> |
| 36 | #include <__type_traits/is_same.h> | ||
| 37 | #include <__type_traits/is_unsigned.h> | ||
| 26 | #include <__type_traits/void_t.h> | 38 | #include <__type_traits/void_t.h> |
| 39 | #include <__utility/pair.h> | ||
| 27 | #include <__utility/swap.h> | 40 | #include <__utility/swap.h> |
| 41 | #include <climits> | ||
| 28 | 42 | ||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 43 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 30 | # pragma GCC system_header | 44 | # pragma GCC system_header |
| ... | @@ -55,6 +69,53 @@ struct __size_difference_type_traits<_Cp, __void_t<typename _Cp::difference_type | ... | @@ -55,6 +69,53 @@ struct __size_difference_type_traits<_Cp, __void_t<typename _Cp::difference_type |
| 55 | using size_type = typename _Cp::size_type; | 69 | using size_type = typename _Cp::size_type; |
| 56 | }; | 70 | }; |
| 57 | 71 | ||
| 72 | // The `__x_mask` functions are designed to work exclusively with any unsigned `_StorageType`s, including small | ||
| 73 | // integral types such as unsigned char/short, `uint8_t`, and `uint16_t`. To prevent undefined behavior or | ||
| 74 | // ambiguities due to integral promotions for the small integral types, all intermediate bitwise operations are | ||
| 75 | // explicitly cast back to the unsigned `_StorageType`. | ||
| 76 | |||
| 77 | // Creates a mask of type `_StorageType` with a specified number of leading zeros (__clz) and sets all remaining | ||
| 78 | // bits to one. | ||
| 79 | template <class _StorageType> | ||
| 80 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __trailing_mask(unsigned __clz) { | ||
| 81 | static_assert(is_unsigned<_StorageType>::value, "__trailing_mask only works with unsigned types"); | ||
| 82 | return static_cast<_StorageType>(~static_cast<_StorageType>(0)) >> __clz; | ||
| 83 | } | ||
| 84 | |||
| 85 | // Creates a mask of type `_StorageType` with a specified number of trailing zeros (__ctz) and sets all remaining | ||
| 86 | // bits to one. | ||
| 87 | template <class _StorageType> | ||
| 88 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __leading_mask(unsigned __ctz) { | ||
| 89 | static_assert(is_unsigned<_StorageType>::value, "__leading_mask only works with unsigned types"); | ||
| 90 | return static_cast<_StorageType>(~static_cast<_StorageType>(0)) << __ctz; | ||
| 91 | } | ||
| 92 | |||
| 93 | // Creates a mask of type `_StorageType` with a specified number of leading zeros (__clz), a specified number of | ||
| 94 | // trailing zeros (__ctz), and sets all bits in between to one. | ||
| 95 | template <class _StorageType> | ||
| 96 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __middle_mask(unsigned __clz, unsigned __ctz) { | ||
| 97 | static_assert(is_unsigned<_StorageType>::value, "__middle_mask only works with unsigned types"); | ||
| 98 | return std::__leading_mask<_StorageType>(__ctz) & std::__trailing_mask<_StorageType>(__clz); | ||
| 99 | } | ||
| 100 | |||
| 101 | // This function is designed to operate correctly even for smaller integral types like `uint8_t`, `uint16_t`, | ||
| 102 | // or `unsigned short`. | ||
| 103 | // See https://github.com/llvm/llvm-project/pull/122410. | ||
| 104 | template <class _StoragePointer> | ||
| 105 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | ||
| 106 | __fill_masked_range(_StoragePointer __word, unsigned __clz, unsigned __ctz, bool __fill_val) { | ||
| 107 | static_assert(is_unsigned<typename pointer_traits<_StoragePointer>::element_type>::value, | ||
| 108 | "__fill_masked_range must be called with unsigned type"); | ||
| 109 | using _StorageType = typename pointer_traits<_StoragePointer>::element_type; | ||
| 110 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | ||
| 111 | __ctz + __clz < sizeof(_StorageType) * CHAR_BIT, "__fill_masked_range called with invalid range"); | ||
| 112 | _StorageType __m = std::__middle_mask<_StorageType>(__clz, __ctz); | ||
| 113 | if (__fill_val) | ||
| 114 | *__word |= __m; | ||
| 115 | else | ||
| 116 | *__word &= ~__m; | ||
| 117 | } | ||
| 118 | |||
| 58 | template <class _Cp, bool = __has_storage_type<_Cp>::value> | 119 | template <class _Cp, bool = __has_storage_type<_Cp>::value> |
| 59 | class __bit_reference { | 120 | class __bit_reference { |
| 60 | using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type; | 121 | using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type; |
| ... | @@ -104,7 +165,7 @@ public: | ... | @@ -104,7 +165,7 @@ public: |
| 104 | 165 | ||
| 105 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT { *__seg_ ^= __mask_; } | 166 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT { *__seg_ ^= __mask_; } |
| 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT { | 167 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT { |
| 107 | return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_))); | 168 | return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__countr_zero(__mask_))); |
| 108 | } | 169 | } |
| 109 | 170 | ||
| 110 | private: | 171 | private: |
| ... | @@ -173,7 +234,7 @@ public: | ... | @@ -173,7 +234,7 @@ public: |
| 173 | } | 234 | } |
| 174 | 235 | ||
| 175 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT { | 236 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT { |
| 176 | return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_))); | 237 | return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__countr_zero(__mask_))); |
| 177 | } | 238 | } |
| 178 | 239 | ||
| 179 | private: | 240 | private: |
| ... | @@ -183,422 +244,6 @@ private: | ... | @@ -183,422 +244,6 @@ private: |
| 183 | __mask_(__m) {} | 244 | __mask_(__m) {} |
| 184 | }; | 245 | }; |
| 185 | 246 | ||
| 186 | // copy | ||
| 187 | |||
| 188 | template <class _Cp, bool _IsConst> | ||
| 189 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_aligned( | ||
| 190 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 191 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 192 | using difference_type = typename _In::difference_type; | ||
| 193 | using __storage_type = typename _In::__storage_type; | ||
| 194 | |||
| 195 | const int __bits_per_word = _In::__bits_per_word; | ||
| 196 | difference_type __n = __last - __first; | ||
| 197 | if (__n > 0) { | ||
| 198 | // do first word | ||
| 199 | if (__first.__ctz_ != 0) { | ||
| 200 | unsigned __clz = __bits_per_word - __first.__ctz_; | ||
| 201 | difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); | ||
| 202 | __n -= __dn; | ||
| 203 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); | ||
| 204 | __storage_type __b = *__first.__seg_ & __m; | ||
| 205 | *__result.__seg_ &= ~__m; | ||
| 206 | *__result.__seg_ |= __b; | ||
| 207 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 208 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 209 | ++__first.__seg_; | ||
| 210 | // __first.__ctz_ = 0; | ||
| 211 | } | ||
| 212 | // __first.__ctz_ == 0; | ||
| 213 | // do middle words | ||
| 214 | __storage_type __nw = __n / __bits_per_word; | ||
| 215 | std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_)); | ||
| 216 | __n -= __nw * __bits_per_word; | ||
| 217 | __result.__seg_ += __nw; | ||
| 218 | // do last word | ||
| 219 | if (__n > 0) { | ||
| 220 | __first.__seg_ += __nw; | ||
| 221 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 222 | __storage_type __b = *__first.__seg_ & __m; | ||
| 223 | *__result.__seg_ &= ~__m; | ||
| 224 | *__result.__seg_ |= __b; | ||
| 225 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 226 | } | ||
| 227 | } | ||
| 228 | return __result; | ||
| 229 | } | ||
| 230 | |||
| 231 | template <class _Cp, bool _IsConst> | ||
| 232 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_unaligned( | ||
| 233 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 234 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 235 | using difference_type = typename _In::difference_type; | ||
| 236 | using __storage_type = typename _In::__storage_type; | ||
| 237 | |||
| 238 | const int __bits_per_word = _In::__bits_per_word; | ||
| 239 | difference_type __n = __last - __first; | ||
| 240 | if (__n > 0) { | ||
| 241 | // do first word | ||
| 242 | if (__first.__ctz_ != 0) { | ||
| 243 | unsigned __clz_f = __bits_per_word - __first.__ctz_; | ||
| 244 | difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); | ||
| 245 | __n -= __dn; | ||
| 246 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | ||
| 247 | __storage_type __b = *__first.__seg_ & __m; | ||
| 248 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 249 | __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); | ||
| 250 | __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); | ||
| 251 | *__result.__seg_ &= ~__m; | ||
| 252 | if (__result.__ctz_ > __first.__ctz_) | ||
| 253 | *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); | ||
| 254 | else | ||
| 255 | *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); | ||
| 256 | __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; | ||
| 257 | __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); | ||
| 258 | __dn -= __ddn; | ||
| 259 | if (__dn > 0) { | ||
| 260 | __m = ~__storage_type(0) >> (__bits_per_word - __dn); | ||
| 261 | *__result.__seg_ &= ~__m; | ||
| 262 | *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); | ||
| 263 | __result.__ctz_ = static_cast<unsigned>(__dn); | ||
| 264 | } | ||
| 265 | ++__first.__seg_; | ||
| 266 | // __first.__ctz_ = 0; | ||
| 267 | } | ||
| 268 | // __first.__ctz_ == 0; | ||
| 269 | // do middle words | ||
| 270 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 271 | __storage_type __m = ~__storage_type(0) << __result.__ctz_; | ||
| 272 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) { | ||
| 273 | __storage_type __b = *__first.__seg_; | ||
| 274 | *__result.__seg_ &= ~__m; | ||
| 275 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 276 | ++__result.__seg_; | ||
| 277 | *__result.__seg_ &= __m; | ||
| 278 | *__result.__seg_ |= __b >> __clz_r; | ||
| 279 | } | ||
| 280 | // do last word | ||
| 281 | if (__n > 0) { | ||
| 282 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 283 | __storage_type __b = *__first.__seg_ & __m; | ||
| 284 | __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r)); | ||
| 285 | __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); | ||
| 286 | *__result.__seg_ &= ~__m; | ||
| 287 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 288 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 289 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 290 | __n -= __dn; | ||
| 291 | if (__n > 0) { | ||
| 292 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 293 | *__result.__seg_ &= ~__m; | ||
| 294 | *__result.__seg_ |= __b >> __dn; | ||
| 295 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 296 | } | ||
| 297 | } | ||
| 298 | } | ||
| 299 | return __result; | ||
| 300 | } | ||
| 301 | |||
| 302 | template <class _Cp, bool _IsConst> | ||
| 303 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> | ||
| 304 | copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 305 | if (__first.__ctz_ == __result.__ctz_) | ||
| 306 | return std::__copy_aligned(__first, __last, __result); | ||
| 307 | return std::__copy_unaligned(__first, __last, __result); | ||
| 308 | } | ||
| 309 | |||
| 310 | // copy_backward | ||
| 311 | |||
| 312 | template <class _Cp, bool _IsConst> | ||
| 313 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_aligned( | ||
| 314 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 315 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 316 | using difference_type = typename _In::difference_type; | ||
| 317 | using __storage_type = typename _In::__storage_type; | ||
| 318 | |||
| 319 | const int __bits_per_word = _In::__bits_per_word; | ||
| 320 | difference_type __n = __last - __first; | ||
| 321 | if (__n > 0) { | ||
| 322 | // do first word | ||
| 323 | if (__last.__ctz_ != 0) { | ||
| 324 | difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n); | ||
| 325 | __n -= __dn; | ||
| 326 | unsigned __clz = __bits_per_word - __last.__ctz_; | ||
| 327 | __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz); | ||
| 328 | __storage_type __b = *__last.__seg_ & __m; | ||
| 329 | *__result.__seg_ &= ~__m; | ||
| 330 | *__result.__seg_ |= __b; | ||
| 331 | __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); | ||
| 332 | // __last.__ctz_ = 0 | ||
| 333 | } | ||
| 334 | // __last.__ctz_ == 0 || __n == 0 | ||
| 335 | // __result.__ctz_ == 0 || __n == 0 | ||
| 336 | // do middle words | ||
| 337 | __storage_type __nw = __n / __bits_per_word; | ||
| 338 | __result.__seg_ -= __nw; | ||
| 339 | __last.__seg_ -= __nw; | ||
| 340 | std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_)); | ||
| 341 | __n -= __nw * __bits_per_word; | ||
| 342 | // do last word | ||
| 343 | if (__n > 0) { | ||
| 344 | __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n); | ||
| 345 | __storage_type __b = *--__last.__seg_ & __m; | ||
| 346 | *--__result.__seg_ &= ~__m; | ||
| 347 | *__result.__seg_ |= __b; | ||
| 348 | __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); | ||
| 349 | } | ||
| 350 | } | ||
| 351 | return __result; | ||
| 352 | } | ||
| 353 | |||
| 354 | template <class _Cp, bool _IsConst> | ||
| 355 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_unaligned( | ||
| 356 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 357 | using _In = __bit_iterator<_Cp, _IsConst>; | ||
| 358 | using difference_type = typename _In::difference_type; | ||
| 359 | using __storage_type = typename _In::__storage_type; | ||
| 360 | |||
| 361 | const int __bits_per_word = _In::__bits_per_word; | ||
| 362 | difference_type __n = __last - __first; | ||
| 363 | if (__n > 0) { | ||
| 364 | // do first word | ||
| 365 | if (__last.__ctz_ != 0) { | ||
| 366 | difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n); | ||
| 367 | __n -= __dn; | ||
| 368 | unsigned __clz_l = __bits_per_word - __last.__ctz_; | ||
| 369 | __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l); | ||
| 370 | __storage_type __b = *__last.__seg_ & __m; | ||
| 371 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 372 | __storage_type __ddn = std::min(__dn, static_cast<difference_type>(__result.__ctz_)); | ||
| 373 | if (__ddn > 0) { | ||
| 374 | __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r); | ||
| 375 | *__result.__seg_ &= ~__m; | ||
| 376 | if (__result.__ctz_ > __last.__ctz_) | ||
| 377 | *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); | ||
| 378 | else | ||
| 379 | *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_); | ||
| 380 | __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); | ||
| 381 | __dn -= __ddn; | ||
| 382 | } | ||
| 383 | if (__dn > 0) { | ||
| 384 | // __result.__ctz_ == 0 | ||
| 385 | --__result.__seg_; | ||
| 386 | __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1)); | ||
| 387 | __m = ~__storage_type(0) << __result.__ctz_; | ||
| 388 | *__result.__seg_ &= ~__m; | ||
| 389 | __last.__ctz_ -= __dn + __ddn; | ||
| 390 | *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); | ||
| 391 | } | ||
| 392 | // __last.__ctz_ = 0 | ||
| 393 | } | ||
| 394 | // __last.__ctz_ == 0 || __n == 0 | ||
| 395 | // __result.__ctz_ != 0 || __n == 0 | ||
| 396 | // do middle words | ||
| 397 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 398 | __storage_type __m = ~__storage_type(0) >> __clz_r; | ||
| 399 | for (; __n >= __bits_per_word; __n -= __bits_per_word) { | ||
| 400 | __storage_type __b = *--__last.__seg_; | ||
| 401 | *__result.__seg_ &= ~__m; | ||
| 402 | *__result.__seg_ |= __b >> __clz_r; | ||
| 403 | *--__result.__seg_ &= __m; | ||
| 404 | *__result.__seg_ |= __b << __result.__ctz_; | ||
| 405 | } | ||
| 406 | // do last word | ||
| 407 | if (__n > 0) { | ||
| 408 | __m = ~__storage_type(0) << (__bits_per_word - __n); | ||
| 409 | __storage_type __b = *--__last.__seg_ & __m; | ||
| 410 | __clz_r = __bits_per_word - __result.__ctz_; | ||
| 411 | __storage_type __dn = std::min(__n, static_cast<difference_type>(__result.__ctz_)); | ||
| 412 | __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r); | ||
| 413 | *__result.__seg_ &= ~__m; | ||
| 414 | *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_); | ||
| 415 | __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); | ||
| 416 | __n -= __dn; | ||
| 417 | if (__n > 0) { | ||
| 418 | // __result.__ctz_ == 0 | ||
| 419 | --__result.__seg_; | ||
| 420 | __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); | ||
| 421 | __m = ~__storage_type(0) << __result.__ctz_; | ||
| 422 | *__result.__seg_ &= ~__m; | ||
| 423 | *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn)); | ||
| 424 | } | ||
| 425 | } | ||
| 426 | } | ||
| 427 | return __result; | ||
| 428 | } | ||
| 429 | |||
| 430 | template <class _Cp, bool _IsConst> | ||
| 431 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> copy_backward( | ||
| 432 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 433 | if (__last.__ctz_ == __result.__ctz_) | ||
| 434 | return std::__copy_backward_aligned(__first, __last, __result); | ||
| 435 | return std::__copy_backward_unaligned(__first, __last, __result); | ||
| 436 | } | ||
| 437 | |||
| 438 | // move | ||
| 439 | |||
| 440 | template <class _Cp, bool _IsConst> | ||
| 441 | inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> | ||
| 442 | move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 443 | return std::copy(__first, __last, __result); | ||
| 444 | } | ||
| 445 | |||
| 446 | // move_backward | ||
| 447 | |||
| 448 | template <class _Cp, bool _IsConst> | ||
| 449 | inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> move_backward( | ||
| 450 | __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { | ||
| 451 | return std::copy_backward(__first, __last, __result); | ||
| 452 | } | ||
| 453 | |||
| 454 | // swap_ranges | ||
| 455 | |||
| 456 | template <class _Cl, class _Cr> | ||
| 457 | _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> __swap_ranges_aligned( | ||
| 458 | __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) { | ||
| 459 | using _I1 = __bit_iterator<_Cl, false>; | ||
| 460 | using difference_type = typename _I1::difference_type; | ||
| 461 | using __storage_type = typename _I1::__storage_type; | ||
| 462 | |||
| 463 | const int __bits_per_word = _I1::__bits_per_word; | ||
| 464 | difference_type __n = __last - __first; | ||
| 465 | if (__n > 0) { | ||
| 466 | // do first word | ||
| 467 | if (__first.__ctz_ != 0) { | ||
| 468 | unsigned __clz = __bits_per_word - __first.__ctz_; | ||
| 469 | difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); | ||
| 470 | __n -= __dn; | ||
| 471 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); | ||
| 472 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 473 | *__first.__seg_ &= ~__m; | ||
| 474 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 475 | *__result.__seg_ &= ~__m; | ||
| 476 | *__result.__seg_ |= __b1; | ||
| 477 | *__first.__seg_ |= __b2; | ||
| 478 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 479 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 480 | ++__first.__seg_; | ||
| 481 | // __first.__ctz_ = 0; | ||
| 482 | } | ||
| 483 | // __first.__ctz_ == 0; | ||
| 484 | // do middle words | ||
| 485 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_) | ||
| 486 | swap(*__first.__seg_, *__result.__seg_); | ||
| 487 | // do last word | ||
| 488 | if (__n > 0) { | ||
| 489 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 490 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 491 | *__first.__seg_ &= ~__m; | ||
| 492 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 493 | *__result.__seg_ &= ~__m; | ||
| 494 | *__result.__seg_ |= __b1; | ||
| 495 | *__first.__seg_ |= __b2; | ||
| 496 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 497 | } | ||
| 498 | } | ||
| 499 | return __result; | ||
| 500 | } | ||
| 501 | |||
| 502 | template <class _Cl, class _Cr> | ||
| 503 | _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> __swap_ranges_unaligned( | ||
| 504 | __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) { | ||
| 505 | using _I1 = __bit_iterator<_Cl, false>; | ||
| 506 | using difference_type = typename _I1::difference_type; | ||
| 507 | using __storage_type = typename _I1::__storage_type; | ||
| 508 | |||
| 509 | const int __bits_per_word = _I1::__bits_per_word; | ||
| 510 | difference_type __n = __last - __first; | ||
| 511 | if (__n > 0) { | ||
| 512 | // do first word | ||
| 513 | if (__first.__ctz_ != 0) { | ||
| 514 | unsigned __clz_f = __bits_per_word - __first.__ctz_; | ||
| 515 | difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); | ||
| 516 | __n -= __dn; | ||
| 517 | __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | ||
| 518 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 519 | *__first.__seg_ &= ~__m; | ||
| 520 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 521 | __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); | ||
| 522 | __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); | ||
| 523 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 524 | *__result.__seg_ &= ~__m; | ||
| 525 | if (__result.__ctz_ > __first.__ctz_) { | ||
| 526 | unsigned __s = __result.__ctz_ - __first.__ctz_; | ||
| 527 | *__result.__seg_ |= __b1 << __s; | ||
| 528 | *__first.__seg_ |= __b2 >> __s; | ||
| 529 | } else { | ||
| 530 | unsigned __s = __first.__ctz_ - __result.__ctz_; | ||
| 531 | *__result.__seg_ |= __b1 >> __s; | ||
| 532 | *__first.__seg_ |= __b2 << __s; | ||
| 533 | } | ||
| 534 | __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; | ||
| 535 | __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); | ||
| 536 | __dn -= __ddn; | ||
| 537 | if (__dn > 0) { | ||
| 538 | __m = ~__storage_type(0) >> (__bits_per_word - __dn); | ||
| 539 | __b2 = *__result.__seg_ & __m; | ||
| 540 | *__result.__seg_ &= ~__m; | ||
| 541 | unsigned __s = __first.__ctz_ + __ddn; | ||
| 542 | *__result.__seg_ |= __b1 >> __s; | ||
| 543 | *__first.__seg_ |= __b2 << __s; | ||
| 544 | __result.__ctz_ = static_cast<unsigned>(__dn); | ||
| 545 | } | ||
| 546 | ++__first.__seg_; | ||
| 547 | // __first.__ctz_ = 0; | ||
| 548 | } | ||
| 549 | // __first.__ctz_ == 0; | ||
| 550 | // do middle words | ||
| 551 | __storage_type __m = ~__storage_type(0) << __result.__ctz_; | ||
| 552 | unsigned __clz_r = __bits_per_word - __result.__ctz_; | ||
| 553 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) { | ||
| 554 | __storage_type __b1 = *__first.__seg_; | ||
| 555 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 556 | *__result.__seg_ &= ~__m; | ||
| 557 | *__result.__seg_ |= __b1 << __result.__ctz_; | ||
| 558 | *__first.__seg_ = __b2 >> __result.__ctz_; | ||
| 559 | ++__result.__seg_; | ||
| 560 | __b2 = *__result.__seg_ & ~__m; | ||
| 561 | *__result.__seg_ &= __m; | ||
| 562 | *__result.__seg_ |= __b1 >> __clz_r; | ||
| 563 | *__first.__seg_ |= __b2 << __clz_r; | ||
| 564 | } | ||
| 565 | // do last word | ||
| 566 | if (__n > 0) { | ||
| 567 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 568 | __storage_type __b1 = *__first.__seg_ & __m; | ||
| 569 | *__first.__seg_ &= ~__m; | ||
| 570 | __storage_type __dn = std::min<__storage_type>(__n, __clz_r); | ||
| 571 | __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); | ||
| 572 | __storage_type __b2 = *__result.__seg_ & __m; | ||
| 573 | *__result.__seg_ &= ~__m; | ||
| 574 | *__result.__seg_ |= __b1 << __result.__ctz_; | ||
| 575 | *__first.__seg_ |= __b2 >> __result.__ctz_; | ||
| 576 | __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; | ||
| 577 | __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); | ||
| 578 | __n -= __dn; | ||
| 579 | if (__n > 0) { | ||
| 580 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 581 | __b2 = *__result.__seg_ & __m; | ||
| 582 | *__result.__seg_ &= ~__m; | ||
| 583 | *__result.__seg_ |= __b1 >> __dn; | ||
| 584 | *__first.__seg_ |= __b2 << __dn; | ||
| 585 | __result.__ctz_ = static_cast<unsigned>(__n); | ||
| 586 | } | ||
| 587 | } | ||
| 588 | } | ||
| 589 | return __result; | ||
| 590 | } | ||
| 591 | |||
| 592 | template <class _Cl, class _Cr> | ||
| 593 | inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> swap_ranges( | ||
| 594 | __bit_iterator<_Cl, false> __first1, __bit_iterator<_Cl, false> __last1, __bit_iterator<_Cr, false> __first2) { | ||
| 595 | if (__first1.__ctz_ == __first2.__ctz_) | ||
| 596 | return std::__swap_ranges_aligned(__first1, __last1, __first2); | ||
| 597 | return std::__swap_ranges_unaligned(__first1, __last1, __first2); | ||
| 598 | } | ||
| 599 | |||
| 600 | // rotate | ||
| 601 | |||
| 602 | template <class _Cp> | 247 | template <class _Cp> |
| 603 | struct __bit_array { | 248 | struct __bit_array { |
| 604 | using difference_type _LIBCPP_NODEBUG = typename __size_difference_type_traits<_Cp>::difference_type; | 249 | using difference_type _LIBCPP_NODEBUG = typename __size_difference_type_traits<_Cp>::difference_type; |
| ... | @@ -630,166 +275,6 @@ struct __bit_array { | ... | @@ -630,166 +275,6 @@ struct __bit_array { |
| 630 | } | 275 | } |
| 631 | }; | 276 | }; |
| 632 | 277 | ||
| 633 | template <class _Cp> | ||
| 634 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> | ||
| 635 | rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) { | ||
| 636 | using _I1 = __bit_iterator<_Cp, false>; | ||
| 637 | using difference_type = typename _I1::difference_type; | ||
| 638 | |||
| 639 | difference_type __d1 = __middle - __first; | ||
| 640 | difference_type __d2 = __last - __middle; | ||
| 641 | _I1 __r = __first + __d2; | ||
| 642 | while (__d1 != 0 && __d2 != 0) { | ||
| 643 | if (__d1 <= __d2) { | ||
| 644 | if (__d1 <= __bit_array<_Cp>::capacity()) { | ||
| 645 | __bit_array<_Cp> __b(__d1); | ||
| 646 | std::copy(__first, __middle, __b.begin()); | ||
| 647 | std::copy(__b.begin(), __b.end(), std::copy(__middle, __last, __first)); | ||
| 648 | break; | ||
| 649 | } else { | ||
| 650 | __bit_iterator<_Cp, false> __mp = std::swap_ranges(__first, __middle, __middle); | ||
| 651 | __first = __middle; | ||
| 652 | __middle = __mp; | ||
| 653 | __d2 -= __d1; | ||
| 654 | } | ||
| 655 | } else { | ||
| 656 | if (__d2 <= __bit_array<_Cp>::capacity()) { | ||
| 657 | __bit_array<_Cp> __b(__d2); | ||
| 658 | std::copy(__middle, __last, __b.begin()); | ||
| 659 | std::copy_backward(__b.begin(), __b.end(), std::copy_backward(__first, __middle, __last)); | ||
| 660 | break; | ||
| 661 | } else { | ||
| 662 | __bit_iterator<_Cp, false> __mp = __first + __d2; | ||
| 663 | std::swap_ranges(__first, __mp, __middle); | ||
| 664 | __first = __mp; | ||
| 665 | __d1 -= __d2; | ||
| 666 | } | ||
| 667 | } | ||
| 668 | } | ||
| 669 | return __r; | ||
| 670 | } | ||
| 671 | |||
| 672 | // equal | ||
| 673 | |||
| 674 | template <class _Cp, bool _IC1, bool _IC2> | ||
| 675 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __equal_unaligned( | ||
| 676 | __bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { | ||
| 677 | using _It = __bit_iterator<_Cp, _IC1>; | ||
| 678 | using difference_type = typename _It::difference_type; | ||
| 679 | using __storage_type = typename _It::__storage_type; | ||
| 680 | |||
| 681 | const int __bits_per_word = _It::__bits_per_word; | ||
| 682 | difference_type __n = __last1 - __first1; | ||
| 683 | if (__n > 0) { | ||
| 684 | // do first word | ||
| 685 | if (__first1.__ctz_ != 0) { | ||
| 686 | unsigned __clz_f = __bits_per_word - __first1.__ctz_; | ||
| 687 | difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); | ||
| 688 | __n -= __dn; | ||
| 689 | __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); | ||
| 690 | __storage_type __b = *__first1.__seg_ & __m; | ||
| 691 | unsigned __clz_r = __bits_per_word - __first2.__ctz_; | ||
| 692 | __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); | ||
| 693 | __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); | ||
| 694 | if (__first2.__ctz_ > __first1.__ctz_) { | ||
| 695 | if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_))) | ||
| 696 | return false; | ||
| 697 | } else { | ||
| 698 | if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_))) | ||
| 699 | return false; | ||
| 700 | } | ||
| 701 | __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word; | ||
| 702 | __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_) % __bits_per_word); | ||
| 703 | __dn -= __ddn; | ||
| 704 | if (__dn > 0) { | ||
| 705 | __m = ~__storage_type(0) >> (__bits_per_word - __dn); | ||
| 706 | if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn))) | ||
| 707 | return false; | ||
| 708 | __first2.__ctz_ = static_cast<unsigned>(__dn); | ||
| 709 | } | ||
| 710 | ++__first1.__seg_; | ||
| 711 | // __first1.__ctz_ = 0; | ||
| 712 | } | ||
| 713 | // __first1.__ctz_ == 0; | ||
| 714 | // do middle words | ||
| 715 | unsigned __clz_r = __bits_per_word - __first2.__ctz_; | ||
| 716 | __storage_type __m = ~__storage_type(0) << __first2.__ctz_; | ||
| 717 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) { | ||
| 718 | __storage_type __b = *__first1.__seg_; | ||
| 719 | if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) | ||
| 720 | return false; | ||
| 721 | ++__first2.__seg_; | ||
| 722 | if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r)) | ||
| 723 | return false; | ||
| 724 | } | ||
| 725 | // do last word | ||
| 726 | if (__n > 0) { | ||
| 727 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 728 | __storage_type __b = *__first1.__seg_ & __m; | ||
| 729 | __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r)); | ||
| 730 | __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); | ||
| 731 | if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) | ||
| 732 | return false; | ||
| 733 | __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word; | ||
| 734 | __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_) % __bits_per_word); | ||
| 735 | __n -= __dn; | ||
| 736 | if (__n > 0) { | ||
| 737 | __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 738 | if ((*__first2.__seg_ & __m) != (__b >> __dn)) | ||
| 739 | return false; | ||
| 740 | } | ||
| 741 | } | ||
| 742 | } | ||
| 743 | return true; | ||
| 744 | } | ||
| 745 | |||
| 746 | template <class _Cp, bool _IC1, bool _IC2> | ||
| 747 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __equal_aligned( | ||
| 748 | __bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { | ||
| 749 | using _It = __bit_iterator<_Cp, _IC1>; | ||
| 750 | using difference_type = typename _It::difference_type; | ||
| 751 | using __storage_type = typename _It::__storage_type; | ||
| 752 | |||
| 753 | const int __bits_per_word = _It::__bits_per_word; | ||
| 754 | difference_type __n = __last1 - __first1; | ||
| 755 | if (__n > 0) { | ||
| 756 | // do first word | ||
| 757 | if (__first1.__ctz_ != 0) { | ||
| 758 | unsigned __clz = __bits_per_word - __first1.__ctz_; | ||
| 759 | difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); | ||
| 760 | __n -= __dn; | ||
| 761 | __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); | ||
| 762 | if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) | ||
| 763 | return false; | ||
| 764 | ++__first2.__seg_; | ||
| 765 | ++__first1.__seg_; | ||
| 766 | // __first1.__ctz_ = 0; | ||
| 767 | // __first2.__ctz_ = 0; | ||
| 768 | } | ||
| 769 | // __first1.__ctz_ == 0; | ||
| 770 | // __first2.__ctz_ == 0; | ||
| 771 | // do middle words | ||
| 772 | for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_) | ||
| 773 | if (*__first2.__seg_ != *__first1.__seg_) | ||
| 774 | return false; | ||
| 775 | // do last word | ||
| 776 | if (__n > 0) { | ||
| 777 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 778 | if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) | ||
| 779 | return false; | ||
| 780 | } | ||
| 781 | } | ||
| 782 | return true; | ||
| 783 | } | ||
| 784 | |||
| 785 | template <class _Cp, bool _IC1, bool _IC2> | ||
| 786 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
| 787 | equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { | ||
| 788 | if (__first1.__ctz_ == __first2.__ctz_) | ||
| 789 | return std::__equal_aligned(__first1, __last1, __first2); | ||
| 790 | return std::__equal_unaligned(__first1, __last1, __first2); | ||
| 791 | } | ||
| 792 | |||
| 793 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type> | 278 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type> |
| 794 | class __bit_iterator { | 279 | class __bit_iterator { |
| 795 | public: | 280 | public: |
| ... | @@ -844,6 +329,7 @@ public: | ... | @@ -844,6 +329,7 @@ public: |
| 844 | } | 329 | } |
| 845 | 330 | ||
| 846 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT { | 331 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT { |
| 332 | _LIBCPP_ASSERT_INTERNAL(__ctz_ < __bits_per_word, "Dereferencing an invalid __bit_iterator."); | ||
| 847 | return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >( | 333 | return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >( |
| 848 | __seg_, __storage_type(1) << __ctz_); | 334 | __seg_, __storage_type(1) << __ctz_); |
| 849 | } | 335 | } |
| ... | @@ -968,7 +454,10 @@ private: | ... | @@ -968,7 +454,10 @@ private: |
| 968 | _LIBCPP_HIDE_FROM_ABI | 454 | _LIBCPP_HIDE_FROM_ABI |
| 969 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT | 455 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT |
| 970 | : __seg_(__s), | 456 | : __seg_(__s), |
| 971 | __ctz_(__ctz) {} | 457 | __ctz_(__ctz) { |
| 458 | _LIBCPP_ASSERT_INTERNAL( | ||
| 459 | __ctz_ < __bits_per_word, "__bit_iterator initialized with an invalid number of trailing zeros."); | ||
| 460 | } | ||
| 972 | 461 | ||
| 973 | friend typename _Cp::__self; | 462 | friend typename _Cp::__self; |
| 974 | 463 | ||
| ... | @@ -989,38 +478,59 @@ private: | ... | @@ -989,38 +478,59 @@ private: |
| 989 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_unaligned( | 478 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_unaligned( |
| 990 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | 479 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); |
| 991 | template <class _Dp, bool _IC> | 480 | template <class _Dp, bool _IC> |
| 992 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> | 481 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Dp, _IC>, __bit_iterator<_Dp, false> > |
| 993 | copy(__bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | 482 | __copy_impl::operator()( |
| 483 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result) const; | ||
| 994 | template <class _Dp, bool _IC> | 484 | template <class _Dp, bool _IC> |
| 995 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_aligned( | 485 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_aligned( |
| 996 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | 486 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); |
| 997 | template <class _Dp, bool _IC> | 487 | template <class _Dp, bool _IC> |
| 998 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_unaligned( | 488 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_unaligned( |
| 999 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | 489 | __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); |
| 1000 | template <class _Dp, bool _IC> | 490 | template <class _AlgPolicy> |
| 1001 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> | 491 | friend struct __copy_backward_impl; |
| 1002 | copy_backward(__bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); | ||
| 1003 | template <class _Cl, class _Cr> | 492 | template <class _Cl, class _Cr> |
| 1004 | friend __bit_iterator<_Cr, false> | 493 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Cr, false> |
| 1005 | __swap_ranges_aligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); | 494 | __swap_ranges_aligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); |
| 1006 | template <class _Cl, class _Cr> | 495 | template <class _Cl, class _Cr> |
| 1007 | friend __bit_iterator<_Cr, false> | 496 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Cr, false> |
| 1008 | __swap_ranges_unaligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); | 497 | __swap_ranges_unaligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); |
| 1009 | template <class _Cl, class _Cr> | 498 | template <class, class _Cl, class _Cr> |
| 1010 | friend __bit_iterator<_Cr, false> | 499 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> > |
| 1011 | swap_ranges(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); | 500 | __swap_ranges(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); |
| 1012 | template <class _Dp> | 501 | template <class, class _Dp> |
| 1013 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> | 502 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false> > |
| 1014 | rotate(__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>); | 503 | __rotate(__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>); |
| 1015 | template <class _Dp, bool _IC1, bool _IC2> | 504 | template <class _Dp, bool _IsConst1, bool _IsConst2> |
| 1016 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool | ||
| 1017 | __equal_aligned(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>); | ||
| 1018 | template <class _Dp, bool _IC1, bool _IC2> | ||
| 1019 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool | 505 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool |
| 1020 | __equal_unaligned(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>); | 506 | __equal_aligned(__bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst2>); |
| 1021 | template <class _Dp, bool _IC1, bool _IC2> | 507 | template <class _Dp, bool _IsConst1, bool _IsConst2> |
| 1022 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool | 508 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool |
| 1023 | equal(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>); | 509 | __equal_unaligned(__bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst2>); |
| 510 | template <class _Dp, | ||
| 511 | bool _IsConst1, | ||
| 512 | bool _IsConst2, | ||
| 513 | class _BinaryPredicate, | ||
| 514 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, int> > | ||
| 515 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool __equal_iter_impl( | ||
| 516 | __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst2>, _BinaryPredicate); | ||
| 517 | template <class _Dp, | ||
| 518 | bool _IsConst1, | ||
| 519 | bool _IsConst2, | ||
| 520 | class _Pred, | ||
| 521 | class _Proj1, | ||
| 522 | class _Proj2, | ||
| 523 | __enable_if_t<__desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value && | ||
| 524 | __is_identity<_Proj2>::value, | ||
| 525 | int> > | ||
| 526 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool __equal_impl( | ||
| 527 | __bit_iterator<_Dp, _IsConst1> __first1, | ||
| 528 | __bit_iterator<_Dp, _IsConst1> __last1, | ||
| 529 | __bit_iterator<_Dp, _IsConst2> __first2, | ||
| 530 | __bit_iterator<_Dp, _IsConst2>, | ||
| 531 | _Pred&, | ||
| 532 | _Proj1&, | ||
| 533 | _Proj2&); | ||
| 1024 | template <bool _ToFind, class _Dp, bool _IC> | 534 | template <bool _ToFind, class _Dp, bool _IC> |
| 1025 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC> | 535 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC> |
| 1026 | __find_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type); | 536 | __find_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type); |
lib/libcxx/include/__charconv/tables.h+8-12| ... | @@ -19,16 +19,14 @@ | ... | @@ -19,16 +19,14 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if _LIBCPP_STD_VER >= 17 | ||
| 23 | |||
| 24 | namespace __itoa { | 22 | namespace __itoa { |
| 25 | 23 | ||
| 26 | inline constexpr char __base_2_lut[64] = { | 24 | inline _LIBCPP_CONSTEXPR const char __base_2_lut[64] = { |
| 27 | '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1', | 25 | '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1', |
| 28 | '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0', | 26 | '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0', |
| 29 | '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'}; | 27 | '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'}; |
| 30 | 28 | ||
| 31 | inline constexpr char __base_8_lut[128] = { | 29 | inline _LIBCPP_CONSTEXPR const char __base_8_lut[128] = { |
| 32 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2', | 30 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2', |
| 33 | '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', | 31 | '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', |
| 34 | '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0', | 32 | '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0', |
| ... | @@ -36,7 +34,7 @@ inline constexpr char __base_8_lut[128] = { | ... | @@ -36,7 +34,7 @@ inline constexpr char __base_8_lut[128] = { |
| 36 | '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', | 34 | '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', |
| 37 | '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'}; | 35 | '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'}; |
| 38 | 36 | ||
| 39 | inline constexpr char __base_16_lut[512] = { | 37 | inline _LIBCPP_CONSTEXPR const char __base_16_lut[512] = { |
| 40 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0', | 38 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0', |
| 41 | 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', | 39 | 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', |
| 42 | '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2', | 40 | '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2', |
| ... | @@ -61,7 +59,7 @@ inline constexpr char __base_16_lut[512] = { | ... | @@ -61,7 +59,7 @@ inline constexpr char __base_16_lut[512] = { |
| 61 | '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c', | 59 | '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c', |
| 62 | 'f', 'd', 'f', 'e', 'f', 'f'}; | 60 | 'f', 'd', 'f', 'e', 'f', 'f'}; |
| 63 | 61 | ||
| 64 | inline constexpr uint32_t __pow10_32[10] = { | 62 | inline _LIBCPP_CONSTEXPR const uint32_t __pow10_32[10] = { |
| 65 | UINT32_C(0), | 63 | UINT32_C(0), |
| 66 | UINT32_C(10), | 64 | UINT32_C(10), |
| 67 | UINT32_C(100), | 65 | UINT32_C(100), |
| ... | @@ -73,7 +71,7 @@ inline constexpr uint32_t __pow10_32[10] = { | ... | @@ -73,7 +71,7 @@ inline constexpr uint32_t __pow10_32[10] = { |
| 73 | UINT32_C(100000000), | 71 | UINT32_C(100000000), |
| 74 | UINT32_C(1000000000)}; | 72 | UINT32_C(1000000000)}; |
| 75 | 73 | ||
| 76 | inline constexpr uint64_t __pow10_64[20] = { | 74 | inline _LIBCPP_CONSTEXPR const uint64_t __pow10_64[20] = { |
| 77 | UINT64_C(0), | 75 | UINT64_C(0), |
| 78 | UINT64_C(10), | 76 | UINT64_C(10), |
| 79 | UINT64_C(100), | 77 | UINT64_C(100), |
| ... | @@ -96,8 +94,8 @@ inline constexpr uint64_t __pow10_64[20] = { | ... | @@ -96,8 +94,8 @@ inline constexpr uint64_t __pow10_64[20] = { |
| 96 | UINT64_C(10000000000000000000)}; | 94 | UINT64_C(10000000000000000000)}; |
| 97 | 95 | ||
| 98 | # if _LIBCPP_HAS_INT128 | 96 | # if _LIBCPP_HAS_INT128 |
| 99 | inline constexpr int __pow10_128_offset = 0; | 97 | inline _LIBCPP_CONSTEXPR const int __pow10_128_offset = 0; |
| 100 | inline constexpr __uint128_t __pow10_128[40] = { | 98 | inline _LIBCPP_CONSTEXPR const __uint128_t __pow10_128[40] = { |
| 101 | UINT64_C(0), | 99 | UINT64_C(0), |
| 102 | UINT64_C(10), | 100 | UINT64_C(10), |
| 103 | UINT64_C(100), | 101 | UINT64_C(100), |
| ... | @@ -140,7 +138,7 @@ inline constexpr __uint128_t __pow10_128[40] = { | ... | @@ -140,7 +138,7 @@ inline constexpr __uint128_t __pow10_128[40] = { |
| 140 | (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10}; | 138 | (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10}; |
| 141 | # endif | 139 | # endif |
| 142 | 140 | ||
| 143 | inline constexpr char __digits_base_10[200] = { | 141 | inline _LIBCPP_CONSTEXPR const char __digits_base_10[200] = { |
| 144 | // clang-format off | 142 | // clang-format off |
| 145 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', | 143 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', |
| 146 | '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', | 144 | '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', |
| ... | @@ -156,8 +154,6 @@ inline constexpr char __digits_base_10[200] = { | ... | @@ -156,8 +154,6 @@ inline constexpr char __digits_base_10[200] = { |
| 156 | 154 | ||
| 157 | } // namespace __itoa | 155 | } // namespace __itoa |
| 158 | 156 | ||
| 159 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 160 | |||
| 161 | _LIBCPP_END_NAMESPACE_STD | 157 | _LIBCPP_END_NAMESPACE_STD |
| 162 | 158 | ||
| 163 | #endif // _LIBCPP___CHARCONV_TABLES | 159 | #endif // _LIBCPP___CHARCONV_TABLES |
lib/libcxx/include/__charconv/to_chars_base_10.h+14-18| ... | @@ -26,55 +26,53 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,55 +26,53 @@ _LIBCPP_PUSH_MACROS |
| 26 | 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 17 | ||
| 30 | |||
| 31 | namespace __itoa { | 29 | namespace __itoa { |
| 32 | 30 | ||
| 33 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept { | 31 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) _NOEXCEPT { |
| 34 | *__first = '0' + static_cast<char>(__value); | 32 | *__first = '0' + static_cast<char>(__value); |
| 35 | return __first + 1; | 33 | return __first + 1; |
| 36 | } | 34 | } |
| 37 | 35 | ||
| 38 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept { | 36 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) _NOEXCEPT { |
| 39 | return std::copy_n(&__digits_base_10[__value * 2], 2, __first); | 37 | return std::copy_n(&__digits_base_10[__value * 2], 2, __first); |
| 40 | } | 38 | } |
| 41 | 39 | ||
| 42 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept { | 40 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) _NOEXCEPT { |
| 43 | return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100); | 41 | return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100); |
| 44 | } | 42 | } |
| 45 | 43 | ||
| 46 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept { | 44 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) _NOEXCEPT { |
| 47 | return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100); | 45 | return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept { | 48 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) _NOEXCEPT { |
| 51 | return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000); | 49 | return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000); |
| 52 | } | 50 | } |
| 53 | 51 | ||
| 54 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept { | 52 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) _NOEXCEPT { |
| 55 | return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000); | 53 | return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000); |
| 56 | } | 54 | } |
| 57 | 55 | ||
| 58 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept { | 56 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) _NOEXCEPT { |
| 59 | return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000); | 57 | return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000); |
| 60 | } | 58 | } |
| 61 | 59 | ||
| 62 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept { | 60 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) _NOEXCEPT { |
| 63 | return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000); | 61 | return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000); |
| 64 | } | 62 | } |
| 65 | 63 | ||
| 66 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept { | 64 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) _NOEXCEPT { |
| 67 | return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000); | 65 | return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000); |
| 68 | } | 66 | } |
| 69 | 67 | ||
| 70 | template <class _Tp> | 68 | template <class _Tp> |
| 71 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept { | 69 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) _NOEXCEPT { |
| 72 | return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)), | 70 | return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)), |
| 73 | static_cast<uint32_t>(__value % 100000000)); | 71 | static_cast<uint32_t>(__value % 100000000)); |
| 74 | } | 72 | } |
| 75 | 73 | ||
| 76 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* | 74 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* |
| 77 | __base_10_u32(char* __first, uint32_t __value) noexcept { | 75 | __base_10_u32(char* __first, uint32_t __value) _NOEXCEPT { |
| 78 | if (__value < 1000000) { | 76 | if (__value < 1000000) { |
| 79 | if (__value < 10000) { | 77 | if (__value < 10000) { |
| 80 | if (__value < 100) { | 78 | if (__value < 100) { |
| ... | @@ -110,7 +108,7 @@ __base_10_u32(char* __first, uint32_t __value) noexcept { | ... | @@ -110,7 +108,7 @@ __base_10_u32(char* __first, uint32_t __value) noexcept { |
| 110 | } | 108 | } |
| 111 | 109 | ||
| 112 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* | 110 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* |
| 113 | __base_10_u64(char* __buffer, uint64_t __value) noexcept { | 111 | __base_10_u64(char* __buffer, uint64_t __value) _NOEXCEPT { |
| 114 | if (__value <= UINT32_MAX) | 112 | if (__value <= UINT32_MAX) |
| 115 | return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value)); | 113 | return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value)); |
| 116 | 114 | ||
| ... | @@ -132,13 +130,13 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept { | ... | @@ -132,13 +130,13 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept { |
| 132 | /// \note The lookup table contains a partial set of exponents limiting the | 130 | /// \note The lookup table contains a partial set of exponents limiting the |
| 133 | /// range that can be used. However the range is sufficient for | 131 | /// range that can be used. However the range is sufficient for |
| 134 | /// \ref __base_10_u128. | 132 | /// \ref __base_10_u128. |
| 135 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept { | 133 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) _NOEXCEPT { |
| 136 | _LIBCPP_ASSERT_INTERNAL(__exp >= __pow10_128_offset, "Index out of bounds"); | 134 | _LIBCPP_ASSERT_INTERNAL(__exp >= __pow10_128_offset, "Index out of bounds"); |
| 137 | return __pow10_128[__exp - __pow10_128_offset]; | 135 | return __pow10_128[__exp - __pow10_128_offset]; |
| 138 | } | 136 | } |
| 139 | 137 | ||
| 140 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* | 138 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* |
| 141 | __base_10_u128(char* __buffer, __uint128_t __value) noexcept { | 139 | __base_10_u128(char* __buffer, __uint128_t __value) _NOEXCEPT { |
| 142 | _LIBCPP_ASSERT_INTERNAL( | 140 | _LIBCPP_ASSERT_INTERNAL( |
| 143 | __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fails when this isn't true."); | 141 | __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fails when this isn't true."); |
| 144 | 142 | ||
| ... | @@ -179,8 +177,6 @@ __base_10_u128(char* __buffer, __uint128_t __value) noexcept { | ... | @@ -179,8 +177,6 @@ __base_10_u128(char* __buffer, __uint128_t __value) noexcept { |
| 179 | # endif | 177 | # endif |
| 180 | } // namespace __itoa | 178 | } // namespace __itoa |
| 181 | 179 | ||
| 182 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 183 | |||
| 184 | _LIBCPP_END_NAMESPACE_STD | 180 | _LIBCPP_END_NAMESPACE_STD |
| 185 | 181 | ||
| 186 | _LIBCPP_POP_MACROS | 182 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__charconv/to_chars_integral.h+51-36| ... | @@ -39,16 +39,12 @@ _LIBCPP_PUSH_MACROS | ... | @@ -39,16 +39,12 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | ||
| 40 | _LIBCPP_BEGIN_NAMESPACE_STD | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | ||
| 42 | #if _LIBCPP_STD_VER >= 17 | ||
| 43 | |||
| 44 | to_chars_result to_chars(char*, char*, bool, int = 10) = delete; | ||
| 45 | |||
| 46 | template <typename _Tp> | 42 | template <typename _Tp> |
| 47 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 43 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 48 | __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type); | 44 | __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type); |
| 49 | 45 | ||
| 50 | template <typename _Tp> | 46 | template <typename _Tp> |
| 51 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 47 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 52 | __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) { | 48 | __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) { |
| 53 | auto __x = std::__to_unsigned_like(__value); | 49 | auto __x = std::__to_unsigned_like(__value); |
| 54 | if (__value < 0 && __first != __last) { | 50 | if (__value < 0 && __first != __last) { |
| ... | @@ -60,7 +56,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) { | ... | @@ -60,7 +56,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) { |
| 60 | } | 56 | } |
| 61 | 57 | ||
| 62 | template <typename _Tp> | 58 | template <typename _Tp> |
| 63 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 59 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 64 | __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) { | 60 | __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) { |
| 65 | using __tx = __itoa::__traits<_Tp>; | 61 | using __tx = __itoa::__traits<_Tp>; |
| 66 | auto __diff = __last - __first; | 62 | auto __diff = __last - __first; |
| ... | @@ -73,7 +69,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) { | ... | @@ -73,7 +69,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) { |
| 73 | 69 | ||
| 74 | # if _LIBCPP_HAS_INT128 | 70 | # if _LIBCPP_HAS_INT128 |
| 75 | template <> | 71 | template <> |
| 76 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 72 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 77 | __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) { | 73 | __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) { |
| 78 | // When the value fits in 64-bits use the 64-bit code path. This reduces | 74 | // When the value fits in 64-bits use the 64-bit code path. This reduces |
| 79 | // the number of expensive calculations on 128-bit values. | 75 | // the number of expensive calculations on 128-bit values. |
| ... | @@ -92,20 +88,20 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) { | ... | @@ -92,20 +88,20 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) { |
| 92 | } | 88 | } |
| 93 | # endif | 89 | # endif |
| 94 | 90 | ||
| 95 | template <class _Tp> | 91 | template <class _Tp, __enable_if_t<!is_signed<_Tp>::value, int> = 0> |
| 96 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 92 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 97 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type); | 93 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base); |
| 98 | 94 | ||
| 99 | template <typename _Tp> | 95 | template <class _Tp, __enable_if_t<is_signed<_Tp>::value, int> = 0> |
| 100 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 96 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 101 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, true_type) { | 97 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base) { |
| 102 | auto __x = std::__to_unsigned_like(__value); | 98 | auto __x = std::__to_unsigned_like(__value); |
| 103 | if (__value < 0 && __first != __last) { | 99 | if (__value < 0 && __first != __last) { |
| 104 | *__first++ = '-'; | 100 | *__first++ = '-'; |
| 105 | __x = std::__complement(__x); | 101 | __x = std::__complement(__x); |
| 106 | } | 102 | } |
| 107 | 103 | ||
| 108 | return std::__to_chars_integral(__first, __last, __x, __base, false_type()); | 104 | return std::__to_chars_integral(__first, __last, __x, __base); |
| 109 | } | 105 | } |
| 110 | 106 | ||
| 111 | namespace __itoa { | 107 | namespace __itoa { |
| ... | @@ -116,15 +112,14 @@ struct _LIBCPP_HIDDEN __integral; | ... | @@ -116,15 +112,14 @@ struct _LIBCPP_HIDDEN __integral; |
| 116 | template <> | 112 | template <> |
| 117 | struct _LIBCPP_HIDDEN __integral<2> { | 113 | struct _LIBCPP_HIDDEN __integral<2> { |
| 118 | template <typename _Tp> | 114 | template <typename _Tp> |
| 119 | _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { | 115 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT { |
| 120 | // If value == 0 still need one digit. If the value != this has no | 116 | // If value == 0 still need one digit. If the value != this has no |
| 121 | // effect since the code scans for the most significant bit set. (Note | 117 | // effect since the code scans for the most significant bit set. |
| 122 | // that __libcpp_clz doesn't work for 0.) | 118 | return numeric_limits<_Tp>::digits - std::__countl_zero(__value | 1); |
| 123 | return numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1); | ||
| 124 | } | 119 | } |
| 125 | 120 | ||
| 126 | template <typename _Tp> | 121 | template <typename _Tp> |
| 127 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result | 122 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result |
| 128 | __to_chars(char* __first, char* __last, _Tp __value) { | 123 | __to_chars(char* __first, char* __last, _Tp __value) { |
| 129 | ptrdiff_t __cap = __last - __first; | 124 | ptrdiff_t __cap = __last - __first; |
| 130 | int __n = __width(__value); | 125 | int __n = __width(__value); |
| ... | @@ -152,15 +147,14 @@ struct _LIBCPP_HIDDEN __integral<2> { | ... | @@ -152,15 +147,14 @@ struct _LIBCPP_HIDDEN __integral<2> { |
| 152 | template <> | 147 | template <> |
| 153 | struct _LIBCPP_HIDDEN __integral<8> { | 148 | struct _LIBCPP_HIDDEN __integral<8> { |
| 154 | template <typename _Tp> | 149 | template <typename _Tp> |
| 155 | _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { | 150 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT { |
| 156 | // If value == 0 still need one digit. If the value != this has no | 151 | // If value == 0 still need one digit. If the value != this has no |
| 157 | // effect since the code scans for the most significat bit set. (Note | 152 | // effect since the code scans for the most significat bit set. |
| 158 | // that __libcpp_clz doesn't work for 0.) | 153 | return ((numeric_limits<_Tp>::digits - std::__countl_zero(__value | 1)) + 2) / 3; |
| 159 | return ((numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1)) + 2) / 3; | ||
| 160 | } | 154 | } |
| 161 | 155 | ||
| 162 | template <typename _Tp> | 156 | template <typename _Tp> |
| 163 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result | 157 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result |
| 164 | __to_chars(char* __first, char* __last, _Tp __value) { | 158 | __to_chars(char* __first, char* __last, _Tp __value) { |
| 165 | ptrdiff_t __cap = __last - __first; | 159 | ptrdiff_t __cap = __last - __first; |
| 166 | int __n = __width(__value); | 160 | int __n = __width(__value); |
| ... | @@ -188,15 +182,14 @@ struct _LIBCPP_HIDDEN __integral<8> { | ... | @@ -188,15 +182,14 @@ struct _LIBCPP_HIDDEN __integral<8> { |
| 188 | template <> | 182 | template <> |
| 189 | struct _LIBCPP_HIDDEN __integral<16> { | 183 | struct _LIBCPP_HIDDEN __integral<16> { |
| 190 | template <typename _Tp> | 184 | template <typename _Tp> |
| 191 | _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { | 185 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT { |
| 192 | // If value == 0 still need one digit. If the value != this has no | 186 | // If value == 0 still need one digit. If the value != this has no |
| 193 | // effect since the code scans for the most significat bit set. (Note | 187 | // effect since the code scans for the most significat bit set. |
| 194 | // that __libcpp_clz doesn't work for 0.) | 188 | return (numeric_limits<_Tp>::digits - std::__countl_zero(__value | 1) + 3) / 4; |
| 195 | return (numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1) + 3) / 4; | ||
| 196 | } | 189 | } |
| 197 | 190 | ||
| 198 | template <typename _Tp> | 191 | template <typename _Tp> |
| 199 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result | 192 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result |
| 200 | __to_chars(char* __first, char* __last, _Tp __value) { | 193 | __to_chars(char* __first, char* __last, _Tp __value) { |
| 201 | ptrdiff_t __cap = __last - __first; | 194 | ptrdiff_t __cap = __last - __first; |
| 202 | int __n = __width(__value); | 195 | int __n = __width(__value); |
| ... | @@ -235,13 +228,13 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt | ... | @@ -235,13 +228,13 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt |
| 235 | } | 228 | } |
| 236 | 229 | ||
| 237 | template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0> | 230 | template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0> |
| 238 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 231 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 239 | __to_chars_integral(char* __first, char* __last, _Tp __value) { | 232 | __to_chars_integral(char* __first, char* __last, _Tp __value) { |
| 240 | return __itoa::__integral<_Base>::__to_chars(__first, __last, __value); | 233 | return __itoa::__integral<_Base>::__to_chars(__first, __last, __value); |
| 241 | } | 234 | } |
| 242 | 235 | ||
| 243 | template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0> | 236 | template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0> |
| 244 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 237 | _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 245 | __to_chars_integral(char* __first, char* __last, _Tp __value) { | 238 | __to_chars_integral(char* __first, char* __last, _Tp __value) { |
| 246 | return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value)); | 239 | return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value)); |
| 247 | } | 240 | } |
| ... | @@ -272,9 +265,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt | ... | @@ -272,9 +265,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt |
| 272 | __libcpp_unreachable(); | 265 | __libcpp_unreachable(); |
| 273 | } | 266 | } |
| 274 | 267 | ||
| 275 | template <typename _Tp> | 268 | template <class _Tp, __enable_if_t<!is_signed<_Tp>::value, int> > |
| 276 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 269 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result |
| 277 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type) { | 270 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base) { |
| 278 | if (__base == 10) [[likely]] | 271 | if (__base == 10) [[likely]] |
| 279 | return std::__to_chars_itoa(__first, __last, __value, false_type()); | 272 | return std::__to_chars_itoa(__first, __last, __value, false_type()); |
| 280 | 273 | ||
| ... | @@ -302,6 +295,28 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_ | ... | @@ -302,6 +295,28 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_ |
| 302 | return {__last, errc(0)}; | 295 | return {__last, errc(0)}; |
| 303 | } | 296 | } |
| 304 | 297 | ||
| 298 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 char __hex_to_upper(char __c) { | ||
| 299 | switch (__c) { | ||
| 300 | case 'a': | ||
| 301 | return 'A'; | ||
| 302 | case 'b': | ||
| 303 | return 'B'; | ||
| 304 | case 'c': | ||
| 305 | return 'C'; | ||
| 306 | case 'd': | ||
| 307 | return 'D'; | ||
| 308 | case 'e': | ||
| 309 | return 'E'; | ||
| 310 | case 'f': | ||
| 311 | return 'F'; | ||
| 312 | } | ||
| 313 | return __c; | ||
| 314 | } | ||
| 315 | |||
| 316 | #if _LIBCPP_STD_VER >= 17 | ||
| 317 | |||
| 318 | to_chars_result to_chars(char*, char*, bool, int = 10) = delete; | ||
| 319 | |||
| 305 | template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> | 320 | template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> |
| 306 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result | 321 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result |
| 307 | to_chars(char* __first, char* __last, _Tp __value) { | 322 | to_chars(char* __first, char* __last, _Tp __value) { |
| ... | @@ -316,7 +331,7 @@ to_chars(char* __first, char* __last, _Tp __value, int __base) { | ... | @@ -316,7 +331,7 @@ to_chars(char* __first, char* __last, _Tp __value, int __base) { |
| 316 | _LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]"); | 331 | _LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]"); |
| 317 | 332 | ||
| 318 | using _Type = __make_32_64_or_128_bit_t<_Tp>; | 333 | using _Type = __make_32_64_or_128_bit_t<_Tp>; |
| 319 | return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>()); | 334 | return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base); |
| 320 | } | 335 | } |
| 321 | 336 | ||
| 322 | #endif // _LIBCPP_STD_VER >= 17 | 337 | #endif // _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/__charconv/to_chars_result.h+9| ... | @@ -34,6 +34,15 @@ struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result { | ... | @@ -34,6 +34,15 @@ struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result { |
| 34 | 34 | ||
| 35 | #endif // _LIBCPP_STD_VER >= 17 | 35 | #endif // _LIBCPP_STD_VER >= 17 |
| 36 | 36 | ||
| 37 | struct __to_chars_result { | ||
| 38 | char* __ptr; | ||
| 39 | errc __ec; | ||
| 40 | |||
| 41 | #if _LIBCPP_STD_VER >= 17 | ||
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr operator to_chars_result() { return {__ptr, __ec}; } | ||
| 43 | #endif | ||
| 44 | }; | ||
| 45 | |||
| 37 | _LIBCPP_END_NAMESPACE_STD | 46 | _LIBCPP_END_NAMESPACE_STD |
| 38 | 47 | ||
| 39 | #endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H | 48 | #endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H |
lib/libcxx/include/__charconv/traits.h+11-23| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | #include <__charconv/tables.h> | 15 | #include <__charconv/tables.h> |
| 16 | #include <__charconv/to_chars_base_10.h> | 16 | #include <__charconv/to_chars_base_10.h> |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__memory/addressof.h> | ||
| 18 | #include <__type_traits/enable_if.h> | 19 | #include <__type_traits/enable_if.h> |
| 19 | #include <__type_traits/is_unsigned.h> | 20 | #include <__type_traits/is_unsigned.h> |
| 20 | #include <cstdint> | 21 | #include <cstdint> |
| ... | @@ -29,27 +30,22 @@ _LIBCPP_PUSH_MACROS | ... | @@ -29,27 +30,22 @@ _LIBCPP_PUSH_MACROS |
| 29 | 30 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 32 | ||
| 32 | #if _LIBCPP_STD_VER >= 17 | ||
| 33 | |||
| 34 | namespace __itoa { | 33 | namespace __itoa { |
| 35 | 34 | ||
| 36 | template <typename _Tp, typename = void> | 35 | template <typename _Tp, typename = void> |
| 37 | struct _LIBCPP_HIDDEN __traits_base; | 36 | struct _LIBCPP_HIDDEN __traits_base; |
| 38 | 37 | ||
| 39 | template <typename _Tp> | 38 | template <typename _Tp> |
| 40 | struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uint32_t)>> { | 39 | struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uint32_t)> > { |
| 41 | using type = uint32_t; | 40 | using type = uint32_t; |
| 42 | 41 | ||
| 43 | /// The width estimation using a log10 algorithm. | 42 | /// The width estimation using a log10 algorithm. |
| 44 | /// | 43 | /// |
| 45 | /// The algorithm is based on | 44 | /// The algorithm is based on |
| 46 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 | 45 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 |
| 47 | /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that | 46 | /// Instead of using IntegerLogBase2 it uses __countl_zero. |
| 48 | /// function requires its input to have at least one bit set the value of | ||
| 49 | /// zero is set to one. This means the first element of the lookup table is | ||
| 50 | /// zero. | ||
| 51 | static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { | 47 | static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { |
| 52 | auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | 48 | auto __t = (32 - std::__countl_zero(static_cast<type>(__v | 1))) * 1233 >> 12; |
| 53 | return __t - (__v < __itoa::__pow10_32[__t]) + 1; | 49 | return __t - (__v < __itoa::__pow10_32[__t]) + 1; |
| 54 | } | 50 | } |
| 55 | 51 | ||
| ... | @@ -63,19 +59,16 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin | ... | @@ -63,19 +59,16 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin |
| 63 | }; | 59 | }; |
| 64 | 60 | ||
| 65 | template <typename _Tp> | 61 | template <typename _Tp> |
| 66 | struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uint64_t)>> { | 62 | struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uint64_t)> > { |
| 67 | using type = uint64_t; | 63 | using type = uint64_t; |
| 68 | 64 | ||
| 69 | /// The width estimation using a log10 algorithm. | 65 | /// The width estimation using a log10 algorithm. |
| 70 | /// | 66 | /// |
| 71 | /// The algorithm is based on | 67 | /// The algorithm is based on |
| 72 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 | 68 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 |
| 73 | /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that | 69 | /// Instead of using IntegerLogBase2 it uses __countl_zero. |
| 74 | /// function requires its input to have at least one bit set the value of | ||
| 75 | /// zero is set to one. This means the first element of the lookup table is | ||
| 76 | /// zero. | ||
| 77 | static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { | 70 | static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { |
| 78 | auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | 71 | auto __t = (64 - std::__countl_zero(static_cast<type>(__v | 1))) * 1233 >> 12; |
| 79 | return __t - (__v < __itoa::__pow10_64[__t]) + 1; | 72 | return __t - (__v < __itoa::__pow10_64[__t]) + 1; |
| 80 | } | 73 | } |
| 81 | 74 | ||
| ... | @@ -97,15 +90,12 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u | ... | @@ -97,15 +90,12 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u |
| 97 | /// | 90 | /// |
| 98 | /// The algorithm is based on | 91 | /// The algorithm is based on |
| 99 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 | 92 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 |
| 100 | /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that | 93 | /// Instead of using IntegerLogBase2 it uses __countl_zero. |
| 101 | /// function requires its input to have at least one bit set the value of | ||
| 102 | /// zero is set to one. This means the first element of the lookup table is | ||
| 103 | /// zero. | ||
| 104 | static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { | 94 | static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { |
| 105 | _LIBCPP_ASSERT_INTERNAL( | 95 | _LIBCPP_ASSERT_INTERNAL( |
| 106 | __v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true."); | 96 | __v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true."); |
| 107 | // There's always a bit set in the upper 64-bits. | 97 | // There's always a bit set in the upper 64-bits. |
| 108 | auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12; | 98 | auto __t = (128 - std::__countl_zero(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12; |
| 109 | _LIBCPP_ASSERT_INTERNAL(__t >= __itoa::__pow10_128_offset, "Index out of bounds"); | 99 | _LIBCPP_ASSERT_INTERNAL(__t >= __itoa::__pow10_128_offset, "Index out of bounds"); |
| 110 | // __t is adjusted since the lookup table misses the lower entries. | 100 | // __t is adjusted since the lookup table misses the lower entries. |
| 111 | return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1; | 101 | return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1; |
| ... | @@ -142,7 +132,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) { | ... | @@ -142,7 +132,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) { |
| 142 | template <typename _Tp> | 132 | template <typename _Tp> |
| 143 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) { | 133 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) { |
| 144 | static_assert(is_unsigned<_Tp>::value, ""); | 134 | static_assert(is_unsigned<_Tp>::value, ""); |
| 145 | return __builtin_mul_overflow(__a, __b, &__r); | 135 | return __builtin_mul_overflow(__a, __b, std::addressof(__r)); |
| 146 | } | 136 | } |
| 147 | 137 | ||
| 148 | template <typename _Tp, typename _Up> | 138 | template <typename _Tp, typename _Up> |
| ... | @@ -152,7 +142,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool _LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed | ... | @@ -152,7 +142,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool _LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed |
| 152 | 142 | ||
| 153 | template <typename _Tp> | 143 | template <typename _Tp> |
| 154 | struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> { | 144 | struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> { |
| 155 | static constexpr int digits = numeric_limits<_Tp>::digits10 + 1; | 145 | static _LIBCPP_CONSTEXPR const int digits = numeric_limits<_Tp>::digits10 + 1; |
| 156 | using __traits_base<_Tp>::__pow; | 146 | using __traits_base<_Tp>::__pow; |
| 157 | using typename __traits_base<_Tp>::type; | 147 | using typename __traits_base<_Tp>::type; |
| 158 | 148 | ||
| ... | @@ -191,8 +181,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Tp __complement(_Tp | ... | @@ -191,8 +181,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Tp __complement(_Tp |
| 191 | return _Tp(~__x + 1); | 181 | return _Tp(~__x + 1); |
| 192 | } | 182 | } |
| 193 | 183 | ||
| 194 | #endif // _LIBCPP_STD_VER >= 17 | ||
| 195 | |||
| 196 | _LIBCPP_END_NAMESPACE_STD | 184 | _LIBCPP_END_NAMESPACE_STD |
| 197 | 185 | ||
| 198 | _LIBCPP_POP_MACROS | 186 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__chrono/convert_to_tm.h+24-10| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | #include <__chrono/day.h> | 15 | #include <__chrono/day.h> |
| 16 | #include <__chrono/duration.h> | 16 | #include <__chrono/duration.h> |
| 17 | #include <__chrono/file_clock.h> | 17 | #include <__chrono/file_clock.h> |
| 18 | #include <__chrono/gps_clock.h> | ||
| 18 | #include <__chrono/hh_mm_ss.h> | 19 | #include <__chrono/hh_mm_ss.h> |
| 19 | #include <__chrono/local_info.h> | 20 | #include <__chrono/local_info.h> |
| 20 | #include <__chrono/month.h> | 21 | #include <__chrono/month.h> |
| ... | @@ -23,6 +24,7 @@ | ... | @@ -23,6 +24,7 @@ |
| 23 | #include <__chrono/statically_widen.h> | 24 | #include <__chrono/statically_widen.h> |
| 24 | #include <__chrono/sys_info.h> | 25 | #include <__chrono/sys_info.h> |
| 25 | #include <__chrono/system_clock.h> | 26 | #include <__chrono/system_clock.h> |
| 27 | #include <__chrono/tai_clock.h> | ||
| 26 | #include <__chrono/time_point.h> | 28 | #include <__chrono/time_point.h> |
| 27 | #include <__chrono/utc_clock.h> | 29 | #include <__chrono/utc_clock.h> |
| 28 | #include <__chrono/weekday.h> | 30 | #include <__chrono/weekday.h> |
| ... | @@ -35,6 +37,7 @@ | ... | @@ -35,6 +37,7 @@ |
| 35 | #include <__config> | 37 | #include <__config> |
| 36 | #include <__format/format_error.h> | 38 | #include <__format/format_error.h> |
| 37 | #include <__memory/addressof.h> | 39 | #include <__memory/addressof.h> |
| 40 | #include <__type_traits/common_type.h> | ||
| 38 | #include <__type_traits/is_convertible.h> | 41 | #include <__type_traits/is_convertible.h> |
| 39 | #include <__type_traits/is_specialization.h> | 42 | #include <__type_traits/is_specialization.h> |
| 40 | #include <cstdint> | 43 | #include <cstdint> |
| ... | @@ -112,6 +115,21 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::utc_time<_Duration> __tp) { | ... | @@ -112,6 +115,21 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::utc_time<_Duration> __tp) { |
| 112 | return __result; | 115 | return __result; |
| 113 | } | 116 | } |
| 114 | 117 | ||
| 118 | template <class _Tm, class _Duration> | ||
| 119 | _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::tai_time<_Duration> __tp) { | ||
| 120 | using _Rp = common_type_t<_Duration, chrono::seconds>; | ||
| 121 | // The time between the TAI epoch (1958-01-01) and UNIX epoch (1970-01-01). | ||
| 122 | // This avoids leap second conversion when going from TAI to UTC. | ||
| 123 | // (It also avoids issues when the date is before the UTC epoch.) | ||
| 124 | constexpr chrono::seconds __offset{4383 * 24 * 60 * 60}; | ||
| 125 | return std::__convert_to_tm<_Tm>(chrono::sys_time<_Rp>{__tp.time_since_epoch() - __offset}); | ||
| 126 | } | ||
| 127 | |||
| 128 | template <class _Tm, class _Duration> | ||
| 129 | _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::gps_time<_Duration> __tp) { | ||
| 130 | return std::__convert_to_tm<_Tm>(chrono::utc_clock::to_sys(chrono::gps_clock::to_utc(__tp))); | ||
| 131 | } | ||
| 132 | |||
| 115 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | 133 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB |
| 116 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | 134 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION |
| 117 | 135 | ||
| ... | @@ -125,20 +143,16 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { | ... | @@ -125,20 +143,16 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { |
| 125 | # endif | 143 | # endif |
| 126 | 144 | ||
| 127 | if constexpr (__is_time_point<_ChronoT>) { | 145 | if constexpr (__is_time_point<_ChronoT>) { |
| 128 | if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>) | 146 | if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>) |
| 129 | return std::__convert_to_tm<_Tm>(__value); | ||
| 130 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | ||
| 131 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | ||
| 132 | else if constexpr (same_as<typename _ChronoT::clock, chrono::utc_clock>) | ||
| 133 | return std::__convert_to_tm<_Tm>(__value); | ||
| 134 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | ||
| 135 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | ||
| 136 | else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>) | ||
| 137 | return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value)); | 147 | return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value)); |
| 138 | else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>) | 148 | else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>) |
| 139 | return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()}); | 149 | return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()}); |
| 140 | else | 150 | else { |
| 151 | // Note that some clocks have specializations __convert_to_tm for their | ||
| 152 | // time_point. These don't need to be added here. They do not trigger | ||
| 153 | // this assert. | ||
| 141 | static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization"); | 154 | static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization"); |
| 155 | } | ||
| 142 | } else if constexpr (chrono::__is_duration_v<_ChronoT>) { | 156 | } else if constexpr (chrono::__is_duration_v<_ChronoT>) { |
| 143 | // [time.format]/6 | 157 | // [time.format]/6 |
| 144 | // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p, | 158 | // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p, |
lib/libcxx/include/__chrono/duration.h+5-5| ... | @@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | namespace chrono { | 32 | namespace chrono { |
| 33 | 33 | ||
| 34 | template <class _Rep, class _Period = ratio<1> > | 34 | template <class _Rep, class _Period = ratio<1> > |
| 35 | class _LIBCPP_TEMPLATE_VIS duration; | 35 | class duration; |
| 36 | 36 | ||
| 37 | template <class _Tp> | 37 | template <class _Tp> |
| 38 | inline const bool __is_duration_v = false; | 38 | inline const bool __is_duration_v = false; |
| ... | @@ -52,7 +52,7 @@ inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = tru | ... | @@ -52,7 +52,7 @@ inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = tru |
| 52 | } // namespace chrono | 52 | } // namespace chrono |
| 53 | 53 | ||
| 54 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | 54 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 55 | struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > { | 55 | struct common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > { |
| 56 | typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type; | 56 | typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type; |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| ... | @@ -107,7 +107,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const d | ... | @@ -107,7 +107,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const d |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | template <class _Rep> | 109 | template <class _Rep> |
| 110 | struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; | 110 | struct treat_as_floating_point : is_floating_point<_Rep> {}; |
| 111 | 111 | ||
| 112 | #if _LIBCPP_STD_VER >= 17 | 112 | #if _LIBCPP_STD_VER >= 17 |
| 113 | template <class _Rep> | 113 | template <class _Rep> |
| ... | @@ -115,7 +115,7 @@ inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>: | ... | @@ -115,7 +115,7 @@ inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>: |
| 115 | #endif | 115 | #endif |
| 116 | 116 | ||
| 117 | template <class _Rep> | 117 | template <class _Rep> |
| 118 | struct _LIBCPP_TEMPLATE_VIS duration_values { | 118 | struct duration_values { |
| 119 | public: | 119 | public: |
| 120 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); } | 120 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); } |
| 121 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); } | 121 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); } |
| ... | @@ -156,7 +156,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration< | ... | @@ -156,7 +156,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration< |
| 156 | // duration | 156 | // duration |
| 157 | 157 | ||
| 158 | template <class _Rep, class _Period> | 158 | template <class _Rep, class _Period> |
| 159 | class _LIBCPP_TEMPLATE_VIS duration { | 159 | class duration { |
| 160 | static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration"); | 160 | static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration"); |
| 161 | static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio"); | 161 | static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio"); |
| 162 | static_assert(_Period::num > 0, "duration period must be positive"); | 162 | static_assert(_Period::num > 0, "duration period must be positive"); |
lib/libcxx/include/__chrono/formatter.h+54-24| ... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
| 21 | # include <__chrono/day.h> | 21 | # include <__chrono/day.h> |
| 22 | # include <__chrono/duration.h> | 22 | # include <__chrono/duration.h> |
| 23 | # include <__chrono/file_clock.h> | 23 | # include <__chrono/file_clock.h> |
| 24 | # include <__chrono/gps_clock.h> | ||
| 24 | # include <__chrono/hh_mm_ss.h> | 25 | # include <__chrono/hh_mm_ss.h> |
| 25 | # include <__chrono/local_info.h> | 26 | # include <__chrono/local_info.h> |
| 26 | # include <__chrono/month.h> | 27 | # include <__chrono/month.h> |
| ... | @@ -31,6 +32,7 @@ | ... | @@ -31,6 +32,7 @@ |
| 31 | # include <__chrono/statically_widen.h> | 32 | # include <__chrono/statically_widen.h> |
| 32 | # include <__chrono/sys_info.h> | 33 | # include <__chrono/sys_info.h> |
| 33 | # include <__chrono/system_clock.h> | 34 | # include <__chrono/system_clock.h> |
| 35 | # include <__chrono/tai_clock.h> | ||
| 34 | # include <__chrono/time_point.h> | 36 | # include <__chrono/time_point.h> |
| 35 | # include <__chrono/utc_clock.h> | 37 | # include <__chrono/utc_clock.h> |
| 36 | # include <__chrono/weekday.h> | 38 | # include <__chrono/weekday.h> |
| ... | @@ -48,12 +50,14 @@ | ... | @@ -48,12 +50,14 @@ |
| 48 | # include <__format/formatter.h> | 50 | # include <__format/formatter.h> |
| 49 | # include <__format/parser_std_format_spec.h> | 51 | # include <__format/parser_std_format_spec.h> |
| 50 | # include <__format/write_escaped.h> | 52 | # include <__format/write_escaped.h> |
| 53 | # include <__iterator/istreambuf_iterator.h> | ||
| 54 | # include <__iterator/ostreambuf_iterator.h> | ||
| 55 | # include <__locale_dir/time.h> | ||
| 51 | # include <__memory/addressof.h> | 56 | # include <__memory/addressof.h> |
| 52 | # include <__type_traits/is_specialization.h> | 57 | # include <__type_traits/is_specialization.h> |
| 53 | # include <cmath> | 58 | # include <cmath> |
| 54 | # include <ctime> | 59 | # include <ctime> |
| 55 | # include <limits> | 60 | # include <limits> |
| 56 | # include <locale> | ||
| 57 | # include <sstream> | 61 | # include <sstream> |
| 58 | # include <string_view> | 62 | # include <string_view> |
| 59 | 63 | ||
| ... | @@ -232,9 +236,13 @@ _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const | ... | @@ -232,9 +236,13 @@ _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const |
| 232 | if constexpr (same_as<_Tp, chrono::sys_info>) | 236 | if constexpr (same_as<_Tp, chrono::sys_info>) |
| 233 | return {__value.abbrev, __value.offset}; | 237 | return {__value.abbrev, __value.offset}; |
| 234 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | 238 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM |
| 239 | else if constexpr (__is_time_point<_Tp> && requires { requires same_as<typename _Tp::clock, chrono::tai_clock>; }) | ||
| 240 | return {"TAI", chrono::seconds{0}}; | ||
| 241 | else if constexpr (__is_time_point<_Tp> && requires { requires same_as<typename _Tp::clock, chrono::gps_clock>; }) | ||
| 242 | return {"GPS", chrono::seconds{0}}; | ||
| 235 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) | 243 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) |
| 236 | return __formatter::__convert_to_time_zone(__value.get_info()); | 244 | return __formatter::__convert_to_time_zone(__value.get_info()); |
| 237 | # endif | 245 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM |
| 238 | else | 246 | else |
| 239 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | 247 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB |
| 240 | return {"UTC", chrono::seconds{0}}; | 248 | return {"UTC", chrono::seconds{0}}; |
| ... | @@ -312,7 +320,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( | ... | @@ -312,7 +320,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 312 | case _CharT('T'): | 320 | case _CharT('T'): |
| 313 | __facet.put( | 321 | __facet.put( |
| 314 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); | 322 | {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1)); |
| 315 | if constexpr (__use_fraction<_Tp>()) | 323 | if constexpr (__formatter::__use_fraction<_Tp>()) |
| 316 | __formatter::__format_sub_seconds(__sstr, __value); | 324 | __formatter::__format_sub_seconds(__sstr, __value); |
| 317 | break; | 325 | break; |
| 318 | 326 | ||
| ... | @@ -375,7 +383,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( | ... | @@ -375,7 +383,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 375 | break; | 383 | break; |
| 376 | 384 | ||
| 377 | case _CharT('O'): | 385 | case _CharT('O'): |
| 378 | if constexpr (__use_fraction<_Tp>()) { | 386 | if constexpr (__formatter::__use_fraction<_Tp>()) { |
| 379 | // Handle OS using the normal representation for the non-fractional | 387 | // Handle OS using the normal representation for the non-fractional |
| 380 | // part. There seems to be no locale information regarding how the | 388 | // part. There seems to be no locale information regarding how the |
| 381 | // fractional part should be formatted. | 389 | // fractional part should be formatted. |
| ... | @@ -692,7 +700,7 @@ __format_chrono(const _Tp& __value, | ... | @@ -692,7 +700,7 @@ __format_chrono(const _Tp& __value, |
| 692 | } // namespace __formatter | 700 | } // namespace __formatter |
| 693 | 701 | ||
| 694 | template <__fmt_char_type _CharT> | 702 | template <__fmt_char_type _CharT> |
| 695 | struct _LIBCPP_TEMPLATE_VIS __formatter_chrono { | 703 | struct __formatter_chrono { |
| 696 | public: | 704 | public: |
| 697 | template <class _ParseContext> | 705 | template <class _ParseContext> |
| 698 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator | 706 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator |
| ... | @@ -710,7 +718,7 @@ public: | ... | @@ -710,7 +718,7 @@ public: |
| 710 | }; | 718 | }; |
| 711 | 719 | ||
| 712 | template <class _Duration, __fmt_char_type _CharT> | 720 | template <class _Duration, __fmt_char_type _CharT> |
| 713 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { | 721 | struct formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 714 | public: | 722 | public: |
| 715 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 723 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 716 | 724 | ||
| ... | @@ -724,7 +732,29 @@ public: | ... | @@ -724,7 +732,29 @@ public: |
| 724 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | 732 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB |
| 725 | 733 | ||
| 726 | template <class _Duration, __fmt_char_type _CharT> | 734 | template <class _Duration, __fmt_char_type _CharT> |
| 727 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { | 735 | struct formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 736 | public: | ||
| 737 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | ||
| 738 | |||
| 739 | template <class _ParseContext> | ||
| 740 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | ||
| 741 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); | ||
| 742 | } | ||
| 743 | }; | ||
| 744 | |||
| 745 | template <class _Duration, __fmt_char_type _CharT> | ||
| 746 | struct formatter<chrono::tai_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { | ||
| 747 | public: | ||
| 748 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | ||
| 749 | |||
| 750 | template <class _ParseContext> | ||
| 751 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | ||
| 752 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); | ||
| 753 | } | ||
| 754 | }; | ||
| 755 | |||
| 756 | template <class _Duration, __fmt_char_type _CharT> | ||
| 757 | struct formatter<chrono::gps_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { | ||
| 728 | public: | 758 | public: |
| 729 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 759 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 730 | 760 | ||
| ... | @@ -738,7 +768,7 @@ public: | ... | @@ -738,7 +768,7 @@ public: |
| 738 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | 768 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM |
| 739 | 769 | ||
| 740 | template <class _Duration, __fmt_char_type _CharT> | 770 | template <class _Duration, __fmt_char_type _CharT> |
| 741 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { | 771 | struct formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 742 | public: | 772 | public: |
| 743 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 773 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 744 | 774 | ||
| ... | @@ -749,7 +779,7 @@ public: | ... | @@ -749,7 +779,7 @@ public: |
| 749 | }; | 779 | }; |
| 750 | 780 | ||
| 751 | template <class _Duration, __fmt_char_type _CharT> | 781 | template <class _Duration, __fmt_char_type _CharT> |
| 752 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { | 782 | struct formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 753 | public: | 783 | public: |
| 754 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 784 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 755 | 785 | ||
| ... | @@ -783,7 +813,7 @@ public: | ... | @@ -783,7 +813,7 @@ public: |
| 783 | }; | 813 | }; |
| 784 | 814 | ||
| 785 | template <__fmt_char_type _CharT> | 815 | template <__fmt_char_type _CharT> |
| 786 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> { | 816 | struct formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> { |
| 787 | public: | 817 | public: |
| 788 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 818 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 789 | 819 | ||
| ... | @@ -794,7 +824,7 @@ public: | ... | @@ -794,7 +824,7 @@ public: |
| 794 | }; | 824 | }; |
| 795 | 825 | ||
| 796 | template <__fmt_char_type _CharT> | 826 | template <__fmt_char_type _CharT> |
| 797 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> { | 827 | struct formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> { |
| 798 | public: | 828 | public: |
| 799 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 829 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 800 | 830 | ||
| ... | @@ -805,7 +835,7 @@ public: | ... | @@ -805,7 +835,7 @@ public: |
| 805 | }; | 835 | }; |
| 806 | 836 | ||
| 807 | template <__fmt_char_type _CharT> | 837 | template <__fmt_char_type _CharT> |
| 808 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> { | 838 | struct formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> { |
| 809 | public: | 839 | public: |
| 810 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 840 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 811 | 841 | ||
| ... | @@ -816,7 +846,7 @@ public: | ... | @@ -816,7 +846,7 @@ public: |
| 816 | }; | 846 | }; |
| 817 | 847 | ||
| 818 | template <__fmt_char_type _CharT> | 848 | template <__fmt_char_type _CharT> |
| 819 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> { | 849 | struct formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> { |
| 820 | public: | 850 | public: |
| 821 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 851 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 822 | 852 | ||
| ... | @@ -827,7 +857,7 @@ public: | ... | @@ -827,7 +857,7 @@ public: |
| 827 | }; | 857 | }; |
| 828 | 858 | ||
| 829 | template <__fmt_char_type _CharT> | 859 | template <__fmt_char_type _CharT> |
| 830 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> { | 860 | struct formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> { |
| 831 | public: | 861 | public: |
| 832 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 862 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 833 | 863 | ||
| ... | @@ -838,7 +868,7 @@ public: | ... | @@ -838,7 +868,7 @@ public: |
| 838 | }; | 868 | }; |
| 839 | 869 | ||
| 840 | template <__fmt_char_type _CharT> | 870 | template <__fmt_char_type _CharT> |
| 841 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> { | 871 | struct formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> { |
| 842 | public: | 872 | public: |
| 843 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 873 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 844 | 874 | ||
| ... | @@ -849,7 +879,7 @@ public: | ... | @@ -849,7 +879,7 @@ public: |
| 849 | }; | 879 | }; |
| 850 | 880 | ||
| 851 | template <__fmt_char_type _CharT> | 881 | template <__fmt_char_type _CharT> |
| 852 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> { | 882 | struct formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> { |
| 853 | public: | 883 | public: |
| 854 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 884 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 855 | 885 | ||
| ... | @@ -860,7 +890,7 @@ public: | ... | @@ -860,7 +890,7 @@ public: |
| 860 | }; | 890 | }; |
| 861 | 891 | ||
| 862 | template <__fmt_char_type _CharT> | 892 | template <__fmt_char_type _CharT> |
| 863 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> { | 893 | struct formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> { |
| 864 | public: | 894 | public: |
| 865 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 895 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 866 | 896 | ||
| ... | @@ -871,7 +901,7 @@ public: | ... | @@ -871,7 +901,7 @@ public: |
| 871 | }; | 901 | }; |
| 872 | 902 | ||
| 873 | template <__fmt_char_type _CharT> | 903 | template <__fmt_char_type _CharT> |
| 874 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> { | 904 | struct formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> { |
| 875 | public: | 905 | public: |
| 876 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 906 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 877 | 907 | ||
| ... | @@ -882,7 +912,7 @@ public: | ... | @@ -882,7 +912,7 @@ public: |
| 882 | }; | 912 | }; |
| 883 | 913 | ||
| 884 | template <__fmt_char_type _CharT> | 914 | template <__fmt_char_type _CharT> |
| 885 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> { | 915 | struct formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> { |
| 886 | public: | 916 | public: |
| 887 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 917 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 888 | 918 | ||
| ... | @@ -893,7 +923,7 @@ public: | ... | @@ -893,7 +923,7 @@ public: |
| 893 | }; | 923 | }; |
| 894 | 924 | ||
| 895 | template <__fmt_char_type _CharT> | 925 | template <__fmt_char_type _CharT> |
| 896 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> { | 926 | struct formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> { |
| 897 | public: | 927 | public: |
| 898 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 928 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 899 | 929 | ||
| ... | @@ -904,7 +934,7 @@ public: | ... | @@ -904,7 +934,7 @@ public: |
| 904 | }; | 934 | }; |
| 905 | 935 | ||
| 906 | template <__fmt_char_type _CharT> | 936 | template <__fmt_char_type _CharT> |
| 907 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> { | 937 | struct formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> { |
| 908 | public: | 938 | public: |
| 909 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 939 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 910 | 940 | ||
| ... | @@ -915,7 +945,7 @@ public: | ... | @@ -915,7 +945,7 @@ public: |
| 915 | }; | 945 | }; |
| 916 | 946 | ||
| 917 | template <__fmt_char_type _CharT> | 947 | template <__fmt_char_type _CharT> |
| 918 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> { | 948 | struct formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> { |
| 919 | public: | 949 | public: |
| 920 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 950 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 921 | 951 | ||
| ... | @@ -926,7 +956,7 @@ public: | ... | @@ -926,7 +956,7 @@ public: |
| 926 | }; | 956 | }; |
| 927 | 957 | ||
| 928 | template <__fmt_char_type _CharT> | 958 | template <__fmt_char_type _CharT> |
| 929 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> { | 959 | struct formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> { |
| 930 | public: | 960 | public: |
| 931 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 961 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 932 | 962 | ||
| ... | @@ -937,7 +967,7 @@ public: | ... | @@ -937,7 +967,7 @@ public: |
| 937 | }; | 967 | }; |
| 938 | 968 | ||
| 939 | template <__fmt_char_type _CharT> | 969 | template <__fmt_char_type _CharT> |
| 940 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> { | 970 | struct formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> { |
| 941 | public: | 971 | public: |
| 942 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | 972 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; |
| 943 | 973 |
lib/libcxx/include/__chrono/gps_clock.h created+90| ... | @@ -0,0 +1,90 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CHRONO_GPS_CLOCK_H | ||
| 11 | #define _LIBCPP___CHRONO_GPS_CLOCK_H | ||
| 12 | |||
| 13 | #include <version> | ||
| 14 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 15 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | ||
| 16 | |||
| 17 | # include <__assert> | ||
| 18 | # include <__chrono/duration.h> | ||
| 19 | # include <__chrono/time_point.h> | ||
| 20 | # include <__chrono/utc_clock.h> | ||
| 21 | # include <__config> | ||
| 22 | # include <__type_traits/common_type.h> | ||
| 23 | |||
| 24 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | # endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | # include <__undef_macros> | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | ||
| 34 | |||
| 35 | namespace chrono { | ||
| 36 | |||
| 37 | class gps_clock; | ||
| 38 | |||
| 39 | template <class _Duration> | ||
| 40 | using gps_time = time_point<gps_clock, _Duration>; | ||
| 41 | using gps_seconds = gps_time<seconds>; | ||
| 42 | |||
| 43 | class gps_clock { | ||
| 44 | public: | ||
| 45 | using rep = utc_clock::rep; | ||
| 46 | using period = utc_clock::period; | ||
| 47 | using duration = chrono::duration<rep, period>; | ||
| 48 | using time_point = chrono::time_point<gps_clock>; | ||
| 49 | static constexpr bool is_steady = false; // The utc_clock is not steady. | ||
| 50 | |||
| 51 | // The static difference between UTC and GPS time as specified in the Standard. | ||
| 52 | static constexpr chrono::seconds __offset{315964809}; | ||
| 53 | |||
| 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static time_point now() { return from_utc(utc_clock::now()); } | ||
| 55 | |||
| 56 | template <class _Duration> | ||
| 57 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static utc_time<common_type_t<_Duration, seconds>> | ||
| 58 | to_utc(const gps_time<_Duration>& __time) noexcept { | ||
| 59 | using _Rp = common_type_t<_Duration, seconds>; | ||
| 60 | _Duration __time_since_epoch = __time.time_since_epoch(); | ||
| 61 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch >= utc_time<_Rp>::min().time_since_epoch() + __offset, | ||
| 62 | "the GPS to UTC conversion would underflow"); | ||
| 63 | |||
| 64 | return utc_time<_Rp>{__time_since_epoch + __offset}; | ||
| 65 | } | ||
| 66 | |||
| 67 | template <class _Duration> | ||
| 68 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static gps_time<common_type_t<_Duration, seconds>> | ||
| 69 | from_utc(const utc_time<_Duration>& __time) noexcept { | ||
| 70 | using _Rp = common_type_t<_Duration, seconds>; | ||
| 71 | _Duration __time_since_epoch = __time.time_since_epoch(); | ||
| 72 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch <= utc_time<_Rp>::max().time_since_epoch() - __offset, | ||
| 73 | "the UTC to GPS conversion would overflow"); | ||
| 74 | |||
| 75 | return gps_time<_Rp>{__time_since_epoch - __offset}; | ||
| 76 | } | ||
| 77 | }; | ||
| 78 | |||
| 79 | } // namespace chrono | ||
| 80 | |||
| 81 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | ||
| 82 | // _LIBCPP_HAS_LOCALIZATION | ||
| 83 | |||
| 84 | _LIBCPP_END_NAMESPACE_STD | ||
| 85 | |||
| 86 | _LIBCPP_POP_MACROS | ||
| 87 | |||
| 88 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | ||
| 89 | |||
| 90 | #endif // _LIBCPP___CHRONO_GPS_CLOCK_H | ||
lib/libcxx/include/__chrono/ostream.h+14| ... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
| 18 | # include <__chrono/day.h> | 18 | # include <__chrono/day.h> |
| 19 | # include <__chrono/duration.h> | 19 | # include <__chrono/duration.h> |
| 20 | # include <__chrono/file_clock.h> | 20 | # include <__chrono/file_clock.h> |
| 21 | # include <__chrono/gps_clock.h> | ||
| 21 | # include <__chrono/hh_mm_ss.h> | 22 | # include <__chrono/hh_mm_ss.h> |
| 22 | # include <__chrono/local_info.h> | 23 | # include <__chrono/local_info.h> |
| 23 | # include <__chrono/month.h> | 24 | # include <__chrono/month.h> |
| ... | @@ -26,6 +27,7 @@ | ... | @@ -26,6 +27,7 @@ |
| 26 | # include <__chrono/statically_widen.h> | 27 | # include <__chrono/statically_widen.h> |
| 27 | # include <__chrono/sys_info.h> | 28 | # include <__chrono/sys_info.h> |
| 28 | # include <__chrono/system_clock.h> | 29 | # include <__chrono/system_clock.h> |
| 30 | # include <__chrono/tai_clock.h> | ||
| 29 | # include <__chrono/utc_clock.h> | 31 | # include <__chrono/utc_clock.h> |
| 30 | # include <__chrono/weekday.h> | 32 | # include <__chrono/weekday.h> |
| 31 | # include <__chrono/year.h> | 33 | # include <__chrono/year.h> |
| ... | @@ -71,6 +73,18 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const utc_time<_Duration>& __tp | ... | @@ -71,6 +73,18 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const utc_time<_Duration>& __tp |
| 71 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp); | 73 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp); |
| 72 | } | 74 | } |
| 73 | 75 | ||
| 76 | template <class _CharT, class _Traits, class _Duration> | ||
| 77 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 78 | operator<<(basic_ostream<_CharT, _Traits>& __os, const tai_time<_Duration>& __tp) { | ||
| 79 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp); | ||
| 80 | } | ||
| 81 | |||
| 82 | template <class _CharT, class _Traits, class _Duration> | ||
| 83 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | ||
| 84 | operator<<(basic_ostream<_CharT, _Traits>& __os, const gps_time<_Duration>& __tp) { | ||
| 85 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp); | ||
| 86 | } | ||
| 87 | |||
| 74 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | 88 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB |
| 75 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | 89 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM |
| 76 | 90 |
lib/libcxx/include/__chrono/parser_std_format_spec.h+1-1| ... | @@ -139,7 +139,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) { | ... | @@ -139,7 +139,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) { |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | template <class _CharT> | 141 | template <class _CharT> |
| 142 | class _LIBCPP_TEMPLATE_VIS __parser_chrono { | 142 | class __parser_chrono { |
| 143 | using _ConstIterator _LIBCPP_NODEBUG = typename basic_format_parse_context<_CharT>::const_iterator; | 143 | using _ConstIterator _LIBCPP_NODEBUG = typename basic_format_parse_context<_CharT>::const_iterator; |
| 144 | 144 | ||
| 145 | public: | 145 | public: |
lib/libcxx/include/__chrono/tai_clock.h created+108| ... | @@ -0,0 +1,108 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___CHRONO_TAI_CLOCK_H | ||
| 11 | #define _LIBCPP___CHRONO_TAI_CLOCK_H | ||
| 12 | |||
| 13 | #include <version> | ||
| 14 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | ||
| 15 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | ||
| 16 | |||
| 17 | # include <__assert> | ||
| 18 | # include <__chrono/duration.h> | ||
| 19 | # include <__chrono/time_point.h> | ||
| 20 | # include <__chrono/utc_clock.h> | ||
| 21 | # include <__config> | ||
| 22 | # include <__type_traits/common_type.h> | ||
| 23 | |||
| 24 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | # endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | # include <__undef_macros> | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | ||
| 34 | |||
| 35 | namespace chrono { | ||
| 36 | |||
| 37 | class tai_clock; | ||
| 38 | |||
| 39 | template <class _Duration> | ||
| 40 | using tai_time = time_point<tai_clock, _Duration>; | ||
| 41 | using tai_seconds = tai_time<seconds>; | ||
| 42 | |||
| 43 | // [time.clock.tai.overview]/1 | ||
| 44 | // The clock tai_clock measures seconds since 1958-01-01 00:00:00 and is | ||
| 45 | // offset 10s ahead of UTC at this date. That is, 1958-01-01 00:00:00 TAI is | ||
| 46 | // equivalent to 1957-12-31 23:59:50 UTC. Leap seconds are not inserted into | ||
| 47 | // TAI. Therefore every time a leap second is inserted into UTC, UTC shifts | ||
| 48 | // another second with respect to TAI. For example by 2000-01-01 there had | ||
| 49 | // been 22 positive and 0 negative leap seconds inserted so 2000-01-01 | ||
| 50 | // 00:00:00 UTC is equivalent to 2000-01-01 00:00:32 TAI (22s plus the | ||
| 51 | // initial 10s offset). | ||
| 52 | // | ||
| 53 | // Note this does not specify what the UTC offset before 1958-01-01 00:00:00 | ||
| 54 | // TAI is, nor does it follow the "real" TAI clock between 1958-01-01 and the | ||
| 55 | // start of the UTC epoch. So while the member functions are fully specified in | ||
| 56 | // the standard, they do not technically follow the "real-world" TAI clock with | ||
| 57 | // 100% accuracy. | ||
| 58 | // | ||
| 59 | // https://koka-lang.github.io/koka/doc/std_time_utc.html contains more | ||
| 60 | // information and references. | ||
| 61 | class tai_clock { | ||
| 62 | public: | ||
| 63 | using rep = utc_clock::rep; | ||
| 64 | using period = utc_clock::period; | ||
| 65 | using duration = chrono::duration<rep, period>; | ||
| 66 | using time_point = chrono::time_point<tai_clock>; | ||
| 67 | static constexpr bool is_steady = false; // The utc_clock is not steady. | ||
| 68 | |||
| 69 | // The static difference between UTC and TAI time. | ||
| 70 | static constexpr chrono::seconds __offset{378691210}; | ||
| 71 | |||
| 72 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static time_point now() { return from_utc(utc_clock::now()); } | ||
| 73 | |||
| 74 | template <class _Duration> | ||
| 75 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static utc_time<common_type_t<_Duration, seconds>> | ||
| 76 | to_utc(const tai_time<_Duration>& __time) noexcept { | ||
| 77 | using _Rp = common_type_t<_Duration, seconds>; | ||
| 78 | _Duration __time_since_epoch = __time.time_since_epoch(); | ||
| 79 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch >= utc_time<_Rp>::min().time_since_epoch() + __offset, | ||
| 80 | "the TAI to UTC conversion would underflow"); | ||
| 81 | |||
| 82 | return utc_time<_Rp>{__time_since_epoch - __offset}; | ||
| 83 | } | ||
| 84 | |||
| 85 | template <class _Duration> | ||
| 86 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static tai_time<common_type_t<_Duration, seconds>> | ||
| 87 | from_utc(const utc_time<_Duration>& __time) noexcept { | ||
| 88 | using _Rp = common_type_t<_Duration, seconds>; | ||
| 89 | _Duration __time_since_epoch = __time.time_since_epoch(); | ||
| 90 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch <= utc_time<_Rp>::max().time_since_epoch() - __offset, | ||
| 91 | "the UTC to TAI conversion would overflow"); | ||
| 92 | |||
| 93 | return tai_time<_Rp>{__time_since_epoch + __offset}; | ||
| 94 | } | ||
| 95 | }; | ||
| 96 | |||
| 97 | } // namespace chrono | ||
| 98 | |||
| 99 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | ||
| 100 | // _LIBCPP_HAS_LOCALIZATION | ||
| 101 | |||
| 102 | _LIBCPP_END_NAMESPACE_STD | ||
| 103 | |||
| 104 | _LIBCPP_POP_MACROS | ||
| 105 | |||
| 106 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | ||
| 107 | |||
| 108 | #endif // _LIBCPP___CHRONO_TAI_CLOCK_H | ||
lib/libcxx/include/__chrono/time_point.h+15-3| ... | @@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | namespace chrono { | 31 | namespace chrono { |
| 32 | 32 | ||
| 33 | template <class _Clock, class _Duration = typename _Clock::duration> | 33 | template <class _Clock, class _Duration = typename _Clock::duration> |
| 34 | class _LIBCPP_TEMPLATE_VIS time_point { | 34 | class time_point { |
| 35 | static_assert(__is_duration_v<_Duration>, "Second template parameter of time_point must be a std::chrono::duration"); | 35 | static_assert(__is_duration_v<_Duration>, "Second template parameter of time_point must be a std::chrono::duration"); |
| 36 | 36 | ||
| 37 | public: | 37 | public: |
| ... | @@ -58,6 +58,19 @@ public: | ... | @@ -58,6 +58,19 @@ public: |
| 58 | 58 | ||
| 59 | // arithmetic | 59 | // arithmetic |
| 60 | 60 | ||
| 61 | #if _LIBCPP_STD_VER >= 20 | ||
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr time_point& operator++() { | ||
| 63 | ++__d_; | ||
| 64 | return *this; | ||
| 65 | } | ||
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr time_point operator++(int) { return time_point{__d_++}; } | ||
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr time_point& operator--() { | ||
| 68 | --__d_; | ||
| 69 | return *this; | ||
| 70 | } | ||
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr time_point operator--(int) { return time_point{__d_--}; } | ||
| 72 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 73 | |||
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) { | 74 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) { |
| 62 | __d_ += __d; | 75 | __d_ += __d; |
| 63 | return *this; | 76 | return *this; |
| ... | @@ -76,8 +89,7 @@ public: | ... | @@ -76,8 +89,7 @@ public: |
| 76 | } // namespace chrono | 89 | } // namespace chrono |
| 77 | 90 | ||
| 78 | template <class _Clock, class _Duration1, class _Duration2> | 91 | template <class _Clock, class _Duration1, class _Duration2> |
| 79 | struct _LIBCPP_TEMPLATE_VIS | 92 | struct common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > { |
| 80 | common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > { | ||
| 81 | typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; | 93 | typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; |
| 82 | }; | 94 | }; |
| 83 | 95 |
lib/libcxx/include/__compare/common_comparison_category.h+3-3| ... | @@ -55,7 +55,7 @@ __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) { | ... | @@ -55,7 +55,7 @@ __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) { |
| 55 | template <class... _Ts, bool _False = false> | 55 | template <class... _Ts, bool _False = false> |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() { | 56 | _LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() { |
| 57 | using _CCC = _ClassifyCompCategory; | 57 | using _CCC = _ClassifyCompCategory; |
| 58 | constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...}; | 58 | constexpr _CCC __type_kinds[] = {_StrongOrd, __comp_detail::__type_to_enum<_Ts>()...}; |
| 59 | constexpr _CCC __cat = __comp_detail::__compute_comp_type(__type_kinds); | 59 | constexpr _CCC __cat = __comp_detail::__compute_comp_type(__type_kinds); |
| 60 | if constexpr (__cat == _None) | 60 | if constexpr (__cat == _None) |
| 61 | return void(); | 61 | return void(); |
| ... | @@ -72,8 +72,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() { | ... | @@ -72,8 +72,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() { |
| 72 | 72 | ||
| 73 | // [cmp.common], common comparison category type | 73 | // [cmp.common], common comparison category type |
| 74 | template <class... _Ts> | 74 | template <class... _Ts> |
| 75 | struct _LIBCPP_TEMPLATE_VIS common_comparison_category { | 75 | struct common_comparison_category { |
| 76 | using type = decltype(__comp_detail::__get_comp_type<_Ts...>()); | 76 | using type _LIBCPP_NODEBUG = decltype(__comp_detail::__get_comp_type<_Ts...>()); |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | template <class... _Ts> | 79 | template <class... _Ts> |
lib/libcxx/include/__compare/compare_three_way.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | #if _LIBCPP_STD_VER >= 20 | 23 | #if _LIBCPP_STD_VER >= 20 |
| 24 | 24 | ||
| 25 | struct _LIBCPP_TEMPLATE_VIS compare_three_way { | 25 | struct compare_three_way { |
| 26 | template <class _T1, class _T2> | 26 | template <class _T1, class _T2> |
| 27 | requires three_way_comparable_with<_T1, _T2> | 27 | requires three_way_comparable_with<_T1, _T2> |
| 28 | constexpr _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 28 | constexpr _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
lib/libcxx/include/__compare/compare_three_way_result.h+3-3| ... | @@ -29,12 +29,12 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result< | ... | @@ -29,12 +29,12 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result< |
| 29 | _Tp, | 29 | _Tp, |
| 30 | _Up, | 30 | _Up, |
| 31 | decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void())> { | 31 | decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void())> { |
| 32 | using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>()); | 32 | using type _LIBCPP_NODEBUG = |
| 33 | decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>()); | ||
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| 35 | template <class _Tp, class _Up = _Tp> | 36 | template <class _Tp, class _Up = _Tp> |
| 36 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result | 37 | struct _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> {}; |
| 37 | : __compare_three_way_result<_Tp, _Up, void> {}; | ||
| 38 | 38 | ||
| 39 | template <class _Tp, class _Up = _Tp> | 39 | template <class _Tp, class _Up = _Tp> |
| 40 | using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type; | 40 | using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type; |
lib/libcxx/include/__concepts/arithmetic.h-13| ... | @@ -13,8 +13,6 @@ | ... | @@ -13,8 +13,6 @@ |
| 13 | #include <__type_traits/is_floating_point.h> | 13 | #include <__type_traits/is_floating_point.h> |
| 14 | #include <__type_traits/is_integral.h> | 14 | #include <__type_traits/is_integral.h> |
| 15 | #include <__type_traits/is_signed.h> | 15 | #include <__type_traits/is_signed.h> |
| 16 | #include <__type_traits/is_signed_integer.h> | ||
| 17 | #include <__type_traits/is_unsigned_integer.h> | ||
| 18 | 16 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 18 | # pragma GCC system_header |
| ... | @@ -38,17 +36,6 @@ concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; | ... | @@ -38,17 +36,6 @@ concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; |
| 38 | template <class _Tp> | 36 | template <class _Tp> |
| 39 | concept floating_point = is_floating_point_v<_Tp>; | 37 | concept floating_point = is_floating_point_v<_Tp>; |
| 40 | 38 | ||
| 41 | // Concept helpers for the internal type traits for the fundamental types. | ||
| 42 | |||
| 43 | template <class _Tp> | ||
| 44 | concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value; | ||
| 45 | |||
| 46 | template <class _Tp> | ||
| 47 | concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value; | ||
| 48 | |||
| 49 | template <class _Tp> | ||
| 50 | concept __libcpp_integer = __libcpp_unsigned_integer<_Tp> || __libcpp_signed_integer<_Tp>; | ||
| 51 | |||
| 52 | #endif // _LIBCPP_STD_VER >= 20 | 39 | #endif // _LIBCPP_STD_VER >= 20 |
| 53 | 40 | ||
| 54 | _LIBCPP_END_NAMESPACE_STD | 41 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__concepts/class_or_enum.h-1| ... | @@ -13,7 +13,6 @@ | ... | @@ -13,7 +13,6 @@ |
| 13 | #include <__type_traits/is_class.h> | 13 | #include <__type_traits/is_class.h> |
| 14 | #include <__type_traits/is_enum.h> | 14 | #include <__type_traits/is_enum.h> |
| 15 | #include <__type_traits/is_union.h> | 15 | #include <__type_traits/is_union.h> |
| 16 | #include <__type_traits/remove_cvref.h> | ||
| 17 | 16 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header | 18 | # pragma GCC system_header |
lib/libcxx/include/__concepts/common_with.h+1-1| ... | @@ -12,7 +12,7 @@ | ... | @@ -12,7 +12,7 @@ |
| 12 | #include <__concepts/common_reference_with.h> | 12 | #include <__concepts/common_reference_with.h> |
| 13 | #include <__concepts/same_as.h> | 13 | #include <__concepts/same_as.h> |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__type_traits/add_lvalue_reference.h> | 15 | #include <__type_traits/add_reference.h> |
| 16 | #include <__type_traits/common_reference.h> | 16 | #include <__type_traits/common_reference.h> |
| 17 | #include <__type_traits/common_type.h> | 17 | #include <__type_traits/common_type.h> |
| 18 | #include <__utility/declval.h> | 18 | #include <__utility/declval.h> |
lib/libcxx/include/__concepts/swappable.h-1| ... | @@ -22,7 +22,6 @@ | ... | @@ -22,7 +22,6 @@ |
| 22 | #include <__utility/exchange.h> | 22 | #include <__utility/exchange.h> |
| 23 | #include <__utility/forward.h> | 23 | #include <__utility/forward.h> |
| 24 | #include <__utility/move.h> | 24 | #include <__utility/move.h> |
| 25 | #include <__utility/swap.h> | ||
| 26 | 25 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | # pragma GCC system_header | 27 | # pragma GCC system_header |
lib/libcxx/include/__condition_variable/condition_variable.h+87-99| ... | @@ -39,60 +39,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -39,60 +39,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 39 | _LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout}; | 39 | _LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout}; |
| 40 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) | 40 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) |
| 41 | 41 | ||
| 42 | class _LIBCPP_EXPORTED_FROM_ABI condition_variable { | ||
| 43 | __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; | ||
| 44 | |||
| 45 | public: | ||
| 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default; | ||
| 47 | |||
| 48 | # if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | ||
| 49 | ~condition_variable() = default; | ||
| 50 | # else | ||
| 51 | ~condition_variable(); | ||
| 52 | # endif | ||
| 53 | |||
| 54 | condition_variable(const condition_variable&) = delete; | ||
| 55 | condition_variable& operator=(const condition_variable&) = delete; | ||
| 56 | |||
| 57 | void notify_one() _NOEXCEPT; | ||
| 58 | void notify_all() _NOEXCEPT; | ||
| 59 | |||
| 60 | void wait(unique_lock<mutex>& __lk) _NOEXCEPT; | ||
| 61 | template <class _Predicate> | ||
| 62 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS void wait(unique_lock<mutex>& __lk, _Predicate __pred); | ||
| 63 | |||
| 64 | template <class _Clock, class _Duration> | ||
| 65 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS cv_status | ||
| 66 | wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t); | ||
| 67 | |||
| 68 | template <class _Clock, class _Duration, class _Predicate> | ||
| 69 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool | ||
| 70 | wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred); | ||
| 71 | |||
| 72 | template <class _Rep, class _Period> | ||
| 73 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS cv_status | ||
| 74 | wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d); | ||
| 75 | |||
| 76 | template <class _Rep, class _Period, class _Predicate> | ||
| 77 | bool _LIBCPP_HIDE_FROM_ABI | ||
| 78 | wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); | ||
| 79 | |||
| 80 | typedef __libcpp_condvar_t* native_handle_type; | ||
| 81 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__cv_; } | ||
| 82 | |||
| 83 | private: | ||
| 84 | void | ||
| 85 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT; | ||
| 86 | # if _LIBCPP_HAS_COND_CLOCKWAIT | ||
| 87 | _LIBCPP_HIDE_FROM_ABI void | ||
| 88 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT; | ||
| 89 | # endif | ||
| 90 | template <class _Clock> | ||
| 91 | _LIBCPP_HIDE_FROM_ABI void | ||
| 92 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT; | ||
| 93 | }; | ||
| 94 | #endif // _LIBCPP_HAS_THREADS | ||
| 95 | |||
| 96 | template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0> | 42 | template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0> |
| 97 | inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { | 43 | inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { |
| 98 | using namespace chrono; | 44 | using namespace chrono; |
| ... | @@ -140,64 +86,106 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono:: | ... | @@ -140,64 +86,106 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono:: |
| 140 | return nanoseconds(__result); | 86 | return nanoseconds(__result); |
| 141 | } | 87 | } |
| 142 | 88 | ||
| 143 | #if _LIBCPP_HAS_THREADS | 89 | class _LIBCPP_EXPORTED_FROM_ABI condition_variable { |
| 144 | template <class _Predicate> | 90 | __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; |
| 145 | void condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred) { | ||
| 146 | while (!__pred()) | ||
| 147 | wait(__lk); | ||
| 148 | } | ||
| 149 | 91 | ||
| 150 | template <class _Clock, class _Duration> | 92 | public: |
| 151 | cv_status condition_variable::wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t) { | 93 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default; |
| 152 | using namespace chrono; | ||
| 153 | using __clock_tp_ns = time_point<_Clock, nanoseconds>; | ||
| 154 | 94 | ||
| 155 | typename _Clock::time_point __now = _Clock::now(); | 95 | # if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION |
| 156 | if (__t <= __now) | 96 | ~condition_variable() = default; |
| 157 | return cv_status::timeout; | 97 | # else |
| 98 | ~condition_variable(); | ||
| 99 | # endif | ||
| 158 | 100 | ||
| 159 | __clock_tp_ns __t_ns = __clock_tp_ns(std::__safe_nanosecond_cast(__t.time_since_epoch())); | 101 | condition_variable(const condition_variable&) = delete; |
| 102 | condition_variable& operator=(const condition_variable&) = delete; | ||
| 160 | 103 | ||
| 161 | __do_timed_wait(__lk, __t_ns); | 104 | void notify_one() _NOEXCEPT; |
| 162 | return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout; | 105 | void notify_all() _NOEXCEPT; |
| 163 | } | 106 | |
| 107 | void wait(unique_lock<mutex>& __lk) _NOEXCEPT; | ||
| 164 | 108 | ||
| 165 | template <class _Clock, class _Duration, class _Predicate> | 109 | template <class _Predicate> |
| 166 | bool condition_variable::wait_until( | 110 | _LIBCPP_HIDE_FROM_ABI void wait(unique_lock<mutex>& __lk, _Predicate __pred) { |
| 167 | unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) { | 111 | while (!__pred()) |
| 168 | while (!__pred()) { | 112 | wait(__lk); |
| 169 | if (wait_until(__lk, __t) == cv_status::timeout) | ||
| 170 | return __pred(); | ||
| 171 | } | 113 | } |
| 172 | return true; | ||
| 173 | } | ||
| 174 | 114 | ||
| 175 | template <class _Rep, class _Period> | 115 | template <class _Clock, class _Duration> |
| 176 | cv_status condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d) { | 116 | _LIBCPP_HIDE_FROM_ABI cv_status |
| 177 | using namespace chrono; | 117 | wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t) { |
| 178 | if (__d <= __d.zero()) | 118 | using namespace chrono; |
| 179 | return cv_status::timeout; | 119 | using __clock_tp_ns = time_point<_Clock, nanoseconds>; |
| 180 | using __ns_rep = nanoseconds::rep; | 120 | |
| 181 | steady_clock::time_point __c_now = steady_clock::now(); | 121 | typename _Clock::time_point __now = _Clock::now(); |
| 122 | if (__t <= __now) | ||
| 123 | return cv_status::timeout; | ||
| 124 | |||
| 125 | __clock_tp_ns __t_ns = __clock_tp_ns(std::__safe_nanosecond_cast(__t.time_since_epoch())); | ||
| 126 | |||
| 127 | __do_timed_wait(__lk, __t_ns); | ||
| 128 | return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout; | ||
| 129 | } | ||
| 130 | |||
| 131 | template <class _Clock, class _Duration, class _Predicate> | ||
| 132 | _LIBCPP_HIDE_FROM_ABI bool | ||
| 133 | wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) { | ||
| 134 | while (!__pred()) { | ||
| 135 | if (wait_until(__lk, __t) == cv_status::timeout) | ||
| 136 | return __pred(); | ||
| 137 | } | ||
| 138 | return true; | ||
| 139 | } | ||
| 140 | |||
| 141 | template <class _Rep, class _Period> | ||
| 142 | _LIBCPP_HIDE_FROM_ABI cv_status wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d) { | ||
| 143 | using namespace chrono; | ||
| 144 | if (__d <= __d.zero()) | ||
| 145 | return cv_status::timeout; | ||
| 146 | using __ns_rep = nanoseconds::rep; | ||
| 147 | steady_clock::time_point __c_now = steady_clock::now(); | ||
| 182 | 148 | ||
| 183 | # if _LIBCPP_HAS_COND_CLOCKWAIT | 149 | # if _LIBCPP_HAS_COND_CLOCKWAIT |
| 184 | using __clock_tp_ns = time_point<steady_clock, nanoseconds>; | 150 | using __clock_tp_ns = time_point<steady_clock, nanoseconds>; |
| 185 | __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count(); | 151 | __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count(); |
| 186 | # else | 152 | # else |
| 187 | using __clock_tp_ns = time_point<system_clock, nanoseconds>; | 153 | using __clock_tp_ns = time_point<system_clock, nanoseconds>; |
| 188 | __ns_rep __now_count_ns = std::__safe_nanosecond_cast(system_clock::now().time_since_epoch()).count(); | 154 | __ns_rep __now_count_ns = std::__safe_nanosecond_cast(system_clock::now().time_since_epoch()).count(); |
| 189 | # endif | 155 | # endif |
| 190 | 156 | ||
| 191 | __ns_rep __d_ns_count = std::__safe_nanosecond_cast(__d).count(); | 157 | __ns_rep __d_ns_count = std::__safe_nanosecond_cast(__d).count(); |
| 192 | 158 | ||
| 193 | if (__now_count_ns > numeric_limits<__ns_rep>::max() - __d_ns_count) { | 159 | if (__now_count_ns > numeric_limits<__ns_rep>::max() - __d_ns_count) { |
| 194 | __do_timed_wait(__lk, __clock_tp_ns::max()); | 160 | __do_timed_wait(__lk, __clock_tp_ns::max()); |
| 195 | } else { | 161 | } else { |
| 196 | __do_timed_wait(__lk, __clock_tp_ns(nanoseconds(__now_count_ns + __d_ns_count))); | 162 | __do_timed_wait(__lk, __clock_tp_ns(nanoseconds(__now_count_ns + __d_ns_count))); |
| 163 | } | ||
| 164 | |||
| 165 | return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : cv_status::timeout; | ||
| 197 | } | 166 | } |
| 198 | 167 | ||
| 199 | return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : cv_status::timeout; | 168 | template <class _Rep, class _Period, class _Predicate> |
| 200 | } | 169 | bool _LIBCPP_HIDE_FROM_ABI |
| 170 | wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); | ||
| 171 | |||
| 172 | typedef __libcpp_condvar_t* native_handle_type; | ||
| 173 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__cv_; } | ||
| 174 | |||
| 175 | private: | ||
| 176 | void | ||
| 177 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT; | ||
| 178 | # if _LIBCPP_HAS_COND_CLOCKWAIT | ||
| 179 | _LIBCPP_HIDE_FROM_ABI void | ||
| 180 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT; | ||
| 181 | # endif | ||
| 182 | template <class _Clock> | ||
| 183 | _LIBCPP_HIDE_FROM_ABI void | ||
| 184 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT; | ||
| 185 | }; | ||
| 186 | #endif // _LIBCPP_HAS_THREADS | ||
| 187 | |||
| 188 | #if _LIBCPP_HAS_THREADS | ||
| 201 | 189 | ||
| 202 | template <class _Rep, class _Period, class _Predicate> | 190 | template <class _Rep, class _Period, class _Predicate> |
| 203 | inline bool | 191 | inline bool |
| ... | @@ -210,7 +198,7 @@ inline void condition_variable::__do_timed_wait( | ... | @@ -210,7 +198,7 @@ inline void condition_variable::__do_timed_wait( |
| 210 | unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT { | 198 | unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT { |
| 211 | using namespace chrono; | 199 | using namespace chrono; |
| 212 | if (!__lk.owns_lock()) | 200 | if (!__lk.owns_lock()) |
| 213 | __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); | 201 | std::__throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); |
| 214 | nanoseconds __d = __tp.time_since_epoch(); | 202 | nanoseconds __d = __tp.time_since_epoch(); |
| 215 | timespec __ts; | 203 | timespec __ts; |
| 216 | seconds __s = duration_cast<seconds>(__d); | 204 | seconds __s = duration_cast<seconds>(__d); |
| ... | @@ -225,7 +213,7 @@ inline void condition_variable::__do_timed_wait( | ... | @@ -225,7 +213,7 @@ inline void condition_variable::__do_timed_wait( |
| 225 | } | 213 | } |
| 226 | int __ec = pthread_cond_clockwait(&__cv_, __lk.mutex()->native_handle(), CLOCK_MONOTONIC, &__ts); | 214 | int __ec = pthread_cond_clockwait(&__cv_, __lk.mutex()->native_handle(), CLOCK_MONOTONIC, &__ts); |
| 227 | if (__ec != 0 && __ec != ETIMEDOUT) | 215 | if (__ec != 0 && __ec != ETIMEDOUT) |
| 228 | __throw_system_error(__ec, "condition_variable timed_wait failed"); | 216 | std::__throw_system_error(__ec, "condition_variable timed_wait failed"); |
| 229 | } | 217 | } |
| 230 | # endif // _LIBCPP_HAS_COND_CLOCKWAIT | 218 | # endif // _LIBCPP_HAS_COND_CLOCKWAIT |
| 231 | 219 |
lib/libcxx/include/__config+186-162| ... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
| 28 | // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. | 28 | // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. |
| 29 | // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is | 29 | // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is |
| 30 | // defined to XXYYZZ. | 30 | // defined to XXYYZZ. |
| 31 | # define _LIBCPP_VERSION 200100 | 31 | # define _LIBCPP_VERSION 210100 |
| 32 | 32 | ||
| 33 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y | 33 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y |
| 34 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) | 34 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) |
| ... | @@ -38,11 +38,47 @@ | ... | @@ -38,11 +38,47 @@ |
| 38 | # define _LIBCPP_FREESTANDING | 38 | # define _LIBCPP_FREESTANDING |
| 39 | # endif | 39 | # endif |
| 40 | 40 | ||
| 41 | // NOLINTNEXTLINE(libcpp-cpp-version-check) | ||
| 42 | # if __cplusplus < 201103L | ||
| 43 | # define _LIBCPP_CXX03_LANG | ||
| 44 | # endif | ||
| 45 | |||
| 46 | # if __has_feature(experimental_library) | ||
| 47 | # ifndef _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 48 | # define _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 49 | # endif | ||
| 50 | # endif | ||
| 51 | |||
| 52 | // Incomplete features get their own specific disabling flags. This makes it | ||
| 53 | // easier to grep for target specific flags once the feature is complete. | ||
| 54 | # if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 55 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1 | ||
| 56 | # else | ||
| 57 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0 | ||
| 58 | # endif | ||
| 59 | |||
| 60 | # define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 61 | # define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 62 | # define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 63 | # define _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 64 | |||
| 41 | // HARDENING { | 65 | // HARDENING { |
| 42 | 66 | ||
| 43 | // TODO: Remove in LLVM 21. We're making this an error to catch folks who might not have migrated. | 67 | // TODO(LLVM 23): Remove this. We're making these an error to catch folks who might not have migrated. |
| 44 | # ifdef _LIBCPP_ENABLE_ASSERTIONS | 68 | // Since hardening went through several changes (many of which impacted user-facing macros), |
| 45 | # error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead" | 69 | // we're keeping these checks around for a bit longer than usual. Failure to properly configure |
| 70 | // hardening results in checks being dropped silently, which is a pretty big deal. | ||
| 71 | # if defined(_LIBCPP_ENABLE_ASSERTIONS) | ||
| 72 | # error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 73 | # endif | ||
| 74 | # if defined(_LIBCPP_ENABLE_HARDENED_MODE) | ||
| 75 | # error "_LIBCPP_ENABLE_HARDENED_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 76 | # endif | ||
| 77 | # if defined(_LIBCPP_ENABLE_SAFE_MODE) | ||
| 78 | # error "_LIBCPP_ENABLE_SAFE_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 79 | # endif | ||
| 80 | # if defined(_LIBCPP_ENABLE_DEBUG_MODE) | ||
| 81 | # error "_LIBCPP_ENABLE_DEBUG_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)" | ||
| 46 | # endif | 82 | # endif |
| 47 | 83 | ||
| 48 | // The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values: | 84 | // The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values: |
| ... | @@ -147,16 +183,53 @@ _LIBCPP_HARDENING_MODE_EXTENSIVE, \ | ... | @@ -147,16 +183,53 @@ _LIBCPP_HARDENING_MODE_EXTENSIVE, \ |
| 147 | _LIBCPP_HARDENING_MODE_DEBUG | 183 | _LIBCPP_HARDENING_MODE_DEBUG |
| 148 | # endif | 184 | # endif |
| 149 | 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 | |||
| 150 | // } HARDENING | 228 | // } HARDENING |
| 151 | 229 | ||
| 152 | # define _LIBCPP_TOSTRING2(x) #x | 230 | # define _LIBCPP_TOSTRING2(x) #x |
| 153 | # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) | 231 | # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) |
| 154 | 232 | ||
| 155 | // NOLINTNEXTLINE(libcpp-cpp-version-check) | ||
| 156 | # if __cplusplus < 201103L | ||
| 157 | # define _LIBCPP_CXX03_LANG | ||
| 158 | # endif | ||
| 159 | |||
| 160 | # ifndef __has_constexpr_builtin | 233 | # ifndef __has_constexpr_builtin |
| 161 | # define __has_constexpr_builtin(x) 0 | 234 | # define __has_constexpr_builtin(x) 0 |
| 162 | # endif | 235 | # endif |
| ... | @@ -190,24 +263,6 @@ _LIBCPP_HARDENING_MODE_DEBUG | ... | @@ -190,24 +263,6 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 190 | # define _LIBCPP_ABI_VCRUNTIME | 263 | # define _LIBCPP_ABI_VCRUNTIME |
| 191 | # endif | 264 | # endif |
| 192 | 265 | ||
| 193 | # if __has_feature(experimental_library) | ||
| 194 | # ifndef _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 195 | # define _LIBCPP_ENABLE_EXPERIMENTAL | ||
| 196 | # endif | ||
| 197 | # endif | ||
| 198 | |||
| 199 | // Incomplete features get their own specific disabling flags. This makes it | ||
| 200 | // easier to grep for target specific flags once the feature is complete. | ||
| 201 | # if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 202 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1 | ||
| 203 | # else | ||
| 204 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0 | ||
| 205 | # endif | ||
| 206 | |||
| 207 | # define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 208 | # define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 209 | # define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | ||
| 210 | |||
| 211 | # if defined(__MVS__) | 266 | # if defined(__MVS__) |
| 212 | # include <features.h> // for __NATIVE_ASCII_F | 267 | # include <features.h> // for __NATIVE_ASCII_F |
| 213 | # endif | 268 | # endif |
| ... | @@ -319,41 +374,14 @@ typedef __char32_t char32_t; | ... | @@ -319,41 +374,14 @@ typedef __char32_t char32_t; |
| 319 | 374 | ||
| 320 | # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) | 375 | # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) |
| 321 | 376 | ||
| 322 | // Objective-C++ features (opt-in) | 377 | # if __has_extension(blocks) && defined(__APPLE__) |
| 323 | # if __has_feature(objc_arc) | ||
| 324 | # define _LIBCPP_HAS_OBJC_ARC 1 | ||
| 325 | # else | ||
| 326 | # define _LIBCPP_HAS_OBJC_ARC 0 | ||
| 327 | # endif | ||
| 328 | |||
| 329 | # if __has_feature(objc_arc_weak) | ||
| 330 | # define _LIBCPP_HAS_OBJC_ARC_WEAK 1 | ||
| 331 | # else | ||
| 332 | # define _LIBCPP_HAS_OBJC_ARC_WEAK 0 | ||
| 333 | # endif | ||
| 334 | |||
| 335 | # if __has_extension(blocks) | ||
| 336 | # define _LIBCPP_HAS_EXTENSION_BLOCKS 1 | ||
| 337 | # else | ||
| 338 | # define _LIBCPP_HAS_EXTENSION_BLOCKS 0 | ||
| 339 | # endif | ||
| 340 | |||
| 341 | # if _LIBCPP_HAS_EXTENSION_BLOCKS && defined(__APPLE__) | ||
| 342 | # define _LIBCPP_HAS_BLOCKS_RUNTIME 1 | 378 | # define _LIBCPP_HAS_BLOCKS_RUNTIME 1 |
| 343 | # else | 379 | # else |
| 344 | # define _LIBCPP_HAS_BLOCKS_RUNTIME 0 | 380 | # define _LIBCPP_HAS_BLOCKS_RUNTIME 0 |
| 345 | # endif | 381 | # endif |
| 346 | 382 | ||
| 347 | # if __has_feature(address_sanitizer) | ||
| 348 | # define _LIBCPP_HAS_ASAN 1 | ||
| 349 | # else | ||
| 350 | # define _LIBCPP_HAS_ASAN 0 | ||
| 351 | # endif | ||
| 352 | |||
| 353 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) | 383 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) |
| 354 | 384 | ||
| 355 | # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ | ||
| 356 | |||
| 357 | # if defined(_LIBCPP_OBJECT_FORMAT_COFF) | 385 | # if defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| 358 | 386 | ||
| 359 | # ifdef _DLL | 387 | # ifdef _DLL |
| ... | @@ -363,35 +391,30 @@ typedef __char32_t char32_t; | ... | @@ -363,35 +391,30 @@ typedef __char32_t char32_t; |
| 363 | # endif | 391 | # endif |
| 364 | 392 | ||
| 365 | # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) | 393 | # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) |
| 366 | # define _LIBCPP_DLL_VIS | ||
| 367 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | 394 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS |
| 368 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | 395 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 369 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS | 396 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS |
| 370 | # define _LIBCPP_EXPORTED_FROM_ABI | 397 | # define _LIBCPP_EXPORTED_FROM_ABI |
| 371 | # elif defined(_LIBCPP_BUILDING_LIBRARY) | 398 | # elif defined(_LIBCPP_BUILDING_LIBRARY) |
| 372 | # define _LIBCPP_DLL_VIS __declspec(dllexport) | ||
| 373 | # if defined(__MINGW32__) | 399 | # if defined(__MINGW32__) |
| 374 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS | 400 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllexport) |
| 375 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | 401 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 376 | # else | 402 | # else |
| 377 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | 403 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS |
| 378 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS | 404 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __declspec(dllexport) |
| 379 | # endif | 405 | # endif |
| 380 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS | 406 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS __declspec(dllexport) |
| 381 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) | 407 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) |
| 382 | # else | 408 | # else |
| 383 | # define _LIBCPP_DLL_VIS __declspec(dllimport) | 409 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllimport) |
| 384 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS | ||
| 385 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | 410 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 386 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS | 411 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS |
| 387 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) | 412 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) |
| 388 | # endif | 413 | # endif |
| 389 | 414 | ||
| 390 | # define _LIBCPP_HIDDEN | 415 | # define _LIBCPP_HIDDEN |
| 391 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | ||
| 392 | # define _LIBCPP_TEMPLATE_VIS | ||
| 393 | # define _LIBCPP_TEMPLATE_DATA_VIS | 416 | # define _LIBCPP_TEMPLATE_DATA_VIS |
| 394 | # define _LIBCPP_TYPE_VISIBILITY_DEFAULT | 417 | # define _LIBCPP_NAMESPACE_VISIBILITY |
| 395 | 418 | ||
| 396 | # else | 419 | # else |
| 397 | 420 | ||
| ... | @@ -412,24 +435,12 @@ typedef __char32_t char32_t; | ... | @@ -412,24 +435,12 @@ typedef __char32_t char32_t; |
| 412 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default") | 435 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default") |
| 413 | # endif | 436 | # endif |
| 414 | 437 | ||
| 415 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | ||
| 416 | // The inline should be removed once PR32114 is resolved | ||
| 417 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN | ||
| 418 | # else | ||
| 419 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | ||
| 420 | # endif | ||
| 421 | |||
| 422 | // GCC doesn't support the type_visibility attribute, so we have to keep the visibility attribute on templates | ||
| 423 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !__has_attribute(__type_visibility__) | ||
| 424 | # define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) | ||
| 425 | # else | ||
| 426 | # define _LIBCPP_TEMPLATE_VIS | ||
| 427 | # endif | ||
| 428 | |||
| 429 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) | 438 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) |
| 430 | # define _LIBCPP_TYPE_VISIBILITY_DEFAULT __attribute__((__type_visibility__("default"))) | 439 | # define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default"))) |
| 440 | # elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | ||
| 441 | # define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default"))) | ||
| 431 | # else | 442 | # else |
| 432 | # define _LIBCPP_TYPE_VISIBILITY_DEFAULT | 443 | # define _LIBCPP_NAMESPACE_VISIBILITY |
| 433 | # endif | 444 | # endif |
| 434 | 445 | ||
| 435 | # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) | 446 | # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| ... | @@ -549,24 +560,17 @@ typedef __char32_t char32_t; | ... | @@ -549,24 +560,17 @@ typedef __char32_t char32_t; |
| 549 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | 560 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI |
| 550 | # endif | 561 | # endif |
| 551 | 562 | ||
| 552 | // TODO: Remove this workaround once we drop support for Clang 16 | ||
| 553 | # if __has_warning("-Wc++23-extensions") | ||
| 554 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") | ||
| 555 | # else | ||
| 556 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions") | ||
| 557 | # endif | ||
| 558 | |||
| 559 | // Clang modules take a significant compile time hit when pushing and popping diagnostics. | 563 | // Clang modules take a significant compile time hit when pushing and popping diagnostics. |
| 560 | // Since all the headers are marked as system headers in the modulemap, we can simply disable this | 564 | // Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can |
| 561 | // pushing and popping when building with clang modules. | 565 | // simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined. |
| 562 | # if !__has_feature(modules) | 566 | # ifdef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 563 | # define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \ | 567 | # define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \ |
| 564 | _LIBCPP_DIAGNOSTIC_PUSH \ | 568 | _LIBCPP_DIAGNOSTIC_PUSH \ |
| 565 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \ | 569 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \ |
| 566 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ | 570 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ |
| 567 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ | 571 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ |
| 568 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ | 572 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ |
| 569 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \ | 573 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \ |
| 570 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ | 574 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \ |
| 571 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ | 575 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \ |
| 572 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ | 576 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \ |
| ... | @@ -577,15 +581,27 @@ typedef __char32_t char32_t; | ... | @@ -577,15 +581,27 @@ typedef __char32_t char32_t; |
| 577 | # define _LIBCPP_POP_EXTENSION_DIAGNOSTICS | 581 | # define _LIBCPP_POP_EXTENSION_DIAGNOSTICS |
| 578 | # endif | 582 | # endif |
| 579 | 583 | ||
| 580 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. | ||
| 581 | // clang-format off | 584 | // clang-format off |
| 582 | # define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \ | ||
| 583 | namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \ | ||
| 584 | inline namespace _LIBCPP_ABI_NAMESPACE { | ||
| 585 | # define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS | ||
| 586 | 585 | ||
| 587 | #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { | 586 | // The unversioned namespace is used when we want to be ABI compatible with other standard libraries in some way. There |
| 588 | #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL }} | 587 | // are two main categories where that's the case: |
| 588 | // - Historically, we have made exception types ABI compatible with libstdc++ to allow throwing them between libstdc++ | ||
| 589 | // and libc++. This is not used anymore for new exception types, since there is no use-case for it anymore. | ||
| 590 | // - Types and functions which are used by the compiler are in the unversioned namespace, since the compiler has to know | ||
| 591 | // their mangling without the appropriate declaration in some cases. | ||
| 592 | // If it's not clear whether using the unversioned namespace is the correct thing to do, it's not. The versioned | ||
| 593 | // namespace (_LIBCPP_BEGIN_NAMESPACE_STD) should almost always be used. | ||
| 594 | # define _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD \ | ||
| 595 | _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS namespace _LIBCPP_NAMESPACE_VISIBILITY std { | ||
| 596 | |||
| 597 | # define _LIBCPP_END_UNVERSIONED_NAMESPACE_STD } _LIBCPP_POP_EXTENSION_DIAGNOSTICS | ||
| 598 | |||
| 599 | # define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD inline namespace _LIBCPP_ABI_NAMESPACE { | ||
| 600 | # define _LIBCPP_END_NAMESPACE_STD } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD | ||
| 601 | |||
| 602 | // TODO: This should really be in the versioned namespace | ||
| 603 | #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD namespace experimental { | ||
| 604 | #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD | ||
| 589 | 605 | ||
| 590 | #define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { | 606 | #define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { |
| 591 | #define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL | 607 | #define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL |
| ... | @@ -663,7 +679,10 @@ typedef __char32_t char32_t; | ... | @@ -663,7 +679,10 @@ typedef __char32_t char32_t; |
| 663 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ | 679 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ |
| 664 | __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ | 680 | __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ |
| 665 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ | 681 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ |
| 666 | __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) | 682 | __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ |
| 683 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \ | ||
| 684 | __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) || \ | ||
| 685 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) | ||
| 667 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 | 686 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 |
| 668 | # else | 687 | # else |
| 669 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 | 688 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 |
| ... | @@ -675,10 +694,6 @@ typedef __char32_t char32_t; | ... | @@ -675,10 +694,6 @@ typedef __char32_t char32_t; |
| 675 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 | 694 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 |
| 676 | # endif | 695 | # endif |
| 677 | 696 | ||
| 678 | # if defined(__APPLE__) || defined(__FreeBSD__) | ||
| 679 | # define _LIBCPP_HAS_DEFAULTRUNELOCALE | ||
| 680 | # endif | ||
| 681 | |||
| 682 | # if defined(__APPLE__) || defined(__FreeBSD__) | 697 | # if defined(__APPLE__) || defined(__FreeBSD__) |
| 683 | # define _LIBCPP_WCTYPE_IS_MASK | 698 | # define _LIBCPP_WCTYPE_IS_MASK |
| 684 | # endif | 699 | # endif |
| ... | @@ -741,8 +756,10 @@ typedef __char32_t char32_t; | ... | @@ -741,8 +756,10 @@ typedef __char32_t char32_t; |
| 741 | 756 | ||
| 742 | # if _LIBCPP_STD_VER >= 26 | 757 | # if _LIBCPP_STD_VER >= 26 |
| 743 | # define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED | 758 | # define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED |
| 759 | # define _LIBCPP_DEPRECATED_IN_CXX26_(m) _LIBCPP_DEPRECATED_(m) | ||
| 744 | # else | 760 | # else |
| 745 | # define _LIBCPP_DEPRECATED_IN_CXX26 | 761 | # define _LIBCPP_DEPRECATED_IN_CXX26 |
| 762 | # define _LIBCPP_DEPRECATED_IN_CXX26_(m) | ||
| 746 | # endif | 763 | # endif |
| 747 | 764 | ||
| 748 | # if _LIBCPP_HAS_CHAR8_T | 765 | # if _LIBCPP_HAS_CHAR8_T |
| ... | @@ -937,23 +954,6 @@ typedef __char32_t char32_t; | ... | @@ -937,23 +954,6 @@ typedef __char32_t char32_t; |
| 937 | # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS | 954 | # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS |
| 938 | # endif | 955 | # endif |
| 939 | 956 | ||
| 940 | // Work around the attribute handling in clang. When both __declspec and | ||
| 941 | // __attribute__ are present, the processing goes awry preventing the definition | ||
| 942 | // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus | ||
| 943 | // combining the two does work. | ||
| 944 | # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) && \ | ||
| 945 | __has_attribute(acquire_capability) && !defined(_MSC_VER) | ||
| 946 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1 | ||
| 947 | # else | ||
| 948 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 0 | ||
| 949 | # endif | ||
| 950 | |||
| 951 | # if _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | ||
| 952 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) | ||
| 953 | # else | ||
| 954 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) | ||
| 955 | # endif | ||
| 956 | |||
| 957 | # if _LIBCPP_STD_VER >= 20 | 957 | # if _LIBCPP_STD_VER >= 20 |
| 958 | # define _LIBCPP_CONSTINIT constinit | 958 | # define _LIBCPP_CONSTINIT constinit |
| 959 | # elif __has_attribute(__require_constant_initialization__) | 959 | # elif __has_attribute(__require_constant_initialization__) |
| ... | @@ -1064,9 +1064,8 @@ typedef __char32_t char32_t; | ... | @@ -1064,9 +1064,8 @@ typedef __char32_t char32_t; |
| 1064 | # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "") | 1064 | # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "") |
| 1065 | # endif | 1065 | # endif |
| 1066 | 1066 | ||
| 1067 | // TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use | 1067 | // TODO(LLVM 22): Remove the workaround |
| 1068 | // compiler intrinsics in the Objective-C++ mode. | 1068 | # if defined(__OBJC__) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER < 2001) |
| 1069 | # ifdef __OBJC__ | ||
| 1070 | # define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS | 1069 | # define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS |
| 1071 | # endif | 1070 | # endif |
| 1072 | 1071 | ||
| ... | @@ -1119,26 +1118,28 @@ typedef __char32_t char32_t; | ... | @@ -1119,26 +1118,28 @@ typedef __char32_t char32_t; |
| 1119 | 1118 | ||
| 1120 | // Optional attributes - these are useful for a better QoI, but not required to be available | 1119 | // Optional attributes - these are useful for a better QoI, but not required to be available |
| 1121 | 1120 | ||
| 1121 | # define _LIBCPP_NOALIAS __attribute__((__malloc__)) | ||
| 1122 | # define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]] | ||
| 1123 | # define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__))) | ||
| 1124 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100))) | ||
| 1125 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ | ||
| 1126 | __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) | ||
| 1127 | # define _LIBCPP_PACKED __attribute__((__packed__)) | ||
| 1128 | |||
| 1122 | # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) | 1129 | # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) |
| 1123 | # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) | 1130 | # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) |
| 1124 | # else | 1131 | # else |
| 1125 | # define _LIBCPP_NO_CFI | 1132 | # define _LIBCPP_NO_CFI |
| 1126 | # endif | 1133 | # endif |
| 1127 | 1134 | ||
| 1128 | # if __has_attribute(__malloc__) | ||
| 1129 | # define _LIBCPP_NOALIAS __attribute__((__malloc__)) | ||
| 1130 | # else | ||
| 1131 | # define _LIBCPP_NOALIAS | ||
| 1132 | # endif | ||
| 1133 | |||
| 1134 | # if __has_attribute(__using_if_exists__) | 1135 | # if __has_attribute(__using_if_exists__) |
| 1135 | # define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__)) | 1136 | # define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__)) |
| 1136 | # else | 1137 | # else |
| 1137 | # define _LIBCPP_USING_IF_EXISTS | 1138 | # define _LIBCPP_USING_IF_EXISTS |
| 1138 | # endif | 1139 | # endif |
| 1139 | 1140 | ||
| 1140 | # if __has_attribute(__no_destroy__) | 1141 | # if __has_cpp_attribute(_Clang::__no_destroy__) |
| 1141 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) | 1142 | # define _LIBCPP_NO_DESTROY [[_Clang::__no_destroy__]] |
| 1142 | # else | 1143 | # else |
| 1143 | # define _LIBCPP_NO_DESTROY | 1144 | # define _LIBCPP_NO_DESTROY |
| 1144 | # endif | 1145 | # endif |
| ... | @@ -1149,15 +1150,6 @@ typedef __char32_t char32_t; | ... | @@ -1149,15 +1150,6 @@ typedef __char32_t char32_t; |
| 1149 | # define _LIBCPP_DIAGNOSE_WARNING(...) | 1150 | # define _LIBCPP_DIAGNOSE_WARNING(...) |
| 1150 | # endif | 1151 | # endif |
| 1151 | 1152 | ||
| 1152 | // Use a function like macro to imply that it must be followed by a semicolon | ||
| 1153 | # if __has_cpp_attribute(fallthrough) | ||
| 1154 | # define _LIBCPP_FALLTHROUGH() [[fallthrough]] | ||
| 1155 | # elif __has_attribute(__fallthrough__) | ||
| 1156 | # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) | ||
| 1157 | # else | ||
| 1158 | # define _LIBCPP_FALLTHROUGH() ((void)0) | ||
| 1159 | # endif | ||
| 1160 | |||
| 1161 | # if __has_cpp_attribute(_Clang::__lifetimebound__) | 1153 | # if __has_cpp_attribute(_Clang::__lifetimebound__) |
| 1162 | # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]] | 1154 | # define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]] |
| 1163 | # else | 1155 | # else |
| ... | @@ -1170,8 +1162,6 @@ typedef __char32_t char32_t; | ... | @@ -1170,8 +1162,6 @@ typedef __char32_t char32_t; |
| 1170 | # define _LIBCPP_NOESCAPE | 1162 | # define _LIBCPP_NOESCAPE |
| 1171 | # endif | 1163 | # endif |
| 1172 | 1164 | ||
| 1173 | # define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]] | ||
| 1174 | |||
| 1175 | # if __has_cpp_attribute(_Clang::__no_specializations__) | 1165 | # if __has_cpp_attribute(_Clang::__no_specializations__) |
| 1176 | # define _LIBCPP_NO_SPECIALIZATIONS \ | 1166 | # define _LIBCPP_NO_SPECIALIZATIONS \ |
| 1177 | [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]] | 1167 | [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]] |
| ... | @@ -1179,43 +1169,70 @@ typedef __char32_t char32_t; | ... | @@ -1179,43 +1169,70 @@ typedef __char32_t char32_t; |
| 1179 | # define _LIBCPP_NO_SPECIALIZATIONS | 1169 | # define _LIBCPP_NO_SPECIALIZATIONS |
| 1180 | # endif | 1170 | # endif |
| 1181 | 1171 | ||
| 1182 | # if __has_attribute(__standalone_debug__) | 1172 | # if __has_cpp_attribute(_Clang::__standalone_debug__) |
| 1183 | # define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) | 1173 | # define _LIBCPP_STANDALONE_DEBUG [[_Clang::__standalone_debug__]] |
| 1184 | # else | 1174 | # else |
| 1185 | # define _LIBCPP_STANDALONE_DEBUG | 1175 | # define _LIBCPP_STANDALONE_DEBUG |
| 1186 | # endif | 1176 | # endif |
| 1187 | 1177 | ||
| 1188 | # if __has_attribute(__preferred_name__) | 1178 | # if __has_cpp_attribute(_Clang::__preferred_name__) |
| 1189 | # define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) | 1179 | # define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]] |
| 1190 | # else | 1180 | # else |
| 1191 | # define _LIBCPP_PREFERRED_NAME(x) | 1181 | # define _LIBCPP_PREFERRED_NAME(x) |
| 1192 | # endif | 1182 | # endif |
| 1193 | 1183 | ||
| 1194 | # if __has_attribute(__no_sanitize__) | 1184 | # if __has_cpp_attribute(_Clang::__scoped_lockable__) |
| 1195 | # define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__))) | 1185 | # define _LIBCPP_SCOPED_LOCKABLE [[_Clang::__scoped_lockable__]] |
| 1186 | # else | ||
| 1187 | # define _LIBCPP_SCOPED_LOCKABLE | ||
| 1188 | # endif | ||
| 1189 | |||
| 1190 | # if __has_cpp_attribute(_Clang::__capability__) | ||
| 1191 | # define _LIBCPP_CAPABILITY(...) [[_Clang::__capability__(__VA_ARGS__)]] | ||
| 1196 | # else | 1192 | # else |
| 1197 | # define _LIBCPP_NO_SANITIZE(...) | 1193 | # define _LIBCPP_CAPABILITY(...) |
| 1198 | # endif | 1194 | # endif |
| 1199 | 1195 | ||
| 1200 | # if __has_attribute(__init_priority__) | 1196 | # if __has_attribute(__acquire_capability__) |
| 1201 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100))) | 1197 | # define _LIBCPP_ACQUIRE_CAPABILITY(...) __attribute__((__acquire_capability__(__VA_ARGS__))) |
| 1202 | # else | 1198 | # else |
| 1203 | # define _LIBCPP_INIT_PRIORITY_MAX | 1199 | # define _LIBCPP_ACQUIRE_CAPABILITY(...) |
| 1204 | # endif | 1200 | # endif |
| 1205 | 1201 | ||
| 1206 | # if __has_attribute(__format__) | 1202 | # if __has_cpp_attribute(_Clang::__try_acquire_capability__) |
| 1207 | // The attribute uses 1-based indices for ordinary and static member functions. | 1203 | # define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...) [[_Clang::__try_acquire_capability__(__VA_ARGS__)]] |
| 1208 | // The attribute uses 2-based indices for non-static member functions. | ||
| 1209 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ | ||
| 1210 | __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) | ||
| 1211 | # else | 1204 | # else |
| 1212 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ | 1205 | # define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...) |
| 1213 | # endif | 1206 | # endif |
| 1214 | 1207 | ||
| 1215 | # if __has_attribute(__packed__) | 1208 | # if __has_cpp_attribute(_Clang::__acquire_shared_capability__) |
| 1216 | # define _LIBCPP_PACKED __attribute__((__packed__)) | 1209 | # define _LIBCPP_ACQUIRE_SHARED_CAPABILITY [[_Clang::__acquire_shared_capability__]] |
| 1217 | # else | 1210 | # else |
| 1218 | # define _LIBCPP_PACKED | 1211 | # define _LIBCPP_ACQUIRE_SHARED_CAPABILITY |
| 1212 | # endif | ||
| 1213 | |||
| 1214 | # if __has_cpp_attribute(_Clang::__try_acquire_shared_capability__) | ||
| 1215 | # define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...) [[_Clang::__try_acquire_shared_capability__(__VA_ARGS__)]] | ||
| 1216 | # else | ||
| 1217 | # define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...) | ||
| 1218 | # endif | ||
| 1219 | |||
| 1220 | # if __has_cpp_attribute(_Clang::__release_capability__) | ||
| 1221 | # define _LIBCPP_RELEASE_CAPABILITY [[_Clang::__release_capability__]] | ||
| 1222 | # else | ||
| 1223 | # define _LIBCPP_RELEASE_CAPABILITY | ||
| 1224 | # endif | ||
| 1225 | |||
| 1226 | # if __has_cpp_attribute(_Clang::__release_shared_capability__) | ||
| 1227 | # define _LIBCPP_RELEASE_SHARED_CAPABILITY [[_Clang::__release_shared_capability__]] | ||
| 1228 | # else | ||
| 1229 | # define _LIBCPP_RELEASE_SHARED_CAPABILITY | ||
| 1230 | # endif | ||
| 1231 | |||
| 1232 | # if __has_attribute(__requires_capability__) | ||
| 1233 | # define _LIBCPP_REQUIRES_CAPABILITY(...) __attribute__((__requires_capability__(__VA_ARGS__))) | ||
| 1234 | # else | ||
| 1235 | # define _LIBCPP_REQUIRES_CAPABILITY(...) | ||
| 1219 | # endif | 1236 | # endif |
| 1220 | 1237 | ||
| 1221 | # if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases) | 1238 | # if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases) |
| ... | @@ -1231,6 +1248,13 @@ typedef __char32_t char32_t; | ... | @@ -1231,6 +1248,13 @@ typedef __char32_t char32_t; |
| 1231 | # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | 1248 | # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 1232 | # endif | 1249 | # endif |
| 1233 | 1250 | ||
| 1251 | # if __has_feature(nullability) | ||
| 1252 | # define _LIBCPP_DIAGNOSE_NULLPTR _Nonnull | ||
| 1253 | # else | ||
| 1254 | # define _LIBCPP_DIAGNOSE_NULLPTR | ||
| 1255 | # endif | ||
| 1256 | |||
| 1257 | // TODO(LLVM 22): Remove this macro once LLVM19 support ends. __cpp_explicit_this_parameter has been set in LLVM20. | ||
| 1234 | // Clang-18 has support for deducing this, but it does not set the FTM. | 1258 | // Clang-18 has support for deducing this, but it does not set the FTM. |
| 1235 | # if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800) | 1259 | # if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800) |
| 1236 | # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1 | 1260 | # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1 |
lib/libcxx/include/__configuration/abi.h+30-104| ... | @@ -38,92 +38,47 @@ | ... | @@ -38,92 +38,47 @@ |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #if _LIBCPP_ABI_VERSION >= 2 | 40 | #if _LIBCPP_ABI_VERSION >= 2 |
| 41 | // Change short string representation so that string data starts at offset 0, | 41 | // TODO: Move the description of the remaining ABI flags to ABIGuarantees.rst or remove them. |
| 42 | // improving its alignment in some cases. | 42 | |
| 43 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 44 | // Fix deque iterator type in order to support incomplete types. | ||
| 45 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | ||
| 46 | // Fix undefined behavior in how std::list stores its linked nodes. | ||
| 47 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | ||
| 48 | // Fix undefined behavior in how __tree stores its end and parent nodes. | ||
| 49 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | ||
| 50 | // Fix undefined behavior in how __hash_table stores its pointer types. | ||
| 51 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | ||
| 52 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | ||
| 53 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE | ||
| 54 | // Override the default return value of exception::what() for bad_function_call::what() | 43 | // Override the default return value of exception::what() for bad_function_call::what() |
| 55 | // with a string that is specific to bad_function_call (see http://wg21.link/LWG2233). | 44 | // with a string that is specific to bad_function_call (see http://wg21.link/LWG2233). |
| 56 | // This is an ABI break on platforms that sign and authenticate vtable function pointers | 45 | // This is an ABI break on platforms that sign and authenticate vtable function pointers |
| 57 | // because it changes the mangling of the virtual function located in the vtable, which | 46 | // because it changes the mangling of the virtual function located in the vtable, which |
| 58 | // changes how it gets signed. | 47 | // changes how it gets signed. |
| 59 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | 48 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE |
| 60 | // Enable optimized version of __do_get_(un)signed which avoids redundant copies. | 49 | // According to the Standard, `bitset::operator[] const` returns bool |
| 61 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | 50 | # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL |
| 62 | // Give reverse_iterator<T> one data member of type T, not two. | 51 | |
| 63 | // Also, in C++17 and later, don't derive iterator types from std::iterator. | 52 | // In LLVM 20, we've changed to take these ABI breaks unconditionally. These flags only exist in case someone is running |
| 53 | // into the static_asserts we added to catch the ABI break and don't care that it is one. | ||
| 54 | // TODO(LLVM 22): Remove these flags | ||
| 55 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | ||
| 56 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | ||
| 57 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | ||
| 58 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | ||
| 59 | |||
| 60 | // These flags are documented in ABIGuarantees.rst | ||
| 61 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | ||
| 62 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | ||
| 63 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | ||
| 64 | # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | ||
| 65 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI | ||
| 66 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI | ||
| 67 | # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION | ||
| 68 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE | ||
| 69 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | ||
| 70 | # define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE | ||
| 71 | # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | ||
| 72 | # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE | ||
| 64 | # define _LIBCPP_ABI_NO_ITERATOR_BASES | 73 | # define _LIBCPP_ABI_NO_ITERATOR_BASES |
| 65 | // Use the smallest possible integer type to represent the index of the variant. | 74 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT |
| 66 | // Previously libc++ used "unsigned int" exclusively. | ||
| 67 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | ||
| 68 | // Unstable attempt to provide a more optimized std::function | ||
| 69 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION | 75 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION |
| 70 | // All the regex constants must be distinct and nonzero. | ||
| 71 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | 76 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO |
| 72 | // Re-worked external template instantiations for std::string with a focus on | ||
| 73 | // performance and fast-path inlining. | ||
| 74 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | 77 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 75 | // Enable clang::trivial_abi on std::unique_ptr. | ||
| 76 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI | ||
| 77 | // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr | ||
| 78 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI | ||
| 79 | // std::random_device holds some state when it uses an implementation that gets | ||
| 80 | // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this | ||
| 81 | // implementation to another one on a platform that has already shipped | ||
| 82 | // std::random_device, one needs to retain the same object layout to remain ABI | ||
| 83 | // compatible. This switch removes these workarounds for platforms that don't care | ||
| 84 | // about ABI compatibility. | ||
| 85 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT | ||
| 86 | // Don't export the legacy __basic_string_common class and its methods from the built library. | ||
| 87 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | ||
| 88 | // Don't export the legacy __vector_base_common class and its methods from the built library. | ||
| 89 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | ||
| 90 | // According to the Standard, `bitset::operator[] const` returns bool | ||
| 91 | # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | ||
| 92 | // Fix the implementation of CityHash used for std::hash<fundamental-type>. | ||
| 93 | // This is an ABI break because `std::hash` will return a different result, | ||
| 94 | // which means that hashing the same object in translation units built against | ||
| 95 | // different versions of libc++ can return inconsistent results. This is especially | ||
| 96 | // tricky since std::hash is used in the implementation of unordered containers. | ||
| 97 | // | ||
| 98 | // The incorrect implementation of CityHash has the problem that it drops some | ||
| 99 | // bits on the floor. | ||
| 100 | # define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION | ||
| 101 | // Remove the base 10 implementation of std::to_chars from the dylib. | ||
| 102 | // The implementation moved to the header, but we still export the symbols from | ||
| 103 | // the dylib for backwards compatibility. | ||
| 104 | # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | ||
| 105 | // Define std::array/std::string_view iterators to be __wrap_iters instead of raw | ||
| 106 | // pointers, which prevents people from relying on a non-portable implementation | ||
| 107 | // detail. This is especially useful because enabling bounded iterators hardening | ||
| 108 | // requires code not to make these assumptions. | ||
| 109 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY | 78 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY |
| 110 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW | 79 | # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW |
| 111 | // Dont' add an inline namespace for `std::filesystem` | 80 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION |
| 112 | # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE | 81 | |
| 113 | // std::basic_ios uses WEOF to indicate that the fill value is | ||
| 114 | // uninitialized. However, on platforms where the size of char_type is | ||
| 115 | // equal to or greater than the size of int_type and char_type is unsigned, | ||
| 116 | // std::char_traits<char_type>::eq_int_type() cannot distinguish between WEOF | ||
| 117 | // and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill | ||
| 118 | // value has been initialized using a separate boolean, which changes the ABI. | ||
| 119 | # define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE | ||
| 120 | // Historically, libc++ used a type called `__compressed_pair` to reduce storage needs in cases of empty types (e.g. an | ||
| 121 | // empty allocator in std::vector). We switched to using `[[no_unique_address]]`. However, for ABI compatibility reasons | ||
| 122 | // we had to add artificial padding in a few places. | ||
| 123 | // | ||
| 124 | // This setting disables the addition of such artificial padding, leading to a more optimal | ||
| 125 | // representation for several types. | ||
| 126 | # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | ||
| 127 | #elif _LIBCPP_ABI_VERSION == 1 | 82 | #elif _LIBCPP_ABI_VERSION == 1 |
| 128 | # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) | 83 | # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) |
| 129 | // Enable compiling copies of now inline methods into the dylib to support | 84 | // Enable compiling copies of now inline methods into the dylib to support |
| ... | @@ -138,7 +93,7 @@ | ... | @@ -138,7 +93,7 @@ |
| 138 | # endif | 93 | # endif |
| 139 | // Feature macros for disabling pre ABI v1 features. All of these options | 94 | // Feature macros for disabling pre ABI v1 features. All of these options |
| 140 | // are deprecated. | 95 | // are deprecated. |
| 141 | # if defined(__FreeBSD__) && __FreeBSD__ < 14 | 96 | # if defined(__FreeBSD__) |
| 142 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR | 97 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR |
| 143 | # endif | 98 | # endif |
| 144 | #endif | 99 | #endif |
| ... | @@ -153,35 +108,6 @@ | ... | @@ -153,35 +108,6 @@ |
| 153 | // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. | 108 | // The macro below is used for all classes whose ABI have changed as part of fixing these bugs. |
| 154 | #define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua"))) | 109 | #define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua"))) |
| 155 | 110 | ||
| 156 | // Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's | ||
| 157 | // within the bounds of the original container and asserts it on every dereference. | ||
| 158 | // | ||
| 159 | // ABI impact: changes the iterator type of the relevant containers. | ||
| 160 | // | ||
| 161 | // Supported containers: | ||
| 162 | // - `span`; | ||
| 163 | // - `string_view`. | ||
| 164 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS | ||
| 165 | |||
| 166 | // Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds | ||
| 167 | // of the original container and asserts it on every dereference and when performing iterator arithmetics. | ||
| 168 | // | ||
| 169 | // ABI impact: changes the iterator type of `basic_string` and its specializations, such as `string` and `wstring`. | ||
| 170 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | ||
| 171 | |||
| 172 | // Changes the iterator type of `vector` to a bounded iterator that keeps track of whether it's within the bounds of the | ||
| 173 | // original container and asserts it on every dereference and when performing iterator arithmetics. Note: this doesn't | ||
| 174 | // yet affect `vector<bool>`. | ||
| 175 | // | ||
| 176 | // ABI impact: changes the iterator type of `vector` (except `vector<bool>`). | ||
| 177 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | ||
| 178 | |||
| 179 | // Changes the iterator type of `array` to a bounded iterator that keeps track of whether it's within the bounds of the | ||
| 180 | // container and asserts it on every dereference and when performing iterator arithmetic. | ||
| 181 | // | ||
| 182 | // ABI impact: changes the iterator type of `array`, its size and its layout. | ||
| 183 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY | ||
| 184 | |||
| 185 | // [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work. | 111 | // [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work. |
| 186 | #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING) | 112 | #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING) |
| 187 | # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | 113 | # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING |
lib/libcxx/include/__configuration/availability.h+24-41| ... | @@ -69,7 +69,13 @@ | ... | @@ -69,7 +69,13 @@ |
| 69 | 69 | ||
| 70 | // Availability markup is disabled when building the library, or when a non-Clang | 70 | // Availability markup is disabled when building the library, or when a non-Clang |
| 71 | // compiler is used because only Clang supports the necessary attributes. | 71 | // compiler is used because only Clang supports the necessary attributes. |
| 72 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED) | 72 | // |
| 73 | // We also allow users to force-disable availability markup via the `_LIBCPP_DISABLE_AVAILABILITY` | ||
| 74 | // macro because that is the only way to work around a Clang bug related to availability | ||
| 75 | // attributes: https://github.com/llvm/llvm-project/issues/134151. | ||
| 76 | // Once that bug has been fixed, we should remove the macro. | ||
| 77 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || \ | ||
| 78 | !defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_DISABLE_AVAILABILITY) | ||
| 73 | # undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS | 79 | # undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS |
| 74 | # define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0 | 80 | # define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0 |
| 75 | #endif | 81 | #endif |
| ... | @@ -78,6 +84,9 @@ | ... | @@ -78,6 +84,9 @@ |
| 78 | // in all versions of the library are available. | 84 | // in all versions of the library are available. |
| 79 | #if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS | 85 | #if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS |
| 80 | 86 | ||
| 87 | # define _LIBCPP_INTRODUCED_IN_LLVM_21 1 | ||
| 88 | # define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE /* nothing */ | ||
| 89 | |||
| 81 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 1 | 90 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 1 |
| 82 | # define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */ | 91 | # define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */ |
| 83 | 92 | ||
| ... | @@ -107,13 +116,15 @@ | ... | @@ -107,13 +116,15 @@ |
| 107 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */ | 116 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */ |
| 108 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */ | 117 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */ |
| 109 | 118 | ||
| 110 | # define _LIBCPP_INTRODUCED_IN_LLVM_4 1 | ||
| 111 | # define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */ | ||
| 112 | |||
| 113 | #elif defined(__APPLE__) | 119 | #elif defined(__APPLE__) |
| 114 | 120 | ||
| 115 | // clang-format off | 121 | // clang-format off |
| 116 | 122 | ||
| 123 | // LLVM 21 | ||
| 124 | // TODO: Fill this in | ||
| 125 | # define _LIBCPP_INTRODUCED_IN_LLVM_21 0 | ||
| 126 | # define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable)) | ||
| 127 | |||
| 117 | // LLVM 20 | 128 | // LLVM 20 |
| 118 | // TODO: Fill this in | 129 | // TODO: Fill this in |
| 119 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 0 | 130 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 0 |
| ... | @@ -244,14 +255,6 @@ | ... | @@ -244,14 +255,6 @@ |
| 244 | _Pragma("clang attribute pop") \ | 255 | _Pragma("clang attribute pop") \ |
| 245 | _Pragma("clang attribute pop") | 256 | _Pragma("clang attribute pop") |
| 246 | 257 | ||
| 247 | // LLVM 4 | ||
| 248 | # if defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000 | ||
| 249 | # define _LIBCPP_INTRODUCED_IN_LLVM_4 0 | ||
| 250 | # else | ||
| 251 | # define _LIBCPP_INTRODUCED_IN_LLVM_4 1 | ||
| 252 | # endif | ||
| 253 | # define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE __attribute__((availability(watchos, strict, introduced = 5.0))) | ||
| 254 | |||
| 255 | // clang-format on | 258 | // clang-format on |
| 256 | 259 | ||
| 257 | #else | 260 | #else |
| ... | @@ -263,23 +266,6 @@ | ... | @@ -263,23 +266,6 @@ |
| 263 | 266 | ||
| 264 | #endif | 267 | #endif |
| 265 | 268 | ||
| 266 | // These macros control the availability of std::bad_optional_access and | ||
| 267 | // other exception types. These were put in the shared library to prevent | ||
| 268 | // code bloat from every user program defining the vtable for these exception | ||
| 269 | // types. | ||
| 270 | // | ||
| 271 | // Note that when exceptions are disabled, the methods that normally throw | ||
| 272 | // these exceptions can be used even on older deployment targets, but those | ||
| 273 | // methods will abort instead of throwing. | ||
| 274 | #define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4 | ||
| 275 | #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE | ||
| 276 | |||
| 277 | #define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4 | ||
| 278 | #define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE | ||
| 279 | |||
| 280 | #define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4 | ||
| 281 | #define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE | ||
| 282 | |||
| 283 | // These macros control the availability of all parts of <filesystem> that | 269 | // These macros control the availability of all parts of <filesystem> that |
| 284 | // depend on something in the dylib. | 270 | // depend on something in the dylib. |
| 285 | #define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9 | 271 | #define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9 |
| ... | @@ -359,18 +345,15 @@ | ... | @@ -359,18 +345,15 @@ |
| 359 | #define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20 | 345 | #define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20 |
| 360 | #define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE | 346 | #define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE |
| 361 | 347 | ||
| 362 | // Define availability attributes that depend on _LIBCPP_HAS_EXCEPTIONS. | 348 | // This controls whether `std::__hash_memory` is available in the dylib, which |
| 363 | // Those are defined in terms of the availability attributes above, and | 349 | // is used for some `std::hash` specializations. |
| 364 | // should not be vendor-specific. | 350 | #define _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY _LIBCPP_INTRODUCED_IN_LLVM_21 |
| 365 | #if !_LIBCPP_HAS_EXCEPTIONS | 351 | // No attribute, since we've had hash in the headers before |
| 366 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST | 352 | |
| 367 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | 353 | // This controls whether we provide a message for `bad_function_call::what()` that specific to `std::bad_function_call`. |
| 368 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS | 354 | // See https://wg21.link/LWG2233. This requires `std::bad_function_call::what()` to be available in the dylib. |
| 369 | #else | 355 | #define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21 |
| 370 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST | 356 | // No attribute, since we've had bad_function_call::what() in the headers before |
| 371 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS | ||
| 372 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS | ||
| 373 | #endif | ||
| 374 | 357 | ||
| 375 | // Define availability attributes that depend on both | 358 | // Define availability attributes that depend on both |
| 376 | // _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI. | 359 | // _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI. |
lib/libcxx/include/__configuration/compiler.h+2-2| ... | @@ -33,8 +33,8 @@ | ... | @@ -33,8 +33,8 @@ |
| 33 | // Warn if a compiler version is used that is not supported 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 < 1800 | 36 | # if _LIBCPP_CLANG_VER < 1900 |
| 37 | # warning "Libc++ only supports Clang 18 and later" | 37 | # warning "Libc++ only supports Clang 19 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 < 1500 |
lib/libcxx/include/__configuration/platform.h+7| ... | @@ -42,6 +42,13 @@ | ... | @@ -42,6 +42,13 @@ |
| 42 | # endif | 42 | # endif |
| 43 | #endif | 43 | #endif |
| 44 | 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 | ||
| 51 | |||
| 45 | #ifndef __BYTE_ORDER__ | 52 | #ifndef __BYTE_ORDER__ |
| 46 | # error \ | 53 | # error \ |
| 47 | "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform" | 54 | "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform" |
lib/libcxx/include/__coroutine/coroutine_handle.h+4-4| ... | @@ -28,10 +28,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,10 +28,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | // [coroutine.handle] | 29 | // [coroutine.handle] |
| 30 | template <class _Promise = void> | 30 | template <class _Promise = void> |
| 31 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle; | 31 | struct coroutine_handle; |
| 32 | 32 | ||
| 33 | template <> | 33 | template <> |
| 34 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle<void> { | 34 | struct coroutine_handle<void> { |
| 35 | public: | 35 | public: |
| 36 | // [coroutine.handle.con], construct/reset | 36 | // [coroutine.handle.con], construct/reset |
| 37 | constexpr coroutine_handle() noexcept = default; | 37 | constexpr coroutine_handle() noexcept = default; |
| ... | @@ -93,7 +93,7 @@ operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept { | ... | @@ -93,7 +93,7 @@ operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept { |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | template <class _Promise> | 95 | template <class _Promise> |
| 96 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle { | 96 | struct coroutine_handle { |
| 97 | public: | 97 | public: |
| 98 | // [coroutine.handle.con], construct/reset | 98 | // [coroutine.handle.con], construct/reset |
| 99 | constexpr coroutine_handle() noexcept = default; | 99 | constexpr coroutine_handle() noexcept = default; |
| ... | @@ -172,6 +172,6 @@ struct hash<coroutine_handle<_Tp>> { | ... | @@ -172,6 +172,6 @@ struct hash<coroutine_handle<_Tp>> { |
| 172 | 172 | ||
| 173 | _LIBCPP_END_NAMESPACE_STD | 173 | _LIBCPP_END_NAMESPACE_STD |
| 174 | 174 | ||
| 175 | #endif // __LIBCPP_STD_VER >= 20 | 175 | #endif // _LIBCPP_STD_VER >= 20 |
| 176 | 176 | ||
| 177 | #endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H | 177 | #endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H |
lib/libcxx/include/__coroutine/coroutine_traits.h+1-1| ... | @@ -43,6 +43,6 @@ struct coroutine_traits : public __coroutine_traits_sfinae<_Ret> {}; | ... | @@ -43,6 +43,6 @@ struct coroutine_traits : public __coroutine_traits_sfinae<_Ret> {}; |
| 43 | 43 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | 44 | _LIBCPP_END_NAMESPACE_STD |
| 45 | 45 | ||
| 46 | #endif // __LIBCPP_STD_VER >= 20 | 46 | #endif // _LIBCPP_STD_VER >= 20 |
| 47 | 47 | ||
| 48 | #endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H | 48 | #endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H |
lib/libcxx/include/__coroutine/noop_coroutine_handle.h+2-2| ... | @@ -28,7 +28,7 @@ struct noop_coroutine_promise {}; | ... | @@ -28,7 +28,7 @@ struct noop_coroutine_promise {}; |
| 28 | 28 | ||
| 29 | // [coroutine.handle.noop] | 29 | // [coroutine.handle.noop] |
| 30 | template <> | 30 | template <> |
| 31 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise> { | 31 | struct coroutine_handle<noop_coroutine_promise> { |
| 32 | public: | 32 | public: |
| 33 | // [coroutine.handle.noop.conv], conversion | 33 | // [coroutine.handle.noop.conv], conversion |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr operator coroutine_handle<>() const noexcept { | 34 | _LIBCPP_HIDE_FROM_ABI constexpr operator coroutine_handle<>() const noexcept { |
| ... | @@ -94,6 +94,6 @@ inline _LIBCPP_HIDE_FROM_ABI noop_coroutine_handle noop_coroutine() noexcept { r | ... | @@ -94,6 +94,6 @@ inline _LIBCPP_HIDE_FROM_ABI noop_coroutine_handle noop_coroutine() noexcept { r |
| 94 | 94 | ||
| 95 | _LIBCPP_END_NAMESPACE_STD | 95 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 96 | ||
| 97 | #endif // __LIBCPP_STD_VER >= 20 | 97 | #endif // _LIBCPP_STD_VER >= 20 |
| 98 | 98 | ||
| 99 | #endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H | 99 | #endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H |
lib/libcxx/include/__coroutine/trivial_awaitables.h+1-1| ... | @@ -35,6 +35,6 @@ struct suspend_always { | ... | @@ -35,6 +35,6 @@ struct suspend_always { |
| 35 | 35 | ||
| 36 | _LIBCPP_END_NAMESPACE_STD | 36 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 37 | ||
| 38 | #endif // __LIBCPP_STD_VER >= 20 | 38 | #endif // _LIBCPP_STD_VER >= 20 |
| 39 | 39 | ||
| 40 | #endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H | 40 | #endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H |
lib/libcxx/include/__cstddef/byte.h+2-2| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | #endif | 19 | #endif |
| 20 | 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 17 | 21 | #if _LIBCPP_STD_VER >= 17 |
| 22 | namespace std { // purposefully not versioned | 22 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | enum class byte : unsigned char {}; | 24 | enum class byte : unsigned char {}; |
| 25 | 25 | ||
| ... | @@ -79,7 +79,7 @@ template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | ... | @@ -79,7 +79,7 @@ template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> |
| 79 | return static_cast<_Integer>(__b); | 79 | return static_cast<_Integer>(__b); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | } // namespace std | 82 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 83 | #endif // _LIBCPP_STD_VER >= 17 | 83 | #endif // _LIBCPP_STD_VER >= 17 |
| 84 | 84 | ||
| 85 | #endif // _LIBCPP___CSTDDEF_BYTE_H | 85 | #endif // _LIBCPP___CSTDDEF_BYTE_H |
lib/libcxx/include/__debug_utils/sanitizers.h+5-5| ... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
| 17 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | #if _LIBCPP_HAS_ASAN | 20 | #if __has_feature(address_sanitizer) |
| 21 | 21 | ||
| 22 | extern "C" { | 22 | extern "C" { |
| 23 | _LIBCPP_EXPORTED_FROM_ABI void | 23 | _LIBCPP_EXPORTED_FROM_ABI void |
| ... | @@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int | ... | @@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int |
| 28 | __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); | 28 | __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | #endif // _LIBCPP_HAS_ASAN | 31 | #endif // __has_feature(address_sanitizer) |
| 32 | 32 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | ||
| 35 | // ASan choices | 35 | // ASan choices |
| 36 | #if _LIBCPP_HAS_ASAN | 36 | #if __has_feature(address_sanitizer) |
| 37 | # define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 | 37 | # define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| ... | @@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container( | ... | @@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container( |
| 57 | const void* __last_old_contained, | 57 | const void* __last_old_contained, |
| 58 | const void* __first_new_contained, | 58 | const void* __first_new_contained, |
| 59 | const void* __last_new_contained) { | 59 | const void* __last_new_contained) { |
| 60 | #if !_LIBCPP_HAS_ASAN | 60 | #if !__has_feature(address_sanitizer) |
| 61 | (void)__first_storage; | 61 | (void)__first_storage; |
| 62 | (void)__last_storage; | 62 | (void)__last_storage; |
| 63 | (void)__first_old_contained; | 63 | (void)__first_old_contained; |
| ... | @@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c | ... | @@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c |
| 86 | const void* __last_storage, | 86 | const void* __last_storage, |
| 87 | const void* __old_last_contained, | 87 | const void* __old_last_contained, |
| 88 | const void* __new_last_contained) { | 88 | const void* __new_last_contained) { |
| 89 | #if !_LIBCPP_HAS_ASAN | 89 | #if !__has_feature(address_sanitizer) |
| 90 | (void)__first_storage; | 90 | (void)__first_storage; |
| 91 | (void)__last_storage; | 91 | (void)__last_storage; |
| 92 | (void)__old_last_contained; | 92 | (void)__old_last_contained; |
lib/libcxx/include/__exception/exception.h+2-2| ... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
| 21 | # pragma GCC system_header | 21 | # pragma GCC system_header |
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | namespace std { // purposefully not using versioning namespace | 24 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | #if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0) | 26 | #if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0) |
| 27 | // The std::exception class was already included above, but we're explicit about this condition here for clarity. | 27 | // The std::exception class was already included above, but we're explicit about this condition here for clarity. |
| ... | @@ -89,6 +89,6 @@ public: | ... | @@ -89,6 +89,6 @@ public: |
| 89 | }; | 89 | }; |
| 90 | #endif // !_LIBCPP_ABI_VCRUNTIME | 90 | #endif // !_LIBCPP_ABI_VCRUNTIME |
| 91 | 91 | ||
| 92 | } // namespace std | 92 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 93 | 93 | ||
| 94 | #endif // _LIBCPP___EXCEPTION_EXCEPTION_H | 94 | #endif // _LIBCPP___EXCEPTION_EXCEPTION_H |
lib/libcxx/include/__exception/exception_ptr.h+49-21| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | #include <__memory/addressof.h> | 15 | #include <__memory/addressof.h> |
| 16 | #include <__memory/construct_at.h> | 16 | #include <__memory/construct_at.h> |
| 17 | #include <__type_traits/decay.h> | 17 | #include <__type_traits/decay.h> |
| 18 | #include <__type_traits/is_pointer.h> | ||
| 18 | #include <cstdlib> | 19 | #include <cstdlib> |
| 19 | #include <typeinfo> | 20 | #include <typeinfo> |
| 20 | 21 | ||
| ... | @@ -52,7 +53,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception( | ... | @@ -52,7 +53,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception( |
| 52 | 53 | ||
| 53 | #endif | 54 | #endif |
| 54 | 55 | ||
| 55 | namespace std { // purposefully not using versioning namespace | 56 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 56 | 57 | ||
| 57 | #ifndef _LIBCPP_ABI_MICROSOFT | 58 | #ifndef _LIBCPP_ABI_MICROSOFT |
| 58 | 59 | ||
| ... | @@ -62,11 +63,13 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { | ... | @@ -62,11 +63,13 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { |
| 62 | static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT; | 63 | static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT; |
| 63 | 64 | ||
| 64 | template <class _Ep> | 65 | template <class _Ep> |
| 65 | friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT; | 66 | friend _LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep&) _NOEXCEPT; |
| 66 | 67 | ||
| 67 | public: | 68 | public: |
| 68 | // exception_ptr is basically a COW string. | 69 | // exception_ptr is basically a COW string so it is trivially relocatable. |
| 70 | // It is also replaceable because assignment has normal value semantics. | ||
| 69 | using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr; | 71 | using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr; |
| 72 | using __replaceable _LIBCPP_NODEBUG = exception_ptr; | ||
| 70 | 73 | ||
| 71 | _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {} | 74 | _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {} |
| 72 | _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} | 75 | _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} |
| ... | @@ -89,25 +92,21 @@ public: | ... | @@ -89,25 +92,21 @@ public: |
| 89 | friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | 92 | friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); |
| 90 | }; | 93 | }; |
| 91 | 94 | ||
| 92 | template <class _Ep> | ||
| 93 | _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { | ||
| 94 | # if _LIBCPP_HAS_EXCEPTIONS | 95 | # if _LIBCPP_HAS_EXCEPTIONS |
| 95 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L | 96 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION |
| 97 | template <class _Ep> | ||
| 98 | _LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep& __e) _NOEXCEPT { | ||
| 96 | using _Ep2 = __decay_t<_Ep>; | 99 | using _Ep2 = __decay_t<_Ep>; |
| 97 | |||
| 98 | void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep)); | 100 | void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep)); |
| 99 | # ifdef __wasm__ | 101 | # ifdef __wasm__ |
| 100 | // In Wasm, a destructor returns its argument | 102 | auto __cleanup = [](void* __p) -> void* { |
| 101 | (void)__cxxabiv1::__cxa_init_primary_exception( | 103 | std::__destroy_at(static_cast<_Ep2*>(__p)); |
| 102 | __ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) -> void* { | 104 | return __p; |
| 105 | }; | ||
| 103 | # else | 106 | # else |
| 104 | (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) { | 107 | auto __cleanup = [](void* __p) { std::__destroy_at(static_cast<_Ep2*>(__p)); }; |
| 105 | # endif | ||
| 106 | std::__destroy_at(static_cast<_Ep2*>(__p)); | ||
| 107 | # ifdef __wasm__ | ||
| 108 | return __p; | ||
| 109 | # endif | 108 | # endif |
| 110 | }); | 109 | (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), __cleanup); |
| 111 | 110 | ||
| 112 | try { | 111 | try { |
| 113 | ::new (__ex) _Ep2(__e); | 112 | ::new (__ex) _Ep2(__e); |
| ... | @@ -116,18 +115,47 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { | ... | @@ -116,18 +115,47 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { |
| 116 | __cxxabiv1::__cxa_free_exception(__ex); | 115 | __cxxabiv1::__cxa_free_exception(__ex); |
| 117 | return current_exception(); | 116 | return current_exception(); |
| 118 | } | 117 | } |
| 119 | # else | 118 | } |
| 119 | # endif | ||
| 120 | |||
| 121 | template <class _Ep> | ||
| 122 | _LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_via_throw(_Ep& __e) _NOEXCEPT { | ||
| 120 | try { | 123 | try { |
| 121 | throw __e; | 124 | throw __e; |
| 122 | } catch (...) { | 125 | } catch (...) { |
| 123 | return current_exception(); | 126 | return current_exception(); |
| 124 | } | 127 | } |
| 128 | } | ||
| 129 | |||
| 130 | template <class _Ep> | ||
| 131 | _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { | ||
| 132 | // Objective-C exceptions are thrown via pointer. When throwing an Objective-C exception, | ||
| 133 | // Clang generates a call to `objc_exception_throw` instead of the usual `__cxa_throw`. | ||
| 134 | // That function creates an exception with a special Objective-C typeinfo instead of | ||
| 135 | // the usual C++ typeinfo, since that is needed to implement the behavior documented | ||
| 136 | // at [1]). | ||
| 137 | // | ||
| 138 | // Because of this special behavior, we can't create an exception via `__cxa_init_primary_exception` | ||
| 139 | // for Objective-C exceptions, otherwise we'd bypass `objc_exception_throw`. See https://llvm.org/PR135089. | ||
| 140 | // | ||
| 141 | // [1]: | ||
| 142 | // https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Exceptions/Articles/Exceptions64Bit.html | ||
| 143 | if _LIBCPP_CONSTEXPR (is_pointer<_Ep>::value) { | ||
| 144 | return std::__make_exception_ptr_via_throw(__e); | ||
| 145 | } | ||
| 146 | |||
| 147 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && !defined(_LIBCPP_CXX03_LANG) | ||
| 148 | return std::__make_exception_ptr_explicit(__e); | ||
| 149 | # else | ||
| 150 | return std::__make_exception_ptr_via_throw(__e); | ||
| 125 | # endif | 151 | # endif |
| 126 | # else | 152 | } |
| 127 | ((void)__e); | 153 | # else // !_LIBCPP_HAS_EXCEPTIONS |
| 154 | template <class _Ep> | ||
| 155 | _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT { | ||
| 128 | std::abort(); | 156 | std::abort(); |
| 129 | # endif | ||
| 130 | } | 157 | } |
| 158 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 131 | 159 | ||
| 132 | #else // _LIBCPP_ABI_MICROSOFT | 160 | #else // _LIBCPP_ABI_MICROSOFT |
| 133 | 161 | ||
| ... | @@ -171,6 +199,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { | ... | @@ -171,6 +199,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { |
| 171 | } | 199 | } |
| 172 | 200 | ||
| 173 | #endif // _LIBCPP_ABI_MICROSOFT | 201 | #endif // _LIBCPP_ABI_MICROSOFT |
| 174 | } // namespace std | 202 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 175 | 203 | ||
| 176 | #endif // _LIBCPP___EXCEPTION_EXCEPTION_PTR_H | 204 | #endif // _LIBCPP___EXCEPTION_EXCEPTION_PTR_H |
lib/libcxx/include/__exception/nested_exception.h+2-2| ... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
| 27 | # pragma GCC system_header | 27 | # pragma GCC system_header |
| 28 | #endif | 28 | #endif |
| 29 | 29 | ||
| 30 | namespace std { // purposefully not using versioning namespace | 30 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 31 | 31 | ||
| 32 | class _LIBCPP_EXPORTED_FROM_ABI nested_exception { | 32 | class _LIBCPP_EXPORTED_FROM_ABI nested_exception { |
| 33 | exception_ptr __ptr_; | 33 | exception_ptr __ptr_; |
| ... | @@ -95,6 +95,6 @@ inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep& __e) { | ... | @@ -95,6 +95,6 @@ inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep& __e) { |
| 95 | template <class _Ep, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value, int> = 0> | 95 | template <class _Ep, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value, int> = 0> |
| 96 | inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep&) {} | 96 | inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep&) {} |
| 97 | 97 | ||
| 98 | } // namespace std | 98 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 99 | 99 | ||
| 100 | #endif // _LIBCPP___EXCEPTION_NESTED_EXCEPTION_H | 100 | #endif // _LIBCPP___EXCEPTION_NESTED_EXCEPTION_H |
lib/libcxx/include/__exception/operations.h+2-2| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | namespace std { // purposefully not using versioning namespace | 18 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 19 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) || \ | 19 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) || \ |
| 20 | defined(_LIBCPP_BUILDING_LIBRARY) | 20 | defined(_LIBCPP_BUILDING_LIBRARY) |
| 21 | using unexpected_handler = void (*)(); | 21 | using unexpected_handler = void (*)(); |
| ... | @@ -37,6 +37,6 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr; | ... | @@ -37,6 +37,6 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr; |
| 37 | 37 | ||
| 38 | _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; | 38 | _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; |
| 39 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | 39 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); |
| 40 | } // namespace std | 40 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 41 | 41 | ||
| 42 | #endif // _LIBCPP___EXCEPTION_OPERATIONS_H | 42 | #endif // _LIBCPP___EXCEPTION_OPERATIONS_H |
lib/libcxx/include/__exception/terminate.h+2-2| ... | @@ -15,8 +15,8 @@ | ... | @@ -15,8 +15,8 @@ |
| 15 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | namespace std { // purposefully not using versioning namespace | 18 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 19 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT; | 19 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT; |
| 20 | } // namespace std | 20 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #endif // _LIBCPP___EXCEPTION_TERMINATE_H | 22 | #endif // _LIBCPP___EXCEPTION_TERMINATE_H |
lib/libcxx/include/__expected/expected.h+40-5| ... | @@ -25,10 +25,12 @@ | ... | @@ -25,10 +25,12 @@ |
| 25 | #include <__type_traits/is_assignable.h> | 25 | #include <__type_traits/is_assignable.h> |
| 26 | #include <__type_traits/is_constructible.h> | 26 | #include <__type_traits/is_constructible.h> |
| 27 | #include <__type_traits/is_convertible.h> | 27 | #include <__type_traits/is_convertible.h> |
| 28 | #include <__type_traits/is_core_convertible.h> | ||
| 28 | #include <__type_traits/is_function.h> | 29 | #include <__type_traits/is_function.h> |
| 29 | #include <__type_traits/is_nothrow_assignable.h> | 30 | #include <__type_traits/is_nothrow_assignable.h> |
| 30 | #include <__type_traits/is_nothrow_constructible.h> | 31 | #include <__type_traits/is_nothrow_constructible.h> |
| 31 | #include <__type_traits/is_reference.h> | 32 | #include <__type_traits/is_reference.h> |
| 33 | #include <__type_traits/is_replaceable.h> | ||
| 32 | #include <__type_traits/is_same.h> | 34 | #include <__type_traits/is_same.h> |
| 33 | #include <__type_traits/is_swappable.h> | 35 | #include <__type_traits/is_swappable.h> |
| 34 | #include <__type_traits/is_trivially_constructible.h> | 36 | #include <__type_traits/is_trivially_constructible.h> |
| ... | @@ -470,6 +472,8 @@ public: | ... | @@ -470,6 +472,8 @@ public: |
| 470 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value, | 472 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value, |
| 471 | expected, | 473 | expected, |
| 472 | void>; | 474 | void>; |
| 475 | using __replaceable _LIBCPP_NODEBUG = | ||
| 476 | __conditional_t<__is_replaceable_v<_Tp> && __is_replaceable_v<_Err>, expected, void>; | ||
| 473 | 477 | ||
| 474 | template <class _Up> | 478 | template <class _Up> |
| 475 | using rebind = expected<_Up, error_type>; | 479 | using rebind = expected<_Up, error_type>; |
| ... | @@ -1139,8 +1143,15 @@ public: | ... | @@ -1139,8 +1143,15 @@ public: |
| 1139 | 1143 | ||
| 1140 | // [expected.object.eq], equality operators | 1144 | // [expected.object.eq], equality operators |
| 1141 | template <class _T2, class _E2> | 1145 | template <class _T2, class _E2> |
| 1146 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) | ||
| 1142 | requires(!is_void_v<_T2>) | 1147 | requires(!is_void_v<_T2>) |
| 1143 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) { | 1148 | # if _LIBCPP_STD_VER >= 26 |
| 1149 | && requires { | ||
| 1150 | { *__x == *__y } -> __core_convertible_to<bool>; | ||
| 1151 | { __x.error() == __y.error() } -> __core_convertible_to<bool>; | ||
| 1152 | } | ||
| 1153 | # endif | ||
| 1154 | { | ||
| 1144 | if (__x.__has_val() != __y.__has_val()) { | 1155 | if (__x.__has_val() != __y.__has_val()) { |
| 1145 | return false; | 1156 | return false; |
| 1146 | } else { | 1157 | } else { |
| ... | @@ -1153,12 +1164,24 @@ public: | ... | @@ -1153,12 +1164,24 @@ public: |
| 1153 | } | 1164 | } |
| 1154 | 1165 | ||
| 1155 | template <class _T2> | 1166 | template <class _T2> |
| 1156 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const _T2& __v) { | 1167 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const _T2& __v) |
| 1168 | # if _LIBCPP_STD_VER >= 26 | ||
| 1169 | requires(!__is_std_expected<_T2>::value) && requires { | ||
| 1170 | { *__x == __v } -> __core_convertible_to<bool>; | ||
| 1171 | } | ||
| 1172 | # endif | ||
| 1173 | { | ||
| 1157 | return __x.__has_val() && static_cast<bool>(__x.__val() == __v); | 1174 | return __x.__has_val() && static_cast<bool>(__x.__val() == __v); |
| 1158 | } | 1175 | } |
| 1159 | 1176 | ||
| 1160 | template <class _E2> | 1177 | template <class _E2> |
| 1161 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __e) { | 1178 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __e) |
| 1179 | # if _LIBCPP_STD_VER >= 26 | ||
| 1180 | requires requires { | ||
| 1181 | { __x.error() == __e.error() } -> __core_convertible_to<bool>; | ||
| 1182 | } | ||
| 1183 | # endif | ||
| 1184 | { | ||
| 1162 | return !__x.__has_val() && static_cast<bool>(__x.__unex() == __e.error()); | 1185 | return !__x.__has_val() && static_cast<bool>(__x.__unex() == __e.error()); |
| 1163 | } | 1186 | } |
| 1164 | }; | 1187 | }; |
| ... | @@ -1851,7 +1874,13 @@ public: | ... | @@ -1851,7 +1874,13 @@ public: |
| 1851 | // [expected.void.eq], equality operators | 1874 | // [expected.void.eq], equality operators |
| 1852 | template <class _T2, class _E2> | 1875 | template <class _T2, class _E2> |
| 1853 | requires is_void_v<_T2> | 1876 | requires is_void_v<_T2> |
| 1854 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) { | 1877 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) |
| 1878 | # if _LIBCPP_STD_VER >= 26 | ||
| 1879 | requires requires { | ||
| 1880 | { __x.error() == __y.error() } -> __core_convertible_to<bool>; | ||
| 1881 | } | ||
| 1882 | # endif | ||
| 1883 | { | ||
| 1855 | if (__x.__has_val() != __y.__has_val()) { | 1884 | if (__x.__has_val() != __y.__has_val()) { |
| 1856 | return false; | 1885 | return false; |
| 1857 | } else { | 1886 | } else { |
| ... | @@ -1860,7 +1889,13 @@ public: | ... | @@ -1860,7 +1889,13 @@ public: |
| 1860 | } | 1889 | } |
| 1861 | 1890 | ||
| 1862 | template <class _E2> | 1891 | template <class _E2> |
| 1863 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y) { | 1892 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y) |
| 1893 | # if _LIBCPP_STD_VER >= 26 | ||
| 1894 | requires requires { | ||
| 1895 | { __x.error() == __y.error() } -> __core_convertible_to<bool>; | ||
| 1896 | } | ||
| 1897 | # endif | ||
| 1898 | { | ||
| 1864 | return !__x.__has_val() && static_cast<bool>(__x.__unex() == __y.error()); | 1899 | return !__x.__has_val() && static_cast<bool>(__x.__unex() == __y.error()); |
| 1865 | } | 1900 | } |
| 1866 | }; | 1901 | }; |
lib/libcxx/include/__filesystem/directory_entry.h+1-1| ... | @@ -286,7 +286,7 @@ private: | ... | @@ -286,7 +286,7 @@ private: |
| 286 | return; | 286 | return; |
| 287 | } | 287 | } |
| 288 | if (__ec && (!__allow_dne || !__is_dne_error(__ec))) | 288 | if (__ec && (!__allow_dne || !__is_dne_error(__ec))) |
| 289 | __throw_filesystem_error(__msg, __p_, __ec); | 289 | filesystem::__throw_filesystem_error(__msg, __p_, __ec); |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | _LIBCPP_HIDE_FROM_ABI void __refresh(error_code* __ec = nullptr) { | 292 | _LIBCPP_HIDE_FROM_ABI void __refresh(error_code* __ec = nullptr) { |
lib/libcxx/include/__filesystem/operations.h+3-3| ... | @@ -66,6 +66,9 @@ _LIBCPP_EXPORTED_FROM_ABI bool __remove(const path&, error_code* __ec = nullptr) | ... | @@ -66,6 +66,9 @@ _LIBCPP_EXPORTED_FROM_ABI bool __remove(const path&, error_code* __ec = nullptr) |
| 66 | _LIBCPP_EXPORTED_FROM_ABI void __rename(const path& __from, const path& __to, error_code* __ec = nullptr); | 66 | _LIBCPP_EXPORTED_FROM_ABI void __rename(const path& __from, const path& __to, error_code* __ec = nullptr); |
| 67 | _LIBCPP_EXPORTED_FROM_ABI void __resize_file(const path&, uintmax_t __size, error_code* = nullptr); | 67 | _LIBCPP_EXPORTED_FROM_ABI void __resize_file(const path&, uintmax_t __size, error_code* = nullptr); |
| 68 | _LIBCPP_EXPORTED_FROM_ABI path __temp_directory_path(error_code* __ec = nullptr); | 68 | _LIBCPP_EXPORTED_FROM_ABI path __temp_directory_path(error_code* __ec = nullptr); |
| 69 | _LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = nullptr); | ||
| 70 | _LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr); | ||
| 71 | _LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr); | ||
| 69 | 72 | ||
| 70 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); } | 73 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); } |
| 71 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); } | 74 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); } |
| ... | @@ -182,7 +185,6 @@ inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_dire | ... | @@ -182,7 +185,6 @@ inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_dire |
| 182 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { | 185 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { |
| 183 | return is_directory(__status(__p, &__ec)); | 186 | return is_directory(__status(__p, &__ec)); |
| 184 | } | 187 | } |
| 185 | _LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = nullptr); | ||
| 186 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); } | 188 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); } |
| 187 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } | 189 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } |
| 188 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; } | 190 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; } |
| ... | @@ -220,7 +222,6 @@ inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_typ | ... | @@ -220,7 +222,6 @@ inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_typ |
| 220 | inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { | 222 | inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { |
| 221 | __last_write_time(__p, __t, &__ec); | 223 | __last_write_time(__p, __t, &__ec); |
| 222 | } | 224 | } |
| 223 | _LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr); | ||
| 224 | inline _LIBCPP_HIDE_FROM_ABI void | 225 | inline _LIBCPP_HIDE_FROM_ABI void |
| 225 | permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { | 226 | permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { |
| 226 | __permissions(__p, __prms, __opts); | 227 | __permissions(__p, __prms, __opts); |
| ... | @@ -281,7 +282,6 @@ inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { | ... | @@ -281,7 +282,6 @@ inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { |
| 281 | inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { | 282 | inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { |
| 282 | return __resize_file(__p, __ns, &__ec); | 283 | return __resize_file(__p, __ns, &__ec); |
| 283 | } | 284 | } |
| 284 | _LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr); | ||
| 285 | inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); } | 285 | 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 { | 286 | inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept { |
| 287 | return __space(__p, &__ec); | 287 | return __space(__p, &__ec); |
lib/libcxx/include/__filesystem/path.h+3-2| ... | @@ -17,7 +17,9 @@ | ... | @@ -17,7 +17,9 @@ |
| 17 | #include <__fwd/functional.h> | 17 | #include <__fwd/functional.h> |
| 18 | #include <__iterator/back_insert_iterator.h> | 18 | #include <__iterator/back_insert_iterator.h> |
| 19 | #include <__iterator/iterator_traits.h> | 19 | #include <__iterator/iterator_traits.h> |
| 20 | #include <__memory/addressof.h> | ||
| 20 | #include <__type_traits/decay.h> | 21 | #include <__type_traits/decay.h> |
| 22 | #include <__type_traits/enable_if.h> | ||
| 21 | #include <__type_traits/is_pointer.h> | 23 | #include <__type_traits/is_pointer.h> |
| 22 | #include <__type_traits/remove_const.h> | 24 | #include <__type_traits/remove_const.h> |
| 23 | #include <__type_traits/remove_pointer.h> | 25 | #include <__type_traits/remove_pointer.h> |
| ... | @@ -27,7 +29,6 @@ | ... | @@ -27,7 +29,6 @@ |
| 27 | 29 | ||
| 28 | #if _LIBCPP_HAS_LOCALIZATION | 30 | #if _LIBCPP_HAS_LOCALIZATION |
| 29 | # include <iomanip> // for quoted | 31 | # include <iomanip> // for quoted |
| 30 | # include <locale> | ||
| 31 | #endif | 32 | #endif |
| 32 | 33 | ||
| 33 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 34 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -583,7 +584,7 @@ public: | ... | @@ -583,7 +584,7 @@ public: |
| 583 | 584 | ||
| 584 | template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0> | 585 | template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0> |
| 585 | _LIBCPP_HIDE_FROM_ABI path& operator+=(_ECharT __x) { | 586 | _LIBCPP_HIDE_FROM_ABI path& operator+=(_ECharT __x) { |
| 586 | _PathCVT<_ECharT>::__append_source(__pn_, basic_string_view<_ECharT>(&__x, 1)); | 587 | _PathCVT<_ECharT>::__append_source(__pn_, basic_string_view<_ECharT>(std::addressof(__x), 1)); |
| 587 | return *this; | 588 | return *this; |
| 588 | } | 589 | } |
| 589 | 590 |
lib/libcxx/include/__filesystem/u8path.h+1-6| ... | @@ -13,14 +13,9 @@ | ... | @@ -13,14 +13,9 @@ |
| 13 | #include <__algorithm/unwrap_iter.h> | 13 | #include <__algorithm/unwrap_iter.h> |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__filesystem/path.h> | 15 | #include <__filesystem/path.h> |
| 16 | #include <__locale> | ||
| 16 | #include <string> | 17 | #include <string> |
| 17 | 18 | ||
| 18 | // Only required on Windows for __widen_from_utf8, and included conservatively | ||
| 19 | // because it requires support for localization. | ||
| 20 | #if defined(_LIBCPP_WIN32API) | ||
| 21 | # include <locale> | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | # pragma GCC system_header | 20 | # pragma GCC system_header |
| 26 | #endif | 21 | #endif |
lib/libcxx/include/__flat_map/flat_map.h+258-185| ... | @@ -11,16 +11,15 @@ | ... | @@ -11,16 +11,15 @@ |
| 11 | #define _LIBCPP___FLAT_MAP_FLAT_MAP_H | 11 | #define _LIBCPP___FLAT_MAP_FLAT_MAP_H |
| 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/min.h> | 15 | #include <__algorithm/min.h> |
| 15 | #include <__algorithm/ranges_adjacent_find.h> | 16 | #include <__algorithm/ranges_adjacent_find.h> |
| 16 | #include <__algorithm/ranges_equal.h> | 17 | #include <__algorithm/ranges_equal.h> |
| 17 | #include <__algorithm/ranges_inplace_merge.h> | 18 | #include <__algorithm/ranges_inplace_merge.h> |
| 18 | #include <__algorithm/ranges_lower_bound.h> | ||
| 19 | #include <__algorithm/ranges_partition_point.h> | ||
| 20 | #include <__algorithm/ranges_sort.h> | 19 | #include <__algorithm/ranges_sort.h> |
| 21 | #include <__algorithm/ranges_unique.h> | 20 | #include <__algorithm/ranges_unique.h> |
| 22 | #include <__algorithm/ranges_upper_bound.h> | ||
| 23 | #include <__algorithm/remove_if.h> | 21 | #include <__algorithm/remove_if.h> |
| 22 | #include <__algorithm/upper_bound.h> | ||
| 24 | #include <__assert> | 23 | #include <__assert> |
| 25 | #include <__compare/synth_three_way.h> | 24 | #include <__compare/synth_three_way.h> |
| 26 | #include <__concepts/swappable.h> | 25 | #include <__concepts/swappable.h> |
| ... | @@ -33,6 +32,7 @@ | ... | @@ -33,6 +32,7 @@ |
| 33 | #include <__functional/invoke.h> | 32 | #include <__functional/invoke.h> |
| 34 | #include <__functional/is_transparent.h> | 33 | #include <__functional/is_transparent.h> |
| 35 | #include <__functional/operations.h> | 34 | #include <__functional/operations.h> |
| 35 | #include <__fwd/memory.h> | ||
| 36 | #include <__fwd/vector.h> | 36 | #include <__fwd/vector.h> |
| 37 | #include <__iterator/concepts.h> | 37 | #include <__iterator/concepts.h> |
| 38 | #include <__iterator/distance.h> | 38 | #include <__iterator/distance.h> |
| ... | @@ -114,11 +114,12 @@ public: | ... | @@ -114,11 +114,12 @@ public: |
| 114 | class value_compare { | 114 | class value_compare { |
| 115 | private: | 115 | private: |
| 116 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_; | 116 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_; |
| 117 | _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {} | 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare(key_compare __c) : __comp_(__c) {} |
| 118 | friend flat_map; | 118 | friend flat_map; |
| 119 | 119 | ||
| 120 | public: | 120 | public: |
| 121 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | 121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool |
| 122 | operator()(const_reference __x, const_reference __y) const { | ||
| 122 | return __comp_(__x.first, __y.first); | 123 | return __comp_(__x.first, __y.first); |
| 123 | } | 124 | } |
| 124 | }; | 125 | }; |
| ... | @@ -137,14 +138,14 @@ private: | ... | @@ -137,14 +138,14 @@ private: |
| 137 | 138 | ||
| 138 | public: | 139 | public: |
| 139 | // [flat.map.cons], construct/copy/destroy | 140 | // [flat.map.cons], construct/copy/destroy |
| 140 | _LIBCPP_HIDE_FROM_ABI flat_map() noexcept( | 141 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map() noexcept( |
| 141 | is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> && | 142 | is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> && |
| 142 | is_nothrow_default_constructible_v<_Compare>) | 143 | is_nothrow_default_constructible_v<_Compare>) |
| 143 | : __containers_(), __compare_() {} | 144 | : __containers_(), __compare_() {} |
| 144 | 145 | ||
| 145 | _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map&) = default; | 146 | _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map&) = default; |
| 146 | 147 | ||
| 147 | _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other) noexcept( | 148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(flat_map&& __other) noexcept( |
| 148 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> && | 149 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> && |
| 149 | is_nothrow_move_constructible_v<_Compare>) | 150 | is_nothrow_move_constructible_v<_Compare>) |
| 150 | # if _LIBCPP_HAS_EXCEPTIONS | 151 | # if _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -165,7 +166,7 @@ public: | ... | @@ -165,7 +166,7 @@ public: |
| 165 | 166 | ||
| 166 | template <class _Allocator> | 167 | template <class _Allocator> |
| 167 | requires __allocator_ctor_constraint<_Allocator> | 168 | requires __allocator_ctor_constraint<_Allocator> |
| 168 | _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map& __other, const _Allocator& __alloc) | 169 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(const flat_map& __other, const _Allocator& __alloc) |
| 169 | : flat_map(__ctor_uses_allocator_tag{}, | 170 | : flat_map(__ctor_uses_allocator_tag{}, |
| 170 | __alloc, | 171 | __alloc, |
| 171 | __other.__containers_.keys, | 172 | __other.__containers_.keys, |
| ... | @@ -174,7 +175,7 @@ public: | ... | @@ -174,7 +175,7 @@ public: |
| 174 | 175 | ||
| 175 | template <class _Allocator> | 176 | template <class _Allocator> |
| 176 | requires __allocator_ctor_constraint<_Allocator> | 177 | requires __allocator_ctor_constraint<_Allocator> |
| 177 | _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other, const _Allocator& __alloc) | 178 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(flat_map&& __other, const _Allocator& __alloc) |
| 178 | # if _LIBCPP_HAS_EXCEPTIONS | 179 | # if _LIBCPP_HAS_EXCEPTIONS |
| 179 | try | 180 | try |
| 180 | # endif // _LIBCPP_HAS_EXCEPTIONS | 181 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -191,7 +192,7 @@ public: | ... | @@ -191,7 +192,7 @@ public: |
| 191 | # endif // _LIBCPP_HAS_EXCEPTIONS | 192 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 192 | } | 193 | } |
| 193 | 194 | ||
| 194 | _LIBCPP_HIDE_FROM_ABI flat_map( | 195 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map( |
| 195 | key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare()) | 196 | key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare()) |
| 196 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { | 197 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { |
| 197 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 198 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| ... | @@ -201,7 +202,7 @@ public: | ... | @@ -201,7 +202,7 @@ public: |
| 201 | 202 | ||
| 202 | template <class _Allocator> | 203 | template <class _Allocator> |
| 203 | requires __allocator_ctor_constraint<_Allocator> | 204 | requires __allocator_ctor_constraint<_Allocator> |
| 204 | _LIBCPP_HIDE_FROM_ABI | 205 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 205 | flat_map(const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc) | 206 | flat_map(const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc) |
| 206 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { | 207 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { |
| 207 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 208 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| ... | @@ -211,7 +212,7 @@ public: | ... | @@ -211,7 +212,7 @@ public: |
| 211 | 212 | ||
| 212 | template <class _Allocator> | 213 | template <class _Allocator> |
| 213 | requires __allocator_ctor_constraint<_Allocator> | 214 | requires __allocator_ctor_constraint<_Allocator> |
| 214 | _LIBCPP_HIDE_FROM_ABI | 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 215 | flat_map(const key_container_type& __key_cont, | 216 | flat_map(const key_container_type& __key_cont, |
| 216 | const mapped_container_type& __mapped_cont, | 217 | const mapped_container_type& __mapped_cont, |
| 217 | const key_compare& __comp, | 218 | const key_compare& __comp, |
| ... | @@ -222,7 +223,7 @@ public: | ... | @@ -222,7 +223,7 @@ public: |
| 222 | __sort_and_unique(); | 223 | __sort_and_unique(); |
| 223 | } | 224 | } |
| 224 | 225 | ||
| 225 | _LIBCPP_HIDE_FROM_ABI | 226 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 226 | flat_map(sorted_unique_t, | 227 | flat_map(sorted_unique_t, |
| 227 | key_container_type __key_cont, | 228 | key_container_type __key_cont, |
| 228 | mapped_container_type __mapped_cont, | 229 | mapped_container_type __mapped_cont, |
| ... | @@ -236,7 +237,7 @@ public: | ... | @@ -236,7 +237,7 @@ public: |
| 236 | 237 | ||
| 237 | template <class _Allocator> | 238 | template <class _Allocator> |
| 238 | requires __allocator_ctor_constraint<_Allocator> | 239 | requires __allocator_ctor_constraint<_Allocator> |
| 239 | _LIBCPP_HIDE_FROM_ABI | 240 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 240 | flat_map(sorted_unique_t, | 241 | flat_map(sorted_unique_t, |
| 241 | const key_container_type& __key_cont, | 242 | const key_container_type& __key_cont, |
| 242 | const mapped_container_type& __mapped_cont, | 243 | const mapped_container_type& __mapped_cont, |
| ... | @@ -250,12 +251,12 @@ public: | ... | @@ -250,12 +251,12 @@ public: |
| 250 | 251 | ||
| 251 | template <class _Allocator> | 252 | template <class _Allocator> |
| 252 | requires __allocator_ctor_constraint<_Allocator> | 253 | requires __allocator_ctor_constraint<_Allocator> |
| 253 | _LIBCPP_HIDE_FROM_ABI | 254 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map( |
| 254 | flat_map(sorted_unique_t, | 255 | sorted_unique_t, |
| 255 | const key_container_type& __key_cont, | 256 | const key_container_type& __key_cont, |
| 256 | const mapped_container_type& __mapped_cont, | 257 | const mapped_container_type& __mapped_cont, |
| 257 | const key_compare& __comp, | 258 | const key_compare& __comp, |
| 258 | const _Allocator& __alloc) | 259 | const _Allocator& __alloc) |
| 259 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { | 260 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { |
| 260 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | 261 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), |
| 261 | "flat_map keys and mapped containers have different size"); | 262 | "flat_map keys and mapped containers have different size"); |
| ... | @@ -263,21 +264,22 @@ public: | ... | @@ -263,21 +264,22 @@ public: |
| 263 | __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates"); | 264 | __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates"); |
| 264 | } | 265 | } |
| 265 | 266 | ||
| 266 | _LIBCPP_HIDE_FROM_ABI explicit flat_map(const key_compare& __comp) : __containers_(), __compare_(__comp) {} | 267 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_map(const key_compare& __comp) |
| 268 | : __containers_(), __compare_(__comp) {} | ||
| 267 | 269 | ||
| 268 | template <class _Allocator> | 270 | template <class _Allocator> |
| 269 | requires __allocator_ctor_constraint<_Allocator> | 271 | requires __allocator_ctor_constraint<_Allocator> |
| 270 | _LIBCPP_HIDE_FROM_ABI flat_map(const key_compare& __comp, const _Allocator& __alloc) | 272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(const key_compare& __comp, const _Allocator& __alloc) |
| 271 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {} | 273 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {} |
| 272 | 274 | ||
| 273 | template <class _Allocator> | 275 | template <class _Allocator> |
| 274 | requires __allocator_ctor_constraint<_Allocator> | 276 | requires __allocator_ctor_constraint<_Allocator> |
| 275 | _LIBCPP_HIDE_FROM_ABI explicit flat_map(const _Allocator& __alloc) | 277 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_map(const _Allocator& __alloc) |
| 276 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {} | 278 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {} |
| 277 | 279 | ||
| 278 | template <class _InputIterator> | 280 | template <class _InputIterator> |
| 279 | requires __has_input_iterator_category<_InputIterator>::value | 281 | requires __has_input_iterator_category<_InputIterator>::value |
| 280 | _LIBCPP_HIDE_FROM_ABI | 282 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 281 | flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | 283 | flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) |
| 282 | : __containers_(), __compare_(__comp) { | 284 | : __containers_(), __compare_(__comp) { |
| 283 | insert(__first, __last); | 285 | insert(__first, __last); |
| ... | @@ -285,7 +287,7 @@ public: | ... | @@ -285,7 +287,7 @@ public: |
| 285 | 287 | ||
| 286 | template <class _InputIterator, class _Allocator> | 288 | template <class _InputIterator, class _Allocator> |
| 287 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | 289 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) |
| 288 | _LIBCPP_HIDE_FROM_ABI | 290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 289 | flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) | 291 | flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) |
| 290 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | 292 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { |
| 291 | insert(__first, __last); | 293 | insert(__first, __last); |
| ... | @@ -293,99 +295,105 @@ public: | ... | @@ -293,99 +295,105 @@ public: |
| 293 | 295 | ||
| 294 | template <class _InputIterator, class _Allocator> | 296 | template <class _InputIterator, class _Allocator> |
| 295 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | 297 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) |
| 296 | _LIBCPP_HIDE_FROM_ABI flat_map(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | 298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 299 | flat_map(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | ||
| 297 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { | 300 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { |
| 298 | insert(__first, __last); | 301 | insert(__first, __last); |
| 299 | } | 302 | } |
| 300 | 303 | ||
| 301 | template <_ContainerCompatibleRange<value_type> _Range> | 304 | template <_ContainerCompatibleRange<value_type> _Range> |
| 302 | _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t __fr, _Range&& __rg) | 305 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(from_range_t __fr, _Range&& __rg) |
| 303 | : flat_map(__fr, std::forward<_Range>(__rg), key_compare()) {} | 306 | : flat_map(__fr, std::forward<_Range>(__rg), key_compare()) {} |
| 304 | 307 | ||
| 305 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | 308 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> |
| 306 | requires __allocator_ctor_constraint<_Allocator> | 309 | requires __allocator_ctor_constraint<_Allocator> |
| 307 | _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const _Allocator& __alloc) | 310 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(from_range_t, _Range&& __rg, const _Allocator& __alloc) |
| 308 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { | 311 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { |
| 309 | insert_range(std::forward<_Range>(__rg)); | 312 | insert_range(std::forward<_Range>(__rg)); |
| 310 | } | 313 | } |
| 311 | 314 | ||
| 312 | template <_ContainerCompatibleRange<value_type> _Range> | 315 | template <_ContainerCompatibleRange<value_type> _Range> |
| 313 | _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_map(__comp) { | 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(from_range_t, _Range&& __rg, const key_compare& __comp) |
| 317 | : flat_map(__comp) { | ||
| 314 | insert_range(std::forward<_Range>(__rg)); | 318 | insert_range(std::forward<_Range>(__rg)); |
| 315 | } | 319 | } |
| 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_map(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | 323 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 324 | flat_map(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | ||
| 320 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | 325 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { |
| 321 | insert_range(std::forward<_Range>(__rg)); | 326 | insert_range(std::forward<_Range>(__rg)); |
| 322 | } | 327 | } |
| 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 | 331 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 327 | flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | 332 | flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) |
| 328 | : __containers_(), __compare_(__comp) { | 333 | : __containers_(), __compare_(__comp) { |
| 329 | insert(sorted_unique, __first, __last); | 334 | insert(sorted_unique, __first, __last); |
| 330 | } | 335 | } |
| 331 | template <class _InputIterator, class _Allocator> | 336 | template <class _InputIterator, class _Allocator> |
| 332 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | 337 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) |
| 333 | _LIBCPP_HIDE_FROM_ABI | 338 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map( |
| 334 | flat_map(sorted_unique_t, | 339 | sorted_unique_t, |
| 335 | _InputIterator __first, | 340 | _InputIterator __first, |
| 336 | _InputIterator __last, | 341 | _InputIterator __last, |
| 337 | const key_compare& __comp, | 342 | const key_compare& __comp, |
| 338 | const _Allocator& __alloc) | 343 | const _Allocator& __alloc) |
| 339 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | 344 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { |
| 340 | insert(sorted_unique, __first, __last); | 345 | insert(sorted_unique, __first, __last); |
| 341 | } | 346 | } |
| 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_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | 351 | flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) |
| 347 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { | 352 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { |
| 348 | insert(sorted_unique, __first, __last); | 353 | insert(sorted_unique, __first, __last); |
| 349 | } | 354 | } |
| 350 | 355 | ||
| 351 | _LIBCPP_HIDE_FROM_ABI flat_map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 357 | flat_map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | ||
| 352 | : flat_map(__il.begin(), __il.end(), __comp) {} | 358 | : flat_map(__il.begin(), __il.end(), __comp) {} |
| 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_map(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | 363 | flat_map(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) |
| 358 | : flat_map(__il.begin(), __il.end(), __comp, __alloc) {} | 364 | : flat_map(__il.begin(), __il.end(), __comp, __alloc) {} |
| 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_map(initializer_list<value_type> __il, const _Allocator& __alloc) | 368 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 369 | flat_map(initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 363 | : flat_map(__il.begin(), __il.end(), __alloc) {} | 370 | : flat_map(__il.begin(), __il.end(), __alloc) {} |
| 364 | 371 | ||
| 365 | _LIBCPP_HIDE_FROM_ABI | 372 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 366 | flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 373 | flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 367 | : flat_map(sorted_unique, __il.begin(), __il.end(), __comp) {} | 374 | : flat_map(sorted_unique, __il.begin(), __il.end(), __comp) {} |
| 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 | 378 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 372 | flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | 379 | flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) |
| 373 | : flat_map(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {} | 380 | : flat_map(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {} |
| 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_map(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc) | 384 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 385 | flat_map(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 378 | : flat_map(sorted_unique, __il.begin(), __il.end(), __alloc) {} | 386 | : flat_map(sorted_unique, __il.begin(), __il.end(), __alloc) {} |
| 379 | 387 | ||
| 380 | _LIBCPP_HIDE_FROM_ABI flat_map& operator=(initializer_list<value_type> __il) { | 388 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map& operator=(initializer_list<value_type> __il) { |
| 381 | clear(); | 389 | clear(); |
| 382 | insert(__il); | 390 | insert(__il); |
| 383 | return *this; | 391 | return *this; |
| 384 | } | 392 | } |
| 385 | 393 | ||
| 386 | _LIBCPP_HIDE_FROM_ABI flat_map& operator=(const flat_map&) = default; | 394 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map& operator=(const flat_map&) = default; |
| 387 | 395 | ||
| 388 | _LIBCPP_HIDE_FROM_ABI flat_map& operator=(flat_map&& __other) noexcept( | 396 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map& operator=(flat_map&& __other) noexcept( |
| 389 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> && | 397 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> && |
| 390 | is_nothrow_move_assignable_v<_Compare>) { | 398 | is_nothrow_move_assignable_v<_Compare>) { |
| 391 | // No matter what happens, we always want to clear the other container before returning | 399 | // No matter what happens, we always want to clear the other container before returning |
| ... | @@ -402,49 +410,65 @@ public: | ... | @@ -402,49 +410,65 @@ public: |
| 402 | } | 410 | } |
| 403 | 411 | ||
| 404 | // iterators | 412 | // iterators |
| 405 | _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { | 413 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { |
| 406 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); | 414 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); |
| 407 | } | 415 | } |
| 408 | 416 | ||
| 409 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { | 417 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { |
| 410 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); | 418 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); |
| 411 | } | 419 | } |
| 412 | 420 | ||
| 413 | _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { | 421 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { |
| 414 | return iterator(__containers_.keys.end(), __containers_.values.end()); | 422 | return iterator(__containers_.keys.end(), __containers_.values.end()); |
| 415 | } | 423 | } |
| 416 | 424 | ||
| 417 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { | 425 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { |
| 418 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); | 426 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); |
| 419 | } | 427 | } |
| 420 | 428 | ||
| 421 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } | 429 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { |
| 422 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } | 430 | return reverse_iterator(end()); |
| 423 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); } | 431 | } |
| 424 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } | 432 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { |
| 433 | return const_reverse_iterator(end()); | ||
| 434 | } | ||
| 435 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { | ||
| 436 | return reverse_iterator(begin()); | ||
| 437 | } | ||
| 438 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { | ||
| 439 | return const_reverse_iterator(begin()); | ||
| 440 | } | ||
| 425 | 441 | ||
| 426 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); } | 442 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { return begin(); } |
| 427 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); } | 443 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { return end(); } |
| 428 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } | 444 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { |
| 429 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } | 445 | return const_reverse_iterator(end()); |
| 446 | } | ||
| 447 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { | ||
| 448 | return const_reverse_iterator(begin()); | ||
| 449 | } | ||
| 430 | 450 | ||
| 431 | // [flat.map.capacity], capacity | 451 | // [flat.map.capacity], capacity |
| 432 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __containers_.keys.empty(); } | 452 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const noexcept { |
| 453 | return __containers_.keys.empty(); | ||
| 454 | } | ||
| 433 | 455 | ||
| 434 | _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __containers_.keys.size(); } | 456 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { |
| 457 | return __containers_.keys.size(); | ||
| 458 | } | ||
| 435 | 459 | ||
| 436 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { | 460 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { |
| 437 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); | 461 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); |
| 438 | } | 462 | } |
| 439 | 463 | ||
| 440 | // [flat.map.access], element access | 464 | // [flat.map.access], element access |
| 441 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __x) | 465 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](const key_type& __x) |
| 442 | requires is_constructible_v<mapped_type> | 466 | requires is_constructible_v<mapped_type> |
| 443 | { | 467 | { |
| 444 | return try_emplace(__x).first->second; | 468 | return try_emplace(__x).first->second; |
| 445 | } | 469 | } |
| 446 | 470 | ||
| 447 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __x) | 471 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](key_type&& __x) |
| 448 | requires is_constructible_v<mapped_type> | 472 | requires is_constructible_v<mapped_type> |
| 449 | { | 473 | { |
| 450 | return try_emplace(std::move(__x)).first->second; | 474 | return try_emplace(std::move(__x)).first->second; |
| ... | @@ -453,11 +477,11 @@ public: | ... | @@ -453,11 +477,11 @@ public: |
| 453 | template <class _Kp> | 477 | template <class _Kp> |
| 454 | requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type> && | 478 | requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type> && |
| 455 | !is_convertible_v<_Kp &&, const_iterator> && !is_convertible_v<_Kp &&, iterator>) | 479 | !is_convertible_v<_Kp &&, const_iterator> && !is_convertible_v<_Kp &&, iterator>) |
| 456 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](_Kp&& __x) { | 480 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](_Kp&& __x) { |
| 457 | return try_emplace(std::forward<_Kp>(__x)).first->second; | 481 | return try_emplace(std::forward<_Kp>(__x)).first->second; |
| 458 | } | 482 | } |
| 459 | 483 | ||
| 460 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __x) { | 484 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const key_type& __x) { |
| 461 | auto __it = find(__x); | 485 | auto __it = find(__x); |
| 462 | if (__it == end()) { | 486 | if (__it == end()) { |
| 463 | std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist"); | 487 | std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist"); |
| ... | @@ -465,7 +489,7 @@ public: | ... | @@ -465,7 +489,7 @@ public: |
| 465 | return __it->second; | 489 | return __it->second; |
| 466 | } | 490 | } |
| 467 | 491 | ||
| 468 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __x) const { | 492 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const key_type& __x) const { |
| 469 | auto __it = find(__x); | 493 | auto __it = find(__x); |
| 470 | if (__it == end()) { | 494 | if (__it == end()) { |
| 471 | std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist"); | 495 | std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist"); |
| ... | @@ -475,7 +499,7 @@ public: | ... | @@ -475,7 +499,7 @@ public: |
| 475 | 499 | ||
| 476 | template <class _Kp> | 500 | template <class _Kp> |
| 477 | requires __is_compare_transparent | 501 | requires __is_compare_transparent |
| 478 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const _Kp& __x) { | 502 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const _Kp& __x) { |
| 479 | auto __it = find(__x); | 503 | auto __it = find(__x); |
| 480 | if (__it == end()) { | 504 | if (__it == end()) { |
| 481 | std::__throw_out_of_range("flat_map::at(const K&): Key does not exist"); | 505 | std::__throw_out_of_range("flat_map::at(const K&): Key does not exist"); |
| ... | @@ -485,7 +509,7 @@ public: | ... | @@ -485,7 +509,7 @@ public: |
| 485 | 509 | ||
| 486 | template <class _Kp> | 510 | template <class _Kp> |
| 487 | requires __is_compare_transparent | 511 | requires __is_compare_transparent |
| 488 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const _Kp& __x) const { | 512 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const _Kp& __x) const { |
| 489 | auto __it = find(__x); | 513 | auto __it = find(__x); |
| 490 | if (__it == end()) { | 514 | if (__it == end()) { |
| 491 | std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist"); | 515 | std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist"); |
| ... | @@ -496,45 +520,49 @@ public: | ... | @@ -496,45 +520,49 @@ public: |
| 496 | // [flat.map.modifiers], modifiers | 520 | // [flat.map.modifiers], modifiers |
| 497 | template <class... _Args> | 521 | template <class... _Args> |
| 498 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> | 522 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> |
| 499 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) { | 523 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) { |
| 500 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | 524 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); |
| 501 | return __try_emplace(std::move(__pair.first), std::move(__pair.second)); | 525 | return __try_emplace(std::move(__pair.first), std::move(__pair.second)); |
| 502 | } | 526 | } |
| 503 | 527 | ||
| 504 | template <class... _Args> | 528 | template <class... _Args> |
| 505 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> | 529 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> |
| 506 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) { | 530 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __hint, _Args&&... __args) { |
| 507 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | 531 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); |
| 508 | return __try_emplace_hint(__hint, std::move(__pair.first), std::move(__pair.second)).first; | 532 | return __try_emplace_hint(__hint, std::move(__pair.first), std::move(__pair.second)).first; |
| 509 | } | 533 | } |
| 510 | 534 | ||
| 511 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return emplace(__x); } | 535 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __x) { |
| 536 | return emplace(__x); | ||
| 537 | } | ||
| 512 | 538 | ||
| 513 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { return emplace(std::move(__x)); } | 539 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __x) { |
| 540 | return emplace(std::move(__x)); | ||
| 541 | } | ||
| 514 | 542 | ||
| 515 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) { | 543 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, const value_type& __x) { |
| 516 | return emplace_hint(__hint, __x); | 544 | return emplace_hint(__hint, __x); |
| 517 | } | 545 | } |
| 518 | 546 | ||
| 519 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) { | 547 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, value_type&& __x) { |
| 520 | return emplace_hint(__hint, std::move(__x)); | 548 | return emplace_hint(__hint, std::move(__x)); |
| 521 | } | 549 | } |
| 522 | 550 | ||
| 523 | template <class _PairLike> | 551 | template <class _PairLike> |
| 524 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | 552 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> |
| 525 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_PairLike&& __x) { | 553 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(_PairLike&& __x) { |
| 526 | return emplace(std::forward<_PairLike>(__x)); | 554 | return emplace(std::forward<_PairLike>(__x)); |
| 527 | } | 555 | } |
| 528 | 556 | ||
| 529 | template <class _PairLike> | 557 | template <class _PairLike> |
| 530 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | 558 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> |
| 531 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _PairLike&& __x) { | 559 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, _PairLike&& __x) { |
| 532 | return emplace_hint(__hint, std::forward<_PairLike>(__x)); | 560 | return emplace_hint(__hint, std::forward<_PairLike>(__x)); |
| 533 | } | 561 | } |
| 534 | 562 | ||
| 535 | template <class _InputIterator> | 563 | template <class _InputIterator> |
| 536 | requires __has_input_iterator_category<_InputIterator>::value | 564 | requires __has_input_iterator_category<_InputIterator>::value |
| 537 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { | 565 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) { |
| 538 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | 566 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { |
| 539 | __reserve(__last - __first); | 567 | __reserve(__last - __first); |
| 540 | } | 568 | } |
| ... | @@ -543,7 +571,8 @@ public: | ... | @@ -543,7 +571,8 @@ public: |
| 543 | 571 | ||
| 544 | template <class _InputIterator> | 572 | template <class _InputIterator> |
| 545 | requires __has_input_iterator_category<_InputIterator>::value | 573 | requires __has_input_iterator_category<_InputIterator>::value |
| 546 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) { | 574 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 575 | insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) { | ||
| 547 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | 576 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { |
| 548 | __reserve(__last - __first); | 577 | __reserve(__last - __first); |
| 549 | } | 578 | } |
| ... | @@ -552,7 +581,7 @@ public: | ... | @@ -552,7 +581,7 @@ public: |
| 552 | } | 581 | } |
| 553 | 582 | ||
| 554 | template <_ContainerCompatibleRange<value_type> _Range> | 583 | template <_ContainerCompatibleRange<value_type> _Range> |
| 555 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 584 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) { |
| 556 | if constexpr (ranges::sized_range<_Range>) { | 585 | if constexpr (ranges::sized_range<_Range>) { |
| 557 | __reserve(ranges::size(__range)); | 586 | __reserve(ranges::size(__range)); |
| 558 | } | 587 | } |
| ... | @@ -560,19 +589,22 @@ public: | ... | @@ -560,19 +589,22 @@ public: |
| 560 | __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); | 589 | __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); |
| 561 | } | 590 | } |
| 562 | 591 | ||
| 563 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 592 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { |
| 593 | insert(__il.begin(), __il.end()); | ||
| 594 | } | ||
| 564 | 595 | ||
| 565 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, initializer_list<value_type> __il) { | 596 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(sorted_unique_t, initializer_list<value_type> __il) { |
| 566 | insert(sorted_unique, __il.begin(), __il.end()); | 597 | insert(sorted_unique, __il.begin(), __il.end()); |
| 567 | } | 598 | } |
| 568 | 599 | ||
| 569 | _LIBCPP_HIDE_FROM_ABI containers extract() && { | 600 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 containers extract() && { |
| 570 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | 601 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); |
| 571 | auto __ret = std::move(__containers_); | 602 | auto __ret = std::move(__containers_); |
| 572 | return __ret; | 603 | return __ret; |
| 573 | } | 604 | } |
| 574 | 605 | ||
| 575 | _LIBCPP_HIDE_FROM_ABI void replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) { | 606 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 607 | replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) { | ||
| 576 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | 608 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( |
| 577 | __key_cont.size() == __mapped_cont.size(), "flat_map keys and mapped containers have different size"); | 609 | __key_cont.size() == __mapped_cont.size(), "flat_map keys and mapped containers have different size"); |
| 578 | 610 | ||
| ... | @@ -586,13 +618,15 @@ public: | ... | @@ -586,13 +618,15 @@ public: |
| 586 | 618 | ||
| 587 | template <class... _Args> | 619 | template <class... _Args> |
| 588 | requires is_constructible_v<mapped_type, _Args...> | 620 | requires is_constructible_v<mapped_type, _Args...> |
| 589 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __key, _Args&&... __args) { | 621 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 622 | try_emplace(const key_type& __key, _Args&&... __args) { | ||
| 590 | return __try_emplace(__key, std::forward<_Args>(__args)...); | 623 | return __try_emplace(__key, std::forward<_Args>(__args)...); |
| 591 | } | 624 | } |
| 592 | 625 | ||
| 593 | template <class... _Args> | 626 | template <class... _Args> |
| 594 | requires is_constructible_v<mapped_type, _Args...> | 627 | requires is_constructible_v<mapped_type, _Args...> |
| 595 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __key, _Args&&... __args) { | 628 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 629 | try_emplace(key_type&& __key, _Args&&... __args) { | ||
| 596 | return __try_emplace(std::move(__key), std::forward<_Args>(__args)...); | 630 | return __try_emplace(std::move(__key), std::forward<_Args>(__args)...); |
| 597 | } | 631 | } |
| 598 | 632 | ||
| ... | @@ -600,75 +634,84 @@ public: | ... | @@ -600,75 +634,84 @@ public: |
| 600 | requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && | 634 | requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && |
| 601 | is_constructible_v<mapped_type, _Args...> && !is_convertible_v<_Kp &&, const_iterator> && | 635 | is_constructible_v<mapped_type, _Args...> && !is_convertible_v<_Kp &&, const_iterator> && |
| 602 | !is_convertible_v<_Kp &&, iterator>) | 636 | !is_convertible_v<_Kp &&, iterator>) |
| 603 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(_Kp&& __key, _Args&&... __args) { | 637 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> try_emplace(_Kp&& __key, _Args&&... __args) { |
| 604 | return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...); | 638 | return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...); |
| 605 | } | 639 | } |
| 606 | 640 | ||
| 607 | template <class... _Args> | 641 | template <class... _Args> |
| 608 | requires is_constructible_v<mapped_type, _Args...> | 642 | requires is_constructible_v<mapped_type, _Args...> |
| 609 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, const key_type& __key, _Args&&... __args) { | 643 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 644 | try_emplace(const_iterator __hint, const key_type& __key, _Args&&... __args) { | ||
| 610 | return __try_emplace_hint(__hint, __key, std::forward<_Args>(__args)...).first; | 645 | return __try_emplace_hint(__hint, __key, std::forward<_Args>(__args)...).first; |
| 611 | } | 646 | } |
| 612 | 647 | ||
| 613 | template <class... _Args> | 648 | template <class... _Args> |
| 614 | requires is_constructible_v<mapped_type, _Args...> | 649 | requires is_constructible_v<mapped_type, _Args...> |
| 615 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, key_type&& __key, _Args&&... __args) { | 650 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 651 | try_emplace(const_iterator __hint, key_type&& __key, _Args&&... __args) { | ||
| 616 | return __try_emplace_hint(__hint, std::move(__key), std::forward<_Args>(__args)...).first; | 652 | return __try_emplace_hint(__hint, std::move(__key), std::forward<_Args>(__args)...).first; |
| 617 | } | 653 | } |
| 618 | 654 | ||
| 619 | template <class _Kp, class... _Args> | 655 | template <class _Kp, class... _Args> |
| 620 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type, _Args...> | 656 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type, _Args...> |
| 621 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, _Kp&& __key, _Args&&... __args) { | 657 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 658 | try_emplace(const_iterator __hint, _Kp&& __key, _Args&&... __args) { | ||
| 622 | return __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Args>(__args)...).first; | 659 | return __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Args>(__args)...).first; |
| 623 | } | 660 | } |
| 624 | 661 | ||
| 625 | template <class _Mapped> | 662 | template <class _Mapped> |
| 626 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | 663 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> |
| 627 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __key, _Mapped&& __obj) { | 664 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 665 | insert_or_assign(const key_type& __key, _Mapped&& __obj) { | ||
| 628 | return __insert_or_assign(__key, std::forward<_Mapped>(__obj)); | 666 | return __insert_or_assign(__key, std::forward<_Mapped>(__obj)); |
| 629 | } | 667 | } |
| 630 | 668 | ||
| 631 | template <class _Mapped> | 669 | template <class _Mapped> |
| 632 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | 670 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> |
| 633 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __key, _Mapped&& __obj) { | 671 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 672 | insert_or_assign(key_type&& __key, _Mapped&& __obj) { | ||
| 634 | return __insert_or_assign(std::move(__key), std::forward<_Mapped>(__obj)); | 673 | return __insert_or_assign(std::move(__key), std::forward<_Mapped>(__obj)); |
| 635 | } | 674 | } |
| 636 | 675 | ||
| 637 | template <class _Kp, class _Mapped> | 676 | template <class _Kp, class _Mapped> |
| 638 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> && | 677 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> && |
| 639 | is_constructible_v<mapped_type, _Mapped> | 678 | is_constructible_v<mapped_type, _Mapped> |
| 640 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(_Kp&& __key, _Mapped&& __obj) { | 679 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 680 | insert_or_assign(_Kp&& __key, _Mapped&& __obj) { | ||
| 641 | return __insert_or_assign(std::forward<_Kp>(__key), std::forward<_Mapped>(__obj)); | 681 | return __insert_or_assign(std::forward<_Kp>(__key), std::forward<_Mapped>(__obj)); |
| 642 | } | 682 | } |
| 643 | 683 | ||
| 644 | template <class _Mapped> | 684 | template <class _Mapped> |
| 645 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | 685 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> |
| 646 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, const key_type& __key, _Mapped&& __obj) { | 686 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 687 | insert_or_assign(const_iterator __hint, const key_type& __key, _Mapped&& __obj) { | ||
| 647 | return __insert_or_assign(__hint, __key, std::forward<_Mapped>(__obj)); | 688 | return __insert_or_assign(__hint, __key, std::forward<_Mapped>(__obj)); |
| 648 | } | 689 | } |
| 649 | 690 | ||
| 650 | template <class _Mapped> | 691 | template <class _Mapped> |
| 651 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | 692 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> |
| 652 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, key_type&& __key, _Mapped&& __obj) { | 693 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 694 | insert_or_assign(const_iterator __hint, key_type&& __key, _Mapped&& __obj) { | ||
| 653 | return __insert_or_assign(__hint, std::move(__key), std::forward<_Mapped>(__obj)); | 695 | return __insert_or_assign(__hint, std::move(__key), std::forward<_Mapped>(__obj)); |
| 654 | } | 696 | } |
| 655 | 697 | ||
| 656 | template <class _Kp, class _Mapped> | 698 | template <class _Kp, class _Mapped> |
| 657 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> && | 699 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> && |
| 658 | is_constructible_v<mapped_type, _Mapped> | 700 | is_constructible_v<mapped_type, _Mapped> |
| 659 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __obj) { | 701 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 702 | insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __obj) { | ||
| 660 | return __insert_or_assign(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__obj)); | 703 | return __insert_or_assign(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__obj)); |
| 661 | } | 704 | } |
| 662 | 705 | ||
| 663 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) { | 706 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __position) { |
| 664 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | 707 | return __erase(__position.__key_iter_, __position.__mapped_iter_); |
| 665 | } | 708 | } |
| 666 | 709 | ||
| 667 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) { | 710 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __position) { |
| 668 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | 711 | return __erase(__position.__key_iter_, __position.__mapped_iter_); |
| 669 | } | 712 | } |
| 670 | 713 | ||
| 671 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) { | 714 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __x) { |
| 672 | auto __iter = find(__x); | 715 | auto __iter = find(__x); |
| 673 | if (__iter != end()) { | 716 | if (__iter != end()) { |
| 674 | erase(__iter); | 717 | erase(__iter); |
| ... | @@ -680,14 +723,14 @@ public: | ... | @@ -680,14 +723,14 @@ public: |
| 680 | template <class _Kp> | 723 | template <class _Kp> |
| 681 | requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> && | 724 | requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> && |
| 682 | !is_convertible_v<_Kp &&, const_iterator>) | 725 | !is_convertible_v<_Kp &&, const_iterator>) |
| 683 | _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) { | 726 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(_Kp&& __x) { |
| 684 | auto [__first, __last] = equal_range(__x); | 727 | auto [__first, __last] = equal_range(__x); |
| 685 | auto __res = __last - __first; | 728 | auto __res = __last - __first; |
| 686 | erase(__first, __last); | 729 | erase(__first, __last); |
| 687 | return __res; | 730 | return __res; |
| 688 | } | 731 | } |
| 689 | 732 | ||
| 690 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { | 733 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __first, const_iterator __last) { |
| 691 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 734 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 692 | auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_); | 735 | auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_); |
| 693 | auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_); | 736 | auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_); |
| ... | @@ -695,7 +738,7 @@ public: | ... | @@ -695,7 +738,7 @@ public: |
| 695 | return iterator(std::move(__key_it), std::move(__mapped_it)); | 738 | return iterator(std::move(__key_it), std::move(__mapped_it)); |
| 696 | } | 739 | } |
| 697 | 740 | ||
| 698 | _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __y) noexcept { | 741 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_map& __y) noexcept { |
| 699 | // warning: The spec has unconditional noexcept, which means that | 742 | // warning: The spec has unconditional noexcept, which means that |
| 700 | // if any of the following functions throw an exception, | 743 | // if any of the following functions throw an exception, |
| 701 | // std::terminate will be called. | 744 | // std::terminate will be called. |
| ... | @@ -705,133 +748,156 @@ public: | ... | @@ -705,133 +748,156 @@ public: |
| 705 | ranges::swap(__containers_.values, __y.__containers_.values); | 748 | ranges::swap(__containers_.values, __y.__containers_.values); |
| 706 | } | 749 | } |
| 707 | 750 | ||
| 708 | _LIBCPP_HIDE_FROM_ABI void clear() noexcept { | 751 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { |
| 709 | __containers_.keys.clear(); | 752 | __containers_.keys.clear(); |
| 710 | __containers_.values.clear(); | 753 | __containers_.values.clear(); |
| 711 | } | 754 | } |
| 712 | 755 | ||
| 713 | // observers | 756 | // observers |
| 714 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; } | 757 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } |
| 715 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); } | 758 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { |
| 759 | return value_compare(__compare_); | ||
| 760 | } | ||
| 716 | 761 | ||
| 717 | _LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; } | 762 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const key_container_type& keys() const noexcept { |
| 718 | _LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; } | 763 | return __containers_.keys; |
| 764 | } | ||
| 765 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_container_type& values() const noexcept { | ||
| 766 | return __containers_.values; | ||
| 767 | } | ||
| 719 | 768 | ||
| 720 | // map operations | 769 | // map operations |
| 721 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); } | 770 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { |
| 771 | return __find_impl(*this, __x); | ||
| 772 | } | ||
| 722 | 773 | ||
| 723 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); } | 774 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { |
| 775 | return __find_impl(*this, __x); | ||
| 776 | } | ||
| 724 | 777 | ||
| 725 | template <class _Kp> | 778 | template <class _Kp> |
| 726 | requires __is_compare_transparent | 779 | requires __is_compare_transparent |
| 727 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) { | 780 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { |
| 728 | return __find_impl(*this, __x); | 781 | return __find_impl(*this, __x); |
| 729 | } | 782 | } |
| 730 | 783 | ||
| 731 | template <class _Kp> | 784 | template <class _Kp> |
| 732 | requires __is_compare_transparent | 785 | requires __is_compare_transparent |
| 733 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const { | 786 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { |
| 734 | return __find_impl(*this, __x); | 787 | return __find_impl(*this, __x); |
| 735 | } | 788 | } |
| 736 | 789 | ||
| 737 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { return contains(__x) ? 1 : 0; } | 790 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { |
| 791 | return contains(__x) ? 1 : 0; | ||
| 792 | } | ||
| 738 | 793 | ||
| 739 | template <class _Kp> | 794 | template <class _Kp> |
| 740 | requires __is_compare_transparent | 795 | requires __is_compare_transparent |
| 741 | _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const { | 796 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { |
| 742 | return contains(__x) ? 1 : 0; | 797 | return contains(__x) ? 1 : 0; |
| 743 | } | 798 | } |
| 744 | 799 | ||
| 745 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); } | 800 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { |
| 801 | return find(__x) != end(); | ||
| 802 | } | ||
| 746 | 803 | ||
| 747 | template <class _Kp> | 804 | template <class _Kp> |
| 748 | requires __is_compare_transparent | 805 | requires __is_compare_transparent |
| 749 | _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const { | 806 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { |
| 750 | return find(__x) != end(); | 807 | return find(__x) != end(); |
| 751 | } | 808 | } |
| 752 | 809 | ||
| 753 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { return __lower_bound<iterator>(*this, __x); } | 810 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { |
| 811 | return __lower_bound<iterator>(*this, __x); | ||
| 812 | } | ||
| 754 | 813 | ||
| 755 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const { | 814 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __x) const { |
| 756 | return __lower_bound<const_iterator>(*this, __x); | 815 | return __lower_bound<const_iterator>(*this, __x); |
| 757 | } | 816 | } |
| 758 | 817 | ||
| 759 | template <class _Kp> | 818 | template <class _Kp> |
| 760 | requires __is_compare_transparent | 819 | requires __is_compare_transparent |
| 761 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) { | 820 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { |
| 762 | return __lower_bound<iterator>(*this, __x); | 821 | return __lower_bound<iterator>(*this, __x); |
| 763 | } | 822 | } |
| 764 | 823 | ||
| 765 | template <class _Kp> | 824 | template <class _Kp> |
| 766 | requires __is_compare_transparent | 825 | requires __is_compare_transparent |
| 767 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const { | 826 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { |
| 768 | return __lower_bound<const_iterator>(*this, __x); | 827 | return __lower_bound<const_iterator>(*this, __x); |
| 769 | } | 828 | } |
| 770 | 829 | ||
| 771 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { return __upper_bound<iterator>(*this, __x); } | 830 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { |
| 831 | return __upper_bound<iterator>(*this, __x); | ||
| 832 | } | ||
| 772 | 833 | ||
| 773 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const { | 834 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __x) const { |
| 774 | return __upper_bound<const_iterator>(*this, __x); | 835 | return __upper_bound<const_iterator>(*this, __x); |
| 775 | } | 836 | } |
| 776 | 837 | ||
| 777 | template <class _Kp> | 838 | template <class _Kp> |
| 778 | requires __is_compare_transparent | 839 | requires __is_compare_transparent |
| 779 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) { | 840 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { |
| 780 | return __upper_bound<iterator>(*this, __x); | 841 | return __upper_bound<iterator>(*this, __x); |
| 781 | } | 842 | } |
| 782 | 843 | ||
| 783 | template <class _Kp> | 844 | template <class _Kp> |
| 784 | requires __is_compare_transparent | 845 | requires __is_compare_transparent |
| 785 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const { | 846 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { |
| 786 | return __upper_bound<const_iterator>(*this, __x); | 847 | return __upper_bound<const_iterator>(*this, __x); |
| 787 | } | 848 | } |
| 788 | 849 | ||
| 789 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) { | 850 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __x) { |
| 790 | return __equal_range_impl(*this, __x); | 851 | return __equal_range_impl(*this, __x); |
| 791 | } | 852 | } |
| 792 | 853 | ||
| 793 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { | 854 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 855 | equal_range(const key_type& __x) const { | ||
| 794 | return __equal_range_impl(*this, __x); | 856 | return __equal_range_impl(*this, __x); |
| 795 | } | 857 | } |
| 796 | 858 | ||
| 797 | template <class _Kp> | 859 | template <class _Kp> |
| 798 | requires __is_compare_transparent | 860 | requires __is_compare_transparent |
| 799 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) { | 861 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _Kp& __x) { |
| 800 | return __equal_range_impl(*this, __x); | 862 | return __equal_range_impl(*this, __x); |
| 801 | } | 863 | } |
| 802 | template <class _Kp> | 864 | template <class _Kp> |
| 803 | requires __is_compare_transparent | 865 | requires __is_compare_transparent |
| 804 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const { | 866 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> |
| 867 | equal_range(const _Kp& __x) const { | ||
| 805 | return __equal_range_impl(*this, __x); | 868 | return __equal_range_impl(*this, __x); |
| 806 | } | 869 | } |
| 807 | 870 | ||
| 808 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_map& __x, const flat_map& __y) { | 871 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator==(const flat_map& __x, const flat_map& __y) { |
| 809 | return ranges::equal(__x, __y); | 872 | return ranges::equal(__x, __y); |
| 810 | } | 873 | } |
| 811 | 874 | ||
| 812 | friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_map& __x, const flat_map& __y) { | 875 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto |
| 876 | operator<=>(const flat_map& __x, const flat_map& __y) { | ||
| 813 | return std::lexicographical_compare_three_way( | 877 | return std::lexicographical_compare_three_way( |
| 814 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 878 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 815 | } | 879 | } |
| 816 | 880 | ||
| 817 | friend _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __x, flat_map& __y) noexcept { __x.swap(__y); } | 881 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_map& __x, flat_map& __y) noexcept { |
| 882 | __x.swap(__y); | ||
| 883 | } | ||
| 818 | 884 | ||
| 819 | private: | 885 | private: |
| 820 | struct __ctor_uses_allocator_tag { | 886 | struct __ctor_uses_allocator_tag { |
| 821 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_tag() = default; | 887 | explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __ctor_uses_allocator_tag() = default; |
| 822 | }; | 888 | }; |
| 823 | struct __ctor_uses_allocator_empty_tag { | 889 | struct __ctor_uses_allocator_empty_tag { |
| 824 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_empty_tag() = default; | 890 | explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __ctor_uses_allocator_empty_tag() = default; |
| 825 | }; | 891 | }; |
| 826 | 892 | ||
| 827 | template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg> | 893 | template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg> |
| 828 | requires __allocator_ctor_constraint<_Allocator> | 894 | requires __allocator_ctor_constraint<_Allocator> |
| 829 | _LIBCPP_HIDE_FROM_ABI | 895 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map( |
| 830 | flat_map(__ctor_uses_allocator_tag, | 896 | __ctor_uses_allocator_tag, |
| 831 | const _Allocator& __alloc, | 897 | const _Allocator& __alloc, |
| 832 | _KeyCont&& __key_cont, | 898 | _KeyCont&& __key_cont, |
| 833 | _MappedCont&& __mapped_cont, | 899 | _MappedCont&& __mapped_cont, |
| 834 | _CompArg&&... __comp) | 900 | _CompArg&&... __comp) |
| 835 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>( | 901 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>( |
| 836 | __alloc, std::forward<_KeyCont>(__key_cont)), | 902 | __alloc, std::forward<_KeyCont>(__key_cont)), |
| 837 | .values = std::make_obj_using_allocator<mapped_container_type>( | 903 | .values = std::make_obj_using_allocator<mapped_container_type>( |
| ... | @@ -840,12 +906,13 @@ private: | ... | @@ -840,12 +906,13 @@ private: |
| 840 | 906 | ||
| 841 | template <class _Allocator, class... _CompArg> | 907 | template <class _Allocator, class... _CompArg> |
| 842 | requires __allocator_ctor_constraint<_Allocator> | 908 | requires __allocator_ctor_constraint<_Allocator> |
| 843 | _LIBCPP_HIDE_FROM_ABI flat_map(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp) | 909 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 910 | flat_map(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp) | ||
| 844 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc), | 911 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc), |
| 845 | .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)}, | 912 | .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)}, |
| 846 | __compare_(std::forward<_CompArg>(__comp)...) {} | 913 | __compare_(std::forward<_CompArg>(__comp)...) {} |
| 847 | 914 | ||
| 848 | _LIBCPP_HIDE_FROM_ABI bool __is_sorted_and_unique(auto&& __key_container) const { | 915 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const { |
| 849 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); }; | 916 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); }; |
| 850 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); | 917 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); |
| 851 | } | 918 | } |
| ... | @@ -853,7 +920,7 @@ private: | ... | @@ -853,7 +920,7 @@ private: |
| 853 | // This function is only used in constructors. So there is not exception handling in this function. | 920 | // This function is only used in constructors. So there is not exception handling in this function. |
| 854 | // If the function exits via an exception, there will be no flat_map object constructed, thus, there | 921 | // If the function exits via an exception, there will be no flat_map object constructed, thus, there |
| 855 | // is no invariant state to preserve | 922 | // is no invariant state to preserve |
| 856 | _LIBCPP_HIDE_FROM_ABI void __sort_and_unique() { | 923 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __sort_and_unique() { |
| 857 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | 924 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); |
| 858 | ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); }); | 925 | ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); }); |
| 859 | auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin(); | 926 | auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin(); |
| ... | @@ -862,8 +929,17 @@ private: | ... | @@ -862,8 +929,17 @@ private: |
| 862 | __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end()); | 929 | __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end()); |
| 863 | } | 930 | } |
| 864 | 931 | ||
| 932 | template <class _Self, class _KeyIter> | ||
| 933 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto | ||
| 934 | __corresponding_mapped_it(_Self&& __self, _KeyIter&& __key_iter) { | ||
| 935 | return __self.__containers_.values.begin() + | ||
| 936 | static_cast<ranges::range_difference_t<mapped_container_type>>( | ||
| 937 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); | ||
| 938 | } | ||
| 939 | |||
| 865 | template <bool _WasSorted, class _InputIterator, class _Sentinel> | 940 | template <bool _WasSorted, class _InputIterator, class _Sentinel> |
| 866 | _LIBCPP_HIDE_FROM_ABI void __append_sort_merge_unique(_InputIterator __first, _Sentinel __last) { | 941 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 942 | __append_sort_merge_unique(_InputIterator __first, _Sentinel __last) { | ||
| 867 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 943 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 868 | size_t __num_of_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last)); | 944 | size_t __num_of_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last)); |
| 869 | if (__num_of_appended != 0) { | 945 | if (__num_of_appended != 0) { |
| ... | @@ -891,7 +967,7 @@ private: | ... | @@ -891,7 +967,7 @@ private: |
| 891 | } | 967 | } |
| 892 | 968 | ||
| 893 | template <class _Self, class _Kp> | 969 | template <class _Self, class _Kp> |
| 894 | _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) { | 970 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __find_impl(_Self&& __self, const _Kp& __key) { |
| 895 | auto __it = __self.lower_bound(__key); | 971 | auto __it = __self.lower_bound(__key); |
| 896 | auto __last = __self.end(); | 972 | auto __last = __self.end(); |
| 897 | if (__it == __last || __self.__compare_(__key, __it->first)) { | 973 | if (__it == __last || __self.__compare_(__key, __it->first)) { |
| ... | @@ -901,8 +977,9 @@ private: | ... | @@ -901,8 +977,9 @@ private: |
| 901 | } | 977 | } |
| 902 | 978 | ||
| 903 | template <class _Self, class _Kp> | 979 | template <class _Self, class _Kp> |
| 904 | _LIBCPP_HIDE_FROM_ABI static auto __key_equal_range(_Self&& __self, const _Kp& __key) { | 980 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __key_equal_range(_Self&& __self, const _Kp& __key) { |
| 905 | auto __it = ranges::lower_bound(__self.__containers_.keys, __key, __self.__compare_); | 981 | auto __it = |
| 982 | std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __key, __self.__compare_); | ||
| 906 | auto __last = __self.__containers_.keys.end(); | 983 | auto __last = __self.__containers_.keys.end(); |
| 907 | if (__it == __last || __self.__compare_(__key, *__it)) { | 984 | if (__it == __last || __self.__compare_(__key, *__it)) { |
| 908 | return std::make_pair(__it, __it); | 985 | return std::make_pair(__it, __it); |
| ... | @@ -911,44 +988,33 @@ private: | ... | @@ -911,44 +988,33 @@ private: |
| 911 | } | 988 | } |
| 912 | 989 | ||
| 913 | template <class _Self, class _Kp> | 990 | template <class _Self, class _Kp> |
| 914 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | 991 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { |
| 915 | auto [__key_first, __key_last] = __key_equal_range(__self, __key); | 992 | auto [__key_first, __key_last] = __key_equal_range(__self, __key); |
| 916 | 993 | using __iterator_type = ranges::iterator_t<decltype(__self)>; | |
| 917 | const auto __make_mapped_iter = [&](const auto& __key_iter) { | 994 | return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)), |
| 918 | return __self.__containers_.values.begin() + | 995 | __iterator_type(__key_last, __corresponding_mapped_it(__self, __key_last))); |
| 919 | static_cast<ranges::range_difference_t<mapped_container_type>>( | ||
| 920 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); | ||
| 921 | }; | ||
| 922 | |||
| 923 | using __iterator_type = ranges::iterator_t<decltype(__self)>; | ||
| 924 | return std::make_pair(__iterator_type(__key_first, __make_mapped_iter(__key_first)), | ||
| 925 | __iterator_type(__key_last, __make_mapped_iter(__key_last))); | ||
| 926 | } | 996 | } |
| 927 | 997 | ||
| 928 | template <class _Res, class _Self, class _Kp> | 998 | template <class _Res, class _Self, class _Kp> |
| 929 | _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) { | 999 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static _Res __lower_bound(_Self&& __self, _Kp& __x) { |
| 930 | return __binary_search<_Res>(__self, ranges::lower_bound, __x); | 1000 | auto __key_iter = |
| 1001 | std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); | ||
| 1002 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | ||
| 1003 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | ||
| 931 | } | 1004 | } |
| 932 | 1005 | ||
| 933 | template <class _Res, class _Self, class _Kp> | 1006 | template <class _Res, class _Self, class _Kp> |
| 934 | _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) { | 1007 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static _Res __upper_bound(_Self&& __self, _Kp& __x) { |
| 935 | return __binary_search<_Res>(__self, ranges::upper_bound, __x); | 1008 | auto __key_iter = |
| 936 | } | 1009 | std::upper_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); |
| 937 | 1010 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | |
| 938 | template <class _Res, class _Self, class _Fn, class _Kp> | ||
| 939 | _LIBCPP_HIDE_FROM_ABI static _Res __binary_search(_Self&& __self, _Fn __search_fn, _Kp& __x) { | ||
| 940 | auto __key_iter = __search_fn(__self.__containers_.keys, __x, __self.__compare_); | ||
| 941 | auto __mapped_iter = | ||
| 942 | __self.__containers_.values.begin() + | ||
| 943 | static_cast<ranges::range_difference_t<mapped_container_type>>( | ||
| 944 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); | ||
| 945 | |||
| 946 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | 1011 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); |
| 947 | } | 1012 | } |
| 948 | 1013 | ||
| 949 | template <class _KeyArg, class... _MArgs> | 1014 | template <class _KeyArg, class... _MArgs> |
| 950 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace(_KeyArg&& __key, _MArgs&&... __mapped_args) { | 1015 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 951 | auto __key_it = ranges::lower_bound(__containers_.keys, __key, __compare_); | 1016 | __try_emplace(_KeyArg&& __key, _MArgs&&... __mapped_args) { |
| 1017 | auto __key_it = std::lower_bound(__containers_.keys.begin(), __containers_.keys.end(), __key, __compare_); | ||
| 952 | auto __mapped_it = __containers_.values.begin() + ranges::distance(__containers_.keys.begin(), __key_it); | 1018 | auto __mapped_it = __containers_.values.begin() + ranges::distance(__containers_.keys.begin(), __key_it); |
| 953 | 1019 | ||
| 954 | if (__key_it == __containers_.keys.end() || __compare_(__key, *__key_it)) { | 1020 | if (__key_it == __containers_.keys.end() || __compare_(__key, *__key_it)) { |
| ... | @@ -966,7 +1032,7 @@ private: | ... | @@ -966,7 +1032,7 @@ private: |
| 966 | } | 1032 | } |
| 967 | 1033 | ||
| 968 | template <class _Kp> | 1034 | template <class _Kp> |
| 969 | _LIBCPP_HIDE_FROM_ABI bool __is_hint_correct(const_iterator __hint, _Kp&& __key) { | 1035 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_hint_correct(const_iterator __hint, _Kp&& __key) { |
| 970 | if (__hint != cbegin() && !__compare_((__hint - 1)->first, __key)) { | 1036 | if (__hint != cbegin() && !__compare_((__hint - 1)->first, __key)) { |
| 971 | return false; | 1037 | return false; |
| 972 | } | 1038 | } |
| ... | @@ -977,7 +1043,8 @@ private: | ... | @@ -977,7 +1043,8 @@ private: |
| 977 | } | 1043 | } |
| 978 | 1044 | ||
| 979 | template <class _Kp, class... _Args> | 1045 | template <class _Kp, class... _Args> |
| 980 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace_hint(const_iterator __hint, _Kp&& __key, _Args&&... __args) { | 1046 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 1047 | __try_emplace_hint(const_iterator __hint, _Kp&& __key, _Args&&... __args) { | ||
| 981 | if (__is_hint_correct(__hint, __key)) { | 1048 | if (__is_hint_correct(__hint, __key)) { |
| 982 | if (__hint == cend() || __compare_(__key, __hint->first)) { | 1049 | if (__hint == cend() || __compare_(__key, __hint->first)) { |
| 983 | return {__flat_map_utils::__emplace_exact_pos( | 1050 | return {__flat_map_utils::__emplace_exact_pos( |
| ... | @@ -998,7 +1065,8 @@ private: | ... | @@ -998,7 +1065,8 @@ private: |
| 998 | } | 1065 | } |
| 999 | 1066 | ||
| 1000 | template <class _Kp, class _Mapped> | 1067 | template <class _Kp, class _Mapped> |
| 1001 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_or_assign(_Kp&& __key, _Mapped&& __mapped) { | 1068 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> |
| 1069 | __insert_or_assign(_Kp&& __key, _Mapped&& __mapped) { | ||
| 1002 | auto __r = try_emplace(std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped)); | 1070 | auto __r = try_emplace(std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped)); |
| 1003 | if (!__r.second) { | 1071 | if (!__r.second) { |
| 1004 | __r.first->second = std::forward<_Mapped>(__mapped); | 1072 | __r.first->second = std::forward<_Mapped>(__mapped); |
| ... | @@ -1007,7 +1075,8 @@ private: | ... | @@ -1007,7 +1075,8 @@ private: |
| 1007 | } | 1075 | } |
| 1008 | 1076 | ||
| 1009 | template <class _Kp, class _Mapped> | 1077 | template <class _Kp, class _Mapped> |
| 1010 | _LIBCPP_HIDE_FROM_ABI iterator __insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __mapped) { | 1078 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 1079 | __insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __mapped) { | ||
| 1011 | auto __r = __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped)); | 1080 | auto __r = __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped)); |
| 1012 | if (!__r.second) { | 1081 | if (!__r.second) { |
| 1013 | __r.first->second = std::forward<_Mapped>(__mapped); | 1082 | __r.first->second = std::forward<_Mapped>(__mapped); |
| ... | @@ -1015,18 +1084,19 @@ private: | ... | @@ -1015,18 +1084,19 @@ private: |
| 1015 | return __r.first; | 1084 | return __r.first; |
| 1016 | } | 1085 | } |
| 1017 | 1086 | ||
| 1018 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { | 1087 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __reserve(size_t __size) { |
| 1019 | if constexpr (requires { __containers_.keys.reserve(__size); }) { | 1088 | if constexpr (__container_traits<_KeyContainer>::__reservable) { |
| 1020 | __containers_.keys.reserve(__size); | 1089 | __containers_.keys.reserve(__size); |
| 1021 | } | 1090 | } |
| 1022 | 1091 | ||
| 1023 | if constexpr (requires { __containers_.values.reserve(__size); }) { | 1092 | if constexpr (__container_traits<_MappedContainer>::__reservable) { |
| 1024 | __containers_.values.reserve(__size); | 1093 | __containers_.values.reserve(__size); |
| 1025 | } | 1094 | } |
| 1026 | } | 1095 | } |
| 1027 | 1096 | ||
| 1028 | template <class _KIter, class _MIter> | 1097 | template <class _KIter, class _MIter> |
| 1029 | _LIBCPP_HIDE_FROM_ABI iterator __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) { | 1098 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator |
| 1099 | __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) { | ||
| 1030 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | 1100 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); |
| 1031 | auto __key_iter = __containers_.keys.erase(__key_iter_to_remove); | 1101 | auto __key_iter = __containers_.keys.erase(__key_iter_to_remove); |
| 1032 | auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove); | 1102 | auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove); |
| ... | @@ -1036,7 +1106,8 @@ private: | ... | @@ -1036,7 +1106,8 @@ private: |
| 1036 | 1106 | ||
| 1037 | template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate> | 1107 | template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate> |
| 1038 | friend typename flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type | 1108 | friend typename flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type |
| 1039 | erase_if(flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate); | 1109 | _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 1110 | erase_if(flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate); | ||
| 1040 | 1111 | ||
| 1041 | friend __flat_map_utils; | 1112 | friend __flat_map_utils; |
| 1042 | 1113 | ||
| ... | @@ -1044,8 +1115,9 @@ private: | ... | @@ -1044,8 +1115,9 @@ private: |
| 1044 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; | 1115 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; |
| 1045 | 1116 | ||
| 1046 | struct __key_equiv { | 1117 | struct __key_equiv { |
| 1047 | _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {} | 1118 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {} |
| 1048 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | 1119 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool |
| 1120 | operator()(const_reference __x, const_reference __y) const { | ||
| 1049 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); | 1121 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); |
| 1050 | } | 1122 | } |
| 1051 | key_compare __comp_; | 1123 | key_compare __comp_; |
| ... | @@ -1168,8 +1240,9 @@ struct uses_allocator<flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContai | ... | @@ -1168,8 +1240,9 @@ struct uses_allocator<flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContai |
| 1168 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {}; | 1240 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {}; |
| 1169 | 1241 | ||
| 1170 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate> | 1242 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate> |
| 1171 | _LIBCPP_HIDE_FROM_ABI typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type | 1243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 1172 | erase_if(flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_map, _Predicate __pred) { | 1244 | typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type |
| 1245 | erase_if(flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_map, _Predicate __pred) { | ||
| 1173 | auto __zv = ranges::views::zip(__flat_map.__containers_.keys, __flat_map.__containers_.values); | 1246 | auto __zv = ranges::views::zip(__flat_map.__containers_.keys, __flat_map.__containers_.values); |
| 1174 | auto __first = __zv.begin(); | 1247 | auto __first = __zv.begin(); |
| 1175 | auto __last = __zv.end(); | 1248 | auto __last = __zv.end(); |
lib/libcxx/include/__flat_map/flat_multimap.h+14-13| ... | @@ -10,18 +10,16 @@ | ... | @@ -10,18 +10,16 @@ |
| 10 | #ifndef _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H | 10 | #ifndef _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H |
| 11 | #define _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H | 11 | #define _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/equal_range.h> | ||
| 13 | #include <__algorithm/lexicographical_compare_three_way.h> | 14 | #include <__algorithm/lexicographical_compare_three_way.h> |
| 15 | #include <__algorithm/lower_bound.h> | ||
| 14 | #include <__algorithm/min.h> | 16 | #include <__algorithm/min.h> |
| 15 | #include <__algorithm/ranges_equal.h> | 17 | #include <__algorithm/ranges_equal.h> |
| 16 | #include <__algorithm/ranges_equal_range.h> | ||
| 17 | #include <__algorithm/ranges_inplace_merge.h> | 18 | #include <__algorithm/ranges_inplace_merge.h> |
| 18 | #include <__algorithm/ranges_is_sorted.h> | 19 | #include <__algorithm/ranges_is_sorted.h> |
| 19 | #include <__algorithm/ranges_lower_bound.h> | ||
| 20 | #include <__algorithm/ranges_partition_point.h> | ||
| 21 | #include <__algorithm/ranges_sort.h> | 20 | #include <__algorithm/ranges_sort.h> |
| 22 | #include <__algorithm/ranges_unique.h> | ||
| 23 | #include <__algorithm/ranges_upper_bound.h> | ||
| 24 | #include <__algorithm/remove_if.h> | 21 | #include <__algorithm/remove_if.h> |
| 22 | #include <__algorithm/upper_bound.h> | ||
| 25 | #include <__assert> | 23 | #include <__assert> |
| 26 | #include <__compare/synth_three_way.h> | 24 | #include <__compare/synth_three_way.h> |
| 27 | #include <__concepts/convertible_to.h> | 25 | #include <__concepts/convertible_to.h> |
| ... | @@ -443,7 +441,7 @@ public: | ... | @@ -443,7 +441,7 @@ public: |
| 443 | is_move_constructible_v<mapped_type> | 441 | is_move_constructible_v<mapped_type> |
| 444 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { | 442 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { |
| 445 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | 443 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); |
| 446 | auto __key_it = ranges::upper_bound(__containers_.keys, __pair.first, __compare_); | 444 | auto __key_it = std::upper_bound(__containers_.keys.begin(), __containers_.keys.end(), __pair.first, __compare_); |
| 447 | auto __mapped_it = __corresponding_mapped_it(*this, __key_it); | 445 | auto __mapped_it = __corresponding_mapped_it(*this, __key_it); |
| 448 | 446 | ||
| 449 | return __flat_map_utils::__emplace_exact_pos( | 447 | return __flat_map_utils::__emplace_exact_pos( |
| ... | @@ -473,7 +471,7 @@ public: | ... | @@ -473,7 +471,7 @@ public: |
| 473 | // | | 471 | // | |
| 474 | // hint | 472 | // hint |
| 475 | // We want to insert "2" after the last existing "2" | 473 | // We want to insert "2" after the last existing "2" |
| 476 | __key_iter = ranges::upper_bound(__containers_.keys.begin(), __key_iter, __pair.first, __compare_); | 474 | __key_iter = std::upper_bound(__containers_.keys.begin(), __key_iter, __pair.first, __compare_); |
| 477 | __mapped_iter = __corresponding_mapped_it(*this, __key_iter); | 475 | __mapped_iter = __corresponding_mapped_it(*this, __key_iter); |
| 478 | } else { | 476 | } else { |
| 479 | _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multimap is not sorted"); | 477 | _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multimap is not sorted"); |
| ... | @@ -485,7 +483,7 @@ public: | ... | @@ -485,7 +483,7 @@ public: |
| 485 | // | | 483 | // | |
| 486 | // hint | 484 | // hint |
| 487 | // We want to insert "2" before the first existing "2" | 485 | // We want to insert "2" before the first existing "2" |
| 488 | __key_iter = ranges::lower_bound(__key_iter, __containers_.keys.end(), __pair.first, __compare_); | 486 | __key_iter = std::lower_bound(__key_iter, __containers_.keys.end(), __pair.first, __compare_); |
| 489 | __mapped_iter = __corresponding_mapped_it(*this, __key_iter); | 487 | __mapped_iter = __corresponding_mapped_it(*this, __key_iter); |
| 490 | } | 488 | } |
| 491 | return __flat_map_utils::__emplace_exact_pos( | 489 | return __flat_map_utils::__emplace_exact_pos( |
| ... | @@ -804,7 +802,8 @@ private: | ... | @@ -804,7 +802,8 @@ private: |
| 804 | 802 | ||
| 805 | template <class _Self, class _Kp> | 803 | template <class _Self, class _Kp> |
| 806 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | 804 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { |
| 807 | auto [__key_first, __key_last] = ranges::equal_range(__self.__containers_.keys, __key, __self.__compare_); | 805 | auto [__key_first, __key_last] = |
| 806 | std::equal_range(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __key, __self.__compare_); | ||
| 808 | 807 | ||
| 809 | using __iterator_type = ranges::iterator_t<decltype(__self)>; | 808 | using __iterator_type = ranges::iterator_t<decltype(__self)>; |
| 810 | return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)), | 809 | return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)), |
| ... | @@ -813,24 +812,26 @@ private: | ... | @@ -813,24 +812,26 @@ private: |
| 813 | 812 | ||
| 814 | template <class _Res, class _Self, class _Kp> | 813 | template <class _Res, class _Self, class _Kp> |
| 815 | _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) { | 814 | _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) { |
| 816 | auto __key_iter = ranges::lower_bound(__self.__containers_.keys, __x, __self.__compare_); | 815 | auto __key_iter = |
| 816 | std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); | ||
| 817 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | 817 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); |
| 818 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | 818 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); |
| 819 | } | 819 | } |
| 820 | 820 | ||
| 821 | template <class _Res, class _Self, class _Kp> | 821 | template <class _Res, class _Self, class _Kp> |
| 822 | _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) { | 822 | _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) { |
| 823 | auto __key_iter = ranges::upper_bound(__self.__containers_.keys, __x, __self.__compare_); | 823 | auto __key_iter = |
| 824 | std::upper_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_); | ||
| 824 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | 825 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); |
| 825 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | 826 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); |
| 826 | } | 827 | } |
| 827 | 828 | ||
| 828 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { | 829 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { |
| 829 | if constexpr (requires { __containers_.keys.reserve(__size); }) { | 830 | if constexpr (__container_traits<_KeyContainer>::__reservable) { |
| 830 | __containers_.keys.reserve(__size); | 831 | __containers_.keys.reserve(__size); |
| 831 | } | 832 | } |
| 832 | 833 | ||
| 833 | if constexpr (requires { __containers_.values.reserve(__size); }) { | 834 | if constexpr (__container_traits<_MappedContainer>::__reservable) { |
| 834 | __containers_.values.reserve(__size); | 835 | __containers_.values.reserve(__size); |
| 835 | } | 836 | } |
| 836 | } | 837 | } |
lib/libcxx/include/__flat_map/key_value_iterator.h+64-22| ... | @@ -13,9 +13,12 @@ | ... | @@ -13,9 +13,12 @@ |
| 13 | #include <__compare/three_way_comparable.h> | 13 | #include <__compare/three_way_comparable.h> |
| 14 | #include <__concepts/convertible_to.h> | 14 | #include <__concepts/convertible_to.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__iterator/product_iterator.h> | ||
| 17 | #include <__memory/addressof.h> | 19 | #include <__memory/addressof.h> |
| 18 | #include <__type_traits/conditional.h> | 20 | #include <__type_traits/conditional.h> |
| 21 | #include <__utility/forward.h> | ||
| 19 | #include <__utility/move.h> | 22 | #include <__utility/move.h> |
| 20 | #include <__utility/pair.h> | 23 | #include <__utility/pair.h> |
| 21 | 24 | ||
| ... | @@ -46,7 +49,7 @@ private: | ... | @@ -46,7 +49,7 @@ private: |
| 46 | 49 | ||
| 47 | struct __arrow_proxy { | 50 | struct __arrow_proxy { |
| 48 | __reference __ref_; | 51 | __reference __ref_; |
| 49 | _LIBCPP_HIDE_FROM_ABI __reference* operator->() { return std::addressof(__ref_); } | 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __reference* operator->() { return std::addressof(__ref_); } |
| 50 | }; | 53 | }; |
| 51 | 54 | ||
| 52 | __key_iterator __key_iter_; | 55 | __key_iterator __key_iter_; |
| ... | @@ -57,6 +60,8 @@ private: | ... | @@ -57,6 +60,8 @@ private: |
| 57 | template <class, class, class, bool> | 60 | template <class, class, class, bool> |
| 58 | friend struct __key_value_iterator; | 61 | friend struct __key_value_iterator; |
| 59 | 62 | ||
| 63 | friend struct __product_iterator_traits<__key_value_iterator>; | ||
| 64 | |||
| 60 | public: | 65 | public: |
| 61 | using iterator_concept = random_access_iterator_tag; | 66 | using iterator_concept = random_access_iterator_tag; |
| 62 | // `__key_value_iterator` only satisfy "Cpp17InputIterator" named requirements, because | 67 | // `__key_value_iterator` only satisfy "Cpp17InputIterator" named requirements, because |
| ... | @@ -69,104 +74,141 @@ public: | ... | @@ -69,104 +74,141 @@ public: |
| 69 | 74 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator() = default; | 75 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator() = default; |
| 71 | 76 | ||
| 72 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, !_Const> __i) | 77 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 78 | __key_value_iterator(__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, !_Const> __i) | ||
| 73 | requires _Const && convertible_to<typename _KeyContainer::iterator, __key_iterator> && | 79 | requires _Const && convertible_to<typename _KeyContainer::iterator, __key_iterator> && |
| 74 | convertible_to<typename _MappedContainer::iterator, __mapped_iterator> | 80 | convertible_to<typename _MappedContainer::iterator, __mapped_iterator> |
| 75 | : __key_iter_(std::move(__i.__key_iter_)), __mapped_iter_(std::move(__i.__mapped_iter_)) {} | 81 | : __key_iter_(std::move(__i.__key_iter_)), __mapped_iter_(std::move(__i.__mapped_iter_)) {} |
| 76 | 82 | ||
| 77 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_iterator __key_iter, __mapped_iterator __mapped_iter) | 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 84 | __key_value_iterator(__key_iterator __key_iter, __mapped_iterator __mapped_iter) | ||
| 78 | : __key_iter_(std::move(__key_iter)), __mapped_iter_(std::move(__mapped_iter)) {} | 85 | : __key_iter_(std::move(__key_iter)), __mapped_iter_(std::move(__mapped_iter)) {} |
| 79 | 86 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI __reference operator*() const { return __reference(*__key_iter_, *__mapped_iter_); } | 87 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __reference operator*() const { |
| 81 | _LIBCPP_HIDE_FROM_ABI __arrow_proxy operator->() const { return __arrow_proxy{**this}; } | 88 | return __reference(*__key_iter_, *__mapped_iter_); |
| 89 | } | ||
| 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __arrow_proxy operator->() const { return __arrow_proxy{**this}; } | ||
| 82 | 91 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator++() { | 92 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator++() { |
| 84 | ++__key_iter_; | 93 | ++__key_iter_; |
| 85 | ++__mapped_iter_; | 94 | ++__mapped_iter_; |
| 86 | return *this; | 95 | return *this; |
| 87 | } | 96 | } |
| 88 | 97 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator++(int) { | 98 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator operator++(int) { |
| 90 | __key_value_iterator __tmp(*this); | 99 | __key_value_iterator __tmp(*this); |
| 91 | ++*this; | 100 | ++*this; |
| 92 | return __tmp; | 101 | return __tmp; |
| 93 | } | 102 | } |
| 94 | 103 | ||
| 95 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator--() { | 104 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator--() { |
| 96 | --__key_iter_; | 105 | --__key_iter_; |
| 97 | --__mapped_iter_; | 106 | --__mapped_iter_; |
| 98 | return *this; | 107 | return *this; |
| 99 | } | 108 | } |
| 100 | 109 | ||
| 101 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator--(int) { | 110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator operator--(int) { |
| 102 | __key_value_iterator __tmp(*this); | 111 | __key_value_iterator __tmp(*this); |
| 103 | --*this; | 112 | --*this; |
| 104 | return __tmp; | 113 | return __tmp; |
| 105 | } | 114 | } |
| 106 | 115 | ||
| 107 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator+=(difference_type __x) { | 116 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator+=(difference_type __x) { |
| 108 | __key_iter_ += __x; | 117 | __key_iter_ += __x; |
| 109 | __mapped_iter_ += __x; | 118 | __mapped_iter_ += __x; |
| 110 | return *this; | 119 | return *this; |
| 111 | } | 120 | } |
| 112 | 121 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator-=(difference_type __x) { | 122 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator-=(difference_type __x) { |
| 114 | __key_iter_ -= __x; | 123 | __key_iter_ -= __x; |
| 115 | __mapped_iter_ -= __x; | 124 | __mapped_iter_ -= __x; |
| 116 | return *this; | 125 | return *this; |
| 117 | } | 126 | } |
| 118 | 127 | ||
| 119 | _LIBCPP_HIDE_FROM_ABI __reference operator[](difference_type __n) const { return *(*this + __n); } | 128 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __reference operator[](difference_type __n) const { |
| 129 | return *(*this + __n); | ||
| 130 | } | ||
| 120 | 131 | ||
| 121 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | 132 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool |
| 122 | operator==(const __key_value_iterator& __x, const __key_value_iterator& __y) { | 133 | operator==(const __key_value_iterator& __x, const __key_value_iterator& __y) { |
| 123 | return __x.__key_iter_ == __y.__key_iter_; | 134 | return __x.__key_iter_ == __y.__key_iter_; |
| 124 | } | 135 | } |
| 125 | 136 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __key_value_iterator& __x, const __key_value_iterator& __y) { | 137 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool |
| 138 | operator<(const __key_value_iterator& __x, const __key_value_iterator& __y) { | ||
| 127 | return __x.__key_iter_ < __y.__key_iter_; | 139 | return __x.__key_iter_ < __y.__key_iter_; |
| 128 | } | 140 | } |
| 129 | 141 | ||
| 130 | _LIBCPP_HIDE_FROM_ABI friend bool operator>(const __key_value_iterator& __x, const __key_value_iterator& __y) { | 142 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool |
| 143 | operator>(const __key_value_iterator& __x, const __key_value_iterator& __y) { | ||
| 131 | return __y < __x; | 144 | return __y < __x; |
| 132 | } | 145 | } |
| 133 | 146 | ||
| 134 | _LIBCPP_HIDE_FROM_ABI friend bool operator<=(const __key_value_iterator& __x, const __key_value_iterator& __y) { | 147 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool |
| 148 | operator<=(const __key_value_iterator& __x, const __key_value_iterator& __y) { | ||
| 135 | return !(__y < __x); | 149 | return !(__y < __x); |
| 136 | } | 150 | } |
| 137 | 151 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI friend bool operator>=(const __key_value_iterator& __x, const __key_value_iterator& __y) { | 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool |
| 153 | operator>=(const __key_value_iterator& __x, const __key_value_iterator& __y) { | ||
| 139 | return !(__x < __y); | 154 | return !(__x < __y); |
| 140 | } | 155 | } |
| 141 | 156 | ||
| 142 | _LIBCPP_HIDE_FROM_ABI friend auto operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y) | 157 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend auto |
| 158 | operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y) | ||
| 143 | requires three_way_comparable<__key_iterator> | 159 | requires three_way_comparable<__key_iterator> |
| 144 | { | 160 | { |
| 145 | return __x.__key_iter_ <=> __y.__key_iter_; | 161 | return __x.__key_iter_ <=> __y.__key_iter_; |
| 146 | } | 162 | } |
| 147 | 163 | ||
| 148 | _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(const __key_value_iterator& __i, difference_type __n) { | 164 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend __key_value_iterator |
| 165 | operator+(const __key_value_iterator& __i, difference_type __n) { | ||
| 149 | auto __tmp = __i; | 166 | auto __tmp = __i; |
| 150 | __tmp += __n; | 167 | __tmp += __n; |
| 151 | return __tmp; | 168 | return __tmp; |
| 152 | } | 169 | } |
| 153 | 170 | ||
| 154 | _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(difference_type __n, const __key_value_iterator& __i) { | 171 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend __key_value_iterator |
| 172 | operator+(difference_type __n, const __key_value_iterator& __i) { | ||
| 155 | return __i + __n; | 173 | return __i + __n; |
| 156 | } | 174 | } |
| 157 | 175 | ||
| 158 | _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator-(const __key_value_iterator& __i, difference_type __n) { | 176 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend __key_value_iterator |
| 177 | operator-(const __key_value_iterator& __i, difference_type __n) { | ||
| 159 | auto __tmp = __i; | 178 | auto __tmp = __i; |
| 160 | __tmp -= __n; | 179 | __tmp -= __n; |
| 161 | return __tmp; | 180 | return __tmp; |
| 162 | } | 181 | } |
| 163 | 182 | ||
| 164 | _LIBCPP_HIDE_FROM_ABI friend difference_type | 183 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend difference_type |
| 165 | operator-(const __key_value_iterator& __x, const __key_value_iterator& __y) { | 184 | operator-(const __key_value_iterator& __x, const __key_value_iterator& __y) { |
| 166 | return difference_type(__x.__key_iter_ - __y.__key_iter_); | 185 | return difference_type(__x.__key_iter_ - __y.__key_iter_); |
| 167 | } | 186 | } |
| 168 | }; | 187 | }; |
| 169 | 188 | ||
| 189 | template <class _Owner, class _KeyContainer, class _MappedContainer, bool _Const> | ||
| 190 | struct __product_iterator_traits<__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, _Const>> { | ||
| 191 | static constexpr size_t __size = 2; | ||
| 192 | |||
| 193 | template <size_t _Nth, class _Iter> | ||
| 194 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static decltype(auto) __get_iterator_element(_Iter&& __it) | ||
| 195 | requires(_Nth <= 1) | ||
| 196 | { | ||
| 197 | if constexpr (_Nth == 0) { | ||
| 198 | return std::forward<_Iter>(__it).__key_iter_; | ||
| 199 | } else { | ||
| 200 | return std::forward<_Iter>(__it).__mapped_iter_; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | |||
| 204 | template <class _KeyIter, class _MappedIter> | ||
| 205 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto | ||
| 206 | __make_product_iterator(_KeyIter&& __key_iter, _MappedIter&& __mapped_iter) { | ||
| 207 | return __key_value_iterator<_Owner, _KeyContainer, _MappedContainer, _Const>( | ||
| 208 | std::forward<_KeyIter>(__key_iter), std::forward<_MappedIter>(__mapped_iter)); | ||
| 209 | } | ||
| 210 | }; | ||
| 211 | |||
| 170 | _LIBCPP_END_NAMESPACE_STD | 212 | _LIBCPP_END_NAMESPACE_STD |
| 171 | 213 | ||
| 172 | #endif // _LIBCPP_STD_VER >= 23 | 214 | #endif // _LIBCPP_STD_VER >= 23 |
lib/libcxx/include/__flat_map/utils.h+22-4| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | #define _LIBCPP___FLAT_MAP_UTILS_H | 11 | #define _LIBCPP___FLAT_MAP_UTILS_H |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__iterator/product_iterator.h> | ||
| 14 | #include <__type_traits/container_traits.h> | 15 | #include <__type_traits/container_traits.h> |
| 15 | #include <__utility/exception_guard.h> | 16 | #include <__utility/exception_guard.h> |
| 16 | #include <__utility/forward.h> | 17 | #include <__utility/forward.h> |
| ... | @@ -35,7 +36,7 @@ struct __flat_map_utils { | ... | @@ -35,7 +36,7 @@ struct __flat_map_utils { |
| 35 | // roll back the changes it made to the map. If it cannot roll back the changes, it will | 36 | // roll back the changes it made to the map. If it cannot roll back the changes, it will |
| 36 | // clear the map. | 37 | // clear the map. |
| 37 | template <class _Map, class _IterK, class _IterM, class _KeyArg, class... _MArgs> | 38 | template <class _Map, class _IterK, class _IterM, class _KeyArg, class... _MArgs> |
| 38 | _LIBCPP_HIDE_FROM_ABI static typename _Map::iterator __emplace_exact_pos( | 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static typename _Map::iterator __emplace_exact_pos( |
| 39 | _Map& __map, _IterK&& __it_key, _IterM&& __it_mapped, _KeyArg&& __key, _MArgs&&... __mapped_args) { | 40 | _Map& __map, _IterK&& __it_key, _IterM&& __it_mapped, _KeyArg&& __key, _MArgs&&... __mapped_args) { |
| 40 | auto __on_key_failed = std::__make_exception_guard([&]() noexcept { | 41 | auto __on_key_failed = std::__make_exception_guard([&]() noexcept { |
| 41 | using _KeyContainer = typename _Map::key_container_type; | 42 | using _KeyContainer = typename _Map::key_container_type; |
| ... | @@ -79,10 +80,8 @@ struct __flat_map_utils { | ... | @@ -79,10 +80,8 @@ struct __flat_map_utils { |
| 79 | return typename _Map::iterator(std::move(__key_it), std::move(__mapped_it)); | 80 | return typename _Map::iterator(std::move(__key_it), std::move(__mapped_it)); |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | // TODO: We could optimize this, see | ||
| 83 | // https://github.com/llvm/llvm-project/issues/108624 | ||
| 84 | template <class _Map, class _InputIterator, class _Sentinel> | 83 | template <class _Map, class _InputIterator, class _Sentinel> |
| 85 | _LIBCPP_HIDE_FROM_ABI static typename _Map::size_type | 84 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static typename _Map::size_type |
| 86 | __append(_Map& __map, _InputIterator __first, _Sentinel __last) { | 85 | __append(_Map& __map, _InputIterator __first, _Sentinel __last) { |
| 87 | typename _Map::size_type __num_appended = 0; | 86 | typename _Map::size_type __num_appended = 0; |
| 88 | for (; __first != __last; ++__first) { | 87 | for (; __first != __last; ++__first) { |
| ... | @@ -93,6 +92,25 @@ struct __flat_map_utils { | ... | @@ -93,6 +92,25 @@ struct __flat_map_utils { |
| 93 | } | 92 | } |
| 94 | return __num_appended; | 93 | return __num_appended; |
| 95 | } | 94 | } |
| 95 | |||
| 96 | template <class _Map, class _InputIterator> | ||
| 97 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static typename _Map::size_type | ||
| 98 | __append(_Map& __map, _InputIterator __first, _InputIterator __last) | ||
| 99 | requires __is_product_iterator_of_size<_InputIterator, 2>::value | ||
| 100 | { | ||
| 101 | auto __s1 = __map.__containers_.keys.size(); | ||
| 102 | __map.__containers_.keys.insert( | ||
| 103 | __map.__containers_.keys.end(), | ||
| 104 | __product_iterator_traits<_InputIterator>::template __get_iterator_element<0>(__first), | ||
| 105 | __product_iterator_traits<_InputIterator>::template __get_iterator_element<0>(__last)); | ||
| 106 | |||
| 107 | __map.__containers_.values.insert( | ||
| 108 | __map.__containers_.values.end(), | ||
| 109 | __product_iterator_traits<_InputIterator>::template __get_iterator_element<1>(__first), | ||
| 110 | __product_iterator_traits<_InputIterator>::template __get_iterator_element<1>(__last)); | ||
| 111 | |||
| 112 | return __map.__containers_.keys.size() - __s1; | ||
| 113 | } | ||
| 96 | }; | 114 | }; |
| 97 | _LIBCPP_END_NAMESPACE_STD | 115 | _LIBCPP_END_NAMESPACE_STD |
| 98 | 116 |
lib/libcxx/include/__flat_set/flat_multiset.h created+792| ... | @@ -0,0 +1,792 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___FLAT_MAP_FLAT_MULTISET_H | ||
| 11 | #define _LIBCPP___FLAT_MAP_FLAT_MULTISET_H | ||
| 12 | |||
| 13 | #include <__algorithm/equal_range.h> | ||
| 14 | #include <__algorithm/lexicographical_compare_three_way.h> | ||
| 15 | #include <__algorithm/lower_bound.h> | ||
| 16 | #include <__algorithm/min.h> | ||
| 17 | #include <__algorithm/ranges_equal.h> | ||
| 18 | #include <__algorithm/ranges_inplace_merge.h> | ||
| 19 | #include <__algorithm/ranges_is_sorted.h> | ||
| 20 | #include <__algorithm/ranges_sort.h> | ||
| 21 | #include <__algorithm/ranges_unique.h> | ||
| 22 | #include <__algorithm/remove_if.h> | ||
| 23 | #include <__algorithm/upper_bound.h> | ||
| 24 | #include <__assert> | ||
| 25 | #include <__compare/synth_three_way.h> | ||
| 26 | #include <__concepts/convertible_to.h> | ||
| 27 | #include <__concepts/swappable.h> | ||
| 28 | #include <__config> | ||
| 29 | #include <__cstddef/byte.h> | ||
| 30 | #include <__cstddef/ptrdiff_t.h> | ||
| 31 | #include <__flat_map/key_value_iterator.h> | ||
| 32 | #include <__flat_map/sorted_equivalent.h> | ||
| 33 | #include <__flat_set/ra_iterator.h> | ||
| 34 | #include <__flat_set/utils.h> | ||
| 35 | #include <__functional/invoke.h> | ||
| 36 | #include <__functional/is_transparent.h> | ||
| 37 | #include <__functional/operations.h> | ||
| 38 | #include <__fwd/vector.h> | ||
| 39 | #include <__iterator/concepts.h> | ||
| 40 | #include <__iterator/distance.h> | ||
| 41 | #include <__iterator/iterator_traits.h> | ||
| 42 | #include <__iterator/prev.h> | ||
| 43 | #include <__iterator/ranges_iterator_traits.h> | ||
| 44 | #include <__iterator/reverse_iterator.h> | ||
| 45 | #include <__memory/allocator_traits.h> | ||
| 46 | #include <__memory/uses_allocator.h> | ||
| 47 | #include <__memory/uses_allocator_construction.h> | ||
| 48 | #include <__ranges/access.h> | ||
| 49 | #include <__ranges/concepts.h> | ||
| 50 | #include <__ranges/container_compatible_range.h> | ||
| 51 | #include <__ranges/drop_view.h> | ||
| 52 | #include <__ranges/from_range.h> | ||
| 53 | #include <__ranges/ref_view.h> | ||
| 54 | #include <__ranges/size.h> | ||
| 55 | #include <__ranges/subrange.h> | ||
| 56 | #include <__ranges/zip_view.h> | ||
| 57 | #include <__type_traits/conjunction.h> | ||
| 58 | #include <__type_traits/container_traits.h> | ||
| 59 | #include <__type_traits/invoke.h> | ||
| 60 | #include <__type_traits/is_allocator.h> | ||
| 61 | #include <__type_traits/is_nothrow_constructible.h> | ||
| 62 | #include <__type_traits/is_same.h> | ||
| 63 | #include <__type_traits/maybe_const.h> | ||
| 64 | #include <__utility/as_const.h> | ||
| 65 | #include <__utility/exception_guard.h> | ||
| 66 | #include <__utility/move.h> | ||
| 67 | #include <__utility/pair.h> | ||
| 68 | #include <__utility/scope_guard.h> | ||
| 69 | #include <__vector/vector.h> | ||
| 70 | #include <initializer_list> | ||
| 71 | |||
| 72 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 73 | # pragma GCC system_header | ||
| 74 | #endif | ||
| 75 | |||
| 76 | _LIBCPP_PUSH_MACROS | ||
| 77 | #include <__undef_macros> | ||
| 78 | |||
| 79 | #if _LIBCPP_STD_VER >= 23 | ||
| 80 | |||
| 81 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 82 | |||
| 83 | template <class _Key, class _Compare = less<_Key>, class _KeyContainer = vector<_Key>> | ||
| 84 | class flat_multiset { | ||
| 85 | template <class, class, class> | ||
| 86 | friend class flat_multiset; | ||
| 87 | |||
| 88 | friend __flat_set_utils; | ||
| 89 | |||
| 90 | static_assert(is_same_v<_Key, typename _KeyContainer::value_type>); | ||
| 91 | static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container"); | ||
| 92 | |||
| 93 | public: | ||
| 94 | // types | ||
| 95 | using key_type = _Key; | ||
| 96 | using value_type = _Key; | ||
| 97 | using key_compare = __type_identity_t<_Compare>; | ||
| 98 | using value_compare = _Compare; | ||
| 99 | using reference = value_type&; | ||
| 100 | using const_reference = const value_type&; | ||
| 101 | using size_type = typename _KeyContainer::size_type; | ||
| 102 | using difference_type = typename _KeyContainer::difference_type; | ||
| 103 | using iterator = __ra_iterator<flat_multiset, typename _KeyContainer::const_iterator>; | ||
| 104 | using const_iterator = iterator; | ||
| 105 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 106 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 107 | using container_type = _KeyContainer; | ||
| 108 | |||
| 109 | public: | ||
| 110 | // [flat.multiset.cons], constructors | ||
| 111 | _LIBCPP_HIDE_FROM_ABI flat_multiset() noexcept(is_nothrow_default_constructible_v<_KeyContainer> && | ||
| 112 | is_nothrow_default_constructible_v<_Compare>) | ||
| 113 | : __keys_(), __compare_() {} | ||
| 114 | |||
| 115 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset&) = default; | ||
| 116 | |||
| 117 | // The copy/move constructors are not specified in the spec, which means they should be defaulted. | ||
| 118 | // However, the move constructor can potentially leave a moved-from object in an inconsistent | ||
| 119 | // state if an exception is thrown. | ||
| 120 | _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other) noexcept( | ||
| 121 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>) | ||
| 122 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 123 | try | ||
| 124 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 125 | : __keys_(std::move(__other.__keys_)), __compare_(std::move(__other.__compare_)) { | ||
| 126 | __other.clear(); | ||
| 127 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 128 | } catch (...) { | ||
| 129 | __other.clear(); | ||
| 130 | // gcc does not like the `throw` keyword in a conditionally noexcept function | ||
| 131 | if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)) { | ||
| 132 | throw; | ||
| 133 | } | ||
| 134 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 135 | } | ||
| 136 | |||
| 137 | _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const key_compare& __comp) : __keys_(), __compare_(__comp) {} | ||
| 138 | |||
| 139 | _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(container_type __keys, const key_compare& __comp = key_compare()) | ||
| 140 | : __keys_(std::move(__keys)), __compare_(__comp) { | ||
| 141 | ranges::sort(__keys_, __compare_); | ||
| 142 | } | ||
| 143 | |||
| 144 | _LIBCPP_HIDE_FROM_ABI | ||
| 145 | flat_multiset(sorted_equivalent_t, container_type __keys, const key_compare& __comp = key_compare()) | ||
| 146 | : __keys_(std::move(__keys)), __compare_(__comp) { | ||
| 147 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | ||
| 148 | } | ||
| 149 | |||
| 150 | template <class _InputIterator> | ||
| 151 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 152 | _LIBCPP_HIDE_FROM_ABI | ||
| 153 | flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | ||
| 154 | : __keys_(), __compare_(__comp) { | ||
| 155 | insert(__first, __last); | ||
| 156 | } | ||
| 157 | |||
| 158 | template <class _InputIterator> | ||
| 159 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 160 | _LIBCPP_HIDE_FROM_ABI flat_multiset( | ||
| 161 | sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | ||
| 162 | : __keys_(__first, __last), __compare_(__comp) { | ||
| 163 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | ||
| 164 | } | ||
| 165 | |||
| 166 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 167 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t __fr, _Range&& __rg) | ||
| 168 | : flat_multiset(__fr, std::forward<_Range>(__rg), key_compare()) {} | ||
| 169 | |||
| 170 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 171 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_multiset(__comp) { | ||
| 172 | insert_range(std::forward<_Range>(__rg)); | ||
| 173 | } | ||
| 174 | |||
| 175 | _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | ||
| 176 | : flat_multiset(__il.begin(), __il.end(), __comp) {} | ||
| 177 | |||
| 178 | _LIBCPP_HIDE_FROM_ABI | ||
| 179 | flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | ||
| 180 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp) {} | ||
| 181 | |||
| 182 | template <class _Allocator> | ||
| 183 | requires uses_allocator<container_type, _Allocator>::value | ||
| 184 | _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const _Allocator& __alloc) | ||
| 185 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {} | ||
| 186 | |||
| 187 | template <class _Allocator> | ||
| 188 | requires uses_allocator<container_type, _Allocator>::value | ||
| 189 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const key_compare& __comp, const _Allocator& __alloc) | ||
| 190 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {} | ||
| 191 | |||
| 192 | template <class _Allocator> | ||
| 193 | requires uses_allocator<container_type, _Allocator>::value | ||
| 194 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const container_type& __keys, const _Allocator& __alloc) | ||
| 195 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { | ||
| 196 | ranges::sort(__keys_, __compare_); | ||
| 197 | } | ||
| 198 | |||
| 199 | template <class _Allocator> | ||
| 200 | requires uses_allocator<container_type, _Allocator>::value | ||
| 201 | _LIBCPP_HIDE_FROM_ABI | ||
| 202 | flat_multiset(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) | ||
| 203 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { | ||
| 204 | ranges::sort(__keys_, __compare_); | ||
| 205 | } | ||
| 206 | |||
| 207 | template <class _Allocator> | ||
| 208 | requires uses_allocator<container_type, _Allocator>::value | ||
| 209 | _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, const container_type& __keys, const _Allocator& __alloc) | ||
| 210 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { | ||
| 211 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | ||
| 212 | } | ||
| 213 | |||
| 214 | template <class _Allocator> | ||
| 215 | requires uses_allocator<container_type, _Allocator>::value | ||
| 216 | _LIBCPP_HIDE_FROM_ABI | ||
| 217 | flat_multiset(sorted_equivalent_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) | ||
| 218 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { | ||
| 219 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | ||
| 220 | } | ||
| 221 | |||
| 222 | template <class _Allocator> | ||
| 223 | requires uses_allocator<container_type, _Allocator>::value | ||
| 224 | _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset& __other, const _Allocator& __alloc) | ||
| 225 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)), | ||
| 226 | __compare_(__other.__compare_) {} | ||
| 227 | |||
| 228 | template <class _Allocator> | ||
| 229 | requires uses_allocator<container_type, _Allocator>::value | ||
| 230 | _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other, const _Allocator& __alloc) | ||
| 231 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 232 | try | ||
| 233 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 234 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, std::move(__other.__keys_))), | ||
| 235 | __compare_(std::move(__other.__compare_)) { | ||
| 236 | __other.clear(); | ||
| 237 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 238 | } catch (...) { | ||
| 239 | __other.clear(); | ||
| 240 | throw; | ||
| 241 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 242 | } | ||
| 243 | |||
| 244 | template <class _InputIterator, class _Allocator> | ||
| 245 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 246 | _LIBCPP_HIDE_FROM_ABI flat_multiset(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | ||
| 247 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { | ||
| 248 | insert(__first, __last); | ||
| 249 | } | ||
| 250 | |||
| 251 | template <class _InputIterator, class _Allocator> | ||
| 252 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 253 | _LIBCPP_HIDE_FROM_ABI | ||
| 254 | flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) | ||
| 255 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { | ||
| 256 | insert(__first, __last); | ||
| 257 | } | ||
| 258 | |||
| 259 | template <class _InputIterator, class _Allocator> | ||
| 260 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 261 | _LIBCPP_HIDE_FROM_ABI | ||
| 262 | flat_multiset(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | ||
| 263 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() { | ||
| 264 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | ||
| 265 | } | ||
| 266 | |||
| 267 | template <class _InputIterator, class _Allocator> | ||
| 268 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 269 | _LIBCPP_HIDE_FROM_ABI | ||
| 270 | flat_multiset(sorted_equivalent_t, | ||
| 271 | _InputIterator __first, | ||
| 272 | _InputIterator __last, | ||
| 273 | const key_compare& __comp, | ||
| 274 | const _Allocator& __alloc) | ||
| 275 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) { | ||
| 276 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted"); | ||
| 277 | } | ||
| 278 | |||
| 279 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | ||
| 280 | requires uses_allocator<container_type, _Allocator>::value | ||
| 281 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const _Allocator& __alloc) | ||
| 282 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { | ||
| 283 | insert_range(std::forward<_Range>(__rg)); | ||
| 284 | } | ||
| 285 | |||
| 286 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | ||
| 287 | requires uses_allocator<container_type, _Allocator>::value | ||
| 288 | _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | ||
| 289 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { | ||
| 290 | insert_range(std::forward<_Range>(__rg)); | ||
| 291 | } | ||
| 292 | |||
| 293 | template <class _Allocator> | ||
| 294 | requires uses_allocator<container_type, _Allocator>::value | ||
| 295 | _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 296 | : flat_multiset(__il.begin(), __il.end(), __alloc) {} | ||
| 297 | |||
| 298 | template <class _Allocator> | ||
| 299 | requires uses_allocator<container_type, _Allocator>::value | ||
| 300 | _LIBCPP_HIDE_FROM_ABI | ||
| 301 | flat_multiset(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | ||
| 302 | : flat_multiset(__il.begin(), __il.end(), __comp, __alloc) {} | ||
| 303 | |||
| 304 | template <class _Allocator> | ||
| 305 | requires uses_allocator<container_type, _Allocator>::value | ||
| 306 | _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 307 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __alloc) {} | ||
| 308 | |||
| 309 | template <class _Allocator> | ||
| 310 | requires uses_allocator<container_type, _Allocator>::value | ||
| 311 | _LIBCPP_HIDE_FROM_ABI flat_multiset( | ||
| 312 | sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | ||
| 313 | : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {} | ||
| 314 | |||
| 315 | _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(initializer_list<value_type> __il) { | ||
| 316 | clear(); | ||
| 317 | insert(__il); | ||
| 318 | return *this; | ||
| 319 | } | ||
| 320 | |||
| 321 | // copy/move assignment are not specified in the spec (defaulted) | ||
| 322 | // but move assignment can potentially leave moved from object in an inconsistent | ||
| 323 | // state if an exception is thrown | ||
| 324 | _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(const flat_multiset&) = default; | ||
| 325 | |||
| 326 | _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(flat_multiset&& __other) noexcept( | ||
| 327 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) { | ||
| 328 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); | ||
| 329 | auto __clear_self_guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 330 | __keys_ = std::move(__other.__keys_); | ||
| 331 | __compare_ = std::move(__other.__compare_); | ||
| 332 | __clear_self_guard.__complete(); | ||
| 333 | return *this; | ||
| 334 | } | ||
| 335 | |||
| 336 | // iterators | ||
| 337 | _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { return iterator(std::as_const(__keys_).begin()); } | ||
| 338 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return const_iterator(__keys_.begin()); } | ||
| 339 | _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { return iterator(std::as_const(__keys_).end()); } | ||
| 340 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return const_iterator(__keys_.end()); } | ||
| 341 | |||
| 342 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } | ||
| 343 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } | ||
| 344 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); } | ||
| 345 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } | ||
| 346 | |||
| 347 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); } | ||
| 348 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); } | ||
| 349 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } | ||
| 350 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } | ||
| 351 | |||
| 352 | // capacity | ||
| 353 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __keys_.empty(); } | ||
| 354 | _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __keys_.size(); } | ||
| 355 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { return __keys_.max_size(); } | ||
| 356 | |||
| 357 | // [flat.multiset.modifiers], modifiers | ||
| 358 | template <class... _Args> | ||
| 359 | requires is_constructible_v<value_type, _Args...> | ||
| 360 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { | ||
| 361 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { | ||
| 362 | return __emplace(std::forward<_Args>(__args)...); | ||
| 363 | } else { | ||
| 364 | return __emplace(_Key(std::forward<_Args>(__args)...)); | ||
| 365 | } | ||
| 366 | } | ||
| 367 | |||
| 368 | template <class... _Args> | ||
| 369 | requires is_constructible_v<value_type, _Args...> | ||
| 370 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) { | ||
| 371 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { | ||
| 372 | return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...); | ||
| 373 | } else { | ||
| 374 | return __emplace_hint(std::move(__hint), _Key(std::forward<_Args>(__args)...)); | ||
| 375 | } | ||
| 376 | } | ||
| 377 | |||
| 378 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return emplace(__x); } | ||
| 379 | |||
| 380 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return emplace(std::move(__x)); } | ||
| 381 | |||
| 382 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) { | ||
| 383 | return emplace_hint(__hint, __x); | ||
| 384 | } | ||
| 385 | |||
| 386 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) { | ||
| 387 | return emplace_hint(__hint, std::move(__x)); | ||
| 388 | } | ||
| 389 | |||
| 390 | template <class _InputIterator> | ||
| 391 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 392 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { | ||
| 393 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | ||
| 394 | __reserve(__last - __first); | ||
| 395 | } | ||
| 396 | __append_sort_merge</*WasSorted = */ false>(std::move(__first), std::move(__last)); | ||
| 397 | } | ||
| 398 | |||
| 399 | template <class _InputIterator> | ||
| 400 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 401 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) { | ||
| 402 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | ||
| 403 | __reserve(__last - __first); | ||
| 404 | } | ||
| 405 | |||
| 406 | __append_sort_merge</*WasSorted = */ true>(std::move(__first), std::move(__last)); | ||
| 407 | } | ||
| 408 | |||
| 409 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 410 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | ||
| 411 | if constexpr (ranges::sized_range<_Range>) { | ||
| 412 | __reserve(ranges::size(__range)); | ||
| 413 | } | ||
| 414 | |||
| 415 | __append_sort_merge</*WasSorted = */ false>(std::forward<_Range>(__range)); | ||
| 416 | } | ||
| 417 | |||
| 418 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | ||
| 419 | |||
| 420 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, initializer_list<value_type> __il) { | ||
| 421 | insert(sorted_equivalent, __il.begin(), __il.end()); | ||
| 422 | } | ||
| 423 | |||
| 424 | _LIBCPP_HIDE_FROM_ABI container_type extract() && { | ||
| 425 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 426 | auto __ret = std::move(__keys_); | ||
| 427 | return __ret; | ||
| 428 | } | ||
| 429 | |||
| 430 | _LIBCPP_HIDE_FROM_ABI void replace(container_type&& __keys) { | ||
| 431 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys, __compare_), "Key container is not sorted"); | ||
| 432 | auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 433 | __keys_ = std::move(__keys); | ||
| 434 | __guard.__complete(); | ||
| 435 | } | ||
| 436 | |||
| 437 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) { | ||
| 438 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 439 | auto __key_iter = __keys_.erase(__position.__base()); | ||
| 440 | __on_failure.__complete(); | ||
| 441 | return iterator(__key_iter); | ||
| 442 | } | ||
| 443 | |||
| 444 | // The following overload is the same as the iterator overload | ||
| 445 | // iterator erase(const_iterator __position); | ||
| 446 | |||
| 447 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) { | ||
| 448 | auto [__first, __last] = equal_range(__x); | ||
| 449 | auto __res = __last - __first; | ||
| 450 | erase(__first, __last); | ||
| 451 | return __res; | ||
| 452 | } | ||
| 453 | |||
| 454 | template <class _Kp> | ||
| 455 | requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> && | ||
| 456 | !is_convertible_v<_Kp &&, const_iterator>) | ||
| 457 | _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) { | ||
| 458 | auto [__first, __last] = equal_range(__x); | ||
| 459 | auto __res = __last - __first; | ||
| 460 | erase(__first, __last); | ||
| 461 | return __res; | ||
| 462 | } | ||
| 463 | |||
| 464 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { | ||
| 465 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 466 | auto __key_it = __keys_.erase(__first.__base(), __last.__base()); | ||
| 467 | __on_failure.__complete(); | ||
| 468 | return iterator(std::move(__key_it)); | ||
| 469 | } | ||
| 470 | |||
| 471 | _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __y) noexcept { | ||
| 472 | // warning: The spec has unconditional noexcept, which means that | ||
| 473 | // if any of the following functions throw an exception, | ||
| 474 | // std::terminate will be called | ||
| 475 | // This is discussed in P3567, which hasn't been voted on yet. | ||
| 476 | ranges::swap(__compare_, __y.__compare_); | ||
| 477 | ranges::swap(__keys_, __y.__keys_); | ||
| 478 | } | ||
| 479 | |||
| 480 | _LIBCPP_HIDE_FROM_ABI void clear() noexcept { __keys_.clear(); } | ||
| 481 | |||
| 482 | // observers | ||
| 483 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; } | ||
| 484 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __compare_; } | ||
| 485 | |||
| 486 | // map operations | ||
| 487 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); } | ||
| 488 | |||
| 489 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); } | ||
| 490 | |||
| 491 | template <class _Kp> | ||
| 492 | requires __is_transparent_v<_Compare> | ||
| 493 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) { | ||
| 494 | return __find_impl(*this, __x); | ||
| 495 | } | ||
| 496 | |||
| 497 | template <class _Kp> | ||
| 498 | requires __is_transparent_v<_Compare> | ||
| 499 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const { | ||
| 500 | return __find_impl(*this, __x); | ||
| 501 | } | ||
| 502 | |||
| 503 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { | ||
| 504 | auto [__first, __last] = equal_range(__x); | ||
| 505 | return __last - __first; | ||
| 506 | } | ||
| 507 | |||
| 508 | template <class _Kp> | ||
| 509 | requires __is_transparent_v<_Compare> | ||
| 510 | _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const { | ||
| 511 | auto [__first, __last] = equal_range(__x); | ||
| 512 | return __last - __first; | ||
| 513 | } | ||
| 514 | |||
| 515 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); } | ||
| 516 | |||
| 517 | template <class _Kp> | ||
| 518 | requires __is_transparent_v<_Compare> | ||
| 519 | _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const { | ||
| 520 | return find(__x) != end(); | ||
| 521 | } | ||
| 522 | |||
| 523 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { | ||
| 524 | const auto& __keys = __keys_; | ||
| 525 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 526 | } | ||
| 527 | |||
| 528 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const { | ||
| 529 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 530 | } | ||
| 531 | |||
| 532 | template <class _Kp> | ||
| 533 | requires __is_transparent_v<_Compare> | ||
| 534 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) { | ||
| 535 | const auto& __keys = __keys_; | ||
| 536 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 537 | } | ||
| 538 | |||
| 539 | template <class _Kp> | ||
| 540 | requires __is_transparent_v<_Compare> | ||
| 541 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const { | ||
| 542 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 543 | } | ||
| 544 | |||
| 545 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { | ||
| 546 | const auto& __keys = __keys_; | ||
| 547 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 548 | } | ||
| 549 | |||
| 550 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const { | ||
| 551 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 552 | } | ||
| 553 | |||
| 554 | template <class _Kp> | ||
| 555 | requires __is_transparent_v<_Compare> | ||
| 556 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) { | ||
| 557 | const auto& __keys = __keys_; | ||
| 558 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 559 | } | ||
| 560 | |||
| 561 | template <class _Kp> | ||
| 562 | requires __is_transparent_v<_Compare> | ||
| 563 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const { | ||
| 564 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 565 | } | ||
| 566 | |||
| 567 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) { | ||
| 568 | return __equal_range_impl(*this, __x); | ||
| 569 | } | ||
| 570 | |||
| 571 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { | ||
| 572 | return __equal_range_impl(*this, __x); | ||
| 573 | } | ||
| 574 | |||
| 575 | template <class _Kp> | ||
| 576 | requires __is_transparent_v<_Compare> | ||
| 577 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) { | ||
| 578 | return __equal_range_impl(*this, __x); | ||
| 579 | } | ||
| 580 | template <class _Kp> | ||
| 581 | requires __is_transparent_v<_Compare> | ||
| 582 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const { | ||
| 583 | return __equal_range_impl(*this, __x); | ||
| 584 | } | ||
| 585 | |||
| 586 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_multiset& __x, const flat_multiset& __y) { | ||
| 587 | return ranges::equal(__x, __y); | ||
| 588 | } | ||
| 589 | |||
| 590 | friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_multiset& __x, const flat_multiset& __y) { | ||
| 591 | return std::lexicographical_compare_three_way( | ||
| 592 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | ||
| 593 | } | ||
| 594 | |||
| 595 | friend _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __x, flat_multiset& __y) noexcept { __x.swap(__y); } | ||
| 596 | |||
| 597 | private: | ||
| 598 | template <bool _WasSorted, class... _Args> | ||
| 599 | _LIBCPP_HIDE_FROM_ABI void __append_sort_merge(_Args&&... __args) { | ||
| 600 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 601 | size_type __old_size = size(); | ||
| 602 | __flat_set_utils::__append(*this, std::forward<_Args>(__args)...); | ||
| 603 | if constexpr (!_WasSorted) { | ||
| 604 | ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_); | ||
| 605 | } else { | ||
| 606 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 607 | ranges::is_sorted(__keys_ | ranges::views::drop(__old_size)), "Key container is not sorted"); | ||
| 608 | } | ||
| 609 | ranges::inplace_merge(__keys_.begin(), __keys_.begin() + __old_size, __keys_.end(), __compare_); | ||
| 610 | __on_failure.__complete(); | ||
| 611 | } | ||
| 612 | |||
| 613 | template <class _Kp> | ||
| 614 | _LIBCPP_HIDE_FROM_ABI iterator __emplace(_Kp&& __key) { | ||
| 615 | auto __it = upper_bound(__key); | ||
| 616 | return __flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key)); | ||
| 617 | } | ||
| 618 | |||
| 619 | template <class _Kp> | ||
| 620 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint(const_iterator __hint, _Kp&& __key) { | ||
| 621 | auto __prev_larger = __hint != cbegin() && __compare_(__key, *std::prev(__hint)); | ||
| 622 | auto __next_smaller = __hint != cend() && __compare_(*__hint, __key); | ||
| 623 | |||
| 624 | if (!__prev_larger && !__next_smaller) [[likely]] { | ||
| 625 | // hint correct, just use exact hint iterator | ||
| 626 | } else if (__prev_larger && !__next_smaller) { | ||
| 627 | // the hint position is more to the right than the key should have been. | ||
| 628 | // we want to emplace the element to a position as right as possible | ||
| 629 | // e.g. Insert new element "2" in the following range | ||
| 630 | // 1, 1, 2, 2, 2, 3, 4, 6 | ||
| 631 | // ^ | ||
| 632 | // | | ||
| 633 | // hint | ||
| 634 | // We want to insert "2" after the last existing "2" | ||
| 635 | __hint = std::upper_bound(begin(), __hint, __key, __compare_); | ||
| 636 | } else { | ||
| 637 | _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multiset is not sorted"); | ||
| 638 | |||
| 639 | // the hint position is more to the left than the key should have been. | ||
| 640 | // we want to emplace the element to a position as left as possible | ||
| 641 | // 1, 1, 2, 2, 2, 3, 4, 6 | ||
| 642 | // ^ | ||
| 643 | // | | ||
| 644 | // hint | ||
| 645 | // We want to insert "2" before the first existing "2" | ||
| 646 | __hint = std::lower_bound(__hint, end(), __key, __compare_); | ||
| 647 | } | ||
| 648 | return __flat_set_utils::__emplace_exact_pos(*this, __hint, std::forward<_Kp>(__key)); | ||
| 649 | } | ||
| 650 | |||
| 651 | template <class _Self, class _Kp> | ||
| 652 | _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) { | ||
| 653 | auto __it = __self.lower_bound(__key); | ||
| 654 | auto __last = __self.end(); | ||
| 655 | if (__it == __last || __self.__compare_(__key, *__it)) { | ||
| 656 | return __last; | ||
| 657 | } | ||
| 658 | return __it; | ||
| 659 | } | ||
| 660 | |||
| 661 | template <class _Self, class _Kp> | ||
| 662 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | ||
| 663 | using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>; | ||
| 664 | auto [__key_first, __key_last] = | ||
| 665 | std::equal_range(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_); | ||
| 666 | return std::make_pair(__iter(__key_first), __iter(__key_last)); | ||
| 667 | } | ||
| 668 | |||
| 669 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { | ||
| 670 | if constexpr (__container_traits<_KeyContainer>::__reservable) { | ||
| 671 | __keys_.reserve(__size); | ||
| 672 | } | ||
| 673 | } | ||
| 674 | |||
| 675 | template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate> | ||
| 676 | friend typename flat_multiset<_Key2, _Compare2, _KeyContainer2>::size_type | ||
| 677 | erase_if(flat_multiset<_Key2, _Compare2, _KeyContainer2>&, _Predicate); | ||
| 678 | |||
| 679 | _KeyContainer __keys_; | ||
| 680 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; | ||
| 681 | |||
| 682 | struct __key_equiv { | ||
| 683 | _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {} | ||
| 684 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | ||
| 685 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); | ||
| 686 | } | ||
| 687 | key_compare __comp_; | ||
| 688 | }; | ||
| 689 | }; | ||
| 690 | |||
| 691 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | ||
| 692 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 693 | is_invocable_v<const _Compare&, | ||
| 694 | const typename _KeyContainer::value_type&, | ||
| 695 | const typename _KeyContainer::value_type&>) | ||
| 696 | flat_multiset(_KeyContainer, _Compare = _Compare()) | ||
| 697 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 698 | |||
| 699 | template <class _KeyContainer, class _Allocator> | ||
| 700 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | ||
| 701 | flat_multiset(_KeyContainer, _Allocator) | ||
| 702 | -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | ||
| 703 | |||
| 704 | template <class _KeyContainer, class _Compare, class _Allocator> | ||
| 705 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 706 | uses_allocator_v<_KeyContainer, _Allocator> && | ||
| 707 | is_invocable_v<const _Compare&, | ||
| 708 | const typename _KeyContainer::value_type&, | ||
| 709 | const typename _KeyContainer::value_type&>) | ||
| 710 | flat_multiset(_KeyContainer, _Compare, _Allocator) | ||
| 711 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 712 | |||
| 713 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | ||
| 714 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 715 | is_invocable_v<const _Compare&, | ||
| 716 | const typename _KeyContainer::value_type&, | ||
| 717 | const typename _KeyContainer::value_type&>) | ||
| 718 | flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare()) | ||
| 719 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 720 | |||
| 721 | template <class _KeyContainer, class _Allocator> | ||
| 722 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | ||
| 723 | flat_multiset(sorted_equivalent_t, _KeyContainer, _Allocator) | ||
| 724 | -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | ||
| 725 | |||
| 726 | template <class _KeyContainer, class _Compare, class _Allocator> | ||
| 727 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 728 | uses_allocator_v<_KeyContainer, _Allocator> && | ||
| 729 | is_invocable_v<const _Compare&, | ||
| 730 | const typename _KeyContainer::value_type&, | ||
| 731 | const typename _KeyContainer::value_type&>) | ||
| 732 | flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Allocator) | ||
| 733 | -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 734 | |||
| 735 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | ||
| 736 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | ||
| 737 | flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare()) | ||
| 738 | -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>; | ||
| 739 | |||
| 740 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | ||
| 741 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | ||
| 742 | flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare()) | ||
| 743 | -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>; | ||
| 744 | |||
| 745 | template <ranges::input_range _Range, | ||
| 746 | class _Compare = less<ranges::range_value_t<_Range>>, | ||
| 747 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | ||
| 748 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | ||
| 749 | flat_multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multiset< | ||
| 750 | ranges::range_value_t<_Range>, | ||
| 751 | _Compare, | ||
| 752 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | ||
| 753 | |||
| 754 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | ||
| 755 | flat_multiset(from_range_t, _Range&&, _Allocator) -> flat_multiset< | ||
| 756 | ranges::range_value_t<_Range>, | ||
| 757 | less<ranges::range_value_t<_Range>>, | ||
| 758 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | ||
| 759 | |||
| 760 | template <class _Key, class _Compare = less<_Key>> | ||
| 761 | requires(!__is_allocator<_Compare>::value) | ||
| 762 | flat_multiset(initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>; | ||
| 763 | |||
| 764 | template <class _Key, class _Compare = less<_Key>> | ||
| 765 | requires(!__is_allocator<_Compare>::value) | ||
| 766 | flat_multiset(sorted_equivalent_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>; | ||
| 767 | |||
| 768 | template <class _Key, class _Compare, class _KeyContainer, class _Allocator> | ||
| 769 | struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Allocator> | ||
| 770 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> > {}; | ||
| 771 | |||
| 772 | template <class _Key, class _Compare, class _KeyContainer, class _Predicate> | ||
| 773 | _LIBCPP_HIDE_FROM_ABI typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type | ||
| 774 | erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __flat_multiset, _Predicate __pred) { | ||
| 775 | auto __guard = std::__make_exception_guard([&] { __flat_multiset.clear(); }); | ||
| 776 | auto __it = | ||
| 777 | std::remove_if(__flat_multiset.__keys_.begin(), __flat_multiset.__keys_.end(), [&](const auto& __e) -> bool { | ||
| 778 | return static_cast<bool>(__pred(__e)); | ||
| 779 | }); | ||
| 780 | auto __res = __flat_multiset.__keys_.end() - __it; | ||
| 781 | __flat_multiset.__keys_.erase(__it, __flat_multiset.__keys_.end()); | ||
| 782 | __guard.__complete(); | ||
| 783 | return __res; | ||
| 784 | } | ||
| 785 | |||
| 786 | _LIBCPP_END_NAMESPACE_STD | ||
| 787 | |||
| 788 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 789 | |||
| 790 | _LIBCPP_POP_MACROS | ||
| 791 | |||
| 792 | #endif // _LIBCPP___FLAT_MAP_FLAT_MULTISET_H | ||
lib/libcxx/include/__flat_set/flat_set.h created+874| ... | @@ -0,0 +1,874 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___FLAT_SET_FLAT_SET_H | ||
| 11 | #define _LIBCPP___FLAT_SET_FLAT_SET_H | ||
| 12 | |||
| 13 | #include <__algorithm/lexicographical_compare_three_way.h> | ||
| 14 | #include <__algorithm/lower_bound.h> | ||
| 15 | #include <__algorithm/min.h> | ||
| 16 | #include <__algorithm/ranges_adjacent_find.h> | ||
| 17 | #include <__algorithm/ranges_equal.h> | ||
| 18 | #include <__algorithm/ranges_inplace_merge.h> | ||
| 19 | #include <__algorithm/ranges_sort.h> | ||
| 20 | #include <__algorithm/ranges_unique.h> | ||
| 21 | #include <__algorithm/remove_if.h> | ||
| 22 | #include <__algorithm/upper_bound.h> | ||
| 23 | #include <__assert> | ||
| 24 | #include <__compare/synth_three_way.h> | ||
| 25 | #include <__concepts/swappable.h> | ||
| 26 | #include <__config> | ||
| 27 | #include <__cstddef/ptrdiff_t.h> | ||
| 28 | #include <__flat_map/sorted_unique.h> | ||
| 29 | #include <__flat_set/ra_iterator.h> | ||
| 30 | #include <__flat_set/utils.h> | ||
| 31 | #include <__functional/invoke.h> | ||
| 32 | #include <__functional/is_transparent.h> | ||
| 33 | #include <__functional/operations.h> | ||
| 34 | #include <__fwd/vector.h> | ||
| 35 | #include <__iterator/concepts.h> | ||
| 36 | #include <__iterator/distance.h> | ||
| 37 | #include <__iterator/iterator_traits.h> | ||
| 38 | #include <__iterator/next.h> | ||
| 39 | #include <__iterator/prev.h> | ||
| 40 | #include <__iterator/ranges_iterator_traits.h> | ||
| 41 | #include <__iterator/reverse_iterator.h> | ||
| 42 | #include <__memory/allocator_traits.h> | ||
| 43 | #include <__memory/uses_allocator.h> | ||
| 44 | #include <__memory/uses_allocator_construction.h> | ||
| 45 | #include <__ranges/access.h> | ||
| 46 | #include <__ranges/concepts.h> | ||
| 47 | #include <__ranges/container_compatible_range.h> | ||
| 48 | #include <__ranges/drop_view.h> | ||
| 49 | #include <__ranges/from_range.h> | ||
| 50 | #include <__ranges/ref_view.h> | ||
| 51 | #include <__ranges/size.h> | ||
| 52 | #include <__ranges/subrange.h> | ||
| 53 | #include <__type_traits/conjunction.h> | ||
| 54 | #include <__type_traits/container_traits.h> | ||
| 55 | #include <__type_traits/invoke.h> | ||
| 56 | #include <__type_traits/is_allocator.h> | ||
| 57 | #include <__type_traits/is_const.h> | ||
| 58 | #include <__type_traits/is_nothrow_constructible.h> | ||
| 59 | #include <__type_traits/is_same.h> | ||
| 60 | #include <__type_traits/remove_reference.h> | ||
| 61 | #include <__utility/as_const.h> | ||
| 62 | #include <__utility/exception_guard.h> | ||
| 63 | #include <__utility/move.h> | ||
| 64 | #include <__utility/pair.h> | ||
| 65 | #include <__utility/scope_guard.h> | ||
| 66 | #include <__vector/vector.h> | ||
| 67 | #include <initializer_list> | ||
| 68 | |||
| 69 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 70 | # pragma GCC system_header | ||
| 71 | #endif | ||
| 72 | |||
| 73 | _LIBCPP_PUSH_MACROS | ||
| 74 | #include <__undef_macros> | ||
| 75 | |||
| 76 | #if _LIBCPP_STD_VER >= 23 | ||
| 77 | |||
| 78 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 79 | |||
| 80 | template <class _Key, class _Compare = less<_Key>, class _KeyContainer = vector<_Key>> | ||
| 81 | class flat_set { | ||
| 82 | template <class, class, class> | ||
| 83 | friend class flat_set; | ||
| 84 | |||
| 85 | friend __flat_set_utils; | ||
| 86 | |||
| 87 | static_assert(is_same_v<_Key, typename _KeyContainer::value_type>); | ||
| 88 | static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container"); | ||
| 89 | |||
| 90 | using __key_iterator _LIBCPP_NODEBUG = typename _KeyContainer::const_iterator; | ||
| 91 | |||
| 92 | public: | ||
| 93 | // types | ||
| 94 | using key_type = _Key; | ||
| 95 | using value_type = _Key; | ||
| 96 | using key_compare = __type_identity_t<_Compare>; | ||
| 97 | using value_compare = _Compare; | ||
| 98 | using reference = value_type&; | ||
| 99 | using const_reference = const value_type&; | ||
| 100 | using size_type = typename _KeyContainer::size_type; | ||
| 101 | using difference_type = typename _KeyContainer::difference_type; | ||
| 102 | using iterator = __ra_iterator<flat_set, typename _KeyContainer::const_iterator>; | ||
| 103 | using const_iterator = iterator; | ||
| 104 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 105 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 106 | using container_type = _KeyContainer; | ||
| 107 | |||
| 108 | public: | ||
| 109 | // [flat.set.cons], construct/copy/destroy | ||
| 110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 111 | flat_set() noexcept(is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_Compare>) | ||
| 112 | : __keys_(), __compare_() {} | ||
| 113 | |||
| 114 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const flat_set&) = default; | ||
| 115 | |||
| 116 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(flat_set&& __other) noexcept( | ||
| 117 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>) | ||
| 118 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 119 | try | ||
| 120 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 121 | : __keys_(std::move(__other.__keys_)), __compare_(std::move(__other.__compare_)) { | ||
| 122 | __other.clear(); | ||
| 123 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 124 | } catch (...) { | ||
| 125 | __other.clear(); | ||
| 126 | // gcc does not like the `throw` keyword in a conditionally noexcept function | ||
| 127 | if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)) { | ||
| 128 | throw; | ||
| 129 | } | ||
| 130 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 131 | } | ||
| 132 | |||
| 133 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(const key_compare& __comp) | ||
| 134 | : __keys_(), __compare_(__comp) {} | ||
| 135 | |||
| 136 | _LIBCPP_HIDE_FROM_ABI | ||
| 137 | _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(container_type __keys, const key_compare& __comp = key_compare()) | ||
| 138 | : __keys_(std::move(__keys)), __compare_(__comp) { | ||
| 139 | __sort_and_unique(); | ||
| 140 | } | ||
| 141 | |||
| 142 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 143 | flat_set(sorted_unique_t, container_type __keys, const key_compare& __comp = key_compare()) | ||
| 144 | : __keys_(std::move(__keys)), __compare_(__comp) { | ||
| 145 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 146 | __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates"); | ||
| 147 | } | ||
| 148 | |||
| 149 | template <class _InputIterator> | ||
| 150 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 151 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 152 | flat_set(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | ||
| 153 | : __keys_(), __compare_(__comp) { | ||
| 154 | insert(__first, __last); | ||
| 155 | } | ||
| 156 | |||
| 157 | template <class _InputIterator> | ||
| 158 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 159 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 160 | flat_set(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | ||
| 161 | : __keys_(__first, __last), __compare_(__comp) { | ||
| 162 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 163 | __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates"); | ||
| 164 | } | ||
| 165 | |||
| 166 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 167 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg) | ||
| 168 | : flat_set(from_range, std::forward<_Range>(__rg), key_compare()) {} | ||
| 169 | |||
| 170 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 171 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg, const key_compare& __comp) | ||
| 172 | : flat_set(__comp) { | ||
| 173 | insert_range(std::forward<_Range>(__rg)); | ||
| 174 | } | ||
| 175 | |||
| 176 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 177 | flat_set(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | ||
| 178 | : flat_set(__il.begin(), __il.end(), __comp) {} | ||
| 179 | |||
| 180 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 181 | flat_set(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | ||
| 182 | : flat_set(sorted_unique, __il.begin(), __il.end(), __comp) {} | ||
| 183 | |||
| 184 | template <class _Allocator> | ||
| 185 | requires uses_allocator<container_type, _Allocator>::value | ||
| 186 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(const _Allocator& __alloc) | ||
| 187 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {} | ||
| 188 | |||
| 189 | template <class _Allocator> | ||
| 190 | requires uses_allocator<container_type, _Allocator>::value | ||
| 191 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const key_compare& __comp, const _Allocator& __alloc) | ||
| 192 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {} | ||
| 193 | |||
| 194 | template <class _Allocator> | ||
| 195 | requires uses_allocator<container_type, _Allocator>::value | ||
| 196 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const container_type& __keys, const _Allocator& __alloc) | ||
| 197 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { | ||
| 198 | __sort_and_unique(); | ||
| 199 | } | ||
| 200 | |||
| 201 | template <class _Allocator> | ||
| 202 | requires uses_allocator<container_type, _Allocator>::value | ||
| 203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 204 | flat_set(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) | ||
| 205 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { | ||
| 206 | __sort_and_unique(); | ||
| 207 | } | ||
| 208 | |||
| 209 | template <class _Allocator> | ||
| 210 | requires uses_allocator<container_type, _Allocator>::value | ||
| 211 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 212 | flat_set(sorted_unique_t, const container_type& __keys, const _Allocator& __alloc) | ||
| 213 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() { | ||
| 214 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 215 | __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates"); | ||
| 216 | } | ||
| 217 | |||
| 218 | template <class _Allocator> | ||
| 219 | requires uses_allocator<container_type, _Allocator>::value | ||
| 220 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 221 | flat_set(sorted_unique_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc) | ||
| 222 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) { | ||
| 223 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 224 | __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates"); | ||
| 225 | } | ||
| 226 | |||
| 227 | template <class _Allocator> | ||
| 228 | requires uses_allocator<container_type, _Allocator>::value | ||
| 229 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const flat_set& __other, const _Allocator& __alloc) | ||
| 230 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)), | ||
| 231 | __compare_(__other.__compare_) {} | ||
| 232 | |||
| 233 | template <class _Allocator> | ||
| 234 | requires uses_allocator<container_type, _Allocator>::value | ||
| 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(flat_set&& __other, const _Allocator& __alloc) | ||
| 236 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 237 | try | ||
| 238 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 239 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, std::move(__other.__keys_))), | ||
| 240 | __compare_(std::move(__other.__compare_)) { | ||
| 241 | __other.clear(); | ||
| 242 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 243 | } catch (...) { | ||
| 244 | __other.clear(); | ||
| 245 | throw; | ||
| 246 | # endif // _LIBCPP_HAS_EXCEPTIONS | ||
| 247 | } | ||
| 248 | |||
| 249 | template <class _InputIterator, class _Allocator> | ||
| 250 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 251 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 252 | flat_set(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | ||
| 253 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { | ||
| 254 | insert(__first, __last); | ||
| 255 | } | ||
| 256 | |||
| 257 | template <class _InputIterator, class _Allocator> | ||
| 258 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 260 | flat_set(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) | ||
| 261 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { | ||
| 262 | insert(__first, __last); | ||
| 263 | } | ||
| 264 | |||
| 265 | template <class _InputIterator, class _Allocator> | ||
| 266 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 267 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 268 | flat_set(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | ||
| 269 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() { | ||
| 270 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 271 | __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates"); | ||
| 272 | } | ||
| 273 | |||
| 274 | template <class _InputIterator, class _Allocator> | ||
| 275 | requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value) | ||
| 276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set( | ||
| 277 | sorted_unique_t, | ||
| 278 | _InputIterator __first, | ||
| 279 | _InputIterator __last, | ||
| 280 | const key_compare& __comp, | ||
| 281 | const _Allocator& __alloc) | ||
| 282 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) { | ||
| 283 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 284 | __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates"); | ||
| 285 | } | ||
| 286 | |||
| 287 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | ||
| 288 | requires uses_allocator<container_type, _Allocator>::value | ||
| 289 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg, const _Allocator& __alloc) | ||
| 290 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() { | ||
| 291 | insert_range(std::forward<_Range>(__rg)); | ||
| 292 | } | ||
| 293 | |||
| 294 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | ||
| 295 | requires uses_allocator<container_type, _Allocator>::value | ||
| 296 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 297 | flat_set(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | ||
| 298 | : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) { | ||
| 299 | insert_range(std::forward<_Range>(__rg)); | ||
| 300 | } | ||
| 301 | |||
| 302 | template <class _Allocator> | ||
| 303 | requires uses_allocator<container_type, _Allocator>::value | ||
| 304 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 305 | flat_set(initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 306 | : flat_set(__il.begin(), __il.end(), __alloc) {} | ||
| 307 | |||
| 308 | template <class _Allocator> | ||
| 309 | requires uses_allocator<container_type, _Allocator>::value | ||
| 310 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 311 | flat_set(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | ||
| 312 | : flat_set(__il.begin(), __il.end(), __comp, __alloc) {} | ||
| 313 | |||
| 314 | template <class _Allocator> | ||
| 315 | requires uses_allocator<container_type, _Allocator>::value | ||
| 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 317 | flat_set(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc) | ||
| 318 | : flat_set(sorted_unique, __il.begin(), __il.end(), __alloc) {} | ||
| 319 | |||
| 320 | template <class _Allocator> | ||
| 321 | requires uses_allocator<container_type, _Allocator>::value | ||
| 322 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 323 | flat_set(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | ||
| 324 | : flat_set(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {} | ||
| 325 | |||
| 326 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(initializer_list<value_type> __il) { | ||
| 327 | clear(); | ||
| 328 | insert(__il); | ||
| 329 | return *this; | ||
| 330 | } | ||
| 331 | |||
| 332 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(const flat_set&) = default; | ||
| 333 | |||
| 334 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(flat_set&& __other) noexcept( | ||
| 335 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) { | ||
| 336 | // No matter what happens, we always want to clear the other container before returning | ||
| 337 | // since we moved from it | ||
| 338 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); | ||
| 339 | { | ||
| 340 | // If an exception is thrown, we have no choice but to clear *this to preserve invariants | ||
| 341 | auto __on_exception = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 342 | __keys_ = std::move(__other.__keys_); | ||
| 343 | __compare_ = std::move(__other.__compare_); | ||
| 344 | __on_exception.__complete(); | ||
| 345 | } | ||
| 346 | return *this; | ||
| 347 | } | ||
| 348 | |||
| 349 | // iterators | ||
| 350 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept { | ||
| 351 | return iterator(std::as_const(__keys_).begin()); | ||
| 352 | } | ||
| 353 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept { | ||
| 354 | return const_iterator(__keys_.begin()); | ||
| 355 | } | ||
| 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept { | ||
| 357 | return iterator(std::as_const(__keys_).end()); | ||
| 358 | } | ||
| 359 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept { | ||
| 360 | return const_iterator(__keys_.end()); | ||
| 361 | } | ||
| 362 | |||
| 363 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept { | ||
| 364 | return reverse_iterator(end()); | ||
| 365 | } | ||
| 366 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept { | ||
| 367 | return const_reverse_iterator(end()); | ||
| 368 | } | ||
| 369 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept { | ||
| 370 | return reverse_iterator(begin()); | ||
| 371 | } | ||
| 372 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept { | ||
| 373 | return const_reverse_iterator(begin()); | ||
| 374 | } | ||
| 375 | |||
| 376 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { return begin(); } | ||
| 377 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { return end(); } | ||
| 378 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept { | ||
| 379 | return const_reverse_iterator(end()); | ||
| 380 | } | ||
| 381 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept { | ||
| 382 | return const_reverse_iterator(begin()); | ||
| 383 | } | ||
| 384 | |||
| 385 | // [flat.set.capacity], capacity | ||
| 386 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const noexcept { | ||
| 387 | return __keys_.empty(); | ||
| 388 | } | ||
| 389 | |||
| 390 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { return __keys_.size(); } | ||
| 391 | |||
| 392 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { return __keys_.max_size(); } | ||
| 393 | |||
| 394 | // [flat.set.modifiers], modifiers | ||
| 395 | template <class... _Args> | ||
| 396 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) { | ||
| 397 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { | ||
| 398 | return __emplace(std::forward<_Args>(__args)...); | ||
| 399 | } else { | ||
| 400 | return __emplace(_Key(std::forward<_Args>(__args)...)); | ||
| 401 | } | ||
| 402 | } | ||
| 403 | |||
| 404 | template <class... _Args> | ||
| 405 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __hint, _Args&&... __args) { | ||
| 406 | if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) { | ||
| 407 | return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...); | ||
| 408 | } else { | ||
| 409 | return __emplace_hint(std::move(__hint), _Key(std::forward<_Args>(__args)...)); | ||
| 410 | } | ||
| 411 | } | ||
| 412 | |||
| 413 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __x) { | ||
| 414 | return emplace(__x); | ||
| 415 | } | ||
| 416 | |||
| 417 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __x) { | ||
| 418 | return emplace(std::move(__x)); | ||
| 419 | } | ||
| 420 | |||
| 421 | template <class _Kp> | ||
| 422 | requires(__is_transparent_v<_Compare> && is_constructible_v<value_type, _Kp>) | ||
| 423 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(_Kp&& __x) { | ||
| 424 | return __emplace(std::forward<_Kp>(__x)); | ||
| 425 | } | ||
| 426 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, const value_type& __x) { | ||
| 427 | return emplace_hint(__hint, __x); | ||
| 428 | } | ||
| 429 | |||
| 430 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, value_type&& __x) { | ||
| 431 | return emplace_hint(__hint, std::move(__x)); | ||
| 432 | } | ||
| 433 | |||
| 434 | template <class _Kp> | ||
| 435 | requires(__is_transparent_v<_Compare> && is_constructible_v<value_type, _Kp>) | ||
| 436 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, _Kp&& __x) { | ||
| 437 | return __emplace_hint(__hint, std::forward<_Kp>(__x)); | ||
| 438 | } | ||
| 439 | |||
| 440 | template <class _InputIterator> | ||
| 441 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 442 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) { | ||
| 443 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | ||
| 444 | __reserve(__last - __first); | ||
| 445 | } | ||
| 446 | __append_sort_merge_unique</*WasSorted = */ false>(std::move(__first), std::move(__last)); | ||
| 447 | } | ||
| 448 | |||
| 449 | template <class _InputIterator> | ||
| 450 | requires __has_input_iterator_category<_InputIterator>::value | ||
| 451 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void | ||
| 452 | insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) { | ||
| 453 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | ||
| 454 | __reserve(__last - __first); | ||
| 455 | } | ||
| 456 | |||
| 457 | __append_sort_merge_unique</*WasSorted = */ true>(std::move(__first), std::move(__last)); | ||
| 458 | } | ||
| 459 | |||
| 460 | template <_ContainerCompatibleRange<value_type> _Range> | ||
| 461 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) { | ||
| 462 | if constexpr (ranges::sized_range<_Range>) { | ||
| 463 | __reserve(ranges::size(__range)); | ||
| 464 | } | ||
| 465 | |||
| 466 | __append_sort_merge_unique</*WasSorted = */ false>(std::forward<_Range>(__range)); | ||
| 467 | } | ||
| 468 | |||
| 469 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) { | ||
| 470 | insert(__il.begin(), __il.end()); | ||
| 471 | } | ||
| 472 | |||
| 473 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(sorted_unique_t, initializer_list<value_type> __il) { | ||
| 474 | insert(sorted_unique, __il.begin(), __il.end()); | ||
| 475 | } | ||
| 476 | |||
| 477 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 container_type extract() && { | ||
| 478 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 479 | auto __ret = std::move(__keys_); | ||
| 480 | return __ret; | ||
| 481 | } | ||
| 482 | |||
| 483 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void replace(container_type&& __keys) { | ||
| 484 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | ||
| 485 | __is_sorted_and_unique(__keys), "Either the key container is not sorted or it contains duplicates"); | ||
| 486 | auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 487 | __keys_ = std::move(__keys); | ||
| 488 | __guard.__complete(); | ||
| 489 | } | ||
| 490 | |||
| 491 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __position) { | ||
| 492 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 493 | auto __key_iter = __keys_.erase(__position.__base()); | ||
| 494 | __on_failure.__complete(); | ||
| 495 | return iterator(__key_iter); | ||
| 496 | } | ||
| 497 | |||
| 498 | // The following overload is the same as the iterator overload | ||
| 499 | // iterator erase(const_iterator __position); | ||
| 500 | |||
| 501 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __x) { | ||
| 502 | auto __iter = find(__x); | ||
| 503 | if (__iter != end()) { | ||
| 504 | erase(__iter); | ||
| 505 | return 1; | ||
| 506 | } | ||
| 507 | return 0; | ||
| 508 | } | ||
| 509 | |||
| 510 | template <class _Kp> | ||
| 511 | requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> && | ||
| 512 | !is_convertible_v<_Kp &&, const_iterator>) | ||
| 513 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(_Kp&& __x) { | ||
| 514 | auto [__first, __last] = equal_range(__x); | ||
| 515 | auto __res = __last - __first; | ||
| 516 | erase(__first, __last); | ||
| 517 | return __res; | ||
| 518 | } | ||
| 519 | |||
| 520 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __first, const_iterator __last) { | ||
| 521 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 522 | auto __key_it = __keys_.erase(__first.__base(), __last.__base()); | ||
| 523 | __on_failure.__complete(); | ||
| 524 | return iterator(std::move(__key_it)); | ||
| 525 | } | ||
| 526 | |||
| 527 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __y) noexcept { | ||
| 528 | // warning: The spec has unconditional noexcept, which means that | ||
| 529 | // if any of the following functions throw an exception, | ||
| 530 | // std::terminate will be called. | ||
| 531 | // This is discussed in P2767, which hasn't been voted on yet. | ||
| 532 | ranges::swap(__compare_, __y.__compare_); | ||
| 533 | ranges::swap(__keys_, __y.__keys_); | ||
| 534 | } | ||
| 535 | |||
| 536 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { __keys_.clear(); } | ||
| 537 | |||
| 538 | // observers | ||
| 539 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; } | ||
| 540 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { return __compare_; } | ||
| 541 | |||
| 542 | // set operations | ||
| 543 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) { | ||
| 544 | return __find_impl(*this, __x); | ||
| 545 | } | ||
| 546 | |||
| 547 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const { | ||
| 548 | return __find_impl(*this, __x); | ||
| 549 | } | ||
| 550 | |||
| 551 | template <class _Kp> | ||
| 552 | requires __is_transparent_v<_Compare> | ||
| 553 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) { | ||
| 554 | return __find_impl(*this, __x); | ||
| 555 | } | ||
| 556 | |||
| 557 | template <class _Kp> | ||
| 558 | requires __is_transparent_v<_Compare> | ||
| 559 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const { | ||
| 560 | return __find_impl(*this, __x); | ||
| 561 | } | ||
| 562 | |||
| 563 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const { | ||
| 564 | return contains(__x) ? 1 : 0; | ||
| 565 | } | ||
| 566 | |||
| 567 | template <class _Kp> | ||
| 568 | requires __is_transparent_v<_Compare> | ||
| 569 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const { | ||
| 570 | return contains(__x) ? 1 : 0; | ||
| 571 | } | ||
| 572 | |||
| 573 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const { | ||
| 574 | return find(__x) != end(); | ||
| 575 | } | ||
| 576 | |||
| 577 | template <class _Kp> | ||
| 578 | requires __is_transparent_v<_Compare> | ||
| 579 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const { | ||
| 580 | return find(__x) != end(); | ||
| 581 | } | ||
| 582 | |||
| 583 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) { | ||
| 584 | const auto& __keys = __keys_; | ||
| 585 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 586 | } | ||
| 587 | |||
| 588 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __x) const { | ||
| 589 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 590 | } | ||
| 591 | |||
| 592 | template <class _Kp> | ||
| 593 | requires __is_transparent_v<_Compare> | ||
| 594 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) { | ||
| 595 | const auto& __keys = __keys_; | ||
| 596 | return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 597 | } | ||
| 598 | |||
| 599 | template <class _Kp> | ||
| 600 | requires __is_transparent_v<_Compare> | ||
| 601 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const { | ||
| 602 | return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 603 | } | ||
| 604 | |||
| 605 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) { | ||
| 606 | const auto& __keys = __keys_; | ||
| 607 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 608 | } | ||
| 609 | |||
| 610 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __x) const { | ||
| 611 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 612 | } | ||
| 613 | |||
| 614 | template <class _Kp> | ||
| 615 | requires __is_transparent_v<_Compare> | ||
| 616 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) { | ||
| 617 | const auto& __keys = __keys_; | ||
| 618 | return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_)); | ||
| 619 | } | ||
| 620 | |||
| 621 | template <class _Kp> | ||
| 622 | requires __is_transparent_v<_Compare> | ||
| 623 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const { | ||
| 624 | return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_)); | ||
| 625 | } | ||
| 626 | |||
| 627 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __x) { | ||
| 628 | return __equal_range_impl(*this, __x); | ||
| 629 | } | ||
| 630 | |||
| 631 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> | ||
| 632 | equal_range(const key_type& __x) const { | ||
| 633 | return __equal_range_impl(*this, __x); | ||
| 634 | } | ||
| 635 | |||
| 636 | template <class _Kp> | ||
| 637 | requires __is_transparent_v<_Compare> | ||
| 638 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _Kp& __x) { | ||
| 639 | return __equal_range_impl(*this, __x); | ||
| 640 | } | ||
| 641 | template <class _Kp> | ||
| 642 | requires __is_transparent_v<_Compare> | ||
| 643 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator> | ||
| 644 | equal_range(const _Kp& __x) const { | ||
| 645 | return __equal_range_impl(*this, __x); | ||
| 646 | } | ||
| 647 | |||
| 648 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator==(const flat_set& __x, const flat_set& __y) { | ||
| 649 | return ranges::equal(__x, __y); | ||
| 650 | } | ||
| 651 | |||
| 652 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto | ||
| 653 | operator<=>(const flat_set& __x, const flat_set& __y) { | ||
| 654 | return std::lexicographical_compare_three_way( | ||
| 655 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | ||
| 656 | } | ||
| 657 | |||
| 658 | friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __x, flat_set& __y) noexcept { | ||
| 659 | __x.swap(__y); | ||
| 660 | } | ||
| 661 | |||
| 662 | private: | ||
| 663 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const { | ||
| 664 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); }; | ||
| 665 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); | ||
| 666 | } | ||
| 667 | |||
| 668 | // This function is only used in constructors. So there is not exception handling in this function. | ||
| 669 | // If the function exits via an exception, there will be no flat_set object constructed, thus, there | ||
| 670 | // is no invariant state to preserve | ||
| 671 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __sort_and_unique() { | ||
| 672 | ranges::sort(__keys_, __compare_); | ||
| 673 | auto __dup_start = ranges::unique(__keys_, __key_equiv(__compare_)).begin(); | ||
| 674 | __keys_.erase(__dup_start, __keys_.end()); | ||
| 675 | } | ||
| 676 | |||
| 677 | template <bool _WasSorted, class... _Args> | ||
| 678 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __append_sort_merge_unique(_Args&&... __args) { | ||
| 679 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | ||
| 680 | size_type __old_size = size(); | ||
| 681 | __flat_set_utils::__append(*this, std::forward<_Args>(__args)...); | ||
| 682 | if (size() != __old_size) { | ||
| 683 | if constexpr (!_WasSorted) { | ||
| 684 | ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_); | ||
| 685 | } else { | ||
| 686 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted_and_unique(__keys_ | ranges::views::drop(__old_size)), | ||
| 687 | "Either the key container is not sorted or it contains duplicates"); | ||
| 688 | } | ||
| 689 | ranges::inplace_merge(__keys_.begin(), __keys_.begin() + __old_size, __keys_.end(), __compare_); | ||
| 690 | |||
| 691 | auto __dup_start = ranges::unique(__keys_, __key_equiv(__compare_)).begin(); | ||
| 692 | __keys_.erase(__dup_start, __keys_.end()); | ||
| 693 | } | ||
| 694 | __on_failure.__complete(); | ||
| 695 | } | ||
| 696 | |||
| 697 | template <class _Self, class _Kp> | ||
| 698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __find_impl(_Self&& __self, const _Kp& __key) { | ||
| 699 | auto __it = __self.lower_bound(__key); | ||
| 700 | auto __last = __self.end(); | ||
| 701 | if (__it == __last || __self.__compare_(__key, *__it)) { | ||
| 702 | return __last; | ||
| 703 | } | ||
| 704 | return __it; | ||
| 705 | } | ||
| 706 | |||
| 707 | template <class _Self, class _Kp> | ||
| 708 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | ||
| 709 | using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>; | ||
| 710 | auto __it = std::lower_bound(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_); | ||
| 711 | auto __last = __self.__keys_.end(); | ||
| 712 | if (__it == __last || __self.__compare_(__key, *__it)) { | ||
| 713 | return std::make_pair(__iter(__it), __iter(__it)); | ||
| 714 | } | ||
| 715 | return std::make_pair(__iter(__it), __iter(std::next(__it))); | ||
| 716 | } | ||
| 717 | |||
| 718 | template <class _Kp> | ||
| 719 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> __emplace(_Kp&& __key) { | ||
| 720 | auto __it = lower_bound(__key); | ||
| 721 | if (__it == end() || __compare_(__key, *__it)) { | ||
| 722 | return pair<iterator, bool>(__flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key)), true); | ||
| 723 | } else { | ||
| 724 | return pair<iterator, bool>(std::move(__it), false); | ||
| 725 | } | ||
| 726 | } | ||
| 727 | |||
| 728 | template <class _Kp> | ||
| 729 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_hint_correct(const_iterator __hint, _Kp&& __key) { | ||
| 730 | if (__hint != cbegin() && !__compare_(*std::prev(__hint), __key)) { | ||
| 731 | return false; | ||
| 732 | } | ||
| 733 | if (__hint != cend() && __compare_(*__hint, __key)) { | ||
| 734 | return false; | ||
| 735 | } | ||
| 736 | return true; | ||
| 737 | } | ||
| 738 | |||
| 739 | template <class _Kp> | ||
| 740 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint(const_iterator __hint, _Kp&& __key) { | ||
| 741 | if (__is_hint_correct(__hint, __key)) { | ||
| 742 | if (__hint == cend() || __compare_(__key, *__hint)) { | ||
| 743 | return __flat_set_utils::__emplace_exact_pos(*this, __hint, std::forward<_Kp>(__key)); | ||
| 744 | } else { | ||
| 745 | // we already have an equal key | ||
| 746 | return __hint; | ||
| 747 | } | ||
| 748 | } else { | ||
| 749 | return __emplace(std::forward<_Kp>(__key)).first; | ||
| 750 | } | ||
| 751 | } | ||
| 752 | |||
| 753 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __reserve(size_t __size) { | ||
| 754 | if constexpr (__container_traits<_KeyContainer>::__reservable) { | ||
| 755 | __keys_.reserve(__size); | ||
| 756 | } | ||
| 757 | } | ||
| 758 | |||
| 759 | template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate> | ||
| 760 | friend typename flat_set<_Key2, _Compare2, _KeyContainer2>::size_type _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 761 | erase_if(flat_set<_Key2, _Compare2, _KeyContainer2>&, _Predicate); | ||
| 762 | |||
| 763 | _KeyContainer __keys_; | ||
| 764 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; | ||
| 765 | |||
| 766 | struct __key_equiv { | ||
| 767 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {} | ||
| 768 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool | ||
| 769 | operator()(const_reference __x, const_reference __y) const { | ||
| 770 | return !__comp_(__x, __y) && !__comp_(__y, __x); | ||
| 771 | } | ||
| 772 | key_compare __comp_; | ||
| 773 | }; | ||
| 774 | }; | ||
| 775 | |||
| 776 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | ||
| 777 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 778 | is_invocable_v<const _Compare&, | ||
| 779 | const typename _KeyContainer::value_type&, | ||
| 780 | const typename _KeyContainer::value_type&>) | ||
| 781 | flat_set(_KeyContainer, _Compare = _Compare()) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 782 | |||
| 783 | template <class _KeyContainer, class _Allocator> | ||
| 784 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | ||
| 785 | flat_set(_KeyContainer, _Allocator) | ||
| 786 | -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | ||
| 787 | |||
| 788 | template <class _KeyContainer, class _Compare, class _Allocator> | ||
| 789 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 790 | uses_allocator_v<_KeyContainer, _Allocator> && | ||
| 791 | is_invocable_v<const _Compare&, | ||
| 792 | const typename _KeyContainer::value_type&, | ||
| 793 | const typename _KeyContainer::value_type&>) | ||
| 794 | flat_set(_KeyContainer, _Compare, _Allocator) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 795 | |||
| 796 | template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>> | ||
| 797 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 798 | is_invocable_v<const _Compare&, | ||
| 799 | const typename _KeyContainer::value_type&, | ||
| 800 | const typename _KeyContainer::value_type&>) | ||
| 801 | flat_set(sorted_unique_t, _KeyContainer, _Compare = _Compare()) | ||
| 802 | -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 803 | |||
| 804 | template <class _KeyContainer, class _Allocator> | ||
| 805 | requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value) | ||
| 806 | flat_set(sorted_unique_t, _KeyContainer, _Allocator) | ||
| 807 | -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>; | ||
| 808 | |||
| 809 | template <class _KeyContainer, class _Compare, class _Allocator> | ||
| 810 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | ||
| 811 | uses_allocator_v<_KeyContainer, _Allocator> && | ||
| 812 | is_invocable_v<const _Compare&, | ||
| 813 | const typename _KeyContainer::value_type&, | ||
| 814 | const typename _KeyContainer::value_type&>) | ||
| 815 | flat_set(sorted_unique_t, _KeyContainer, _Compare, _Allocator) | ||
| 816 | -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>; | ||
| 817 | |||
| 818 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | ||
| 819 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | ||
| 820 | flat_set(_InputIterator, _InputIterator, _Compare = _Compare()) | ||
| 821 | -> flat_set<__iter_value_type<_InputIterator>, _Compare>; | ||
| 822 | |||
| 823 | template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>> | ||
| 824 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | ||
| 825 | flat_set(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare()) | ||
| 826 | -> flat_set<__iter_value_type<_InputIterator>, _Compare>; | ||
| 827 | |||
| 828 | template <ranges::input_range _Range, | ||
| 829 | class _Compare = less<ranges::range_value_t<_Range>>, | ||
| 830 | class _Allocator = allocator<ranges::range_value_t<_Range>>, | ||
| 831 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | ||
| 832 | flat_set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_set< | ||
| 833 | ranges::range_value_t<_Range>, | ||
| 834 | _Compare, | ||
| 835 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | ||
| 836 | |||
| 837 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | ||
| 838 | flat_set(from_range_t, _Range&&, _Allocator) -> flat_set< | ||
| 839 | ranges::range_value_t<_Range>, | ||
| 840 | less<ranges::range_value_t<_Range>>, | ||
| 841 | vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>; | ||
| 842 | |||
| 843 | template <class _Key, class _Compare = less<_Key>> | ||
| 844 | requires(!__is_allocator<_Compare>::value) | ||
| 845 | flat_set(initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>; | ||
| 846 | |||
| 847 | template <class _Key, class _Compare = less<_Key>> | ||
| 848 | requires(!__is_allocator<_Compare>::value) | ||
| 849 | flat_set(sorted_unique_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>; | ||
| 850 | |||
| 851 | template <class _Key, class _Compare, class _KeyContainer, class _Allocator> | ||
| 852 | struct uses_allocator<flat_set<_Key, _Compare, _KeyContainer>, _Allocator> | ||
| 853 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator>> {}; | ||
| 854 | |||
| 855 | template <class _Key, class _Compare, class _KeyContainer, class _Predicate> | ||
| 856 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename flat_set<_Key, _Compare, _KeyContainer>::size_type | ||
| 857 | erase_if(flat_set<_Key, _Compare, _KeyContainer>& __flat_set, _Predicate __pred) { | ||
| 858 | auto __guard = std::__make_exception_guard([&] { __flat_set.clear(); }); | ||
| 859 | auto __it = std::remove_if(__flat_set.__keys_.begin(), __flat_set.__keys_.end(), [&](const auto& __e) -> bool { | ||
| 860 | return static_cast<bool>(__pred(__e)); | ||
| 861 | }); | ||
| 862 | auto __res = __flat_set.__keys_.end() - __it; | ||
| 863 | __flat_set.__keys_.erase(__it, __flat_set.__keys_.end()); | ||
| 864 | __guard.__complete(); | ||
| 865 | return __res; | ||
| 866 | } | ||
| 867 | |||
| 868 | _LIBCPP_END_NAMESPACE_STD | ||
| 869 | |||
| 870 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 871 | |||
| 872 | _LIBCPP_POP_MACROS | ||
| 873 | |||
| 874 | #endif // _LIBCPP___FLAT_SET_FLAT_SET_H | ||
lib/libcxx/include/__flat_set/ra_iterator.h created+157| ... | @@ -0,0 +1,157 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___FLAT_SET_RA_ITERATOR_H | ||
| 11 | #define _LIBCPP___FLAT_SET_RA_ITERATOR_H | ||
| 12 | |||
| 13 | #include "__type_traits/is_same.h" | ||
| 14 | #include <__compare/three_way_comparable.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__iterator/incrementable_traits.h> | ||
| 17 | #include <__iterator/iterator_traits.h> | ||
| 18 | #include <__type_traits/is_constructible.h> | ||
| 19 | #include <__utility/move.h> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | #include <__undef_macros> | ||
| 27 | |||
| 28 | #if _LIBCPP_STD_VER >= 23 | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | /** | ||
| 33 | * __ra_iterator is a random access iterator that wraps an underlying iterator. | ||
| 34 | * It also stores the underlying container type in its type so that algorithms | ||
| 35 | * can optimize based on the underlying container type, and to avoid inadvertently | ||
| 36 | * mixing iterators coming from different containers.. | ||
| 37 | */ | ||
| 38 | template <class _Container, class _Iterator> | ||
| 39 | struct __ra_iterator { | ||
| 40 | private: | ||
| 41 | _Iterator __iter_; | ||
| 42 | |||
| 43 | friend _Container; | ||
| 44 | |||
| 45 | // note: checking the concept random_access_iterator does not work for incomplete types | ||
| 46 | static_assert(_IsSame<typename iterator_traits<_Iterator>::iterator_category, random_access_iterator_tag>::value, | ||
| 47 | "Underlying iterator must be a random access iterator"); | ||
| 48 | |||
| 49 | public: | ||
| 50 | using iterator_concept = random_access_iterator_tag; // deliberately lower contiguous_iterator | ||
| 51 | using iterator_category = random_access_iterator_tag; | ||
| 52 | using value_type = iter_value_t<_Iterator>; | ||
| 53 | using difference_type = iter_difference_t<_Iterator>; | ||
| 54 | |||
| 55 | _LIBCPP_HIDE_FROM_ABI __ra_iterator() | ||
| 56 | requires is_default_constructible_v<_Iterator> | ||
| 57 | = default; | ||
| 58 | |||
| 59 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __ra_iterator(_Iterator __iter) : __iter_(std::move(__iter)) {} | ||
| 60 | |||
| 61 | _LIBCPP_HIDE_FROM_ABI constexpr _Iterator __base() const noexcept(noexcept(_Iterator(__iter_))) { return __iter_; } | ||
| 62 | |||
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return *__iter_; } | ||
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator->() const | ||
| 65 | requires requires { __iter_.operator->(); } | ||
| 66 | { | ||
| 67 | return __iter_.operator->(); | ||
| 68 | } | ||
| 69 | |||
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator++() { | ||
| 71 | ++__iter_; | ||
| 72 | return *this; | ||
| 73 | } | ||
| 74 | |||
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator operator++(int) { | ||
| 76 | __ra_iterator __tmp(*this); | ||
| 77 | ++*this; | ||
| 78 | return __tmp; | ||
| 79 | } | ||
| 80 | |||
| 81 | _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator--() { | ||
| 82 | --__iter_; | ||
| 83 | return *this; | ||
| 84 | } | ||
| 85 | |||
| 86 | _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator operator--(int) { | ||
| 87 | __ra_iterator __tmp(*this); | ||
| 88 | --*this; | ||
| 89 | return __tmp; | ||
| 90 | } | ||
| 91 | |||
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator+=(difference_type __x) { | ||
| 93 | __iter_ += __x; | ||
| 94 | return *this; | ||
| 95 | } | ||
| 96 | |||
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator-=(difference_type __x) { | ||
| 98 | __iter_ -= __x; | ||
| 99 | return *this; | ||
| 100 | } | ||
| 101 | |||
| 102 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const { return *(*this + __n); } | ||
| 103 | |||
| 104 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __ra_iterator& __x, const __ra_iterator& __y) { | ||
| 105 | return __x.__iter_ == __y.__iter_; | ||
| 106 | } | ||
| 107 | |||
| 108 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __ra_iterator& __x, const __ra_iterator& __y) { | ||
| 109 | return __x.__iter_ < __y.__iter_; | ||
| 110 | } | ||
| 111 | |||
| 112 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __ra_iterator& __x, const __ra_iterator& __y) { | ||
| 113 | return __y < __x; | ||
| 114 | } | ||
| 115 | |||
| 116 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __ra_iterator& __x, const __ra_iterator& __y) { | ||
| 117 | return !(__y < __x); | ||
| 118 | } | ||
| 119 | |||
| 120 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __ra_iterator& __x, const __ra_iterator& __y) { | ||
| 121 | return !(__x < __y); | ||
| 122 | } | ||
| 123 | |||
| 124 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __ra_iterator& __x, const __ra_iterator& __y) | ||
| 125 | requires three_way_comparable<_Iterator> | ||
| 126 | { | ||
| 127 | return __x.__iter_ <=> __y.__iter_; | ||
| 128 | } | ||
| 129 | |||
| 130 | _LIBCPP_HIDE_FROM_ABI friend constexpr __ra_iterator operator+(const __ra_iterator& __i, difference_type __n) { | ||
| 131 | auto __tmp = __i; | ||
| 132 | __tmp += __n; | ||
| 133 | return __tmp; | ||
| 134 | } | ||
| 135 | |||
| 136 | _LIBCPP_HIDE_FROM_ABI friend constexpr __ra_iterator operator+(difference_type __n, const __ra_iterator& __i) { | ||
| 137 | return __i + __n; | ||
| 138 | } | ||
| 139 | |||
| 140 | _LIBCPP_HIDE_FROM_ABI friend constexpr __ra_iterator operator-(const __ra_iterator& __i, difference_type __n) { | ||
| 141 | auto __tmp = __i; | ||
| 142 | __tmp -= __n; | ||
| 143 | return __tmp; | ||
| 144 | } | ||
| 145 | |||
| 146 | _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __ra_iterator& __x, const __ra_iterator& __y) { | ||
| 147 | return __x.__iter_ - __y.__iter_; | ||
| 148 | } | ||
| 149 | }; | ||
| 150 | |||
| 151 | _LIBCPP_END_NAMESPACE_STD | ||
| 152 | |||
| 153 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 154 | |||
| 155 | _LIBCPP_POP_MACROS | ||
| 156 | |||
| 157 | #endif // _LIBCPP___FLAT_SET_RA_ITERATOR_H | ||
lib/libcxx/include/__flat_set/utils.h created+82| ... | @@ -0,0 +1,82 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___FLAT_SET_UTILS_H | ||
| 11 | #define _LIBCPP___FLAT_SET_UTILS_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__iterator/iterator_traits.h> | ||
| 15 | #include <__ranges/access.h> | ||
| 16 | #include <__ranges/concepts.h> | ||
| 17 | #include <__type_traits/container_traits.h> | ||
| 18 | #include <__type_traits/decay.h> | ||
| 19 | #include <__utility/exception_guard.h> | ||
| 20 | #include <__utility/forward.h> | ||
| 21 | #include <__utility/move.h> | ||
| 22 | |||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 24 | # pragma GCC system_header | ||
| 25 | #endif | ||
| 26 | |||
| 27 | _LIBCPP_PUSH_MACROS | ||
| 28 | #include <__undef_macros> | ||
| 29 | |||
| 30 | #if _LIBCPP_STD_VER >= 23 | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | // These utilities are defined in a class instead of a namespace so that this class can be befriended more easily. | ||
| 35 | struct __flat_set_utils { | ||
| 36 | // Emplace a key into a flat_{multi}set, at the exact position that | ||
| 37 | // __it point to, assuming that the key is not already present in the set. | ||
| 38 | // When an exception is thrown during the emplacement, the function will clear the set if the container does not | ||
| 39 | // have strong exception safety guarantee on emplacement. | ||
| 40 | template <class _Set, class _Iter, class _KeyArg> | ||
| 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto | ||
| 42 | __emplace_exact_pos(_Set& __set, _Iter&& __iter, _KeyArg&& __key) { | ||
| 43 | using _KeyContainer = typename decay_t<_Set>::container_type; | ||
| 44 | auto __on_failure = std::__make_exception_guard([&]() noexcept { | ||
| 45 | if constexpr (!__container_traits<_KeyContainer>::__emplacement_has_strong_exception_safety_guarantee) { | ||
| 46 | __set.clear() /* noexcept */; | ||
| 47 | } | ||
| 48 | }); | ||
| 49 | auto __key_it = __set.__keys_.emplace(__iter.__base(), std::forward<_KeyArg>(__key)); | ||
| 50 | __on_failure.__complete(); | ||
| 51 | return typename decay_t<_Set>::iterator(std::move(__key_it)); | ||
| 52 | } | ||
| 53 | |||
| 54 | template <class _Set, class _InputIterator> | ||
| 55 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void | ||
| 56 | __append(_Set& __set, _InputIterator __first, _InputIterator __last) { | ||
| 57 | __set.__keys_.insert(__set.__keys_.end(), std::move(__first), std::move(__last)); | ||
| 58 | } | ||
| 59 | |||
| 60 | template <class _Set, class _Range> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void __append(_Set& __set, _Range&& __rng) { | ||
| 62 | if constexpr (requires { __set.__keys_.insert_range(__set.__keys_.end(), std::forward<_Range>(__rng)); }) { | ||
| 63 | // C++23 Sequence Container should have insert_range member function | ||
| 64 | // Note that not all Sequence Containers provide append_range. | ||
| 65 | __set.__keys_.insert_range(__set.__keys_.end(), std::forward<_Range>(__rng)); | ||
| 66 | } else if constexpr (ranges::common_range<_Range> && | ||
| 67 | __has_input_iterator_category<ranges::iterator_t<_Range>>::value) { | ||
| 68 | __set.__keys_.insert(__set.__keys_.end(), ranges::begin(__rng), ranges::end(__rng)); | ||
| 69 | } else { | ||
| 70 | for (auto&& __x : __rng) { | ||
| 71 | __set.__keys_.insert(__set.__keys_.end(), std::forward<decltype(__x)>(__x)); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | }; | ||
| 76 | _LIBCPP_END_NAMESPACE_STD | ||
| 77 | |||
| 78 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 79 | |||
| 80 | _LIBCPP_POP_MACROS | ||
| 81 | |||
| 82 | #endif // #define _LIBCPP___FLAT_SET_UTILS_H | ||
lib/libcxx/include/__format/buffer.h+14-15| ... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
| 15 | #include <__algorithm/max.h> | 15 | #include <__algorithm/max.h> |
| 16 | #include <__algorithm/min.h> | 16 | #include <__algorithm/min.h> |
| 17 | #include <__algorithm/ranges_copy.h> | 17 | #include <__algorithm/ranges_copy.h> |
| 18 | #include <__algorithm/ranges_copy_n.h> | ||
| 19 | #include <__algorithm/transform.h> | 18 | #include <__algorithm/transform.h> |
| 20 | #include <__algorithm/unwrap_iter.h> | 19 | #include <__algorithm/unwrap_iter.h> |
| 21 | #include <__concepts/same_as.h> | 20 | #include <__concepts/same_as.h> |
| ... | @@ -33,7 +32,7 @@ | ... | @@ -33,7 +32,7 @@ |
| 33 | #include <__memory/allocator.h> | 32 | #include <__memory/allocator.h> |
| 34 | #include <__memory/allocator_traits.h> | 33 | #include <__memory/allocator_traits.h> |
| 35 | #include <__memory/construct_at.h> | 34 | #include <__memory/construct_at.h> |
| 36 | #include <__memory/ranges_construct_at.h> | 35 | #include <__memory/destroy.h> |
| 37 | #include <__memory/uninitialized_algorithms.h> | 36 | #include <__memory/uninitialized_algorithms.h> |
| 38 | #include <__type_traits/add_pointer.h> | 37 | #include <__type_traits/add_pointer.h> |
| 39 | #include <__type_traits/conditional.h> | 38 | #include <__type_traits/conditional.h> |
| ... | @@ -180,7 +179,7 @@ private: | ... | @@ -180,7 +179,7 @@ private: |
| 180 | /// The latter option allows formatted_size to use the output buffer without | 179 | /// The latter option allows formatted_size to use the output buffer without |
| 181 | /// ever writing anything to the buffer. | 180 | /// ever writing anything to the buffer. |
| 182 | template <__fmt_char_type _CharT> | 181 | template <__fmt_char_type _CharT> |
| 183 | class _LIBCPP_TEMPLATE_VIS __output_buffer { | 182 | class __output_buffer { |
| 184 | public: | 183 | public: |
| 185 | using value_type _LIBCPP_NODEBUG = _CharT; | 184 | using value_type _LIBCPP_NODEBUG = _CharT; |
| 186 | using __prepare_write_type _LIBCPP_NODEBUG = void (*)(__output_buffer<_CharT>&, size_t); | 185 | using __prepare_write_type _LIBCPP_NODEBUG = void (*)(__output_buffer<_CharT>&, size_t); |
| ... | @@ -340,18 +339,18 @@ concept __insertable = | ... | @@ -340,18 +339,18 @@ concept __insertable = |
| 340 | 339 | ||
| 341 | /// Extract the container type of a \ref back_insert_iterator. | 340 | /// Extract the container type of a \ref back_insert_iterator. |
| 342 | template <class _It> | 341 | template <class _It> |
| 343 | struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container { | 342 | struct __back_insert_iterator_container { |
| 344 | using type _LIBCPP_NODEBUG = void; | 343 | using type _LIBCPP_NODEBUG = void; |
| 345 | }; | 344 | }; |
| 346 | 345 | ||
| 347 | template <__insertable _Container> | 346 | template <__insertable _Container> |
| 348 | struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> { | 347 | struct __back_insert_iterator_container<back_insert_iterator<_Container>> { |
| 349 | using type _LIBCPP_NODEBUG = _Container; | 348 | using type _LIBCPP_NODEBUG = _Container; |
| 350 | }; | 349 | }; |
| 351 | 350 | ||
| 352 | // A dynamically growing buffer. | 351 | // A dynamically growing buffer. |
| 353 | template <__fmt_char_type _CharT> | 352 | template <__fmt_char_type _CharT> |
| 354 | class _LIBCPP_TEMPLATE_VIS __allocating_buffer : public __output_buffer<_CharT> { | 353 | class __allocating_buffer : public __output_buffer<_CharT> { |
| 355 | public: | 354 | public: |
| 356 | __allocating_buffer(const __allocating_buffer&) = delete; | 355 | __allocating_buffer(const __allocating_buffer&) = delete; |
| 357 | __allocating_buffer& operator=(const __allocating_buffer&) = delete; | 356 | __allocating_buffer& operator=(const __allocating_buffer&) = delete; |
| ... | @@ -408,7 +407,7 @@ private: | ... | @@ -408,7 +407,7 @@ private: |
| 408 | 407 | ||
| 409 | // A buffer that directly writes to the underlying buffer. | 408 | // A buffer that directly writes to the underlying buffer. |
| 410 | template <class _OutIt, __fmt_char_type _CharT> | 409 | template <class _OutIt, __fmt_char_type _CharT> |
| 411 | class _LIBCPP_TEMPLATE_VIS __direct_iterator_buffer : public __output_buffer<_CharT> { | 410 | class __direct_iterator_buffer : public __output_buffer<_CharT> { |
| 412 | public: | 411 | public: |
| 413 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it) | 412 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it) |
| 414 | : __direct_iterator_buffer{__out_it, nullptr} {} | 413 | : __direct_iterator_buffer{__out_it, nullptr} {} |
| ... | @@ -437,7 +436,7 @@ private: | ... | @@ -437,7 +436,7 @@ private: |
| 437 | 436 | ||
| 438 | // A buffer that writes its output to the end of a container. | 437 | // A buffer that writes its output to the end of a container. |
| 439 | template <class _OutIt, __fmt_char_type _CharT> | 438 | template <class _OutIt, __fmt_char_type _CharT> |
| 440 | class _LIBCPP_TEMPLATE_VIS __container_inserter_buffer : public __output_buffer<_CharT> { | 439 | class __container_inserter_buffer : public __output_buffer<_CharT> { |
| 441 | public: | 440 | public: |
| 442 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it) | 441 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it) |
| 443 | : __container_inserter_buffer{__out_it, nullptr} {} | 442 | : __container_inserter_buffer{__out_it, nullptr} {} |
| ... | @@ -478,7 +477,7 @@ private: | ... | @@ -478,7 +477,7 @@ private: |
| 478 | // Unlike the __container_inserter_buffer this class' performance does benefit | 477 | // Unlike the __container_inserter_buffer this class' performance does benefit |
| 479 | // from allocating and then inserting. | 478 | // from allocating and then inserting. |
| 480 | template <class _OutIt, __fmt_char_type _CharT> | 479 | template <class _OutIt, __fmt_char_type _CharT> |
| 481 | class _LIBCPP_TEMPLATE_VIS __iterator_buffer : public __allocating_buffer<_CharT> { | 480 | class __iterator_buffer : public __allocating_buffer<_CharT> { |
| 482 | public: | 481 | public: |
| 483 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it) | 482 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it) |
| 484 | : __allocating_buffer<_CharT>{}, __out_it_{std::move(__out_it)} {} | 483 | : __allocating_buffer<_CharT>{}, __out_it_{std::move(__out_it)} {} |
| ... | @@ -496,7 +495,7 @@ private: | ... | @@ -496,7 +495,7 @@ private: |
| 496 | 495 | ||
| 497 | // Selects the type of the buffer used for the output iterator. | 496 | // Selects the type of the buffer used for the output iterator. |
| 498 | template <class _OutIt, __fmt_char_type _CharT> | 497 | template <class _OutIt, __fmt_char_type _CharT> |
| 499 | class _LIBCPP_TEMPLATE_VIS __buffer_selector { | 498 | class __buffer_selector { |
| 500 | using _Container _LIBCPP_NODEBUG = __back_insert_iterator_container<_OutIt>::type; | 499 | using _Container _LIBCPP_NODEBUG = __back_insert_iterator_container<_OutIt>::type; |
| 501 | 500 | ||
| 502 | public: | 501 | public: |
| ... | @@ -510,7 +509,7 @@ public: | ... | @@ -510,7 +509,7 @@ public: |
| 510 | 509 | ||
| 511 | // A buffer that counts and limits the number of insertions. | 510 | // A buffer that counts and limits the number of insertions. |
| 512 | template <class _OutIt, __fmt_char_type _CharT> | 511 | template <class _OutIt, __fmt_char_type _CharT> |
| 513 | class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer : private __buffer_selector<_OutIt, _CharT>::type { | 512 | class __format_to_n_buffer : private __buffer_selector<_OutIt, _CharT>::type { |
| 514 | public: | 513 | public: |
| 515 | using _Base _LIBCPP_NODEBUG = __buffer_selector<_OutIt, _CharT>::type; | 514 | using _Base _LIBCPP_NODEBUG = __buffer_selector<_OutIt, _CharT>::type; |
| 516 | 515 | ||
| ... | @@ -534,7 +533,7 @@ private: | ... | @@ -534,7 +533,7 @@ private: |
| 534 | // Since formatted_size only needs to know the size, the output itself is | 533 | // Since formatted_size only needs to know the size, the output itself is |
| 535 | // discarded. | 534 | // discarded. |
| 536 | template <__fmt_char_type _CharT> | 535 | template <__fmt_char_type _CharT> |
| 537 | class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer : private __output_buffer<_CharT> { | 536 | class __formatted_size_buffer : private __output_buffer<_CharT> { |
| 538 | public: | 537 | public: |
| 539 | using _Base _LIBCPP_NODEBUG = __output_buffer<_CharT>; | 538 | using _Base _LIBCPP_NODEBUG = __output_buffer<_CharT>; |
| 540 | 539 | ||
| ... | @@ -577,7 +576,7 @@ private: | ... | @@ -577,7 +576,7 @@ private: |
| 577 | // This class uses its own buffer management, since using vector | 576 | // This class uses its own buffer management, since using vector |
| 578 | // would lead to a circular include with formatter for vector<bool>. | 577 | // would lead to a circular include with formatter for vector<bool>. |
| 579 | template <__fmt_char_type _CharT> | 578 | template <__fmt_char_type _CharT> |
| 580 | class _LIBCPP_TEMPLATE_VIS __retarget_buffer { | 579 | class __retarget_buffer { |
| 581 | using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>; | 580 | using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>; |
| 582 | 581 | ||
| 583 | public: | 582 | public: |
| ... | @@ -621,7 +620,7 @@ public: | ... | @@ -621,7 +620,7 @@ public: |
| 621 | } | 620 | } |
| 622 | 621 | ||
| 623 | _LIBCPP_HIDE_FROM_ABI ~__retarget_buffer() { | 622 | _LIBCPP_HIDE_FROM_ABI ~__retarget_buffer() { |
| 624 | ranges::destroy_n(__ptr_, __size_); | 623 | std::destroy_n(__ptr_, __size_); |
| 625 | allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_); | 624 | allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_); |
| 626 | } | 625 | } |
| 627 | 626 | ||
| ... | @@ -686,7 +685,7 @@ private: | ... | @@ -686,7 +685,7 @@ private: |
| 686 | // guard is optimized away so there is no runtime overhead. | 685 | // guard is optimized away so there is no runtime overhead. |
| 687 | std::uninitialized_move_n(__ptr_, __size_, __result.ptr); | 686 | std::uninitialized_move_n(__ptr_, __size_, __result.ptr); |
| 688 | __guard.__complete(); | 687 | __guard.__complete(); |
| 689 | ranges::destroy_n(__ptr_, __size_); | 688 | std::destroy_n(__ptr_, __size_); |
| 690 | allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_); | 689 | allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_); |
| 691 | 690 | ||
| 692 | __ptr_ = __result.ptr; | 691 | __ptr_ = __result.ptr; |
lib/libcxx/include/__format/container_adaptor.h+4-4| ... | @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | // adaptor headers. To use the format functions users already include <format>. | 35 | // adaptor headers. To use the format functions users already include <format>. |
| 36 | 36 | ||
| 37 | template <class _Adaptor, class _CharT> | 37 | template <class _Adaptor, class _CharT> |
| 38 | struct _LIBCPP_TEMPLATE_VIS __formatter_container_adaptor { | 38 | struct __formatter_container_adaptor { |
| 39 | private: | 39 | private: |
| 40 | using __maybe_const_container _LIBCPP_NODEBUG = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>; | 40 | using __maybe_const_container _LIBCPP_NODEBUG = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>; |
| 41 | using __maybe_const_adaptor _LIBCPP_NODEBUG = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>; | 41 | using __maybe_const_adaptor _LIBCPP_NODEBUG = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>; |
| ... | @@ -55,15 +55,15 @@ public: | ... | @@ -55,15 +55,15 @@ public: |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | template <class _CharT, class _Tp, formattable<_CharT> _Container> | 57 | template <class _CharT, class _Tp, formattable<_CharT> _Container> |
| 58 | struct _LIBCPP_TEMPLATE_VIS formatter<queue<_Tp, _Container>, _CharT> | 58 | struct formatter<queue<_Tp, _Container>, _CharT> |
| 59 | : public __formatter_container_adaptor<queue<_Tp, _Container>, _CharT> {}; | 59 | : public __formatter_container_adaptor<queue<_Tp, _Container>, _CharT> {}; |
| 60 | 60 | ||
| 61 | template <class _CharT, class _Tp, class _Container, class _Compare> | 61 | template <class _CharT, class _Tp, class _Container, class _Compare> |
| 62 | struct _LIBCPP_TEMPLATE_VIS formatter<priority_queue<_Tp, _Container, _Compare>, _CharT> | 62 | struct formatter<priority_queue<_Tp, _Container, _Compare>, _CharT> |
| 63 | : public __formatter_container_adaptor<priority_queue<_Tp, _Container, _Compare>, _CharT> {}; | 63 | : public __formatter_container_adaptor<priority_queue<_Tp, _Container, _Compare>, _CharT> {}; |
| 64 | 64 | ||
| 65 | template <class _CharT, class _Tp, formattable<_CharT> _Container> | 65 | template <class _CharT, class _Tp, formattable<_CharT> _Container> |
| 66 | struct _LIBCPP_TEMPLATE_VIS formatter<stack<_Tp, _Container>, _CharT> | 66 | struct formatter<stack<_Tp, _Container>, _CharT> |
| 67 | : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {}; | 67 | : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {}; |
| 68 | 68 | ||
| 69 | #endif // _LIBCPP_STD_VER >= 23 | 69 | #endif // _LIBCPP_STD_VER >= 23 |
lib/libcxx/include/__format/escaped_output_table.h+53-29| ... | @@ -109,7 +109,7 @@ namespace __escaped_output_table { | ... | @@ -109,7 +109,7 @@ namespace __escaped_output_table { |
| 109 | /// - bits [14, 31] The lower bound code point of the range. The upper bound of | 109 | /// - bits [14, 31] The lower bound code point of the range. The upper bound of |
| 110 | /// the range is lower bound + size. Note the code expects code units the fit | 110 | /// the range is lower bound + size. Note the code expects code units the fit |
| 111 | /// into 18 bits, instead of the 21 bits needed for the full Unicode range. | 111 | /// into 18 bits, instead of the 21 bits needed for the full Unicode range. |
| 112 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | 112 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[735] = { |
| 113 | 0x00000020 /* 00000000 - 00000020 [ 33] */, | 113 | 0x00000020 /* 00000000 - 00000020 [ 33] */, |
| 114 | 0x001fc021 /* 0000007f - 000000a0 [ 34] */, | 114 | 0x001fc021 /* 0000007f - 000000a0 [ 34] */, |
| 115 | 0x002b4000 /* 000000ad - 000000ad [ 1] */, | 115 | 0x002b4000 /* 000000ad - 000000ad [ 1] */, |
| ... | @@ -136,7 +136,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -136,7 +136,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 136 | 0x02170001 /* 0000085c - 0000085d [ 2] */, | 136 | 0x02170001 /* 0000085c - 0000085d [ 2] */, |
| 137 | 0x0217c000 /* 0000085f - 0000085f [ 1] */, | 137 | 0x0217c000 /* 0000085f - 0000085f [ 1] */, |
| 138 | 0x021ac004 /* 0000086b - 0000086f [ 5] */, | 138 | 0x021ac004 /* 0000086b - 0000086f [ 5] */, |
| 139 | 0x0223c008 /* 0000088f - 00000897 [ 9] */, | 139 | 0x0223c007 /* 0000088f - 00000896 [ 8] */, |
| 140 | 0x02388000 /* 000008e2 - 000008e2 [ 1] */, | 140 | 0x02388000 /* 000008e2 - 000008e2 [ 1] */, |
| 141 | 0x02610000 /* 00000984 - 00000984 [ 1] */, | 141 | 0x02610000 /* 00000984 - 00000984 [ 1] */, |
| 142 | 0x02634001 /* 0000098d - 0000098e [ 2] */, | 142 | 0x02634001 /* 0000098d - 0000098e [ 2] */, |
| ... | @@ -331,12 +331,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -331,12 +331,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 331 | 0x06a68005 /* 00001a9a - 00001a9f [ 6] */, | 331 | 0x06a68005 /* 00001a9a - 00001a9f [ 6] */, |
| 332 | 0x06ab8001 /* 00001aae - 00001aaf [ 2] */, | 332 | 0x06ab8001 /* 00001aae - 00001aaf [ 2] */, |
| 333 | 0x06b3c030 /* 00001acf - 00001aff [ 49] */, | 333 | 0x06b3c030 /* 00001acf - 00001aff [ 49] */, |
| 334 | 0x06d34002 /* 00001b4d - 00001b4f [ 3] */, | 334 | 0x06d34000 /* 00001b4d - 00001b4d [ 1] */, |
| 335 | 0x06dfc000 /* 00001b7f - 00001b7f [ 1] */, | ||
| 336 | 0x06fd0007 /* 00001bf4 - 00001bfb [ 8] */, | 335 | 0x06fd0007 /* 00001bf4 - 00001bfb [ 8] */, |
| 337 | 0x070e0002 /* 00001c38 - 00001c3a [ 3] */, | 336 | 0x070e0002 /* 00001c38 - 00001c3a [ 3] */, |
| 338 | 0x07128002 /* 00001c4a - 00001c4c [ 3] */, | 337 | 0x07128002 /* 00001c4a - 00001c4c [ 3] */, |
| 339 | 0x07224006 /* 00001c89 - 00001c8f [ 7] */, | 338 | 0x0722c004 /* 00001c8b - 00001c8f [ 5] */, |
| 340 | 0x072ec001 /* 00001cbb - 00001cbc [ 2] */, | 339 | 0x072ec001 /* 00001cbb - 00001cbc [ 2] */, |
| 341 | 0x07320007 /* 00001cc8 - 00001ccf [ 8] */, | 340 | 0x07320007 /* 00001cc8 - 00001ccf [ 8] */, |
| 342 | 0x073ec004 /* 00001cfb - 00001cff [ 5] */, | 341 | 0x073ec004 /* 00001cfb - 00001cff [ 5] */, |
| ... | @@ -364,7 +363,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -364,7 +363,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 364 | 0x0830400e /* 000020c1 - 000020cf [ 15] */, | 363 | 0x0830400e /* 000020c1 - 000020cf [ 15] */, |
| 365 | 0x083c400e /* 000020f1 - 000020ff [ 15] */, | 364 | 0x083c400e /* 000020f1 - 000020ff [ 15] */, |
| 366 | 0x08630003 /* 0000218c - 0000218f [ 4] */, | 365 | 0x08630003 /* 0000218c - 0000218f [ 4] */, |
| 367 | 0x0909c018 /* 00002427 - 0000243f [ 25] */, | 366 | 0x090a8015 /* 0000242a - 0000243f [ 22] */, |
| 368 | 0x0912c014 /* 0000244b - 0000245f [ 21] */, | 367 | 0x0912c014 /* 0000244b - 0000245f [ 21] */, |
| 369 | 0x0add0001 /* 00002b74 - 00002b75 [ 2] */, | 368 | 0x0add0001 /* 00002b74 - 00002b75 [ 2] */, |
| 370 | 0x0ae58000 /* 00002b96 - 00002b96 [ 1] */, | 369 | 0x0ae58000 /* 00002b96 - 00002b96 [ 1] */, |
| ... | @@ -393,16 +392,16 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -393,16 +392,16 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 393 | 0x0c400004 /* 00003100 - 00003104 [ 5] */, | 392 | 0x0c400004 /* 00003100 - 00003104 [ 5] */, |
| 394 | 0x0c4c0000 /* 00003130 - 00003130 [ 1] */, | 393 | 0x0c4c0000 /* 00003130 - 00003130 [ 1] */, |
| 395 | 0x0c63c000 /* 0000318f - 0000318f [ 1] */, | 394 | 0x0c63c000 /* 0000318f - 0000318f [ 1] */, |
| 396 | 0x0c79000a /* 000031e4 - 000031ee [ 11] */, | 395 | 0x0c798008 /* 000031e6 - 000031ee [ 9] */, |
| 397 | 0x0c87c000 /* 0000321f - 0000321f [ 1] */, | 396 | 0x0c87c000 /* 0000321f - 0000321f [ 1] */, |
| 398 | 0x29234002 /* 0000a48d - 0000a48f [ 3] */, | 397 | 0x29234002 /* 0000a48d - 0000a48f [ 3] */, |
| 399 | 0x2931c008 /* 0000a4c7 - 0000a4cf [ 9] */, | 398 | 0x2931c008 /* 0000a4c7 - 0000a4cf [ 9] */, |
| 400 | 0x298b0013 /* 0000a62c - 0000a63f [ 20] */, | 399 | 0x298b0013 /* 0000a62c - 0000a63f [ 20] */, |
| 401 | 0x29be0007 /* 0000a6f8 - 0000a6ff [ 8] */, | 400 | 0x29be0007 /* 0000a6f8 - 0000a6ff [ 8] */, |
| 402 | 0x29f2c004 /* 0000a7cb - 0000a7cf [ 5] */, | 401 | 0x29f38001 /* 0000a7ce - 0000a7cf [ 2] */, |
| 403 | 0x29f48000 /* 0000a7d2 - 0000a7d2 [ 1] */, | 402 | 0x29f48000 /* 0000a7d2 - 0000a7d2 [ 1] */, |
| 404 | 0x29f50000 /* 0000a7d4 - 0000a7d4 [ 1] */, | 403 | 0x29f50000 /* 0000a7d4 - 0000a7d4 [ 1] */, |
| 405 | 0x29f68017 /* 0000a7da - 0000a7f1 [ 24] */, | 404 | 0x29f74014 /* 0000a7dd - 0000a7f1 [ 21] */, |
| 406 | 0x2a0b4002 /* 0000a82d - 0000a82f [ 3] */, | 405 | 0x2a0b4002 /* 0000a82d - 0000a82f [ 3] */, |
| 407 | 0x2a0e8005 /* 0000a83a - 0000a83f [ 6] */, | 406 | 0x2a0e8005 /* 0000a83a - 0000a83f [ 6] */, |
| 408 | 0x2a1e0007 /* 0000a878 - 0000a87f [ 8] */, | 407 | 0x2a1e0007 /* 0000a878 - 0000a87f [ 8] */, |
| ... | @@ -491,7 +490,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -491,7 +490,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 491 | 0x41688000 /* 000105a2 - 000105a2 [ 1] */, | 490 | 0x41688000 /* 000105a2 - 000105a2 [ 1] */, |
| 492 | 0x416c8000 /* 000105b2 - 000105b2 [ 1] */, | 491 | 0x416c8000 /* 000105b2 - 000105b2 [ 1] */, |
| 493 | 0x416e8000 /* 000105ba - 000105ba [ 1] */, | 492 | 0x416e8000 /* 000105ba - 000105ba [ 1] */, |
| 494 | 0x416f4042 /* 000105bd - 000105ff [ 67] */, | 493 | 0x416f4002 /* 000105bd - 000105bf [ 3] */, |
| 494 | 0x417d000b /* 000105f4 - 000105ff [ 12] */, | ||
| 495 | 0x41cdc008 /* 00010737 - 0001073f [ 9] */, | 495 | 0x41cdc008 /* 00010737 - 0001073f [ 9] */, |
| 496 | 0x41d58009 /* 00010756 - 0001075f [ 10] */, | 496 | 0x41d58009 /* 00010756 - 0001075f [ 10] */, |
| 497 | 0x41da0017 /* 00010768 - 0001077f [ 24] */, | 497 | 0x41da0017 /* 00010768 - 0001077f [ 24] */, |
| ... | @@ -534,11 +534,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -534,11 +534,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 534 | 0x432cc00c /* 00010cb3 - 00010cbf [ 13] */, | 534 | 0x432cc00c /* 00010cb3 - 00010cbf [ 13] */, |
| 535 | 0x433cc006 /* 00010cf3 - 00010cf9 [ 7] */, | 535 | 0x433cc006 /* 00010cf3 - 00010cf9 [ 7] */, |
| 536 | 0x434a0007 /* 00010d28 - 00010d2f [ 8] */, | 536 | 0x434a0007 /* 00010d28 - 00010d2f [ 8] */, |
| 537 | 0x434e8125 /* 00010d3a - 00010e5f [ 294] */, | 537 | 0x434e8005 /* 00010d3a - 00010d3f [ 6] */, |
| 538 | 0x43598002 /* 00010d66 - 00010d68 [ 3] */, | ||
| 539 | 0x43618007 /* 00010d86 - 00010d8d [ 8] */, | ||
| 540 | 0x436400cf /* 00010d90 - 00010e5f [ 208] */, | ||
| 538 | 0x439fc000 /* 00010e7f - 00010e7f [ 1] */, | 541 | 0x439fc000 /* 00010e7f - 00010e7f [ 1] */, |
| 539 | 0x43aa8000 /* 00010eaa - 00010eaa [ 1] */, | 542 | 0x43aa8000 /* 00010eaa - 00010eaa [ 1] */, |
| 540 | 0x43ab8001 /* 00010eae - 00010eaf [ 2] */, | 543 | 0x43ab8001 /* 00010eae - 00010eaf [ 2] */, |
| 541 | 0x43ac804a /* 00010eb2 - 00010efc [ 75] */, | 544 | 0x43ac800f /* 00010eb2 - 00010ec1 [ 16] */, |
| 545 | 0x43b14036 /* 00010ec5 - 00010efb [ 55] */, | ||
| 542 | 0x43ca0007 /* 00010f28 - 00010f2f [ 8] */, | 546 | 0x43ca0007 /* 00010f28 - 00010f2f [ 8] */, |
| 543 | 0x43d68015 /* 00010f5a - 00010f6f [ 22] */, | 547 | 0x43d68015 /* 00010f5a - 00010f6f [ 22] */, |
| 544 | 0x43e28025 /* 00010f8a - 00010faf [ 38] */, | 548 | 0x43e28025 /* 00010f8a - 00010faf [ 38] */, |
| ... | @@ -578,7 +582,18 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -578,7 +582,18 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 578 | 0x44d60004 /* 00011358 - 0001135c [ 5] */, | 582 | 0x44d60004 /* 00011358 - 0001135c [ 5] */, |
| 579 | 0x44d90001 /* 00011364 - 00011365 [ 2] */, | 583 | 0x44d90001 /* 00011364 - 00011365 [ 2] */, |
| 580 | 0x44db4002 /* 0001136d - 0001136f [ 3] */, | 584 | 0x44db4002 /* 0001136d - 0001136f [ 3] */, |
| 581 | 0x44dd408a /* 00011375 - 000113ff [ 139] */, | 585 | 0x44dd400a /* 00011375 - 0001137f [ 11] */, |
| 586 | 0x44e28000 /* 0001138a - 0001138a [ 1] */, | ||
| 587 | 0x44e30001 /* 0001138c - 0001138d [ 2] */, | ||
| 588 | 0x44e3c000 /* 0001138f - 0001138f [ 1] */, | ||
| 589 | 0x44ed8000 /* 000113b6 - 000113b6 [ 1] */, | ||
| 590 | 0x44f04000 /* 000113c1 - 000113c1 [ 1] */, | ||
| 591 | 0x44f0c001 /* 000113c3 - 000113c4 [ 2] */, | ||
| 592 | 0x44f18000 /* 000113c6 - 000113c6 [ 1] */, | ||
| 593 | 0x44f2c000 /* 000113cb - 000113cb [ 1] */, | ||
| 594 | 0x44f58000 /* 000113d6 - 000113d6 [ 1] */, | ||
| 595 | 0x44f64007 /* 000113d9 - 000113e0 [ 8] */, | ||
| 596 | 0x44f8c01c /* 000113e3 - 000113ff [ 29] */, | ||
| 582 | 0x45170000 /* 0001145c - 0001145c [ 1] */, | 597 | 0x45170000 /* 0001145c - 0001145c [ 1] */, |
| 583 | 0x4518801d /* 00011462 - 0001147f [ 30] */, | 598 | 0x4518801d /* 00011462 - 0001147f [ 30] */, |
| 584 | 0x45320007 /* 000114c8 - 000114cf [ 8] */, | 599 | 0x45320007 /* 000114c8 - 000114cf [ 8] */, |
| ... | @@ -589,7 +604,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -589,7 +604,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 589 | 0x45968005 /* 0001165a - 0001165f [ 6] */, | 604 | 0x45968005 /* 0001165a - 0001165f [ 6] */, |
| 590 | 0x459b4012 /* 0001166d - 0001167f [ 19] */, | 605 | 0x459b4012 /* 0001166d - 0001167f [ 19] */, |
| 591 | 0x45ae8005 /* 000116ba - 000116bf [ 6] */, | 606 | 0x45ae8005 /* 000116ba - 000116bf [ 6] */, |
| 592 | 0x45b28035 /* 000116ca - 000116ff [ 54] */, | 607 | 0x45b28005 /* 000116ca - 000116cf [ 6] */, |
| 608 | 0x45b9001b /* 000116e4 - 000116ff [ 28] */, | ||
| 593 | 0x45c6c001 /* 0001171b - 0001171c [ 2] */, | 609 | 0x45c6c001 /* 0001171b - 0001171c [ 2] */, |
| 594 | 0x45cb0003 /* 0001172c - 0001172f [ 4] */, | 610 | 0x45cb0003 /* 0001172c - 0001172f [ 4] */, |
| 595 | 0x45d1c0b8 /* 00011747 - 000117ff [ 185] */, | 611 | 0x45d1c0b8 /* 00011747 - 000117ff [ 185] */, |
| ... | @@ -609,7 +625,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -609,7 +625,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 609 | 0x46920007 /* 00011a48 - 00011a4f [ 8] */, | 625 | 0x46920007 /* 00011a48 - 00011a4f [ 8] */, |
| 610 | 0x46a8c00c /* 00011aa3 - 00011aaf [ 13] */, | 626 | 0x46a8c00c /* 00011aa3 - 00011aaf [ 13] */, |
| 611 | 0x46be4006 /* 00011af9 - 00011aff [ 7] */, | 627 | 0x46be4006 /* 00011af9 - 00011aff [ 7] */, |
| 612 | 0x46c280f5 /* 00011b0a - 00011bff [ 246] */, | 628 | 0x46c280b5 /* 00011b0a - 00011bbf [ 182] */, |
| 629 | 0x46f8800d /* 00011be2 - 00011bef [ 14] */, | ||
| 630 | 0x46fe8005 /* 00011bfa - 00011bff [ 6] */, | ||
| 613 | 0x47024000 /* 00011c09 - 00011c09 [ 1] */, | 631 | 0x47024000 /* 00011c09 - 00011c09 [ 1] */, |
| 614 | 0x470dc000 /* 00011c37 - 00011c37 [ 1] */, | 632 | 0x470dc000 /* 00011c37 - 00011c37 [ 1] */, |
| 615 | 0x47118009 /* 00011c46 - 00011c4f [ 10] */, | 633 | 0x47118009 /* 00011c46 - 00011c4f [ 10] */, |
| ... | @@ -633,7 +651,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -633,7 +651,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 633 | 0x47be4006 /* 00011ef9 - 00011eff [ 7] */, | 651 | 0x47be4006 /* 00011ef9 - 00011eff [ 7] */, |
| 634 | 0x47c44000 /* 00011f11 - 00011f11 [ 1] */, | 652 | 0x47c44000 /* 00011f11 - 00011f11 [ 1] */, |
| 635 | 0x47cec002 /* 00011f3b - 00011f3d [ 3] */, | 653 | 0x47cec002 /* 00011f3b - 00011f3d [ 3] */, |
| 636 | 0x47d68055 /* 00011f5a - 00011faf [ 86] */, | 654 | 0x47d6c054 /* 00011f5b - 00011faf [ 85] */, |
| 637 | 0x47ec400e /* 00011fb1 - 00011fbf [ 15] */, | 655 | 0x47ec400e /* 00011fb1 - 00011fbf [ 15] */, |
| 638 | 0x47fc800c /* 00011ff2 - 00011ffe [ 13] */, | 656 | 0x47fc800c /* 00011ff2 - 00011ffe [ 13] */, |
| 639 | 0x48e68065 /* 0001239a - 000123ff [ 102] */, | 657 | 0x48e68065 /* 0001239a - 000123ff [ 102] */, |
| ... | @@ -642,8 +660,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -642,8 +660,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 642 | 0x49510a4b /* 00012544 - 00012f8f [ 2636] */, | 660 | 0x49510a4b /* 00012544 - 00012f8f [ 2636] */, |
| 643 | 0x4bfcc00c /* 00012ff3 - 00012fff [ 13] */, | 661 | 0x4bfcc00c /* 00012ff3 - 00012fff [ 13] */, |
| 644 | 0x4d0c000f /* 00013430 - 0001343f [ 16] */, | 662 | 0x4d0c000f /* 00013430 - 0001343f [ 16] */, |
| 645 | 0x4d158fa9 /* 00013456 - 000143ff [ 4010] */, | 663 | 0x4d158009 /* 00013456 - 0001345f [ 10] */, |
| 646 | 0x5191e1b8 /* 00014647 - 000167ff [ 8633] */, | 664 | 0x50fec004 /* 000143fb - 000143ff [ 5] */, |
| 665 | 0x5191dab8 /* 00014647 - 000160ff [ 6841] */, | ||
| 666 | 0x584e86c5 /* 0001613a - 000167ff [ 1734] */, | ||
| 647 | 0x5a8e4006 /* 00016a39 - 00016a3f [ 7] */, | 667 | 0x5a8e4006 /* 00016a39 - 00016a3f [ 7] */, |
| 648 | 0x5a97c000 /* 00016a5f - 00016a5f [ 1] */, | 668 | 0x5a97c000 /* 00016a5f - 00016a5f [ 1] */, |
| 649 | 0x5a9a8003 /* 00016a6a - 00016a6d [ 4] */, | 669 | 0x5a9a8003 /* 00016a6a - 00016a6d [ 4] */, |
| ... | @@ -655,7 +675,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -655,7 +675,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 655 | 0x5ad68000 /* 00016b5a - 00016b5a [ 1] */, | 675 | 0x5ad68000 /* 00016b5a - 00016b5a [ 1] */, |
| 656 | 0x5ad88000 /* 00016b62 - 00016b62 [ 1] */, | 676 | 0x5ad88000 /* 00016b62 - 00016b62 [ 1] */, |
| 657 | 0x5ade0004 /* 00016b78 - 00016b7c [ 5] */, | 677 | 0x5ade0004 /* 00016b78 - 00016b7c [ 5] */, |
| 658 | 0x5ae402af /* 00016b90 - 00016e3f [ 688] */, | 678 | 0x5ae401af /* 00016b90 - 00016d3f [ 432] */, |
| 679 | 0x5b5e80c5 /* 00016d7a - 00016e3f [ 198] */, | ||
| 659 | 0x5ba6c064 /* 00016e9b - 00016eff [ 101] */, | 680 | 0x5ba6c064 /* 00016e9b - 00016eff [ 101] */, |
| 660 | 0x5bd2c003 /* 00016f4b - 00016f4e [ 4] */, | 681 | 0x5bd2c003 /* 00016f4b - 00016f4e [ 4] */, |
| 661 | 0x5be20006 /* 00016f88 - 00016f8e [ 7] */, | 682 | 0x5be20006 /* 00016f88 - 00016f8e [ 7] */, |
| ... | @@ -663,7 +684,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -663,7 +684,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 663 | 0x5bf9400a /* 00016fe5 - 00016fef [ 11] */, | 684 | 0x5bf9400a /* 00016fe5 - 00016fef [ 11] */, |
| 664 | 0x5bfc800d /* 00016ff2 - 00016fff [ 14] */, | 685 | 0x5bfc800d /* 00016ff2 - 00016fff [ 14] */, |
| 665 | 0x61fe0007 /* 000187f8 - 000187ff [ 8] */, | 686 | 0x61fe0007 /* 000187f8 - 000187ff [ 8] */, |
| 666 | 0x63358029 /* 00018cd6 - 00018cff [ 42] */, | 687 | 0x63358028 /* 00018cd6 - 00018cfe [ 41] */, |
| 667 | 0x634262e6 /* 00018d09 - 0001afef [ 8935] */, | 688 | 0x634262e6 /* 00018d09 - 0001afef [ 8935] */, |
| 668 | 0x6bfd0000 /* 0001aff4 - 0001aff4 [ 1] */, | 689 | 0x6bfd0000 /* 0001aff4 - 0001aff4 [ 1] */, |
| 669 | 0x6bff0000 /* 0001affc - 0001affc [ 1] */, | 690 | 0x6bff0000 /* 0001affc - 0001affc [ 1] */, |
| ... | @@ -678,7 +699,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -678,7 +699,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 678 | 0x6f1f4002 /* 0001bc7d - 0001bc7f [ 3] */, | 699 | 0x6f1f4002 /* 0001bc7d - 0001bc7f [ 3] */, |
| 679 | 0x6f224006 /* 0001bc89 - 0001bc8f [ 7] */, | 700 | 0x6f224006 /* 0001bc89 - 0001bc8f [ 7] */, |
| 680 | 0x6f268001 /* 0001bc9a - 0001bc9b [ 2] */, | 701 | 0x6f268001 /* 0001bc9a - 0001bc9b [ 2] */, |
| 681 | 0x6f28125f /* 0001bca0 - 0001ceff [ 4704] */, | 702 | 0x6f280f5f /* 0001bca0 - 0001cbff [ 3936] */, |
| 703 | 0x733e8005 /* 0001ccfa - 0001ccff [ 6] */, | ||
| 704 | 0x73ad004b /* 0001ceb4 - 0001ceff [ 76] */, | ||
| 682 | 0x73cb8001 /* 0001cf2e - 0001cf2f [ 2] */, | 705 | 0x73cb8001 /* 0001cf2e - 0001cf2f [ 2] */, |
| 683 | 0x73d1c008 /* 0001cf47 - 0001cf4f [ 9] */, | 706 | 0x73d1c008 /* 0001cf47 - 0001cf4f [ 9] */, |
| 684 | 0x73f1003b /* 0001cfc4 - 0001cfff [ 60] */, | 707 | 0x73f1003b /* 0001cfc4 - 0001cfff [ 60] */, |
| ... | @@ -730,7 +753,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -730,7 +753,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 730 | 0x78abc010 /* 0001e2af - 0001e2bf [ 17] */, | 753 | 0x78abc010 /* 0001e2af - 0001e2bf [ 17] */, |
| 731 | 0x78be8004 /* 0001e2fa - 0001e2fe [ 5] */, | 754 | 0x78be8004 /* 0001e2fa - 0001e2fe [ 5] */, |
| 732 | 0x78c001cf /* 0001e300 - 0001e4cf [ 464] */, | 755 | 0x78c001cf /* 0001e300 - 0001e4cf [ 464] */, |
| 733 | 0x793e82e5 /* 0001e4fa - 0001e7df [ 742] */, | 756 | 0x793e80d5 /* 0001e4fa - 0001e5cf [ 214] */, |
| 757 | 0x797ec003 /* 0001e5fb - 0001e5fe [ 4] */, | ||
| 758 | 0x798001df /* 0001e600 - 0001e7df [ 480] */, | ||
| 734 | 0x79f9c000 /* 0001e7e7 - 0001e7e7 [ 1] */, | 759 | 0x79f9c000 /* 0001e7e7 - 0001e7e7 [ 1] */, |
| 735 | 0x79fb0000 /* 0001e7ec - 0001e7ec [ 1] */, | 760 | 0x79fb0000 /* 0001e7ec - 0001e7ec [ 1] */, |
| 736 | 0x79fbc000 /* 0001e7ef - 0001e7ef [ 1] */, | 761 | 0x79fbc000 /* 0001e7ef - 0001e7ef [ 1] */, |
| ... | @@ -800,18 +825,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { | ... | @@ -800,18 +825,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 800 | 0x7e168005 /* 0001f85a - 0001f85f [ 6] */, | 825 | 0x7e168005 /* 0001f85a - 0001f85f [ 6] */, |
| 801 | 0x7e220007 /* 0001f888 - 0001f88f [ 8] */, | 826 | 0x7e220007 /* 0001f888 - 0001f88f [ 8] */, |
| 802 | 0x7e2b8001 /* 0001f8ae - 0001f8af [ 2] */, | 827 | 0x7e2b8001 /* 0001f8ae - 0001f8af [ 2] */, |
| 803 | 0x7e2c804d /* 0001f8b2 - 0001f8ff [ 78] */, | 828 | 0x7e2f0003 /* 0001f8bc - 0001f8bf [ 4] */, |
| 829 | 0x7e30803d /* 0001f8c2 - 0001f8ff [ 62] */, | ||
| 804 | 0x7e95000b /* 0001fa54 - 0001fa5f [ 12] */, | 830 | 0x7e95000b /* 0001fa54 - 0001fa5f [ 12] */, |
| 805 | 0x7e9b8001 /* 0001fa6e - 0001fa6f [ 2] */, | 831 | 0x7e9b8001 /* 0001fa6e - 0001fa6f [ 2] */, |
| 806 | 0x7e9f4002 /* 0001fa7d - 0001fa7f [ 3] */, | 832 | 0x7e9f4002 /* 0001fa7d - 0001fa7f [ 3] */, |
| 807 | 0x7ea24006 /* 0001fa89 - 0001fa8f [ 7] */, | 833 | 0x7ea28004 /* 0001fa8a - 0001fa8e [ 5] */, |
| 808 | 0x7eaf8000 /* 0001fabe - 0001fabe [ 1] */, | 834 | 0x7eb1c006 /* 0001fac7 - 0001facd [ 7] */, |
| 809 | 0x7eb18007 /* 0001fac6 - 0001facd [ 8] */, | 835 | 0x7eb74001 /* 0001fadd - 0001fade [ 2] */, |
| 810 | 0x7eb70003 /* 0001fadc - 0001fadf [ 4] */, | 836 | 0x7eba8005 /* 0001faea - 0001faef [ 6] */, |
| 811 | 0x7eba4006 /* 0001fae9 - 0001faef [ 7] */, | ||
| 812 | 0x7ebe4006 /* 0001faf9 - 0001faff [ 7] */, | 837 | 0x7ebe4006 /* 0001faf9 - 0001faff [ 7] */, |
| 813 | 0x7ee4c000 /* 0001fb93 - 0001fb93 [ 1] */, | 838 | 0x7ee4c000 /* 0001fb93 - 0001fb93 [ 1] */, |
| 814 | 0x7ef2c024 /* 0001fbcb - 0001fbef [ 37] */, | ||
| 815 | 0x7efe8405 /* 0001fbfa - 0001ffff [ 1030] */, | 839 | 0x7efe8405 /* 0001fbfa - 0001ffff [ 1030] */, |
| 816 | 0xa9b8001f /* 0002a6e0 - 0002a6ff [ 32] */, | 840 | 0xa9b8001f /* 0002a6e0 - 0002a6ff [ 32] */, |
| 817 | 0xadce8005 /* 0002b73a - 0002b73f [ 6] */, | 841 | 0xadce8005 /* 0002b73a - 0002b73f [ 6] */, |
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+52-47| ... | @@ -125,7 +125,7 @@ enum class __property : uint8_t { | ... | @@ -125,7 +125,7 @@ enum class __property : uint8_t { |
| 125 | /// following benchmark. | 125 | /// following benchmark. |
| 126 | /// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp | 126 | /// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp |
| 127 | // clang-format off | 127 | // clang-format off |
| 128 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | 128 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1501] = { |
| 129 | 0x00000091, | 129 | 0x00000091, |
| 130 | 0x00005005, | 130 | 0x00005005, |
| 131 | 0x00005811, | 131 | 0x00005811, |
| ... | @@ -164,7 +164,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -164,7 +164,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 164 | 0x00414842, | 164 | 0x00414842, |
| 165 | 0x0042c822, | 165 | 0x0042c822, |
| 166 | 0x00448018, | 166 | 0x00448018, |
| 167 | 0x0044c072, | 167 | 0x0044b882, |
| 168 | 0x00465172, | 168 | 0x00465172, |
| 169 | 0x00471008, | 169 | 0x00471008, |
| 170 | 0x004719f2, | 170 | 0x004719f2, |
| ... | @@ -246,14 +246,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -246,14 +246,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 246 | 0x0064101a, | 246 | 0x0064101a, |
| 247 | 0x0065e002, | 247 | 0x0065e002, |
| 248 | 0x0065f00a, | 248 | 0x0065f00a, |
| 249 | 0x0065f802, | 249 | 0x0065f812, |
| 250 | 0x0066001a, | 250 | 0x0066080a, |
| 251 | 0x00661002, | 251 | 0x00661002, |
| 252 | 0x0066181a, | 252 | 0x0066181a, |
| 253 | 0x00663002, | 253 | 0x00663022, |
| 254 | 0x0066381a, | 254 | 0x00665032, |
| 255 | 0x0066501a, | ||
| 256 | 0x00666012, | ||
| 257 | 0x0066a812, | 255 | 0x0066a812, |
| 258 | 0x00671012, | 256 | 0x00671012, |
| 259 | 0x0067980a, | 257 | 0x0067980a, |
| ... | @@ -318,10 +316,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -318,10 +316,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 318 | 0x008b047c, | 316 | 0x008b047c, |
| 319 | 0x008d457b, | 317 | 0x008d457b, |
| 320 | 0x009ae822, | 318 | 0x009ae822, |
| 321 | 0x00b89022, | 319 | 0x00b89032, |
| 322 | 0x00b8a80a, | 320 | 0x00b99022, |
| 323 | 0x00b99012, | ||
| 324 | 0x00b9a00a, | ||
| 325 | 0x00ba9012, | 321 | 0x00ba9012, |
| 326 | 0x00bb9012, | 322 | 0x00bb9012, |
| 327 | 0x00bda012, | 323 | 0x00bda012, |
| ... | @@ -361,29 +357,23 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -361,29 +357,23 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 361 | 0x00d581e2, | 357 | 0x00d581e2, |
| 362 | 0x00d80032, | 358 | 0x00d80032, |
| 363 | 0x00d8200a, | 359 | 0x00d8200a, |
| 364 | 0x00d9a062, | 360 | 0x00d9a092, |
| 365 | 0x00d9d80a, | 361 | 0x00d9f03a, |
| 366 | 0x00d9e002, | 362 | 0x00da1022, |
| 367 | 0x00d9e84a, | ||
| 368 | 0x00da1002, | ||
| 369 | 0x00da181a, | ||
| 370 | 0x00db5882, | 363 | 0x00db5882, |
| 371 | 0x00dc0012, | 364 | 0x00dc0012, |
| 372 | 0x00dc100a, | 365 | 0x00dc100a, |
| 373 | 0x00dd080a, | 366 | 0x00dd080a, |
| 374 | 0x00dd1032, | 367 | 0x00dd1032, |
| 375 | 0x00dd301a, | 368 | 0x00dd301a, |
| 376 | 0x00dd4012, | 369 | 0x00dd4052, |
| 377 | 0x00dd500a, | ||
| 378 | 0x00dd5822, | ||
| 379 | 0x00df3002, | 370 | 0x00df3002, |
| 380 | 0x00df380a, | 371 | 0x00df380a, |
| 381 | 0x00df4012, | 372 | 0x00df4012, |
| 382 | 0x00df502a, | 373 | 0x00df502a, |
| 383 | 0x00df6802, | 374 | 0x00df6802, |
| 384 | 0x00df700a, | 375 | 0x00df700a, |
| 385 | 0x00df7822, | 376 | 0x00df7842, |
| 386 | 0x00df901a, | ||
| 387 | 0x00e1207a, | 377 | 0x00e1207a, |
| 388 | 0x00e16072, | 378 | 0x00e16072, |
| 389 | 0x00e1a01a, | 379 | 0x00e1a01a, |
| ... | @@ -475,7 +465,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -475,7 +465,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 475 | 0x0547f802, | 465 | 0x0547f802, |
| 476 | 0x05493072, | 466 | 0x05493072, |
| 477 | 0x054a38a2, | 467 | 0x054a38a2, |
| 478 | 0x054a901a, | 468 | 0x054a900a, |
| 469 | 0x054a9802, | ||
| 479 | 0x054b01c4, | 470 | 0x054b01c4, |
| 480 | 0x054c0022, | 471 | 0x054c0022, |
| 481 | 0x054c180a, | 472 | 0x054c180a, |
| ... | @@ -484,7 +475,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -484,7 +475,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 484 | 0x054db032, | 475 | 0x054db032, |
| 485 | 0x054dd01a, | 476 | 0x054dd01a, |
| 486 | 0x054de012, | 477 | 0x054de012, |
| 487 | 0x054df02a, | 478 | 0x054df01a, |
| 479 | 0x054e0002, | ||
| 488 | 0x054f2802, | 480 | 0x054f2802, |
| 489 | 0x05514852, | 481 | 0x05514852, |
| 490 | 0x0551781a, | 482 | 0x0551781a, |
| ... | @@ -1328,8 +1320,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1328,8 +1320,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1328 | 0x0851f802, | 1320 | 0x0851f802, |
| 1329 | 0x08572812, | 1321 | 0x08572812, |
| 1330 | 0x08692032, | 1322 | 0x08692032, |
| 1323 | 0x086b4842, | ||
| 1331 | 0x08755812, | 1324 | 0x08755812, |
| 1332 | 0x0877e822, | 1325 | 0x0877e032, |
| 1333 | 0x087a30a2, | 1326 | 0x087a30a2, |
| 1334 | 0x087c1032, | 1327 | 0x087c1032, |
| 1335 | 0x0880000a, | 1328 | 0x0880000a, |
| ... | @@ -1357,7 +1350,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1357,7 +1350,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1357 | 0x088c100a, | 1350 | 0x088c100a, |
| 1358 | 0x088d982a, | 1351 | 0x088d982a, |
| 1359 | 0x088db082, | 1352 | 0x088db082, |
| 1360 | 0x088df81a, | 1353 | 0x088df80a, |
| 1354 | 0x088e0002, | ||
| 1361 | 0x088e1018, | 1355 | 0x088e1018, |
| 1362 | 0x088e4832, | 1356 | 0x088e4832, |
| 1363 | 0x088e700a, | 1357 | 0x088e700a, |
| ... | @@ -1365,9 +1359,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1365,9 +1359,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1365 | 0x0891602a, | 1359 | 0x0891602a, |
| 1366 | 0x08917822, | 1360 | 0x08917822, |
| 1367 | 0x0891901a, | 1361 | 0x0891901a, |
| 1368 | 0x0891a002, | 1362 | 0x0891a032, |
| 1369 | 0x0891a80a, | ||
| 1370 | 0x0891b012, | ||
| 1371 | 0x0891f002, | 1363 | 0x0891f002, |
| 1372 | 0x08920802, | 1364 | 0x08920802, |
| 1373 | 0x0896f802, | 1365 | 0x0896f802, |
| ... | @@ -1381,11 +1373,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1381,11 +1373,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1381 | 0x089a0002, | 1373 | 0x089a0002, |
| 1382 | 0x089a083a, | 1374 | 0x089a083a, |
| 1383 | 0x089a381a, | 1375 | 0x089a381a, |
| 1384 | 0x089a582a, | 1376 | 0x089a581a, |
| 1377 | 0x089a6802, | ||
| 1385 | 0x089ab802, | 1378 | 0x089ab802, |
| 1386 | 0x089b101a, | 1379 | 0x089b101a, |
| 1387 | 0x089b3062, | 1380 | 0x089b3062, |
| 1388 | 0x089b8042, | 1381 | 0x089b8042, |
| 1382 | 0x089dc002, | ||
| 1383 | 0x089dc81a, | ||
| 1384 | 0x089dd852, | ||
| 1385 | 0x089e1002, | ||
| 1386 | 0x089e2802, | ||
| 1387 | 0x089e3822, | ||
| 1388 | 0x089e500a, | ||
| 1389 | 0x089e601a, | ||
| 1390 | 0x089e7022, | ||
| 1391 | 0x089e8808, | ||
| 1392 | 0x089e9002, | ||
| 1393 | 0x089f0812, | ||
| 1389 | 0x08a1a82a, | 1394 | 0x08a1a82a, |
| 1390 | 0x08a1c072, | 1395 | 0x08a1c072, |
| 1391 | 0x08a2001a, | 1396 | 0x08a2001a, |
| ... | @@ -1422,10 +1427,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1422,10 +1427,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1422 | 0x08b5600a, | 1427 | 0x08b5600a, |
| 1423 | 0x08b56802, | 1428 | 0x08b56802, |
| 1424 | 0x08b5701a, | 1429 | 0x08b5701a, |
| 1425 | 0x08b58052, | 1430 | 0x08b58072, |
| 1426 | 0x08b5b00a, | 1431 | 0x08b8e802, |
| 1427 | 0x08b5b802, | 1432 | 0x08b8f00a, |
| 1428 | 0x08b8e822, | 1433 | 0x08b8f802, |
| 1429 | 0x08b91032, | 1434 | 0x08b91032, |
| 1430 | 0x08b9300a, | 1435 | 0x08b9300a, |
| 1431 | 0x08b93842, | 1436 | 0x08b93842, |
| ... | @@ -1436,9 +1441,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1436,9 +1441,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1436 | 0x08c98002, | 1441 | 0x08c98002, |
| 1437 | 0x08c9884a, | 1442 | 0x08c9884a, |
| 1438 | 0x08c9b81a, | 1443 | 0x08c9b81a, |
| 1439 | 0x08c9d812, | 1444 | 0x08c9d832, |
| 1440 | 0x08c9e80a, | ||
| 1441 | 0x08c9f002, | ||
| 1442 | 0x08c9f808, | 1445 | 0x08c9f808, |
| 1443 | 0x08ca000a, | 1446 | 0x08ca000a, |
| 1444 | 0x08ca0808, | 1447 | 0x08ca0808, |
| ... | @@ -1495,28 +1498,29 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1495,28 +1498,29 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1495 | 0x08f9a01a, | 1498 | 0x08f9a01a, |
| 1496 | 0x08f9b042, | 1499 | 0x08f9b042, |
| 1497 | 0x08f9f01a, | 1500 | 0x08f9f01a, |
| 1498 | 0x08fa0002, | 1501 | 0x08fa0022, |
| 1499 | 0x08fa080a, | 1502 | 0x08fad002, |
| 1500 | 0x08fa1002, | ||
| 1501 | 0x09a180f1, | 1503 | 0x09a180f1, |
| 1502 | 0x09a20002, | 1504 | 0x09a20002, |
| 1503 | 0x09a238e2, | 1505 | 0x09a238e2, |
| 1506 | 0x0b08f0b2, | ||
| 1507 | 0x0b09502a, | ||
| 1508 | 0x0b096822, | ||
| 1504 | 0x0b578042, | 1509 | 0x0b578042, |
| 1505 | 0x0b598062, | 1510 | 0x0b598062, |
| 1511 | 0x0b6b180c, | ||
| 1512 | 0x0b6b383c, | ||
| 1506 | 0x0b7a7802, | 1513 | 0x0b7a7802, |
| 1507 | 0x0b7a8b6a, | 1514 | 0x0b7a8b6a, |
| 1508 | 0x0b7c7832, | 1515 | 0x0b7c7832, |
| 1509 | 0x0b7f2002, | 1516 | 0x0b7f2002, |
| 1510 | 0x0b7f801a, | 1517 | 0x0b7f8012, |
| 1511 | 0x0de4e812, | 1518 | 0x0de4e812, |
| 1512 | 0x0de50031, | 1519 | 0x0de50031, |
| 1513 | 0x0e7802d2, | 1520 | 0x0e7802d2, |
| 1514 | 0x0e798162, | 1521 | 0x0e798162, |
| 1515 | 0x0e8b2802, | 1522 | 0x0e8b2842, |
| 1516 | 0x0e8b300a, | 1523 | 0x0e8b6852, |
| 1517 | 0x0e8b3822, | ||
| 1518 | 0x0e8b680a, | ||
| 1519 | 0x0e8b7042, | ||
| 1520 | 0x0e8b9871, | 1524 | 0x0e8b9871, |
| 1521 | 0x0e8bd872, | 1525 | 0x0e8bd872, |
| 1522 | 0x0e8c2862, | 1526 | 0x0e8c2862, |
| ... | @@ -1538,6 +1542,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { | ... | @@ -1538,6 +1542,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1538 | 0x0f157002, | 1542 | 0x0f157002, |
| 1539 | 0x0f176032, | 1543 | 0x0f176032, |
| 1540 | 0x0f276032, | 1544 | 0x0f276032, |
| 1545 | 0x0f2f7012, | ||
| 1541 | 0x0f468062, | 1546 | 0x0f468062, |
| 1542 | 0x0f4a2062, | 1547 | 0x0f4a2062, |
| 1543 | 0x0f8007f3, | 1548 | 0x0f8007f3, |
lib/libcxx/include/__format/format_arg.h+3-3| ... | @@ -277,9 +277,9 @@ public: | ... | @@ -277,9 +277,9 @@ public: |
| 277 | }; | 277 | }; |
| 278 | 278 | ||
| 279 | template <class _Context> | 279 | template <class _Context> |
| 280 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS basic_format_arg { | 280 | class _LIBCPP_NO_SPECIALIZATIONS basic_format_arg { |
| 281 | public: | 281 | public: |
| 282 | class _LIBCPP_TEMPLATE_VIS handle; | 282 | class handle; |
| 283 | 283 | ||
| 284 | _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept : __type_{__format::__arg_t::__none} {} | 284 | _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept : __type_{__format::__arg_t::__none} {} |
| 285 | 285 | ||
| ... | @@ -355,7 +355,7 @@ public: | ... | @@ -355,7 +355,7 @@ public: |
| 355 | }; | 355 | }; |
| 356 | 356 | ||
| 357 | template <class _Context> | 357 | template <class _Context> |
| 358 | class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle { | 358 | class basic_format_arg<_Context>::handle { |
| 359 | public: | 359 | public: |
| 360 | _LIBCPP_HIDE_FROM_ABI void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const { | 360 | _LIBCPP_HIDE_FROM_ABI void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const { |
| 361 | __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_); | 361 | __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_); |
lib/libcxx/include/__format/format_arg_store.h+24-14| ... | @@ -14,13 +14,14 @@ | ... | @@ -14,13 +14,14 @@ |
| 14 | # pragma GCC system_header | 14 | # pragma GCC system_header |
| 15 | #endif | 15 | #endif |
| 16 | 16 | ||
| 17 | #include <__concepts/arithmetic.h> | ||
| 18 | #include <__concepts/same_as.h> | 17 | #include <__concepts/same_as.h> |
| 19 | #include <__config> | 18 | #include <__config> |
| 19 | #include <__cstddef/size_t.h> | ||
| 20 | #include <__format/concepts.h> | 20 | #include <__format/concepts.h> |
| 21 | #include <__format/format_arg.h> | 21 | #include <__format/format_arg.h> |
| 22 | #include <__type_traits/conditional.h> | 22 | #include <__type_traits/conditional.h> |
| 23 | #include <__type_traits/extent.h> | 23 | #include <__type_traits/extent.h> |
| 24 | #include <__type_traits/integer_traits.h> | ||
| 24 | #include <__type_traits/remove_const.h> | 25 | #include <__type_traits/remove_const.h> |
| 25 | #include <cstdint> | 26 | #include <cstdint> |
| 26 | #include <string> | 27 | #include <string> |
| ... | @@ -32,6 +33,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -32,6 +33,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 33 | ||
| 33 | namespace __format { | 34 | namespace __format { |
| 34 | 35 | ||
| 36 | template <class _Arr, class _Elem> | ||
| 37 | inline constexpr bool __is_bounded_array_of = false; | ||
| 38 | |||
| 39 | template <class _Elem, size_t _Len> | ||
| 40 | inline constexpr bool __is_bounded_array_of<_Elem[_Len], _Elem> = true; | ||
| 41 | |||
| 35 | /// \returns The @c __arg_t based on the type of the formatting argument. | 42 | /// \returns The @c __arg_t based on the type of the formatting argument. |
| 36 | /// | 43 | /// |
| 37 | /// \pre \c __formattable<_Tp, typename _Context::char_type> | 44 | /// \pre \c __formattable<_Tp, typename _Context::char_type> |
| ... | @@ -58,7 +65,7 @@ consteval __arg_t __determine_arg_t() { | ... | @@ -58,7 +65,7 @@ consteval __arg_t __determine_arg_t() { |
| 58 | # endif | 65 | # endif |
| 59 | 66 | ||
| 60 | // Signed integers | 67 | // Signed integers |
| 61 | template <class, __libcpp_signed_integer _Tp> | 68 | template <class, __signed_integer _Tp> |
| 62 | consteval __arg_t __determine_arg_t() { | 69 | consteval __arg_t __determine_arg_t() { |
| 63 | if constexpr (sizeof(_Tp) <= sizeof(int)) | 70 | if constexpr (sizeof(_Tp) <= sizeof(int)) |
| 64 | return __arg_t::__int; | 71 | return __arg_t::__int; |
| ... | @@ -73,7 +80,7 @@ consteval __arg_t __determine_arg_t() { | ... | @@ -73,7 +80,7 @@ consteval __arg_t __determine_arg_t() { |
| 73 | } | 80 | } |
| 74 | 81 | ||
| 75 | // Unsigned integers | 82 | // Unsigned integers |
| 76 | template <class, __libcpp_unsigned_integer _Tp> | 83 | template <class, __unsigned_integer _Tp> |
| 77 | consteval __arg_t __determine_arg_t() { | 84 | consteval __arg_t __determine_arg_t() { |
| 78 | if constexpr (sizeof(_Tp) <= sizeof(unsigned)) | 85 | if constexpr (sizeof(_Tp) <= sizeof(unsigned)) |
| 79 | return __arg_t::__unsigned; | 86 | return __arg_t::__unsigned; |
| ... | @@ -110,7 +117,7 @@ consteval __arg_t __determine_arg_t() { | ... | @@ -110,7 +117,7 @@ consteval __arg_t __determine_arg_t() { |
| 110 | 117 | ||
| 111 | // Char array | 118 | // Char array |
| 112 | template <class _Context, class _Tp> | 119 | template <class _Context, class _Tp> |
| 113 | requires(is_array_v<_Tp> && same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>) | 120 | requires __is_bounded_array_of<_Tp, typename _Context::char_type> |
| 114 | consteval __arg_t __determine_arg_t() { | 121 | consteval __arg_t __determine_arg_t() { |
| 115 | return __arg_t::__string_view; | 122 | return __arg_t::__string_view; |
| 116 | } | 123 | } |
| ... | @@ -164,17 +171,18 @@ consteval __arg_t __determine_arg_t() { | ... | @@ -164,17 +171,18 @@ consteval __arg_t __determine_arg_t() { |
| 164 | template <class _Context, class _Tp> | 171 | template <class _Context, class _Tp> |
| 165 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __value) noexcept { | 172 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __value) noexcept { |
| 166 | using _Dp = remove_const_t<_Tp>; | 173 | using _Dp = remove_const_t<_Tp>; |
| 167 | constexpr __arg_t __arg = __determine_arg_t<_Context, _Dp>(); | 174 | constexpr __arg_t __arg = __format::__determine_arg_t<_Context, _Dp>(); |
| 168 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); | 175 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); |
| 169 | static_assert(__formattable_with<_Tp, _Context>); | 176 | static_assert(__formattable_with<_Tp, _Context>); |
| 170 | 177 | ||
| 178 | using __context_char_type = _Context::char_type; | ||
| 171 | // Not all types can be used to directly initialize the | 179 | // Not all types can be used to directly initialize the |
| 172 | // __basic_format_arg_value. First handle all types needing adjustment, the | 180 | // __basic_format_arg_value. First handle all types needing adjustment, the |
| 173 | // final else requires no adjustment. | 181 | // final else requires no adjustment. |
| 174 | if constexpr (__arg == __arg_t::__char_type) | 182 | if constexpr (__arg == __arg_t::__char_type) |
| 175 | 183 | ||
| 176 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 184 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 177 | if constexpr (same_as<typename _Context::char_type, wchar_t> && same_as<_Dp, char>) | 185 | if constexpr (same_as<__context_char_type, wchar_t> && same_as<_Dp, char>) |
| 178 | return basic_format_arg<_Context>{__arg, static_cast<wchar_t>(static_cast<unsigned char>(__value))}; | 186 | return basic_format_arg<_Context>{__arg, static_cast<wchar_t>(static_cast<unsigned char>(__value))}; |
| 179 | else | 187 | else |
| 180 | # endif | 188 | # endif |
| ... | @@ -189,14 +197,16 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu | ... | @@ -189,14 +197,16 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu |
| 189 | return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)}; | 197 | return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)}; |
| 190 | else if constexpr (__arg == __arg_t::__string_view) | 198 | else if constexpr (__arg == __arg_t::__string_view) |
| 191 | // Using std::size on a character array will add the NUL-terminator to the size. | 199 | // Using std::size on a character array will add the NUL-terminator to the size. |
| 192 | if constexpr (is_array_v<_Dp>) | 200 | if constexpr (__is_bounded_array_of<_Dp, __context_char_type>) { |
| 193 | return basic_format_arg<_Context>{ | 201 | const __context_char_type* const __pbegin = std::begin(__value); |
| 194 | __arg, basic_string_view<typename _Context::char_type>{__value, extent_v<_Dp> - 1}}; | 202 | const __context_char_type* const __pzero = |
| 195 | else | 203 | char_traits<__context_char_type>::find(__pbegin, extent_v<_Dp>, __context_char_type{}); |
| 196 | // When the _Traits or _Allocator are different an implicit conversion will | 204 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__pzero != nullptr, "formatting a non-null-terminated array"); |
| 197 | // fail. | ||
| 198 | return basic_format_arg<_Context>{ | 205 | return basic_format_arg<_Context>{ |
| 199 | __arg, basic_string_view<typename _Context::char_type>{__value.data(), __value.size()}}; | 206 | __arg, basic_string_view<__context_char_type>{__pbegin, static_cast<size_t>(__pzero - __pbegin)}}; |
| 207 | } else | ||
| 208 | // When the _Traits or _Allocator are different an implicit conversion will fail. | ||
| 209 | return basic_format_arg<_Context>{__arg, basic_string_view<__context_char_type>{__value.data(), __value.size()}}; | ||
| 200 | else if constexpr (__arg == __arg_t::__ptr) | 210 | else if constexpr (__arg == __arg_t::__ptr) |
| 201 | return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)}; | 211 | return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)}; |
| 202 | else if constexpr (__arg == __arg_t::__handle) | 212 | else if constexpr (__arg == __arg_t::__handle) |
| ... | @@ -247,7 +257,7 @@ struct __unpacked_format_arg_store { | ... | @@ -247,7 +257,7 @@ struct __unpacked_format_arg_store { |
| 247 | } // namespace __format | 257 | } // namespace __format |
| 248 | 258 | ||
| 249 | template <class _Context, class... _Args> | 259 | template <class _Context, class... _Args> |
| 250 | struct _LIBCPP_TEMPLATE_VIS __format_arg_store { | 260 | struct __format_arg_store { |
| 251 | _LIBCPP_HIDE_FROM_ABI __format_arg_store(_Args&... __args) noexcept { | 261 | _LIBCPP_HIDE_FROM_ABI __format_arg_store(_Args&... __args) noexcept { |
| 252 | if constexpr (sizeof...(_Args) != 0) { | 262 | if constexpr (sizeof...(_Args) != 0) { |
| 253 | if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) | 263 | if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) |
lib/libcxx/include/__format/format_args.h+1-1| ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | #if _LIBCPP_STD_VER >= 20 | 26 | #if _LIBCPP_STD_VER >= 20 |
| 27 | 27 | ||
| 28 | template <class _Context> | 28 | template <class _Context> |
| 29 | class _LIBCPP_TEMPLATE_VIS basic_format_args { | 29 | class basic_format_args { |
| 30 | public: | 30 | public: |
| 31 | template <class... _Args> | 31 | template <class... _Args> |
| 32 | _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept | 32 | _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept |
lib/libcxx/include/__format/format_context.h+4-9| ... | @@ -42,7 +42,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -42,7 +42,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 42 | 42 | ||
| 43 | template <class _OutIt, class _CharT> | 43 | template <class _OutIt, class _CharT> |
| 44 | requires output_iterator<_OutIt, const _CharT&> | 44 | requires output_iterator<_OutIt, const _CharT&> |
| 45 | class _LIBCPP_TEMPLATE_VIS basic_format_context; | 45 | class basic_format_context; |
| 46 | 46 | ||
| 47 | # if _LIBCPP_HAS_LOCALIZATION | 47 | # if _LIBCPP_HAS_LOCALIZATION |
| 48 | /** | 48 | /** |
| ... | @@ -72,13 +72,8 @@ using wformat_context = basic_format_context< back_insert_iterator<__format::__o | ... | @@ -72,13 +72,8 @@ using wformat_context = basic_format_context< back_insert_iterator<__format::__o |
| 72 | 72 | ||
| 73 | template <class _OutIt, class _CharT> | 73 | template <class _OutIt, class _CharT> |
| 74 | requires output_iterator<_OutIt, const _CharT&> | 74 | requires output_iterator<_OutIt, const _CharT&> |
| 75 | class | 75 | class _LIBCPP_PREFERRED_NAME(format_context) |
| 76 | // clang-format off | 76 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) basic_format_context { |
| 77 | _LIBCPP_TEMPLATE_VIS | ||
| 78 | _LIBCPP_PREFERRED_NAME(format_context) | ||
| 79 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) | ||
| 80 | // clang-format on | ||
| 81 | basic_format_context { | ||
| 82 | public: | 77 | public: |
| 83 | using iterator = _OutIt; | 78 | using iterator = _OutIt; |
| 84 | using char_type = _CharT; | 79 | using char_type = _CharT; |
| ... | @@ -153,7 +148,7 @@ public: | ... | @@ -153,7 +148,7 @@ public: |
| 153 | // Here the width of an element in input is determined dynamically. | 148 | // Here the width of an element in input is determined dynamically. |
| 154 | // Note when the top-level element has no width the retargeting is not needed. | 149 | // Note when the top-level element has no width the retargeting is not needed. |
| 155 | template <class _CharT> | 150 | template <class _CharT> |
| 156 | class _LIBCPP_TEMPLATE_VIS basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> { | 151 | class basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> { |
| 157 | public: | 152 | public: |
| 158 | using iterator = typename __format::__retarget_buffer<_CharT>::__iterator; | 153 | using iterator = typename __format::__retarget_buffer<_CharT>::__iterator; |
| 159 | using char_type = _CharT; | 154 | using char_type = _CharT; |
lib/libcxx/include/__format/format_functions.h+48-5| ... | @@ -11,6 +11,8 @@ | ... | @@ -11,6 +11,8 @@ |
| 11 | #define _LIBCPP___FORMAT_FORMAT_FUNCTIONS | 11 | #define _LIBCPP___FORMAT_FORMAT_FUNCTIONS |
| 12 | 12 | ||
| 13 | #include <__algorithm/clamp.h> | 13 | #include <__algorithm/clamp.h> |
| 14 | #include <__algorithm/ranges_find_first_of.h> | ||
| 15 | #include <__chrono/statically_widen.h> | ||
| 14 | #include <__concepts/convertible_to.h> | 16 | #include <__concepts/convertible_to.h> |
| 15 | #include <__concepts/same_as.h> | 17 | #include <__concepts/same_as.h> |
| 16 | #include <__config> | 18 | #include <__config> |
| ... | @@ -36,6 +38,7 @@ | ... | @@ -36,6 +38,7 @@ |
| 36 | #include <__iterator/iterator_traits.h> // iter_value_t | 38 | #include <__iterator/iterator_traits.h> // iter_value_t |
| 37 | #include <__variant/monostate.h> | 39 | #include <__variant/monostate.h> |
| 38 | #include <array> | 40 | #include <array> |
| 41 | #include <optional> | ||
| 39 | #include <string> | 42 | #include <string> |
| 40 | #include <string_view> | 43 | #include <string_view> |
| 41 | 44 | ||
| ... | @@ -83,7 +86,7 @@ namespace __format { | ... | @@ -83,7 +86,7 @@ namespace __format { |
| 83 | /// When parsing a handle which is not enabled the code is ill-formed. | 86 | /// When parsing a handle which is not enabled the code is ill-formed. |
| 84 | /// This helper uses the parser of the appropriate formatter for the stored type. | 87 | /// This helper uses the parser of the appropriate formatter for the stored type. |
| 85 | template <class _CharT> | 88 | template <class _CharT> |
| 86 | class _LIBCPP_TEMPLATE_VIS __compile_time_handle { | 89 | class __compile_time_handle { |
| 87 | public: | 90 | public: |
| 88 | template <class _ParseContext> | 91 | template <class _ParseContext> |
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr void __parse(_ParseContext& __ctx) const { | 92 | _LIBCPP_HIDE_FROM_ABI constexpr void __parse(_ParseContext& __ctx) const { |
| ... | @@ -110,7 +113,7 @@ private: | ... | @@ -110,7 +113,7 @@ private: |
| 110 | // Dummy format_context only providing the parts used during constant | 113 | // Dummy format_context only providing the parts used during constant |
| 111 | // validation of the basic_format_string. | 114 | // validation of the basic_format_string. |
| 112 | template <class _CharT> | 115 | template <class _CharT> |
| 113 | struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context { | 116 | struct __compile_time_basic_format_context { |
| 114 | public: | 117 | public: |
| 115 | using char_type = _CharT; | 118 | using char_type = _CharT; |
| 116 | 119 | ||
| ... | @@ -339,12 +342,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator __vformat_to(_ParseCtx&& | ... | @@ -339,12 +342,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator __vformat_to(_ParseCtx&& |
| 339 | 342 | ||
| 340 | # if _LIBCPP_STD_VER >= 26 | 343 | # if _LIBCPP_STD_VER >= 26 |
| 341 | template <class _CharT> | 344 | template <class _CharT> |
| 342 | struct _LIBCPP_TEMPLATE_VIS __runtime_format_string { | 345 | struct __runtime_format_string { |
| 343 | private: | 346 | private: |
| 344 | basic_string_view<_CharT> __str_; | 347 | basic_string_view<_CharT> __str_; |
| 345 | 348 | ||
| 346 | template <class _Cp, class... _Args> | 349 | template <class _Cp, class... _Args> |
| 347 | friend struct _LIBCPP_TEMPLATE_VIS basic_format_string; | 350 | friend struct basic_format_string; |
| 348 | 351 | ||
| 349 | public: | 352 | public: |
| 350 | _LIBCPP_HIDE_FROM_ABI __runtime_format_string(basic_string_view<_CharT> __s) noexcept : __str_(__s) {} | 353 | _LIBCPP_HIDE_FROM_ABI __runtime_format_string(basic_string_view<_CharT> __s) noexcept : __str_(__s) {} |
| ... | @@ -362,7 +365,7 @@ _LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wst | ... | @@ -362,7 +365,7 @@ _LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wst |
| 362 | # endif // _LIBCPP_STD_VER >= 26 | 365 | # endif // _LIBCPP_STD_VER >= 26 |
| 363 | 366 | ||
| 364 | template <class _CharT, class... _Args> | 367 | template <class _CharT, class... _Args> |
| 365 | struct _LIBCPP_TEMPLATE_VIS basic_format_string { | 368 | struct basic_format_string { |
| 366 | template <class _Tp> | 369 | template <class _Tp> |
| 367 | requires convertible_to<const _Tp&, basic_string_view<_CharT>> | 370 | requires convertible_to<const _Tp&, basic_string_view<_CharT>> |
| 368 | consteval basic_format_string(const _Tp& __str) : __str_{__str} { | 371 | consteval basic_format_string(const _Tp& __str) : __str_{__str} { |
| ... | @@ -447,10 +450,47 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) { | ... | @@ -447,10 +450,47 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 447 | } | 450 | } |
| 448 | # endif | 451 | # endif |
| 449 | 452 | ||
| 453 | // Try constant folding the format string instead of going through the whole formatting machinery. If there is no | ||
| 454 | // constant folding no extra code should be emitted (with optimizations enabled) and the function returns nullopt. When | ||
| 455 | // constant folding is successful, the formatting is performed and the resulting string is returned. | ||
| 456 | namespace __format { | ||
| 457 | template <class _CharT> | ||
| 458 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<basic_string<_CharT>> __try_constant_folding( | ||
| 459 | basic_string_view<_CharT> __fmt, | ||
| 460 | basic_format_args<basic_format_context<back_insert_iterator<__format::__output_buffer<_CharT>>, _CharT>> __args) { | ||
| 461 | // Fold strings not containing '{' or '}' to just return the string | ||
| 462 | if (bool __is_identity = [&] [[__gnu__::__pure__]] // Make sure the compiler knows this call can be eliminated | ||
| 463 | { return std::ranges::find_first_of(__fmt, array{'{', '}'}) == __fmt.end(); }(); | ||
| 464 | __builtin_constant_p(__is_identity) && __is_identity) | ||
| 465 | return basic_string<_CharT>{__fmt}; | ||
| 466 | |||
| 467 | // Fold '{}' to the appropriate conversion function | ||
| 468 | if (auto __only_first_arg = __fmt == _LIBCPP_STATICALLY_WIDEN(_CharT, "{}"); | ||
| 469 | __builtin_constant_p(__only_first_arg) && __only_first_arg) { | ||
| 470 | if (auto __arg = __args.get(0); __builtin_constant_p(__arg.__type_)) { | ||
| 471 | return std::__visit_format_arg( | ||
| 472 | []<class _Tp>(_Tp&& __argument) -> optional<basic_string<_CharT>> { | ||
| 473 | if constexpr (is_same_v<remove_cvref_t<_Tp>, basic_string_view<_CharT>>) { | ||
| 474 | return basic_string<_CharT>{__argument}; | ||
| 475 | } else { | ||
| 476 | return nullopt; | ||
| 477 | } | ||
| 478 | }, | ||
| 479 | __arg); | ||
| 480 | } | ||
| 481 | } | ||
| 482 | |||
| 483 | return nullopt; | ||
| 484 | } | ||
| 485 | } // namespace __format | ||
| 486 | |||
| 450 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup | 487 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup |
| 451 | // fires too eagerly, see http://llvm.org/PR61563. | 488 | // fires too eagerly, see http://llvm.org/PR61563. |
| 452 | template <class = void> | 489 | template <class = void> |
| 453 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) { | 490 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) { |
| 491 | auto __result = __format::__try_constant_folding(__fmt, __args); | ||
| 492 | if (__result.has_value()) | ||
| 493 | return *std::move(__result); | ||
| 454 | __format::__allocating_buffer<char> __buffer; | 494 | __format::__allocating_buffer<char> __buffer; |
| 455 | std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args); | 495 | std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args); |
| 456 | return string{__buffer.__view()}; | 496 | return string{__buffer.__view()}; |
| ... | @@ -462,6 +502,9 @@ template <class = void> | ... | @@ -462,6 +502,9 @@ template <class = void> |
| 462 | template <class = void> | 502 | template <class = void> |
| 463 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring | 503 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring |
| 464 | vformat(wstring_view __fmt, wformat_args __args) { | 504 | vformat(wstring_view __fmt, wformat_args __args) { |
| 505 | auto __result = __format::__try_constant_folding(__fmt, __args); | ||
| 506 | if (__result.has_value()) | ||
| 507 | return *std::move(__result); | ||
| 465 | __format::__allocating_buffer<wchar_t> __buffer; | 508 | __format::__allocating_buffer<wchar_t> __buffer; |
| 466 | std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args); | 509 | std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args); |
| 467 | return wstring{__buffer.__view()}; | 510 | return wstring{__buffer.__view()}; |
lib/libcxx/include/__format/format_parse_context.h+1-1| ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | #if _LIBCPP_STD_VER >= 20 | 24 | #if _LIBCPP_STD_VER >= 20 |
| 25 | 25 | ||
| 26 | template <class _CharT> | 26 | template <class _CharT> |
| 27 | class _LIBCPP_TEMPLATE_VIS basic_format_parse_context { | 27 | class basic_format_parse_context { |
| 28 | public: | 28 | public: |
| 29 | using char_type = _CharT; | 29 | using char_type = _CharT; |
| 30 | using const_iterator = typename basic_string_view<_CharT>::const_iterator; | 30 | using const_iterator = typename basic_string_view<_CharT>::const_iterator; |
lib/libcxx/include/__format/format_string.h+1-1| ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | namespace __format { | 29 | namespace __format { |
| 30 | 30 | ||
| 31 | template <contiguous_iterator _Iterator> | 31 | template <contiguous_iterator _Iterator> |
| 32 | struct _LIBCPP_TEMPLATE_VIS __parse_number_result { | 32 | struct __parse_number_result { |
| 33 | _Iterator __last; | 33 | _Iterator __last; |
| 34 | uint32_t __value; | 34 | uint32_t __value; |
| 35 | }; | 35 | }; |
lib/libcxx/include/__format/format_to_n_result.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER >= 20 | 22 | #if _LIBCPP_STD_VER >= 20 |
| 23 | 23 | ||
| 24 | template <class _OutIt> | 24 | template <class _OutIt> |
| 25 | struct _LIBCPP_TEMPLATE_VIS format_to_n_result { | 25 | struct format_to_n_result { |
| 26 | _OutIt out; | 26 | _OutIt out; |
| 27 | iter_difference_t<_OutIt> size; | 27 | iter_difference_t<_OutIt> size; |
| 28 | }; | 28 | }; |
lib/libcxx/include/__format/formatter.h+9-7| ... | @@ -21,6 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,6 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if _LIBCPP_STD_VER >= 20 | 22 | #if _LIBCPP_STD_VER >= 20 |
| 23 | 23 | ||
| 24 | struct __disabled_formatter { | ||
| 25 | __disabled_formatter() = delete; | ||
| 26 | __disabled_formatter(const __disabled_formatter&) = delete; | ||
| 27 | __disabled_formatter& operator=(const __disabled_formatter&) = delete; | ||
| 28 | }; | ||
| 29 | |||
| 24 | /// The default formatter template. | 30 | /// The default formatter template. |
| 25 | /// | 31 | /// |
| 26 | /// [format.formatter.spec]/5 | 32 | /// [format.formatter.spec]/5 |
| ... | @@ -28,14 +34,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,14 +34,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | /// - is_default_constructible_v<F>, | 34 | /// - is_default_constructible_v<F>, |
| 29 | /// - is_copy_constructible_v<F>, | 35 | /// - is_copy_constructible_v<F>, |
| 30 | /// - is_move_constructible_v<F>, | 36 | /// - is_move_constructible_v<F>, |
| 31 | /// - is_copy_assignable<F>, and | 37 | /// - is_copy_assignable_v<F>, and |
| 32 | /// - is_move_assignable<F>. | 38 | /// - is_move_assignable_v<F>. |
| 33 | template <class _Tp, class _CharT> | 39 | template <class _Tp, class _CharT> |
| 34 | struct _LIBCPP_TEMPLATE_VIS formatter { | 40 | struct formatter : __disabled_formatter {}; |
| 35 | formatter() = delete; | ||
| 36 | formatter(const formatter&) = delete; | ||
| 37 | formatter& operator=(const formatter&) = delete; | ||
| 38 | }; | ||
| 39 | 41 | ||
| 40 | # if _LIBCPP_STD_VER >= 23 | 42 | # if _LIBCPP_STD_VER >= 23 |
| 41 | 43 |
lib/libcxx/include/__format/formatter_bool.h+1-1| ... | @@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | #if _LIBCPP_STD_VER >= 20 | 33 | #if _LIBCPP_STD_VER >= 20 |
| 34 | 34 | ||
| 35 | template <__fmt_char_type _CharT> | 35 | template <__fmt_char_type _CharT> |
| 36 | struct _LIBCPP_TEMPLATE_VIS formatter<bool, _CharT> { | 36 | struct formatter<bool, _CharT> { |
| 37 | public: | 37 | public: |
| 38 | template <class _ParseContext> | 38 | template <class _ParseContext> |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | 39 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
lib/libcxx/include/__format/formatter_char.h+4-4| ... | @@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | #if _LIBCPP_STD_VER >= 20 | 31 | #if _LIBCPP_STD_VER >= 20 |
| 32 | 32 | ||
| 33 | template <__fmt_char_type _CharT> | 33 | template <__fmt_char_type _CharT> |
| 34 | struct _LIBCPP_TEMPLATE_VIS __formatter_char { | 34 | struct __formatter_char { |
| 35 | public: | 35 | public: |
| 36 | template <class _ParseContext> | 36 | template <class _ParseContext> |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | 37 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | @@ -75,14 +75,14 @@ public: | ... | @@ -75,14 +75,14 @@ public: |
| 75 | }; | 75 | }; |
| 76 | 76 | ||
| 77 | template <> | 77 | template <> |
| 78 | struct _LIBCPP_TEMPLATE_VIS formatter<char, char> : public __formatter_char<char> {}; | 78 | struct formatter<char, char> : public __formatter_char<char> {}; |
| 79 | 79 | ||
| 80 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 80 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 81 | template <> | 81 | template <> |
| 82 | struct _LIBCPP_TEMPLATE_VIS formatter<char, wchar_t> : public __formatter_char<wchar_t> {}; | 82 | struct formatter<char, wchar_t> : public __formatter_char<wchar_t> {}; |
| 83 | 83 | ||
| 84 | template <> | 84 | template <> |
| 85 | struct _LIBCPP_TEMPLATE_VIS formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {}; | 85 | struct formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {}; |
| 86 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 86 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 87 | 87 | ||
| 88 | # if _LIBCPP_STD_VER >= 23 | 88 | # if _LIBCPP_STD_VER >= 23 |
lib/libcxx/include/__format/formatter_floating_point.h+6-5| ... | @@ -19,6 +19,7 @@ | ... | @@ -19,6 +19,7 @@ |
| 19 | #include <__assert> | 19 | #include <__assert> |
| 20 | #include <__charconv/chars_format.h> | 20 | #include <__charconv/chars_format.h> |
| 21 | #include <__charconv/to_chars_floating_point.h> | 21 | #include <__charconv/to_chars_floating_point.h> |
| 22 | #include <__charconv/to_chars_integral.h> | ||
| 22 | #include <__charconv/to_chars_result.h> | 23 | #include <__charconv/to_chars_result.h> |
| 23 | #include <__concepts/arithmetic.h> | 24 | #include <__concepts/arithmetic.h> |
| 24 | #include <__concepts/same_as.h> | 25 | #include <__concepts/same_as.h> |
| ... | @@ -140,7 +141,7 @@ struct __traits<double> { | ... | @@ -140,7 +141,7 @@ struct __traits<double> { |
| 140 | /// Depending on the maximum size required for a value, the buffer is allocated | 141 | /// Depending on the maximum size required for a value, the buffer is allocated |
| 141 | /// on the stack or the heap. | 142 | /// on the stack or the heap. |
| 142 | template <floating_point _Fp> | 143 | template <floating_point _Fp> |
| 143 | class _LIBCPP_TEMPLATE_VIS __float_buffer { | 144 | class __float_buffer { |
| 144 | using _Traits _LIBCPP_NODEBUG = __traits<_Fp>; | 145 | using _Traits _LIBCPP_NODEBUG = __traits<_Fp>; |
| 145 | 146 | ||
| 146 | public: | 147 | public: |
| ... | @@ -750,7 +751,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par | ... | @@ -750,7 +751,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par |
| 750 | } // namespace __formatter | 751 | } // namespace __formatter |
| 751 | 752 | ||
| 752 | template <__fmt_char_type _CharT> | 753 | template <__fmt_char_type _CharT> |
| 753 | struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point { | 754 | struct __formatter_floating_point { |
| 754 | public: | 755 | public: |
| 755 | template <class _ParseContext> | 756 | template <class _ParseContext> |
| 756 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | 757 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | @@ -768,11 +769,11 @@ public: | ... | @@ -768,11 +769,11 @@ public: |
| 768 | }; | 769 | }; |
| 769 | 770 | ||
| 770 | template <__fmt_char_type _CharT> | 771 | template <__fmt_char_type _CharT> |
| 771 | struct _LIBCPP_TEMPLATE_VIS formatter<float, _CharT> : public __formatter_floating_point<_CharT> {}; | 772 | struct formatter<float, _CharT> : public __formatter_floating_point<_CharT> {}; |
| 772 | template <__fmt_char_type _CharT> | 773 | template <__fmt_char_type _CharT> |
| 773 | struct _LIBCPP_TEMPLATE_VIS formatter<double, _CharT> : public __formatter_floating_point<_CharT> {}; | 774 | struct formatter<double, _CharT> : public __formatter_floating_point<_CharT> {}; |
| 774 | template <__fmt_char_type _CharT> | 775 | template <__fmt_char_type _CharT> |
| 775 | struct _LIBCPP_TEMPLATE_VIS formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {}; | 776 | struct formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {}; |
| 776 | 777 | ||
| 777 | # if _LIBCPP_STD_VER >= 23 | 778 | # if _LIBCPP_STD_VER >= 23 |
| 778 | template <> | 779 | template <> |
lib/libcxx/include/__format/formatter_integer.h+13-13| ... | @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | #if _LIBCPP_STD_VER >= 20 | 30 | #if _LIBCPP_STD_VER >= 20 |
| 31 | 31 | ||
| 32 | template <__fmt_char_type _CharT> | 32 | template <__fmt_char_type _CharT> |
| 33 | struct _LIBCPP_TEMPLATE_VIS __formatter_integer { | 33 | struct __formatter_integer { |
| 34 | public: | 34 | public: |
| 35 | template <class _ParseContext> | 35 | template <class _ParseContext> |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | 36 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | @@ -58,34 +58,34 @@ public: | ... | @@ -58,34 +58,34 @@ public: |
| 58 | 58 | ||
| 59 | // Signed integral types. | 59 | // Signed integral types. |
| 60 | template <__fmt_char_type _CharT> | 60 | template <__fmt_char_type _CharT> |
| 61 | struct _LIBCPP_TEMPLATE_VIS formatter<signed char, _CharT> : public __formatter_integer<_CharT> {}; | 61 | struct formatter<signed char, _CharT> : public __formatter_integer<_CharT> {}; |
| 62 | template <__fmt_char_type _CharT> | 62 | template <__fmt_char_type _CharT> |
| 63 | struct _LIBCPP_TEMPLATE_VIS formatter<short, _CharT> : public __formatter_integer<_CharT> {}; | 63 | struct formatter<short, _CharT> : public __formatter_integer<_CharT> {}; |
| 64 | template <__fmt_char_type _CharT> | 64 | template <__fmt_char_type _CharT> |
| 65 | struct _LIBCPP_TEMPLATE_VIS formatter<int, _CharT> : public __formatter_integer<_CharT> {}; | 65 | struct formatter<int, _CharT> : public __formatter_integer<_CharT> {}; |
| 66 | template <__fmt_char_type _CharT> | 66 | template <__fmt_char_type _CharT> |
| 67 | struct _LIBCPP_TEMPLATE_VIS formatter<long, _CharT> : public __formatter_integer<_CharT> {}; | 67 | struct formatter<long, _CharT> : public __formatter_integer<_CharT> {}; |
| 68 | template <__fmt_char_type _CharT> | 68 | template <__fmt_char_type _CharT> |
| 69 | struct _LIBCPP_TEMPLATE_VIS formatter<long long, _CharT> : public __formatter_integer<_CharT> {}; | 69 | struct formatter<long long, _CharT> : public __formatter_integer<_CharT> {}; |
| 70 | # if _LIBCPP_HAS_INT128 | 70 | # if _LIBCPP_HAS_INT128 |
| 71 | template <__fmt_char_type _CharT> | 71 | template <__fmt_char_type _CharT> |
| 72 | struct _LIBCPP_TEMPLATE_VIS formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {}; | 72 | struct formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {}; |
| 73 | # endif | 73 | # endif |
| 74 | 74 | ||
| 75 | // Unsigned integral types. | 75 | // Unsigned integral types. |
| 76 | template <__fmt_char_type _CharT> | 76 | template <__fmt_char_type _CharT> |
| 77 | struct _LIBCPP_TEMPLATE_VIS formatter<unsigned char, _CharT> : public __formatter_integer<_CharT> {}; | 77 | struct formatter<unsigned char, _CharT> : public __formatter_integer<_CharT> {}; |
| 78 | template <__fmt_char_type _CharT> | 78 | template <__fmt_char_type _CharT> |
| 79 | struct _LIBCPP_TEMPLATE_VIS formatter<unsigned short, _CharT> : public __formatter_integer<_CharT> {}; | 79 | struct formatter<unsigned short, _CharT> : public __formatter_integer<_CharT> {}; |
| 80 | template <__fmt_char_type _CharT> | 80 | template <__fmt_char_type _CharT> |
| 81 | struct _LIBCPP_TEMPLATE_VIS formatter<unsigned, _CharT> : public __formatter_integer<_CharT> {}; | 81 | struct formatter<unsigned, _CharT> : public __formatter_integer<_CharT> {}; |
| 82 | template <__fmt_char_type _CharT> | 82 | template <__fmt_char_type _CharT> |
| 83 | struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long, _CharT> : public __formatter_integer<_CharT> {}; | 83 | struct formatter<unsigned long, _CharT> : public __formatter_integer<_CharT> {}; |
| 84 | template <__fmt_char_type _CharT> | 84 | template <__fmt_char_type _CharT> |
| 85 | struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long long, _CharT> : public __formatter_integer<_CharT> {}; | 85 | struct formatter<unsigned long long, _CharT> : public __formatter_integer<_CharT> {}; |
| 86 | # if _LIBCPP_HAS_INT128 | 86 | # if _LIBCPP_HAS_INT128 |
| 87 | template <__fmt_char_type _CharT> | 87 | template <__fmt_char_type _CharT> |
| 88 | struct _LIBCPP_TEMPLATE_VIS formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {}; | 88 | struct formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {}; |
| 89 | # endif | 89 | # endif |
| 90 | 90 | ||
| 91 | # if _LIBCPP_STD_VER >= 23 | 91 | # if _LIBCPP_STD_VER >= 23 |
lib/libcxx/include/__format/formatter_integral.h+4-4| ... | @@ -338,7 +338,7 @@ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer( | ... | @@ -338,7 +338,7 @@ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer( |
| 338 | if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]] | 338 | if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]] |
| 339 | return __formatter::__write(__first, __last, __ctx.out(), __specs); | 339 | return __formatter::__write(__first, __last, __ctx.out(), __specs); |
| 340 | 340 | ||
| 341 | return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper); | 341 | return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, std::__hex_to_upper); |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | template <unsigned_integral _Tp, class _CharT, class _FormatContext> | 344 | template <unsigned_integral _Tp, class _CharT, class _FormatContext> |
| ... | @@ -404,17 +404,17 @@ __format_integer(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_spe | ... | @@ -404,17 +404,17 @@ __format_integer(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_spe |
| 404 | // | 404 | // |
| 405 | 405 | ||
| 406 | template <class _CharT> | 406 | template <class _CharT> |
| 407 | struct _LIBCPP_TEMPLATE_VIS __bool_strings; | 407 | struct __bool_strings; |
| 408 | 408 | ||
| 409 | template <> | 409 | template <> |
| 410 | struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> { | 410 | struct __bool_strings<char> { |
| 411 | static constexpr string_view __true{"true"}; | 411 | static constexpr string_view __true{"true"}; |
| 412 | static constexpr string_view __false{"false"}; | 412 | static constexpr string_view __false{"false"}; |
| 413 | }; | 413 | }; |
| 414 | 414 | ||
| 415 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 415 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 416 | template <> | 416 | template <> |
| 417 | struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> { | 417 | struct __bool_strings<wchar_t> { |
| 418 | static constexpr wstring_view __true{L"true"}; | 418 | static constexpr wstring_view __true{L"true"}; |
| 419 | static constexpr wstring_view __false{L"false"}; | 419 | static constexpr wstring_view __false{L"false"}; |
| 420 | }; | 420 | }; |
lib/libcxx/include/__format/formatter_output.h-18| ... | @@ -45,24 +45,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -45,24 +45,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 45 | 45 | ||
| 46 | namespace __formatter { | 46 | namespace __formatter { |
| 47 | 47 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char __c) { | ||
| 49 | switch (__c) { | ||
| 50 | case 'a': | ||
| 51 | return 'A'; | ||
| 52 | case 'b': | ||
| 53 | return 'B'; | ||
| 54 | case 'c': | ||
| 55 | return 'C'; | ||
| 56 | case 'd': | ||
| 57 | return 'D'; | ||
| 58 | case 'e': | ||
| 59 | return 'E'; | ||
| 60 | case 'f': | ||
| 61 | return 'F'; | ||
| 62 | } | ||
| 63 | return __c; | ||
| 64 | } | ||
| 65 | |||
| 66 | struct _LIBCPP_EXPORTED_FROM_ABI __padding_size_result { | 48 | struct _LIBCPP_EXPORTED_FROM_ABI __padding_size_result { |
| 67 | size_t __before_; | 49 | size_t __before_; |
| 68 | size_t __after_; | 50 | size_t __after_; |
lib/libcxx/include/__format/formatter_pointer.h+4-4| ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | #if _LIBCPP_STD_VER >= 20 | 29 | #if _LIBCPP_STD_VER >= 20 |
| 30 | 30 | ||
| 31 | template <__fmt_char_type _CharT> | 31 | template <__fmt_char_type _CharT> |
| 32 | struct _LIBCPP_TEMPLATE_VIS __formatter_pointer { | 32 | struct __formatter_pointer { |
| 33 | public: | 33 | public: |
| 34 | template <class _ParseContext> | 34 | template <class _ParseContext> |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | 35 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | @@ -59,11 +59,11 @@ public: | ... | @@ -59,11 +59,11 @@ public: |
| 59 | // - template<> struct formatter<void*, charT>; | 59 | // - template<> struct formatter<void*, charT>; |
| 60 | // - template<> struct formatter<const void*, charT>; | 60 | // - template<> struct formatter<const void*, charT>; |
| 61 | template <__fmt_char_type _CharT> | 61 | template <__fmt_char_type _CharT> |
| 62 | struct _LIBCPP_TEMPLATE_VIS formatter<nullptr_t, _CharT> : public __formatter_pointer<_CharT> {}; | 62 | struct formatter<nullptr_t, _CharT> : public __formatter_pointer<_CharT> {}; |
| 63 | template <__fmt_char_type _CharT> | 63 | template <__fmt_char_type _CharT> |
| 64 | struct _LIBCPP_TEMPLATE_VIS formatter<void*, _CharT> : public __formatter_pointer<_CharT> {}; | 64 | struct formatter<void*, _CharT> : public __formatter_pointer<_CharT> {}; |
| 65 | template <__fmt_char_type _CharT> | 65 | template <__fmt_char_type _CharT> |
| 66 | struct _LIBCPP_TEMPLATE_VIS formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {}; | 66 | struct formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {}; |
| 67 | 67 | ||
| 68 | # if _LIBCPP_STD_VER >= 23 | 68 | # if _LIBCPP_STD_VER >= 23 |
| 69 | template <> | 69 | template <> |
lib/libcxx/include/__format/formatter_string.h+24-8| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_STRING_H | 11 | #define _LIBCPP___FORMAT_FORMATTER_STRING_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__format/concepts.h> | 15 | #include <__format/concepts.h> |
| 15 | #include <__format/format_parse_context.h> | 16 | #include <__format/format_parse_context.h> |
| ... | @@ -17,6 +18,7 @@ | ... | @@ -17,6 +18,7 @@ |
| 17 | #include <__format/formatter_output.h> | 18 | #include <__format/formatter_output.h> |
| 18 | #include <__format/parser_std_format_spec.h> | 19 | #include <__format/parser_std_format_spec.h> |
| 19 | #include <__format/write_escaped.h> | 20 | #include <__format/write_escaped.h> |
| 21 | #include <cstddef> | ||
| 20 | #include <string> | 22 | #include <string> |
| 21 | #include <string_view> | 23 | #include <string_view> |
| 22 | 24 | ||
| ... | @@ -29,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -29,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | #if _LIBCPP_STD_VER >= 20 | 31 | #if _LIBCPP_STD_VER >= 20 |
| 30 | 32 | ||
| 31 | template <__fmt_char_type _CharT> | 33 | template <__fmt_char_type _CharT> |
| 32 | struct _LIBCPP_TEMPLATE_VIS __formatter_string { | 34 | struct __formatter_string { |
| 33 | public: | 35 | public: |
| 34 | template <class _ParseContext> | 36 | template <class _ParseContext> |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | 37 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | @@ -58,7 +60,7 @@ public: | ... | @@ -58,7 +60,7 @@ public: |
| 58 | 60 | ||
| 59 | // Formatter const char*. | 61 | // Formatter const char*. |
| 60 | template <__fmt_char_type _CharT> | 62 | template <__fmt_char_type _CharT> |
| 61 | struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatter_string<_CharT> { | 63 | struct formatter<const _CharT*, _CharT> : public __formatter_string<_CharT> { |
| 62 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | 64 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; |
| 63 | 65 | ||
| 64 | template <class _FormatContext> | 66 | template <class _FormatContext> |
| ... | @@ -77,7 +79,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatte | ... | @@ -77,7 +79,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatte |
| 77 | 79 | ||
| 78 | // Formatter char*. | 80 | // Formatter char*. |
| 79 | template <__fmt_char_type _CharT> | 81 | template <__fmt_char_type _CharT> |
| 80 | struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> { | 82 | struct formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> { |
| 81 | using _Base _LIBCPP_NODEBUG = formatter<const _CharT*, _CharT>; | 83 | using _Base _LIBCPP_NODEBUG = formatter<const _CharT*, _CharT>; |
| 82 | 84 | ||
| 83 | template <class _FormatContext> | 85 | template <class _FormatContext> |
| ... | @@ -88,20 +90,21 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const | ... | @@ -88,20 +90,21 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const |
| 88 | 90 | ||
| 89 | // Formatter char[]. | 91 | // Formatter char[]. |
| 90 | template <__fmt_char_type _CharT, size_t _Size> | 92 | template <__fmt_char_type _CharT, size_t _Size> |
| 91 | struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> { | 93 | struct formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> { |
| 92 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | 94 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; |
| 93 | 95 | ||
| 94 | template <class _FormatContext> | 96 | template <class _FormatContext> |
| 95 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator | 97 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator |
| 96 | format(const _CharT (&__str)[_Size], _FormatContext& __ctx) const { | 98 | format(const _CharT (&__str)[_Size], _FormatContext& __ctx) const { |
| 97 | return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); | 99 | const _CharT* const __pzero = char_traits<_CharT>::find(__str, _Size, _CharT{}); |
| 100 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__pzero != nullptr, "formatting a non-null-terminated array"); | ||
| 101 | return _Base::format(basic_string_view<_CharT>(__str, static_cast<size_t>(__pzero - __str)), __ctx); | ||
| 98 | } | 102 | } |
| 99 | }; | 103 | }; |
| 100 | 104 | ||
| 101 | // Formatter std::string. | 105 | // Formatter std::string. |
| 102 | template <__fmt_char_type _CharT, class _Traits, class _Allocator> | 106 | template <__fmt_char_type _CharT, class _Traits, class _Allocator> |
| 103 | struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> | 107 | struct formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> : public __formatter_string<_CharT> { |
| 104 | : public __formatter_string<_CharT> { | ||
| 105 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | 108 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; |
| 106 | 109 | ||
| 107 | template <class _FormatContext> | 110 | template <class _FormatContext> |
| ... | @@ -114,7 +117,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, | ... | @@ -114,7 +117,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, |
| 114 | 117 | ||
| 115 | // Formatter std::string_view. | 118 | // Formatter std::string_view. |
| 116 | template <__fmt_char_type _CharT, class _Traits> | 119 | template <__fmt_char_type _CharT, class _Traits> |
| 117 | struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT> : public __formatter_string<_CharT> { | 120 | struct formatter<basic_string_view<_CharT, _Traits>, _CharT> : public __formatter_string<_CharT> { |
| 118 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | 121 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; |
| 119 | 122 | ||
| 120 | template <class _FormatContext> | 123 | template <class _FormatContext> |
| ... | @@ -125,6 +128,19 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT | ... | @@ -125,6 +128,19 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT |
| 125 | } | 128 | } |
| 126 | }; | 129 | }; |
| 127 | 130 | ||
| 131 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 132 | template <> | ||
| 133 | struct formatter<char*, wchar_t> : __disabled_formatter {}; | ||
| 134 | template <> | ||
| 135 | struct formatter<const char*, wchar_t> : __disabled_formatter {}; | ||
| 136 | template <size_t _Size> | ||
| 137 | struct formatter<char[_Size], wchar_t> : __disabled_formatter {}; | ||
| 138 | template <class _Traits, class _Allocator> | ||
| 139 | struct formatter<basic_string<char, _Traits, _Allocator>, wchar_t> : __disabled_formatter {}; | ||
| 140 | template <class _Traits> | ||
| 141 | struct formatter<basic_string_view<char, _Traits>, wchar_t> : __disabled_formatter {}; | ||
| 142 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 143 | |||
| 128 | # if _LIBCPP_STD_VER >= 23 | 144 | # if _LIBCPP_STD_VER >= 23 |
| 129 | template <> | 145 | template <> |
| 130 | inline constexpr bool enable_nonlocking_formatter_optimization<char*> = true; | 146 | inline constexpr bool enable_nonlocking_formatter_optimization<char*> = true; |
lib/libcxx/include/__format/formatter_tuple.h+3-5| ... | @@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | #if _LIBCPP_STD_VER >= 23 | 36 | #if _LIBCPP_STD_VER >= 23 |
| 37 | 37 | ||
| 38 | template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args> | 38 | template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args> |
| 39 | struct _LIBCPP_TEMPLATE_VIS __formatter_tuple { | 39 | struct __formatter_tuple { |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept { | 40 | _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept { |
| 41 | __separator_ = __separator; | 41 | __separator_ = __separator; |
| 42 | } | 42 | } |
| ... | @@ -136,12 +136,10 @@ private: | ... | @@ -136,12 +136,10 @@ private: |
| 136 | }; | 136 | }; |
| 137 | 137 | ||
| 138 | template <__fmt_char_type _CharT, formattable<_CharT>... _Args> | 138 | template <__fmt_char_type _CharT, formattable<_CharT>... _Args> |
| 139 | struct _LIBCPP_TEMPLATE_VIS formatter<pair<_Args...>, _CharT> | 139 | struct formatter<pair<_Args...>, _CharT> : public __formatter_tuple<_CharT, pair<_Args...>, _Args...> {}; |
| 140 | : public __formatter_tuple<_CharT, pair<_Args...>, _Args...> {}; | ||
| 141 | 140 | ||
| 142 | template <__fmt_char_type _CharT, formattable<_CharT>... _Args> | 141 | template <__fmt_char_type _CharT, formattable<_CharT>... _Args> |
| 143 | struct _LIBCPP_TEMPLATE_VIS formatter<tuple<_Args...>, _CharT> | 142 | struct formatter<tuple<_Args...>, _CharT> : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {}; |
| 144 | : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {}; | ||
| 145 | 143 | ||
| 146 | #endif // _LIBCPP_STD_VER >= 23 | 144 | #endif // _LIBCPP_STD_VER >= 23 |
| 147 | 145 |
lib/libcxx/include/__format/indic_conjunct_break_table.h+257-55| ... | @@ -107,10 +107,9 @@ enum class __property : uint8_t { | ... | @@ -107,10 +107,9 @@ enum class __property : uint8_t { |
| 107 | /// following benchmark. | 107 | /// following benchmark. |
| 108 | /// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp | 108 | /// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp |
| 109 | // clang-format off | 109 | // clang-format off |
| 110 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { | 110 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[403] = { |
| 111 | 0x00180139, | 111 | 0x001801bd, |
| 112 | 0x001a807d, | 112 | 0x00241819, |
| 113 | 0x00241811, | ||
| 114 | 0x002c88b1, | 113 | 0x002c88b1, |
| 115 | 0x002df801, | 114 | 0x002df801, |
| 116 | 0x002e0805, | 115 | 0x002e0805, |
| ... | @@ -125,6 +124,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { | ... | @@ -125,6 +124,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { |
| 125 | 0x0037500d, | 124 | 0x0037500d, |
| 126 | 0x00388801, | 125 | 0x00388801, |
| 127 | 0x00398069, | 126 | 0x00398069, |
| 127 | 0x003d3029, | ||
| 128 | 0x003f5821, | 128 | 0x003f5821, |
| 129 | 0x003fe801, | 129 | 0x003fe801, |
| 130 | 0x0040b00d, | 130 | 0x0040b00d, |
| ... | @@ -132,87 +132,174 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { | ... | @@ -132,87 +132,174 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { |
| 132 | 0x00412809, | 132 | 0x00412809, |
| 133 | 0x00414811, | 133 | 0x00414811, |
| 134 | 0x0042c809, | 134 | 0x0042c809, |
| 135 | 0x0044c01d, | 135 | 0x0044b821, |
| 136 | 0x0046505d, | 136 | 0x0046505d, |
| 137 | 0x00471871, | 137 | 0x0047187d, |
| 138 | 0x0048a890, | 138 | 0x0048a890, |
| 139 | 0x0049d001, | ||
| 139 | 0x0049e001, | 140 | 0x0049e001, |
| 141 | 0x004a081d, | ||
| 140 | 0x004a6802, | 142 | 0x004a6802, |
| 141 | 0x004a880d, | 143 | 0x004a8819, |
| 142 | 0x004ac01c, | 144 | 0x004ac01c, |
| 145 | 0x004b1005, | ||
| 143 | 0x004bc01c, | 146 | 0x004bc01c, |
| 147 | 0x004c0801, | ||
| 144 | 0x004ca84c, | 148 | 0x004ca84c, |
| 145 | 0x004d5018, | 149 | 0x004d5018, |
| 146 | 0x004d9000, | 150 | 0x004d9000, |
| 147 | 0x004db00c, | 151 | 0x004db00c, |
| 148 | 0x004de001, | 152 | 0x004de001, |
| 153 | 0x004df001, | ||
| 154 | 0x004e080d, | ||
| 149 | 0x004e6802, | 155 | 0x004e6802, |
| 156 | 0x004eb801, | ||
| 150 | 0x004ee004, | 157 | 0x004ee004, |
| 151 | 0x004ef800, | 158 | 0x004ef800, |
| 159 | 0x004f1005, | ||
| 152 | 0x004f8004, | 160 | 0x004f8004, |
| 153 | 0x004ff001, | 161 | 0x004ff001, |
| 162 | 0x00500805, | ||
| 154 | 0x0051e001, | 163 | 0x0051e001, |
| 164 | 0x00520805, | ||
| 165 | 0x00523805, | ||
| 166 | 0x00525809, | ||
| 167 | 0x00528801, | ||
| 168 | 0x00538005, | ||
| 169 | 0x0053a801, | ||
| 170 | 0x00540805, | ||
| 155 | 0x0054a84c, | 171 | 0x0054a84c, |
| 156 | 0x00555018, | 172 | 0x00555018, |
| 157 | 0x00559004, | 173 | 0x00559004, |
| 158 | 0x0055a810, | 174 | 0x0055a810, |
| 159 | 0x0055e001, | 175 | 0x0055e001, |
| 176 | 0x00560811, | ||
| 177 | 0x00563805, | ||
| 160 | 0x00566802, | 178 | 0x00566802, |
| 179 | 0x00571005, | ||
| 161 | 0x0057c800, | 180 | 0x0057c800, |
| 181 | 0x0057d015, | ||
| 182 | 0x00580801, | ||
| 162 | 0x0058a84c, | 183 | 0x0058a84c, |
| 163 | 0x00595018, | 184 | 0x00595018, |
| 164 | 0x00599004, | 185 | 0x00599004, |
| 165 | 0x0059a810, | 186 | 0x0059a810, |
| 166 | 0x0059e001, | 187 | 0x0059e001, |
| 188 | 0x0059f005, | ||
| 189 | 0x005a080d, | ||
| 167 | 0x005a6802, | 190 | 0x005a6802, |
| 191 | 0x005aa809, | ||
| 168 | 0x005ae004, | 192 | 0x005ae004, |
| 169 | 0x005af800, | 193 | 0x005af800, |
| 194 | 0x005b1005, | ||
| 170 | 0x005b8800, | 195 | 0x005b8800, |
| 196 | 0x005c1001, | ||
| 197 | 0x005df001, | ||
| 198 | 0x005e0001, | ||
| 199 | 0x005e6801, | ||
| 200 | 0x005eb801, | ||
| 201 | 0x00600001, | ||
| 202 | 0x00602001, | ||
| 171 | 0x0060a84c, | 203 | 0x0060a84c, |
| 172 | 0x0061503c, | 204 | 0x0061503c, |
| 173 | 0x0061e001, | 205 | 0x0061e001, |
| 206 | 0x0061f009, | ||
| 207 | 0x00623009, | ||
| 208 | 0x00625009, | ||
| 174 | 0x00626802, | 209 | 0x00626802, |
| 175 | 0x0062a805, | 210 | 0x0062a805, |
| 176 | 0x0062c008, | 211 | 0x0062c008, |
| 212 | 0x00631005, | ||
| 213 | 0x00640801, | ||
| 177 | 0x0065e001, | 214 | 0x0065e001, |
| 215 | 0x0065f805, | ||
| 216 | 0x00661001, | ||
| 217 | 0x00663009, | ||
| 218 | 0x0066500d, | ||
| 219 | 0x0066a805, | ||
| 220 | 0x00671005, | ||
| 221 | 0x00680005, | ||
| 178 | 0x0068a894, | 222 | 0x0068a894, |
| 179 | 0x0069d805, | 223 | 0x0069d805, |
| 224 | 0x0069f001, | ||
| 225 | 0x006a080d, | ||
| 180 | 0x006a6802, | 226 | 0x006a6802, |
| 181 | 0x0071c009, | 227 | 0x006ab801, |
| 182 | 0x0072400d, | 228 | 0x006b1005, |
| 183 | 0x0075c009, | 229 | 0x006c0801, |
| 184 | 0x0076400d, | 230 | 0x006e5001, |
| 231 | 0x006e7801, | ||
| 232 | 0x006e9009, | ||
| 233 | 0x006eb001, | ||
| 234 | 0x006ef801, | ||
| 235 | 0x00718801, | ||
| 236 | 0x0071a019, | ||
| 237 | 0x0072381d, | ||
| 238 | 0x00758801, | ||
| 239 | 0x0075a021, | ||
| 240 | 0x00764019, | ||
| 185 | 0x0078c005, | 241 | 0x0078c005, |
| 186 | 0x0079a801, | 242 | 0x0079a801, |
| 187 | 0x0079b801, | 243 | 0x0079b801, |
| 188 | 0x0079c801, | 244 | 0x0079c801, |
| 189 | 0x007b8805, | 245 | 0x007b8835, |
| 190 | 0x007ba001, | 246 | 0x007c0011, |
| 191 | 0x007bd00d, | ||
| 192 | 0x007c0001, | ||
| 193 | 0x007c1009, | ||
| 194 | 0x007c3005, | 247 | 0x007c3005, |
| 248 | 0x007c6829, | ||
| 249 | 0x007cc88d, | ||
| 195 | 0x007e3001, | 250 | 0x007e3001, |
| 196 | 0x0081b801, | 251 | 0x0081680d, |
| 252 | 0x00819015, | ||
| 197 | 0x0081c805, | 253 | 0x0081c805, |
| 254 | 0x0081e805, | ||
| 255 | 0x0082c005, | ||
| 256 | 0x0082f009, | ||
| 257 | 0x0083880d, | ||
| 258 | 0x00841001, | ||
| 259 | 0x00842805, | ||
| 198 | 0x00846801, | 260 | 0x00846801, |
| 261 | 0x0084e801, | ||
| 199 | 0x009ae809, | 262 | 0x009ae809, |
| 200 | 0x00b8a001, | 263 | 0x00b8900d, |
| 201 | 0x00be9001, | 264 | 0x00b99009, |
| 265 | 0x00ba9005, | ||
| 266 | 0x00bb9005, | ||
| 267 | 0x00bda005, | ||
| 268 | 0x00bdb819, | ||
| 269 | 0x00be3001, | ||
| 270 | 0x00be4829, | ||
| 202 | 0x00bee801, | 271 | 0x00bee801, |
| 272 | 0x00c05809, | ||
| 273 | 0x00c07801, | ||
| 274 | 0x00c42805, | ||
| 203 | 0x00c54801, | 275 | 0x00c54801, |
| 276 | 0x00c90009, | ||
| 277 | 0x00c93805, | ||
| 278 | 0x00c99001, | ||
| 204 | 0x00c9c809, | 279 | 0x00c9c809, |
| 205 | 0x00d0b805, | 280 | 0x00d0b805, |
| 281 | 0x00d0d801, | ||
| 282 | 0x00d2b001, | ||
| 283 | 0x00d2c019, | ||
| 206 | 0x00d30001, | 284 | 0x00d30001, |
| 207 | 0x00d3a81d, | 285 | 0x00d31001, |
| 286 | 0x00d3281d, | ||
| 287 | 0x00d39825, | ||
| 208 | 0x00d3f801, | 288 | 0x00d3f801, |
| 209 | 0x00d58035, | 289 | 0x00d58079, |
| 210 | 0x00d5f83d, | 290 | 0x00d8000d, |
| 211 | 0x00d9a001, | 291 | 0x00d9a025, |
| 292 | 0x00da1009, | ||
| 212 | 0x00db5821, | 293 | 0x00db5821, |
| 213 | 0x00dd5801, | 294 | 0x00dc0005, |
| 295 | 0x00dd100d, | ||
| 296 | 0x00dd4015, | ||
| 214 | 0x00df3001, | 297 | 0x00df3001, |
| 215 | 0x00e1b801, | 298 | 0x00df4005, |
| 299 | 0x00df6801, | ||
| 300 | 0x00df7811, | ||
| 301 | 0x00e1601d, | ||
| 302 | 0x00e1b005, | ||
| 216 | 0x00e68009, | 303 | 0x00e68009, |
| 217 | 0x00e6a031, | 304 | 0x00e6a031, |
| 218 | 0x00e71019, | 305 | 0x00e71019, |
| ... | @@ -221,82 +308,193 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { | ... | @@ -221,82 +308,193 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { |
| 221 | 0x00e7c005, | 308 | 0x00e7c005, |
| 222 | 0x00ee00fd, | 309 | 0x00ee00fd, |
| 223 | 0x01006801, | 310 | 0x01006801, |
| 224 | 0x01068031, | 311 | 0x01068081, |
| 225 | 0x01070801, | ||
| 226 | 0x0107282d, | ||
| 227 | 0x01677809, | 312 | 0x01677809, |
| 228 | 0x016bf801, | 313 | 0x016bf801, |
| 229 | 0x016f007d, | 314 | 0x016f007d, |
| 230 | 0x01815015, | 315 | 0x01815015, |
| 231 | 0x0184c805, | 316 | 0x0184c805, |
| 232 | 0x05337801, | 317 | 0x0533780d, |
| 233 | 0x0533a025, | 318 | 0x0533a025, |
| 234 | 0x0534f005, | 319 | 0x0534f005, |
| 235 | 0x05378005, | 320 | 0x05378005, |
| 321 | 0x05401001, | ||
| 322 | 0x05403001, | ||
| 323 | 0x05405801, | ||
| 324 | 0x05412805, | ||
| 236 | 0x05416001, | 325 | 0x05416001, |
| 326 | 0x05462005, | ||
| 237 | 0x05470045, | 327 | 0x05470045, |
| 238 | 0x05495809, | 328 | 0x0547f801, |
| 329 | 0x0549301d, | ||
| 330 | 0x054a3829, | ||
| 331 | 0x054a9801, | ||
| 332 | 0x054c0009, | ||
| 239 | 0x054d9801, | 333 | 0x054d9801, |
| 334 | 0x054db00d, | ||
| 335 | 0x054de005, | ||
| 336 | 0x054e0001, | ||
| 337 | 0x054f2801, | ||
| 338 | 0x05514815, | ||
| 339 | 0x05518805, | ||
| 340 | 0x0551a805, | ||
| 341 | 0x05521801, | ||
| 342 | 0x05526001, | ||
| 343 | 0x0553e001, | ||
| 240 | 0x05558001, | 344 | 0x05558001, |
| 241 | 0x05559009, | 345 | 0x05559009, |
| 242 | 0x0555b805, | 346 | 0x0555b805, |
| 243 | 0x0555f005, | 347 | 0x0555f005, |
| 244 | 0x05560801, | 348 | 0x05560801, |
| 349 | 0x05576005, | ||
| 245 | 0x0557b001, | 350 | 0x0557b001, |
| 351 | 0x055f2801, | ||
| 352 | 0x055f4001, | ||
| 246 | 0x055f6801, | 353 | 0x055f6801, |
| 247 | 0x07d8f001, | 354 | 0x07d8f001, |
| 355 | 0x07f0003d, | ||
| 248 | 0x07f1003d, | 356 | 0x07f1003d, |
| 357 | 0x07fcf005, | ||
| 249 | 0x080fe801, | 358 | 0x080fe801, |
| 250 | 0x08170001, | 359 | 0x08170001, |
| 251 | 0x081bb011, | 360 | 0x081bb011, |
| 252 | 0x08506801, | 361 | 0x08500809, |
| 253 | 0x08507801, | 362 | 0x08502805, |
| 363 | 0x0850600d, | ||
| 254 | 0x0851c009, | 364 | 0x0851c009, |
| 255 | 0x0851f801, | 365 | 0x0851f801, |
| 256 | 0x08572805, | 366 | 0x08572805, |
| 257 | 0x0869200d, | 367 | 0x0869200d, |
| 368 | 0x086b4811, | ||
| 258 | 0x08755805, | 369 | 0x08755805, |
| 259 | 0x0877e809, | 370 | 0x0877e00d, |
| 260 | 0x087a3029, | 371 | 0x087a3029, |
| 261 | 0x087c100d, | 372 | 0x087c100d, |
| 373 | 0x08800801, | ||
| 374 | 0x0881c039, | ||
| 262 | 0x08838001, | 375 | 0x08838001, |
| 263 | 0x0883f801, | 376 | 0x08839805, |
| 264 | 0x0885d001, | 377 | 0x0883f809, |
| 378 | 0x0885980d, | ||
| 379 | 0x0885c805, | ||
| 380 | 0x08861001, | ||
| 265 | 0x08880009, | 381 | 0x08880009, |
| 266 | 0x08899805, | 382 | 0x08893811, |
| 383 | 0x0889681d, | ||
| 267 | 0x088b9801, | 384 | 0x088b9801, |
| 268 | 0x088e5001, | 385 | 0x088c0005, |
| 269 | 0x0891b001, | 386 | 0x088db021, |
| 270 | 0x08974805, | 387 | 0x088e0001, |
| 388 | 0x088e480d, | ||
| 389 | 0x088e7801, | ||
| 390 | 0x08917809, | ||
| 391 | 0x0891a00d, | ||
| 392 | 0x0891f001, | ||
| 393 | 0x08920801, | ||
| 394 | 0x0896f801, | ||
| 395 | 0x0897181d, | ||
| 396 | 0x08980005, | ||
| 271 | 0x0899d805, | 397 | 0x0899d805, |
| 398 | 0x0899f001, | ||
| 399 | 0x089a0001, | ||
| 400 | 0x089a6801, | ||
| 401 | 0x089ab801, | ||
| 272 | 0x089b3019, | 402 | 0x089b3019, |
| 273 | 0x089b8011, | 403 | 0x089b8011, |
| 404 | 0x089dc001, | ||
| 405 | 0x089dd815, | ||
| 406 | 0x089e1001, | ||
| 407 | 0x089e2801, | ||
| 408 | 0x089e3809, | ||
| 409 | 0x089e7009, | ||
| 410 | 0x089e9001, | ||
| 411 | 0x089f0805, | ||
| 412 | 0x08a1c01d, | ||
| 413 | 0x08a21009, | ||
| 274 | 0x08a23001, | 414 | 0x08a23001, |
| 275 | 0x08a2f001, | 415 | 0x08a2f001, |
| 276 | 0x08a61801, | 416 | 0x08a58001, |
| 277 | 0x08ae0001, | 417 | 0x08a59815, |
| 278 | 0x08b5b801, | 418 | 0x08a5d001, |
| 279 | 0x08b95801, | 419 | 0x08a5e801, |
| 280 | 0x08c1d001, | 420 | 0x08a5f805, |
| 281 | 0x08c9f001, | 421 | 0x08a61005, |
| 422 | 0x08ad7801, | ||
| 423 | 0x08ad900d, | ||
| 424 | 0x08ade005, | ||
| 425 | 0x08adf805, | ||
| 426 | 0x08aee005, | ||
| 427 | 0x08b1981d, | ||
| 428 | 0x08b1e801, | ||
| 429 | 0x08b1f805, | ||
| 430 | 0x08b55801, | ||
| 431 | 0x08b56801, | ||
| 432 | 0x08b5801d, | ||
| 433 | 0x08b8e801, | ||
| 434 | 0x08b8f801, | ||
| 435 | 0x08b9100d, | ||
| 436 | 0x08b93811, | ||
| 437 | 0x08c17821, | ||
| 438 | 0x08c1c805, | ||
| 439 | 0x08c98001, | ||
| 440 | 0x08c9d80d, | ||
| 282 | 0x08ca1801, | 441 | 0x08ca1801, |
| 283 | 0x08d1a001, | 442 | 0x08cea00d, |
| 443 | 0x08ced005, | ||
| 444 | 0x08cf0001, | ||
| 445 | 0x08d00825, | ||
| 446 | 0x08d19815, | ||
| 447 | 0x08d1d80d, | ||
| 284 | 0x08d23801, | 448 | 0x08d23801, |
| 285 | 0x08d4c801, | 449 | 0x08d28815, |
| 286 | 0x08ea1001, | 450 | 0x08d2c809, |
| 287 | 0x08ea2005, | 451 | 0x08d45031, |
| 452 | 0x08d4c005, | ||
| 453 | 0x08e18019, | ||
| 454 | 0x08e1c015, | ||
| 455 | 0x08e1f801, | ||
| 456 | 0x08e49055, | ||
| 457 | 0x08e55019, | ||
| 458 | 0x08e59005, | ||
| 459 | 0x08e5a805, | ||
| 460 | 0x08e98815, | ||
| 461 | 0x08e9d001, | ||
| 462 | 0x08e9e005, | ||
| 463 | 0x08e9f819, | ||
| 464 | 0x08ea3801, | ||
| 465 | 0x08ec8005, | ||
| 466 | 0x08eca801, | ||
| 288 | 0x08ecb801, | 467 | 0x08ecb801, |
| 289 | 0x08fa1001, | 468 | 0x08f79805, |
| 469 | 0x08f80005, | ||
| 470 | 0x08f9b011, | ||
| 471 | 0x08fa0009, | ||
| 472 | 0x08fad001, | ||
| 473 | 0x09a20001, | ||
| 474 | 0x09a23839, | ||
| 475 | 0x0b08f02d, | ||
| 476 | 0x0b096809, | ||
| 290 | 0x0b578011, | 477 | 0x0b578011, |
| 291 | 0x0b598019, | 478 | 0x0b598019, |
| 292 | 0x0de4f001, | 479 | 0x0b7a7801, |
| 293 | 0x0e8b2801, | 480 | 0x0b7c780d, |
| 294 | 0x0e8b3809, | 481 | 0x0b7f2001, |
| 295 | 0x0e8b7011, | 482 | 0x0b7f8005, |
| 483 | 0x0de4e805, | ||
| 484 | 0x0e7800b5, | ||
| 485 | 0x0e798059, | ||
| 486 | 0x0e8b2811, | ||
| 487 | 0x0e8b6815, | ||
| 296 | 0x0e8bd81d, | 488 | 0x0e8bd81d, |
| 297 | 0x0e8c2819, | 489 | 0x0e8c2819, |
| 298 | 0x0e8d500d, | 490 | 0x0e8d500d, |
| 299 | 0x0e921009, | 491 | 0x0e921009, |
| 492 | 0x0ed000d9, | ||
| 493 | 0x0ed1d8c5, | ||
| 494 | 0x0ed3a801, | ||
| 495 | 0x0ed42001, | ||
| 496 | 0x0ed4d811, | ||
| 497 | 0x0ed50839, | ||
| 300 | 0x0f000019, | 498 | 0x0f000019, |
| 301 | 0x0f004041, | 499 | 0x0f004041, |
| 302 | 0x0f00d819, | 500 | 0x0f00d819, |
| ... | @@ -307,8 +505,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { | ... | @@ -307,8 +505,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { |
| 307 | 0x0f157001, | 505 | 0x0f157001, |
| 308 | 0x0f17600d, | 506 | 0x0f17600d, |
| 309 | 0x0f27600d, | 507 | 0x0f27600d, |
| 508 | 0x0f2f7005, | ||
| 310 | 0x0f468019, | 509 | 0x0f468019, |
| 311 | 0x0f4a2019}; | 510 | 0x0f4a2019, |
| 511 | 0x0f9fd811, | ||
| 512 | 0x7001017d, | ||
| 513 | 0x700803bd}; | ||
| 312 | // clang-format on | 514 | // clang-format on |
| 313 | 515 | ||
| 314 | /// Returns the indic conjuct break property of a code point. | 516 | /// Returns the indic conjuct break property of a code point. |
lib/libcxx/include/__format/parser_std_format_spec.h+1-1| ... | @@ -335,7 +335,7 @@ static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>); | ... | @@ -335,7 +335,7 @@ static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>); |
| 335 | /// set to zero. That way they can be repurposed if a future revision of the | 335 | /// set to zero. That way they can be repurposed if a future revision of the |
| 336 | /// Standards adds new fields to std-format-spec. | 336 | /// Standards adds new fields to std-format-spec. |
| 337 | template <class _CharT> | 337 | template <class _CharT> |
| 338 | class _LIBCPP_TEMPLATE_VIS __parser { | 338 | class __parser { |
| 339 | public: | 339 | public: |
| 340 | // Parses the format specification. | 340 | // Parses the format specification. |
| 341 | // | 341 | // |
lib/libcxx/include/__format/range_default_formatter.h+7-7| ... | @@ -52,7 +52,7 @@ _LIBCPP_DIAGNOSTIC_POP | ... | @@ -52,7 +52,7 @@ _LIBCPP_DIAGNOSTIC_POP |
| 52 | // There is no definition of this struct, it's purely intended to be used to | 52 | // There is no definition of this struct, it's purely intended to be used to |
| 53 | // generate diagnostics. | 53 | // generate diagnostics. |
| 54 | template <class _Rp> | 54 | template <class _Rp> |
| 55 | struct _LIBCPP_TEMPLATE_VIS __instantiated_the_primary_template_of_format_kind; | 55 | struct __instantiated_the_primary_template_of_format_kind; |
| 56 | 56 | ||
| 57 | template <class _Rp> | 57 | template <class _Rp> |
| 58 | constexpr range_format format_kind = [] { | 58 | constexpr range_format format_kind = [] { |
| ... | @@ -88,12 +88,12 @@ inline constexpr range_format format_kind<_Rp> = [] { | ... | @@ -88,12 +88,12 @@ inline constexpr range_format format_kind<_Rp> = [] { |
| 88 | }(); | 88 | }(); |
| 89 | 89 | ||
| 90 | template <range_format _Kp, ranges::input_range _Rp, class _CharT> | 90 | template <range_format _Kp, ranges::input_range _Rp, class _CharT> |
| 91 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter; | 91 | struct __range_default_formatter; |
| 92 | 92 | ||
| 93 | // Required specializations | 93 | // Required specializations |
| 94 | 94 | ||
| 95 | template <ranges::input_range _Rp, class _CharT> | 95 | template <ranges::input_range _Rp, class _CharT> |
| 96 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::sequence, _Rp, _CharT> { | 96 | struct __range_default_formatter<range_format::sequence, _Rp, _CharT> { |
| 97 | private: | 97 | private: |
| 98 | using __maybe_const_r _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; | 98 | using __maybe_const_r _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; |
| 99 | range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_; | 99 | range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_; |
| ... | @@ -120,7 +120,7 @@ public: | ... | @@ -120,7 +120,7 @@ public: |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | template <ranges::input_range _Rp, class _CharT> | 122 | template <ranges::input_range _Rp, class _CharT> |
| 123 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::map, _Rp, _CharT> { | 123 | struct __range_default_formatter<range_format::map, _Rp, _CharT> { |
| 124 | private: | 124 | private: |
| 125 | using __maybe_const_map _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; | 125 | using __maybe_const_map _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; |
| 126 | using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>; | 126 | using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>; |
| ... | @@ -148,7 +148,7 @@ public: | ... | @@ -148,7 +148,7 @@ public: |
| 148 | }; | 148 | }; |
| 149 | 149 | ||
| 150 | template <ranges::input_range _Rp, class _CharT> | 150 | template <ranges::input_range _Rp, class _CharT> |
| 151 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::set, _Rp, _CharT> { | 151 | struct __range_default_formatter<range_format::set, _Rp, _CharT> { |
| 152 | private: | 152 | private: |
| 153 | using __maybe_const_set _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; | 153 | using __maybe_const_set _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; |
| 154 | using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>; | 154 | using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>; |
| ... | @@ -173,7 +173,7 @@ public: | ... | @@ -173,7 +173,7 @@ public: |
| 173 | 173 | ||
| 174 | template <range_format _Kp, ranges::input_range _Rp, class _CharT> | 174 | template <range_format _Kp, ranges::input_range _Rp, class _CharT> |
| 175 | requires(_Kp == range_format::string || _Kp == range_format::debug_string) | 175 | requires(_Kp == range_format::string || _Kp == range_format::debug_string) |
| 176 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<_Kp, _Rp, _CharT> { | 176 | struct __range_default_formatter<_Kp, _Rp, _CharT> { |
| 177 | private: | 177 | private: |
| 178 | // This deviates from the Standard, there the exposition only type is | 178 | // This deviates from the Standard, there the exposition only type is |
| 179 | // formatter<basic_string<charT>, charT> underlying_; | 179 | // formatter<basic_string<charT>, charT> underlying_; |
| ... | @@ -205,7 +205,7 @@ public: | ... | @@ -205,7 +205,7 @@ public: |
| 205 | 205 | ||
| 206 | template <ranges::input_range _Rp, class _CharT> | 206 | template <ranges::input_range _Rp, class _CharT> |
| 207 | requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>) | 207 | requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>) |
| 208 | struct _LIBCPP_TEMPLATE_VIS formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {}; | 208 | struct formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {}; |
| 209 | 209 | ||
| 210 | #endif // _LIBCPP_STD_VER >= 23 | 210 | #endif // _LIBCPP_STD_VER >= 23 |
| 211 | 211 |
lib/libcxx/include/__format/range_formatter.h+1-1| ... | @@ -39,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -39,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 39 | 39 | ||
| 40 | template <class _Tp, class _CharT = char> | 40 | template <class _Tp, class _CharT = char> |
| 41 | requires same_as<remove_cvref_t<_Tp>, _Tp> && formattable<_Tp, _CharT> | 41 | requires same_as<remove_cvref_t<_Tp>, _Tp> && formattable<_Tp, _CharT> |
| 42 | struct _LIBCPP_TEMPLATE_VIS range_formatter { | 42 | struct range_formatter { |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept { | 43 | _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept { |
| 44 | __separator_ = __separator; | 44 | __separator_ = __separator; |
| 45 | } | 45 | } |
lib/libcxx/include/__format/width_estimation_table.h+11-8| ... | @@ -119,7 +119,7 @@ namespace __width_estimation_table { | ... | @@ -119,7 +119,7 @@ namespace __width_estimation_table { |
| 119 | /// - bits [0, 13] The size of the range, allowing 16384 elements. | 119 | /// - bits [0, 13] The size of the range, allowing 16384 elements. |
| 120 | /// - bits [14, 31] The lower bound code point of the range. The upper bound of | 120 | /// - bits [14, 31] The lower bound code point of the range. The upper bound of |
| 121 | /// the range is lower bound + size. | 121 | /// the range is lower bound + size. |
| 122 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { | 122 | _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[110] = { |
| 123 | 0x0440005f /* 00001100 - 0000115f [ 96] */, // | 123 | 0x0440005f /* 00001100 - 0000115f [ 96] */, // |
| 124 | 0x08c68001 /* 0000231a - 0000231b [ 2] */, // | 124 | 0x08c68001 /* 0000231a - 0000231b [ 2] */, // |
| 125 | 0x08ca4001 /* 00002329 - 0000232a [ 2] */, // | 125 | 0x08ca4001 /* 00002329 - 0000232a [ 2] */, // |
| ... | @@ -128,8 +128,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { | ... | @@ -128,8 +128,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { |
| 128 | 0x08fcc000 /* 000023f3 - 000023f3 [ 1] */, // | 128 | 0x08fcc000 /* 000023f3 - 000023f3 [ 1] */, // |
| 129 | 0x097f4001 /* 000025fd - 000025fe [ 2] */, // | 129 | 0x097f4001 /* 000025fd - 000025fe [ 2] */, // |
| 130 | 0x09850001 /* 00002614 - 00002615 [ 2] */, // | 130 | 0x09850001 /* 00002614 - 00002615 [ 2] */, // |
| 131 | 0x098c0007 /* 00002630 - 00002637 [ 8] */, // | ||
| 131 | 0x0992000b /* 00002648 - 00002653 [ 12] */, // | 132 | 0x0992000b /* 00002648 - 00002653 [ 12] */, // |
| 132 | 0x099fc000 /* 0000267f - 0000267f [ 1] */, // | 133 | 0x099fc000 /* 0000267f - 0000267f [ 1] */, // |
| 134 | 0x09a28005 /* 0000268a - 0000268f [ 6] */, // | ||
| 133 | 0x09a4c000 /* 00002693 - 00002693 [ 1] */, // | 135 | 0x09a4c000 /* 00002693 - 00002693 [ 1] */, // |
| 134 | 0x09a84000 /* 000026a1 - 000026a1 [ 1] */, // | 136 | 0x09a84000 /* 000026a1 - 000026a1 [ 1] */, // |
| 135 | 0x09aa8001 /* 000026aa - 000026ab [ 2] */, // | 137 | 0x09aa8001 /* 000026aa - 000026ab [ 2] */, // |
| ... | @@ -163,7 +165,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { | ... | @@ -163,7 +165,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { |
| 163 | 0x0c264066 /* 00003099 - 000030ff [ 103] */, // | 165 | 0x0c264066 /* 00003099 - 000030ff [ 103] */, // |
| 164 | 0x0c41402a /* 00003105 - 0000312f [ 43] */, // | 166 | 0x0c41402a /* 00003105 - 0000312f [ 43] */, // |
| 165 | 0x0c4c405d /* 00003131 - 0000318e [ 94] */, // | 167 | 0x0c4c405d /* 00003131 - 0000318e [ 94] */, // |
| 166 | 0x0c640053 /* 00003190 - 000031e3 [ 84] */, // | 168 | 0x0c640055 /* 00003190 - 000031e5 [ 86] */, // |
| 167 | 0x0c7bc02f /* 000031ef - 0000321e [ 48] */, // | 169 | 0x0c7bc02f /* 000031ef - 0000321e [ 48] */, // |
| 168 | 0x0c880027 /* 00003220 - 00003247 [ 40] */, // | 170 | 0x0c880027 /* 00003220 - 00003247 [ 40] */, // |
| 169 | 0x0c943fff /* 00003250 - 0000724f [16384] */, // | 171 | 0x0c943fff /* 00003250 - 0000724f [16384] */, // |
| ... | @@ -182,7 +184,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { | ... | @@ -182,7 +184,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { |
| 182 | 0x5bfc0001 /* 00016ff0 - 00016ff1 [ 2] */, // | 184 | 0x5bfc0001 /* 00016ff0 - 00016ff1 [ 2] */, // |
| 183 | 0x5c0017f7 /* 00017000 - 000187f7 [ 6136] */, // | 185 | 0x5c0017f7 /* 00017000 - 000187f7 [ 6136] */, // |
| 184 | 0x620004d5 /* 00018800 - 00018cd5 [ 1238] */, // | 186 | 0x620004d5 /* 00018800 - 00018cd5 [ 1238] */, // |
| 185 | 0x63400008 /* 00018d00 - 00018d08 [ 9] */, // | 187 | 0x633fc009 /* 00018cff - 00018d08 [ 10] */, // |
| 186 | 0x6bfc0003 /* 0001aff0 - 0001aff3 [ 4] */, // | 188 | 0x6bfc0003 /* 0001aff0 - 0001aff3 [ 4] */, // |
| 187 | 0x6bfd4006 /* 0001aff5 - 0001affb [ 7] */, // | 189 | 0x6bfd4006 /* 0001aff5 - 0001affb [ 7] */, // |
| 188 | 0x6bff4001 /* 0001affd - 0001affe [ 2] */, // | 190 | 0x6bff4001 /* 0001affd - 0001affe [ 2] */, // |
| ... | @@ -192,6 +194,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { | ... | @@ -192,6 +194,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { |
| 192 | 0x6c554000 /* 0001b155 - 0001b155 [ 1] */, // | 194 | 0x6c554000 /* 0001b155 - 0001b155 [ 1] */, // |
| 193 | 0x6c590003 /* 0001b164 - 0001b167 [ 4] */, // | 195 | 0x6c590003 /* 0001b164 - 0001b167 [ 4] */, // |
| 194 | 0x6c5c018b /* 0001b170 - 0001b2fb [ 396] */, // | 196 | 0x6c5c018b /* 0001b170 - 0001b2fb [ 396] */, // |
| 197 | 0x74c00056 /* 0001d300 - 0001d356 [ 87] */, // | ||
| 198 | 0x74d80016 /* 0001d360 - 0001d376 [ 23] */, // | ||
| 195 | 0x7c010000 /* 0001f004 - 0001f004 [ 1] */, // | 199 | 0x7c010000 /* 0001f004 - 0001f004 [ 1] */, // |
| 196 | 0x7c33c000 /* 0001f0cf - 0001f0cf [ 1] */, // | 200 | 0x7c33c000 /* 0001f0cf - 0001f0cf [ 1] */, // |
| 197 | 0x7c638000 /* 0001f18e - 0001f18e [ 1] */, // | 201 | 0x7c638000 /* 0001f18e - 0001f18e [ 1] */, // |
| ... | @@ -213,11 +217,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { | ... | @@ -213,11 +217,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = { |
| 213 | 0x7dfc0000 /* 0001f7f0 - 0001f7f0 [ 1] */, // | 217 | 0x7dfc0000 /* 0001f7f0 - 0001f7f0 [ 1] */, // |
| 214 | 0x7e4000ff /* 0001f900 - 0001f9ff [ 256] */, // | 218 | 0x7e4000ff /* 0001f900 - 0001f9ff [ 256] */, // |
| 215 | 0x7e9c000c /* 0001fa70 - 0001fa7c [ 13] */, // | 219 | 0x7e9c000c /* 0001fa70 - 0001fa7c [ 13] */, // |
| 216 | 0x7ea00008 /* 0001fa80 - 0001fa88 [ 9] */, // | 220 | 0x7ea00009 /* 0001fa80 - 0001fa89 [ 10] */, // |
| 217 | 0x7ea4002d /* 0001fa90 - 0001fabd [ 46] */, // | 221 | 0x7ea3c037 /* 0001fa8f - 0001fac6 [ 56] */, // |
| 218 | 0x7eafc006 /* 0001fabf - 0001fac5 [ 7] */, // | 222 | 0x7eb3800e /* 0001face - 0001fadc [ 15] */, // |
| 219 | 0x7eb3800d /* 0001face - 0001fadb [ 14] */, // | 223 | 0x7eb7c00a /* 0001fadf - 0001fae9 [ 11] */, // |
| 220 | 0x7eb80008 /* 0001fae0 - 0001fae8 [ 9] */, // | ||
| 221 | 0x7ebc0008 /* 0001faf0 - 0001faf8 [ 9] */, // | 224 | 0x7ebc0008 /* 0001faf0 - 0001faf8 [ 9] */, // |
| 222 | 0x80003fff /* 00020000 - 00023fff [16384] */, // | 225 | 0x80003fff /* 00020000 - 00023fff [16384] */, // |
| 223 | 0x90003fff /* 00024000 - 00027fff [16384] */, // | 226 | 0x90003fff /* 00024000 - 00027fff [16384] */, // |
lib/libcxx/include/__functional/binary_function.h+3-4| ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | 21 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) |
| 22 | 22 | ||
| 23 | template <class _Arg1, class _Arg2, class _Result> | 23 | template <class _Arg1, class _Arg2, class _Result> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function { | 24 | struct _LIBCPP_DEPRECATED_IN_CXX11 binary_function { |
| 25 | typedef _Arg1 first_argument_type; | 25 | typedef _Arg1 first_argument_type; |
| 26 | typedef _Arg2 second_argument_type; | 26 | typedef _Arg2 second_argument_type; |
| 27 | typedef _Result result_type; | 27 | typedef _Result result_type; |
| ... | @@ -39,11 +39,10 @@ struct __binary_function_keep_layout_base { | ... | @@ -39,11 +39,10 @@ struct __binary_function_keep_layout_base { |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | 41 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) |
| 42 | _LIBCPP_DIAGNOSTIC_PUSH | 42 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 43 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") | ||
| 44 | template <class _Arg1, class _Arg2, class _Result> | 43 | template <class _Arg1, class _Arg2, class _Result> |
| 45 | using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>; | 44 | using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>; |
| 46 | _LIBCPP_DIAGNOSTIC_POP | 45 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 47 | #else | 46 | #else |
| 48 | template <class _Arg1, class _Arg2, class _Result> | 47 | template <class _Arg1, class _Arg2, class _Result> |
| 49 | using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; | 48 | using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; |
lib/libcxx/include/__functional/binary_negate.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) | 22 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) |
| 23 | 23 | ||
| 24 | template <class _Predicate> | 24 | template <class _Predicate> |
| 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate | 25 | class _LIBCPP_DEPRECATED_IN_CXX17 binary_negate |
| 26 | : public __binary_function<typename _Predicate::first_argument_type, | 26 | : public __binary_function<typename _Predicate::first_argument_type, |
| 27 | typename _Predicate::second_argument_type, | 27 | typename _Predicate::second_argument_type, |
| 28 | bool> { | 28 | bool> { |
lib/libcxx/include/__functional/bind.h+3-3| ... | @@ -130,7 +130,7 @@ struct __mu_return_invokable // false | ... | @@ -130,7 +130,7 @@ struct __mu_return_invokable // false |
| 130 | 130 | ||
| 131 | template <class _Ti, class... _Uj> | 131 | template <class _Ti, class... _Uj> |
| 132 | struct __mu_return_invokable<true, _Ti, _Uj...> { | 132 | struct __mu_return_invokable<true, _Ti, _Uj...> { |
| 133 | using type = __invoke_result_t<_Ti&, _Uj...>; | 133 | using type _LIBCPP_NODEBUG = __invoke_result_t<_Ti&, _Uj...>; |
| 134 | }; | 134 | }; |
| 135 | 135 | ||
| 136 | template <class _Ti, class... _Uj> | 136 | template <class _Ti, class... _Uj> |
| ... | @@ -181,12 +181,12 @@ struct __bind_return; | ... | @@ -181,12 +181,12 @@ struct __bind_return; |
| 181 | 181 | ||
| 182 | template <class _Fp, class... _BoundArgs, class _TupleUj> | 182 | template <class _Fp, class... _BoundArgs, class _TupleUj> |
| 183 | struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> { | 183 | struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> { |
| 184 | using type = __invoke_result_t< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >; | 184 | using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<_BoundArgs, _TupleUj>::type...>; |
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | template <class _Fp, class... _BoundArgs, class _TupleUj> | 187 | template <class _Fp, class... _BoundArgs, class _TupleUj> |
| 188 | struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> { | 188 | struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> { |
| 189 | using type = __invoke_result_t< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >; | 189 | using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<const _BoundArgs, _TupleUj>::type...>; |
| 190 | }; | 190 | }; |
| 191 | 191 | ||
| 192 | template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args> | 192 | template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args> |
lib/libcxx/include/__functional/binder1st.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) | 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) |
| 23 | 23 | ||
| 24 | template <class _Operation> | 24 | template <class _Operation> |
| 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st | 25 | class _LIBCPP_DEPRECATED_IN_CXX11 binder1st |
| 26 | : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> { | 26 | : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> { |
| 27 | protected: | 27 | protected: |
| 28 | _Operation op; | 28 | _Operation op; |
lib/libcxx/include/__functional/binder2nd.h+1-1| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) | 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) |
| 23 | 23 | ||
| 24 | template <class _Operation> | 24 | template <class _Operation> |
| 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd | 25 | class _LIBCPP_DEPRECATED_IN_CXX11 binder2nd |
| 26 | : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> { | 26 | : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> { |
| 27 | protected: | 27 | protected: |
| 28 | _Operation op; | 28 | _Operation op; |
lib/libcxx/include/__functional/boyer_moore_searcher.h+7-9| ... | @@ -17,12 +17,10 @@ | ... | @@ -17,12 +17,10 @@ |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__functional/hash.h> | 18 | #include <__functional/hash.h> |
| 19 | #include <__functional/operations.h> | 19 | #include <__functional/operations.h> |
| 20 | #include <__iterator/distance.h> | ||
| 21 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__memory/shared_ptr.h> | 21 | #include <__memory/shared_ptr.h> |
| 23 | #include <__type_traits/make_unsigned.h> | 22 | #include <__type_traits/make_unsigned.h> |
| 24 | #include <__utility/pair.h> | 23 | #include <__utility/pair.h> |
| 25 | #include <__vector/vector.h> | ||
| 26 | #include <array> | 24 | #include <array> |
| 27 | #include <limits> | 25 | #include <limits> |
| 28 | #include <unordered_map> | 26 | #include <unordered_map> |
| ... | @@ -88,7 +86,7 @@ public: | ... | @@ -88,7 +86,7 @@ public: |
| 88 | template <class _RandomAccessIterator1, | 86 | template <class _RandomAccessIterator1, |
| 89 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, | 87 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, |
| 90 | class _BinaryPredicate = equal_to<>> | 88 | class _BinaryPredicate = equal_to<>> |
| 91 | class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher { | 89 | class boyer_moore_searcher { |
| 92 | private: | 90 | private: |
| 93 | using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type; | 91 | using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type; |
| 94 | using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type; | 92 | using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type; |
| ... | @@ -125,8 +123,8 @@ public: | ... | @@ -125,8 +123,8 @@ public: |
| 125 | template <class _RandomAccessIterator2> | 123 | template <class _RandomAccessIterator2> |
| 126 | _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2> | 124 | _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2> |
| 127 | operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { | 125 | operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { |
| 128 | static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type, | 126 | static_assert(is_same_v<__remove_cvref_t<typename iterator_traits<_RandomAccessIterator1>::value_type>, |
| 129 | typename iterator_traits<_RandomAccessIterator2>::value_type>::value, | 127 | __remove_cvref_t<typename iterator_traits<_RandomAccessIterator2>::value_type>>, |
| 130 | "Corpus and Pattern iterators must point to the same type"); | 128 | "Corpus and Pattern iterators must point to the same type"); |
| 131 | if (__first == __last) | 129 | if (__first == __last) |
| 132 | return std::make_pair(__last, __last); | 130 | return std::make_pair(__last, __last); |
| ... | @@ -196,7 +194,7 @@ private: | ... | @@ -196,7 +194,7 @@ private: |
| 196 | if (__count == 0) | 194 | if (__count == 0) |
| 197 | return; | 195 | return; |
| 198 | 196 | ||
| 199 | vector<difference_type> __scratch(__count); | 197 | auto __scratch = std::make_unique<difference_type[]>(__count); |
| 200 | 198 | ||
| 201 | __compute_bm_prefix(__first, __last, __pred, __scratch); | 199 | __compute_bm_prefix(__first, __last, __pred, __scratch); |
| 202 | for (size_t __i = 0; __i <= __count; ++__i) | 200 | for (size_t __i = 0; __i <= __count; ++__i) |
| ... | @@ -219,7 +217,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher); | ... | @@ -219,7 +217,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher); |
| 219 | template <class _RandomAccessIterator1, | 217 | template <class _RandomAccessIterator1, |
| 220 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, | 218 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, |
| 221 | class _BinaryPredicate = equal_to<>> | 219 | class _BinaryPredicate = equal_to<>> |
| 222 | class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher { | 220 | class boyer_moore_horspool_searcher { |
| 223 | private: | 221 | private: |
| 224 | using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type; | 222 | using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type; |
| 225 | using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type; | 223 | using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type; |
| ... | @@ -256,8 +254,8 @@ public: | ... | @@ -256,8 +254,8 @@ public: |
| 256 | template <class _RandomAccessIterator2> | 254 | template <class _RandomAccessIterator2> |
| 257 | _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2> | 255 | _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2> |
| 258 | operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { | 256 | operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { |
| 259 | static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type, | 257 | static_assert(is_same_v<__remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator1>::value_type>, |
| 260 | typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value, | 258 | __remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator2>::value_type>>, |
| 261 | "Corpus and Pattern iterators must point to the same type"); | 259 | "Corpus and Pattern iterators must point to the same type"); |
| 262 | if (__first == __last) | 260 | if (__first == __last) |
| 263 | return std::make_pair(__last, __last); | 261 | return std::make_pair(__last, __last); |
lib/libcxx/include/__functional/default_searcher.h+1-1| ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | // default searcher | 28 | // default searcher |
| 29 | template <class _ForwardIterator, class _BinaryPredicate = equal_to<>> | 29 | template <class _ForwardIterator, class _BinaryPredicate = equal_to<>> |
| 30 | class _LIBCPP_TEMPLATE_VIS default_searcher { | 30 | class default_searcher { |
| 31 | public: | 31 | public: |
| 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 33 | default_searcher(_ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate()) | 33 | default_searcher(_ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate()) |
lib/libcxx/include/__functional/function.h+78-301| ... | @@ -17,13 +17,7 @@ | ... | @@ -17,13 +17,7 @@ |
| 17 | #include <__functional/binary_function.h> | 17 | #include <__functional/binary_function.h> |
| 18 | #include <__functional/invoke.h> | 18 | #include <__functional/invoke.h> |
| 19 | #include <__functional/unary_function.h> | 19 | #include <__functional/unary_function.h> |
| 20 | #include <__iterator/iterator_traits.h> | ||
| 21 | #include <__memory/addressof.h> | 20 | #include <__memory/addressof.h> |
| 22 | #include <__memory/allocator.h> | ||
| 23 | #include <__memory/allocator_destructor.h> | ||
| 24 | #include <__memory/allocator_traits.h> | ||
| 25 | #include <__memory/compressed_pair.h> | ||
| 26 | #include <__memory/unique_ptr.h> | ||
| 27 | #include <__type_traits/aligned_storage.h> | 21 | #include <__type_traits/aligned_storage.h> |
| 28 | #include <__type_traits/decay.h> | 22 | #include <__type_traits/decay.h> |
| 29 | #include <__type_traits/is_core_convertible.h> | 23 | #include <__type_traits/is_core_convertible.h> |
| ... | @@ -34,9 +28,7 @@ | ... | @@ -34,9 +28,7 @@ |
| 34 | #include <__type_traits/strip_signature.h> | 28 | #include <__type_traits/strip_signature.h> |
| 35 | #include <__utility/forward.h> | 29 | #include <__utility/forward.h> |
| 36 | #include <__utility/move.h> | 30 | #include <__utility/move.h> |
| 37 | #include <__utility/piecewise_construct.h> | ||
| 38 | #include <__utility/swap.h> | 31 | #include <__utility/swap.h> |
| 39 | #include <__verbose_abort> | ||
| 40 | #include <tuple> | 32 | #include <tuple> |
| 41 | #include <typeinfo> | 33 | #include <typeinfo> |
| 42 | 34 | ||
| ... | @@ -71,7 +63,7 @@ public: | ... | @@ -71,7 +63,7 @@ public: |
| 71 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {} | 63 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {} |
| 72 | # endif | 64 | # endif |
| 73 | 65 | ||
| 74 | # ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | 66 | # if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE |
| 75 | const char* what() const _NOEXCEPT override; | 67 | const char* what() const _NOEXCEPT override; |
| 76 | # endif | 68 | # endif |
| 77 | }; | 69 | }; |
| ... | @@ -86,7 +78,7 @@ _LIBCPP_DIAGNOSTIC_POP | ... | @@ -86,7 +78,7 @@ _LIBCPP_DIAGNOSTIC_POP |
| 86 | } | 78 | } |
| 87 | 79 | ||
| 88 | template <class _Fp> | 80 | template <class _Fp> |
| 89 | class _LIBCPP_TEMPLATE_VIS function; // undefined | 81 | class function; // undefined |
| 90 | 82 | ||
| 91 | namespace __function { | 83 | namespace __function { |
| 92 | 84 | ||
| ... | @@ -122,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) { | ... | @@ -122,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) { |
| 122 | return !!__f; | 114 | return !!__f; |
| 123 | } | 115 | } |
| 124 | 116 | ||
| 125 | # if _LIBCPP_HAS_EXTENSION_BLOCKS | 117 | # if __has_extension(blocks) |
| 126 | template <class _Rp, class... _Args> | 118 | template <class _Rp, class... _Args> |
| 127 | _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) { | 119 | _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) { |
| 128 | return __p; | 120 | return __p; |
| ... | @@ -133,108 +125,10 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) { | ... | @@ -133,108 +125,10 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) { |
| 133 | 125 | ||
| 134 | namespace __function { | 126 | namespace __function { |
| 135 | 127 | ||
| 136 | // __alloc_func holds a functor and an allocator. | ||
| 137 | |||
| 138 | template <class _Fp, class _Ap, class _FB> | ||
| 139 | class __alloc_func; | ||
| 140 | template <class _Fp, class _FB> | ||
| 141 | class __default_alloc_func; | ||
| 142 | |||
| 143 | template <class _Fp, class _Ap, class _Rp, class... _ArgTypes> | ||
| 144 | class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> { | ||
| 145 | _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Ap, __alloc_); | ||
| 146 | |||
| 147 | public: | ||
| 148 | using _Target _LIBCPP_NODEBUG = _Fp; | ||
| 149 | using _Alloc _LIBCPP_NODEBUG = _Ap; | ||
| 150 | |||
| 151 | _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __func_; } | ||
| 152 | |||
| 153 | // WIN32 APIs may define __allocator, so use __get_allocator instead. | ||
| 154 | _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __alloc_; } | ||
| 155 | |||
| 156 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) : __func_(std::move(__f)), __alloc_() {} | ||
| 157 | |||
| 158 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {} | ||
| 159 | |||
| 160 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, _Alloc&& __a) | ||
| 161 | : __func_(__f), __alloc_(std::move(__a)) {} | ||
| 162 | |||
| 163 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f, _Alloc&& __a) | ||
| 164 | : __func_(std::move(__f)), __alloc_(std::move(__a)) {} | ||
| 165 | |||
| 166 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) { | ||
| 167 | return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...); | ||
| 168 | } | ||
| 169 | |||
| 170 | _LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const { | ||
| 171 | typedef allocator_traits<_Alloc> __alloc_traits; | ||
| 172 | typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA; | ||
| 173 | _AA __a(__alloc_); | ||
| 174 | typedef __allocator_destructor<_AA> _Dp; | ||
| 175 | unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); | ||
| 176 | ::new ((void*)__hold.get()) __alloc_func(__func_, _Alloc(__a)); | ||
| 177 | return __hold.release(); | ||
| 178 | } | ||
| 179 | |||
| 180 | _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { | ||
| 181 | __func_.~_Fp(); | ||
| 182 | __alloc_.~_Alloc(); | ||
| 183 | } | ||
| 184 | |||
| 185 | _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__alloc_func* __f) { | ||
| 186 | typedef allocator_traits<_Alloc> __alloc_traits; | ||
| 187 | typedef __rebind_alloc<__alloc_traits, __alloc_func> _FunAlloc; | ||
| 188 | _FunAlloc __a(__f->__get_allocator()); | ||
| 189 | __f->destroy(); | ||
| 190 | __a.deallocate(__f, 1); | ||
| 191 | } | ||
| 192 | }; | ||
| 193 | |||
| 194 | template <class _Tp> | ||
| 195 | struct __deallocating_deleter { | ||
| 196 | _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const { | ||
| 197 | std::__libcpp_deallocate<_Tp>(static_cast<_Tp*>(__p), __element_count(1)); | ||
| 198 | } | ||
| 199 | }; | ||
| 200 | |||
| 201 | template <class _Fp, class _Rp, class... _ArgTypes> | ||
| 202 | class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> { | ||
| 203 | _Fp __f_; | ||
| 204 | |||
| 205 | public: | ||
| 206 | using _Target _LIBCPP_NODEBUG = _Fp; | ||
| 207 | |||
| 208 | _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_; } | ||
| 209 | |||
| 210 | _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(_Target&& __f) : __f_(std::move(__f)) {} | ||
| 211 | |||
| 212 | _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(const _Target& __f) : __f_(__f) {} | ||
| 213 | |||
| 214 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) { | ||
| 215 | return std::__invoke_r<_Rp>(__f_, std::forward<_ArgTypes>(__arg)...); | ||
| 216 | } | ||
| 217 | |||
| 218 | _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const { | ||
| 219 | using _Self = __default_alloc_func; | ||
| 220 | unique_ptr<_Self, __deallocating_deleter<_Self>> __hold(std::__libcpp_allocate<_Self>(__element_count(1))); | ||
| 221 | _Self* __res = ::new ((void*)__hold.get()) _Self(__f_); | ||
| 222 | (void)__hold.release(); | ||
| 223 | return __res; | ||
| 224 | } | ||
| 225 | |||
| 226 | _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { __f_.~_Target(); } | ||
| 227 | |||
| 228 | _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__default_alloc_func* __f) { | ||
| 229 | __f->destroy(); | ||
| 230 | std::__libcpp_deallocate<__default_alloc_func>(__f, __element_count(1)); | ||
| 231 | } | ||
| 232 | }; | ||
| 233 | |||
| 234 | // __base provides an abstract interface for copyable functors. | 128 | // __base provides an abstract interface for copyable functors. |
| 235 | 129 | ||
| 236 | template <class _Fp> | 130 | template <class _Fp> |
| 237 | class _LIBCPP_TEMPLATE_VIS __base; | 131 | class __base; |
| 238 | 132 | ||
| 239 | template <class _Rp, class... _ArgTypes> | 133 | template <class _Rp, class... _ArgTypes> |
| 240 | class __base<_Rp(_ArgTypes...)> { | 134 | class __base<_Rp(_ArgTypes...)> { |
| ... | @@ -257,84 +151,38 @@ public: | ... | @@ -257,84 +151,38 @@ public: |
| 257 | 151 | ||
| 258 | // __func implements __base for a given functor type. | 152 | // __func implements __base for a given functor type. |
| 259 | 153 | ||
| 260 | template <class _FD, class _Alloc, class _FB> | 154 | template <class _FD, class _FB> |
| 261 | class __func; | 155 | class __func; |
| 262 | 156 | ||
| 263 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | 157 | template <class _Fp, class _Rp, class... _ArgTypes> |
| 264 | class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> { | 158 | class __func<_Fp, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> { |
| 265 | __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_; | 159 | _Fp __func_; |
| 266 | 160 | ||
| 267 | public: | 161 | public: |
| 268 | _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f) : __f_(std::move(__f)) {} | 162 | _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f) : __func_(std::move(__f)) {} |
| 163 | _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f) : __func_(__f) {} | ||
| 269 | 164 | ||
| 270 | _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {} | 165 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL __base<_Rp(_ArgTypes...)>* __clone() const override { return new __func(__func_); } |
| 271 | 166 | ||
| 272 | _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f, _Alloc&& __a) : __f_(__f, std::move(__a)) {} | 167 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __clone(__base<_Rp(_ArgTypes...)>* __p) const override { |
| 273 | 168 | ::new ((void*)__p) __func(__func_); | |
| 274 | _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f, _Alloc&& __a) : __f_(std::move(__f), std::move(__a)) {} | 169 | } |
| 275 | 170 | ||
| 276 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const; | 171 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void destroy() _NOEXCEPT override { __func_.~_Fp(); } |
| 277 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; | 172 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void destroy_deallocate() _NOEXCEPT override { delete this; } |
| 278 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT; | 173 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL _Rp operator()(_ArgTypes&&... __arg) override { |
| 279 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT; | 174 | return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...); |
| 280 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg); | 175 | } |
| 281 | # if _LIBCPP_HAS_RTTI | 176 | # if _LIBCPP_HAS_RTTI |
| 282 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(const type_info&) const _NOEXCEPT; | 177 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* target(const type_info& __ti) const _NOEXCEPT override { |
| 283 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT; | 178 | if (__ti == typeid(_Fp)) |
| 179 | return std::addressof(__func_); | ||
| 180 | return nullptr; | ||
| 181 | } | ||
| 182 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const std::type_info& target_type() const _NOEXCEPT override { return typeid(_Fp); } | ||
| 284 | # endif // _LIBCPP_HAS_RTTI | 183 | # endif // _LIBCPP_HAS_RTTI |
| 285 | }; | 184 | }; |
| 286 | 185 | ||
| 287 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | ||
| 288 | __base<_Rp(_ArgTypes...)>* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const { | ||
| 289 | typedef allocator_traits<_Alloc> __alloc_traits; | ||
| 290 | typedef __rebind_alloc<__alloc_traits, __func> _Ap; | ||
| 291 | _Ap __a(__f_.__get_allocator()); | ||
| 292 | typedef __allocator_destructor<_Ap> _Dp; | ||
| 293 | unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); | ||
| 294 | ::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a)); | ||
| 295 | return __hold.release(); | ||
| 296 | } | ||
| 297 | |||
| 298 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | ||
| 299 | void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const { | ||
| 300 | ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator()); | ||
| 301 | } | ||
| 302 | |||
| 303 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | ||
| 304 | void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT { | ||
| 305 | __f_.destroy(); | ||
| 306 | } | ||
| 307 | |||
| 308 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | ||
| 309 | void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT { | ||
| 310 | typedef allocator_traits<_Alloc> __alloc_traits; | ||
| 311 | typedef __rebind_alloc<__alloc_traits, __func> _Ap; | ||
| 312 | _Ap __a(__f_.__get_allocator()); | ||
| 313 | __f_.destroy(); | ||
| 314 | __a.deallocate(this, 1); | ||
| 315 | } | ||
| 316 | |||
| 317 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | ||
| 318 | _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) { | ||
| 319 | return __f_(std::forward<_ArgTypes>(__arg)...); | ||
| 320 | } | ||
| 321 | |||
| 322 | # if _LIBCPP_HAS_RTTI | ||
| 323 | |||
| 324 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | ||
| 325 | const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT { | ||
| 326 | if (__ti == typeid(_Fp)) | ||
| 327 | return std::addressof(__f_.__target()); | ||
| 328 | return nullptr; | ||
| 329 | } | ||
| 330 | |||
| 331 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> | ||
| 332 | const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT { | ||
| 333 | return typeid(_Fp); | ||
| 334 | } | ||
| 335 | |||
| 336 | # endif // _LIBCPP_HAS_RTTI | ||
| 337 | |||
| 338 | // __value_func creates a value-type from a __func. | 186 | // __value_func creates a value-type from a __func. |
| 339 | 187 | ||
| 340 | template <class _Fp> | 188 | template <class _Fp> |
| ... | @@ -354,29 +202,19 @@ class __value_func<_Rp(_ArgTypes...)> { | ... | @@ -354,29 +202,19 @@ class __value_func<_Rp(_ArgTypes...)> { |
| 354 | public: | 202 | public: |
| 355 | _LIBCPP_HIDE_FROM_ABI __value_func() _NOEXCEPT : __f_(nullptr) {} | 203 | _LIBCPP_HIDE_FROM_ABI __value_func() _NOEXCEPT : __f_(nullptr) {} |
| 356 | 204 | ||
| 357 | template <class _Fp, class _Alloc> | 205 | template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __value_func>::value, int> = 0> |
| 358 | _LIBCPP_HIDE_FROM_ABI __value_func(_Fp&& __f, const _Alloc& __a) : __f_(nullptr) { | 206 | _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __f_(nullptr) { |
| 359 | typedef allocator_traits<_Alloc> __alloc_traits; | 207 | typedef __function::__func<_Fp, _Rp(_ArgTypes...)> _Fun; |
| 360 | typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; | ||
| 361 | typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc; | ||
| 362 | 208 | ||
| 363 | if (__function::__not_null(__f)) { | 209 | if (__function::__not_null(__f)) { |
| 364 | _FunAlloc __af(__a); | 210 | if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) { |
| 365 | if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value && | 211 | __f_ = ::new (std::addressof(__buf_)) _Fun(std::move(__f)); |
| 366 | is_nothrow_copy_constructible<_FunAlloc>::value) { | ||
| 367 | __f_ = ::new ((void*)&__buf_) _Fun(std::move(__f), _Alloc(__af)); | ||
| 368 | } else { | 212 | } else { |
| 369 | typedef __allocator_destructor<_FunAlloc> _Dp; | 213 | __f_ = new _Fun(std::move(__f)); |
| 370 | unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); | ||
| 371 | ::new ((void*)__hold.get()) _Fun(std::move(__f), _Alloc(__a)); | ||
| 372 | __f_ = __hold.release(); | ||
| 373 | } | 214 | } |
| 374 | } | 215 | } |
| 375 | } | 216 | } |
| 376 | 217 | ||
| 377 | template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __value_func>::value, int> = 0> | ||
| 378 | _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __value_func(std::forward<_Fp>(__f), allocator<_Fp>()) {} | ||
| 379 | |||
| 380 | _LIBCPP_HIDE_FROM_ABI __value_func(const __value_func& __f) { | 218 | _LIBCPP_HIDE_FROM_ABI __value_func(const __value_func& __f) { |
| 381 | if (__f.__f_ == nullptr) | 219 | if (__f.__f_ == nullptr) |
| 382 | __f_ = nullptr; | 220 | __f_ = nullptr; |
| ... | @@ -432,12 +270,12 @@ public: | ... | @@ -432,12 +270,12 @@ public: |
| 432 | 270 | ||
| 433 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const { | 271 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const { |
| 434 | if (__f_ == nullptr) | 272 | if (__f_ == nullptr) |
| 435 | __throw_bad_function_call(); | 273 | std::__throw_bad_function_call(); |
| 436 | return (*__f_)(std::forward<_ArgTypes>(__args)...); | 274 | return (*__f_)(std::forward<_ArgTypes>(__args)...); |
| 437 | } | 275 | } |
| 438 | 276 | ||
| 439 | _LIBCPP_HIDE_FROM_ABI void swap(__value_func& __f) _NOEXCEPT { | 277 | _LIBCPP_HIDE_FROM_ABI void swap(__value_func& __f) _NOEXCEPT { |
| 440 | if (&__f == this) | 278 | if (std::addressof(__f) == this) |
| 441 | return; | 279 | return; |
| 442 | if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) { | 280 | if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) { |
| 443 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 281 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | @@ -539,22 +377,22 @@ private: | ... | @@ -539,22 +377,22 @@ private: |
| 539 | template <typename _Fun> | 377 | template <typename _Fun> |
| 540 | _LIBCPP_HIDE_FROM_ABI static void* __large_clone(const void* __s) { | 378 | _LIBCPP_HIDE_FROM_ABI static void* __large_clone(const void* __s) { |
| 541 | const _Fun* __f = static_cast<const _Fun*>(__s); | 379 | const _Fun* __f = static_cast<const _Fun*>(__s); |
| 542 | return __f->__clone(); | 380 | return new _Fun(*__f); |
| 543 | } | 381 | } |
| 544 | 382 | ||
| 545 | template <typename _Fun> | 383 | template <typename _Fun> |
| 546 | _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) { | 384 | _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) { |
| 547 | _Fun::__destroy_and_delete(static_cast<_Fun*>(__s)); | 385 | delete static_cast<_Fun*>(__s); |
| 548 | } | 386 | } |
| 549 | 387 | ||
| 550 | template <typename _Fun> | 388 | template <typename _Fun> |
| 551 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) { | 389 | _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) { |
| 552 | static constexpr __policy __policy = { | 390 | static constexpr __policy __policy = { |
| 553 | &__large_clone<_Fun>, | 391 | std::addressof(__large_clone<_Fun>), |
| 554 | &__large_destroy<_Fun>, | 392 | std::addressof(__large_destroy<_Fun>), |
| 555 | false, | 393 | false, |
| 556 | # if _LIBCPP_HAS_RTTI | 394 | # if _LIBCPP_HAS_RTTI |
| 557 | &typeid(typename _Fun::_Target) | 395 | &typeid(_Fun) |
| 558 | # else | 396 | # else |
| 559 | nullptr | 397 | nullptr |
| 560 | # endif | 398 | # endif |
| ... | @@ -569,7 +407,7 @@ private: | ... | @@ -569,7 +407,7 @@ private: |
| 569 | nullptr, | 407 | nullptr, |
| 570 | false, | 408 | false, |
| 571 | # if _LIBCPP_HAS_RTTI | 409 | # if _LIBCPP_HAS_RTTI |
| 572 | &typeid(typename _Fun::_Target) | 410 | &typeid(_Fun) |
| 573 | # else | 411 | # else |
| 574 | nullptr | 412 | nullptr |
| 575 | # endif | 413 | # endif |
| ... | @@ -583,42 +421,7 @@ private: | ... | @@ -583,42 +421,7 @@ private: |
| 583 | template <typename _Tp> | 421 | template <typename _Tp> |
| 584 | using __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>; | 422 | using __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>; |
| 585 | 423 | ||
| 586 | // __policy_invoker calls an instance of __alloc_func held in __policy_storage. | 424 | // __policy_func uses a __policy to create a type-erased, copyable functor. |
| 587 | |||
| 588 | template <class _Fp> | ||
| 589 | struct __policy_invoker; | ||
| 590 | |||
| 591 | template <class _Rp, class... _ArgTypes> | ||
| 592 | struct __policy_invoker<_Rp(_ArgTypes...)> { | ||
| 593 | typedef _Rp (*__Call)(const __policy_storage*, __fast_forward<_ArgTypes>...); | ||
| 594 | |||
| 595 | __Call __call_; | ||
| 596 | |||
| 597 | // Creates an invoker that throws bad_function_call. | ||
| 598 | _LIBCPP_HIDE_FROM_ABI __policy_invoker() : __call_(&__call_empty) {} | ||
| 599 | |||
| 600 | // Creates an invoker that calls the given instance of __func. | ||
| 601 | template <typename _Fun> | ||
| 602 | _LIBCPP_HIDE_FROM_ABI static __policy_invoker __create() { | ||
| 603 | return __policy_invoker(&__call_impl<_Fun>); | ||
| 604 | } | ||
| 605 | |||
| 606 | private: | ||
| 607 | _LIBCPP_HIDE_FROM_ABI explicit __policy_invoker(__Call __c) : __call_(__c) {} | ||
| 608 | |||
| 609 | _LIBCPP_HIDE_FROM_ABI static _Rp __call_empty(const __policy_storage*, __fast_forward<_ArgTypes>...) { | ||
| 610 | __throw_bad_function_call(); | ||
| 611 | } | ||
| 612 | |||
| 613 | template <typename _Fun> | ||
| 614 | _LIBCPP_HIDE_FROM_ABI static _Rp __call_impl(const __policy_storage* __buf, __fast_forward<_ArgTypes>... __args) { | ||
| 615 | _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value ? &__buf->__small : __buf->__large); | ||
| 616 | return (*__f)(std::forward<_ArgTypes>(__args)...); | ||
| 617 | } | ||
| 618 | }; | ||
| 619 | |||
| 620 | // __policy_func uses a __policy and __policy_invoker to create a type-erased, | ||
| 621 | // copyable functor. | ||
| 622 | 425 | ||
| 623 | template <class _Fp> | 426 | template <class _Fp> |
| 624 | class __policy_func; | 427 | class __policy_func; |
| ... | @@ -628,69 +431,52 @@ class __policy_func<_Rp(_ArgTypes...)> { | ... | @@ -628,69 +431,52 @@ class __policy_func<_Rp(_ArgTypes...)> { |
| 628 | // Inline storage for small objects. | 431 | // Inline storage for small objects. |
| 629 | __policy_storage __buf_; | 432 | __policy_storage __buf_; |
| 630 | 433 | ||
| 631 | // Calls the value stored in __buf_. This could technically be part of | 434 | using _ErasedFunc _LIBCPP_NODEBUG = _Rp(const __policy_storage*, __fast_forward<_ArgTypes>...); |
| 632 | // policy, but storing it here eliminates a level of indirection inside | 435 | |
| 633 | // operator(). | 436 | _ErasedFunc* __func_; |
| 634 | typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker; | ||
| 635 | __invoker __invoker_; | ||
| 636 | 437 | ||
| 637 | // The policy that describes how to move / copy / destroy __buf_. Never | 438 | // The policy that describes how to move / copy / destroy __buf_. Never |
| 638 | // null, even if the function is empty. | 439 | // null, even if the function is empty. |
| 639 | const __policy* __policy_; | 440 | const __policy* __policy_; |
| 640 | 441 | ||
| 641 | public: | 442 | _LIBCPP_HIDE_FROM_ABI static _Rp __empty_func(const __policy_storage*, __fast_forward<_ArgTypes>...) { |
| 642 | _LIBCPP_HIDE_FROM_ABI __policy_func() : __policy_(__policy::__create_empty()) {} | 443 | std::__throw_bad_function_call(); |
| 643 | 444 | } | |
| 644 | template <class _Fp, class _Alloc> | ||
| 645 | _LIBCPP_HIDE_FROM_ABI __policy_func(_Fp&& __f, const _Alloc& __a) : __policy_(__policy::__create_empty()) { | ||
| 646 | typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; | ||
| 647 | typedef allocator_traits<_Alloc> __alloc_traits; | ||
| 648 | typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc; | ||
| 649 | 445 | ||
| 650 | if (__function::__not_null(__f)) { | 446 | template <class _Fun> |
| 651 | __invoker_ = __invoker::template __create<_Fun>(); | 447 | _LIBCPP_HIDE_FROM_ABI static _Rp __call_func(const __policy_storage* __buf, __fast_forward<_ArgTypes>... __args) { |
| 652 | __policy_ = __policy::__create<_Fun>(); | 448 | _Fun* __func = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value ? &__buf->__small : __buf->__large); |
| 653 | 449 | ||
| 654 | _FunAlloc __af(__a); | 450 | return std::__invoke_r<_Rp>(*__func, std::forward<_ArgTypes>(__args)...); |
| 655 | if (__use_small_storage<_Fun>()) { | ||
| 656 | ::new ((void*)&__buf_.__small) _Fun(std::move(__f), _Alloc(__af)); | ||
| 657 | } else { | ||
| 658 | typedef __allocator_destructor<_FunAlloc> _Dp; | ||
| 659 | unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); | ||
| 660 | ::new ((void*)__hold.get()) _Fun(std::move(__f), _Alloc(__af)); | ||
| 661 | __buf_.__large = __hold.release(); | ||
| 662 | } | ||
| 663 | } | ||
| 664 | } | 451 | } |
| 665 | 452 | ||
| 453 | public: | ||
| 454 | _LIBCPP_HIDE_FROM_ABI __policy_func() : __func_(__empty_func), __policy_(__policy::__create_empty()) {} | ||
| 455 | |||
| 666 | template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0> | 456 | template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0> |
| 667 | _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) { | 457 | _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) { |
| 668 | typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun; | ||
| 669 | |||
| 670 | if (__function::__not_null(__f)) { | 458 | if (__function::__not_null(__f)) { |
| 671 | __invoker_ = __invoker::template __create<_Fun>(); | 459 | __func_ = __call_func<_Fp>; |
| 672 | __policy_ = __policy::__create<_Fun>(); | 460 | __policy_ = __policy::__create<_Fp>(); |
| 673 | if (__use_small_storage<_Fun>()) { | 461 | if (__use_small_storage<_Fp>()) { |
| 674 | ::new ((void*)&__buf_.__small) _Fun(std::move(__f)); | 462 | ::new ((void*)&__buf_.__small) _Fp(std::move(__f)); |
| 675 | } else { | 463 | } else { |
| 676 | unique_ptr<_Fun, __deallocating_deleter<_Fun>> __hold(std::__libcpp_allocate<_Fun>(__element_count(1))); | 464 | __buf_.__large = ::new _Fp(std::move(__f)); |
| 677 | __buf_.__large = ::new ((void*)__hold.get()) _Fun(std::move(__f)); | ||
| 678 | (void)__hold.release(); | ||
| 679 | } | 465 | } |
| 680 | } | 466 | } |
| 681 | } | 467 | } |
| 682 | 468 | ||
| 683 | _LIBCPP_HIDE_FROM_ABI __policy_func(const __policy_func& __f) | 469 | _LIBCPP_HIDE_FROM_ABI __policy_func(const __policy_func& __f) |
| 684 | : __buf_(__f.__buf_), __invoker_(__f.__invoker_), __policy_(__f.__policy_) { | 470 | : __buf_(__f.__buf_), __func_(__f.__func_), __policy_(__f.__policy_) { |
| 685 | if (__policy_->__clone) | 471 | if (__policy_->__clone) |
| 686 | __buf_.__large = __policy_->__clone(__f.__buf_.__large); | 472 | __buf_.__large = __policy_->__clone(__f.__buf_.__large); |
| 687 | } | 473 | } |
| 688 | 474 | ||
| 689 | _LIBCPP_HIDE_FROM_ABI __policy_func(__policy_func&& __f) | 475 | _LIBCPP_HIDE_FROM_ABI __policy_func(__policy_func&& __f) |
| 690 | : __buf_(__f.__buf_), __invoker_(__f.__invoker_), __policy_(__f.__policy_) { | 476 | : __buf_(__f.__buf_), __func_(__f.__func_), __policy_(__f.__policy_) { |
| 691 | if (__policy_->__destroy) { | 477 | if (__policy_->__destroy) { |
| 692 | __f.__policy_ = __policy::__create_empty(); | 478 | __f.__policy_ = __policy::__create_empty(); |
| 693 | __f.__invoker_ = __invoker(); | 479 | __f.__func_ = {}; |
| 694 | } | 480 | } |
| 695 | } | 481 | } |
| 696 | 482 | ||
| ... | @@ -700,30 +486,30 @@ public: | ... | @@ -700,30 +486,30 @@ public: |
| 700 | } | 486 | } |
| 701 | 487 | ||
| 702 | _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(__policy_func&& __f) { | 488 | _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(__policy_func&& __f) { |
| 703 | *this = nullptr; | 489 | *this = nullptr; |
| 704 | __buf_ = __f.__buf_; | 490 | __buf_ = __f.__buf_; |
| 705 | __invoker_ = __f.__invoker_; | 491 | __func_ = __f.__func_; |
| 706 | __policy_ = __f.__policy_; | 492 | __policy_ = __f.__policy_; |
| 707 | __f.__policy_ = __policy::__create_empty(); | 493 | __f.__policy_ = __policy::__create_empty(); |
| 708 | __f.__invoker_ = __invoker(); | 494 | __f.__func_ = {}; |
| 709 | return *this; | 495 | return *this; |
| 710 | } | 496 | } |
| 711 | 497 | ||
| 712 | _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(nullptr_t) { | 498 | _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(nullptr_t) { |
| 713 | const __policy* __p = __policy_; | 499 | const __policy* __p = __policy_; |
| 714 | __policy_ = __policy::__create_empty(); | 500 | __policy_ = __policy::__create_empty(); |
| 715 | __invoker_ = __invoker(); | 501 | __func_ = {}; |
| 716 | if (__p->__destroy) | 502 | if (__p->__destroy) |
| 717 | __p->__destroy(__buf_.__large); | 503 | __p->__destroy(__buf_.__large); |
| 718 | return *this; | 504 | return *this; |
| 719 | } | 505 | } |
| 720 | 506 | ||
| 721 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const { | 507 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const { |
| 722 | return __invoker_.__call_(std::addressof(__buf_), std::forward<_ArgTypes>(__args)...); | 508 | return __func_(std::addressof(__buf_), std::forward<_ArgTypes>(__args)...); |
| 723 | } | 509 | } |
| 724 | 510 | ||
| 725 | _LIBCPP_HIDE_FROM_ABI void swap(__policy_func& __f) { | 511 | _LIBCPP_HIDE_FROM_ABI void swap(__policy_func& __f) { |
| 726 | std::swap(__invoker_, __f.__invoker_); | 512 | std::swap(__func_, __f.__func_); |
| 727 | std::swap(__policy_, __f.__policy_); | 513 | std::swap(__policy_, __f.__policy_); |
| 728 | std::swap(__buf_, __f.__buf_); | 514 | std::swap(__buf_, __f.__buf_); |
| 729 | } | 515 | } |
| ... | @@ -750,14 +536,14 @@ public: | ... | @@ -750,14 +536,14 @@ public: |
| 750 | extern "C" void* _Block_copy(const void*); | 536 | extern "C" void* _Block_copy(const void*); |
| 751 | extern "C" void _Block_release(const void*); | 537 | extern "C" void _Block_release(const void*); |
| 752 | 538 | ||
| 753 | template <class _Rp1, class... _ArgTypes1, class _Alloc, class _Rp, class... _ArgTypes> | 539 | template <class _Rp1, class... _ArgTypes1, class _Rp, class... _ArgTypes> |
| 754 | class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> { | 540 | class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> { |
| 755 | typedef _Rp1 (^__block_type)(_ArgTypes1...); | 541 | typedef _Rp1 (^__block_type)(_ArgTypes1...); |
| 756 | __block_type __f_; | 542 | __block_type __f_; |
| 757 | 543 | ||
| 758 | public: | 544 | public: |
| 759 | _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f) | 545 | _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f) |
| 760 | # if _LIBCPP_HAS_OBJC_ARC | 546 | # if __has_feature(objc_arc) |
| 761 | : __f_(__f) | 547 | : __f_(__f) |
| 762 | # else | 548 | # else |
| 763 | : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) | 549 | : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) |
| ... | @@ -767,15 +553,6 @@ public: | ... | @@ -767,15 +553,6 @@ public: |
| 767 | 553 | ||
| 768 | // [TODO] add && to save on a retain | 554 | // [TODO] add && to save on a retain |
| 769 | 555 | ||
| 770 | _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type __f, const _Alloc& /* unused */) | ||
| 771 | # if _LIBCPP_HAS_OBJC_ARC | ||
| 772 | : __f_(__f) | ||
| 773 | # else | ||
| 774 | : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) | ||
| 775 | # endif | ||
| 776 | { | ||
| 777 | } | ||
| 778 | |||
| 779 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const { | 556 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const { |
| 780 | _LIBCPP_ASSERT_INTERNAL( | 557 | _LIBCPP_ASSERT_INTERNAL( |
| 781 | false, | 558 | false, |
| ... | @@ -790,7 +567,7 @@ public: | ... | @@ -790,7 +567,7 @@ public: |
| 790 | } | 567 | } |
| 791 | 568 | ||
| 792 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT { | 569 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT { |
| 793 | # if !_LIBCPP_HAS_OBJC_ARC | 570 | # if !__has_feature(objc_arc) |
| 794 | if (__f_) | 571 | if (__f_) |
| 795 | _Block_release(__f_); | 572 | _Block_release(__f_); |
| 796 | # endif | 573 | # endif |
| ... | @@ -822,12 +599,12 @@ public: | ... | @@ -822,12 +599,12 @@ public: |
| 822 | # endif // _LIBCPP_HAS_RTTI | 599 | # endif // _LIBCPP_HAS_RTTI |
| 823 | }; | 600 | }; |
| 824 | 601 | ||
| 825 | # endif // _LIBCPP_HAS_EXTENSION_BLOCKS | 602 | # endif // _LIBCPP_HAS_BLOCKS_RUNTIME |
| 826 | 603 | ||
| 827 | } // namespace __function | 604 | } // namespace __function |
| 828 | 605 | ||
| 829 | template <class _Rp, class... _ArgTypes> | 606 | template <class _Rp, class... _ArgTypes> |
| 830 | class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> | 607 | class function<_Rp(_ArgTypes...)> |
| 831 | : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, | 608 | : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, |
| 832 | public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> { | 609 | public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> { |
| 833 | # ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION | 610 | # ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION |
| ... | @@ -954,7 +731,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(std::move(__f)) {} | ... | @@ -954,7 +731,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(std::move(__f)) {} |
| 954 | # if _LIBCPP_STD_VER <= 14 | 731 | # if _LIBCPP_STD_VER <= 14 |
| 955 | template <class _Rp, class... _ArgTypes> | 732 | template <class _Rp, class... _ArgTypes> |
| 956 | template <class _Fp, class _Alloc, class> | 733 | template <class _Fp, class _Alloc, class> |
| 957 | function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a, _Fp __f) : __f_(std::move(__f), __a) {} | 734 | function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, _Fp __f) : __f_(std::move(__f)) {} |
| 958 | # endif | 735 | # endif |
| 959 | 736 | ||
| 960 | template <class _Rp, class... _ArgTypes> | 737 | template <class _Rp, class... _ArgTypes> |
lib/libcxx/include/__functional/hash.h+44-126| ... | @@ -13,11 +13,14 @@ | ... | @@ -13,11 +13,14 @@ |
| 13 | #include <__cstddef/nullptr_t.h> | 13 | #include <__cstddef/nullptr_t.h> |
| 14 | #include <__functional/unary_function.h> | 14 | #include <__functional/unary_function.h> |
| 15 | #include <__fwd/functional.h> | 15 | #include <__fwd/functional.h> |
| 16 | #include <__memory/addressof.h> | ||
| 16 | #include <__type_traits/conjunction.h> | 17 | #include <__type_traits/conjunction.h> |
| 17 | #include <__type_traits/enable_if.h> | 18 | #include <__type_traits/enable_if.h> |
| 18 | #include <__type_traits/invoke.h> | 19 | #include <__type_traits/invoke.h> |
| 19 | #include <__type_traits/is_constructible.h> | 20 | #include <__type_traits/is_constructible.h> |
| 20 | #include <__type_traits/is_enum.h> | 21 | #include <__type_traits/is_enum.h> |
| 22 | #include <__type_traits/is_floating_point.h> | ||
| 23 | #include <__type_traits/is_integral.h> | ||
| 21 | #include <__type_traits/underlying_type.h> | 24 | #include <__type_traits/underlying_type.h> |
| 22 | #include <__utility/pair.h> | 25 | #include <__utility/pair.h> |
| 23 | #include <__utility/swap.h> | 26 | #include <__utility/swap.h> |
| ... | @@ -33,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -33,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | template <class _Size> | 36 | template <class _Size> |
| 34 | inline _LIBCPP_HIDE_FROM_ABI _Size __loadword(const void* __p) { | 37 | inline _LIBCPP_HIDE_FROM_ABI _Size __loadword(const void* __p) { |
| 35 | _Size __r; | 38 | _Size __r; |
| 36 | std::memcpy(&__r, __p, sizeof(__r)); | 39 | std::memcpy(std::addressof(__r), __p, sizeof(__r)); |
| 37 | return __r; | 40 | return __r; |
| 38 | } | 41 | } |
| 39 | 42 | ||
| ... | @@ -63,10 +66,10 @@ struct __murmur2_or_cityhash<_Size, 32> { | ... | @@ -63,10 +66,10 @@ struct __murmur2_or_cityhash<_Size, 32> { |
| 63 | switch (__len) { | 66 | switch (__len) { |
| 64 | case 3: | 67 | case 3: |
| 65 | __h ^= static_cast<_Size>(__data[2] << 16); | 68 | __h ^= static_cast<_Size>(__data[2] << 16); |
| 66 | _LIBCPP_FALLTHROUGH(); | 69 | [[__fallthrough__]]; |
| 67 | case 2: | 70 | case 2: |
| 68 | __h ^= static_cast<_Size>(__data[1] << 8); | 71 | __h ^= static_cast<_Size>(__data[1] << 8); |
| 69 | _LIBCPP_FALLTHROUGH(); | 72 | [[__fallthrough__]]; |
| 70 | case 1: | 73 | case 1: |
| 71 | __h ^= __data[0]; | 74 | __h ^= __data[0]; |
| 72 | __h *= __m; | 75 | __h *= __m; |
| ... | @@ -237,6 +240,14 @@ private: | ... | @@ -237,6 +240,14 @@ private: |
| 237 | } | 240 | } |
| 238 | }; | 241 | }; |
| 239 | 242 | ||
| 243 | #if _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY | ||
| 244 | [[__gnu__::__pure__]] _LIBCPP_EXPORTED_FROM_ABI size_t __hash_memory(_LIBCPP_NOESCAPE const void*, size_t) _NOEXCEPT; | ||
| 245 | #else | ||
| 246 | _LIBCPP_HIDE_FROM_ABI inline size_t __hash_memory(const void* __ptr, size_t __size) _NOEXCEPT { | ||
| 247 | return __murmur2_or_cityhash<size_t>()(__ptr, __size); | ||
| 248 | } | ||
| 249 | #endif | ||
| 250 | |||
| 240 | template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> | 251 | template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> |
| 241 | struct __scalar_hash; | 252 | struct __scalar_hash; |
| 242 | 253 | ||
| ... | @@ -276,7 +287,7 @@ struct __scalar_hash<_Tp, 2> : public __unary_function<_Tp, size_t> { | ... | @@ -276,7 +287,7 @@ struct __scalar_hash<_Tp, 2> : public __unary_function<_Tp, size_t> { |
| 276 | } __s; | 287 | } __s; |
| 277 | } __u; | 288 | } __u; |
| 278 | __u.__t = __v; | 289 | __u.__t = __v; |
| 279 | return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 290 | return std::__hash_memory(std::addressof(__u), sizeof(__u)); |
| 280 | } | 291 | } |
| 281 | }; | 292 | }; |
| 282 | 293 | ||
| ... | @@ -292,7 +303,7 @@ struct __scalar_hash<_Tp, 3> : public __unary_function<_Tp, size_t> { | ... | @@ -292,7 +303,7 @@ struct __scalar_hash<_Tp, 3> : public __unary_function<_Tp, size_t> { |
| 292 | } __s; | 303 | } __s; |
| 293 | } __u; | 304 | } __u; |
| 294 | __u.__t = __v; | 305 | __u.__t = __v; |
| 295 | return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 306 | return std::__hash_memory(std::addressof(__u), sizeof(__u)); |
| 296 | } | 307 | } |
| 297 | }; | 308 | }; |
| 298 | 309 | ||
| ... | @@ -309,7 +320,7 @@ struct __scalar_hash<_Tp, 4> : public __unary_function<_Tp, size_t> { | ... | @@ -309,7 +320,7 @@ struct __scalar_hash<_Tp, 4> : public __unary_function<_Tp, size_t> { |
| 309 | } __s; | 320 | } __s; |
| 310 | } __u; | 321 | } __u; |
| 311 | __u.__t = __v; | 322 | __u.__t = __v; |
| 312 | return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 323 | return std::__hash_memory(std::addressof(__u), sizeof(__u)); |
| 313 | } | 324 | } |
| 314 | }; | 325 | }; |
| 315 | 326 | ||
| ... | @@ -325,133 +336,54 @@ _LIBCPP_HIDE_FROM_ABI inline size_t __hash_combine(size_t __lhs, size_t __rhs) _ | ... | @@ -325,133 +336,54 @@ _LIBCPP_HIDE_FROM_ABI inline size_t __hash_combine(size_t __lhs, size_t __rhs) _ |
| 325 | } | 336 | } |
| 326 | 337 | ||
| 327 | template <class _Tp> | 338 | template <class _Tp> |
| 328 | struct _LIBCPP_TEMPLATE_VIS hash<_Tp*> : public __unary_function<_Tp*, size_t> { | 339 | struct hash<_Tp*> : public __unary_function<_Tp*, size_t> { |
| 329 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp* __v) const _NOEXCEPT { | 340 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp* __v) const _NOEXCEPT { |
| 330 | union { | 341 | union { |
| 331 | _Tp* __t; | 342 | _Tp* __t; |
| 332 | size_t __a; | 343 | size_t __a; |
| 333 | } __u; | 344 | } __u; |
| 334 | __u.__t = __v; | 345 | __u.__t = __v; |
| 335 | return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 346 | return std::__hash_memory(std::addressof(__u), sizeof(__u)); |
| 336 | } | 347 | } |
| 337 | }; | 348 | }; |
| 338 | 349 | ||
| 339 | template <> | 350 | template <class _Tp, class = void> |
| 340 | struct _LIBCPP_TEMPLATE_VIS hash<bool> : public __unary_function<bool, size_t> { | 351 | struct __hash_impl { |
| 341 | _LIBCPP_HIDE_FROM_ABI size_t operator()(bool __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | 352 | __hash_impl() = delete; |
| 342 | }; | 353 | __hash_impl(__hash_impl const&) = delete; |
| 343 | 354 | __hash_impl& operator=(__hash_impl const&) = delete; | |
| 344 | template <> | ||
| 345 | struct _LIBCPP_TEMPLATE_VIS hash<char> : public __unary_function<char, size_t> { | ||
| 346 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 347 | }; | 355 | }; |
| 348 | 356 | ||
| 349 | template <> | 357 | template <class _Tp> |
| 350 | struct _LIBCPP_TEMPLATE_VIS hash<signed char> : public __unary_function<signed char, size_t> { | 358 | struct __hash_impl<_Tp, __enable_if_t<is_enum<_Tp>::value> > : __unary_function<_Tp, size_t> { |
| 351 | _LIBCPP_HIDE_FROM_ABI size_t operator()(signed char __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | 359 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { |
| 352 | }; | 360 | using type = __underlying_type_t<_Tp>; |
| 353 | 361 | return hash<type>()(static_cast<type>(__v)); | |
| 354 | template <> | ||
| 355 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public __unary_function<unsigned char, size_t> { | ||
| 356 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 357 | }; | ||
| 358 | |||
| 359 | #if _LIBCPP_HAS_CHAR8_T | ||
| 360 | template <> | ||
| 361 | struct _LIBCPP_TEMPLATE_VIS hash<char8_t> : public __unary_function<char8_t, size_t> { | ||
| 362 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char8_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 363 | }; | ||
| 364 | #endif // _LIBCPP_HAS_CHAR8_T | ||
| 365 | |||
| 366 | template <> | ||
| 367 | struct _LIBCPP_TEMPLATE_VIS hash<char16_t> : public __unary_function<char16_t, size_t> { | ||
| 368 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char16_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 369 | }; | ||
| 370 | |||
| 371 | template <> | ||
| 372 | struct _LIBCPP_TEMPLATE_VIS hash<char32_t> : public __unary_function<char32_t, size_t> { | ||
| 373 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char32_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 374 | }; | ||
| 375 | |||
| 376 | #if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 377 | template <> | ||
| 378 | struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> : public __unary_function<wchar_t, size_t> { | ||
| 379 | _LIBCPP_HIDE_FROM_ABI size_t operator()(wchar_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 380 | }; | ||
| 381 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 382 | |||
| 383 | template <> | ||
| 384 | struct _LIBCPP_TEMPLATE_VIS hash<short> : public __unary_function<short, size_t> { | ||
| 385 | _LIBCPP_HIDE_FROM_ABI size_t operator()(short __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 386 | }; | ||
| 387 | |||
| 388 | template <> | ||
| 389 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> : public __unary_function<unsigned short, size_t> { | ||
| 390 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned short __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 391 | }; | ||
| 392 | |||
| 393 | template <> | ||
| 394 | struct _LIBCPP_TEMPLATE_VIS hash<int> : public __unary_function<int, size_t> { | ||
| 395 | _LIBCPP_HIDE_FROM_ABI size_t operator()(int __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 396 | }; | ||
| 397 | |||
| 398 | template <> | ||
| 399 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> : public __unary_function<unsigned int, size_t> { | ||
| 400 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned int __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 401 | }; | ||
| 402 | |||
| 403 | template <> | ||
| 404 | struct _LIBCPP_TEMPLATE_VIS hash<long> : public __unary_function<long, size_t> { | ||
| 405 | _LIBCPP_HIDE_FROM_ABI size_t operator()(long __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | ||
| 406 | }; | ||
| 407 | |||
| 408 | template <> | ||
| 409 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public __unary_function<unsigned long, size_t> { | ||
| 410 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __v) const _NOEXCEPT { | ||
| 411 | static_assert(sizeof(size_t) >= sizeof(unsigned long), | ||
| 412 | "This would be a terrible hash function on a platform where size_t is smaller than unsigned long"); | ||
| 413 | return static_cast<size_t>(__v); | ||
| 414 | } | 362 | } |
| 415 | }; | 363 | }; |
| 416 | 364 | ||
| 417 | template <> | 365 | template <class _Tp> |
| 418 | struct _LIBCPP_TEMPLATE_VIS hash<long long> : public __scalar_hash<long long> {}; | 366 | struct __hash_impl<_Tp, __enable_if_t<is_integral<_Tp>::value && (sizeof(_Tp) <= sizeof(size_t))> > |
| 419 | 367 | : __unary_function<_Tp, size_t> { | |
| 420 | template <> | 368 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { return static_cast<size_t>(__v); } |
| 421 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> : public __scalar_hash<unsigned long long> {}; | 369 | }; |
| 422 | |||
| 423 | #if _LIBCPP_HAS_INT128 | ||
| 424 | |||
| 425 | template <> | ||
| 426 | struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> : public __scalar_hash<__int128_t> {}; | ||
| 427 | |||
| 428 | template <> | ||
| 429 | struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t> : public __scalar_hash<__uint128_t> {}; | ||
| 430 | 370 | ||
| 431 | #endif | 371 | template <class _Tp> |
| 372 | struct __hash_impl<_Tp, __enable_if_t<is_integral<_Tp>::value && (sizeof(_Tp) > sizeof(size_t))> > | ||
| 373 | : __scalar_hash<_Tp> {}; | ||
| 432 | 374 | ||
| 433 | template <> | 375 | template <class _Tp> |
| 434 | struct _LIBCPP_TEMPLATE_VIS hash<float> : public __scalar_hash<float> { | 376 | struct __hash_impl<_Tp, __enable_if_t<is_floating_point<_Tp>::value> > : __scalar_hash<_Tp> { |
| 435 | _LIBCPP_HIDE_FROM_ABI size_t operator()(float __v) const _NOEXCEPT { | 377 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { |
| 436 | // -0.0 and 0.0 should return same hash | 378 | // -0.0 and 0.0 should return same hash |
| 437 | if (__v == 0.0f) | 379 | if (__v == 0.0f) |
| 438 | return 0; | 380 | return 0; |
| 439 | return __scalar_hash<float>::operator()(__v); | 381 | return __scalar_hash<_Tp>::operator()(__v); |
| 440 | } | ||
| 441 | }; | ||
| 442 | |||
| 443 | template <> | ||
| 444 | struct _LIBCPP_TEMPLATE_VIS hash<double> : public __scalar_hash<double> { | ||
| 445 | _LIBCPP_HIDE_FROM_ABI size_t operator()(double __v) const _NOEXCEPT { | ||
| 446 | // -0.0 and 0.0 should return same hash | ||
| 447 | if (__v == 0.0) | ||
| 448 | return 0; | ||
| 449 | return __scalar_hash<double>::operator()(__v); | ||
| 450 | } | 382 | } |
| 451 | }; | 383 | }; |
| 452 | 384 | ||
| 453 | template <> | 385 | template <> |
| 454 | struct _LIBCPP_TEMPLATE_VIS hash<long double> : public __scalar_hash<long double> { | 386 | struct __hash_impl<long double> : __scalar_hash<long double> { |
| 455 | _LIBCPP_HIDE_FROM_ABI size_t operator()(long double __v) const _NOEXCEPT { | 387 | _LIBCPP_HIDE_FROM_ABI size_t operator()(long double __v) const _NOEXCEPT { |
| 456 | // -0.0 and 0.0 should return same hash | 388 | // -0.0 and 0.0 should return same hash |
| 457 | if (__v == 0.0L) | 389 | if (__v == 0.0L) |
| ... | @@ -492,27 +424,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double> : public __scalar_hash<long double | ... | @@ -492,27 +424,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double> : public __scalar_hash<long double |
| 492 | } | 424 | } |
| 493 | }; | 425 | }; |
| 494 | 426 | ||
| 495 | template <class _Tp, bool = is_enum<_Tp>::value> | ||
| 496 | struct _LIBCPP_TEMPLATE_VIS __enum_hash : public __unary_function<_Tp, size_t> { | ||
| 497 | _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { | ||
| 498 | typedef typename underlying_type<_Tp>::type type; | ||
| 499 | return hash<type>()(static_cast<type>(__v)); | ||
| 500 | } | ||
| 501 | }; | ||
| 502 | template <class _Tp> | ||
| 503 | struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> { | ||
| 504 | __enum_hash() = delete; | ||
| 505 | __enum_hash(__enum_hash const&) = delete; | ||
| 506 | __enum_hash& operator=(__enum_hash const&) = delete; | ||
| 507 | }; | ||
| 508 | |||
| 509 | template <class _Tp> | 427 | template <class _Tp> |
| 510 | struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> {}; | 428 | struct hash : public __hash_impl<_Tp> {}; |
| 511 | 429 | ||
| 512 | #if _LIBCPP_STD_VER >= 17 | 430 | #if _LIBCPP_STD_VER >= 17 |
| 513 | 431 | ||
| 514 | template <> | 432 | template <> |
| 515 | struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> : public __unary_function<nullptr_t, size_t> { | 433 | struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> { |
| 516 | _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; } | 434 | _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; } |
| 517 | }; | 435 | }; |
| 518 | #endif | 436 | #endif |
lib/libcxx/include/__functional/mem_fun_ref.h+8-9| ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) | 23 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) |
| 24 | 24 | ||
| 25 | template <class _Sp, class _Tp> | 25 | template <class _Sp, class _Tp> |
| 26 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> { | 26 | class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> { |
| 27 | _Sp (_Tp::*__p_)(); | 27 | _Sp (_Tp::*__p_)(); |
| 28 | 28 | ||
| 29 | public: | 29 | public: |
| ... | @@ -32,7 +32,7 @@ public: | ... | @@ -32,7 +32,7 @@ public: |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | template <class _Sp, class _Tp, class _Ap> | 34 | template <class _Sp, class _Tp, class _Ap> |
| 35 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t : public __binary_function<_Tp*, _Ap, _Sp> { | 35 | class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t : public __binary_function<_Tp*, _Ap, _Sp> { |
| 36 | _Sp (_Tp::*__p_)(_Ap); | 36 | _Sp (_Tp::*__p_)(_Ap); |
| 37 | 37 | ||
| 38 | public: | 38 | public: |
| ... | @@ -51,7 +51,7 @@ _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun1_t<_Sp, _Tp, _A | ... | @@ -51,7 +51,7 @@ _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun1_t<_Sp, _Tp, _A |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | template <class _Sp, class _Tp> | 53 | template <class _Sp, class _Tp> |
| 54 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t : public __unary_function<_Tp, _Sp> { | 54 | class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t : public __unary_function<_Tp, _Sp> { |
| 55 | _Sp (_Tp::*__p_)(); | 55 | _Sp (_Tp::*__p_)(); |
| 56 | 56 | ||
| 57 | public: | 57 | public: |
| ... | @@ -60,7 +60,7 @@ public: | ... | @@ -60,7 +60,7 @@ public: |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | template <class _Sp, class _Tp, class _Ap> | 62 | template <class _Sp, class _Tp, class _Ap> |
| 63 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> { | 63 | class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> { |
| 64 | _Sp (_Tp::*__p_)(_Ap); | 64 | _Sp (_Tp::*__p_)(_Ap); |
| 65 | 65 | ||
| 66 | public: | 66 | public: |
| ... | @@ -80,7 +80,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) { | ... | @@ -80,7 +80,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) { |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | template <class _Sp, class _Tp> | 82 | template <class _Sp, class _Tp> |
| 83 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t : public __unary_function<const _Tp*, _Sp> { | 83 | class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t : public __unary_function<const _Tp*, _Sp> { |
| 84 | _Sp (_Tp::*__p_)() const; | 84 | _Sp (_Tp::*__p_)() const; |
| 85 | 85 | ||
| 86 | public: | 86 | public: |
| ... | @@ -89,8 +89,7 @@ public: | ... | @@ -89,8 +89,7 @@ public: |
| 89 | }; | 89 | }; |
| 90 | 90 | ||
| 91 | template <class _Sp, class _Tp, class _Ap> | 91 | template <class _Sp, class _Tp, class _Ap> |
| 92 | class _LIBCPP_TEMPLATE_VIS | 92 | class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t : public __binary_function<const _Tp*, _Ap, _Sp> { |
| 93 | _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t : public __binary_function<const _Tp*, _Ap, _Sp> { | ||
| 94 | _Sp (_Tp::*__p_)(_Ap) const; | 93 | _Sp (_Tp::*__p_)(_Ap) const; |
| 95 | 94 | ||
| 96 | public: | 95 | public: |
| ... | @@ -110,7 +109,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) { | ... | @@ -110,7 +109,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) { |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 112 | template <class _Sp, class _Tp> | 111 | template <class _Sp, class _Tp> |
| 113 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t : public __unary_function<_Tp, _Sp> { | 112 | class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t : public __unary_function<_Tp, _Sp> { |
| 114 | _Sp (_Tp::*__p_)() const; | 113 | _Sp (_Tp::*__p_)() const; |
| 115 | 114 | ||
| 116 | public: | 115 | public: |
| ... | @@ -119,7 +118,7 @@ public: | ... | @@ -119,7 +118,7 @@ public: |
| 119 | }; | 118 | }; |
| 120 | 119 | ||
| 121 | template <class _Sp, class _Tp, class _Ap> | 120 | template <class _Sp, class _Tp, class _Ap> |
| 122 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> { | 121 | class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> { |
| 123 | _Sp (_Tp::*__p_)(_Ap) const; | 122 | _Sp (_Tp::*__p_)(_Ap) const; |
| 124 | 123 | ||
| 125 | public: | 124 | public: |
lib/libcxx/include/__functional/operations.h+39-42| ... | @@ -13,6 +13,7 @@ | ... | @@ -13,6 +13,7 @@ |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__functional/binary_function.h> | 14 | #include <__functional/binary_function.h> |
| 15 | #include <__functional/unary_function.h> | 15 | #include <__functional/unary_function.h> |
| 16 | #include <__fwd/functional.h> | ||
| 16 | #include <__type_traits/desugars_to.h> | 17 | #include <__type_traits/desugars_to.h> |
| 17 | #include <__type_traits/is_integral.h> | 18 | #include <__type_traits/is_integral.h> |
| 18 | #include <__utility/forward.h> | 19 | #include <__utility/forward.h> |
| ... | @@ -30,7 +31,7 @@ template <class _Tp = void> | ... | @@ -30,7 +31,7 @@ template <class _Tp = void> |
| 30 | #else | 31 | #else |
| 31 | template <class _Tp> | 32 | template <class _Tp> |
| 32 | #endif | 33 | #endif |
| 33 | struct _LIBCPP_TEMPLATE_VIS plus : __binary_function<_Tp, _Tp, _Tp> { | 34 | struct plus : __binary_function<_Tp, _Tp, _Tp> { |
| 34 | typedef _Tp __result_type; // used by valarray | 35 | typedef _Tp __result_type; // used by valarray |
| 35 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 36 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 36 | return __x + __y; | 37 | return __x + __y; |
| ... | @@ -48,7 +49,7 @@ inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true; | ... | @@ -48,7 +49,7 @@ inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true; |
| 48 | 49 | ||
| 49 | #if _LIBCPP_STD_VER >= 14 | 50 | #if _LIBCPP_STD_VER >= 14 |
| 50 | template <> | 51 | template <> |
| 51 | struct _LIBCPP_TEMPLATE_VIS plus<void> { | 52 | struct plus<void> { |
| 52 | template <class _T1, class _T2> | 53 | template <class _T1, class _T2> |
| 53 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 54 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 54 | noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) // | 55 | noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) // |
| ... | @@ -64,7 +65,7 @@ template <class _Tp = void> | ... | @@ -64,7 +65,7 @@ template <class _Tp = void> |
| 64 | #else | 65 | #else |
| 65 | template <class _Tp> | 66 | template <class _Tp> |
| 66 | #endif | 67 | #endif |
| 67 | struct _LIBCPP_TEMPLATE_VIS minus : __binary_function<_Tp, _Tp, _Tp> { | 68 | struct minus : __binary_function<_Tp, _Tp, _Tp> { |
| 68 | typedef _Tp __result_type; // used by valarray | 69 | typedef _Tp __result_type; // used by valarray |
| 69 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 70 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 70 | return __x - __y; | 71 | return __x - __y; |
| ... | @@ -74,7 +75,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus); | ... | @@ -74,7 +75,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus); |
| 74 | 75 | ||
| 75 | #if _LIBCPP_STD_VER >= 14 | 76 | #if _LIBCPP_STD_VER >= 14 |
| 76 | template <> | 77 | template <> |
| 77 | struct _LIBCPP_TEMPLATE_VIS minus<void> { | 78 | struct minus<void> { |
| 78 | template <class _T1, class _T2> | 79 | template <class _T1, class _T2> |
| 79 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 80 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 80 | noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) // | 81 | noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) // |
| ... | @@ -90,7 +91,7 @@ template <class _Tp = void> | ... | @@ -90,7 +91,7 @@ template <class _Tp = void> |
| 90 | #else | 91 | #else |
| 91 | template <class _Tp> | 92 | template <class _Tp> |
| 92 | #endif | 93 | #endif |
| 93 | struct _LIBCPP_TEMPLATE_VIS multiplies : __binary_function<_Tp, _Tp, _Tp> { | 94 | struct multiplies : __binary_function<_Tp, _Tp, _Tp> { |
| 94 | typedef _Tp __result_type; // used by valarray | 95 | typedef _Tp __result_type; // used by valarray |
| 95 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 96 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 96 | return __x * __y; | 97 | return __x * __y; |
| ... | @@ -100,7 +101,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies); | ... | @@ -100,7 +101,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies); |
| 100 | 101 | ||
| 101 | #if _LIBCPP_STD_VER >= 14 | 102 | #if _LIBCPP_STD_VER >= 14 |
| 102 | template <> | 103 | template <> |
| 103 | struct _LIBCPP_TEMPLATE_VIS multiplies<void> { | 104 | struct multiplies<void> { |
| 104 | template <class _T1, class _T2> | 105 | template <class _T1, class _T2> |
| 105 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 106 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 106 | noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) // | 107 | noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) // |
| ... | @@ -116,7 +117,7 @@ template <class _Tp = void> | ... | @@ -116,7 +117,7 @@ template <class _Tp = void> |
| 116 | #else | 117 | #else |
| 117 | template <class _Tp> | 118 | template <class _Tp> |
| 118 | #endif | 119 | #endif |
| 119 | struct _LIBCPP_TEMPLATE_VIS divides : __binary_function<_Tp, _Tp, _Tp> { | 120 | struct divides : __binary_function<_Tp, _Tp, _Tp> { |
| 120 | typedef _Tp __result_type; // used by valarray | 121 | typedef _Tp __result_type; // used by valarray |
| 121 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 122 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 122 | return __x / __y; | 123 | return __x / __y; |
| ... | @@ -126,7 +127,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides); | ... | @@ -126,7 +127,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides); |
| 126 | 127 | ||
| 127 | #if _LIBCPP_STD_VER >= 14 | 128 | #if _LIBCPP_STD_VER >= 14 |
| 128 | template <> | 129 | template <> |
| 129 | struct _LIBCPP_TEMPLATE_VIS divides<void> { | 130 | struct divides<void> { |
| 130 | template <class _T1, class _T2> | 131 | template <class _T1, class _T2> |
| 131 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 132 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 132 | noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) // | 133 | noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) // |
| ... | @@ -142,7 +143,7 @@ template <class _Tp = void> | ... | @@ -142,7 +143,7 @@ template <class _Tp = void> |
| 142 | #else | 143 | #else |
| 143 | template <class _Tp> | 144 | template <class _Tp> |
| 144 | #endif | 145 | #endif |
| 145 | struct _LIBCPP_TEMPLATE_VIS modulus : __binary_function<_Tp, _Tp, _Tp> { | 146 | struct modulus : __binary_function<_Tp, _Tp, _Tp> { |
| 146 | typedef _Tp __result_type; // used by valarray | 147 | typedef _Tp __result_type; // used by valarray |
| 147 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 148 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 148 | return __x % __y; | 149 | return __x % __y; |
| ... | @@ -152,7 +153,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus); | ... | @@ -152,7 +153,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus); |
| 152 | 153 | ||
| 153 | #if _LIBCPP_STD_VER >= 14 | 154 | #if _LIBCPP_STD_VER >= 14 |
| 154 | template <> | 155 | template <> |
| 155 | struct _LIBCPP_TEMPLATE_VIS modulus<void> { | 156 | struct modulus<void> { |
| 156 | template <class _T1, class _T2> | 157 | template <class _T1, class _T2> |
| 157 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 158 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 158 | noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) // | 159 | noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) // |
| ... | @@ -168,7 +169,7 @@ template <class _Tp = void> | ... | @@ -168,7 +169,7 @@ template <class _Tp = void> |
| 168 | #else | 169 | #else |
| 169 | template <class _Tp> | 170 | template <class _Tp> |
| 170 | #endif | 171 | #endif |
| 171 | struct _LIBCPP_TEMPLATE_VIS negate : __unary_function<_Tp, _Tp> { | 172 | struct negate : __unary_function<_Tp, _Tp> { |
| 172 | typedef _Tp __result_type; // used by valarray | 173 | typedef _Tp __result_type; // used by valarray |
| 173 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return -__x; } | 174 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return -__x; } |
| 174 | }; | 175 | }; |
| ... | @@ -176,7 +177,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate); | ... | @@ -176,7 +177,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate); |
| 176 | 177 | ||
| 177 | #if _LIBCPP_STD_VER >= 14 | 178 | #if _LIBCPP_STD_VER >= 14 |
| 178 | template <> | 179 | template <> |
| 179 | struct _LIBCPP_TEMPLATE_VIS negate<void> { | 180 | struct negate<void> { |
| 180 | template <class _Tp> | 181 | template <class _Tp> |
| 181 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const | 182 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const |
| 182 | noexcept(noexcept(-std::forward<_Tp>(__x))) // | 183 | noexcept(noexcept(-std::forward<_Tp>(__x))) // |
| ... | @@ -194,7 +195,7 @@ template <class _Tp = void> | ... | @@ -194,7 +195,7 @@ template <class _Tp = void> |
| 194 | #else | 195 | #else |
| 195 | template <class _Tp> | 196 | template <class _Tp> |
| 196 | #endif | 197 | #endif |
| 197 | struct _LIBCPP_TEMPLATE_VIS bit_and : __binary_function<_Tp, _Tp, _Tp> { | 198 | struct bit_and : __binary_function<_Tp, _Tp, _Tp> { |
| 198 | typedef _Tp __result_type; // used by valarray | 199 | typedef _Tp __result_type; // used by valarray |
| 199 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 200 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 200 | return __x & __y; | 201 | return __x & __y; |
| ... | @@ -204,7 +205,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and); | ... | @@ -204,7 +205,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and); |
| 204 | 205 | ||
| 205 | #if _LIBCPP_STD_VER >= 14 | 206 | #if _LIBCPP_STD_VER >= 14 |
| 206 | template <> | 207 | template <> |
| 207 | struct _LIBCPP_TEMPLATE_VIS bit_and<void> { | 208 | struct bit_and<void> { |
| 208 | template <class _T1, class _T2> | 209 | template <class _T1, class _T2> |
| 209 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 210 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 210 | noexcept(noexcept(std::forward<_T1>(__t) & | 211 | noexcept(noexcept(std::forward<_T1>(__t) & |
| ... | @@ -217,13 +218,13 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void> { | ... | @@ -217,13 +218,13 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void> { |
| 217 | 218 | ||
| 218 | #if _LIBCPP_STD_VER >= 14 | 219 | #if _LIBCPP_STD_VER >= 14 |
| 219 | template <class _Tp = void> | 220 | template <class _Tp = void> |
| 220 | struct _LIBCPP_TEMPLATE_VIS bit_not : __unary_function<_Tp, _Tp> { | 221 | struct bit_not : __unary_function<_Tp, _Tp> { |
| 221 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; } | 222 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; } |
| 222 | }; | 223 | }; |
| 223 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not); | 224 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not); |
| 224 | 225 | ||
| 225 | template <> | 226 | template <> |
| 226 | struct _LIBCPP_TEMPLATE_VIS bit_not<void> { | 227 | struct bit_not<void> { |
| 227 | template <class _Tp> | 228 | template <class _Tp> |
| 228 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const | 229 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const |
| 229 | noexcept(noexcept(~std::forward<_Tp>(__x))) // | 230 | noexcept(noexcept(~std::forward<_Tp>(__x))) // |
| ... | @@ -239,7 +240,7 @@ template <class _Tp = void> | ... | @@ -239,7 +240,7 @@ template <class _Tp = void> |
| 239 | #else | 240 | #else |
| 240 | template <class _Tp> | 241 | template <class _Tp> |
| 241 | #endif | 242 | #endif |
| 242 | struct _LIBCPP_TEMPLATE_VIS bit_or : __binary_function<_Tp, _Tp, _Tp> { | 243 | struct bit_or : __binary_function<_Tp, _Tp, _Tp> { |
| 243 | typedef _Tp __result_type; // used by valarray | 244 | typedef _Tp __result_type; // used by valarray |
| 244 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 245 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 245 | return __x | __y; | 246 | return __x | __y; |
| ... | @@ -249,7 +250,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or); | ... | @@ -249,7 +250,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or); |
| 249 | 250 | ||
| 250 | #if _LIBCPP_STD_VER >= 14 | 251 | #if _LIBCPP_STD_VER >= 14 |
| 251 | template <> | 252 | template <> |
| 252 | struct _LIBCPP_TEMPLATE_VIS bit_or<void> { | 253 | struct bit_or<void> { |
| 253 | template <class _T1, class _T2> | 254 | template <class _T1, class _T2> |
| 254 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 255 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 255 | noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) // | 256 | noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) // |
| ... | @@ -265,7 +266,7 @@ template <class _Tp = void> | ... | @@ -265,7 +266,7 @@ template <class _Tp = void> |
| 265 | #else | 266 | #else |
| 266 | template <class _Tp> | 267 | template <class _Tp> |
| 267 | #endif | 268 | #endif |
| 268 | struct _LIBCPP_TEMPLATE_VIS bit_xor : __binary_function<_Tp, _Tp, _Tp> { | 269 | struct bit_xor : __binary_function<_Tp, _Tp, _Tp> { |
| 269 | typedef _Tp __result_type; // used by valarray | 270 | typedef _Tp __result_type; // used by valarray |
| 270 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { | 271 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { |
| 271 | return __x ^ __y; | 272 | return __x ^ __y; |
| ... | @@ -275,7 +276,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor); | ... | @@ -275,7 +276,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor); |
| 275 | 276 | ||
| 276 | #if _LIBCPP_STD_VER >= 14 | 277 | #if _LIBCPP_STD_VER >= 14 |
| 277 | template <> | 278 | template <> |
| 278 | struct _LIBCPP_TEMPLATE_VIS bit_xor<void> { | 279 | struct bit_xor<void> { |
| 279 | template <class _T1, class _T2> | 280 | template <class _T1, class _T2> |
| 280 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 281 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 281 | noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) // | 282 | noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) // |
| ... | @@ -293,7 +294,7 @@ template <class _Tp = void> | ... | @@ -293,7 +294,7 @@ template <class _Tp = void> |
| 293 | #else | 294 | #else |
| 294 | template <class _Tp> | 295 | template <class _Tp> |
| 295 | #endif | 296 | #endif |
| 296 | struct _LIBCPP_TEMPLATE_VIS equal_to : __binary_function<_Tp, _Tp, bool> { | 297 | struct equal_to : __binary_function<_Tp, _Tp, bool> { |
| 297 | typedef bool __result_type; // used by valarray | 298 | typedef bool __result_type; // used by valarray |
| 298 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 299 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 299 | return __x == __y; | 300 | return __x == __y; |
| ... | @@ -303,7 +304,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to); | ... | @@ -303,7 +304,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to); |
| 303 | 304 | ||
| 304 | #if _LIBCPP_STD_VER >= 14 | 305 | #if _LIBCPP_STD_VER >= 14 |
| 305 | template <> | 306 | template <> |
| 306 | struct _LIBCPP_TEMPLATE_VIS equal_to<void> { | 307 | struct equal_to<void> { |
| 307 | template <class _T1, class _T2> | 308 | template <class _T1, class _T2> |
| 308 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 309 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 309 | noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) // | 310 | noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) // |
| ... | @@ -328,7 +329,7 @@ template <class _Tp = void> | ... | @@ -328,7 +329,7 @@ template <class _Tp = void> |
| 328 | #else | 329 | #else |
| 329 | template <class _Tp> | 330 | template <class _Tp> |
| 330 | #endif | 331 | #endif |
| 331 | struct _LIBCPP_TEMPLATE_VIS not_equal_to : __binary_function<_Tp, _Tp, bool> { | 332 | struct not_equal_to : __binary_function<_Tp, _Tp, bool> { |
| 332 | typedef bool __result_type; // used by valarray | 333 | typedef bool __result_type; // used by valarray |
| 333 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 334 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 334 | return __x != __y; | 335 | return __x != __y; |
| ... | @@ -338,7 +339,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to); | ... | @@ -338,7 +339,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to); |
| 338 | 339 | ||
| 339 | #if _LIBCPP_STD_VER >= 14 | 340 | #if _LIBCPP_STD_VER >= 14 |
| 340 | template <> | 341 | template <> |
| 341 | struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> { | 342 | struct not_equal_to<void> { |
| 342 | template <class _T1, class _T2> | 343 | template <class _T1, class _T2> |
| 343 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 344 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 344 | noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) // | 345 | noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) // |
| ... | @@ -349,12 +350,8 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> { | ... | @@ -349,12 +350,8 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> { |
| 349 | }; | 350 | }; |
| 350 | #endif | 351 | #endif |
| 351 | 352 | ||
| 352 | #if _LIBCPP_STD_VER >= 14 | ||
| 353 | template <class _Tp = void> | ||
| 354 | #else | ||
| 355 | template <class _Tp> | 353 | template <class _Tp> |
| 356 | #endif | 354 | struct less : __binary_function<_Tp, _Tp, bool> { |
| 357 | struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> { | ||
| 358 | typedef bool __result_type; // used by valarray | 355 | typedef bool __result_type; // used by valarray |
| 359 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 356 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 360 | return __x < __y; | 357 | return __x < __y; |
| ... | @@ -370,7 +367,7 @@ inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _T | ... | @@ -370,7 +367,7 @@ inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _T |
| 370 | 367 | ||
| 371 | #if _LIBCPP_STD_VER >= 14 | 368 | #if _LIBCPP_STD_VER >= 14 |
| 372 | template <> | 369 | template <> |
| 373 | struct _LIBCPP_TEMPLATE_VIS less<void> { | 370 | struct less<void> { |
| 374 | template <class _T1, class _T2> | 371 | template <class _T1, class _T2> |
| 375 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 372 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 376 | noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) // | 373 | noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) // |
| ... | @@ -392,7 +389,7 @@ template <class _Tp = void> | ... | @@ -392,7 +389,7 @@ template <class _Tp = void> |
| 392 | #else | 389 | #else |
| 393 | template <class _Tp> | 390 | template <class _Tp> |
| 394 | #endif | 391 | #endif |
| 395 | struct _LIBCPP_TEMPLATE_VIS less_equal : __binary_function<_Tp, _Tp, bool> { | 392 | struct less_equal : __binary_function<_Tp, _Tp, bool> { |
| 396 | typedef bool __result_type; // used by valarray | 393 | typedef bool __result_type; // used by valarray |
| 397 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 394 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 398 | return __x <= __y; | 395 | return __x <= __y; |
| ... | @@ -402,7 +399,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal); | ... | @@ -402,7 +399,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal); |
| 402 | 399 | ||
| 403 | #if _LIBCPP_STD_VER >= 14 | 400 | #if _LIBCPP_STD_VER >= 14 |
| 404 | template <> | 401 | template <> |
| 405 | struct _LIBCPP_TEMPLATE_VIS less_equal<void> { | 402 | struct less_equal<void> { |
| 406 | template <class _T1, class _T2> | 403 | template <class _T1, class _T2> |
| 407 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 404 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 408 | noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) // | 405 | noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) // |
| ... | @@ -418,7 +415,7 @@ template <class _Tp = void> | ... | @@ -418,7 +415,7 @@ template <class _Tp = void> |
| 418 | #else | 415 | #else |
| 419 | template <class _Tp> | 416 | template <class _Tp> |
| 420 | #endif | 417 | #endif |
| 421 | struct _LIBCPP_TEMPLATE_VIS greater_equal : __binary_function<_Tp, _Tp, bool> { | 418 | struct greater_equal : __binary_function<_Tp, _Tp, bool> { |
| 422 | typedef bool __result_type; // used by valarray | 419 | typedef bool __result_type; // used by valarray |
| 423 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 420 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 424 | return __x >= __y; | 421 | return __x >= __y; |
| ... | @@ -428,7 +425,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal); | ... | @@ -428,7 +425,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal); |
| 428 | 425 | ||
| 429 | #if _LIBCPP_STD_VER >= 14 | 426 | #if _LIBCPP_STD_VER >= 14 |
| 430 | template <> | 427 | template <> |
| 431 | struct _LIBCPP_TEMPLATE_VIS greater_equal<void> { | 428 | struct greater_equal<void> { |
| 432 | template <class _T1, class _T2> | 429 | template <class _T1, class _T2> |
| 433 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 430 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 434 | noexcept(noexcept(std::forward<_T1>(__t) >= | 431 | noexcept(noexcept(std::forward<_T1>(__t) >= |
| ... | @@ -444,7 +441,7 @@ template <class _Tp = void> | ... | @@ -444,7 +441,7 @@ template <class _Tp = void> |
| 444 | #else | 441 | #else |
| 445 | template <class _Tp> | 442 | template <class _Tp> |
| 446 | #endif | 443 | #endif |
| 447 | struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> { | 444 | struct greater : __binary_function<_Tp, _Tp, bool> { |
| 448 | typedef bool __result_type; // used by valarray | 445 | typedef bool __result_type; // used by valarray |
| 449 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 446 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 450 | return __x > __y; | 447 | return __x > __y; |
| ... | @@ -457,7 +454,7 @@ inline const bool __desugars_to_v<__greater_tag, greater<_Tp>, _Tp, _Tp> = true; | ... | @@ -457,7 +454,7 @@ inline const bool __desugars_to_v<__greater_tag, greater<_Tp>, _Tp, _Tp> = true; |
| 457 | 454 | ||
| 458 | #if _LIBCPP_STD_VER >= 14 | 455 | #if _LIBCPP_STD_VER >= 14 |
| 459 | template <> | 456 | template <> |
| 460 | struct _LIBCPP_TEMPLATE_VIS greater<void> { | 457 | struct greater<void> { |
| 461 | template <class _T1, class _T2> | 458 | template <class _T1, class _T2> |
| 462 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 459 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 463 | noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) // | 460 | noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) // |
| ... | @@ -478,7 +475,7 @@ template <class _Tp = void> | ... | @@ -478,7 +475,7 @@ template <class _Tp = void> |
| 478 | #else | 475 | #else |
| 479 | template <class _Tp> | 476 | template <class _Tp> |
| 480 | #endif | 477 | #endif |
| 481 | struct _LIBCPP_TEMPLATE_VIS logical_and : __binary_function<_Tp, _Tp, bool> { | 478 | struct logical_and : __binary_function<_Tp, _Tp, bool> { |
| 482 | typedef bool __result_type; // used by valarray | 479 | typedef bool __result_type; // used by valarray |
| 483 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 480 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 484 | return __x && __y; | 481 | return __x && __y; |
| ... | @@ -488,7 +485,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and); | ... | @@ -488,7 +485,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and); |
| 488 | 485 | ||
| 489 | #if _LIBCPP_STD_VER >= 14 | 486 | #if _LIBCPP_STD_VER >= 14 |
| 490 | template <> | 487 | template <> |
| 491 | struct _LIBCPP_TEMPLATE_VIS logical_and<void> { | 488 | struct logical_and<void> { |
| 492 | template <class _T1, class _T2> | 489 | template <class _T1, class _T2> |
| 493 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 490 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 494 | noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) // | 491 | noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) // |
| ... | @@ -504,7 +501,7 @@ template <class _Tp = void> | ... | @@ -504,7 +501,7 @@ template <class _Tp = void> |
| 504 | #else | 501 | #else |
| 505 | template <class _Tp> | 502 | template <class _Tp> |
| 506 | #endif | 503 | #endif |
| 507 | struct _LIBCPP_TEMPLATE_VIS logical_not : __unary_function<_Tp, bool> { | 504 | struct logical_not : __unary_function<_Tp, bool> { |
| 508 | typedef bool __result_type; // used by valarray | 505 | typedef bool __result_type; // used by valarray |
| 509 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x) const { return !__x; } | 506 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x) const { return !__x; } |
| 510 | }; | 507 | }; |
| ... | @@ -512,7 +509,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not); | ... | @@ -512,7 +509,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not); |
| 512 | 509 | ||
| 513 | #if _LIBCPP_STD_VER >= 14 | 510 | #if _LIBCPP_STD_VER >= 14 |
| 514 | template <> | 511 | template <> |
| 515 | struct _LIBCPP_TEMPLATE_VIS logical_not<void> { | 512 | struct logical_not<void> { |
| 516 | template <class _Tp> | 513 | template <class _Tp> |
| 517 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const | 514 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const |
| 518 | noexcept(noexcept(!std::forward<_Tp>(__x))) // | 515 | noexcept(noexcept(!std::forward<_Tp>(__x))) // |
| ... | @@ -528,7 +525,7 @@ template <class _Tp = void> | ... | @@ -528,7 +525,7 @@ template <class _Tp = void> |
| 528 | #else | 525 | #else |
| 529 | template <class _Tp> | 526 | template <class _Tp> |
| 530 | #endif | 527 | #endif |
| 531 | struct _LIBCPP_TEMPLATE_VIS logical_or : __binary_function<_Tp, _Tp, bool> { | 528 | struct logical_or : __binary_function<_Tp, _Tp, bool> { |
| 532 | typedef bool __result_type; // used by valarray | 529 | typedef bool __result_type; // used by valarray |
| 533 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { | 530 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const { |
| 534 | return __x || __y; | 531 | return __x || __y; |
| ... | @@ -538,7 +535,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or); | ... | @@ -538,7 +535,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or); |
| 538 | 535 | ||
| 539 | #if _LIBCPP_STD_VER >= 14 | 536 | #if _LIBCPP_STD_VER >= 14 |
| 540 | template <> | 537 | template <> |
| 541 | struct _LIBCPP_TEMPLATE_VIS logical_or<void> { | 538 | struct logical_or<void> { |
| 542 | template <class _T1, class _T2> | 539 | template <class _T1, class _T2> |
| 543 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const | 540 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const |
| 544 | noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) // | 541 | noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) // |
lib/libcxx/include/__functional/pointer_to_binary_function.h+1-2| ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) | 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) |
| 23 | 23 | ||
| 24 | template <class _Arg1, class _Arg2, class _Result> | 24 | template <class _Arg1, class _Arg2, class _Result> |
| 25 | class _LIBCPP_TEMPLATE_VIS | 25 | class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public __binary_function<_Arg1, _Arg2, _Result> { |
| 26 | _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public __binary_function<_Arg1, _Arg2, _Result> { | ||
| 27 | _Result (*__f_)(_Arg1, _Arg2); | 26 | _Result (*__f_)(_Arg1, _Arg2); |
| 28 | 27 | ||
| 29 | public: | 28 | public: |
lib/libcxx/include/__functional/pointer_to_unary_function.h+1-2| ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) | 22 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) |
| 23 | 23 | ||
| 24 | template <class _Arg, class _Result> | 24 | template <class _Arg, class _Result> |
| 25 | class _LIBCPP_TEMPLATE_VIS | 25 | class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> { |
| 26 | _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> { | ||
| 27 | _Result (*__f_)(_Arg); | 26 | _Result (*__f_)(_Arg); |
| 28 | 27 | ||
| 29 | public: | 28 | public: |
lib/libcxx/include/__functional/reference_wrapper.h+42-6| ... | @@ -11,13 +11,18 @@ | ... | @@ -11,13 +11,18 @@ |
| 11 | #define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H | 11 | #define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H |
| 12 | 12 | ||
| 13 | #include <__compare/synth_three_way.h> | 13 | #include <__compare/synth_three_way.h> |
| 14 | #include <__concepts/boolean_testable.h> | 14 | #include <__concepts/convertible_to.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__functional/weak_result_type.h> | 16 | #include <__functional/weak_result_type.h> |
| 17 | #include <__memory/addressof.h> | 17 | #include <__memory/addressof.h> |
| 18 | #include <__type_traits/common_reference.h> | ||
| 19 | #include <__type_traits/desugars_to.h> | ||
| 18 | #include <__type_traits/enable_if.h> | 20 | #include <__type_traits/enable_if.h> |
| 19 | #include <__type_traits/invoke.h> | 21 | #include <__type_traits/invoke.h> |
| 20 | #include <__type_traits/is_const.h> | 22 | #include <__type_traits/is_const.h> |
| 23 | #include <__type_traits/is_core_convertible.h> | ||
| 24 | #include <__type_traits/is_same.h> | ||
| 25 | #include <__type_traits/is_specialization.h> | ||
| 21 | #include <__type_traits/remove_cvref.h> | 26 | #include <__type_traits/remove_cvref.h> |
| 22 | #include <__type_traits/void_t.h> | 27 | #include <__type_traits/void_t.h> |
| 23 | #include <__utility/declval.h> | 28 | #include <__utility/declval.h> |
| ... | @@ -30,7 +35,7 @@ | ... | @@ -30,7 +35,7 @@ |
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 36 | ||
| 32 | template <class _Tp> | 37 | template <class _Tp> |
| 33 | class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> { | 38 | class reference_wrapper : public __weak_result_type<_Tp> { |
| 34 | public: | 39 | public: |
| 35 | // types | 40 | // types |
| 36 | typedef _Tp type; | 41 | typedef _Tp type; |
| ... | @@ -44,7 +49,7 @@ private: | ... | @@ -44,7 +49,7 @@ private: |
| 44 | public: | 49 | public: |
| 45 | template <class _Up, | 50 | template <class _Up, |
| 46 | class = __void_t<decltype(__fun(std::declval<_Up>()))>, | 51 | class = __void_t<decltype(__fun(std::declval<_Up>()))>, |
| 47 | __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, int> = 0> | 52 | __enable_if_t<!is_same<__remove_cvref_t<_Up>, reference_wrapper>::value, int> = 0> |
| 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u) | 53 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u) |
| 49 | _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) { | 54 | _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) { |
| 50 | type& __f = static_cast<_Up&&>(__u); | 55 | type& __f = static_cast<_Up&&>(__u); |
| ... | @@ -74,7 +79,7 @@ public: | ... | @@ -74,7 +79,7 @@ public: |
| 74 | 79 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y) | 80 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y) |
| 76 | requires requires { | 81 | requires requires { |
| 77 | { __x.get() == __y.get() } -> __boolean_testable; | 82 | { __x.get() == __y.get() } -> __core_convertible_to<bool>; |
| 78 | } | 83 | } |
| 79 | { | 84 | { |
| 80 | return __x.get() == __y.get(); | 85 | return __x.get() == __y.get(); |
| ... | @@ -82,7 +87,7 @@ public: | ... | @@ -82,7 +87,7 @@ public: |
| 82 | 87 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y) | 88 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y) |
| 84 | requires requires { | 89 | requires requires { |
| 85 | { __x.get() == __y } -> __boolean_testable; | 90 | { __x.get() == __y } -> __core_convertible_to<bool>; |
| 86 | } | 91 | } |
| 87 | { | 92 | { |
| 88 | return __x.get() == __y; | 93 | return __x.get() == __y; |
| ... | @@ -90,7 +95,7 @@ public: | ... | @@ -90,7 +95,7 @@ public: |
| 90 | 95 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y) | 96 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y) |
| 92 | requires(!is_const_v<_Tp>) && requires { | 97 | requires(!is_const_v<_Tp>) && requires { |
| 93 | { __x.get() == __y.get() } -> __boolean_testable; | 98 | { __x.get() == __y.get() } -> __core_convertible_to<bool>; |
| 94 | } | 99 | } |
| 95 | { | 100 | { |
| 96 | return __x.get() == __y.get(); | 101 | return __x.get() == __y.get(); |
| ... | @@ -149,6 +154,37 @@ void ref(const _Tp&&) = delete; | ... | @@ -149,6 +154,37 @@ void ref(const _Tp&&) = delete; |
| 149 | template <class _Tp> | 154 | template <class _Tp> |
| 150 | void cref(const _Tp&&) = delete; | 155 | void cref(const _Tp&&) = delete; |
| 151 | 156 | ||
| 157 | // Let desugars-to pass through std::reference_wrapper | ||
| 158 | template <class _CanonicalTag, class _Operation, class... _Args> | ||
| 159 | inline const bool __desugars_to_v<_CanonicalTag, reference_wrapper<_Operation>, _Args...> = | ||
| 160 | __desugars_to_v<_CanonicalTag, _Operation, _Args...>; | ||
| 161 | |||
| 162 | #if _LIBCPP_STD_VER >= 20 | ||
| 163 | |||
| 164 | template <class _Tp> | ||
| 165 | inline constexpr bool __is_ref_wrapper = __is_specialization_v<_Tp, reference_wrapper>; | ||
| 166 | |||
| 167 | template <class _Rp, class _Tp, class _RpQual, class _TpQual> | ||
| 168 | concept __ref_wrap_common_reference_exists_with = __is_ref_wrapper<_Rp> && requires { | ||
| 169 | typename common_reference_t<typename _Rp::type&, _TpQual>; | ||
| 170 | } && convertible_to<_RpQual, common_reference_t<typename _Rp::type&, _TpQual>>; | ||
| 171 | |||
| 172 | template <class _Rp, class _Tp, template <class> class _RpQual, template <class> class _TpQual> | ||
| 173 | requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> && | ||
| 174 | !__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>) | ||
| 175 | struct basic_common_reference<_Rp, _Tp, _RpQual, _TpQual> { | ||
| 176 | using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>; | ||
| 177 | }; | ||
| 178 | |||
| 179 | template <class _Tp, class _Rp, template <class> class _TpQual, template <class> class _RpQual> | ||
| 180 | requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> && | ||
| 181 | !__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>) | ||
| 182 | struct basic_common_reference<_Tp, _Rp, _TpQual, _RpQual> { | ||
| 183 | using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>; | ||
| 184 | }; | ||
| 185 | |||
| 186 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 187 | |||
| 152 | _LIBCPP_END_NAMESPACE_STD | 188 | _LIBCPP_END_NAMESPACE_STD |
| 153 | 189 | ||
| 154 | #endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H | 190 | #endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H |
lib/libcxx/include/__functional/unary_function.h+3-4| ... | @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | 20 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) |
| 21 | 21 | ||
| 22 | template <class _Arg, class _Result> | 22 | template <class _Arg, class _Result> |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function { | 23 | struct _LIBCPP_DEPRECATED_IN_CXX11 unary_function { |
| 24 | typedef _Arg argument_type; | 24 | typedef _Arg argument_type; |
| 25 | typedef _Result result_type; | 25 | typedef _Result result_type; |
| 26 | }; | 26 | }; |
| ... | @@ -36,11 +36,10 @@ struct __unary_function_keep_layout_base { | ... | @@ -36,11 +36,10 @@ struct __unary_function_keep_layout_base { |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | 38 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) |
| 39 | _LIBCPP_DIAGNOSTIC_PUSH | 39 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 40 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") | ||
| 41 | template <class _Arg, class _Result> | 40 | template <class _Arg, class _Result> |
| 42 | using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>; | 41 | using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>; |
| 43 | _LIBCPP_DIAGNOSTIC_POP | 42 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 44 | #else | 43 | #else |
| 45 | template <class _Arg, class _Result> | 44 | template <class _Arg, class _Result> |
| 46 | using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>; | 45 | using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>; |
lib/libcxx/include/__functional/unary_negate.h+1-2| ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) | 22 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) |
| 23 | 23 | ||
| 24 | template <class _Predicate> | 24 | template <class _Predicate> |
| 25 | class _LIBCPP_TEMPLATE_VIS | 25 | class _LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> { |
| 26 | _LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> { | ||
| 27 | _Predicate __pred_; | 26 | _Predicate __pred_; |
| 28 | 27 | ||
| 29 | public: | 28 | public: |
lib/libcxx/include/__functional/weak_result_type.h+2| ... | @@ -77,6 +77,7 @@ struct __maybe_derive_from_unary_function // bool is true | ... | @@ -77,6 +77,7 @@ struct __maybe_derive_from_unary_function // bool is true |
| 77 | template <class _Tp> | 77 | template <class _Tp> |
| 78 | struct __maybe_derive_from_unary_function<_Tp, false> {}; | 78 | struct __maybe_derive_from_unary_function<_Tp, false> {}; |
| 79 | 79 | ||
| 80 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 80 | template <class _Tp, bool = __derives_from_binary_function<_Tp>::value> | 81 | template <class _Tp, bool = __derives_from_binary_function<_Tp>::value> |
| 81 | struct __maybe_derive_from_binary_function // bool is true | 82 | struct __maybe_derive_from_binary_function // bool is true |
| 82 | : public __derives_from_binary_function<_Tp>::type {}; | 83 | : public __derives_from_binary_function<_Tp>::type {}; |
| ... | @@ -99,6 +100,7 @@ struct __weak_result_type_imp<_Tp, false> | ... | @@ -99,6 +100,7 @@ struct __weak_result_type_imp<_Tp, false> |
| 99 | 100 | ||
| 100 | template <class _Tp> | 101 | template <class _Tp> |
| 101 | struct __weak_result_type : public __weak_result_type_imp<_Tp> {}; | 102 | struct __weak_result_type : public __weak_result_type_imp<_Tp> {}; |
| 103 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 102 | 104 | ||
| 103 | // 0 argument case | 105 | // 0 argument case |
| 104 | 106 |
lib/libcxx/include/__fwd/array.h+1-1| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _Tp, size_t _Size> | 22 | template <class _Tp, size_t _Size> |
| 23 | struct _LIBCPP_TEMPLATE_VIS array; | 23 | struct array; |
| 24 | 24 | ||
| 25 | template <size_t _Ip, class _Tp, size_t _Size> | 25 | template <size_t _Ip, class _Tp, size_t _Size> |
| 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT; | 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT; |
lib/libcxx/include/__fwd/bit_reference.h+16| ... | @@ -20,9 +20,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,9 +20,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> | 20 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> |
| 21 | class __bit_iterator; | 21 | class __bit_iterator; |
| 22 | 22 | ||
| 23 | template <class _Cp> | ||
| 24 | struct __bit_array; | ||
| 25 | |||
| 23 | template <class, class = void> | 26 | template <class, class = void> |
| 24 | struct __size_difference_type_traits; | 27 | struct __size_difference_type_traits; |
| 25 | 28 | ||
| 29 | template <class _StoragePointer> | ||
| 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | ||
| 31 | __fill_masked_range(_StoragePointer __word, unsigned __clz, unsigned __ctz, bool __fill_val); | ||
| 32 | |||
| 33 | template <class _StorageType> | ||
| 34 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __trailing_mask(unsigned __clz); | ||
| 35 | |||
| 36 | template <class _StorageType> | ||
| 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __leading_mask(unsigned __ctz); | ||
| 38 | |||
| 39 | template <class _StorageType> | ||
| 40 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __middle_mask(unsigned __clz, unsigned __ctz); | ||
| 41 | |||
| 26 | _LIBCPP_END_NAMESPACE_STD | 42 | _LIBCPP_END_NAMESPACE_STD |
| 27 | 43 | ||
| 28 | #endif // _LIBCPP___FWD_BIT_REFERENCE_H | 44 | #endif // _LIBCPP___FWD_BIT_REFERENCE_H |
lib/libcxx/include/__fwd/byte.h+2-2| ... | @@ -16,11 +16,11 @@ | ... | @@ -16,11 +16,11 @@ |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | #if _LIBCPP_STD_VER >= 17 | 18 | #if _LIBCPP_STD_VER >= 17 |
| 19 | namespace std { // purposefully not versioned | 19 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | enum class byte : unsigned char; | 21 | enum class byte : unsigned char; |
| 22 | 22 | ||
| 23 | } // namespace std | 23 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 24 | #endif // _LIBCPP_STD_VER >= 17 | 24 | #endif // _LIBCPP_STD_VER >= 17 |
| 25 | 25 | ||
| 26 | #endif // _LIBCPP___FWD_BYTE_H | 26 | #endif // _LIBCPP___FWD_BYTE_H |
lib/libcxx/include/__fwd/complex.h+1-1| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | class _LIBCPP_TEMPLATE_VIS complex; | 22 | class complex; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 26 | 24 | #if _LIBCPP_STD_VER >= 26 |
| 25 | 25 |
lib/libcxx/include/__fwd/deque.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, class _Allocator = allocator<_Tp> > | 21 | template <class _Tp, class _Allocator = allocator<_Tp> > |
| 22 | class _LIBCPP_TEMPLATE_VIS deque; | 22 | class deque; |
| 23 | 23 | ||
| 24 | _LIBCPP_END_NAMESPACE_STD | 24 | _LIBCPP_END_NAMESPACE_STD |
| 25 | 25 |
lib/libcxx/include/__fwd/format.h+3-3| ... | @@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER >= 20 | 22 | #if _LIBCPP_STD_VER >= 20 |
| 23 | 23 | ||
| 24 | template <class _Context> | 24 | template <class _Context> |
| 25 | class _LIBCPP_TEMPLATE_VIS basic_format_arg; | 25 | class basic_format_arg; |
| 26 | 26 | ||
| 27 | template <class _OutIt, class _CharT> | 27 | template <class _OutIt, class _CharT> |
| 28 | requires output_iterator<_OutIt, const _CharT&> | 28 | requires output_iterator<_OutIt, const _CharT&> |
| 29 | class _LIBCPP_TEMPLATE_VIS basic_format_context; | 29 | class basic_format_context; |
| 30 | 30 | ||
| 31 | template <class _Tp, class _CharT = char> | 31 | template <class _Tp, class _CharT = char> |
| 32 | struct _LIBCPP_TEMPLATE_VIS formatter; | 32 | struct formatter; |
| 33 | 33 | ||
| 34 | #endif // _LIBCPP_STD_VER >= 20 | 34 | #endif // _LIBCPP_STD_VER >= 20 |
| 35 | 35 |
lib/libcxx/include/__fwd/fstream.h+4-4| ... | @@ -19,13 +19,13 @@ | ... | @@ -19,13 +19,13 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _CharT, class _Traits = char_traits<_CharT> > | 21 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 22 | class _LIBCPP_TEMPLATE_VIS basic_filebuf; | 22 | class basic_filebuf; |
| 23 | template <class _CharT, class _Traits = char_traits<_CharT> > | 23 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 24 | class _LIBCPP_TEMPLATE_VIS basic_ifstream; | 24 | class basic_ifstream; |
| 25 | template <class _CharT, class _Traits = char_traits<_CharT> > | 25 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 26 | class _LIBCPP_TEMPLATE_VIS basic_ofstream; | 26 | class basic_ofstream; |
| 27 | template <class _CharT, class _Traits = char_traits<_CharT> > | 27 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 28 | class _LIBCPP_TEMPLATE_VIS basic_fstream; | 28 | class basic_fstream; |
| 29 | 29 | ||
| 30 | using filebuf = basic_filebuf<char>; | 30 | using filebuf = basic_filebuf<char>; |
| 31 | using ifstream = basic_ifstream<char>; | 31 | using ifstream = basic_ifstream<char>; |
lib/libcxx/include/__fwd/functional.h+9-2| ... | @@ -17,11 +17,18 @@ | ... | @@ -17,11 +17,18 @@ |
| 17 | 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | #if _LIBCPP_STD_VER >= 14 | ||
| 21 | template <class _Tp = void> | ||
| 22 | #else | ||
| 23 | template <class _Tp> | ||
| 24 | #endif | ||
| 25 | struct less; | ||
| 26 | |||
| 20 | template <class> | 27 | template <class> |
| 21 | struct _LIBCPP_TEMPLATE_VIS hash; | 28 | struct hash; |
| 22 | 29 | ||
| 23 | template <class> | 30 | template <class> |
| 24 | class _LIBCPP_TEMPLATE_VIS reference_wrapper; | 31 | class reference_wrapper; |
| 25 | 32 | ||
| 26 | _LIBCPP_END_NAMESPACE_STD | 33 | _LIBCPP_END_NAMESPACE_STD |
| 27 | 34 |
lib/libcxx/include/__fwd/ios.h+1-1| ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | class _LIBCPP_EXPORTED_FROM_ABI ios_base; | 21 | class _LIBCPP_EXPORTED_FROM_ABI ios_base; |
| 22 | 22 | ||
| 23 | template <class _CharT, class _Traits = char_traits<_CharT> > | 23 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 24 | class _LIBCPP_TEMPLATE_VIS basic_ios; | 24 | class basic_ios; |
| 25 | 25 | ||
| 26 | using ios = basic_ios<char>; | 26 | using ios = basic_ios<char>; |
| 27 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 27 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
lib/libcxx/include/__fwd/istream.h+2-2| ... | @@ -19,10 +19,10 @@ | ... | @@ -19,10 +19,10 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _CharT, class _Traits = char_traits<_CharT> > | 21 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 22 | class _LIBCPP_TEMPLATE_VIS basic_istream; | 22 | class basic_istream; |
| 23 | 23 | ||
| 24 | template <class _CharT, class _Traits = char_traits<_CharT> > | 24 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 25 | class _LIBCPP_TEMPLATE_VIS basic_iostream; | 25 | class basic_iostream; |
| 26 | 26 | ||
| 27 | using istream = basic_istream<char>; | 27 | using istream = basic_istream<char>; |
| 28 | using iostream = basic_iostream<char>; | 28 | using iostream = basic_iostream<char>; |
lib/libcxx/include/__fwd/map.h created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_MAP_H | ||
| 10 | #define _LIBCPP___FWD_MAP_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/functional.h> | ||
| 14 | #include <__fwd/memory.h> | ||
| 15 | #include <__fwd/pair.h> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > | ||
| 24 | class map; | ||
| 25 | |||
| 26 | template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > | ||
| 27 | class multimap; | ||
| 28 | |||
| 29 | _LIBCPP_END_NAMESPACE_STD | ||
| 30 | |||
| 31 | #endif // _LIBCPP___FWD_MAP_H | ||
lib/libcxx/include/__fwd/memory.h+2-2| ... | @@ -18,10 +18,10 @@ | ... | @@ -18,10 +18,10 @@ |
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | template <class _Tp> | 20 | template <class _Tp> |
| 21 | class _LIBCPP_TEMPLATE_VIS allocator; | 21 | class allocator; |
| 22 | 22 | ||
| 23 | template <class _Tp> | 23 | template <class _Tp> |
| 24 | class _LIBCPP_TEMPLATE_VIS shared_ptr; | 24 | class shared_ptr; |
| 25 | 25 | ||
| 26 | _LIBCPP_END_NAMESPACE_STD | 26 | _LIBCPP_END_NAMESPACE_STD |
| 27 | 27 |
lib/libcxx/include/__fwd/memory_resource.h+1-1| ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | namespace pmr { | 22 | namespace pmr { |
| 23 | template <class _ValueType> | 23 | template <class _ValueType> |
| 24 | class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator; | 24 | class _LIBCPP_AVAILABILITY_PMR polymorphic_allocator; |
| 25 | } // namespace pmr | 25 | } // namespace pmr |
| 26 | 26 | ||
| 27 | _LIBCPP_END_NAMESPACE_STD | 27 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__fwd/ostream.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 _CharT, class _Traits = char_traits<_CharT> > | 21 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 22 | class _LIBCPP_TEMPLATE_VIS basic_ostream; | 22 | class basic_ostream; |
| 23 | 23 | ||
| 24 | using ostream = basic_ostream<char>; | 24 | using ostream = basic_ostream<char>; |
| 25 | 25 |
lib/libcxx/include/__fwd/pair.h+7-1| ... | @@ -20,7 +20,13 @@ | ... | @@ -20,7 +20,13 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class, class> | 22 | template <class, class> |
| 23 | struct _LIBCPP_TEMPLATE_VIS pair; | 23 | struct pair; |
| 24 | |||
| 25 | template <class _Type> | ||
| 26 | inline const bool __is_pair_v = false; | ||
| 27 | |||
| 28 | template <class _Type1, class _Type2> | ||
| 29 | inline const bool __is_pair_v<pair<_Type1, _Type2> > = true; | ||
| 24 | 30 | ||
| 25 | template <size_t _Ip, class _T1, class _T2> | 31 | template <size_t _Ip, class _T1, class _T2> |
| 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type& | 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type& |
lib/libcxx/include/__fwd/queue.h+2-2| ... | @@ -21,10 +21,10 @@ | ... | @@ -21,10 +21,10 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | template <class _Tp, class _Container = deque<_Tp> > | 23 | template <class _Tp, class _Container = deque<_Tp> > |
| 24 | class _LIBCPP_TEMPLATE_VIS queue; | 24 | class queue; |
| 25 | 25 | ||
| 26 | template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > | 26 | template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > |
| 27 | class _LIBCPP_TEMPLATE_VIS priority_queue; | 27 | class priority_queue; |
| 28 | 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 30 |
lib/libcxx/include/__fwd/set.h created+30| ... | @@ -0,0 +1,30 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___FWD_SET_H | ||
| 10 | #define _LIBCPP___FWD_SET_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/functional.h> | ||
| 14 | #include <__fwd/memory.h> | ||
| 15 | |||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 17 | # pragma GCC system_header | ||
| 18 | #endif | ||
| 19 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 21 | |||
| 22 | template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > | ||
| 23 | class set; | ||
| 24 | |||
| 25 | template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > | ||
| 26 | class multiset; | ||
| 27 | |||
| 28 | _LIBCPP_END_NAMESPACE_STD | ||
| 29 | |||
| 30 | #endif // _LIBCPP___FWD_SET_H | ||
lib/libcxx/include/__fwd/sstream.h+4-4| ... | @@ -20,14 +20,14 @@ | ... | @@ -20,14 +20,14 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > | 22 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > |
| 23 | class _LIBCPP_TEMPLATE_VIS basic_stringbuf; | 23 | class basic_stringbuf; |
| 24 | 24 | ||
| 25 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > | 25 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > |
| 26 | class _LIBCPP_TEMPLATE_VIS basic_istringstream; | 26 | class basic_istringstream; |
| 27 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > | 27 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > |
| 28 | class _LIBCPP_TEMPLATE_VIS basic_ostringstream; | 28 | class basic_ostringstream; |
| 29 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > | 29 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > |
| 30 | class _LIBCPP_TEMPLATE_VIS basic_stringstream; | 30 | class basic_stringstream; |
| 31 | 31 | ||
| 32 | using stringbuf = basic_stringbuf<char>; | 32 | using stringbuf = basic_stringbuf<char>; |
| 33 | using istringstream = basic_istringstream<char>; | 33 | using istringstream = basic_istringstream<char>; |
lib/libcxx/include/__fwd/stack.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, class _Container = deque<_Tp> > | 21 | template <class _Tp, class _Container = deque<_Tp> > |
| 22 | class _LIBCPP_TEMPLATE_VIS stack; | 22 | class stack; |
| 23 | 23 | ||
| 24 | _LIBCPP_END_NAMESPACE_STD | 24 | _LIBCPP_END_NAMESPACE_STD |
| 25 | 25 |
lib/libcxx/include/__fwd/streambuf.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 _CharT, class _Traits = char_traits<_CharT> > | 21 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 22 | class _LIBCPP_TEMPLATE_VIS basic_streambuf; | 22 | class basic_streambuf; |
| 23 | 23 | ||
| 24 | using streambuf = basic_streambuf<char>; | 24 | using streambuf = basic_streambuf<char>; |
| 25 | 25 |
lib/libcxx/include/__fwd/string.h+2-2| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _CharT> | 22 | template <class _CharT> |
| 23 | struct _LIBCPP_TEMPLATE_VIS char_traits; | 23 | struct char_traits; |
| 24 | template <> | 24 | template <> |
| 25 | struct char_traits<char>; | 25 | struct char_traits<char>; |
| 26 | 26 | ||
| ... | @@ -40,7 +40,7 @@ struct char_traits<wchar_t>; | ... | @@ -40,7 +40,7 @@ struct char_traits<wchar_t>; |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > | 42 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > |
| 43 | class _LIBCPP_TEMPLATE_VIS basic_string; | 43 | class basic_string; |
| 44 | 44 | ||
| 45 | using string = basic_string<char>; | 45 | using string = basic_string<char>; |
| 46 | 46 |
lib/libcxx/include/__fwd/string_view.h+1-1| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _CharT, class _Traits = char_traits<_CharT> > | 22 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 23 | class _LIBCPP_TEMPLATE_VIS basic_string_view; | 23 | class basic_string_view; |
| 24 | 24 | ||
| 25 | typedef basic_string_view<char> string_view; | 25 | typedef basic_string_view<char> string_view; |
| 26 | #if _LIBCPP_HAS_CHAR8_T | 26 | #if _LIBCPP_HAS_CHAR8_T |
lib/libcxx/include/__fwd/subrange.h+1-1| ... | @@ -28,7 +28,7 @@ enum class subrange_kind : bool { unsized, sized }; | ... | @@ -28,7 +28,7 @@ enum class subrange_kind : bool { unsized, sized }; |
| 28 | 28 | ||
| 29 | template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind> | 29 | template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind> |
| 30 | requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) | 30 | requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) |
| 31 | class _LIBCPP_TEMPLATE_VIS subrange; | 31 | class subrange; |
| 32 | 32 | ||
| 33 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> | 33 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> |
| 34 | requires((_Index == 0 && copyable<_Iter>) || _Index == 1) | 34 | requires((_Index == 0 && copyable<_Iter>) || _Index == 1) |
lib/libcxx/include/__fwd/tuple.h+3-3| ... | @@ -19,15 +19,15 @@ | ... | @@ -19,15 +19,15 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <size_t, class> | 21 | template <size_t, class> |
| 22 | struct _LIBCPP_TEMPLATE_VIS tuple_element; | 22 | struct tuple_element; |
| 23 | 23 | ||
| 24 | #ifndef _LIBCPP_CXX03_LANG | 24 | #ifndef _LIBCPP_CXX03_LANG |
| 25 | 25 | ||
| 26 | template <class...> | 26 | template <class...> |
| 27 | class _LIBCPP_TEMPLATE_VIS tuple; | 27 | class tuple; |
| 28 | 28 | ||
| 29 | template <class> | 29 | template <class> |
| 30 | struct _LIBCPP_TEMPLATE_VIS tuple_size; | 30 | struct tuple_size; |
| 31 | 31 | ||
| 32 | template <size_t _Ip, class... _Tp> | 32 | template <size_t _Ip, class... _Tp> |
| 33 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type& | 33 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type& |
lib/libcxx/include/__fwd/variant.h+11-20| ... | @@ -21,16 +21,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,16 +21,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | #if _LIBCPP_STD_VER >= 17 | 21 | #if _LIBCPP_STD_VER >= 17 |
| 22 | 22 | ||
| 23 | template <class... _Types> | 23 | template <class... _Types> |
| 24 | class _LIBCPP_TEMPLATE_VIS variant; | 24 | class variant; |
| 25 | 25 | ||
| 26 | template <class _Tp> | 26 | template <class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS variant_size; | 27 | struct variant_size; |
| 28 | 28 | ||
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| 30 | inline constexpr size_t variant_size_v = variant_size<_Tp>::value; | 30 | inline constexpr size_t variant_size_v = variant_size<_Tp>::value; |
| 31 | 31 | ||
| 32 | template <size_t _Ip, class _Tp> | 32 | template <size_t _Ip, class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS variant_alternative; | 33 | struct variant_alternative; |
| 34 | 34 | ||
| 35 | template <size_t _Ip, class _Tp> | 35 | template <size_t _Ip, class _Tp> |
| 36 | using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; | 36 | using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; |
| ... | @@ -38,37 +38,28 @@ using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; | ... | @@ -38,37 +38,28 @@ using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; |
| 38 | inline constexpr size_t variant_npos = static_cast<size_t>(-1); | 38 | inline constexpr size_t variant_npos = static_cast<size_t>(-1); |
| 39 | 39 | ||
| 40 | template <size_t _Ip, class... _Types> | 40 | template <size_t _Ip, class... _Types> |
| 41 | _LIBCPP_HIDE_FROM_ABI | 41 | _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(variant<_Types...>&); |
| 42 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>& | ||
| 43 | get(variant<_Types...>&); | ||
| 44 | 42 | ||
| 45 | template <size_t _Ip, class... _Types> | 43 | template <size_t _Ip, class... _Types> |
| 46 | _LIBCPP_HIDE_FROM_ABI | 44 | _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(variant<_Types...>&&); |
| 47 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&& | ||
| 48 | get(variant<_Types...>&&); | ||
| 49 | 45 | ||
| 50 | template <size_t _Ip, class... _Types> | 46 | template <size_t _Ip, class... _Types> |
| 51 | _LIBCPP_HIDE_FROM_ABI | 47 | _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(const variant<_Types...>&); |
| 52 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>& | ||
| 53 | get(const variant<_Types...>&); | ||
| 54 | 48 | ||
| 55 | template <size_t _Ip, class... _Types> | 49 | template <size_t _Ip, class... _Types> |
| 56 | _LIBCPP_HIDE_FROM_ABI | 50 | _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(const variant<_Types...>&&); |
| 57 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& | ||
| 58 | get(const variant<_Types...>&&); | ||
| 59 | 51 | ||
| 60 | template <class _Tp, class... _Types> | 52 | template <class _Tp, class... _Types> |
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>&); | 53 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>&); |
| 62 | 54 | ||
| 63 | template <class _Tp, class... _Types> | 55 | template <class _Tp, class... _Types> |
| 64 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&&); | 56 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&&); |
| 65 | 57 | ||
| 66 | template <class _Tp, class... _Types> | 58 | template <class _Tp, class... _Types> |
| 67 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp& get(const variant<_Types...>&); | 59 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>&); |
| 68 | 60 | ||
| 69 | template <class _Tp, class... _Types> | 61 | template <class _Tp, class... _Types> |
| 70 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&& | 62 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&&); |
| 71 | get(const variant<_Types...>&&); | ||
| 72 | 63 | ||
| 73 | #endif // _LIBCPP_STD_VER >= 17 | 64 | #endif // _LIBCPP_STD_VER >= 17 |
| 74 | 65 |
lib/libcxx/include/__fwd/vector.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, class _Alloc = allocator<_Tp> > | 21 | template <class _Tp, class _Alloc = allocator<_Tp> > |
| 22 | class _LIBCPP_TEMPLATE_VIS vector; | 22 | class vector; |
| 23 | 23 | ||
| 24 | template <class _Allocator> | 24 | template <class _Allocator> |
| 25 | class vector<bool, _Allocator>; | 25 | class vector<bool, _Allocator>; |
lib/libcxx/include/__hash_table+111-72| ... | @@ -29,6 +29,7 @@ | ... | @@ -29,6 +29,7 @@ |
| 29 | #include <__memory/unique_ptr.h> | 29 | #include <__memory/unique_ptr.h> |
| 30 | #include <__new/launder.h> | 30 | #include <__new/launder.h> |
| 31 | #include <__type_traits/can_extract_key.h> | 31 | #include <__type_traits/can_extract_key.h> |
| 32 | #include <__type_traits/copy_cvref.h> | ||
| 32 | #include <__type_traits/enable_if.h> | 33 | #include <__type_traits/enable_if.h> |
| 33 | #include <__type_traits/invoke.h> | 34 | #include <__type_traits/invoke.h> |
| 34 | #include <__type_traits/is_const.h> | 35 | #include <__type_traits/is_const.h> |
| ... | @@ -108,9 +109,22 @@ struct __hash_node_base { | ... | @@ -108,9 +109,22 @@ struct __hash_node_base { |
| 108 | _LIBCPP_HIDE_FROM_ABI explicit __hash_node_base(__next_pointer __next) _NOEXCEPT : __next_(__next) {} | 109 | _LIBCPP_HIDE_FROM_ABI explicit __hash_node_base(__next_pointer __next) _NOEXCEPT : __next_(__next) {} |
| 109 | }; | 110 | }; |
| 110 | 111 | ||
| 112 | template <class _Tp> | ||
| 113 | struct __get_hash_node_value_type { | ||
| 114 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 115 | }; | ||
| 116 | |||
| 117 | template <class _Key, class _Tp> | ||
| 118 | struct __get_hash_node_value_type<__hash_value_type<_Key, _Tp> > { | ||
| 119 | using type _LIBCPP_NODEBUG = pair<const _Key, _Tp>; | ||
| 120 | }; | ||
| 121 | |||
| 122 | template <class _Tp> | ||
| 123 | using __get_hash_node_value_type_t _LIBCPP_NODEBUG = typename __get_hash_node_value_type<_Tp>::type; | ||
| 124 | |||
| 111 | template <class _Tp, class _VoidPtr> | 125 | template <class _Tp, class _VoidPtr> |
| 112 | struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > { | 126 | struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > { |
| 113 | typedef _Tp __node_value_type; | 127 | using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>; |
| 114 | using _Base _LIBCPP_NODEBUG = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >; | 128 | using _Base _LIBCPP_NODEBUG = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >; |
| 115 | using __next_pointer _LIBCPP_NODEBUG = typename _Base::__next_pointer; | 129 | using __next_pointer _LIBCPP_NODEBUG = typename _Base::__next_pointer; |
| 116 | 130 | ||
| ... | @@ -122,18 +136,20 @@ struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __has | ... | @@ -122,18 +136,20 @@ struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __has |
| 122 | 136 | ||
| 123 | private: | 137 | private: |
| 124 | union { | 138 | union { |
| 125 | _Tp __value_; | 139 | __node_value_type __value_; |
| 126 | }; | 140 | }; |
| 127 | 141 | ||
| 128 | public: | 142 | public: |
| 129 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } | 143 | _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; } |
| 130 | #else | 144 | #else |
| 131 | 145 | ||
| 132 | private: | 146 | private: |
| 133 | _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; | 147 | _ALIGNAS_TYPE(__node_value_type) char __buffer_[sizeof(__node_value_type)]; |
| 134 | 148 | ||
| 135 | public: | 149 | public: |
| 136 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); } | 150 | _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { |
| 151 | return *std::__launder(reinterpret_cast<__node_value_type*>(&__buffer_)); | ||
| 152 | } | ||
| 137 | #endif | 153 | #endif |
| 138 | 154 | ||
| 139 | _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {} | 155 | _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {} |
| ... | @@ -147,24 +163,24 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __constrain_hash(size_t __h, size_t __bc) { | ... | @@ -147,24 +163,24 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __constrain_hash(size_t __h, size_t __bc) { |
| 147 | } | 163 | } |
| 148 | 164 | ||
| 149 | inline _LIBCPP_HIDE_FROM_ABI size_t __next_hash_pow2(size_t __n) { | 165 | inline _LIBCPP_HIDE_FROM_ABI size_t __next_hash_pow2(size_t __n) { |
| 150 | return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - __libcpp_clz(__n - 1))); | 166 | return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - std::__countl_zero(__n - 1))); |
| 151 | } | 167 | } |
| 152 | 168 | ||
| 153 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 169 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 154 | class __hash_table; | 170 | class __hash_table; |
| 155 | 171 | ||
| 156 | template <class _NodePtr> | 172 | template <class _NodePtr> |
| 157 | class _LIBCPP_TEMPLATE_VIS __hash_iterator; | 173 | class __hash_iterator; |
| 158 | template <class _ConstNodePtr> | 174 | template <class _ConstNodePtr> |
| 159 | class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; | 175 | class __hash_const_iterator; |
| 160 | template <class _NodePtr> | 176 | template <class _NodePtr> |
| 161 | class _LIBCPP_TEMPLATE_VIS __hash_local_iterator; | 177 | class __hash_local_iterator; |
| 162 | template <class _ConstNodePtr> | 178 | template <class _ConstNodePtr> |
| 163 | class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; | 179 | class __hash_const_local_iterator; |
| 164 | template <class _HashIterator> | 180 | template <class _HashIterator> |
| 165 | class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; | 181 | class __hash_map_iterator; |
| 166 | template <class _HashIterator> | 182 | template <class _HashIterator> |
| 167 | class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; | 183 | class __hash_map_const_iterator; |
| 168 | 184 | ||
| 169 | template <class _Tp> | 185 | template <class _Tp> |
| 170 | struct __hash_key_value_types { | 186 | struct __hash_key_value_types { |
| ... | @@ -191,18 +207,18 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { | ... | @@ -191,18 +207,18 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { |
| 191 | 207 | ||
| 192 | _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__container_value_type const& __v) { return __v.first; } | 208 | _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__container_value_type const& __v) { return __v.first; } |
| 193 | 209 | ||
| 194 | template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, int> = 0> | 210 | template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __node_value_type>::value, int> = 0> |
| 195 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { | 211 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { |
| 196 | return __t.__get_value(); | 212 | return __t.__get_value(); |
| 197 | } | 213 | } |
| 198 | 214 | ||
| 199 | template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0> | 215 | template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __container_value_type>::value, int> = 0> |
| 200 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { | 216 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { |
| 201 | return __t; | 217 | return __t; |
| 202 | } | 218 | } |
| 203 | 219 | ||
| 204 | _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { | 220 | _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__container_value_type& __n) { |
| 205 | return std::addressof(__n.__get_value()); | 221 | return std::addressof(__n); |
| 206 | } | 222 | } |
| 207 | _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); } | 223 | _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); } |
| 208 | }; | 224 | }; |
| ... | @@ -242,7 +258,7 @@ public: | ... | @@ -242,7 +258,7 @@ public: |
| 242 | 258 | ||
| 243 | typedef typename __node_base_type::__next_pointer __next_pointer; | 259 | typedef typename __node_base_type::__next_pointer __next_pointer; |
| 244 | 260 | ||
| 245 | typedef _Tp __node_value_type; | 261 | using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>; |
| 246 | typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer; | 262 | typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer; |
| 247 | typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer; | 263 | typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer; |
| 248 | 264 | ||
| ... | @@ -273,7 +289,7 @@ struct __make_hash_node_types { | ... | @@ -273,7 +289,7 @@ struct __make_hash_node_types { |
| 273 | }; | 289 | }; |
| 274 | 290 | ||
| 275 | template <class _NodePtr> | 291 | template <class _NodePtr> |
| 276 | class _LIBCPP_TEMPLATE_VIS __hash_iterator { | 292 | class __hash_iterator { |
| 277 | typedef __hash_node_types<_NodePtr> _NodeTypes; | 293 | typedef __hash_node_types<_NodePtr> _NodeTypes; |
| 278 | typedef _NodePtr __node_pointer; | 294 | typedef _NodePtr __node_pointer; |
| 279 | typedef typename _NodeTypes::__next_pointer __next_pointer; | 295 | typedef typename _NodeTypes::__next_pointer __next_pointer; |
| ... | @@ -327,17 +343,17 @@ private: | ... | @@ -327,17 +343,17 @@ private: |
| 327 | template <class, class, class, class> | 343 | template <class, class, class, class> |
| 328 | friend class __hash_table; | 344 | friend class __hash_table; |
| 329 | template <class> | 345 | template <class> |
| 330 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; | 346 | friend class __hash_const_iterator; |
| 331 | template <class> | 347 | template <class> |
| 332 | friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; | 348 | friend class __hash_map_iterator; |
| 333 | template <class, class, class, class, class> | 349 | template <class, class, class, class, class> |
| 334 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; | 350 | friend class unordered_map; |
| 335 | template <class, class, class, class, class> | 351 | template <class, class, class, class, class> |
| 336 | friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; | 352 | friend class unordered_multimap; |
| 337 | }; | 353 | }; |
| 338 | 354 | ||
| 339 | template <class _NodePtr> | 355 | template <class _NodePtr> |
| 340 | class _LIBCPP_TEMPLATE_VIS __hash_const_iterator { | 356 | class __hash_const_iterator { |
| 341 | static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, ""); | 357 | static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, ""); |
| 342 | typedef __hash_node_types<_NodePtr> _NodeTypes; | 358 | typedef __hash_node_types<_NodePtr> _NodeTypes; |
| 343 | typedef _NodePtr __node_pointer; | 359 | typedef _NodePtr __node_pointer; |
| ... | @@ -395,15 +411,15 @@ private: | ... | @@ -395,15 +411,15 @@ private: |
| 395 | template <class, class, class, class> | 411 | template <class, class, class, class> |
| 396 | friend class __hash_table; | 412 | friend class __hash_table; |
| 397 | template <class> | 413 | template <class> |
| 398 | friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; | 414 | friend class __hash_map_const_iterator; |
| 399 | template <class, class, class, class, class> | 415 | template <class, class, class, class, class> |
| 400 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; | 416 | friend class unordered_map; |
| 401 | template <class, class, class, class, class> | 417 | template <class, class, class, class, class> |
| 402 | friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; | 418 | friend class unordered_multimap; |
| 403 | }; | 419 | }; |
| 404 | 420 | ||
| 405 | template <class _NodePtr> | 421 | template <class _NodePtr> |
| 406 | class _LIBCPP_TEMPLATE_VIS __hash_local_iterator { | 422 | class __hash_local_iterator { |
| 407 | typedef __hash_node_types<_NodePtr> _NodeTypes; | 423 | typedef __hash_node_types<_NodePtr> _NodeTypes; |
| 408 | typedef _NodePtr __node_pointer; | 424 | typedef _NodePtr __node_pointer; |
| 409 | typedef typename _NodeTypes::__next_pointer __next_pointer; | 425 | typedef typename _NodeTypes::__next_pointer __next_pointer; |
| ... | @@ -468,13 +484,13 @@ private: | ... | @@ -468,13 +484,13 @@ private: |
| 468 | template <class, class, class, class> | 484 | template <class, class, class, class> |
| 469 | friend class __hash_table; | 485 | friend class __hash_table; |
| 470 | template <class> | 486 | template <class> |
| 471 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; | 487 | friend class __hash_const_local_iterator; |
| 472 | template <class> | 488 | template <class> |
| 473 | friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; | 489 | friend class __hash_map_iterator; |
| 474 | }; | 490 | }; |
| 475 | 491 | ||
| 476 | template <class _ConstNodePtr> | 492 | template <class _ConstNodePtr> |
| 477 | class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator { | 493 | class __hash_const_local_iterator { |
| 478 | typedef __hash_node_types<_ConstNodePtr> _NodeTypes; | 494 | typedef __hash_node_types<_ConstNodePtr> _NodeTypes; |
| 479 | typedef _ConstNodePtr __node_pointer; | 495 | typedef _ConstNodePtr __node_pointer; |
| 480 | typedef typename _NodeTypes::__next_pointer __next_pointer; | 496 | typedef typename _NodeTypes::__next_pointer __next_pointer; |
| ... | @@ -553,7 +569,7 @@ private: | ... | @@ -553,7 +569,7 @@ private: |
| 553 | template <class, class, class, class> | 569 | template <class, class, class, class> |
| 554 | friend class __hash_table; | 570 | friend class __hash_table; |
| 555 | template <class> | 571 | template <class> |
| 556 | friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; | 572 | friend class __hash_map_const_iterator; |
| 557 | }; | 573 | }; |
| 558 | 574 | ||
| 559 | template <class _Alloc> | 575 | template <class _Alloc> |
| ... | @@ -667,14 +683,14 @@ int __diagnose_unordered_container_requirements(void*); | ... | @@ -667,14 +683,14 @@ int __diagnose_unordered_container_requirements(void*); |
| 667 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 683 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 668 | class __hash_table { | 684 | class __hash_table { |
| 669 | public: | 685 | public: |
| 670 | typedef _Tp value_type; | 686 | using value_type = __get_hash_node_value_type_t<_Tp>; |
| 671 | typedef _Hash hasher; | 687 | typedef _Hash hasher; |
| 672 | typedef _Equal key_equal; | 688 | typedef _Equal key_equal; |
| 673 | typedef _Alloc allocator_type; | 689 | typedef _Alloc allocator_type; |
| 674 | 690 | ||
| 675 | private: | 691 | private: |
| 676 | typedef allocator_traits<allocator_type> __alloc_traits; | 692 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 677 | typedef typename __make_hash_node_types<value_type, typename __alloc_traits::void_pointer>::type _NodeTypes; | 693 | typedef typename __make_hash_node_types<_Tp, typename __alloc_traits::void_pointer>::type _NodeTypes; |
| 678 | 694 | ||
| 679 | public: | 695 | public: |
| 680 | typedef typename _NodeTypes::__node_value_type __node_value_type; | 696 | typedef typename _NodeTypes::__node_value_type __node_value_type; |
| ... | @@ -770,9 +786,10 @@ public: | ... | @@ -770,9 +786,10 @@ public: |
| 770 | 786 | ||
| 771 | _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(const __hash_table& __u); | 787 | _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(const __hash_table& __u); |
| 772 | _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(__hash_table&& __u) | 788 | _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(__hash_table&& __u) |
| 773 | _NOEXCEPT_(__node_traits::propagate_on_container_move_assignment::value&& | 789 | _NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value && |
| 774 | is_nothrow_move_assignable<__node_allocator>::value&& is_nothrow_move_assignable<hasher>::value&& | 790 | ((__node_traits::propagate_on_container_move_assignment::value && |
| 775 | is_nothrow_move_assignable<key_equal>::value); | 791 | is_nothrow_move_assignable<__node_allocator>::value) || |
| 792 | allocator_traits<__node_allocator>::is_always_equal::value)); | ||
| 776 | template <class _InputIterator> | 793 | template <class _InputIterator> |
| 777 | _LIBCPP_HIDE_FROM_ABI void __assign_unique(_InputIterator __first, _InputIterator __last); | 794 | _LIBCPP_HIDE_FROM_ABI void __assign_unique(_InputIterator __first, _InputIterator __last); |
| 778 | template <class _InputIterator> | 795 | template <class _InputIterator> |
| ... | @@ -835,27 +852,36 @@ public: | ... | @@ -835,27 +852,36 @@ public: |
| 835 | template <class... _Args> | 852 | template <class... _Args> |
| 836 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); | 853 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); |
| 837 | 854 | ||
| 838 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(__container_value_type&& __x) { | 855 | template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> |
| 839 | return __emplace_unique_key_args(_NodeTypes::__get_key(__x), std::move(__x)); | 856 | _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(value_type&& __value) { |
| 840 | } | 857 | using __key_type = typename _NodeTypes::key_type; |
| 841 | 858 | ||
| 842 | template <class _Pp, __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value, int> = 0> | 859 | __node_holder __h = __construct_node(const_cast<__key_type&&>(__value.first), std::move(__value.second)); |
| 843 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Pp&& __x) { | 860 | __node_insert_unique(__h.get()); |
| 844 | return __emplace_unique(std::forward<_Pp>(__x)); | 861 | __h.release(); |
| 845 | } | 862 | } |
| 846 | 863 | ||
| 847 | template <class _Pp> | 864 | template <class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0> |
| 848 | _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(_Pp&& __x) { | 865 | _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(value_type&& __value) { |
| 849 | return __emplace_multi(std::forward<_Pp>(__x)); | 866 | __node_holder __h = __construct_node(std::move(__value)); |
| 867 | __node_insert_unique(__h.get()); | ||
| 868 | __h.release(); | ||
| 850 | } | 869 | } |
| 851 | 870 | ||
| 852 | template <class _Pp> | 871 | template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> |
| 853 | _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, _Pp&& __x) { | 872 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(value_type&& __value) { |
| 854 | return __emplace_hint_multi(__p, std::forward<_Pp>(__x)); | 873 | using __key_type = typename _NodeTypes::key_type; |
| 874 | |||
| 875 | __node_holder __h = __construct_node(const_cast<__key_type&&>(__value.first), std::move(__value.second)); | ||
| 876 | __node_insert_multi(__h.get()); | ||
| 877 | __h.release(); | ||
| 855 | } | 878 | } |
| 856 | 879 | ||
| 857 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(const __container_value_type& __x) { | 880 | template <class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0> |
| 858 | return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x); | 881 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(value_type&& __value) { |
| 882 | __node_holder __h = __construct_node(std::move(__value)); | ||
| 883 | __node_insert_multi(__h.get()); | ||
| 884 | __h.release(); | ||
| 859 | } | 885 | } |
| 860 | 886 | ||
| 861 | #if _LIBCPP_STD_VER >= 17 | 887 | #if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1019,10 +1045,25 @@ private: | ... | @@ -1019,10 +1045,25 @@ private: |
| 1019 | _LIBCPP_HIDE_FROM_ABI void __deallocate_node(__next_pointer __np) _NOEXCEPT; | 1045 | _LIBCPP_HIDE_FROM_ABI void __deallocate_node(__next_pointer __np) _NOEXCEPT; |
| 1020 | _LIBCPP_HIDE_FROM_ABI __next_pointer __detach() _NOEXCEPT; | 1046 | _LIBCPP_HIDE_FROM_ABI __next_pointer __detach() _NOEXCEPT; |
| 1021 | 1047 | ||
| 1048 | template <class _From, class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0> | ||
| 1049 | _LIBCPP_HIDE_FROM_ABI void __assign_value(__get_hash_node_value_type_t<_Tp>& __lhs, _From&& __rhs) { | ||
| 1050 | using __key_type = typename _NodeTypes::key_type; | ||
| 1051 | |||
| 1052 | // This is technically UB, since the object was constructed as `const`. | ||
| 1053 | // Clang doesn't optimize on this currently though. | ||
| 1054 | const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first); | ||
| 1055 | __lhs.second = std::forward<_From>(__rhs).second; | ||
| 1056 | } | ||
| 1057 | |||
| 1058 | template <class _From, class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0> | ||
| 1059 | _LIBCPP_HIDE_FROM_ABI void __assign_value(_Tp& __lhs, _From&& __rhs) { | ||
| 1060 | __lhs = std::forward<_From>(__rhs); | ||
| 1061 | } | ||
| 1062 | |||
| 1022 | template <class, class, class, class, class> | 1063 | template <class, class, class, class, class> |
| 1023 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; | 1064 | friend class unordered_map; |
| 1024 | template <class, class, class, class, class> | 1065 | template <class, class, class, class, class> |
| 1025 | friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; | 1066 | friend class unordered_multimap; |
| 1026 | }; | 1067 | }; |
| 1027 | 1068 | ||
| 1028 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1069 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | @@ -1215,8 +1256,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, | ... | @@ -1215,8 +1256,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, |
| 1215 | #endif // _LIBCPP_HAS_EXCEPTIONS | 1256 | #endif // _LIBCPP_HAS_EXCEPTIONS |
| 1216 | const_iterator __i = __u.begin(); | 1257 | const_iterator __i = __u.begin(); |
| 1217 | while (__cache != nullptr && __u.size() != 0) { | 1258 | while (__cache != nullptr && __u.size() != 0) { |
| 1218 | __cache->__upcast()->__get_value() = std::move(__u.remove(__i++)->__get_value()); | 1259 | __assign_value(__cache->__upcast()->__get_value(), std::move(__u.remove(__i++)->__get_value())); |
| 1219 | __next_pointer __next = __cache->__next_; | 1260 | __next_pointer __next = __cache->__next_; |
| 1220 | __node_insert_multi(__cache->__upcast()); | 1261 | __node_insert_multi(__cache->__upcast()); |
| 1221 | __cache = __next; | 1262 | __cache = __next; |
| 1222 | } | 1263 | } |
| ... | @@ -1229,19 +1270,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, | ... | @@ -1229,19 +1270,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, |
| 1229 | __deallocate_node(__cache); | 1270 | __deallocate_node(__cache); |
| 1230 | } | 1271 | } |
| 1231 | const_iterator __i = __u.begin(); | 1272 | const_iterator __i = __u.begin(); |
| 1232 | while (__u.size() != 0) { | 1273 | while (__u.size() != 0) |
| 1233 | __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__get_value())); | 1274 | __insert_multi_from_orphaned_node(std::move(__u.remove(__i++)->__get_value())); |
| 1234 | __node_insert_multi(__h.get()); | ||
| 1235 | __h.release(); | ||
| 1236 | } | ||
| 1237 | } | 1275 | } |
| 1238 | } | 1276 | } |
| 1239 | 1277 | ||
| 1240 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1278 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1241 | inline __hash_table<_Tp, _Hash, _Equal, _Alloc>& | 1279 | inline __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) |
| 1242 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) _NOEXCEPT_( | 1280 | _NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value && |
| 1243 | __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<__node_allocator>::value&& | 1281 | ((__node_traits::propagate_on_container_move_assignment::value && |
| 1244 | is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value) { | 1282 | is_nothrow_move_assignable<__node_allocator>::value) || |
| 1283 | allocator_traits<__node_allocator>::is_always_equal::value)) { | ||
| 1245 | __move_assign(__u, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); | 1284 | __move_assign(__u, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); |
| 1246 | return *this; | 1285 | return *this; |
| 1247 | } | 1286 | } |
| ... | @@ -1260,8 +1299,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __ | ... | @@ -1260,8 +1299,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __ |
| 1260 | try { | 1299 | try { |
| 1261 | #endif // _LIBCPP_HAS_EXCEPTIONS | 1300 | #endif // _LIBCPP_HAS_EXCEPTIONS |
| 1262 | for (; __cache != nullptr && __first != __last; ++__first) { | 1301 | for (; __cache != nullptr && __first != __last; ++__first) { |
| 1263 | __cache->__upcast()->__get_value() = *__first; | 1302 | __assign_value(__cache->__upcast()->__get_value(), *__first); |
| 1264 | __next_pointer __next = __cache->__next_; | 1303 | __next_pointer __next = __cache->__next_; |
| 1265 | __node_insert_unique(__cache->__upcast()); | 1304 | __node_insert_unique(__cache->__upcast()); |
| 1266 | __cache = __next; | 1305 | __cache = __next; |
| 1267 | } | 1306 | } |
| ... | @@ -1274,7 +1313,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __ | ... | @@ -1274,7 +1313,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __ |
| 1274 | __deallocate_node(__cache); | 1313 | __deallocate_node(__cache); |
| 1275 | } | 1314 | } |
| 1276 | for (; __first != __last; ++__first) | 1315 | for (; __first != __last; ++__first) |
| 1277 | __insert_unique(*__first); | 1316 | __emplace_unique(*__first); |
| 1278 | } | 1317 | } |
| 1279 | 1318 | ||
| 1280 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1319 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | @@ -1292,7 +1331,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f | ... | @@ -1292,7 +1331,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f |
| 1292 | try { | 1331 | try { |
| 1293 | #endif // _LIBCPP_HAS_EXCEPTIONS | 1332 | #endif // _LIBCPP_HAS_EXCEPTIONS |
| 1294 | for (; __cache != nullptr && __first != __last; ++__first) { | 1333 | for (; __cache != nullptr && __first != __last; ++__first) { |
| 1295 | __cache->__upcast()->__get_value() = *__first; | 1334 | __assign_value(__cache->__upcast()->__get_value(), *__first); |
| 1296 | __next_pointer __next = __cache->__next_; | 1335 | __next_pointer __next = __cache->__next_; |
| 1297 | __node_insert_multi(__cache->__upcast()); | 1336 | __node_insert_multi(__cache->__upcast()); |
| 1298 | __cache = __next; | 1337 | __cache = __next; |
| ... | @@ -1306,7 +1345,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f | ... | @@ -1306,7 +1345,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f |
| 1306 | __deallocate_node(__cache); | 1345 | __deallocate_node(__cache); |
| 1307 | } | 1346 | } |
| 1308 | for (; __first != __last; ++__first) | 1347 | for (; __first != __last; ++__first) |
| 1309 | __insert_multi(_NodeTypes::__get_value(*__first)); | 1348 | __emplace_multi(_NodeTypes::__get_value(*__first)); |
| 1310 | } | 1349 | } |
| 1311 | 1350 | ||
| 1312 | template <class _Tp, class _Hash, class _Equal, class _Alloc> | 1351 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | @@ -1769,9 +1808,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> | ... | @@ -1769,9 +1808,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1769 | template <class _Key> | 1808 | template <class _Key> |
| 1770 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator | 1809 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 1771 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) { | 1810 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) { |
| 1772 | size_t __hash = hash_function()(__k); | ||
| 1773 | size_type __bc = bucket_count(); | 1811 | size_type __bc = bucket_count(); |
| 1774 | if (__bc != 0) { | 1812 | if (__bc != 0 && size() != 0) { |
| 1813 | size_t __hash = hash_function()(__k); | ||
| 1775 | size_t __chash = std::__constrain_hash(__hash, __bc); | 1814 | size_t __chash = std::__constrain_hash(__hash, __bc); |
| 1776 | __next_pointer __nd = __bucket_list_[__chash]; | 1815 | __next_pointer __nd = __bucket_list_[__chash]; |
| 1777 | if (__nd != nullptr) { | 1816 | if (__nd != nullptr) { |
| ... | @@ -1790,9 +1829,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> | ... | @@ -1790,9 +1829,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1790 | template <class _Key> | 1829 | template <class _Key> |
| 1791 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator | 1830 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator |
| 1792 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const { | 1831 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const { |
| 1793 | size_t __hash = hash_function()(__k); | ||
| 1794 | size_type __bc = bucket_count(); | 1832 | size_type __bc = bucket_count(); |
| 1795 | if (__bc != 0) { | 1833 | if (__bc != 0 && size() != 0) { |
| 1834 | size_t __hash = hash_function()(__k); | ||
| 1796 | size_t __chash = std::__constrain_hash(__hash, __bc); | 1835 | size_t __chash = std::__constrain_hash(__hash, __bc); |
| 1797 | __next_pointer __nd = __bucket_list_[__chash]; | 1836 | __next_pointer __nd = __bucket_list_[__chash]; |
| 1798 | if (__nd != nullptr) { | 1837 | if (__nd != nullptr) { |
lib/libcxx/include/__ios/fpos.h+1-1| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _StateT> | 22 | template <class _StateT> |
| 23 | class _LIBCPP_TEMPLATE_VIS fpos { | 23 | class fpos { |
| 24 | private: | 24 | private: |
| 25 | _StateT __st_; | 25 | _StateT __st_; |
| 26 | streamoff __off_; | 26 | streamoff __off_; |
lib/libcxx/include/__iterator/advance.h+7-9| ... | @@ -65,9 +65,8 @@ template < class _InputIter, | ... | @@ -65,9 +65,8 @@ template < class _InputIter, |
| 65 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) { | 65 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) { |
| 66 | typedef typename iterator_traits<_InputIter>::difference_type _Difference; | 66 | typedef typename iterator_traits<_InputIter>::difference_type _Difference; |
| 67 | _Difference __n = static_cast<_Difference>(std::__convert_to_integral(__orig_n)); | 67 | _Difference __n = static_cast<_Difference>(std::__convert_to_integral(__orig_n)); |
| 68 | // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation. | 68 | _LIBCPP_ASSERT_PEDANTIC(__has_bidirectional_iterator_category<_InputIter>::value || __n >= 0, |
| 69 | _LIBCPP_ASSERT_PEDANTIC(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value, | 69 | "std::advance: Can only pass a negative `n` with a bidirectional_iterator."); |
| 70 | "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); | ||
| 71 | std::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); | 70 | std::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); |
| 72 | } | 71 | } |
| 73 | 72 | ||
| ... | @@ -98,9 +97,8 @@ public: | ... | @@ -98,9 +97,8 @@ public: |
| 98 | // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative. | 97 | // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative. |
| 99 | template <input_or_output_iterator _Ip> | 98 | template <input_or_output_iterator _Ip> |
| 100 | _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const { | 99 | _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const { |
| 101 | // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation. | 100 | _LIBCPP_ASSERT_PEDANTIC(bidirectional_iterator<_Ip> || __n >= 0, |
| 102 | _LIBCPP_ASSERT_PEDANTIC( | 101 | "ranges::advance: Can only pass a negative `n` with a bidirectional_iterator."); |
| 103 | __n >= 0 || bidirectional_iterator<_Ip>, "If `n < 0`, then `bidirectional_iterator<I>` must be true."); | ||
| 104 | 102 | ||
| 105 | // If `I` models `random_access_iterator`, equivalent to `i += n`. | 103 | // If `I` models `random_access_iterator`, equivalent to `i += n`. |
| 106 | if constexpr (random_access_iterator<_Ip>) { | 104 | if constexpr (random_access_iterator<_Ip>) { |
| ... | @@ -149,9 +147,9 @@ public: | ... | @@ -149,9 +147,9 @@ public: |
| 149 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> | 147 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> |
| 150 | _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> | 148 | _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> |
| 151 | operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const { | 149 | operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const { |
| 152 | // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation. | 150 | _LIBCPP_ASSERT_PEDANTIC( |
| 153 | _LIBCPP_ASSERT_PEDANTIC((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>), | 151 | (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) || (__n >= 0), |
| 154 | "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true."); | 152 | "ranges::advance: Can only pass a negative `n` with a bidirectional_iterator coming from a common_range."); |
| 155 | // If `S` and `I` model `sized_sentinel_for<S, I>`: | 153 | // If `S` and `I` model `sized_sentinel_for<S, I>`: |
| 156 | if constexpr (sized_sentinel_for<_Sp, _Ip>) { | 154 | if constexpr (sized_sentinel_for<_Sp, _Ip>) { |
| 157 | // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`. | 155 | // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`. |
lib/libcxx/include/__iterator/aliasing_iterator.h+6-3| ... | @@ -12,8 +12,10 @@ | ... | @@ -12,8 +12,10 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/ptrdiff_t.h> | 13 | #include <__cstddef/ptrdiff_t.h> |
| 14 | #include <__iterator/iterator_traits.h> | 14 | #include <__iterator/iterator_traits.h> |
| 15 | #include <__memory/addressof.h> | ||
| 15 | #include <__memory/pointer_traits.h> | 16 | #include <__memory/pointer_traits.h> |
| 16 | #include <__type_traits/is_trivial.h> | 17 | #include <__type_traits/is_trivially_constructible.h> |
| 18 | #include <__type_traits/is_trivially_copyable.h> | ||
| 17 | 19 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header | 21 | # pragma GCC system_header |
| ... | @@ -44,7 +46,8 @@ struct __aliasing_iterator_wrapper { | ... | @@ -44,7 +46,8 @@ struct __aliasing_iterator_wrapper { |
| 44 | using reference = value_type&; | 46 | using reference = value_type&; |
| 45 | using pointer = value_type*; | 47 | using pointer = value_type*; |
| 46 | 48 | ||
| 47 | static_assert(is_trivial<value_type>::value); | 49 | static_assert(is_trivially_default_constructible<value_type>::value); |
| 50 | static_assert(is_trivially_copyable<value_type>::value); | ||
| 48 | static_assert(sizeof(__base_value_type) == sizeof(value_type)); | 51 | static_assert(sizeof(__base_value_type) == sizeof(value_type)); |
| 49 | 52 | ||
| 50 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | 53 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; |
| ... | @@ -102,7 +105,7 @@ struct __aliasing_iterator_wrapper { | ... | @@ -102,7 +105,7 @@ struct __aliasing_iterator_wrapper { |
| 102 | 105 | ||
| 103 | _LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT { | 106 | _LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT { |
| 104 | _Alias __val; | 107 | _Alias __val; |
| 105 | __builtin_memcpy(&__val, std::__to_address(__base_), sizeof(value_type)); | 108 | __builtin_memcpy(std::addressof(__val), std::__to_address(__base_), sizeof(value_type)); |
| 106 | return __val; | 109 | return __val; |
| 107 | } | 110 | } |
| 108 | 111 |
lib/libcxx/include/__iterator/back_insert_iterator.h+1-1| ... | @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 29 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 30 | template <class _Container> | 30 | template <class _Container> |
| 31 | class _LIBCPP_TEMPLATE_VIS back_insert_iterator | 31 | class back_insert_iterator |
| 32 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 32 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 33 | : public iterator<output_iterator_tag, void, void, void, void> | 33 | : public iterator<output_iterator_tag, void, void, void, void> |
| 34 | #endif | 34 | #endif |
lib/libcxx/include/__iterator/common_iterator.h+4-3| ... | @@ -28,6 +28,7 @@ | ... | @@ -28,6 +28,7 @@ |
| 28 | #include <__memory/addressof.h> | 28 | #include <__memory/addressof.h> |
| 29 | #include <__type_traits/conditional.h> | 29 | #include <__type_traits/conditional.h> |
| 30 | #include <__type_traits/is_pointer.h> | 30 | #include <__type_traits/is_pointer.h> |
| 31 | #include <__type_traits/is_referenceable.h> | ||
| 31 | #include <__utility/declval.h> | 32 | #include <__utility/declval.h> |
| 32 | #include <variant> | 33 | #include <variant> |
| 33 | 34 | ||
| ... | @@ -157,7 +158,7 @@ public: | ... | @@ -157,7 +158,7 @@ public: |
| 157 | ++*this; | 158 | ++*this; |
| 158 | return __tmp; | 159 | return __tmp; |
| 159 | } else if constexpr (requires(_Iter& __i) { | 160 | } else if constexpr (requires(_Iter& __i) { |
| 160 | { *__i++ } -> __can_reference; | 161 | { *__i++ } -> __referenceable; |
| 161 | } || !__can_use_postfix_proxy<_Iter>) { | 162 | } || !__can_use_postfix_proxy<_Iter>) { |
| 162 | return std::__unchecked_get<_Iter>(__hold_)++; | 163 | return std::__unchecked_get<_Iter>(__hold_)++; |
| 163 | } else { | 164 | } else { |
| ... | @@ -272,13 +273,13 @@ concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>& | ... | @@ -272,13 +273,13 @@ concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>& |
| 272 | 273 | ||
| 273 | template <class, class> | 274 | template <class, class> |
| 274 | struct __arrow_type_or_void { | 275 | struct __arrow_type_or_void { |
| 275 | using type = void; | 276 | using type _LIBCPP_NODEBUG = void; |
| 276 | }; | 277 | }; |
| 277 | 278 | ||
| 278 | template <class _Iter, class _Sent> | 279 | template <class _Iter, class _Sent> |
| 279 | requires __common_iter_has_ptr_op<_Iter, _Sent> | 280 | requires __common_iter_has_ptr_op<_Iter, _Sent> |
| 280 | struct __arrow_type_or_void<_Iter, _Sent> { | 281 | struct __arrow_type_or_void<_Iter, _Sent> { |
| 281 | using type = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->()); | 282 | using type _LIBCPP_NODEBUG = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->()); |
| 282 | }; | 283 | }; |
| 283 | 284 | ||
| 284 | template <input_iterator _Iter, class _Sent> | 285 | template <input_iterator _Iter, class _Sent> |
lib/libcxx/include/__iterator/concepts.h+46-5| ... | @@ -29,15 +29,19 @@ | ... | @@ -29,15 +29,19 @@ |
| 29 | #include <__iterator/incrementable_traits.h> | 29 | #include <__iterator/incrementable_traits.h> |
| 30 | #include <__iterator/iter_move.h> | 30 | #include <__iterator/iter_move.h> |
| 31 | #include <__iterator/iterator_traits.h> | 31 | #include <__iterator/iterator_traits.h> |
| 32 | #include <__iterator/readable_traits.h> | ||
| 33 | #include <__memory/pointer_traits.h> | 32 | #include <__memory/pointer_traits.h> |
| 34 | #include <__type_traits/add_pointer.h> | 33 | #include <__type_traits/add_pointer.h> |
| 35 | #include <__type_traits/common_reference.h> | 34 | #include <__type_traits/common_reference.h> |
| 35 | #include <__type_traits/conditional.h> | ||
| 36 | #include <__type_traits/disjunction.h> | ||
| 37 | #include <__type_traits/enable_if.h> | ||
| 36 | #include <__type_traits/integral_constant.h> | 38 | #include <__type_traits/integral_constant.h> |
| 37 | #include <__type_traits/invoke.h> | 39 | #include <__type_traits/invoke.h> |
| 38 | #include <__type_traits/is_pointer.h> | 40 | #include <__type_traits/is_pointer.h> |
| 39 | #include <__type_traits/is_primary_template.h> | 41 | #include <__type_traits/is_primary_template.h> |
| 40 | #include <__type_traits/is_reference.h> | 42 | #include <__type_traits/is_reference.h> |
| 43 | #include <__type_traits/is_referenceable.h> | ||
| 44 | #include <__type_traits/is_valid_expansion.h> | ||
| 41 | #include <__type_traits/remove_cv.h> | 45 | #include <__type_traits/remove_cv.h> |
| 42 | #include <__type_traits/remove_cvref.h> | 46 | #include <__type_traits/remove_cvref.h> |
| 43 | #include <__utility/forward.h> | 47 | #include <__utility/forward.h> |
| ... | @@ -80,12 +84,13 @@ concept __specialization_of_projected = requires { | ... | @@ -80,12 +84,13 @@ concept __specialization_of_projected = requires { |
| 80 | 84 | ||
| 81 | template <class _Tp> | 85 | template <class _Tp> |
| 82 | struct __indirect_value_t_impl { | 86 | struct __indirect_value_t_impl { |
| 83 | using type = iter_value_t<_Tp>&; | 87 | using type _LIBCPP_NODEBUG = iter_value_t<_Tp>&; |
| 84 | }; | 88 | }; |
| 85 | template <__specialization_of_projected _Tp> | 89 | template <__specialization_of_projected _Tp> |
| 86 | struct __indirect_value_t_impl<_Tp> { | 90 | struct __indirect_value_t_impl<_Tp> { |
| 87 | using type = invoke_result_t<__projected_projection_t<_Tp>&, | 91 | using type _LIBCPP_NODEBUG = |
| 88 | typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>; | 92 | invoke_result_t<__projected_projection_t<_Tp>&, |
| 93 | typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>; | ||
| 89 | }; | 94 | }; |
| 90 | 95 | ||
| 91 | template <indirectly_readable _Tp> | 96 | template <indirectly_readable _Tp> |
| ... | @@ -131,7 +136,7 @@ concept incrementable = regular<_Ip> && weakly_incrementable<_Ip> && requires(_I | ... | @@ -131,7 +136,7 @@ concept incrementable = regular<_Ip> && weakly_incrementable<_Ip> && requires(_I |
| 131 | // [iterator.concept.iterator] | 136 | // [iterator.concept.iterator] |
| 132 | template <class _Ip> | 137 | template <class _Ip> |
| 133 | concept input_or_output_iterator = requires(_Ip __i) { | 138 | concept input_or_output_iterator = requires(_Ip __i) { |
| 134 | { *__i } -> __can_reference; | 139 | { *__i } -> __referenceable; |
| 135 | } && weakly_incrementable<_Ip>; | 140 | } && weakly_incrementable<_Ip>; |
| 136 | 141 | ||
| 137 | // [iterator.concept.sentinel] | 142 | // [iterator.concept.sentinel] |
| ... | @@ -149,6 +154,42 @@ concept sized_sentinel_for = | ... | @@ -149,6 +154,42 @@ concept sized_sentinel_for = |
| 149 | { __i - __s } -> same_as<iter_difference_t<_Ip>>; | 154 | { __i - __s } -> same_as<iter_difference_t<_Ip>>; |
| 150 | }; | 155 | }; |
| 151 | 156 | ||
| 157 | template <class _Iter> | ||
| 158 | struct __iter_traits_cache { | ||
| 159 | using type _LIBCPP_NODEBUG = | ||
| 160 | _If<__is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >; | ||
| 161 | }; | ||
| 162 | template <class _Iter> | ||
| 163 | using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type; | ||
| 164 | |||
| 165 | struct __iter_concept_concept_test { | ||
| 166 | template <class _Iter> | ||
| 167 | using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_concept; | ||
| 168 | }; | ||
| 169 | struct __iter_concept_category_test { | ||
| 170 | template <class _Iter> | ||
| 171 | using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_category; | ||
| 172 | }; | ||
| 173 | struct __iter_concept_random_fallback { | ||
| 174 | template <class _Iter> | ||
| 175 | using _Apply _LIBCPP_NODEBUG = | ||
| 176 | __enable_if_t<__is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag>; | ||
| 177 | }; | ||
| 178 | |||
| 179 | template <class _Iter, class _Tester> | ||
| 180 | struct __test_iter_concept : _IsValidExpansion<_Tester::template _Apply, _Iter>, _Tester {}; | ||
| 181 | |||
| 182 | template <class _Iter> | ||
| 183 | struct __iter_concept_cache { | ||
| 184 | using type _LIBCPP_NODEBUG = | ||
| 185 | _Or<__test_iter_concept<_Iter, __iter_concept_concept_test>, | ||
| 186 | __test_iter_concept<_Iter, __iter_concept_category_test>, | ||
| 187 | __test_iter_concept<_Iter, __iter_concept_random_fallback> >; | ||
| 188 | }; | ||
| 189 | |||
| 190 | template <class _Iter> | ||
| 191 | using _ITER_CONCEPT _LIBCPP_NODEBUG = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>; | ||
| 192 | |||
| 152 | // [iterator.concept.input] | 193 | // [iterator.concept.input] |
| 153 | template <class _Ip> | 194 | template <class _Ip> |
| 154 | concept input_iterator = input_or_output_iterator<_Ip> && indirectly_readable<_Ip> && requires { | 195 | concept input_iterator = input_or_output_iterator<_Ip> && indirectly_readable<_Ip> && requires { |
lib/libcxx/include/__iterator/front_insert_iterator.h+1-1| ... | @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 29 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 30 | template <class _Container> | 30 | template <class _Container> |
| 31 | class _LIBCPP_TEMPLATE_VIS front_insert_iterator | 31 | class front_insert_iterator |
| 32 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 32 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 33 | : public iterator<output_iterator_tag, void, void, void, void> | 33 | : public iterator<output_iterator_tag, void, void, void, void> |
| 34 | #endif | 34 | #endif |
lib/libcxx/include/__iterator/insert_iterator.h+1-1| ... | @@ -37,7 +37,7 @@ using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator; | ... | @@ -37,7 +37,7 @@ using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator; |
| 37 | 37 | ||
| 38 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 38 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 39 | template <class _Container> | 39 | template <class _Container> |
| 40 | class _LIBCPP_TEMPLATE_VIS insert_iterator | 40 | class insert_iterator |
| 41 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 41 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 42 | : public iterator<output_iterator_tag, void, void, void, void> | 42 | : public iterator<output_iterator_tag, void, void, void, void> |
| 43 | #endif | 43 | #endif |
lib/libcxx/include/__iterator/istream_iterator.h+4-1| ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 29 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> | 29 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> |
| 30 | class _LIBCPP_TEMPLATE_VIS istream_iterator | 30 | class istream_iterator |
| 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 32 | : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> | 32 | : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> |
| 33 | #endif | 33 | #endif |
| ... | @@ -58,6 +58,9 @@ public: | ... | @@ -58,6 +58,9 @@ public: |
| 58 | __in_stream_ = nullptr; | 58 | __in_stream_ = nullptr; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | // LWG3600 Changed the wording of the copy constructor. In libc++ this constructor | ||
| 62 | // can still be trivial after this change. | ||
| 63 | |||
| 61 | _LIBCPP_HIDE_FROM_ABI const _Tp& operator*() const { return __value_; } | 64 | _LIBCPP_HIDE_FROM_ABI const _Tp& operator*() const { return __value_; } |
| 62 | _LIBCPP_HIDE_FROM_ABI const _Tp* operator->() const { return std::addressof((operator*())); } | 65 | _LIBCPP_HIDE_FROM_ABI const _Tp* operator->() const { return std::addressof((operator*())); } |
| 63 | _LIBCPP_HIDE_FROM_ABI istream_iterator& operator++() { | 66 | _LIBCPP_HIDE_FROM_ABI istream_iterator& operator++() { |
lib/libcxx/include/__iterator/istreambuf_iterator.h+1-1| ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 29 | template <class _CharT, class _Traits> | 29 | template <class _CharT, class _Traits> |
| 30 | class _LIBCPP_TEMPLATE_VIS istreambuf_iterator | 30 | class istreambuf_iterator |
| 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 32 | : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT> | 32 | : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT> |
| 33 | #endif | 33 | #endif |
lib/libcxx/include/__iterator/iter_move.h+2-1| ... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__iterator/iterator_traits.h> | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__type_traits/is_reference.h> | 16 | #include <__type_traits/is_reference.h> |
| 17 | #include <__type_traits/is_referenceable.h> | ||
| 17 | #include <__type_traits/remove_cvref.h> | 18 | #include <__type_traits/remove_cvref.h> |
| 18 | #include <__utility/declval.h> | 19 | #include <__utility/declval.h> |
| 19 | #include <__utility/forward.h> | 20 | #include <__utility/forward.h> |
| ... | @@ -90,7 +91,7 @@ inline constexpr auto iter_move = __iter_move::__fn{}; | ... | @@ -90,7 +91,7 @@ inline constexpr auto iter_move = __iter_move::__fn{}; |
| 90 | 91 | ||
| 91 | template <__dereferenceable _Tp> | 92 | template <__dereferenceable _Tp> |
| 92 | requires requires(_Tp& __t) { | 93 | requires requires(_Tp& __t) { |
| 93 | { ranges::iter_move(__t) } -> __can_reference; | 94 | { ranges::iter_move(__t) } -> __referenceable; |
| 94 | } | 95 | } |
| 95 | using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>())); | 96 | using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>())); |
| 96 | 97 |
lib/libcxx/include/__iterator/iterator.h+1-1| ... | @@ -20,7 +20,7 @@ | ... | @@ -20,7 +20,7 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _Category, class _Tp, class _Distance = ptrdiff_t, class _Pointer = _Tp*, class _Reference = _Tp&> | 22 | template <class _Category, class _Tp, class _Distance = ptrdiff_t, class _Pointer = _Tp*, class _Reference = _Tp&> |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator { | 23 | struct _LIBCPP_DEPRECATED_IN_CXX17 iterator { |
| 24 | typedef _Tp value_type; | 24 | typedef _Tp value_type; |
| 25 | typedef _Distance difference_type; | 25 | typedef _Distance difference_type; |
| 26 | typedef _Pointer pointer; | 26 | typedef _Pointer pointer; |
lib/libcxx/include/__iterator/iterator_traits.h+71-126| ... | @@ -22,16 +22,18 @@ | ... | @@ -22,16 +22,18 @@ |
| 22 | #include <__fwd/pair.h> | 22 | #include <__fwd/pair.h> |
| 23 | #include <__iterator/incrementable_traits.h> | 23 | #include <__iterator/incrementable_traits.h> |
| 24 | #include <__iterator/readable_traits.h> | 24 | #include <__iterator/readable_traits.h> |
| 25 | #include <__tuple/tuple_element.h> | ||
| 25 | #include <__type_traits/common_reference.h> | 26 | #include <__type_traits/common_reference.h> |
| 26 | #include <__type_traits/conditional.h> | 27 | #include <__type_traits/conditional.h> |
| 28 | #include <__type_traits/detected_or.h> | ||
| 27 | #include <__type_traits/disjunction.h> | 29 | #include <__type_traits/disjunction.h> |
| 28 | #include <__type_traits/enable_if.h> | ||
| 29 | #include <__type_traits/integral_constant.h> | 30 | #include <__type_traits/integral_constant.h> |
| 30 | #include <__type_traits/is_convertible.h> | 31 | #include <__type_traits/is_convertible.h> |
| 31 | #include <__type_traits/is_object.h> | 32 | #include <__type_traits/is_object.h> |
| 32 | #include <__type_traits/is_primary_template.h> | 33 | #include <__type_traits/is_primary_template.h> |
| 33 | #include <__type_traits/is_reference.h> | 34 | #include <__type_traits/is_reference.h> |
| 34 | #include <__type_traits/is_valid_expansion.h> | 35 | #include <__type_traits/is_referenceable.h> |
| 36 | #include <__type_traits/nat.h> | ||
| 35 | #include <__type_traits/remove_const.h> | 37 | #include <__type_traits/remove_const.h> |
| 36 | #include <__type_traits/remove_cv.h> | 38 | #include <__type_traits/remove_cv.h> |
| 37 | #include <__type_traits/remove_cvref.h> | 39 | #include <__type_traits/remove_cvref.h> |
| ... | @@ -46,15 +48,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -46,15 +48,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 46 | 48 | ||
| 47 | #if _LIBCPP_STD_VER >= 20 | 49 | #if _LIBCPP_STD_VER >= 20 |
| 48 | 50 | ||
| 49 | template <class _Tp> | ||
| 50 | using __with_reference _LIBCPP_NODEBUG = _Tp&; | ||
| 51 | |||
| 52 | template <class _Tp> | ||
| 53 | concept __can_reference = requires { typename __with_reference<_Tp>; }; | ||
| 54 | |||
| 55 | template <class _Tp> | 51 | template <class _Tp> |
| 56 | concept __dereferenceable = requires(_Tp& __t) { | 52 | concept __dereferenceable = requires(_Tp& __t) { |
| 57 | { *__t } -> __can_reference; // not required to be equality-preserving | 53 | { *__t } -> __referenceable; // not required to be equality-preserving |
| 58 | }; | 54 | }; |
| 59 | 55 | ||
| 60 | // [iterator.traits] | 56 | // [iterator.traits] |
| ... | @@ -64,92 +60,17 @@ using iter_reference_t = decltype(*std::declval<_Tp&>()); | ... | @@ -64,92 +60,17 @@ using iter_reference_t = decltype(*std::declval<_Tp&>()); |
| 64 | #endif // _LIBCPP_STD_VER >= 20 | 60 | #endif // _LIBCPP_STD_VER >= 20 |
| 65 | 61 | ||
| 66 | template <class _Iter> | 62 | template <class _Iter> |
| 67 | struct _LIBCPP_TEMPLATE_VIS iterator_traits; | 63 | struct iterator_traits; |
| 68 | 64 | ||
| 69 | struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {}; | 65 | struct input_iterator_tag {}; |
| 70 | struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {}; | 66 | struct output_iterator_tag {}; |
| 71 | struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {}; | 67 | struct forward_iterator_tag : public input_iterator_tag {}; |
| 72 | struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; | 68 | struct bidirectional_iterator_tag : public forward_iterator_tag {}; |
| 73 | struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; | 69 | struct random_access_iterator_tag : public bidirectional_iterator_tag {}; |
| 74 | #if _LIBCPP_STD_VER >= 20 | 70 | #if _LIBCPP_STD_VER >= 20 |
| 75 | struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_iterator_tag {}; | 71 | struct contiguous_iterator_tag : public random_access_iterator_tag {}; |
| 76 | #endif | 72 | #endif |
| 77 | 73 | ||
| 78 | template <class _Iter> | ||
| 79 | struct __iter_traits_cache { | ||
| 80 | using type = _If< __is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >; | ||
| 81 | }; | ||
| 82 | template <class _Iter> | ||
| 83 | using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type; | ||
| 84 | |||
| 85 | struct __iter_concept_concept_test { | ||
| 86 | template <class _Iter> | ||
| 87 | using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_concept; | ||
| 88 | }; | ||
| 89 | struct __iter_concept_category_test { | ||
| 90 | template <class _Iter> | ||
| 91 | using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_category; | ||
| 92 | }; | ||
| 93 | struct __iter_concept_random_fallback { | ||
| 94 | template <class _Iter> | ||
| 95 | using _Apply _LIBCPP_NODEBUG = | ||
| 96 | __enable_if_t<__is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag>; | ||
| 97 | }; | ||
| 98 | |||
| 99 | template <class _Iter, class _Tester> | ||
| 100 | struct __test_iter_concept : _IsValidExpansion<_Tester::template _Apply, _Iter>, _Tester {}; | ||
| 101 | |||
| 102 | template <class _Iter> | ||
| 103 | struct __iter_concept_cache { | ||
| 104 | using type = _Or< __test_iter_concept<_Iter, __iter_concept_concept_test>, | ||
| 105 | __test_iter_concept<_Iter, __iter_concept_category_test>, | ||
| 106 | __test_iter_concept<_Iter, __iter_concept_random_fallback> >; | ||
| 107 | }; | ||
| 108 | |||
| 109 | template <class _Iter> | ||
| 110 | using _ITER_CONCEPT _LIBCPP_NODEBUG = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>; | ||
| 111 | |||
| 112 | template <class _Tp> | ||
| 113 | struct __has_iterator_typedefs { | ||
| 114 | private: | ||
| 115 | template <class _Up> | ||
| 116 | static false_type __test(...); | ||
| 117 | template <class _Up> | ||
| 118 | static true_type | ||
| 119 | __test(__void_t<typename _Up::iterator_category>* = nullptr, | ||
| 120 | __void_t<typename _Up::difference_type>* = nullptr, | ||
| 121 | __void_t<typename _Up::value_type>* = nullptr, | ||
| 122 | __void_t<typename _Up::reference>* = nullptr, | ||
| 123 | __void_t<typename _Up::pointer>* = nullptr); | ||
| 124 | |||
| 125 | public: | ||
| 126 | static const bool value = decltype(__test<_Tp>(nullptr, nullptr, nullptr, nullptr, nullptr))::value; | ||
| 127 | }; | ||
| 128 | |||
| 129 | template <class _Tp> | ||
| 130 | struct __has_iterator_category { | ||
| 131 | private: | ||
| 132 | template <class _Up> | ||
| 133 | static false_type __test(...); | ||
| 134 | template <class _Up> | ||
| 135 | static true_type __test(typename _Up::iterator_category* = nullptr); | ||
| 136 | |||
| 137 | public: | ||
| 138 | static const bool value = decltype(__test<_Tp>(nullptr))::value; | ||
| 139 | }; | ||
| 140 | |||
| 141 | template <class _Tp> | ||
| 142 | struct __has_iterator_concept { | ||
| 143 | private: | ||
| 144 | template <class _Up> | ||
| 145 | static false_type __test(...); | ||
| 146 | template <class _Up> | ||
| 147 | static true_type __test(typename _Up::iterator_concept* = nullptr); | ||
| 148 | |||
| 149 | public: | ||
| 150 | static const bool value = decltype(__test<_Tp>(nullptr))::value; | ||
| 151 | }; | ||
| 152 | |||
| 153 | #if _LIBCPP_STD_VER >= 20 | 74 | #if _LIBCPP_STD_VER >= 20 |
| 154 | 75 | ||
| 155 | // The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements | 76 | // The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements |
| ... | @@ -158,9 +79,9 @@ public: | ... | @@ -158,9 +79,9 @@ public: |
| 158 | namespace __iterator_traits_detail { | 79 | namespace __iterator_traits_detail { |
| 159 | template <class _Ip> | 80 | template <class _Ip> |
| 160 | concept __cpp17_iterator = requires(_Ip __i) { | 81 | concept __cpp17_iterator = requires(_Ip __i) { |
| 161 | { *__i } -> __can_reference; | 82 | { *__i } -> __referenceable; |
| 162 | { ++__i } -> same_as<_Ip&>; | 83 | { ++__i } -> same_as<_Ip&>; |
| 163 | { *__i++ } -> __can_reference; | 84 | { *__i++ } -> __referenceable; |
| 164 | } && copyable<_Ip>; | 85 | } && copyable<_Ip>; |
| 165 | 86 | ||
| 166 | template <class _Ip> | 87 | template <class _Ip> |
| ... | @@ -219,16 +140,6 @@ concept __specifies_members = requires { | ... | @@ -219,16 +140,6 @@ concept __specifies_members = requires { |
| 219 | requires __has_member_iterator_category<_Ip>; | 140 | requires __has_member_iterator_category<_Ip>; |
| 220 | }; | 141 | }; |
| 221 | 142 | ||
| 222 | template <class> | ||
| 223 | struct __iterator_traits_member_pointer_or_void { | ||
| 224 | using type = void; | ||
| 225 | }; | ||
| 226 | |||
| 227 | template <__has_member_pointer _Tp> | ||
| 228 | struct __iterator_traits_member_pointer_or_void<_Tp> { | ||
| 229 | using type = typename _Tp::pointer; | ||
| 230 | }; | ||
| 231 | |||
| 232 | template <class _Tp> | 143 | template <class _Tp> |
| 233 | concept __cpp17_iterator_missing_members = !__specifies_members<_Tp> && __iterator_traits_detail::__cpp17_iterator<_Tp>; | 144 | concept __cpp17_iterator_missing_members = !__specifies_members<_Tp> && __iterator_traits_detail::__cpp17_iterator<_Tp>; |
| 234 | 145 | ||
| ... | @@ -239,14 +150,14 @@ concept __cpp17_input_iterator_missing_members = | ... | @@ -239,14 +150,14 @@ concept __cpp17_input_iterator_missing_members = |
| 239 | // Otherwise, `pointer` names `void`. | 150 | // Otherwise, `pointer` names `void`. |
| 240 | template <class> | 151 | template <class> |
| 241 | struct __iterator_traits_member_pointer_or_arrow_or_void { | 152 | struct __iterator_traits_member_pointer_or_arrow_or_void { |
| 242 | using type = void; | 153 | using type _LIBCPP_NODEBUG = void; |
| 243 | }; | 154 | }; |
| 244 | 155 | ||
| 245 | // [iterator.traits]/3.2.1 | 156 | // [iterator.traits]/3.2.1 |
| 246 | // If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type. | 157 | // If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type. |
| 247 | template <__has_member_pointer _Ip> | 158 | template <__has_member_pointer _Ip> |
| 248 | struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { | 159 | struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { |
| 249 | using type = typename _Ip::pointer; | 160 | using type _LIBCPP_NODEBUG = typename _Ip::pointer; |
| 250 | }; | 161 | }; |
| 251 | 162 | ||
| 252 | // Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that | 163 | // Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that |
| ... | @@ -254,48 +165,48 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { | ... | @@ -254,48 +165,48 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { |
| 254 | template <class _Ip> | 165 | template <class _Ip> |
| 255 | requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>) | 166 | requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>) |
| 256 | struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { | 167 | struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { |
| 257 | using type = decltype(std::declval<_Ip&>().operator->()); | 168 | using type _LIBCPP_NODEBUG = decltype(std::declval<_Ip&>().operator->()); |
| 258 | }; | 169 | }; |
| 259 | 170 | ||
| 260 | // Otherwise, `reference` names `iter-reference-t<I>`. | 171 | // Otherwise, `reference` names `iter-reference-t<I>`. |
| 261 | template <class _Ip> | 172 | template <class _Ip> |
| 262 | struct __iterator_traits_member_reference { | 173 | struct __iterator_traits_member_reference { |
| 263 | using type = iter_reference_t<_Ip>; | 174 | using type _LIBCPP_NODEBUG = iter_reference_t<_Ip>; |
| 264 | }; | 175 | }; |
| 265 | 176 | ||
| 266 | // [iterator.traits]/3.2.2 | 177 | // [iterator.traits]/3.2.2 |
| 267 | // If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type. | 178 | // If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type. |
| 268 | template <__has_member_reference _Ip> | 179 | template <__has_member_reference _Ip> |
| 269 | struct __iterator_traits_member_reference<_Ip> { | 180 | struct __iterator_traits_member_reference<_Ip> { |
| 270 | using type = typename _Ip::reference; | 181 | using type _LIBCPP_NODEBUG = typename _Ip::reference; |
| 271 | }; | 182 | }; |
| 272 | 183 | ||
| 273 | // [iterator.traits]/3.2.3.4 | 184 | // [iterator.traits]/3.2.3.4 |
| 274 | // input_iterator_tag | 185 | // input_iterator_tag |
| 275 | template <class _Ip> | 186 | template <class _Ip> |
| 276 | struct __deduce_iterator_category { | 187 | struct __deduce_iterator_category { |
| 277 | using type = input_iterator_tag; | 188 | using type _LIBCPP_NODEBUG = input_iterator_tag; |
| 278 | }; | 189 | }; |
| 279 | 190 | ||
| 280 | // [iterator.traits]/3.2.3.1 | 191 | // [iterator.traits]/3.2.3.1 |
| 281 | // `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise | 192 | // `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise |
| 282 | template <__iterator_traits_detail::__cpp17_random_access_iterator _Ip> | 193 | template <__iterator_traits_detail::__cpp17_random_access_iterator _Ip> |
| 283 | struct __deduce_iterator_category<_Ip> { | 194 | struct __deduce_iterator_category<_Ip> { |
| 284 | using type = random_access_iterator_tag; | 195 | using type _LIBCPP_NODEBUG = random_access_iterator_tag; |
| 285 | }; | 196 | }; |
| 286 | 197 | ||
| 287 | // [iterator.traits]/3.2.3.2 | 198 | // [iterator.traits]/3.2.3.2 |
| 288 | // `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise | 199 | // `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise |
| 289 | template <__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip> | 200 | template <__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip> |
| 290 | struct __deduce_iterator_category<_Ip> { | 201 | struct __deduce_iterator_category<_Ip> { |
| 291 | using type = bidirectional_iterator_tag; | 202 | using type _LIBCPP_NODEBUG = bidirectional_iterator_tag; |
| 292 | }; | 203 | }; |
| 293 | 204 | ||
| 294 | // [iterator.traits]/3.2.3.3 | 205 | // [iterator.traits]/3.2.3.3 |
| 295 | // `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise | 206 | // `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise |
| 296 | template <__iterator_traits_detail::__cpp17_forward_iterator _Ip> | 207 | template <__iterator_traits_detail::__cpp17_forward_iterator _Ip> |
| 297 | struct __deduce_iterator_category<_Ip> { | 208 | struct __deduce_iterator_category<_Ip> { |
| 298 | using type = forward_iterator_tag; | 209 | using type _LIBCPP_NODEBUG = forward_iterator_tag; |
| 299 | }; | 210 | }; |
| 300 | 211 | ||
| 301 | template <class _Ip> | 212 | template <class _Ip> |
| ... | @@ -306,13 +217,13 @@ struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {}; | ... | @@ -306,13 +217,13 @@ struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {}; |
| 306 | // that type. | 217 | // that type. |
| 307 | template <__has_member_iterator_category _Ip> | 218 | template <__has_member_iterator_category _Ip> |
| 308 | struct __iterator_traits_iterator_category<_Ip> { | 219 | struct __iterator_traits_iterator_category<_Ip> { |
| 309 | using type = typename _Ip::iterator_category; | 220 | using type _LIBCPP_NODEBUG = typename _Ip::iterator_category; |
| 310 | }; | 221 | }; |
| 311 | 222 | ||
| 312 | // otherwise, it names void. | 223 | // otherwise, it names void. |
| 313 | template <class> | 224 | template <class> |
| 314 | struct __iterator_traits_difference_type { | 225 | struct __iterator_traits_difference_type { |
| 315 | using type = void; | 226 | using type _LIBCPP_NODEBUG = void; |
| 316 | }; | 227 | }; |
| 317 | 228 | ||
| 318 | // If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then | 229 | // If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then |
| ... | @@ -320,7 +231,7 @@ struct __iterator_traits_difference_type { | ... | @@ -320,7 +231,7 @@ struct __iterator_traits_difference_type { |
| 320 | template <class _Ip> | 231 | template <class _Ip> |
| 321 | requires requires { typename incrementable_traits<_Ip>::difference_type; } | 232 | requires requires { typename incrementable_traits<_Ip>::difference_type; } |
| 322 | struct __iterator_traits_difference_type<_Ip> { | 233 | struct __iterator_traits_difference_type<_Ip> { |
| 323 | using type = typename incrementable_traits<_Ip>::difference_type; | 234 | using type _LIBCPP_NODEBUG = typename incrementable_traits<_Ip>::difference_type; |
| 324 | }; | 235 | }; |
| 325 | 236 | ||
| 326 | // [iterator.traits]/3.4 | 237 | // [iterator.traits]/3.4 |
| ... | @@ -328,6 +239,9 @@ struct __iterator_traits_difference_type<_Ip> { | ... | @@ -328,6 +239,9 @@ struct __iterator_traits_difference_type<_Ip> { |
| 328 | template <class> | 239 | template <class> |
| 329 | struct __iterator_traits {}; | 240 | struct __iterator_traits {}; |
| 330 | 241 | ||
| 242 | template <class _Tp> | ||
| 243 | using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; | ||
| 244 | |||
| 331 | // [iterator.traits]/3.1 | 245 | // [iterator.traits]/3.1 |
| 332 | // If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and | 246 | // If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and |
| 333 | // `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members: | 247 | // `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members: |
| ... | @@ -336,7 +250,7 @@ struct __iterator_traits<_Ip> { | ... | @@ -336,7 +250,7 @@ struct __iterator_traits<_Ip> { |
| 336 | using iterator_category = typename _Ip::iterator_category; | 250 | using iterator_category = typename _Ip::iterator_category; |
| 337 | using value_type = typename _Ip::value_type; | 251 | using value_type = typename _Ip::value_type; |
| 338 | using difference_type = typename _Ip::difference_type; | 252 | using difference_type = typename _Ip::difference_type; |
| 339 | using pointer = typename __iterator_traits_member_pointer_or_void<_Ip>::type; | 253 | using pointer = __detected_or_t<void, __pointer_member, _Ip>; |
| 340 | using reference = typename _Ip::reference; | 254 | using reference = typename _Ip::reference; |
| 341 | }; | 255 | }; |
| 342 | 256 | ||
| ... | @@ -391,13 +305,30 @@ struct __iterator_traits<_Iter, true> | ... | @@ -391,13 +305,30 @@ struct __iterator_traits<_Iter, true> |
| 391 | is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value || | 305 | is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value || |
| 392 | is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value > {}; | 306 | is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value > {}; |
| 393 | 307 | ||
| 308 | template <class _Tp> | ||
| 309 | struct __has_iterator_typedefs { | ||
| 310 | private: | ||
| 311 | template <class _Up> | ||
| 312 | static false_type __test(...); | ||
| 313 | template <class _Up> | ||
| 314 | static true_type | ||
| 315 | __test(__void_t<typename _Up::iterator_category>* = nullptr, | ||
| 316 | __void_t<typename _Up::difference_type>* = nullptr, | ||
| 317 | __void_t<typename _Up::value_type>* = nullptr, | ||
| 318 | __void_t<typename _Up::reference>* = nullptr, | ||
| 319 | __void_t<typename _Up::pointer>* = nullptr); | ||
| 320 | |||
| 321 | public: | ||
| 322 | static const bool value = decltype(__test<_Tp>(nullptr, nullptr, nullptr, nullptr, nullptr))::value; | ||
| 323 | }; | ||
| 324 | |||
| 394 | // iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category | 325 | // iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category |
| 395 | // exists. Else iterator_traits<Iterator> will be an empty class. This is a | 326 | // exists. Else iterator_traits<Iterator> will be an empty class. This is a |
| 396 | // conforming extension which allows some programs to compile and behave as | 327 | // conforming extension which allows some programs to compile and behave as |
| 397 | // the client expects instead of failing at compile time. | 328 | // the client expects instead of failing at compile time. |
| 398 | 329 | ||
| 399 | template <class _Iter> | 330 | template <class _Iter> |
| 400 | struct _LIBCPP_TEMPLATE_VIS iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> { | 331 | struct iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> { |
| 401 | using __primary_template _LIBCPP_NODEBUG = iterator_traits; | 332 | using __primary_template _LIBCPP_NODEBUG = iterator_traits; |
| 402 | }; | 333 | }; |
| 403 | #endif // _LIBCPP_STD_VER >= 20 | 334 | #endif // _LIBCPP_STD_VER >= 20 |
| ... | @@ -406,7 +337,7 @@ template <class _Tp> | ... | @@ -406,7 +337,7 @@ template <class _Tp> |
| 406 | #if _LIBCPP_STD_VER >= 20 | 337 | #if _LIBCPP_STD_VER >= 20 |
| 407 | requires is_object_v<_Tp> | 338 | requires is_object_v<_Tp> |
| 408 | #endif | 339 | #endif |
| 409 | struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> { | 340 | struct iterator_traits<_Tp*> { |
| 410 | typedef ptrdiff_t difference_type; | 341 | typedef ptrdiff_t difference_type; |
| 411 | typedef __remove_cv_t<_Tp> value_type; | 342 | typedef __remove_cv_t<_Tp> value_type; |
| 412 | typedef _Tp* pointer; | 343 | typedef _Tp* pointer; |
| ... | @@ -417,18 +348,19 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> { | ... | @@ -417,18 +348,19 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> { |
| 417 | #endif | 348 | #endif |
| 418 | }; | 349 | }; |
| 419 | 350 | ||
| 420 | template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value> | 351 | template <class _Tp> |
| 421 | struct __has_iterator_category_convertible_to : is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up> { | 352 | using __iterator_category _LIBCPP_NODEBUG = typename _Tp::iterator_category; |
| 422 | }; | ||
| 423 | 353 | ||
| 424 | template <class _Tp, class _Up> | 354 | template <class _Tp> |
| 425 | struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {}; | 355 | using __iterator_concept _LIBCPP_NODEBUG = typename _Tp::iterator_concept; |
| 426 | 356 | ||
| 427 | template <class _Tp, class _Up, bool = __has_iterator_concept<_Tp>::value> | 357 | template <class _Tp, class _Up> |
| 428 | struct __has_iterator_concept_convertible_to : is_convertible<typename _Tp::iterator_concept, _Up> {}; | 358 | using __has_iterator_category_convertible_to _LIBCPP_NODEBUG = |
| 359 | is_convertible<__detected_or_t<__nat, __iterator_category, iterator_traits<_Tp> >, _Up>; | ||
| 429 | 360 | ||
| 430 | template <class _Tp, class _Up> | 361 | template <class _Tp, class _Up> |
| 431 | struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {}; | 362 | using __has_iterator_concept_convertible_to _LIBCPP_NODEBUG = |
| 363 | is_convertible<__detected_or_t<__nat, __iterator_concept, _Tp>, _Up>; | ||
| 432 | 364 | ||
| 433 | template <class _Tp> | 365 | template <class _Tp> |
| 434 | using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>; | 366 | using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>; |
| ... | @@ -490,6 +422,18 @@ using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG = | ... | @@ -490,6 +422,18 @@ using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG = |
| 490 | template <class _InputIterator> | 422 | template <class _InputIterator> |
| 491 | using __iter_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type; | 423 | using __iter_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type; |
| 492 | 424 | ||
| 425 | #if _LIBCPP_STD_VER >= 23 | ||
| 426 | template <class _InputIterator> | ||
| 427 | using __iter_key_type _LIBCPP_NODEBUG = remove_const_t<tuple_element_t<0, __iter_value_type<_InputIterator>>>; | ||
| 428 | |||
| 429 | template <class _InputIterator> | ||
| 430 | using __iter_mapped_type _LIBCPP_NODEBUG = tuple_element_t<1, __iter_value_type<_InputIterator>>; | ||
| 431 | |||
| 432 | template <class _InputIterator> | ||
| 433 | using __iter_to_alloc_type _LIBCPP_NODEBUG = | ||
| 434 | pair<const tuple_element_t<0, __iter_value_type<_InputIterator>>, | ||
| 435 | tuple_element_t<1, __iter_value_type<_InputIterator>>>; | ||
| 436 | #else | ||
| 493 | template <class _InputIterator> | 437 | template <class _InputIterator> |
| 494 | using __iter_key_type _LIBCPP_NODEBUG = | 438 | using __iter_key_type _LIBCPP_NODEBUG = |
| 495 | __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; | 439 | __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; |
| ... | @@ -501,6 +445,7 @@ template <class _InputIterator> | ... | @@ -501,6 +445,7 @@ template <class _InputIterator> |
| 501 | using __iter_to_alloc_type _LIBCPP_NODEBUG = | 445 | using __iter_to_alloc_type _LIBCPP_NODEBUG = |
| 502 | pair<const typename iterator_traits<_InputIterator>::value_type::first_type, | 446 | pair<const typename iterator_traits<_InputIterator>::value_type::first_type, |
| 503 | typename iterator_traits<_InputIterator>::value_type::second_type>; | 447 | typename iterator_traits<_InputIterator>::value_type::second_type>; |
| 448 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 504 | 449 | ||
| 505 | template <class _Iter> | 450 | template <class _Iter> |
| 506 | using __iterator_category_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category; | 451 | using __iterator_category_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category; |
lib/libcxx/include/__iterator/move_iterator.h+1-1| ... | @@ -64,7 +64,7 @@ concept __move_iter_comparable = requires { | ... | @@ -64,7 +64,7 @@ concept __move_iter_comparable = requires { |
| 64 | #endif // _LIBCPP_STD_VER >= 20 | 64 | #endif // _LIBCPP_STD_VER >= 20 |
| 65 | 65 | ||
| 66 | template <class _Iter> | 66 | template <class _Iter> |
| 67 | class _LIBCPP_TEMPLATE_VIS move_iterator | 67 | class move_iterator |
| 68 | #if _LIBCPP_STD_VER >= 20 | 68 | #if _LIBCPP_STD_VER >= 20 |
| 69 | : public __move_iter_category_base<_Iter> | 69 | : public __move_iter_category_base<_Iter> |
| 70 | #endif | 70 | #endif |
lib/libcxx/include/__iterator/move_sentinel.h+1-1| ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | #if _LIBCPP_STD_VER >= 20 | 27 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 28 | ||
| 29 | template <semiregular _Sent> | 29 | template <semiregular _Sent> |
| 30 | class _LIBCPP_TEMPLATE_VIS move_sentinel { | 30 | class move_sentinel { |
| 31 | public: | 31 | public: |
| 32 | _LIBCPP_HIDE_FROM_ABI move_sentinel() = default; | 32 | _LIBCPP_HIDE_FROM_ABI move_sentinel() = default; |
| 33 | 33 |
lib/libcxx/include/__iterator/next.h-6| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___ITERATOR_NEXT_H | 10 | #ifndef _LIBCPP___ITERATOR_NEXT_H |
| 11 | #define _LIBCPP___ITERATOR_NEXT_H | 11 | #define _LIBCPP___ITERATOR_NEXT_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__iterator/advance.h> | 14 | #include <__iterator/advance.h> |
| 16 | #include <__iterator/concepts.h> | 15 | #include <__iterator/concepts.h> |
| ... | @@ -27,11 +26,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,11 +26,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> | 26 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 28 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter | 27 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter |
| 29 | next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { | 28 | next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { |
| 30 | // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation. | ||
| 31 | // Note that this check duplicates the similar check in `std::advance`. | ||
| 32 | _LIBCPP_ASSERT_PEDANTIC(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value, | ||
| 33 | "Attempt to next(it, n) with negative n on a non-bidirectional iterator"); | ||
| 34 | |||
| 35 | std::advance(__x, __n); | 29 | std::advance(__x, __n); |
| 36 | return __x; | 30 | return __x; |
| 37 | } | 31 | } |
lib/libcxx/include/__iterator/ostream_iterator.h+1-1| ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 27 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 28 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > | 28 | template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > |
| 29 | class _LIBCPP_TEMPLATE_VIS ostream_iterator | 29 | class ostream_iterator |
| 30 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 30 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 31 | : public iterator<output_iterator_tag, void, void, void, void> | 31 | : public iterator<output_iterator_tag, void, void, void, void> |
| 32 | #endif | 32 | #endif |
lib/libcxx/include/__iterator/ostreambuf_iterator.h+1-1| ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 28 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 29 | template <class _CharT, class _Traits> | 29 | template <class _CharT, class _Traits> |
| 30 | class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator | 30 | class ostreambuf_iterator |
| 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 31 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 32 | : public iterator<output_iterator_tag, void, void, void, void> | 32 | : public iterator<output_iterator_tag, void, void, void, void> |
| 33 | #endif | 33 | #endif |
lib/libcxx/include/__iterator/prev.h-5| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___ITERATOR_PREV_H | 10 | #ifndef _LIBCPP___ITERATOR_PREV_H |
| 11 | #define _LIBCPP___ITERATOR_PREV_H | 11 | #define _LIBCPP___ITERATOR_PREV_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__iterator/advance.h> | 14 | #include <__iterator/advance.h> |
| 16 | #include <__iterator/concepts.h> | 15 | #include <__iterator/concepts.h> |
| ... | @@ -31,10 +30,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -31,10 +30,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> | 30 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 32 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter | 31 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter |
| 33 | prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n) { | 32 | prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n) { |
| 34 | // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation. | ||
| 35 | // Note that this check duplicates the similar check in `std::advance`. | ||
| 36 | _LIBCPP_ASSERT_PEDANTIC(__n <= 0 || __has_bidirectional_iterator_category<_InputIter>::value, | ||
| 37 | "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator"); | ||
| 38 | std::advance(__x, -__n); | 33 | std::advance(__x, -__n); |
| 39 | return __x; | 34 | return __x; |
| 40 | } | 35 | } |
lib/libcxx/include/__iterator/product_iterator.h created+76| ... | @@ -0,0 +1,76 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ITERATOR_PRODUCT_ITERATOR_H | ||
| 10 | #define _LIBCPP___ITERATOR_PRODUCT_ITERATOR_H | ||
| 11 | |||
| 12 | // Product iterators are iterators that contain two or more underlying iterators. | ||
| 13 | // | ||
| 14 | // For example, std::flat_map stores its data into two separate containers, and its iterator | ||
| 15 | // is a proxy over two separate underlying iterators. The concept of product iterators | ||
| 16 | // allows algorithms to operate over these underlying iterators separately, opening the | ||
| 17 | // door to various optimizations. | ||
| 18 | // | ||
| 19 | // If __product_iterator_traits can be instantiated, the following functions and associated types must be provided: | ||
| 20 | // - static constexpr size_t Traits::__size | ||
| 21 | // The number of underlying iterators inside the product iterator. | ||
| 22 | // | ||
| 23 | // - template <size_t _N> | ||
| 24 | // static decltype(auto) Traits::__get_iterator_element(It&& __it) | ||
| 25 | // Returns the _Nth iterator element of the given product iterator. | ||
| 26 | // | ||
| 27 | // - template <class... _Iters> | ||
| 28 | // static _Iterator __make_product_iterator(_Iters&&...); | ||
| 29 | // Creates a product iterator from the given underlying iterators. | ||
| 30 | |||
| 31 | #include <__config> | ||
| 32 | #include <__cstddef/size_t.h> | ||
| 33 | #include <__type_traits/enable_if.h> | ||
| 34 | #include <__type_traits/integral_constant.h> | ||
| 35 | #include <__utility/declval.h> | ||
| 36 | |||
| 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 38 | # pragma GCC system_header | ||
| 39 | #endif | ||
| 40 | |||
| 41 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 42 | |||
| 43 | template <class _Iterator> | ||
| 44 | struct __product_iterator_traits; | ||
| 45 | /* exposition-only: | ||
| 46 | { | ||
| 47 | static constexpr size_t __size = ...; | ||
| 48 | |||
| 49 | template <size_t _N, class _Iter> | ||
| 50 | static decltype(auto) __get_iterator_element(_Iter&&); | ||
| 51 | |||
| 52 | template <class... _Iters> | ||
| 53 | static _Iterator __make_product_iterator(_Iters&&...); | ||
| 54 | }; | ||
| 55 | */ | ||
| 56 | |||
| 57 | template <class _Tp, size_t = 0> | ||
| 58 | struct __is_product_iterator : false_type {}; | ||
| 59 | |||
| 60 | template <class _Tp> | ||
| 61 | struct __is_product_iterator<_Tp, sizeof(__product_iterator_traits<_Tp>) * 0> : true_type {}; | ||
| 62 | |||
| 63 | template <class _Tp, size_t _Size, class = void> | ||
| 64 | struct __is_product_iterator_of_size : false_type {}; | ||
| 65 | |||
| 66 | template <class _Tp, size_t _Size> | ||
| 67 | struct __is_product_iterator_of_size<_Tp, _Size, __enable_if_t<__product_iterator_traits<_Tp>::__size == _Size> > | ||
| 68 | : true_type {}; | ||
| 69 | |||
| 70 | template <class _Iterator, size_t _Nth> | ||
| 71 | using __product_iterator_element_t _LIBCPP_NODEBUG = | ||
| 72 | decltype(__product_iterator_traits<_Iterator>::template __get_iterator_element<_Nth>(std::declval<_Iterator>())); | ||
| 73 | |||
| 74 | _LIBCPP_END_NAMESPACE_STD | ||
| 75 | |||
| 76 | #endif // _LIBCPP___ITERATOR_PRODUCT_ITERATOR_H | ||
lib/libcxx/include/__iterator/reverse_iterator.h+1-1| ... | @@ -48,7 +48,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -48,7 +48,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 48 | ||
| 49 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 49 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 50 | template <class _Iter> | 50 | template <class _Iter> |
| 51 | class _LIBCPP_TEMPLATE_VIS reverse_iterator | 51 | class reverse_iterator |
| 52 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 52 | #if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 53 | : public iterator<typename iterator_traits<_Iter>::iterator_category, | 53 | : public iterator<typename iterator_traits<_Iter>::iterator_category, |
| 54 | typename iterator_traits<_Iter>::value_type, | 54 | typename iterator_traits<_Iter>::value_type, |
lib/libcxx/include/__iterator/segmented_iterator.h+6| ... | @@ -42,6 +42,7 @@ | ... | @@ -42,6 +42,7 @@ |
| 42 | 42 | ||
| 43 | #include <__config> | 43 | #include <__config> |
| 44 | #include <__cstddef/size_t.h> | 44 | #include <__cstddef/size_t.h> |
| 45 | #include <__iterator/iterator_traits.h> | ||
| 45 | #include <__type_traits/integral_constant.h> | 46 | #include <__type_traits/integral_constant.h> |
| 46 | 47 | ||
| 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 48 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -74,6 +75,11 @@ struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {}; | ... | @@ -74,6 +75,11 @@ struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {}; |
| 74 | template <class _Iterator> | 75 | template <class _Iterator> |
| 75 | using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >; | 76 | using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >; |
| 76 | 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 | _LIBCPP_END_NAMESPACE_STD | 83 | _LIBCPP_END_NAMESPACE_STD |
| 78 | 84 | ||
| 79 | #endif // _LIBCPP___SEGMENTED_ITERATOR_H | 85 | #endif // _LIBCPP___SEGMENTED_ITERATOR_H |
lib/libcxx/include/__iterator/wrap_iter.h+3-3| ... | @@ -112,9 +112,9 @@ private: | ... | @@ -112,9 +112,9 @@ private: |
| 112 | template <class _CharT, class _Traits> | 112 | template <class _CharT, class _Traits> |
| 113 | friend class basic_string_view; | 113 | friend class basic_string_view; |
| 114 | template <class _Tp, class _Alloc> | 114 | template <class _Tp, class _Alloc> |
| 115 | friend class _LIBCPP_TEMPLATE_VIS vector; | 115 | friend class vector; |
| 116 | template <class _Tp, size_t> | 116 | template <class _Tp, size_t> |
| 117 | friend class _LIBCPP_TEMPLATE_VIS span; | 117 | friend class span; |
| 118 | template <class _Tp, size_t _Size> | 118 | template <class _Tp, size_t _Size> |
| 119 | friend struct array; | 119 | friend struct array; |
| 120 | }; | 120 | }; |
| ... | @@ -236,7 +236,7 @@ struct __libcpp_is_contiguous_iterator<__wrap_iter<_It> > : true_type {}; | ... | @@ -236,7 +236,7 @@ struct __libcpp_is_contiguous_iterator<__wrap_iter<_It> > : true_type {}; |
| 236 | #endif | 236 | #endif |
| 237 | 237 | ||
| 238 | template <class _It> | 238 | template <class _It> |
| 239 | struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > { | 239 | struct pointer_traits<__wrap_iter<_It> > { |
| 240 | typedef __wrap_iter<_It> pointer; | 240 | typedef __wrap_iter<_It> pointer; |
| 241 | typedef typename pointer_traits<_It>::element_type element_type; | 241 | typedef typename pointer_traits<_It>::element_type element_type; |
| 242 | typedef typename pointer_traits<_It>::difference_type difference_type; | 242 | typedef typename pointer_traits<_It>::difference_type difference_type; |
lib/libcxx/include/__locale+114-122| ... | @@ -11,36 +11,43 @@ | ... | @@ -11,36 +11,43 @@ |
| 11 | #define _LIBCPP___LOCALE | 11 | #define _LIBCPP___LOCALE |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__locale_dir/locale_base_api.h> | 14 | |
| 15 | #include <__memory/shared_count.h> | 15 | #if _LIBCPP_HAS_LOCALIZATION |
| 16 | #include <__mutex/once_flag.h> | 16 | |
| 17 | #include <__type_traits/make_unsigned.h> | 17 | # include <__locale_dir/locale_base_api.h> |
| 18 | #include <__utility/no_destroy.h> | 18 | # include <__memory/addressof.h> |
| 19 | #include <__utility/private_constructor_tag.h> | 19 | # include <__memory/shared_count.h> |
| 20 | #include <cctype> | 20 | # include <__mutex/once_flag.h> |
| 21 | #include <clocale> | 21 | # include <__type_traits/make_unsigned.h> |
| 22 | #include <cstdint> | 22 | # include <__utility/no_destroy.h> |
| 23 | #include <cstdlib> | 23 | # include <__utility/private_constructor_tag.h> |
| 24 | #include <string> | 24 | # include <cctype> |
| 25 | # include <clocale> | ||
| 26 | # include <cstdint> | ||
| 27 | # include <cstdlib> | ||
| 28 | # include <string> | ||
| 25 | 29 | ||
| 26 | // Some platforms require more includes than others. Keep the includes on all plaforms for now. | 30 | // Some platforms require more includes than others. Keep the includes on all plaforms for now. |
| 27 | #include <cstddef> | 31 | # include <cstddef> |
| 28 | #include <cstring> | 32 | # include <cstring> |
| 29 | 33 | ||
| 30 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 34 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 31 | # include <cwchar> | 35 | # include <cwchar> |
| 32 | #else | 36 | # else |
| 33 | # include <__std_mbstate_t.h> | 37 | # include <__std_mbstate_t.h> |
| 34 | #endif | 38 | # endif |
| 35 | 39 | ||
| 36 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 40 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 37 | # pragma GCC system_header | 41 | # pragma GCC system_header |
| 38 | #endif | 42 | # endif |
| 39 | 43 | ||
| 40 | _LIBCPP_BEGIN_NAMESPACE_STD | 44 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 45 | ||
| 42 | class _LIBCPP_EXPORTED_FROM_ABI locale; | 46 | class _LIBCPP_EXPORTED_FROM_ABI locale; |
| 43 | 47 | ||
| 48 | template <class _CharT> | ||
| 49 | class collate; | ||
| 50 | |||
| 44 | template <class _Facet> | 51 | template <class _Facet> |
| 45 | _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale&) _NOEXCEPT; | 52 | _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale&) _NOEXCEPT; |
| 46 | 53 | ||
| ... | @@ -49,8 +56,10 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&); | ... | @@ -49,8 +56,10 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&); |
| 49 | 56 | ||
| 50 | class _LIBCPP_EXPORTED_FROM_ABI locale { | 57 | class _LIBCPP_EXPORTED_FROM_ABI locale { |
| 51 | public: | 58 | public: |
| 52 | // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor. | 59 | // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor, |
| 60 | // so it is trivially relocatable. Like shared_ptr, it is also replaceable. | ||
| 53 | using __trivially_relocatable _LIBCPP_NODEBUG = locale; | 61 | using __trivially_relocatable _LIBCPP_NODEBUG = locale; |
| 62 | using __replaceable _LIBCPP_NODEBUG = locale; | ||
| 54 | 63 | ||
| 55 | // types: | 64 | // types: |
| 56 | class _LIBCPP_EXPORTED_FROM_ABI facet; | 65 | class _LIBCPP_EXPORTED_FROM_ABI facet; |
| ... | @@ -80,17 +89,25 @@ public: | ... | @@ -80,17 +89,25 @@ public: |
| 80 | const locale& operator=(const locale&) _NOEXCEPT; | 89 | const locale& operator=(const locale&) _NOEXCEPT; |
| 81 | 90 | ||
| 82 | template <class _Facet> | 91 | template <class _Facet> |
| 83 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS locale combine(const locale&) const; | 92 | _LIBCPP_HIDE_FROM_ABI locale combine(const locale& __other) const { |
| 93 | if (!std::has_facet<_Facet>(__other)) | ||
| 94 | __throw_runtime_error("locale::combine: locale missing facet"); | ||
| 95 | |||
| 96 | return locale(*this, std::addressof(const_cast<_Facet&>(std::use_facet<_Facet>(__other)))); | ||
| 97 | } | ||
| 84 | 98 | ||
| 85 | // locale operations: | 99 | // locale operations: |
| 86 | string name() const; | 100 | string name() const; |
| 87 | bool operator==(const locale&) const; | 101 | bool operator==(const locale&) const; |
| 88 | #if _LIBCPP_STD_VER <= 17 | 102 | # if _LIBCPP_STD_VER <= 17 |
| 89 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const { return !(*this == __y); } | 103 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const { return !(*this == __y); } |
| 90 | #endif | 104 | # endif |
| 91 | template <class _CharT, class _Traits, class _Allocator> | 105 | template <class _CharT, class _Traits, class _Allocator> |
| 92 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool | 106 | _LIBCPP_HIDE_FROM_ABI bool operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, |
| 93 | operator()(const basic_string<_CharT, _Traits, _Allocator>&, const basic_string<_CharT, _Traits, _Allocator>&) const; | 107 | const basic_string<_CharT, _Traits, _Allocator>& __y) const { |
| 108 | return std::use_facet<std::collate<_CharT> >(*this).compare( | ||
| 109 | __x.data(), __x.data() + __x.size(), __y.data(), __y.data() + __y.size()) < 0; | ||
| 110 | } | ||
| 94 | 111 | ||
| 95 | // global locale objects: | 112 | // global locale objects: |
| 96 | static locale global(const locale&); | 113 | static locale global(const locale&); |
| ... | @@ -151,14 +168,6 @@ inline _LIBCPP_HIDE_FROM_ABI locale::locale(const locale& __other, _Facet* __f) | ... | @@ -151,14 +168,6 @@ inline _LIBCPP_HIDE_FROM_ABI locale::locale(const locale& __other, _Facet* __f) |
| 151 | __install_ctor(__other, __f, __f ? __f->id.__get() : 0); | 168 | __install_ctor(__other, __f, __f ? __f->id.__get() : 0); |
| 152 | } | 169 | } |
| 153 | 170 | ||
| 154 | template <class _Facet> | ||
| 155 | locale locale::combine(const locale& __other) const { | ||
| 156 | if (!std::has_facet<_Facet>(__other)) | ||
| 157 | __throw_runtime_error("locale::combine: locale missing facet"); | ||
| 158 | |||
| 159 | return locale(*this, &const_cast<_Facet&>(std::use_facet<_Facet>(__other))); | ||
| 160 | } | ||
| 161 | |||
| 162 | template <class _Facet> | 171 | template <class _Facet> |
| 163 | inline _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale& __l) _NOEXCEPT { | 172 | inline _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale& __l) _NOEXCEPT { |
| 164 | return __l.has_facet(_Facet::id); | 173 | return __l.has_facet(_Facet::id); |
| ... | @@ -172,7 +181,7 @@ inline _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale& __l) { | ... | @@ -172,7 +181,7 @@ inline _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale& __l) { |
| 172 | // template <class _CharT> class collate; | 181 | // template <class _CharT> class collate; |
| 173 | 182 | ||
| 174 | template <class _CharT> | 183 | template <class _CharT> |
| 175 | class _LIBCPP_TEMPLATE_VIS collate : public locale::facet { | 184 | class collate : public locale::facet { |
| 176 | public: | 185 | public: |
| 177 | typedef _CharT char_type; | 186 | typedef _CharT char_type; |
| 178 | typedef basic_string<char_type> string_type; | 187 | typedef basic_string<char_type> string_type; |
| ... | @@ -237,14 +246,14 @@ long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) cons | ... | @@ -237,14 +246,14 @@ long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) cons |
| 237 | } | 246 | } |
| 238 | 247 | ||
| 239 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>; | 248 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>; |
| 240 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 249 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 241 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>; | 250 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>; |
| 242 | #endif | 251 | # endif |
| 243 | 252 | ||
| 244 | // template <class CharT> class collate_byname; | 253 | // template <class CharT> class collate_byname; |
| 245 | 254 | ||
| 246 | template <class _CharT> | 255 | template <class _CharT> |
| 247 | class _LIBCPP_TEMPLATE_VIS collate_byname; | 256 | class collate_byname; |
| 248 | 257 | ||
| 249 | template <> | 258 | template <> |
| 250 | class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> { | 259 | class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> { |
| ... | @@ -264,7 +273,7 @@ protected: | ... | @@ -264,7 +273,7 @@ protected: |
| 264 | string_type do_transform(const char_type* __lo, const char_type* __hi) const override; | 273 | string_type do_transform(const char_type* __lo, const char_type* __hi) const override; |
| 265 | }; | 274 | }; |
| 266 | 275 | ||
| 267 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 276 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 268 | template <> | 277 | template <> |
| 269 | class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> { | 278 | class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> { |
| 270 | __locale::__locale_t __l_; | 279 | __locale::__locale_t __l_; |
| ... | @@ -283,20 +292,13 @@ protected: | ... | @@ -283,20 +292,13 @@ protected: |
| 283 | const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const override; | 292 | const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const override; |
| 284 | string_type do_transform(const char_type* __lo, const char_type* __hi) const override; | 293 | string_type do_transform(const char_type* __lo, const char_type* __hi) const override; |
| 285 | }; | 294 | }; |
| 286 | #endif | 295 | # endif |
| 287 | |||
| 288 | template <class _CharT, class _Traits, class _Allocator> | ||
| 289 | bool locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, | ||
| 290 | const basic_string<_CharT, _Traits, _Allocator>& __y) const { | ||
| 291 | return std::use_facet<std::collate<_CharT> >(*this).compare( | ||
| 292 | __x.data(), __x.data() + __x.size(), __y.data(), __y.data() + __y.size()) < 0; | ||
| 293 | } | ||
| 294 | 296 | ||
| 295 | // template <class charT> class ctype | 297 | // template <class charT> class ctype |
| 296 | 298 | ||
| 297 | class _LIBCPP_EXPORTED_FROM_ABI ctype_base { | 299 | class _LIBCPP_EXPORTED_FROM_ABI ctype_base { |
| 298 | public: | 300 | public: |
| 299 | #if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE) | 301 | # if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE) |
| 300 | typedef unsigned long mask; | 302 | typedef unsigned long mask; |
| 301 | static const mask space = 1 << 0; | 303 | static const mask space = 1 << 0; |
| 302 | static const mask print = 1 << 1; | 304 | static const mask print = 1 << 1; |
| ... | @@ -308,14 +310,14 @@ public: | ... | @@ -308,14 +310,14 @@ public: |
| 308 | static const mask punct = 1 << 7; | 310 | static const mask punct = 1 << 7; |
| 309 | static const mask xdigit = 1 << 8; | 311 | static const mask xdigit = 1 << 8; |
| 310 | static const mask blank = 1 << 9; | 312 | static const mask blank = 1 << 9; |
| 311 | # if defined(__BIONIC__) | 313 | # if defined(__BIONIC__) |
| 312 | // Historically this was a part of regex_traits rather than ctype_base. The | 314 | // Historically this was a part of regex_traits rather than ctype_base. The |
| 313 | // historical value of the constant is preserved for ABI compatibility. | 315 | // historical value of the constant is preserved for ABI compatibility. |
| 314 | static const mask __regex_word = 0x8000; | 316 | static const mask __regex_word = 0x8000; |
| 315 | # else | 317 | # else |
| 316 | static const mask __regex_word = 1 << 10; | 318 | static const mask __regex_word = 1 << 10; |
| 317 | # endif // defined(__BIONIC__) | 319 | # endif // defined(__BIONIC__) |
| 318 | #elif defined(__GLIBC__) | 320 | # elif defined(__GLIBC__) |
| 319 | typedef unsigned short mask; | 321 | typedef unsigned short mask; |
| 320 | static const mask space = _ISspace; | 322 | static const mask space = _ISspace; |
| 321 | static const mask print = _ISprint; | 323 | static const mask print = _ISprint; |
| ... | @@ -327,12 +329,12 @@ public: | ... | @@ -327,12 +329,12 @@ public: |
| 327 | static const mask punct = _ISpunct; | 329 | static const mask punct = _ISpunct; |
| 328 | static const mask xdigit = _ISxdigit; | 330 | static const mask xdigit = _ISxdigit; |
| 329 | static const mask blank = _ISblank; | 331 | static const mask blank = _ISblank; |
| 330 | # if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN) | 332 | # if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN) |
| 331 | static const mask __regex_word = static_cast<mask>(_ISbit(15)); | 333 | static const mask __regex_word = static_cast<mask>(_ISbit(15)); |
| 332 | # else | 334 | # else |
| 333 | static const mask __regex_word = 0x80; | 335 | static const mask __regex_word = 0x80; |
| 334 | # endif | 336 | # endif |
| 335 | #elif defined(_LIBCPP_MSVCRT_LIKE) | 337 | # elif defined(_LIBCPP_MSVCRT_LIKE) |
| 336 | typedef unsigned short mask; | 338 | typedef unsigned short mask; |
| 337 | static const mask space = _SPACE; | 339 | static const mask space = _SPACE; |
| 338 | static const mask print = _BLANK | _PUNCT | _ALPHA | _DIGIT; | 340 | static const mask print = _BLANK | _PUNCT | _ALPHA | _DIGIT; |
| ... | @@ -345,16 +347,16 @@ public: | ... | @@ -345,16 +347,16 @@ public: |
| 345 | static const mask xdigit = _HEX; | 347 | static const mask xdigit = _HEX; |
| 346 | static const mask blank = _BLANK; | 348 | static const mask blank = _BLANK; |
| 347 | static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used | 349 | static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used |
| 348 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT | 350 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT |
| 349 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA | 351 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA |
| 350 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) | 352 | # elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) |
| 351 | # ifdef __APPLE__ | 353 | # ifdef __APPLE__ |
| 352 | typedef uint32_t mask; | 354 | typedef uint32_t mask; |
| 353 | # elif defined(__FreeBSD__) | 355 | # elif defined(__FreeBSD__) |
| 354 | typedef unsigned long mask; | 356 | typedef unsigned long mask; |
| 355 | # elif defined(__NetBSD__) | 357 | # elif defined(__NetBSD__) |
| 356 | typedef unsigned short mask; | 358 | typedef unsigned short mask; |
| 357 | # endif | 359 | # endif |
| 358 | static const mask space = _CTYPE_S; | 360 | static const mask space = _CTYPE_S; |
| 359 | static const mask print = _CTYPE_R; | 361 | static const mask print = _CTYPE_R; |
| 360 | static const mask cntrl = _CTYPE_C; | 362 | static const mask cntrl = _CTYPE_C; |
| ... | @@ -365,16 +367,16 @@ public: | ... | @@ -365,16 +367,16 @@ public: |
| 365 | static const mask punct = _CTYPE_P; | 367 | static const mask punct = _CTYPE_P; |
| 366 | static const mask xdigit = _CTYPE_X; | 368 | static const mask xdigit = _CTYPE_X; |
| 367 | 369 | ||
| 368 | # if defined(__NetBSD__) | 370 | # if defined(__NetBSD__) |
| 369 | static const mask blank = _CTYPE_BL; | 371 | static const mask blank = _CTYPE_BL; |
| 370 | // NetBSD defines classes up to 0x2000 | 372 | // NetBSD defines classes up to 0x2000 |
| 371 | // see sys/ctype_bits.h, _CTYPE_Q | 373 | // see sys/ctype_bits.h, _CTYPE_Q |
| 372 | static const mask __regex_word = 0x8000; | 374 | static const mask __regex_word = 0x8000; |
| 373 | # else | 375 | # else |
| 374 | static const mask blank = _CTYPE_B; | 376 | static const mask blank = _CTYPE_B; |
| 375 | static const mask __regex_word = 0x80; | 377 | static const mask __regex_word = 0x80; |
| 376 | # endif | 378 | # endif |
| 377 | #elif defined(_AIX) | 379 | # elif defined(_AIX) |
| 378 | typedef unsigned int mask; | 380 | typedef unsigned int mask; |
| 379 | static const mask space = _ISSPACE; | 381 | static const mask space = _ISSPACE; |
| 380 | static const mask print = _ISPRINT; | 382 | static const mask print = _ISPRINT; |
| ... | @@ -387,7 +389,7 @@ public: | ... | @@ -387,7 +389,7 @@ public: |
| 387 | static const mask xdigit = _ISXDIGIT; | 389 | static const mask xdigit = _ISXDIGIT; |
| 388 | static const mask blank = _ISBLANK; | 390 | static const mask blank = _ISBLANK; |
| 389 | static const mask __regex_word = 0x8000; | 391 | static const mask __regex_word = 0x8000; |
| 390 | #elif defined(_NEWLIB_VERSION) | 392 | # elif defined(_NEWLIB_VERSION) |
| 391 | // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. | 393 | // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. |
| 392 | typedef char mask; | 394 | typedef char mask; |
| 393 | // In case char is signed, static_cast is needed to avoid warning on | 395 | // In case char is signed, static_cast is needed to avoid warning on |
| ... | @@ -404,11 +406,11 @@ public: | ... | @@ -404,11 +406,11 @@ public: |
| 404 | static const mask blank = static_cast<mask>(_B); | 406 | static const mask blank = static_cast<mask>(_B); |
| 405 | // mask is already fully saturated, use a different type in regex_type_traits. | 407 | // mask is already fully saturated, use a different type in regex_type_traits. |
| 406 | static const unsigned short __regex_word = 0x100; | 408 | static const unsigned short __regex_word = 0x100; |
| 407 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT | 409 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT |
| 408 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA | 410 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA |
| 409 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT | 411 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT |
| 410 | #elif defined(__MVS__) | 412 | # elif defined(__MVS__) |
| 411 | # if defined(__NATIVE_ASCII_F) | 413 | # if defined(__NATIVE_ASCII_F) |
| 412 | typedef unsigned int mask; | 414 | typedef unsigned int mask; |
| 413 | static const mask space = _ISSPACE_A; | 415 | static const mask space = _ISSPACE_A; |
| 414 | static const mask print = _ISPRINT_A; | 416 | static const mask print = _ISPRINT_A; |
| ... | @@ -420,7 +422,7 @@ public: | ... | @@ -420,7 +422,7 @@ public: |
| 420 | static const mask punct = _ISPUNCT_A; | 422 | static const mask punct = _ISPUNCT_A; |
| 421 | static const mask xdigit = _ISXDIGIT_A; | 423 | static const mask xdigit = _ISXDIGIT_A; |
| 422 | static const mask blank = _ISBLANK_A; | 424 | static const mask blank = _ISBLANK_A; |
| 423 | # else | 425 | # else |
| 424 | typedef unsigned short mask; | 426 | typedef unsigned short mask; |
| 425 | static const mask space = __ISSPACE; | 427 | static const mask space = __ISSPACE; |
| 426 | static const mask print = __ISPRINT; | 428 | static const mask print = __ISPRINT; |
| ... | @@ -432,11 +434,11 @@ public: | ... | @@ -432,11 +434,11 @@ public: |
| 432 | static const mask punct = __ISPUNCT; | 434 | static const mask punct = __ISPUNCT; |
| 433 | static const mask xdigit = __ISXDIGIT; | 435 | static const mask xdigit = __ISXDIGIT; |
| 434 | static const mask blank = __ISBLANK; | 436 | static const mask blank = __ISBLANK; |
| 435 | # endif | 437 | # endif |
| 436 | static const mask __regex_word = 0x8000; | 438 | static const mask __regex_word = 0x8000; |
| 437 | #else | 439 | # else |
| 438 | # error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE? | 440 | # error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE? |
| 439 | #endif | 441 | # endif |
| 440 | static const mask alnum = alpha | digit; | 442 | static const mask alnum = alpha | digit; |
| 441 | static const mask graph = alnum | punct; | 443 | static const mask graph = alnum | punct; |
| 442 | 444 | ||
| ... | @@ -448,9 +450,9 @@ public: | ... | @@ -448,9 +450,9 @@ public: |
| 448 | }; | 450 | }; |
| 449 | 451 | ||
| 450 | template <class _CharT> | 452 | template <class _CharT> |
| 451 | class _LIBCPP_TEMPLATE_VIS ctype; | 453 | class ctype; |
| 452 | 454 | ||
| 453 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 455 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 454 | template <> | 456 | template <> |
| 455 | class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base { | 457 | class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base { |
| 456 | public: | 458 | public: |
| ... | @@ -515,7 +517,7 @@ protected: | ... | @@ -515,7 +517,7 @@ protected: |
| 515 | virtual const char_type* | 517 | virtual const char_type* |
| 516 | do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; | 518 | do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; |
| 517 | }; | 519 | }; |
| 518 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 520 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 519 | 521 | ||
| 520 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_isascii(int __c) { return (__c & ~0x7F) == 0; } | 522 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_isascii(int __c) { return (__c & ~0x7F) == 0; } |
| 521 | 523 | ||
| ... | @@ -580,25 +582,13 @@ public: | ... | @@ -580,25 +582,13 @@ public: |
| 580 | 582 | ||
| 581 | static locale::id id; | 583 | static locale::id id; |
| 582 | 584 | ||
| 583 | #ifdef _CACHED_RUNES | 585 | # ifdef _CACHED_RUNES |
| 584 | static const size_t table_size = _CACHED_RUNES; | 586 | static const size_t table_size = _CACHED_RUNES; |
| 585 | #else | 587 | # else |
| 586 | static const size_t table_size = 256; // FIXME: Don't hardcode this. | 588 | static const size_t table_size = 256; // FIXME: Don't hardcode this. |
| 587 | #endif | 589 | # endif |
| 588 | _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; } | 590 | _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; } |
| 589 | static const mask* classic_table() _NOEXCEPT; | 591 | static const mask* classic_table() _NOEXCEPT; |
| 590 | #if defined(__GLIBC__) || defined(__EMSCRIPTEN__) | ||
| 591 | static const int* __classic_upper_table() _NOEXCEPT; | ||
| 592 | static const int* __classic_lower_table() _NOEXCEPT; | ||
| 593 | #endif | ||
| 594 | #if defined(__NetBSD__) | ||
| 595 | static const short* __classic_upper_table() _NOEXCEPT; | ||
| 596 | static const short* __classic_lower_table() _NOEXCEPT; | ||
| 597 | #endif | ||
| 598 | #if defined(__MVS__) | ||
| 599 | static const unsigned short* __classic_upper_table() _NOEXCEPT; | ||
| 600 | static const unsigned short* __classic_lower_table() _NOEXCEPT; | ||
| 601 | #endif | ||
| 602 | 592 | ||
| 603 | protected: | 593 | protected: |
| 604 | ~ctype() override; | 594 | ~ctype() override; |
| ... | @@ -615,7 +605,7 @@ protected: | ... | @@ -615,7 +605,7 @@ protected: |
| 615 | // template <class CharT> class ctype_byname; | 605 | // template <class CharT> class ctype_byname; |
| 616 | 606 | ||
| 617 | template <class _CharT> | 607 | template <class _CharT> |
| 618 | class _LIBCPP_TEMPLATE_VIS ctype_byname; | 608 | class ctype_byname; |
| 619 | 609 | ||
| 620 | template <> | 610 | template <> |
| 621 | class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> { | 611 | class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> { |
| ... | @@ -633,7 +623,7 @@ protected: | ... | @@ -633,7 +623,7 @@ protected: |
| 633 | const char_type* do_tolower(char_type* __low, const char_type* __high) const override; | 623 | const char_type* do_tolower(char_type* __low, const char_type* __high) const override; |
| 634 | }; | 624 | }; |
| 635 | 625 | ||
| 636 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 626 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 637 | template <> | 627 | template <> |
| 638 | class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> { | 628 | class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> { |
| 639 | __locale::__locale_t __l_; | 629 | __locale::__locale_t __l_; |
| ... | @@ -658,7 +648,7 @@ protected: | ... | @@ -658,7 +648,7 @@ protected: |
| 658 | const char_type* | 648 | const char_type* |
| 659 | do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override; | 649 | do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override; |
| 660 | }; | 650 | }; |
| 661 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 651 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 662 | 652 | ||
| 663 | template <class _CharT> | 653 | template <class _CharT> |
| 664 | inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) { | 654 | inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) { |
| ... | @@ -741,7 +731,7 @@ public: | ... | @@ -741,7 +731,7 @@ public: |
| 741 | // template <class internT, class externT, class stateT> class codecvt; | 731 | // template <class internT, class externT, class stateT> class codecvt; |
| 742 | 732 | ||
| 743 | template <class _InternT, class _ExternT, class _StateT> | 733 | template <class _InternT, class _ExternT, class _StateT> |
| 744 | class _LIBCPP_TEMPLATE_VIS codecvt; | 734 | class codecvt; |
| 745 | 735 | ||
| 746 | // template <> class codecvt<char, char, mbstate_t> | 736 | // template <> class codecvt<char, char, mbstate_t> |
| 747 | 737 | ||
| ... | @@ -824,7 +814,7 @@ protected: | ... | @@ -824,7 +814,7 @@ protected: |
| 824 | 814 | ||
| 825 | // template <> class codecvt<wchar_t, char, mbstate_t> | 815 | // template <> class codecvt<wchar_t, char, mbstate_t> |
| 826 | 816 | ||
| 827 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 817 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 828 | template <> | 818 | template <> |
| 829 | class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base { | 819 | class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base { |
| 830 | __locale::__locale_t __l_; | 820 | __locale::__locale_t __l_; |
| ... | @@ -903,7 +893,7 @@ protected: | ... | @@ -903,7 +893,7 @@ protected: |
| 903 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; | 893 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; |
| 904 | virtual int do_max_length() const _NOEXCEPT; | 894 | virtual int do_max_length() const _NOEXCEPT; |
| 905 | }; | 895 | }; |
| 906 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 896 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 907 | 897 | ||
| 908 | // template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20 | 898 | // template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20 |
| 909 | 899 | ||
| ... | @@ -985,7 +975,7 @@ protected: | ... | @@ -985,7 +975,7 @@ protected: |
| 985 | virtual int do_max_length() const _NOEXCEPT; | 975 | virtual int do_max_length() const _NOEXCEPT; |
| 986 | }; | 976 | }; |
| 987 | 977 | ||
| 988 | #if _LIBCPP_HAS_CHAR8_T | 978 | # if _LIBCPP_HAS_CHAR8_T |
| 989 | 979 | ||
| 990 | // template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20 | 980 | // template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20 |
| 991 | 981 | ||
| ... | @@ -1066,7 +1056,7 @@ protected: | ... | @@ -1066,7 +1056,7 @@ protected: |
| 1066 | virtual int do_max_length() const _NOEXCEPT; | 1056 | virtual int do_max_length() const _NOEXCEPT; |
| 1067 | }; | 1057 | }; |
| 1068 | 1058 | ||
| 1069 | #endif | 1059 | # endif |
| 1070 | 1060 | ||
| 1071 | // template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20 | 1061 | // template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20 |
| 1072 | 1062 | ||
| ... | @@ -1148,7 +1138,7 @@ protected: | ... | @@ -1148,7 +1138,7 @@ protected: |
| 1148 | virtual int do_max_length() const _NOEXCEPT; | 1138 | virtual int do_max_length() const _NOEXCEPT; |
| 1149 | }; | 1139 | }; |
| 1150 | 1140 | ||
| 1151 | #if _LIBCPP_HAS_CHAR8_T | 1141 | # if _LIBCPP_HAS_CHAR8_T |
| 1152 | 1142 | ||
| 1153 | // template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20 | 1143 | // template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20 |
| 1154 | 1144 | ||
| ... | @@ -1229,12 +1219,12 @@ protected: | ... | @@ -1229,12 +1219,12 @@ protected: |
| 1229 | virtual int do_max_length() const _NOEXCEPT; | 1219 | virtual int do_max_length() const _NOEXCEPT; |
| 1230 | }; | 1220 | }; |
| 1231 | 1221 | ||
| 1232 | #endif | 1222 | # endif |
| 1233 | 1223 | ||
| 1234 | // template <class _InternT, class _ExternT, class _StateT> class codecvt_byname | 1224 | // template <class _InternT, class _ExternT, class _StateT> class codecvt_byname |
| 1235 | 1225 | ||
| 1236 | template <class _InternT, class _ExternT, class _StateT> | 1226 | template <class _InternT, class _ExternT, class _StateT> |
| 1237 | class _LIBCPP_TEMPLATE_VIS codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> { | 1227 | class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> { |
| 1238 | public: | 1228 | public: |
| 1239 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_byname(const char* __nm, size_t __refs = 0) | 1229 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_byname(const char* __nm, size_t __refs = 0) |
| 1240 | : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {} | 1230 | : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {} |
| ... | @@ -1251,17 +1241,17 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {} | ... | @@ -1251,17 +1241,17 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {} |
| 1251 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 1241 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 1252 | 1242 | ||
| 1253 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>; | 1243 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>; |
| 1254 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 1244 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1255 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; | 1245 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; |
| 1256 | #endif | 1246 | # endif |
| 1257 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 | 1247 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 |
| 1258 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 | 1248 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 |
| 1259 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 | 1249 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 |
| 1260 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 | 1250 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 |
| 1261 | #if _LIBCPP_HAS_CHAR8_T | 1251 | # if _LIBCPP_HAS_CHAR8_T |
| 1262 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 | 1252 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 |
| 1263 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 | 1253 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 |
| 1264 | #endif | 1254 | # endif |
| 1265 | 1255 | ||
| 1266 | template <size_t _Np> | 1256 | template <size_t _Np> |
| 1267 | struct __narrow_to_utf8 { | 1257 | struct __narrow_to_utf8 { |
| ... | @@ -1298,7 +1288,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> : public codecvt<char16_t, | ... | @@ -1298,7 +1288,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> : public codecvt<char16_t, |
| 1298 | const char16_t* __wn = (const char16_t*)__wb; | 1288 | const char16_t* __wn = (const char16_t*)__wb; |
| 1299 | __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, __buf, __buf + __sz, __bn); | 1289 | __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, __buf, __buf + __sz, __bn); |
| 1300 | if (__r == codecvt_base::error || __wn == (const char16_t*)__wb) | 1290 | if (__r == codecvt_base::error || __wn == (const char16_t*)__wb) |
| 1301 | __throw_runtime_error("locale not supported"); | 1291 | std::__throw_runtime_error("locale not supported"); |
| 1302 | for (const char* __p = __buf; __p < __bn; ++__p, ++__s) | 1292 | for (const char* __p = __buf; __p < __bn; ++__p, ++__s) |
| 1303 | *__s = *__p; | 1293 | *__s = *__p; |
| 1304 | __wb = (const _CharT*)__wn; | 1294 | __wb = (const _CharT*)__wn; |
| ... | @@ -1326,7 +1316,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> : public codecvt<char32_t, | ... | @@ -1326,7 +1316,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> : public codecvt<char32_t, |
| 1326 | const char32_t* __wn = (const char32_t*)__wb; | 1316 | const char32_t* __wn = (const char32_t*)__wb; |
| 1327 | __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, __buf, __buf + __sz, __bn); | 1317 | __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, __buf, __buf + __sz, __bn); |
| 1328 | if (__r == codecvt_base::error || __wn == (const char32_t*)__wb) | 1318 | if (__r == codecvt_base::error || __wn == (const char32_t*)__wb) |
| 1329 | __throw_runtime_error("locale not supported"); | 1319 | std::__throw_runtime_error("locale not supported"); |
| 1330 | for (const char* __p = __buf; __p < __bn; ++__p, ++__s) | 1320 | for (const char* __p = __buf; __p < __bn; ++__p, ++__s) |
| 1331 | *__s = *__p; | 1321 | *__s = *__p; |
| 1332 | __wb = (const _CharT*)__wn; | 1322 | __wb = (const _CharT*)__wn; |
| ... | @@ -1370,7 +1360,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> : public codecvt<char16_t | ... | @@ -1370,7 +1360,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> : public codecvt<char16_t |
| 1370 | const char* __nn = __nb; | 1360 | const char* __nn = __nb; |
| 1371 | __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn); | 1361 | __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn); |
| 1372 | if (__r == codecvt_base::error || __nn == __nb) | 1362 | if (__r == codecvt_base::error || __nn == __nb) |
| 1373 | __throw_runtime_error("locale not supported"); | 1363 | std::__throw_runtime_error("locale not supported"); |
| 1374 | for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s) | 1364 | for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s) |
| 1375 | *__s = *__p; | 1365 | *__s = *__p; |
| 1376 | __nb = __nn; | 1366 | __nb = __nn; |
| ... | @@ -1398,7 +1388,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t | ... | @@ -1398,7 +1388,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t |
| 1398 | const char* __nn = __nb; | 1388 | const char* __nn = __nb; |
| 1399 | __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn); | 1389 | __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn); |
| 1400 | if (__r == codecvt_base::error || __nn == __nb) | 1390 | if (__r == codecvt_base::error || __nn == __nb) |
| 1401 | __throw_runtime_error("locale not supported"); | 1391 | std::__throw_runtime_error("locale not supported"); |
| 1402 | for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s) | 1392 | for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s) |
| 1403 | *__s = *__p; | 1393 | *__s = *__p; |
| 1404 | __nb = __nn; | 1394 | __nb = __nn; |
| ... | @@ -1410,7 +1400,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t | ... | @@ -1410,7 +1400,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t |
| 1410 | // template <class charT> class numpunct | 1400 | // template <class charT> class numpunct |
| 1411 | 1401 | ||
| 1412 | template <class _CharT> | 1402 | template <class _CharT> |
| 1413 | class _LIBCPP_TEMPLATE_VIS numpunct; | 1403 | class numpunct; |
| 1414 | 1404 | ||
| 1415 | template <> | 1405 | template <> |
| 1416 | class _LIBCPP_EXPORTED_FROM_ABI numpunct<char> : public locale::facet { | 1406 | class _LIBCPP_EXPORTED_FROM_ABI numpunct<char> : public locale::facet { |
| ... | @@ -1441,7 +1431,7 @@ protected: | ... | @@ -1441,7 +1431,7 @@ protected: |
| 1441 | string __grouping_; | 1431 | string __grouping_; |
| 1442 | }; | 1432 | }; |
| 1443 | 1433 | ||
| 1444 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 1434 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1445 | template <> | 1435 | template <> |
| 1446 | class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet { | 1436 | class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet { |
| 1447 | public: | 1437 | public: |
| ... | @@ -1470,12 +1460,12 @@ protected: | ... | @@ -1470,12 +1460,12 @@ protected: |
| 1470 | char_type __thousands_sep_; | 1460 | char_type __thousands_sep_; |
| 1471 | string __grouping_; | 1461 | string __grouping_; |
| 1472 | }; | 1462 | }; |
| 1473 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 1463 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 1474 | 1464 | ||
| 1475 | // template <class charT> class numpunct_byname | 1465 | // template <class charT> class numpunct_byname |
| 1476 | 1466 | ||
| 1477 | template <class _CharT> | 1467 | template <class _CharT> |
| 1478 | class _LIBCPP_TEMPLATE_VIS numpunct_byname; | 1468 | class numpunct_byname; |
| 1479 | 1469 | ||
| 1480 | template <> | 1470 | template <> |
| 1481 | class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> : public numpunct<char> { | 1471 | class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> : public numpunct<char> { |
| ... | @@ -1493,7 +1483,7 @@ private: | ... | @@ -1493,7 +1483,7 @@ private: |
| 1493 | void __init(const char*); | 1483 | void __init(const char*); |
| 1494 | }; | 1484 | }; |
| 1495 | 1485 | ||
| 1496 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 1486 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1497 | template <> | 1487 | template <> |
| 1498 | class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> { | 1488 | class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> { |
| 1499 | public: | 1489 | public: |
| ... | @@ -1509,8 +1499,10 @@ protected: | ... | @@ -1509,8 +1499,10 @@ protected: |
| 1509 | private: | 1499 | private: |
| 1510 | void __init(const char*); | 1500 | void __init(const char*); |
| 1511 | }; | 1501 | }; |
| 1512 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 1502 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 1513 | 1503 | ||
| 1514 | _LIBCPP_END_NAMESPACE_STD | 1504 | _LIBCPP_END_NAMESPACE_STD |
| 1515 | 1505 | ||
| 1506 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 1507 | |||
| 1516 | #endif // _LIBCPP___LOCALE | 1508 | #endif // _LIBCPP___LOCALE |
lib/libcxx/include/__locale_dir/check_grouping.h created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_CHECK_GROUPING_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_CHECK_GROUPING_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__fwd/string.h> | ||
| 14 | #include <ios> | ||
| 15 | |||
| 16 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 17 | |||
| 18 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | # endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | _LIBCPP_EXPORTED_FROM_ABI void | ||
| 25 | __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err); | ||
| 26 | |||
| 27 | _LIBCPP_END_NAMESPACE_STD | ||
| 28 | |||
| 29 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 30 | |||
| 31 | #endif // _LIBCPP___LOCALE_DIR_CHECK_GROUPING_H | ||
lib/libcxx/include/__locale_dir/get_c_locale.h created+40| ... | @@ -0,0 +1,40 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_GET_C_LOCALE_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_GET_C_LOCALE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__locale_dir/locale_base_api.h> | ||
| 14 | |||
| 15 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 16 | |||
| 17 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | # endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | // FIXME: This should really be part of the locale base API | ||
| 24 | |||
| 25 | # if defined(__APPLE__) || defined(__FreeBSD__) | ||
| 26 | # define _LIBCPP_GET_C_LOCALE 0 | ||
| 27 | # elif defined(__NetBSD__) | ||
| 28 | # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE | ||
| 29 | # else | ||
| 30 | # define _LIBCPP_GET_C_LOCALE __cloc() | ||
| 31 | // Get the C locale object | ||
| 32 | _LIBCPP_EXPORTED_FROM_ABI __locale::__locale_t __cloc(); | ||
| 33 | # define __cloc_defined | ||
| 34 | # endif | ||
| 35 | |||
| 36 | _LIBCPP_END_NAMESPACE_STD | ||
| 37 | |||
| 38 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 39 | |||
| 40 | #endif // _LIBCPP___LOCALE_DIR_GET_C_LOCALE_H | ||
lib/libcxx/include/__locale_dir/locale_base_api.h+59-59| ... | @@ -64,8 +64,6 @@ | ... | @@ -64,8 +64,6 @@ |
| 64 | // Character manipulation functions | 64 | // Character manipulation functions |
| 65 | // -------------------------------- | 65 | // -------------------------------- |
| 66 | // namespace __locale { | 66 | // namespace __locale { |
| 67 | // int __islower(int, __locale_t); | ||
| 68 | // int __isupper(int, __locale_t); | ||
| 69 | // int __isdigit(int, __locale_t); // required by the headers | 67 | // int __isdigit(int, __locale_t); // required by the headers |
| 70 | // int __isxdigit(int, __locale_t); // required by the headers | 68 | // int __isxdigit(int, __locale_t); // required by the headers |
| 71 | // int __toupper(int, __locale_t); | 69 | // int __toupper(int, __locale_t); |
| ... | @@ -111,59 +109,64 @@ | ... | @@ -111,59 +109,64 @@ |
| 111 | // int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers | 109 | // int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers |
| 112 | // } | 110 | // } |
| 113 | 111 | ||
| 114 | #if defined(__APPLE__) | 112 | #if _LIBCPP_HAS_LOCALIZATION |
| 115 | # include <__locale_dir/support/apple.h> | 113 | |
| 116 | #elif defined(__FreeBSD__) | 114 | # if defined(__APPLE__) |
| 117 | # include <__locale_dir/support/freebsd.h> | 115 | # include <__locale_dir/support/apple.h> |
| 118 | #elif defined(__NetBSD__) | 116 | # elif defined(__FreeBSD__) |
| 119 | # include <__locale_dir/support/netbsd.h> | 117 | # include <__locale_dir/support/freebsd.h> |
| 120 | #elif defined(_LIBCPP_MSVCRT_LIKE) | 118 | /* zig patch: https://github.com/llvm/llvm-project/pull/143055 */ |
| 121 | # include <__locale_dir/support/windows.h> | 119 | # elif defined(__NetBSD__) |
| 122 | #elif defined(__Fuchsia__) | 120 | # include <__locale_dir/support/netbsd.h> |
| 123 | # include <__locale_dir/support/fuchsia.h> | 121 | # elif defined(_LIBCPP_MSVCRT_LIKE) |
| 124 | #else | 122 | # include <__locale_dir/support/windows.h> |
| 123 | # elif defined(__Fuchsia__) | ||
| 124 | # include <__locale_dir/support/fuchsia.h> | ||
| 125 | # elif defined(__linux__) | ||
| 126 | # include <__locale_dir/support/linux.h> | ||
| 127 | # else | ||
| 125 | 128 | ||
| 126 | // TODO: This is a temporary definition to bridge between the old way we defined the locale base API | 129 | // TODO: This is a temporary definition to bridge between the old way we defined the locale base API |
| 127 | // (by providing global non-reserved names) and the new API. As we move individual platforms | 130 | // (by providing global non-reserved names) and the new API. As we move individual platforms |
| 128 | // towards the new way of defining the locale base API, this should disappear since each platform | 131 | // towards the new way of defining the locale base API, this should disappear since each platform |
| 129 | // will define those directly. | 132 | // will define those directly. |
| 130 | # if defined(_AIX) || defined(__MVS__) | 133 | # if defined(_AIX) || defined(__MVS__) |
| 131 | # include <__locale_dir/locale_base_api/ibm.h> | 134 | # include <__locale_dir/locale_base_api/ibm.h> |
| 132 | # elif defined(__ANDROID__) | 135 | # elif defined(__ANDROID__) |
| 133 | # include <__locale_dir/locale_base_api/android.h> | 136 | # include <__locale_dir/locale_base_api/android.h> |
| 134 | # elif defined(__OpenBSD__) | 137 | # elif defined(__OpenBSD__) |
| 135 | # include <__locale_dir/locale_base_api/openbsd.h> | 138 | # include <__locale_dir/locale_base_api/openbsd.h> |
| 136 | # elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC | 139 | # elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC |
| 137 | # include <__locale_dir/locale_base_api/musl.h> | 140 | # include <__locale_dir/locale_base_api/musl.h> |
| 138 | # endif | 141 | # endif |
| 139 | 142 | ||
| 140 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> | 143 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> |
| 141 | 144 | ||
| 142 | # include <__cstddef/size_t.h> | 145 | # include <__cstddef/size_t.h> |
| 143 | # include <__utility/forward.h> | 146 | # include <__utility/forward.h> |
| 144 | # include <ctype.h> | 147 | # include <ctype.h> |
| 145 | # include <string.h> | 148 | # include <string.h> |
| 146 | # include <time.h> | 149 | # include <time.h> |
| 147 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 150 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 148 | # include <wctype.h> | 151 | # include <wctype.h> |
| 149 | # endif | 152 | # endif |
| 150 | _LIBCPP_BEGIN_NAMESPACE_STD | 153 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 151 | namespace __locale { | 154 | namespace __locale { |
| 152 | // | 155 | // |
| 153 | // Locale management | 156 | // Locale management |
| 154 | // | 157 | // |
| 155 | # define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK | 158 | # define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK |
| 156 | # define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK | 159 | # define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK |
| 157 | # define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK | 160 | # define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK |
| 158 | # define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK | 161 | # define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK |
| 159 | # define _LIBCPP_TIME_MASK LC_TIME_MASK | 162 | # define _LIBCPP_TIME_MASK LC_TIME_MASK |
| 160 | # define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK | 163 | # define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK |
| 161 | # define _LIBCPP_ALL_MASK LC_ALL_MASK | 164 | # define _LIBCPP_ALL_MASK LC_ALL_MASK |
| 162 | # define _LIBCPP_LC_ALL LC_ALL | 165 | # define _LIBCPP_LC_ALL LC_ALL |
| 163 | 166 | ||
| 164 | using __locale_t _LIBCPP_NODEBUG = locale_t; | 167 | using __locale_t _LIBCPP_NODEBUG = locale_t; |
| 165 | 168 | ||
| 166 | # if defined(_LIBCPP_BUILDING_LIBRARY) | 169 | # if defined(_LIBCPP_BUILDING_LIBRARY) |
| 167 | using __lconv_t _LIBCPP_NODEBUG = lconv; | 170 | using __lconv_t _LIBCPP_NODEBUG = lconv; |
| 168 | 171 | ||
| 169 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) { | 172 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) { |
| ... | @@ -177,7 +180,7 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __loc | ... | @@ -177,7 +180,7 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __loc |
| 177 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { freelocale(__loc); } | 180 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { freelocale(__loc); } |
| 178 | 181 | ||
| 179 | inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return __libcpp_localeconv_l(__loc); } | 182 | inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return __libcpp_localeconv_l(__loc); } |
| 180 | # endif // _LIBCPP_BUILDING_LIBRARY | 183 | # endif // _LIBCPP_BUILDING_LIBRARY |
| 181 | 184 | ||
| 182 | // | 185 | // |
| 183 | // Strtonum functions | 186 | // Strtonum functions |
| ... | @@ -206,15 +209,10 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ... | @@ -206,15 +209,10 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { |
| 206 | // | 209 | // |
| 207 | // Character manipulation functions | 210 | // Character manipulation functions |
| 208 | // | 211 | // |
| 209 | # if defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 210 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __ch, __locale_t __loc) { return islower_l(__ch, __loc); } | ||
| 211 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __ch, __locale_t __loc) { return isupper_l(__ch, __loc); } | ||
| 212 | # endif | ||
| 213 | |||
| 214 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); } | 212 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); } |
| 215 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); } | 213 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); } |
| 216 | 214 | ||
| 217 | # if defined(_LIBCPP_BUILDING_LIBRARY) | 215 | # if defined(_LIBCPP_BUILDING_LIBRARY) |
| 218 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { | 216 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { |
| 219 | return strcoll_l(__s1, __s2, __loc); | 217 | return strcoll_l(__s1, __s2, __loc); |
| 220 | } | 218 | } |
| ... | @@ -224,7 +222,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s | ... | @@ -224,7 +222,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s |
| 224 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __ch, __locale_t __loc) { return toupper_l(__ch, __loc); } | 222 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __ch, __locale_t __loc) { return toupper_l(__ch, __loc); } |
| 225 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __ch, __locale_t __loc) { return tolower_l(__ch, __loc); } | 223 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __ch, __locale_t __loc) { return tolower_l(__ch, __loc); } |
| 226 | 224 | ||
| 227 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 225 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 228 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* __s2, __locale_t __loc) { | 226 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* __s2, __locale_t __loc) { |
| 229 | return wcscoll_l(__s1, __s2, __loc); | 227 | return wcscoll_l(__s1, __s2, __loc); |
| 230 | } | 228 | } |
| ... | @@ -246,7 +244,7 @@ inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { ret | ... | @@ -246,7 +244,7 @@ inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { ret |
| 246 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __ch, __locale_t __loc) { return iswxdigit_l(__ch, __loc); } | 244 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __ch, __locale_t __loc) { return iswxdigit_l(__ch, __loc); } |
| 247 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) { return towupper_l(__ch, __loc); } | 245 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) { return towupper_l(__ch, __loc); } |
| 248 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); } | 246 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); } |
| 249 | # endif | 247 | # endif |
| 250 | 248 | ||
| 251 | inline _LIBCPP_HIDE_FROM_ABI size_t | 249 | inline _LIBCPP_HIDE_FROM_ABI size_t |
| 252 | __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) { | 250 | __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) { |
| ... | @@ -259,7 +257,7 @@ __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __loca | ... | @@ -259,7 +257,7 @@ __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __loca |
| 259 | inline _LIBCPP_HIDE_FROM_ABI decltype(__libcpp_mb_cur_max_l(__locale_t())) __mb_len_max(__locale_t __loc) { | 257 | inline _LIBCPP_HIDE_FROM_ABI decltype(__libcpp_mb_cur_max_l(__locale_t())) __mb_len_max(__locale_t __loc) { |
| 260 | return __libcpp_mb_cur_max_l(__loc); | 258 | return __libcpp_mb_cur_max_l(__loc); |
| 261 | } | 259 | } |
| 262 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 260 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 263 | inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { return __libcpp_btowc_l(__ch, __loc); } | 261 | inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { return __libcpp_btowc_l(__ch, __loc); } |
| 264 | inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l(__ch, __loc); } | 262 | inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l(__ch, __loc); } |
| 265 | inline _LIBCPP_HIDE_FROM_ABI size_t | 263 | inline _LIBCPP_HIDE_FROM_ABI size_t |
| ... | @@ -287,17 +285,17 @@ inline _LIBCPP_HIDE_FROM_ABI size_t | ... | @@ -287,17 +285,17 @@ inline _LIBCPP_HIDE_FROM_ABI size_t |
| 287 | __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) { | 285 | __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) { |
| 288 | return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc); | 286 | return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc); |
| 289 | } | 287 | } |
| 290 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 288 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 291 | # endif // _LIBCPP_BUILDING_LIBRARY | 289 | # endif // _LIBCPP_BUILDING_LIBRARY |
| 292 | 290 | ||
| 293 | _LIBCPP_DIAGNOSTIC_PUSH | 291 | _LIBCPP_DIAGNOSTIC_PUSH |
| 294 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat") | 292 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat") |
| 295 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates | 293 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates |
| 296 | # ifdef _LIBCPP_COMPILER_CLANG_BASED | 294 | # ifdef _LIBCPP_COMPILER_CLANG_BASED |
| 297 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__) | 295 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__) |
| 298 | # else | 296 | # else |
| 299 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */ | 297 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */ |
| 300 | # endif | 298 | # endif |
| 301 | 299 | ||
| 302 | template <class... _Args> | 300 | template <class... _Args> |
| 303 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( | 301 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( |
| ... | @@ -315,11 +313,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __s | ... | @@ -315,11 +313,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __s |
| 315 | return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); | 313 | return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); |
| 316 | } | 314 | } |
| 317 | _LIBCPP_DIAGNOSTIC_POP | 315 | _LIBCPP_DIAGNOSTIC_POP |
| 318 | # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | 316 | # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT |
| 319 | 317 | ||
| 320 | } // namespace __locale | 318 | } // namespace __locale |
| 321 | _LIBCPP_END_NAMESPACE_STD | 319 | _LIBCPP_END_NAMESPACE_STD |
| 322 | 320 | ||
| 323 | #endif // Compatibility definition of locale base APIs | 321 | # endif // Compatibility definition of locale base APIs |
| 322 | |||
| 323 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 324 | 324 | ||
| 325 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H | 325 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H |
lib/libcxx/include/__locale_dir/messages.h created+143| ... | @@ -0,0 +1,143 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_MESSAGES_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_MESSAGES_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__iterator/back_insert_iterator.h> | ||
| 14 | #include <__locale> | ||
| 15 | #include <string> | ||
| 16 | |||
| 17 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 18 | |||
| 19 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | # endif | ||
| 22 | |||
| 23 | # if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) | ||
| 24 | // Most unix variants have catopen. These are the specific ones that don't. | ||
| 25 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) | ||
| 26 | # define _LIBCPP_HAS_CATOPEN 1 | ||
| 27 | # include <nl_types.h> | ||
| 28 | # else | ||
| 29 | # define _LIBCPP_HAS_CATOPEN 0 | ||
| 30 | # endif | ||
| 31 | # else | ||
| 32 | # define _LIBCPP_HAS_CATOPEN 0 | ||
| 33 | # endif | ||
| 34 | |||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 36 | |||
| 37 | class _LIBCPP_EXPORTED_FROM_ABI messages_base { | ||
| 38 | public: | ||
| 39 | typedef intptr_t catalog; | ||
| 40 | |||
| 41 | _LIBCPP_HIDE_FROM_ABI messages_base() {} | ||
| 42 | }; | ||
| 43 | |||
| 44 | template <class _CharT> | ||
| 45 | class messages : public locale::facet, public messages_base { | ||
| 46 | public: | ||
| 47 | typedef _CharT char_type; | ||
| 48 | typedef basic_string<_CharT> string_type; | ||
| 49 | |||
| 50 | _LIBCPP_HIDE_FROM_ABI explicit messages(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 51 | |||
| 52 | _LIBCPP_HIDE_FROM_ABI catalog open(const basic_string<char>& __nm, const locale& __loc) const { | ||
| 53 | return do_open(__nm, __loc); | ||
| 54 | } | ||
| 55 | |||
| 56 | _LIBCPP_HIDE_FROM_ABI string_type get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { | ||
| 57 | return do_get(__c, __set, __msgid, __dflt); | ||
| 58 | } | ||
| 59 | |||
| 60 | _LIBCPP_HIDE_FROM_ABI void close(catalog __c) const { do_close(__c); } | ||
| 61 | |||
| 62 | static locale::id id; | ||
| 63 | |||
| 64 | protected: | ||
| 65 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages() override {} | ||
| 66 | |||
| 67 | virtual catalog do_open(const basic_string<char>&, const locale&) const; | ||
| 68 | virtual string_type do_get(catalog, int __set, int __msgid, const string_type& __dflt) const; | ||
| 69 | virtual void do_close(catalog) const; | ||
| 70 | }; | ||
| 71 | |||
| 72 | template <class _CharT> | ||
| 73 | locale::id messages<_CharT>::id; | ||
| 74 | |||
| 75 | template <class _CharT> | ||
| 76 | typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const { | ||
| 77 | # if _LIBCPP_HAS_CATOPEN | ||
| 78 | return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); | ||
| 79 | # else // !_LIBCPP_HAS_CATOPEN | ||
| 80 | (void)__nm; | ||
| 81 | return -1; | ||
| 82 | # endif // _LIBCPP_HAS_CATOPEN | ||
| 83 | } | ||
| 84 | |||
| 85 | template <class _CharT> | ||
| 86 | typename messages<_CharT>::string_type | ||
| 87 | messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { | ||
| 88 | # if _LIBCPP_HAS_CATOPEN | ||
| 89 | string __ndflt; | ||
| 90 | __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()( | ||
| 91 | std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); | ||
| 92 | nl_catd __cat = (nl_catd)__c; | ||
| 93 | static_assert(sizeof(catalog) >= sizeof(nl_catd), "Unexpected nl_catd type"); | ||
| 94 | char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str()); | ||
| 95 | string_type __w; | ||
| 96 | __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n)); | ||
| 97 | return __w; | ||
| 98 | # else // !_LIBCPP_HAS_CATOPEN | ||
| 99 | (void)__c; | ||
| 100 | (void)__set; | ||
| 101 | (void)__msgid; | ||
| 102 | return __dflt; | ||
| 103 | # endif // _LIBCPP_HAS_CATOPEN | ||
| 104 | } | ||
| 105 | |||
| 106 | template <class _CharT> | ||
| 107 | void messages<_CharT>::do_close(catalog __c) const { | ||
| 108 | # if _LIBCPP_HAS_CATOPEN | ||
| 109 | catclose((nl_catd)__c); | ||
| 110 | # else // !_LIBCPP_HAS_CATOPEN | ||
| 111 | (void)__c; | ||
| 112 | # endif // _LIBCPP_HAS_CATOPEN | ||
| 113 | } | ||
| 114 | |||
| 115 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>; | ||
| 116 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 117 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>; | ||
| 118 | # endif | ||
| 119 | |||
| 120 | template <class _CharT> | ||
| 121 | class messages_byname : public messages<_CharT> { | ||
| 122 | public: | ||
| 123 | typedef messages_base::catalog catalog; | ||
| 124 | typedef basic_string<_CharT> string_type; | ||
| 125 | |||
| 126 | _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const char*, size_t __refs = 0) : messages<_CharT>(__refs) {} | ||
| 127 | |||
| 128 | _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const string&, size_t __refs = 0) : messages<_CharT>(__refs) {} | ||
| 129 | |||
| 130 | protected: | ||
| 131 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages_byname() override {} | ||
| 132 | }; | ||
| 133 | |||
| 134 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>; | ||
| 135 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 136 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; | ||
| 137 | # endif | ||
| 138 | |||
| 139 | _LIBCPP_END_NAMESPACE_STD | ||
| 140 | |||
| 141 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 142 | |||
| 143 | #endif // _LIBCPP___LOCALE_DIR_MESSAGES_H | ||
lib/libcxx/include/__locale_dir/money.h created+873| ... | @@ -0,0 +1,873 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_MONEY_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_MONEY_H | ||
| 11 | |||
| 12 | #include <__algorithm/copy.h> | ||
| 13 | #include <__algorithm/equal.h> | ||
| 14 | #include <__algorithm/find.h> | ||
| 15 | #include <__algorithm/reverse.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__locale> | ||
| 18 | #include <__locale_dir/check_grouping.h> | ||
| 19 | #include <__locale_dir/get_c_locale.h> | ||
| 20 | #include <__locale_dir/pad_and_output.h> | ||
| 21 | #include <__memory/unique_ptr.h> | ||
| 22 | #include <ios> | ||
| 23 | #include <string> | ||
| 24 | |||
| 25 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 26 | |||
| 27 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 28 | # pragma GCC system_header | ||
| 29 | # endif | ||
| 30 | |||
| 31 | _LIBCPP_PUSH_MACROS | ||
| 32 | # include <__undef_macros> | ||
| 33 | |||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 35 | |||
| 36 | // money_base | ||
| 37 | |||
| 38 | class _LIBCPP_EXPORTED_FROM_ABI money_base { | ||
| 39 | public: | ||
| 40 | enum part { none, space, symbol, sign, value }; | ||
| 41 | struct pattern { | ||
| 42 | char field[4]; | ||
| 43 | }; | ||
| 44 | |||
| 45 | _LIBCPP_HIDE_FROM_ABI money_base() {} | ||
| 46 | }; | ||
| 47 | |||
| 48 | // moneypunct | ||
| 49 | |||
| 50 | template <class _CharT, bool _International = false> | ||
| 51 | class moneypunct : public locale::facet, public money_base { | ||
| 52 | public: | ||
| 53 | typedef _CharT char_type; | ||
| 54 | typedef basic_string<char_type> string_type; | ||
| 55 | |||
| 56 | _LIBCPP_HIDE_FROM_ABI explicit moneypunct(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 57 | |||
| 58 | _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); } | ||
| 59 | _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); } | ||
| 60 | _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); } | ||
| 61 | _LIBCPP_HIDE_FROM_ABI string_type curr_symbol() const { return do_curr_symbol(); } | ||
| 62 | _LIBCPP_HIDE_FROM_ABI string_type positive_sign() const { return do_positive_sign(); } | ||
| 63 | _LIBCPP_HIDE_FROM_ABI string_type negative_sign() const { return do_negative_sign(); } | ||
| 64 | _LIBCPP_HIDE_FROM_ABI int frac_digits() const { return do_frac_digits(); } | ||
| 65 | _LIBCPP_HIDE_FROM_ABI pattern pos_format() const { return do_pos_format(); } | ||
| 66 | _LIBCPP_HIDE_FROM_ABI pattern neg_format() const { return do_neg_format(); } | ||
| 67 | |||
| 68 | static locale::id id; | ||
| 69 | static const bool intl = _International; | ||
| 70 | |||
| 71 | protected: | ||
| 72 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct() override {} | ||
| 73 | |||
| 74 | virtual char_type do_decimal_point() const { return numeric_limits<char_type>::max(); } | ||
| 75 | virtual char_type do_thousands_sep() const { return numeric_limits<char_type>::max(); } | ||
| 76 | virtual string do_grouping() const { return string(); } | ||
| 77 | virtual string_type do_curr_symbol() const { return string_type(); } | ||
| 78 | virtual string_type do_positive_sign() const { return string_type(); } | ||
| 79 | virtual string_type do_negative_sign() const { return string_type(1, '-'); } | ||
| 80 | virtual int do_frac_digits() const { return 0; } | ||
| 81 | virtual pattern do_pos_format() const { | ||
| 82 | pattern __p = {{symbol, sign, none, value}}; | ||
| 83 | return __p; | ||
| 84 | } | ||
| 85 | virtual pattern do_neg_format() const { | ||
| 86 | pattern __p = {{symbol, sign, none, value}}; | ||
| 87 | return __p; | ||
| 88 | } | ||
| 89 | }; | ||
| 90 | |||
| 91 | template <class _CharT, bool _International> | ||
| 92 | locale::id moneypunct<_CharT, _International>::id; | ||
| 93 | |||
| 94 | template <class _CharT, bool _International> | ||
| 95 | const bool moneypunct<_CharT, _International>::intl; | ||
| 96 | |||
| 97 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>; | ||
| 98 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>; | ||
| 99 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 100 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>; | ||
| 101 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>; | ||
| 102 | # endif | ||
| 103 | |||
| 104 | // moneypunct_byname | ||
| 105 | |||
| 106 | template <class _CharT, bool _International = false> | ||
| 107 | class moneypunct_byname : public moneypunct<_CharT, _International> { | ||
| 108 | public: | ||
| 109 | typedef money_base::pattern pattern; | ||
| 110 | typedef _CharT char_type; | ||
| 111 | typedef basic_string<char_type> string_type; | ||
| 112 | |||
| 113 | _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const char* __nm, size_t __refs = 0) | ||
| 114 | : moneypunct<_CharT, _International>(__refs) { | ||
| 115 | init(__nm); | ||
| 116 | } | ||
| 117 | |||
| 118 | _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const string& __nm, size_t __refs = 0) | ||
| 119 | : moneypunct<_CharT, _International>(__refs) { | ||
| 120 | init(__nm.c_str()); | ||
| 121 | } | ||
| 122 | |||
| 123 | protected: | ||
| 124 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct_byname() override {} | ||
| 125 | |||
| 126 | char_type do_decimal_point() const override { return __decimal_point_; } | ||
| 127 | char_type do_thousands_sep() const override { return __thousands_sep_; } | ||
| 128 | string do_grouping() const override { return __grouping_; } | ||
| 129 | string_type do_curr_symbol() const override { return __curr_symbol_; } | ||
| 130 | string_type do_positive_sign() const override { return __positive_sign_; } | ||
| 131 | string_type do_negative_sign() const override { return __negative_sign_; } | ||
| 132 | int do_frac_digits() const override { return __frac_digits_; } | ||
| 133 | pattern do_pos_format() const override { return __pos_format_; } | ||
| 134 | pattern do_neg_format() const override { return __neg_format_; } | ||
| 135 | |||
| 136 | private: | ||
| 137 | char_type __decimal_point_; | ||
| 138 | char_type __thousands_sep_; | ||
| 139 | string __grouping_; | ||
| 140 | string_type __curr_symbol_; | ||
| 141 | string_type __positive_sign_; | ||
| 142 | string_type __negative_sign_; | ||
| 143 | int __frac_digits_; | ||
| 144 | pattern __pos_format_; | ||
| 145 | pattern __neg_format_; | ||
| 146 | |||
| 147 | void init(const char*); | ||
| 148 | }; | ||
| 149 | |||
| 150 | template <> | ||
| 151 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, false>::init(const char*); | ||
| 152 | template <> | ||
| 153 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*); | ||
| 154 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>; | ||
| 155 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>; | ||
| 156 | |||
| 157 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 158 | template <> | ||
| 159 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*); | ||
| 160 | template <> | ||
| 161 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*); | ||
| 162 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>; | ||
| 163 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>; | ||
| 164 | # endif | ||
| 165 | |||
| 166 | // money_get | ||
| 167 | |||
| 168 | template <class _CharT> | ||
| 169 | class __money_get { | ||
| 170 | protected: | ||
| 171 | typedef _CharT char_type; | ||
| 172 | typedef basic_string<char_type> string_type; | ||
| 173 | |||
| 174 | _LIBCPP_HIDE_FROM_ABI __money_get() {} | ||
| 175 | |||
| 176 | static void __gather_info( | ||
| 177 | bool __intl, | ||
| 178 | const locale& __loc, | ||
| 179 | money_base::pattern& __pat, | ||
| 180 | char_type& __dp, | ||
| 181 | char_type& __ts, | ||
| 182 | string& __grp, | ||
| 183 | string_type& __sym, | ||
| 184 | string_type& __psn, | ||
| 185 | string_type& __nsn, | ||
| 186 | int& __fd); | ||
| 187 | }; | ||
| 188 | |||
| 189 | template <class _CharT> | ||
| 190 | void __money_get<_CharT>::__gather_info( | ||
| 191 | bool __intl, | ||
| 192 | const locale& __loc, | ||
| 193 | money_base::pattern& __pat, | ||
| 194 | char_type& __dp, | ||
| 195 | char_type& __ts, | ||
| 196 | string& __grp, | ||
| 197 | string_type& __sym, | ||
| 198 | string_type& __psn, | ||
| 199 | string_type& __nsn, | ||
| 200 | int& __fd) { | ||
| 201 | if (__intl) { | ||
| 202 | const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc); | ||
| 203 | __pat = __mp.neg_format(); | ||
| 204 | __nsn = __mp.negative_sign(); | ||
| 205 | __psn = __mp.positive_sign(); | ||
| 206 | __dp = __mp.decimal_point(); | ||
| 207 | __ts = __mp.thousands_sep(); | ||
| 208 | __grp = __mp.grouping(); | ||
| 209 | __sym = __mp.curr_symbol(); | ||
| 210 | __fd = __mp.frac_digits(); | ||
| 211 | } else { | ||
| 212 | const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc); | ||
| 213 | __pat = __mp.neg_format(); | ||
| 214 | __nsn = __mp.negative_sign(); | ||
| 215 | __psn = __mp.positive_sign(); | ||
| 216 | __dp = __mp.decimal_point(); | ||
| 217 | __ts = __mp.thousands_sep(); | ||
| 218 | __grp = __mp.grouping(); | ||
| 219 | __sym = __mp.curr_symbol(); | ||
| 220 | __fd = __mp.frac_digits(); | ||
| 221 | } | ||
| 222 | } | ||
| 223 | |||
| 224 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>; | ||
| 225 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 226 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>; | ||
| 227 | # endif | ||
| 228 | |||
| 229 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | ||
| 230 | class money_get : public locale::facet, private __money_get<_CharT> { | ||
| 231 | public: | ||
| 232 | typedef _CharT char_type; | ||
| 233 | typedef _InputIterator iter_type; | ||
| 234 | typedef basic_string<char_type> string_type; | ||
| 235 | |||
| 236 | _LIBCPP_HIDE_FROM_ABI explicit money_get(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 237 | |||
| 238 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 239 | get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 240 | return do_get(__b, __e, __intl, __iob, __err, __v); | ||
| 241 | } | ||
| 242 | |||
| 243 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 244 | get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const { | ||
| 245 | return do_get(__b, __e, __intl, __iob, __err, __v); | ||
| 246 | } | ||
| 247 | |||
| 248 | static locale::id id; | ||
| 249 | |||
| 250 | protected: | ||
| 251 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_get() override {} | ||
| 252 | |||
| 253 | virtual iter_type | ||
| 254 | do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const; | ||
| 255 | virtual iter_type | ||
| 256 | do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const; | ||
| 257 | |||
| 258 | private: | ||
| 259 | static bool __do_get( | ||
| 260 | iter_type& __b, | ||
| 261 | iter_type __e, | ||
| 262 | bool __intl, | ||
| 263 | const locale& __loc, | ||
| 264 | ios_base::fmtflags __flags, | ||
| 265 | ios_base::iostate& __err, | ||
| 266 | bool& __neg, | ||
| 267 | const ctype<char_type>& __ct, | ||
| 268 | unique_ptr<char_type, void (*)(void*)>& __wb, | ||
| 269 | char_type*& __wn, | ||
| 270 | char_type* __we); | ||
| 271 | }; | ||
| 272 | |||
| 273 | template <class _CharT, class _InputIterator> | ||
| 274 | locale::id money_get<_CharT, _InputIterator>::id; | ||
| 275 | |||
| 276 | _LIBCPP_EXPORTED_FROM_ABI void __do_nothing(void*); | ||
| 277 | |||
| 278 | template <class _Tp> | ||
| 279 | _LIBCPP_HIDE_FROM_ABI void __double_or_nothing(unique_ptr<_Tp, void (*)(void*)>& __b, _Tp*& __n, _Tp*& __e) { | ||
| 280 | bool __owns = __b.get_deleter() != __do_nothing; | ||
| 281 | size_t __cur_cap = static_cast<size_t>(__e - __b.get()) * sizeof(_Tp); | ||
| 282 | size_t __new_cap = __cur_cap < numeric_limits<size_t>::max() / 2 ? 2 * __cur_cap : numeric_limits<size_t>::max(); | ||
| 283 | if (__new_cap == 0) | ||
| 284 | __new_cap = sizeof(_Tp); | ||
| 285 | size_t __n_off = static_cast<size_t>(__n - __b.get()); | ||
| 286 | _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap); | ||
| 287 | if (__t == 0) | ||
| 288 | std::__throw_bad_alloc(); | ||
| 289 | if (__owns) | ||
| 290 | __b.release(); | ||
| 291 | else | ||
| 292 | std::memcpy(__t, __b.get(), __cur_cap); | ||
| 293 | __b = unique_ptr<_Tp, void (*)(void*)>(__t, free); | ||
| 294 | __new_cap /= sizeof(_Tp); | ||
| 295 | __n = __b.get() + __n_off; | ||
| 296 | __e = __b.get() + __new_cap; | ||
| 297 | } | ||
| 298 | |||
| 299 | // true == success | ||
| 300 | template <class _CharT, class _InputIterator> | ||
| 301 | bool money_get<_CharT, _InputIterator>::__do_get( | ||
| 302 | iter_type& __b, | ||
| 303 | iter_type __e, | ||
| 304 | bool __intl, | ||
| 305 | const locale& __loc, | ||
| 306 | ios_base::fmtflags __flags, | ||
| 307 | ios_base::iostate& __err, | ||
| 308 | bool& __neg, | ||
| 309 | const ctype<char_type>& __ct, | ||
| 310 | unique_ptr<char_type, void (*)(void*)>& __wb, | ||
| 311 | char_type*& __wn, | ||
| 312 | char_type* __we) { | ||
| 313 | if (__b == __e) { | ||
| 314 | __err |= ios_base::failbit; | ||
| 315 | return false; | ||
| 316 | } | ||
| 317 | const unsigned __bz = 100; | ||
| 318 | unsigned __gbuf[__bz]; | ||
| 319 | unique_ptr<unsigned, void (*)(void*)> __gb(__gbuf, __do_nothing); | ||
| 320 | unsigned* __gn = __gb.get(); | ||
| 321 | unsigned* __ge = __gn + __bz; | ||
| 322 | money_base::pattern __pat; | ||
| 323 | char_type __dp; | ||
| 324 | char_type __ts; | ||
| 325 | string __grp; | ||
| 326 | string_type __sym; | ||
| 327 | string_type __psn; | ||
| 328 | string_type __nsn; | ||
| 329 | // Capture the spaces read into money_base::{space,none} so they | ||
| 330 | // can be compared to initial spaces in __sym. | ||
| 331 | string_type __spaces; | ||
| 332 | int __fd; | ||
| 333 | __money_get<_CharT>::__gather_info(__intl, __loc, __pat, __dp, __ts, __grp, __sym, __psn, __nsn, __fd); | ||
| 334 | const string_type* __trailing_sign = 0; | ||
| 335 | __wn = __wb.get(); | ||
| 336 | for (unsigned __p = 0; __p < 4 && __b != __e; ++__p) { | ||
| 337 | switch (__pat.field[__p]) { | ||
| 338 | case money_base::space: | ||
| 339 | if (__p != 3) { | ||
| 340 | if (__ct.is(ctype_base::space, *__b)) | ||
| 341 | __spaces.push_back(*__b++); | ||
| 342 | else { | ||
| 343 | __err |= ios_base::failbit; | ||
| 344 | return false; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | [[__fallthrough__]]; | ||
| 348 | case money_base::none: | ||
| 349 | if (__p != 3) { | ||
| 350 | while (__b != __e && __ct.is(ctype_base::space, *__b)) | ||
| 351 | __spaces.push_back(*__b++); | ||
| 352 | } | ||
| 353 | break; | ||
| 354 | case money_base::sign: | ||
| 355 | if (__psn.size() > 0 && *__b == __psn[0]) { | ||
| 356 | ++__b; | ||
| 357 | __neg = false; | ||
| 358 | if (__psn.size() > 1) | ||
| 359 | __trailing_sign = std::addressof(__psn); | ||
| 360 | break; | ||
| 361 | } | ||
| 362 | if (__nsn.size() > 0 && *__b == __nsn[0]) { | ||
| 363 | ++__b; | ||
| 364 | __neg = true; | ||
| 365 | if (__nsn.size() > 1) | ||
| 366 | __trailing_sign = std::addressof(__nsn); | ||
| 367 | break; | ||
| 368 | } | ||
| 369 | if (__psn.size() > 0 && __nsn.size() > 0) { // sign is required | ||
| 370 | __err |= ios_base::failbit; | ||
| 371 | return false; | ||
| 372 | } | ||
| 373 | if (__psn.size() == 0 && __nsn.size() == 0) | ||
| 374 | // locale has no way of specifying a sign. Use the initial value of __neg as a default | ||
| 375 | break; | ||
| 376 | __neg = (__nsn.size() == 0); | ||
| 377 | break; | ||
| 378 | case money_base::symbol: { | ||
| 379 | bool __more_needed = | ||
| 380 | __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none)); | ||
| 381 | bool __sb = (__flags & ios_base::showbase) != 0; | ||
| 382 | if (__sb || __more_needed) { | ||
| 383 | typename string_type::const_iterator __sym_space_end = __sym.begin(); | ||
| 384 | if (__p > 0 && (__pat.field[__p - 1] == money_base::none || __pat.field[__p - 1] == money_base::space)) { | ||
| 385 | // Match spaces we've already read against spaces at | ||
| 386 | // the beginning of __sym. | ||
| 387 | while (__sym_space_end != __sym.end() && __ct.is(ctype_base::space, *__sym_space_end)) | ||
| 388 | ++__sym_space_end; | ||
| 389 | const size_t __num_spaces = __sym_space_end - __sym.begin(); | ||
| 390 | if (__num_spaces > __spaces.size() || | ||
| 391 | !std::equal(__spaces.end() - __num_spaces, __spaces.end(), __sym.begin())) { | ||
| 392 | // No match. Put __sym_space_end back at the | ||
| 393 | // beginning of __sym, which will prevent a | ||
| 394 | // match in the next loop. | ||
| 395 | __sym_space_end = __sym.begin(); | ||
| 396 | } | ||
| 397 | } | ||
| 398 | typename string_type::const_iterator __sym_curr_char = __sym_space_end; | ||
| 399 | while (__sym_curr_char != __sym.end() && __b != __e && *__b == *__sym_curr_char) { | ||
| 400 | ++__b; | ||
| 401 | ++__sym_curr_char; | ||
| 402 | } | ||
| 403 | if (__sb && __sym_curr_char != __sym.end()) { | ||
| 404 | __err |= ios_base::failbit; | ||
| 405 | return false; | ||
| 406 | } | ||
| 407 | } | ||
| 408 | } break; | ||
| 409 | case money_base::value: { | ||
| 410 | unsigned __ng = 0; | ||
| 411 | for (; __b != __e; ++__b) { | ||
| 412 | char_type __c = *__b; | ||
| 413 | if (__ct.is(ctype_base::digit, __c)) { | ||
| 414 | if (__wn == __we) | ||
| 415 | std::__double_or_nothing(__wb, __wn, __we); | ||
| 416 | *__wn++ = __c; | ||
| 417 | ++__ng; | ||
| 418 | } else if (__grp.size() > 0 && __ng > 0 && __c == __ts) { | ||
| 419 | if (__gn == __ge) | ||
| 420 | std::__double_or_nothing(__gb, __gn, __ge); | ||
| 421 | *__gn++ = __ng; | ||
| 422 | __ng = 0; | ||
| 423 | } else | ||
| 424 | break; | ||
| 425 | } | ||
| 426 | if (__gb.get() != __gn && __ng > 0) { | ||
| 427 | if (__gn == __ge) | ||
| 428 | std::__double_or_nothing(__gb, __gn, __ge); | ||
| 429 | *__gn++ = __ng; | ||
| 430 | } | ||
| 431 | if (__fd > 0) { | ||
| 432 | if (__b == __e || *__b != __dp) { | ||
| 433 | __err |= ios_base::failbit; | ||
| 434 | return false; | ||
| 435 | } | ||
| 436 | for (++__b; __fd > 0; --__fd, ++__b) { | ||
| 437 | if (__b == __e || !__ct.is(ctype_base::digit, *__b)) { | ||
| 438 | __err |= ios_base::failbit; | ||
| 439 | return false; | ||
| 440 | } | ||
| 441 | if (__wn == __we) | ||
| 442 | std::__double_or_nothing(__wb, __wn, __we); | ||
| 443 | *__wn++ = *__b; | ||
| 444 | } | ||
| 445 | } | ||
| 446 | if (__wn == __wb.get()) { | ||
| 447 | __err |= ios_base::failbit; | ||
| 448 | return false; | ||
| 449 | } | ||
| 450 | } break; | ||
| 451 | } | ||
| 452 | } | ||
| 453 | if (__trailing_sign) { | ||
| 454 | for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b) { | ||
| 455 | if (__b == __e || *__b != (*__trailing_sign)[__i]) { | ||
| 456 | __err |= ios_base::failbit; | ||
| 457 | return false; | ||
| 458 | } | ||
| 459 | } | ||
| 460 | } | ||
| 461 | if (__gb.get() != __gn) { | ||
| 462 | ios_base::iostate __et = ios_base::goodbit; | ||
| 463 | __check_grouping(__grp, __gb.get(), __gn, __et); | ||
| 464 | if (__et) { | ||
| 465 | __err |= ios_base::failbit; | ||
| 466 | return false; | ||
| 467 | } | ||
| 468 | } | ||
| 469 | return true; | ||
| 470 | } | ||
| 471 | |||
| 472 | template <class _CharT, class _InputIterator> | ||
| 473 | _InputIterator money_get<_CharT, _InputIterator>::do_get( | ||
| 474 | iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 475 | const int __bz = 100; | ||
| 476 | char_type __wbuf[__bz]; | ||
| 477 | unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing); | ||
| 478 | char_type* __wn; | ||
| 479 | char_type* __we = __wbuf + __bz; | ||
| 480 | locale __loc = __iob.getloc(); | ||
| 481 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 482 | bool __neg = false; | ||
| 483 | if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) { | ||
| 484 | const char __src[] = "0123456789"; | ||
| 485 | char_type __atoms[sizeof(__src) - 1]; | ||
| 486 | __ct.widen(__src, __src + (sizeof(__src) - 1), __atoms); | ||
| 487 | char __nbuf[__bz]; | ||
| 488 | char* __nc = __nbuf; | ||
| 489 | const char* __nc_in = __nc; | ||
| 490 | unique_ptr<char, void (*)(void*)> __h(nullptr, free); | ||
| 491 | if (__wn - __wb.get() > __bz - 2) { | ||
| 492 | __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2))); | ||
| 493 | if (__h.get() == nullptr) | ||
| 494 | std::__throw_bad_alloc(); | ||
| 495 | __nc = __h.get(); | ||
| 496 | __nc_in = __nc; | ||
| 497 | } | ||
| 498 | if (__neg) | ||
| 499 | *__nc++ = '-'; | ||
| 500 | for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc) | ||
| 501 | *__nc = __src[std::find(__atoms, std::end(__atoms), *__w) - __atoms]; | ||
| 502 | *__nc = char(); | ||
| 503 | if (sscanf(__nc_in, "%Lf", &__v) != 1) | ||
| 504 | std::__throw_runtime_error("money_get error"); | ||
| 505 | } | ||
| 506 | if (__b == __e) | ||
| 507 | __err |= ios_base::eofbit; | ||
| 508 | return __b; | ||
| 509 | } | ||
| 510 | |||
| 511 | template <class _CharT, class _InputIterator> | ||
| 512 | _InputIterator money_get<_CharT, _InputIterator>::do_get( | ||
| 513 | iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const { | ||
| 514 | const int __bz = 100; | ||
| 515 | char_type __wbuf[__bz]; | ||
| 516 | unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing); | ||
| 517 | char_type* __wn; | ||
| 518 | char_type* __we = __wbuf + __bz; | ||
| 519 | locale __loc = __iob.getloc(); | ||
| 520 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 521 | bool __neg = false; | ||
| 522 | if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) { | ||
| 523 | __v.clear(); | ||
| 524 | if (__neg) | ||
| 525 | __v.push_back(__ct.widen('-')); | ||
| 526 | char_type __z = __ct.widen('0'); | ||
| 527 | char_type* __w; | ||
| 528 | for (__w = __wb.get(); __w < __wn - 1; ++__w) | ||
| 529 | if (*__w != __z) | ||
| 530 | break; | ||
| 531 | __v.append(__w, __wn); | ||
| 532 | } | ||
| 533 | if (__b == __e) | ||
| 534 | __err |= ios_base::eofbit; | ||
| 535 | return __b; | ||
| 536 | } | ||
| 537 | |||
| 538 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>; | ||
| 539 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 540 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>; | ||
| 541 | # endif | ||
| 542 | |||
| 543 | // money_put | ||
| 544 | |||
| 545 | template <class _CharT> | ||
| 546 | class __money_put { | ||
| 547 | protected: | ||
| 548 | typedef _CharT char_type; | ||
| 549 | typedef basic_string<char_type> string_type; | ||
| 550 | |||
| 551 | _LIBCPP_HIDE_FROM_ABI __money_put() {} | ||
| 552 | |||
| 553 | static void __gather_info( | ||
| 554 | bool __intl, | ||
| 555 | bool __neg, | ||
| 556 | const locale& __loc, | ||
| 557 | money_base::pattern& __pat, | ||
| 558 | char_type& __dp, | ||
| 559 | char_type& __ts, | ||
| 560 | string& __grp, | ||
| 561 | string_type& __sym, | ||
| 562 | string_type& __sn, | ||
| 563 | int& __fd); | ||
| 564 | static void __format( | ||
| 565 | char_type* __mb, | ||
| 566 | char_type*& __mi, | ||
| 567 | char_type*& __me, | ||
| 568 | ios_base::fmtflags __flags, | ||
| 569 | const char_type* __db, | ||
| 570 | const char_type* __de, | ||
| 571 | const ctype<char_type>& __ct, | ||
| 572 | bool __neg, | ||
| 573 | const money_base::pattern& __pat, | ||
| 574 | char_type __dp, | ||
| 575 | char_type __ts, | ||
| 576 | const string& __grp, | ||
| 577 | const string_type& __sym, | ||
| 578 | const string_type& __sn, | ||
| 579 | int __fd); | ||
| 580 | }; | ||
| 581 | |||
| 582 | template <class _CharT> | ||
| 583 | void __money_put<_CharT>::__gather_info( | ||
| 584 | bool __intl, | ||
| 585 | bool __neg, | ||
| 586 | const locale& __loc, | ||
| 587 | money_base::pattern& __pat, | ||
| 588 | char_type& __dp, | ||
| 589 | char_type& __ts, | ||
| 590 | string& __grp, | ||
| 591 | string_type& __sym, | ||
| 592 | string_type& __sn, | ||
| 593 | int& __fd) { | ||
| 594 | if (__intl) { | ||
| 595 | const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc); | ||
| 596 | if (__neg) { | ||
| 597 | __pat = __mp.neg_format(); | ||
| 598 | __sn = __mp.negative_sign(); | ||
| 599 | } else { | ||
| 600 | __pat = __mp.pos_format(); | ||
| 601 | __sn = __mp.positive_sign(); | ||
| 602 | } | ||
| 603 | __dp = __mp.decimal_point(); | ||
| 604 | __ts = __mp.thousands_sep(); | ||
| 605 | __grp = __mp.grouping(); | ||
| 606 | __sym = __mp.curr_symbol(); | ||
| 607 | __fd = __mp.frac_digits(); | ||
| 608 | } else { | ||
| 609 | const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc); | ||
| 610 | if (__neg) { | ||
| 611 | __pat = __mp.neg_format(); | ||
| 612 | __sn = __mp.negative_sign(); | ||
| 613 | } else { | ||
| 614 | __pat = __mp.pos_format(); | ||
| 615 | __sn = __mp.positive_sign(); | ||
| 616 | } | ||
| 617 | __dp = __mp.decimal_point(); | ||
| 618 | __ts = __mp.thousands_sep(); | ||
| 619 | __grp = __mp.grouping(); | ||
| 620 | __sym = __mp.curr_symbol(); | ||
| 621 | __fd = __mp.frac_digits(); | ||
| 622 | } | ||
| 623 | } | ||
| 624 | |||
| 625 | template <class _CharT> | ||
| 626 | void __money_put<_CharT>::__format( | ||
| 627 | char_type* __mb, | ||
| 628 | char_type*& __mi, | ||
| 629 | char_type*& __me, | ||
| 630 | ios_base::fmtflags __flags, | ||
| 631 | const char_type* __db, | ||
| 632 | const char_type* __de, | ||
| 633 | const ctype<char_type>& __ct, | ||
| 634 | bool __neg, | ||
| 635 | const money_base::pattern& __pat, | ||
| 636 | char_type __dp, | ||
| 637 | char_type __ts, | ||
| 638 | const string& __grp, | ||
| 639 | const string_type& __sym, | ||
| 640 | const string_type& __sn, | ||
| 641 | int __fd) { | ||
| 642 | __me = __mb; | ||
| 643 | for (char __p : __pat.field) { | ||
| 644 | switch (__p) { | ||
| 645 | case money_base::none: | ||
| 646 | __mi = __me; | ||
| 647 | break; | ||
| 648 | case money_base::space: | ||
| 649 | __mi = __me; | ||
| 650 | *__me++ = __ct.widen(' '); | ||
| 651 | break; | ||
| 652 | case money_base::sign: | ||
| 653 | if (!__sn.empty()) | ||
| 654 | *__me++ = __sn[0]; | ||
| 655 | break; | ||
| 656 | case money_base::symbol: | ||
| 657 | if (!__sym.empty() && (__flags & ios_base::showbase)) | ||
| 658 | __me = std::copy(__sym.begin(), __sym.end(), __me); | ||
| 659 | break; | ||
| 660 | case money_base::value: { | ||
| 661 | // remember start of value so we can reverse it | ||
| 662 | char_type* __t = __me; | ||
| 663 | // find beginning of digits | ||
| 664 | if (__neg) | ||
| 665 | ++__db; | ||
| 666 | // find end of digits | ||
| 667 | const char_type* __d; | ||
| 668 | for (__d = __db; __d < __de; ++__d) | ||
| 669 | if (!__ct.is(ctype_base::digit, *__d)) | ||
| 670 | break; | ||
| 671 | // print fractional part | ||
| 672 | if (__fd > 0) { | ||
| 673 | int __f; | ||
| 674 | for (__f = __fd; __d > __db && __f > 0; --__f) | ||
| 675 | *__me++ = *--__d; | ||
| 676 | char_type __z = __f > 0 ? __ct.widen('0') : char_type(); | ||
| 677 | for (; __f > 0; --__f) | ||
| 678 | *__me++ = __z; | ||
| 679 | *__me++ = __dp; | ||
| 680 | } | ||
| 681 | // print units part | ||
| 682 | if (__d == __db) { | ||
| 683 | *__me++ = __ct.widen('0'); | ||
| 684 | } else { | ||
| 685 | unsigned __ng = 0; | ||
| 686 | unsigned __ig = 0; | ||
| 687 | unsigned __gl = __grp.empty() ? numeric_limits<unsigned>::max() : static_cast<unsigned>(__grp[__ig]); | ||
| 688 | while (__d != __db) { | ||
| 689 | if (__ng == __gl) { | ||
| 690 | *__me++ = __ts; | ||
| 691 | __ng = 0; | ||
| 692 | if (++__ig < __grp.size()) | ||
| 693 | __gl = __grp[__ig] == numeric_limits<char>::max() | ||
| 694 | ? numeric_limits<unsigned>::max() | ||
| 695 | : static_cast<unsigned>(__grp[__ig]); | ||
| 696 | } | ||
| 697 | *__me++ = *--__d; | ||
| 698 | ++__ng; | ||
| 699 | } | ||
| 700 | } | ||
| 701 | // reverse it | ||
| 702 | std::reverse(__t, __me); | ||
| 703 | } break; | ||
| 704 | } | ||
| 705 | } | ||
| 706 | // print rest of sign, if any | ||
| 707 | if (__sn.size() > 1) | ||
| 708 | __me = std::copy(__sn.begin() + 1, __sn.end(), __me); | ||
| 709 | // set alignment | ||
| 710 | if ((__flags & ios_base::adjustfield) == ios_base::left) | ||
| 711 | __mi = __me; | ||
| 712 | else if ((__flags & ios_base::adjustfield) != ios_base::internal) | ||
| 713 | __mi = __mb; | ||
| 714 | } | ||
| 715 | |||
| 716 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>; | ||
| 717 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 718 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>; | ||
| 719 | # endif | ||
| 720 | |||
| 721 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 722 | class money_put : public locale::facet, private __money_put<_CharT> { | ||
| 723 | public: | ||
| 724 | typedef _CharT char_type; | ||
| 725 | typedef _OutputIterator iter_type; | ||
| 726 | typedef basic_string<char_type> string_type; | ||
| 727 | |||
| 728 | _LIBCPP_HIDE_FROM_ABI explicit money_put(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 729 | |||
| 730 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 731 | put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const { | ||
| 732 | return do_put(__s, __intl, __iob, __fl, __units); | ||
| 733 | } | ||
| 734 | |||
| 735 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 736 | put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const { | ||
| 737 | return do_put(__s, __intl, __iob, __fl, __digits); | ||
| 738 | } | ||
| 739 | |||
| 740 | static locale::id id; | ||
| 741 | |||
| 742 | protected: | ||
| 743 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_put() override {} | ||
| 744 | |||
| 745 | virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const; | ||
| 746 | virtual iter_type | ||
| 747 | do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const; | ||
| 748 | }; | ||
| 749 | |||
| 750 | template <class _CharT, class _OutputIterator> | ||
| 751 | locale::id money_put<_CharT, _OutputIterator>::id; | ||
| 752 | |||
| 753 | template <class _CharT, class _OutputIterator> | ||
| 754 | _OutputIterator money_put<_CharT, _OutputIterator>::do_put( | ||
| 755 | iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const { | ||
| 756 | // convert to char | ||
| 757 | const size_t __bs = 100; | ||
| 758 | char __buf[__bs]; | ||
| 759 | char* __bb = __buf; | ||
| 760 | char_type __digits[__bs]; | ||
| 761 | char_type* __db = __digits; | ||
| 762 | int __n = snprintf(__bb, __bs, "%.0Lf", __units); | ||
| 763 | unique_ptr<char, void (*)(void*)> __hn(nullptr, free); | ||
| 764 | unique_ptr<char_type, void (*)(void*)> __hd(0, free); | ||
| 765 | // secure memory for digit storage | ||
| 766 | if (static_cast<size_t>(__n) > __bs - 1) { | ||
| 767 | __n = __locale::__asprintf(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units); | ||
| 768 | if (__n == -1) | ||
| 769 | std::__throw_bad_alloc(); | ||
| 770 | __hn.reset(__bb); | ||
| 771 | __hd.reset((char_type*)malloc(static_cast<size_t>(__n) * sizeof(char_type))); | ||
| 772 | if (__hd == nullptr) | ||
| 773 | std::__throw_bad_alloc(); | ||
| 774 | __db = __hd.get(); | ||
| 775 | } | ||
| 776 | // gather info | ||
| 777 | locale __loc = __iob.getloc(); | ||
| 778 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 779 | __ct.widen(__bb, __bb + __n, __db); | ||
| 780 | bool __neg = __n > 0 && __bb[0] == '-'; | ||
| 781 | money_base::pattern __pat; | ||
| 782 | char_type __dp; | ||
| 783 | char_type __ts; | ||
| 784 | string __grp; | ||
| 785 | string_type __sym; | ||
| 786 | string_type __sn; | ||
| 787 | int __fd; | ||
| 788 | this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd); | ||
| 789 | // secure memory for formatting | ||
| 790 | char_type __mbuf[__bs]; | ||
| 791 | char_type* __mb = __mbuf; | ||
| 792 | unique_ptr<char_type, void (*)(void*)> __hw(0, free); | ||
| 793 | size_t __exn = __n > __fd ? (static_cast<size_t>(__n) - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() + | ||
| 794 | static_cast<size_t>(__fd) + 1 | ||
| 795 | : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2; | ||
| 796 | if (__exn > __bs) { | ||
| 797 | __hw.reset((char_type*)malloc(__exn * sizeof(char_type))); | ||
| 798 | __mb = __hw.get(); | ||
| 799 | if (__mb == 0) | ||
| 800 | std::__throw_bad_alloc(); | ||
| 801 | } | ||
| 802 | // format | ||
| 803 | char_type* __mi; | ||
| 804 | char_type* __me; | ||
| 805 | this->__format( | ||
| 806 | __mb, __mi, __me, __iob.flags(), __db, __db + __n, __ct, __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd); | ||
| 807 | return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl); | ||
| 808 | } | ||
| 809 | |||
| 810 | template <class _CharT, class _OutputIterator> | ||
| 811 | _OutputIterator money_put<_CharT, _OutputIterator>::do_put( | ||
| 812 | iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const { | ||
| 813 | // gather info | ||
| 814 | locale __loc = __iob.getloc(); | ||
| 815 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 816 | bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-'); | ||
| 817 | money_base::pattern __pat; | ||
| 818 | char_type __dp; | ||
| 819 | char_type __ts; | ||
| 820 | string __grp; | ||
| 821 | string_type __sym; | ||
| 822 | string_type __sn; | ||
| 823 | int __fd; | ||
| 824 | this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd); | ||
| 825 | // secure memory for formatting | ||
| 826 | char_type __mbuf[100]; | ||
| 827 | char_type* __mb = __mbuf; | ||
| 828 | unique_ptr<char_type, void (*)(void*)> __h(0, free); | ||
| 829 | size_t __exn = | ||
| 830 | static_cast<int>(__digits.size()) > __fd | ||
| 831 | ? (__digits.size() - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() + static_cast<size_t>(__fd) + | ||
| 832 | 1 | ||
| 833 | : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2; | ||
| 834 | if (__exn > 100) { | ||
| 835 | __h.reset((char_type*)malloc(__exn * sizeof(char_type))); | ||
| 836 | __mb = __h.get(); | ||
| 837 | if (__mb == 0) | ||
| 838 | std::__throw_bad_alloc(); | ||
| 839 | } | ||
| 840 | // format | ||
| 841 | char_type* __mi; | ||
| 842 | char_type* __me; | ||
| 843 | this->__format( | ||
| 844 | __mb, | ||
| 845 | __mi, | ||
| 846 | __me, | ||
| 847 | __iob.flags(), | ||
| 848 | __digits.data(), | ||
| 849 | __digits.data() + __digits.size(), | ||
| 850 | __ct, | ||
| 851 | __neg, | ||
| 852 | __pat, | ||
| 853 | __dp, | ||
| 854 | __ts, | ||
| 855 | __grp, | ||
| 856 | __sym, | ||
| 857 | __sn, | ||
| 858 | __fd); | ||
| 859 | return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl); | ||
| 860 | } | ||
| 861 | |||
| 862 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>; | ||
| 863 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 864 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; | ||
| 865 | # endif | ||
| 866 | |||
| 867 | _LIBCPP_END_NAMESPACE_STD | ||
| 868 | |||
| 869 | _LIBCPP_POP_MACROS | ||
| 870 | |||
| 871 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 872 | |||
| 873 | #endif // _LIBCPP___LOCALE_DIR_MONEY_H | ||
lib/libcxx/include/__locale_dir/num.h created+1072| ... | @@ -0,0 +1,1072 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_NUM_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_NUM_H | ||
| 11 | |||
| 12 | #include <__algorithm/find.h> | ||
| 13 | #include <__algorithm/reverse.h> | ||
| 14 | #include <__charconv/to_chars_integral.h> | ||
| 15 | #include <__charconv/traits.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__iterator/istreambuf_iterator.h> | ||
| 18 | #include <__iterator/ostreambuf_iterator.h> | ||
| 19 | #include <__locale_dir/check_grouping.h> | ||
| 20 | #include <__locale_dir/get_c_locale.h> | ||
| 21 | #include <__locale_dir/pad_and_output.h> | ||
| 22 | #include <__locale_dir/scan_keyword.h> | ||
| 23 | #include <__memory/unique_ptr.h> | ||
| 24 | #include <__system_error/errc.h> | ||
| 25 | #include <cerrno> | ||
| 26 | #include <ios> | ||
| 27 | #include <streambuf> | ||
| 28 | |||
| 29 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 30 | |||
| 31 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 32 | # pragma GCC system_header | ||
| 33 | # endif | ||
| 34 | |||
| 35 | // TODO: Properly qualify calls now that the locale base API defines functions instead of macros | ||
| 36 | // NOLINTBEGIN(libcpp-robust-against-adl) | ||
| 37 | |||
| 38 | _LIBCPP_PUSH_MACROS | ||
| 39 | # include <__undef_macros> | ||
| 40 | |||
| 41 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 42 | |||
| 43 | struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base { | ||
| 44 | static const int __num_get_buf_sz = 40; | ||
| 45 | |||
| 46 | static int __get_base(ios_base&); | ||
| 47 | static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN" | ||
| 48 | // count of leading characters in __src used for parsing integers ("012..X+-") | ||
| 49 | static const size_t __int_chr_cnt = 26; | ||
| 50 | // count of leading characters in __src used for parsing floating-point values ("012..-pP") | ||
| 51 | static const size_t __fp_chr_cnt = 28; | ||
| 52 | }; | ||
| 53 | |||
| 54 | template <class _CharT> | ||
| 55 | struct __num_get : protected __num_get_base { | ||
| 56 | static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep); | ||
| 57 | |||
| 58 | static int __stage2_float_loop( | ||
| 59 | _CharT __ct, | ||
| 60 | bool& __in_units, | ||
| 61 | char& __exp, | ||
| 62 | char* __a, | ||
| 63 | char*& __a_end, | ||
| 64 | _CharT __decimal_point, | ||
| 65 | _CharT __thousands_sep, | ||
| 66 | const string& __grouping, | ||
| 67 | unsigned* __g, | ||
| 68 | unsigned*& __g_end, | ||
| 69 | unsigned& __dc, | ||
| 70 | _CharT* __atoms); | ||
| 71 | |||
| 72 | [[__deprecated__("This exists only for ABI compatibility")]] static string | ||
| 73 | __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); | ||
| 74 | static int __stage2_int_loop( | ||
| 75 | _CharT __ct, | ||
| 76 | int __base, | ||
| 77 | char* __a, | ||
| 78 | char*& __a_end, | ||
| 79 | unsigned& __dc, | ||
| 80 | _CharT __thousands_sep, | ||
| 81 | const string& __grouping, | ||
| 82 | unsigned* __g, | ||
| 83 | unsigned*& __g_end, | ||
| 84 | _CharT* __atoms); | ||
| 85 | |||
| 86 | _LIBCPP_HIDE_FROM_ABI static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { | ||
| 87 | locale __loc = __iob.getloc(); | ||
| 88 | const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); | ||
| 89 | __thousands_sep = __np.thousands_sep(); | ||
| 90 | return __np.grouping(); | ||
| 91 | } | ||
| 92 | |||
| 93 | _LIBCPP_HIDE_FROM_ABI const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const { | ||
| 94 | return __do_widen_p(__iob, __atoms); | ||
| 95 | } | ||
| 96 | |||
| 97 | private: | ||
| 98 | template <typename _Tp> | ||
| 99 | _LIBCPP_HIDE_FROM_ABI const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const { | ||
| 100 | locale __loc = __iob.getloc(); | ||
| 101 | use_facet<ctype<_Tp> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms); | ||
| 102 | return __atoms; | ||
| 103 | } | ||
| 104 | |||
| 105 | _LIBCPP_HIDE_FROM_ABI const char* __do_widen_p(ios_base& __iob, char* __atoms) const { | ||
| 106 | (void)__iob; | ||
| 107 | (void)__atoms; | ||
| 108 | return __src; | ||
| 109 | } | ||
| 110 | }; | ||
| 111 | |||
| 112 | template <class _CharT> | ||
| 113 | string __num_get<_CharT>::__stage2_float_prep( | ||
| 114 | ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) { | ||
| 115 | locale __loc = __iob.getloc(); | ||
| 116 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __fp_chr_cnt, __atoms); | ||
| 117 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 118 | __decimal_point = __np.decimal_point(); | ||
| 119 | __thousands_sep = __np.thousands_sep(); | ||
| 120 | return __np.grouping(); | ||
| 121 | } | ||
| 122 | |||
| 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> | ||
| 172 | int __num_get<_CharT>::__stage2_float_loop( | ||
| 173 | _CharT __ct, | ||
| 174 | bool& __in_units, | ||
| 175 | char& __exp, | ||
| 176 | char* __a, | ||
| 177 | char*& __a_end, | ||
| 178 | _CharT __decimal_point, | ||
| 179 | _CharT __thousands_sep, | ||
| 180 | const string& __grouping, | ||
| 181 | unsigned* __g, | ||
| 182 | unsigned*& __g_end, | ||
| 183 | unsigned& __dc, | ||
| 184 | _CharT* __atoms) { | ||
| 185 | if (__ct == __decimal_point) { | ||
| 186 | if (!__in_units) | ||
| 187 | return -1; | ||
| 188 | __in_units = false; | ||
| 189 | *__a_end++ = '.'; | ||
| 190 | if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz) | ||
| 191 | *__g_end++ = __dc; | ||
| 192 | return 0; | ||
| 193 | } | ||
| 194 | if (__ct == __thousands_sep && __grouping.size() != 0) { | ||
| 195 | if (!__in_units) | ||
| 196 | return -1; | ||
| 197 | if (__g_end - __g < __num_get_buf_sz) { | ||
| 198 | *__g_end++ = __dc; | ||
| 199 | __dc = 0; | ||
| 200 | } | ||
| 201 | return 0; | ||
| 202 | } | ||
| 203 | ptrdiff_t __f = std::find(__atoms, __atoms + __num_get_base::__fp_chr_cnt, __ct) - __atoms; | ||
| 204 | if (__f >= static_cast<ptrdiff_t>(__num_get_base::__fp_chr_cnt)) | ||
| 205 | return -1; | ||
| 206 | char __x = __src[__f]; | ||
| 207 | if (__x == '-' || __x == '+') { | ||
| 208 | if (__a_end == __a || (std::toupper(__a_end[-1]) == std::toupper(__exp))) { | ||
| 209 | *__a_end++ = __x; | ||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | return -1; | ||
| 213 | } | ||
| 214 | if (__x == 'x' || __x == 'X') | ||
| 215 | __exp = 'P'; | ||
| 216 | else if (std::toupper(__x) == __exp) { | ||
| 217 | __exp = std::tolower(__exp); | ||
| 218 | if (__in_units) { | ||
| 219 | __in_units = false; | ||
| 220 | if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz) | ||
| 221 | *__g_end++ = __dc; | ||
| 222 | } | ||
| 223 | } | ||
| 224 | *__a_end++ = __x; | ||
| 225 | if (__f >= 22) | ||
| 226 | return 0; | ||
| 227 | ++__dc; | ||
| 228 | return 0; | ||
| 229 | } | ||
| 230 | |||
| 231 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>; | ||
| 232 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 233 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>; | ||
| 234 | # endif | ||
| 235 | |||
| 236 | template <class _Tp> | ||
| 237 | _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2); | ||
| 238 | |||
| 239 | template <> | ||
| 240 | inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) { | ||
| 241 | return __locale::__strtof(__a, __p2, _LIBCPP_GET_C_LOCALE); | ||
| 242 | } | ||
| 243 | |||
| 244 | template <> | ||
| 245 | inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) { | ||
| 246 | return __locale::__strtod(__a, __p2, _LIBCPP_GET_C_LOCALE); | ||
| 247 | } | ||
| 248 | |||
| 249 | template <> | ||
| 250 | inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) { | ||
| 251 | return __locale::__strtold(__a, __p2, _LIBCPP_GET_C_LOCALE); | ||
| 252 | } | ||
| 253 | |||
| 254 | template <class _Tp> | ||
| 255 | _LIBCPP_HIDE_FROM_ABI _Tp __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) { | ||
| 256 | if (__a != __a_end) { | ||
| 257 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; | ||
| 258 | errno = 0; | ||
| 259 | char* __p2; | ||
| 260 | _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2); | ||
| 261 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; | ||
| 262 | if (__current_errno == 0) | ||
| 263 | errno = __save_errno; | ||
| 264 | if (__p2 != __a_end) { | ||
| 265 | __err = ios_base::failbit; | ||
| 266 | return 0; | ||
| 267 | } else if (__current_errno == ERANGE) | ||
| 268 | __err = ios_base::failbit; | ||
| 269 | return __ld; | ||
| 270 | } | ||
| 271 | __err = ios_base::failbit; | ||
| 272 | return 0; | ||
| 273 | } | ||
| 274 | |||
| 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> > | ||
| 335 | class num_get : public locale::facet, private __num_get<_CharT> { | ||
| 336 | public: | ||
| 337 | typedef _CharT char_type; | ||
| 338 | typedef _InputIterator iter_type; | ||
| 339 | |||
| 340 | _LIBCPP_HIDE_FROM_ABI explicit num_get(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 341 | |||
| 342 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 343 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const { | ||
| 344 | return do_get(__b, __e, __iob, __err, __v); | ||
| 345 | } | ||
| 346 | |||
| 347 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 348 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { | ||
| 349 | return do_get(__b, __e, __iob, __err, __v); | ||
| 350 | } | ||
| 351 | |||
| 352 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 353 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { | ||
| 354 | return do_get(__b, __e, __iob, __err, __v); | ||
| 355 | } | ||
| 356 | |||
| 357 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 358 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { | ||
| 359 | return do_get(__b, __e, __iob, __err, __v); | ||
| 360 | } | ||
| 361 | |||
| 362 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 363 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { | ||
| 364 | return do_get(__b, __e, __iob, __err, __v); | ||
| 365 | } | ||
| 366 | |||
| 367 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 368 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { | ||
| 369 | return do_get(__b, __e, __iob, __err, __v); | ||
| 370 | } | ||
| 371 | |||
| 372 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 373 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { | ||
| 374 | return do_get(__b, __e, __iob, __err, __v); | ||
| 375 | } | ||
| 376 | |||
| 377 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 378 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { | ||
| 379 | return do_get(__b, __e, __iob, __err, __v); | ||
| 380 | } | ||
| 381 | |||
| 382 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 383 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const { | ||
| 384 | return do_get(__b, __e, __iob, __err, __v); | ||
| 385 | } | ||
| 386 | |||
| 387 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 388 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 389 | return do_get(__b, __e, __iob, __err, __v); | ||
| 390 | } | ||
| 391 | |||
| 392 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 393 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { | ||
| 394 | return do_get(__b, __e, __iob, __err, __v); | ||
| 395 | } | ||
| 396 | |||
| 397 | static locale::id id; | ||
| 398 | |||
| 399 | protected: | ||
| 400 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_get() override {} | ||
| 401 | |||
| 402 | template <class _Fp> | ||
| 403 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 404 | __do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const { | ||
| 405 | // Stage 1, nothing to do | ||
| 406 | // Stage 2 | ||
| 407 | char_type __atoms[__num_get_base::__fp_chr_cnt]; | ||
| 408 | char_type __decimal_point; | ||
| 409 | char_type __thousands_sep; | ||
| 410 | string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep); | ||
| 411 | string __buf; | ||
| 412 | __buf.resize(__buf.capacity()); | ||
| 413 | char* __a = &__buf[0]; | ||
| 414 | char* __a_end = __a; | ||
| 415 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 416 | unsigned* __g_end = __g; | ||
| 417 | unsigned __dc = 0; | ||
| 418 | bool __in_units = true; | ||
| 419 | char __exp = 'E'; | ||
| 420 | bool __is_leading_parsed = false; | ||
| 421 | for (; __b != __e; ++__b) { | ||
| 422 | if (__a_end == __a + __buf.size()) { | ||
| 423 | size_t __tmp = __buf.size(); | ||
| 424 | __buf.resize(2 * __buf.size()); | ||
| 425 | __buf.resize(__buf.capacity()); | ||
| 426 | __a = &__buf[0]; | ||
| 427 | __a_end = __a + __tmp; | ||
| 428 | } | ||
| 429 | if (this->__stage2_float_loop( | ||
| 430 | *__b, | ||
| 431 | __in_units, | ||
| 432 | __exp, | ||
| 433 | __a, | ||
| 434 | __a_end, | ||
| 435 | __decimal_point, | ||
| 436 | __thousands_sep, | ||
| 437 | __grouping, | ||
| 438 | __g, | ||
| 439 | __g_end, | ||
| 440 | __dc, | ||
| 441 | __atoms)) | ||
| 442 | break; | ||
| 443 | |||
| 444 | // the leading character excluding the sign must be a decimal digit | ||
| 445 | if (!__is_leading_parsed) { | ||
| 446 | if (__a_end - __a >= 1 && __a[0] != '-' && __a[0] != '+') { | ||
| 447 | if (('0' <= __a[0] && __a[0] <= '9') || __a[0] == '.') | ||
| 448 | __is_leading_parsed = true; | ||
| 449 | else | ||
| 450 | break; | ||
| 451 | } else if (__a_end - __a >= 2 && (__a[0] == '-' || __a[0] == '+')) { | ||
| 452 | if (('0' <= __a[1] && __a[1] <= '9') || __a[1] == '.') | ||
| 453 | __is_leading_parsed = true; | ||
| 454 | else | ||
| 455 | break; | ||
| 456 | } | ||
| 457 | } | ||
| 458 | } | ||
| 459 | if (__grouping.size() != 0 && __in_units && __g_end - __g < __num_get_base::__num_get_buf_sz) | ||
| 460 | *__g_end++ = __dc; | ||
| 461 | // Stage 3 | ||
| 462 | __v = std::__num_get_float<_Fp>(__a, __a_end, __err); | ||
| 463 | // Digit grouping checked | ||
| 464 | __check_grouping(__grouping, __g, __g_end, __err); | ||
| 465 | // EOF checked | ||
| 466 | if (__b == __e) | ||
| 467 | __err |= ios_base::eofbit; | ||
| 468 | return __b; | ||
| 469 | } | ||
| 470 | |||
| 471 | template <class _Signed> | ||
| 472 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 473 | __do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const { | ||
| 474 | // Stage 1 | ||
| 475 | int __base = this->__get_base(__iob); | ||
| 476 | // Stage 2 | ||
| 477 | char_type __thousands_sep; | ||
| 478 | const int __atoms_size = __num_get_base::__int_chr_cnt; | ||
| 479 | char_type __atoms1[__atoms_size]; | ||
| 480 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | ||
| 481 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | ||
| 482 | string __buf; | ||
| 483 | __buf.resize(__buf.capacity()); | ||
| 484 | char* __a = &__buf[0]; | ||
| 485 | char* __a_end = __a; | ||
| 486 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 487 | unsigned* __g_end = __g; | ||
| 488 | unsigned __dc = 0; | ||
| 489 | for (; __b != __e; ++__b) { | ||
| 490 | if (__a_end == __a + __buf.size()) { | ||
| 491 | size_t __tmp = __buf.size(); | ||
| 492 | __buf.resize(2 * __buf.size()); | ||
| 493 | __buf.resize(__buf.capacity()); | ||
| 494 | __a = &__buf[0]; | ||
| 495 | __a_end = __a + __tmp; | ||
| 496 | } | ||
| 497 | if (this->__stage2_int_loop( | ||
| 498 | *__b, | ||
| 499 | __base, | ||
| 500 | __a, | ||
| 501 | __a_end, | ||
| 502 | __dc, | ||
| 503 | __thousands_sep, | ||
| 504 | __grouping, | ||
| 505 | __g, | ||
| 506 | __g_end, | ||
| 507 | const_cast<char_type*>(__atoms))) | ||
| 508 | break; | ||
| 509 | } | ||
| 510 | if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz) | ||
| 511 | *__g_end++ = __dc; | ||
| 512 | // Stage 3 | ||
| 513 | __v = std::__num_get_signed_integral<_Signed>(__a, __a_end, __err, __base); | ||
| 514 | // Digit grouping checked | ||
| 515 | __check_grouping(__grouping, __g, __g_end, __err); | ||
| 516 | // EOF checked | ||
| 517 | if (__b == __e) | ||
| 518 | __err |= ios_base::eofbit; | ||
| 519 | return __b; | ||
| 520 | } | ||
| 521 | |||
| 522 | template <class _Unsigned> | ||
| 523 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 524 | __do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const { | ||
| 525 | // Stage 1 | ||
| 526 | int __base = this->__get_base(__iob); | ||
| 527 | // Stage 2 | ||
| 528 | char_type __thousands_sep; | ||
| 529 | const int __atoms_size = __num_get_base::__int_chr_cnt; | ||
| 530 | char_type __atoms1[__atoms_size]; | ||
| 531 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | ||
| 532 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | ||
| 533 | string __buf; | ||
| 534 | __buf.resize(__buf.capacity()); | ||
| 535 | char* __a = &__buf[0]; | ||
| 536 | char* __a_end = __a; | ||
| 537 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 538 | unsigned* __g_end = __g; | ||
| 539 | unsigned __dc = 0; | ||
| 540 | for (; __b != __e; ++__b) { | ||
| 541 | if (__a_end == __a + __buf.size()) { | ||
| 542 | size_t __tmp = __buf.size(); | ||
| 543 | __buf.resize(2 * __buf.size()); | ||
| 544 | __buf.resize(__buf.capacity()); | ||
| 545 | __a = &__buf[0]; | ||
| 546 | __a_end = __a + __tmp; | ||
| 547 | } | ||
| 548 | if (this->__stage2_int_loop( | ||
| 549 | *__b, | ||
| 550 | __base, | ||
| 551 | __a, | ||
| 552 | __a_end, | ||
| 553 | __dc, | ||
| 554 | __thousands_sep, | ||
| 555 | __grouping, | ||
| 556 | __g, | ||
| 557 | __g_end, | ||
| 558 | const_cast<char_type*>(__atoms))) | ||
| 559 | break; | ||
| 560 | } | ||
| 561 | if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz) | ||
| 562 | *__g_end++ = __dc; | ||
| 563 | // Stage 3 | ||
| 564 | __v = std::__num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base); | ||
| 565 | // Digit grouping checked | ||
| 566 | __check_grouping(__grouping, __g, __g_end, __err); | ||
| 567 | // EOF checked | ||
| 568 | if (__b == __e) | ||
| 569 | __err |= ios_base::eofbit; | ||
| 570 | return __b; | ||
| 571 | } | ||
| 572 | |||
| 573 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; | ||
| 574 | |||
| 575 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { | ||
| 576 | return this->__do_get_signed(__b, __e, __iob, __err, __v); | ||
| 577 | } | ||
| 578 | |||
| 579 | virtual iter_type | ||
| 580 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { | ||
| 581 | return this->__do_get_signed(__b, __e, __iob, __err, __v); | ||
| 582 | } | ||
| 583 | |||
| 584 | virtual iter_type | ||
| 585 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { | ||
| 586 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 587 | } | ||
| 588 | |||
| 589 | virtual iter_type | ||
| 590 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { | ||
| 591 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 592 | } | ||
| 593 | |||
| 594 | virtual iter_type | ||
| 595 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { | ||
| 596 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 597 | } | ||
| 598 | |||
| 599 | virtual iter_type | ||
| 600 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { | ||
| 601 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 602 | } | ||
| 603 | |||
| 604 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { | ||
| 605 | return this->__do_get_floating_point(__b, __e, __iob, __err, __v); | ||
| 606 | } | ||
| 607 | |||
| 608 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const { | ||
| 609 | return this->__do_get_floating_point(__b, __e, __iob, __err, __v); | ||
| 610 | } | ||
| 611 | |||
| 612 | virtual iter_type | ||
| 613 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 614 | return this->__do_get_floating_point(__b, __e, __iob, __err, __v); | ||
| 615 | } | ||
| 616 | |||
| 617 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const; | ||
| 618 | }; | ||
| 619 | |||
| 620 | template <class _CharT, class _InputIterator> | ||
| 621 | locale::id num_get<_CharT, _InputIterator>::id; | ||
| 622 | |||
| 623 | template <class _CharT, class _InputIterator> | ||
| 624 | _InputIterator num_get<_CharT, _InputIterator>::do_get( | ||
| 625 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const { | ||
| 626 | if ((__iob.flags() & ios_base::boolalpha) == 0) { | ||
| 627 | long __lv = -1; | ||
| 628 | __b = do_get(__b, __e, __iob, __err, __lv); | ||
| 629 | switch (__lv) { | ||
| 630 | case 0: | ||
| 631 | __v = false; | ||
| 632 | break; | ||
| 633 | case 1: | ||
| 634 | __v = true; | ||
| 635 | break; | ||
| 636 | default: | ||
| 637 | __v = true; | ||
| 638 | __err = ios_base::failbit; | ||
| 639 | break; | ||
| 640 | } | ||
| 641 | return __b; | ||
| 642 | } | ||
| 643 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__iob.getloc()); | ||
| 644 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__iob.getloc()); | ||
| 645 | typedef typename numpunct<_CharT>::string_type string_type; | ||
| 646 | const string_type __names[2] = {__np.truename(), __np.falsename()}; | ||
| 647 | const string_type* __i = std::__scan_keyword(__b, __e, __names, __names + 2, __ct, __err); | ||
| 648 | __v = __i == __names; | ||
| 649 | return __b; | ||
| 650 | } | ||
| 651 | |||
| 652 | template <class _CharT, class _InputIterator> | ||
| 653 | _InputIterator num_get<_CharT, _InputIterator>::do_get( | ||
| 654 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { | ||
| 655 | // Stage 1 | ||
| 656 | int __base = 16; | ||
| 657 | // Stage 2 | ||
| 658 | char_type __atoms[__num_get_base::__int_chr_cnt]; | ||
| 659 | char_type __thousands_sep = char_type(); | ||
| 660 | string __grouping; | ||
| 661 | std::use_facet<ctype<_CharT> >(__iob.getloc()) | ||
| 662 | .widen(__num_get_base::__src, __num_get_base::__src + __num_get_base::__int_chr_cnt, __atoms); | ||
| 663 | string __buf; | ||
| 664 | __buf.resize(__buf.capacity()); | ||
| 665 | char* __a = &__buf[0]; | ||
| 666 | char* __a_end = __a; | ||
| 667 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 668 | unsigned* __g_end = __g; | ||
| 669 | unsigned __dc = 0; | ||
| 670 | for (; __b != __e; ++__b) { | ||
| 671 | if (__a_end == __a + __buf.size()) { | ||
| 672 | size_t __tmp = __buf.size(); | ||
| 673 | __buf.resize(2 * __buf.size()); | ||
| 674 | __buf.resize(__buf.capacity()); | ||
| 675 | __a = &__buf[0]; | ||
| 676 | __a_end = __a + __tmp; | ||
| 677 | } | ||
| 678 | if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) | ||
| 679 | break; | ||
| 680 | } | ||
| 681 | // Stage 3 | ||
| 682 | __buf.resize(__a_end - __a); | ||
| 683 | if (__locale::__sscanf(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) | ||
| 684 | __err = ios_base::failbit; | ||
| 685 | // EOF checked | ||
| 686 | if (__b == __e) | ||
| 687 | __err |= ios_base::eofbit; | ||
| 688 | return __b; | ||
| 689 | } | ||
| 690 | |||
| 691 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; | ||
| 692 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 693 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>; | ||
| 694 | # endif | ||
| 695 | |||
| 696 | struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base { | ||
| 697 | protected: | ||
| 698 | static void __format_int(char* __fmt, const char* __len, bool __signd, ios_base::fmtflags __flags); | ||
| 699 | static bool __format_float(char* __fmt, const char* __len, ios_base::fmtflags __flags); | ||
| 700 | static char* __identify_padding(char* __nb, char* __ne, const ios_base& __iob); | ||
| 701 | }; | ||
| 702 | |||
| 703 | template <class _CharT> | ||
| 704 | struct __num_put : protected __num_put_base { | ||
| 705 | static void __widen_and_group_int( | ||
| 706 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc); | ||
| 707 | static void __widen_and_group_float( | ||
| 708 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc); | ||
| 709 | }; | ||
| 710 | |||
| 711 | template <class _CharT> | ||
| 712 | void __num_put<_CharT>::__widen_and_group_int( | ||
| 713 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { | ||
| 714 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc); | ||
| 715 | const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 716 | string __grouping = __npt.grouping(); | ||
| 717 | if (__grouping.empty()) { | ||
| 718 | __ct.widen(__nb, __ne, __ob); | ||
| 719 | __oe = __ob + (__ne - __nb); | ||
| 720 | } else { | ||
| 721 | __oe = __ob; | ||
| 722 | char* __nf = __nb; | ||
| 723 | if (*__nf == '-' || *__nf == '+') | ||
| 724 | *__oe++ = __ct.widen(*__nf++); | ||
| 725 | if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) { | ||
| 726 | *__oe++ = __ct.widen(*__nf++); | ||
| 727 | *__oe++ = __ct.widen(*__nf++); | ||
| 728 | } | ||
| 729 | std::reverse(__nf, __ne); | ||
| 730 | _CharT __thousands_sep = __npt.thousands_sep(); | ||
| 731 | unsigned __dc = 0; | ||
| 732 | unsigned __dg = 0; | ||
| 733 | for (char* __p = __nf; __p < __ne; ++__p) { | ||
| 734 | if (static_cast<unsigned>(__grouping[__dg]) > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) { | ||
| 735 | *__oe++ = __thousands_sep; | ||
| 736 | __dc = 0; | ||
| 737 | if (__dg < __grouping.size() - 1) | ||
| 738 | ++__dg; | ||
| 739 | } | ||
| 740 | *__oe++ = __ct.widen(*__p); | ||
| 741 | ++__dc; | ||
| 742 | } | ||
| 743 | std::reverse(__ob + (__nf - __nb), __oe); | ||
| 744 | } | ||
| 745 | if (__np == __ne) | ||
| 746 | __op = __oe; | ||
| 747 | else | ||
| 748 | __op = __ob + (__np - __nb); | ||
| 749 | } | ||
| 750 | |||
| 751 | template <class _CharT> | ||
| 752 | void __num_put<_CharT>::__widen_and_group_float( | ||
| 753 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { | ||
| 754 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc); | ||
| 755 | const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 756 | string __grouping = __npt.grouping(); | ||
| 757 | __oe = __ob; | ||
| 758 | char* __nf = __nb; | ||
| 759 | if (*__nf == '-' || *__nf == '+') | ||
| 760 | *__oe++ = __ct.widen(*__nf++); | ||
| 761 | char* __ns; | ||
| 762 | if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) { | ||
| 763 | *__oe++ = __ct.widen(*__nf++); | ||
| 764 | *__oe++ = __ct.widen(*__nf++); | ||
| 765 | for (__ns = __nf; __ns < __ne; ++__ns) | ||
| 766 | if (!__locale::__isxdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | ||
| 767 | break; | ||
| 768 | } else { | ||
| 769 | for (__ns = __nf; __ns < __ne; ++__ns) | ||
| 770 | if (!__locale::__isdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | ||
| 771 | break; | ||
| 772 | } | ||
| 773 | if (__grouping.empty()) { | ||
| 774 | __ct.widen(__nf, __ns, __oe); | ||
| 775 | __oe += __ns - __nf; | ||
| 776 | } else { | ||
| 777 | std::reverse(__nf, __ns); | ||
| 778 | _CharT __thousands_sep = __npt.thousands_sep(); | ||
| 779 | unsigned __dc = 0; | ||
| 780 | unsigned __dg = 0; | ||
| 781 | for (char* __p = __nf; __p < __ns; ++__p) { | ||
| 782 | if (__grouping[__dg] > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) { | ||
| 783 | *__oe++ = __thousands_sep; | ||
| 784 | __dc = 0; | ||
| 785 | if (__dg < __grouping.size() - 1) | ||
| 786 | ++__dg; | ||
| 787 | } | ||
| 788 | *__oe++ = __ct.widen(*__p); | ||
| 789 | ++__dc; | ||
| 790 | } | ||
| 791 | std::reverse(__ob + (__nf - __nb), __oe); | ||
| 792 | } | ||
| 793 | for (__nf = __ns; __nf < __ne; ++__nf) { | ||
| 794 | if (*__nf == '.') { | ||
| 795 | *__oe++ = __npt.decimal_point(); | ||
| 796 | ++__nf; | ||
| 797 | break; | ||
| 798 | } else | ||
| 799 | *__oe++ = __ct.widen(*__nf); | ||
| 800 | } | ||
| 801 | __ct.widen(__nf, __ne, __oe); | ||
| 802 | __oe += __ne - __nf; | ||
| 803 | if (__np == __ne) | ||
| 804 | __op = __oe; | ||
| 805 | else | ||
| 806 | __op = __ob + (__np - __nb); | ||
| 807 | } | ||
| 808 | |||
| 809 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>; | ||
| 810 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 811 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>; | ||
| 812 | # endif | ||
| 813 | |||
| 814 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 815 | class num_put : public locale::facet, private __num_put<_CharT> { | ||
| 816 | public: | ||
| 817 | typedef _CharT char_type; | ||
| 818 | typedef _OutputIterator iter_type; | ||
| 819 | |||
| 820 | _LIBCPP_HIDE_FROM_ABI explicit num_put(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 821 | |||
| 822 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const { | ||
| 823 | return do_put(__s, __iob, __fl, __v); | ||
| 824 | } | ||
| 825 | |||
| 826 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const { | ||
| 827 | return do_put(__s, __iob, __fl, __v); | ||
| 828 | } | ||
| 829 | |||
| 830 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const { | ||
| 831 | return do_put(__s, __iob, __fl, __v); | ||
| 832 | } | ||
| 833 | |||
| 834 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const { | ||
| 835 | return do_put(__s, __iob, __fl, __v); | ||
| 836 | } | ||
| 837 | |||
| 838 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const { | ||
| 839 | return do_put(__s, __iob, __fl, __v); | ||
| 840 | } | ||
| 841 | |||
| 842 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const { | ||
| 843 | return do_put(__s, __iob, __fl, __v); | ||
| 844 | } | ||
| 845 | |||
| 846 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const { | ||
| 847 | return do_put(__s, __iob, __fl, __v); | ||
| 848 | } | ||
| 849 | |||
| 850 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const { | ||
| 851 | return do_put(__s, __iob, __fl, __v); | ||
| 852 | } | ||
| 853 | |||
| 854 | static locale::id id; | ||
| 855 | |||
| 856 | protected: | ||
| 857 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_put() override {} | ||
| 858 | |||
| 859 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const; | ||
| 860 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const; | ||
| 861 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const; | ||
| 862 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long) const; | ||
| 863 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long) const; | ||
| 864 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const; | ||
| 865 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const; | ||
| 866 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const; | ||
| 867 | |||
| 868 | template <class _Integral> | ||
| 869 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator | ||
| 870 | __do_put_integral(iter_type __s, ios_base& __iob, char_type __fl, _Integral __v) const; | ||
| 871 | |||
| 872 | template <class _Float> | ||
| 873 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator | ||
| 874 | __do_put_floating_point(iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const; | ||
| 875 | }; | ||
| 876 | |||
| 877 | template <class _CharT, class _OutputIterator> | ||
| 878 | locale::id num_put<_CharT, _OutputIterator>::id; | ||
| 879 | |||
| 880 | template <class _CharT, class _OutputIterator> | ||
| 881 | _OutputIterator | ||
| 882 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const { | ||
| 883 | if ((__iob.flags() & ios_base::boolalpha) == 0) | ||
| 884 | return do_put(__s, __iob, __fl, (unsigned long)__v); | ||
| 885 | const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc()); | ||
| 886 | typedef typename numpunct<char_type>::string_type string_type; | ||
| 887 | string_type __nm = __v ? __np.truename() : __np.falsename(); | ||
| 888 | for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s) | ||
| 889 | *__s = *__i; | ||
| 890 | return __s; | ||
| 891 | } | ||
| 892 | |||
| 893 | template <class _CharT, class _OutputIterator> | ||
| 894 | template <class _Integral> | ||
| 895 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_integral( | ||
| 896 | iter_type __s, ios_base& __iob, char_type __fl, _Integral __v) const { | ||
| 897 | // Stage 1 - Get number in narrow char | ||
| 898 | |||
| 899 | // Worst case is octal, with showbase enabled. Note that octal is always | ||
| 900 | // printed as an unsigned value. | ||
| 901 | using _Unsigned = typename make_unsigned<_Integral>::type; | ||
| 902 | _LIBCPP_CONSTEXPR const unsigned __buffer_size = | ||
| 903 | (numeric_limits<_Unsigned>::digits / 3) // 1 char per 3 bits | ||
| 904 | + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up | ||
| 905 | + 2; // base prefix + terminating null character | ||
| 906 | |||
| 907 | char __char_buffer[__buffer_size]; | ||
| 908 | char* __buffer_ptr = __char_buffer; | ||
| 909 | |||
| 910 | auto __flags = __iob.flags(); | ||
| 911 | |||
| 912 | auto __basefield = (__flags & ios_base::basefield); | ||
| 913 | |||
| 914 | // Extract base | ||
| 915 | int __base = 10; | ||
| 916 | if (__basefield == ios_base::oct) | ||
| 917 | __base = 8; | ||
| 918 | else if (__basefield == ios_base::hex) | ||
| 919 | __base = 16; | ||
| 920 | |||
| 921 | // Print '-' and make the argument unsigned | ||
| 922 | auto __uval = std::__to_unsigned_like(__v); | ||
| 923 | if (__basefield != ios_base::oct && __basefield != ios_base::hex && __v < 0) { | ||
| 924 | *__buffer_ptr++ = '-'; | ||
| 925 | __uval = std::__complement(__uval); | ||
| 926 | } | ||
| 927 | |||
| 928 | // Maybe add '+' prefix | ||
| 929 | if (std::is_signed<_Integral>::value && (__flags & ios_base::showpos) && __basefield != ios_base::oct && | ||
| 930 | __basefield != ios_base::hex && __v >= 0) | ||
| 931 | *__buffer_ptr++ = '+'; | ||
| 932 | |||
| 933 | // Add base prefix | ||
| 934 | if (__v != 0 && __flags & ios_base::showbase) { | ||
| 935 | if (__basefield == ios_base::oct) { | ||
| 936 | *__buffer_ptr++ = '0'; | ||
| 937 | } else if (__basefield == ios_base::hex) { | ||
| 938 | *__buffer_ptr++ = '0'; | ||
| 939 | *__buffer_ptr++ = (__flags & ios_base::uppercase ? 'X' : 'x'); | ||
| 940 | } | ||
| 941 | } | ||
| 942 | |||
| 943 | auto __res = std::__to_chars_integral(__buffer_ptr, __char_buffer + __buffer_size, __uval, __base); | ||
| 944 | _LIBCPP_ASSERT_INTERNAL(__res.__ec == std::errc(0), "to_chars: invalid maximum buffer size computed?"); | ||
| 945 | |||
| 946 | // Make letters uppercase | ||
| 947 | if (__flags & ios_base::hex && __flags & ios_base::uppercase) { | ||
| 948 | for (; __buffer_ptr != __res.__ptr; ++__buffer_ptr) | ||
| 949 | *__buffer_ptr = std::__hex_to_upper(*__buffer_ptr); | ||
| 950 | } | ||
| 951 | |||
| 952 | char* __np = this->__identify_padding(__char_buffer, __res.__ptr, __iob); | ||
| 953 | // Stage 2 - Widen __nar while adding thousands separators | ||
| 954 | char_type __o[2 * (__buffer_size - 1) - 1]; | ||
| 955 | char_type* __op; // pad here | ||
| 956 | char_type* __oe; // end of output | ||
| 957 | this->__widen_and_group_int(__char_buffer, __np, __res.__ptr, __o, __op, __oe, __iob.getloc()); | ||
| 958 | // [__o, __oe) contains thousands_sep'd wide number | ||
| 959 | // Stage 3 & 4 | ||
| 960 | return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl); | ||
| 961 | } | ||
| 962 | |||
| 963 | template <class _CharT, class _OutputIterator> | ||
| 964 | _OutputIterator | ||
| 965 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const { | ||
| 966 | return this->__do_put_integral(__s, __iob, __fl, __v); | ||
| 967 | } | ||
| 968 | |||
| 969 | template <class _CharT, class _OutputIterator> | ||
| 970 | _OutputIterator | ||
| 971 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const { | ||
| 972 | return this->__do_put_integral(__s, __iob, __fl, __v); | ||
| 973 | } | ||
| 974 | |||
| 975 | template <class _CharT, class _OutputIterator> | ||
| 976 | _OutputIterator | ||
| 977 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const { | ||
| 978 | return this->__do_put_integral(__s, __iob, __fl, __v); | ||
| 979 | } | ||
| 980 | |||
| 981 | template <class _CharT, class _OutputIterator> | ||
| 982 | _OutputIterator | ||
| 983 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const { | ||
| 984 | return this->__do_put_integral(__s, __iob, __fl, __v); | ||
| 985 | } | ||
| 986 | |||
| 987 | template <class _CharT, class _OutputIterator> | ||
| 988 | template <class _Float> | ||
| 989 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_floating_point( | ||
| 990 | iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const { | ||
| 991 | // Stage 1 - Get number in narrow char | ||
| 992 | char __fmt[8] = {'%', 0}; | ||
| 993 | bool __specify_precision = this->__format_float(__fmt + 1, __len, __iob.flags()); | ||
| 994 | const unsigned __nbuf = 30; | ||
| 995 | char __nar[__nbuf]; | ||
| 996 | char* __nb = __nar; | ||
| 997 | int __nc; | ||
| 998 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 999 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | ||
| 1000 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | ||
| 1001 | if (__specify_precision) | ||
| 1002 | __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | ||
| 1003 | else | ||
| 1004 | __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); | ||
| 1005 | unique_ptr<char, void (*)(void*)> __nbh(nullptr, free); | ||
| 1006 | if (__nc > static_cast<int>(__nbuf - 1)) { | ||
| 1007 | if (__specify_precision) | ||
| 1008 | __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | ||
| 1009 | else | ||
| 1010 | __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); | ||
| 1011 | if (__nc == -1) | ||
| 1012 | std::__throw_bad_alloc(); | ||
| 1013 | __nbh.reset(__nb); | ||
| 1014 | } | ||
| 1015 | _LIBCPP_DIAGNOSTIC_POP | ||
| 1016 | char* __ne = __nb + __nc; | ||
| 1017 | char* __np = this->__identify_padding(__nb, __ne, __iob); | ||
| 1018 | // Stage 2 - Widen __nar while adding thousands separators | ||
| 1019 | char_type __o[2 * (__nbuf - 1) - 1]; | ||
| 1020 | char_type* __ob = __o; | ||
| 1021 | unique_ptr<char_type, void (*)(void*)> __obh(0, free); | ||
| 1022 | if (__nb != __nar) { | ||
| 1023 | __ob = (char_type*)malloc(2 * static_cast<size_t>(__nc) * sizeof(char_type)); | ||
| 1024 | if (__ob == 0) | ||
| 1025 | std::__throw_bad_alloc(); | ||
| 1026 | __obh.reset(__ob); | ||
| 1027 | } | ||
| 1028 | char_type* __op; // pad here | ||
| 1029 | char_type* __oe; // end of output | ||
| 1030 | this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc()); | ||
| 1031 | // [__o, __oe) contains thousands_sep'd wide number | ||
| 1032 | // Stage 3 & 4 | ||
| 1033 | __s = std::__pad_and_output(__s, __ob, __op, __oe, __iob, __fl); | ||
| 1034 | return __s; | ||
| 1035 | } | ||
| 1036 | |||
| 1037 | template <class _CharT, class _OutputIterator> | ||
| 1038 | _OutputIterator | ||
| 1039 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const { | ||
| 1040 | return this->__do_put_floating_point(__s, __iob, __fl, __v, ""); | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | template <class _CharT, class _OutputIterator> | ||
| 1044 | _OutputIterator | ||
| 1045 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const { | ||
| 1046 | return this->__do_put_floating_point(__s, __iob, __fl, __v, "L"); | ||
| 1047 | } | ||
| 1048 | |||
| 1049 | template <class _CharT, class _OutputIterator> | ||
| 1050 | _OutputIterator | ||
| 1051 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const { | ||
| 1052 | auto __flags = __iob.flags(); | ||
| 1053 | __iob.flags((__flags & ~ios_base::basefield & ~ios_base::uppercase) | ios_base::hex | ios_base::showbase); | ||
| 1054 | auto __res = __do_put_integral(__s, __iob, __fl, reinterpret_cast<uintptr_t>(__v)); | ||
| 1055 | __iob.flags(__flags); | ||
| 1056 | return __res; | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>; | ||
| 1060 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 1061 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>; | ||
| 1062 | # endif | ||
| 1063 | |||
| 1064 | _LIBCPP_END_NAMESPACE_STD | ||
| 1065 | |||
| 1066 | _LIBCPP_POP_MACROS | ||
| 1067 | |||
| 1068 | // NOLINTEND(libcpp-robust-against-adl) | ||
| 1069 | |||
| 1070 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 1071 | |||
| 1072 | #endif // _LIBCPP___LOCALE_DIR_NUM_H | ||
lib/libcxx/include/__locale_dir/scan_keyword.h created+143| ... | @@ -0,0 +1,143 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SCAN_KEYWORD_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_SCAN_KEYWORD_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__memory/unique_ptr.h> | ||
| 14 | #include <ios> | ||
| 15 | |||
| 16 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 17 | |||
| 18 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | # endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | // __scan_keyword | ||
| 25 | // Scans [__b, __e) until a match is found in the basic_strings range | ||
| 26 | // [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke). | ||
| 27 | // __b will be incremented (visibly), consuming CharT until a match is found | ||
| 28 | // or proved to not exist. A keyword may be "", in which will match anything. | ||
| 29 | // If one keyword is a prefix of another, and the next CharT in the input | ||
| 30 | // might match another keyword, the algorithm will attempt to find the longest | ||
| 31 | // matching keyword. If the longer matching keyword ends up not matching, then | ||
| 32 | // no keyword match is found. If no keyword match is found, __ke is returned | ||
| 33 | // and failbit is set in __err. | ||
| 34 | // Else an iterator pointing to the matching keyword is found. If more than | ||
| 35 | // one keyword matches, an iterator to the first matching keyword is returned. | ||
| 36 | // If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false, | ||
| 37 | // __ct is used to force to lower case before comparing characters. | ||
| 38 | // Examples: | ||
| 39 | // Keywords: "a", "abb" | ||
| 40 | // If the input is "a", the first keyword matches and eofbit is set. | ||
| 41 | // If the input is "abc", no match is found and "ab" are consumed. | ||
| 42 | template <class _InputIterator, class _ForwardIterator, class _Ctype> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator __scan_keyword( | ||
| 44 | _InputIterator& __b, | ||
| 45 | _InputIterator __e, | ||
| 46 | _ForwardIterator __kb, | ||
| 47 | _ForwardIterator __ke, | ||
| 48 | const _Ctype& __ct, | ||
| 49 | ios_base::iostate& __err, | ||
| 50 | bool __case_sensitive = true) { | ||
| 51 | typedef typename iterator_traits<_InputIterator>::value_type _CharT; | ||
| 52 | size_t __nkw = static_cast<size_t>(std::distance(__kb, __ke)); | ||
| 53 | const unsigned char __doesnt_match = '\0'; | ||
| 54 | const unsigned char __might_match = '\1'; | ||
| 55 | const unsigned char __does_match = '\2'; | ||
| 56 | unsigned char __statbuf[100]; | ||
| 57 | unsigned char* __status = __statbuf; | ||
| 58 | unique_ptr<unsigned char, void (*)(void*)> __stat_hold(nullptr, free); | ||
| 59 | if (__nkw > sizeof(__statbuf)) { | ||
| 60 | __status = (unsigned char*)malloc(__nkw); | ||
| 61 | if (__status == nullptr) | ||
| 62 | std::__throw_bad_alloc(); | ||
| 63 | __stat_hold.reset(__status); | ||
| 64 | } | ||
| 65 | size_t __n_might_match = __nkw; // At this point, any keyword might match | ||
| 66 | size_t __n_does_match = 0; // but none of them definitely do | ||
| 67 | // Initialize all statuses to __might_match, except for "" keywords are __does_match | ||
| 68 | unsigned char* __st = __status; | ||
| 69 | for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) { | ||
| 70 | if (!__ky->empty()) | ||
| 71 | *__st = __might_match; | ||
| 72 | else { | ||
| 73 | *__st = __does_match; | ||
| 74 | --__n_might_match; | ||
| 75 | ++__n_does_match; | ||
| 76 | } | ||
| 77 | } | ||
| 78 | // While there might be a match, test keywords against the next CharT | ||
| 79 | for (size_t __indx = 0; __b != __e && __n_might_match > 0; ++__indx) { | ||
| 80 | // Peek at the next CharT but don't consume it | ||
| 81 | _CharT __c = *__b; | ||
| 82 | if (!__case_sensitive) | ||
| 83 | __c = __ct.toupper(__c); | ||
| 84 | bool __consume = false; | ||
| 85 | // For each keyword which might match, see if the __indx character is __c | ||
| 86 | // If a match if found, consume __c | ||
| 87 | // If a match is found, and that is the last character in the keyword, | ||
| 88 | // then that keyword matches. | ||
| 89 | // If the keyword doesn't match this character, then change the keyword | ||
| 90 | // to doesn't match | ||
| 91 | __st = __status; | ||
| 92 | for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) { | ||
| 93 | if (*__st == __might_match) { | ||
| 94 | _CharT __kc = (*__ky)[__indx]; | ||
| 95 | if (!__case_sensitive) | ||
| 96 | __kc = __ct.toupper(__kc); | ||
| 97 | if (__c == __kc) { | ||
| 98 | __consume = true; | ||
| 99 | if (__ky->size() == __indx + 1) { | ||
| 100 | *__st = __does_match; | ||
| 101 | --__n_might_match; | ||
| 102 | ++__n_does_match; | ||
| 103 | } | ||
| 104 | } else { | ||
| 105 | *__st = __doesnt_match; | ||
| 106 | --__n_might_match; | ||
| 107 | } | ||
| 108 | } | ||
| 109 | } | ||
| 110 | // consume if we matched a character | ||
| 111 | if (__consume) { | ||
| 112 | ++__b; | ||
| 113 | // If we consumed a character and there might be a matched keyword that | ||
| 114 | // was marked matched on a previous iteration, then such keywords | ||
| 115 | // which are now marked as not matching. | ||
| 116 | if (__n_might_match + __n_does_match > 1) { | ||
| 117 | __st = __status; | ||
| 118 | for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) { | ||
| 119 | if (*__st == __does_match && __ky->size() != __indx + 1) { | ||
| 120 | *__st = __doesnt_match; | ||
| 121 | --__n_does_match; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | } | ||
| 125 | } | ||
| 126 | } | ||
| 127 | // We've exited the loop because we hit eof and/or we have no more "might matches". | ||
| 128 | if (__b == __e) | ||
| 129 | __err |= ios_base::eofbit; | ||
| 130 | // Return the first matching result | ||
| 131 | for (__st = __status; __kb != __ke; ++__kb, (void)++__st) | ||
| 132 | if (*__st == __does_match) | ||
| 133 | break; | ||
| 134 | if (__kb == __ke) | ||
| 135 | __err |= ios_base::failbit; | ||
| 136 | return __kb; | ||
| 137 | } | ||
| 138 | |||
| 139 | _LIBCPP_END_NAMESPACE_STD | ||
| 140 | |||
| 141 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 142 | |||
| 143 | #endif // _LIBCPP___LOCALE_DIR_SCAN_KEYWORD_H | ||
lib/libcxx/include/__locale_dir/support/apple.h-2| ... | @@ -15,8 +15,6 @@ | ... | @@ -15,8 +15,6 @@ |
| 15 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | #include <xlocale.h> | ||
| 19 | |||
| 20 | #include <__locale_dir/support/bsd_like.h> | 18 | #include <__locale_dir/support/bsd_like.h> |
| 21 | 19 | ||
| 22 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H | 20 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H |
lib/libcxx/include/__locale_dir/support/bsd_like.h+7-8| ... | @@ -24,6 +24,11 @@ | ... | @@ -24,6 +24,11 @@ |
| 24 | # include <wctype.h> | 24 | # include <wctype.h> |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | /* zig patch: https://github.com/llvm/llvm-project/pull/143055 */ | ||
| 28 | #if __has_include(<xlocale.h>) | ||
| 29 | # include <xlocale.h> | ||
| 30 | #endif | ||
| 31 | |||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | # pragma GCC system_header | 33 | # pragma GCC system_header |
| 29 | #endif | 34 | #endif |
| ... | @@ -43,9 +48,9 @@ namespace __locale { | ... | @@ -43,9 +48,9 @@ namespace __locale { |
| 43 | #define _LIBCPP_ALL_MASK LC_ALL_MASK | 48 | #define _LIBCPP_ALL_MASK LC_ALL_MASK |
| 44 | #define _LIBCPP_LC_ALL LC_ALL | 49 | #define _LIBCPP_LC_ALL LC_ALL |
| 45 | 50 | ||
| 46 | using __locale_t = ::locale_t; | 51 | using __locale_t _LIBCPP_NODEBUG = ::locale_t; |
| 47 | #if defined(_LIBCPP_BUILDING_LIBRARY) | 52 | #if defined(_LIBCPP_BUILDING_LIBRARY) |
| 48 | using __lconv_t = std::lconv; | 53 | using __lconv_t _LIBCPP_NODEBUG = std::lconv; |
| 49 | 54 | ||
| 50 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) { | 55 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) { |
| 51 | return ::newlocale(__category_mask, __locale, __base); | 56 | return ::newlocale(__category_mask, __locale, __base); |
| ... | @@ -87,12 +92,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ... | @@ -87,12 +92,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { |
| 87 | // | 92 | // |
| 88 | // Character manipulation functions | 93 | // Character manipulation functions |
| 89 | // | 94 | // |
| 90 | #if defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 91 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return ::islower_l(__c, __loc); } | ||
| 92 | |||
| 93 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return ::isupper_l(__c, __loc); } | ||
| 94 | #endif | ||
| 95 | |||
| 96 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); } | 95 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); } |
| 97 | 96 | ||
| 98 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); } | 97 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); } |
lib/libcxx/include/__locale_dir/support/freebsd.h-2| ... | @@ -15,8 +15,6 @@ | ... | @@ -15,8 +15,6 @@ |
| 15 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | #include <xlocale.h> | ||
| 19 | |||
| 20 | #include <__locale_dir/support/bsd_like.h> | 18 | #include <__locale_dir/support/bsd_like.h> |
| 21 | 19 | ||
| 22 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H | 20 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H |
lib/libcxx/include/__locale_dir/support/fuchsia.h+2-2| ... | @@ -49,10 +49,10 @@ struct __locale_guard { | ... | @@ -49,10 +49,10 @@ struct __locale_guard { |
| 49 | #define _LIBCPP_ALL_MASK LC_ALL_MASK | 49 | #define _LIBCPP_ALL_MASK LC_ALL_MASK |
| 50 | #define _LIBCPP_LC_ALL LC_ALL | 50 | #define _LIBCPP_LC_ALL LC_ALL |
| 51 | 51 | ||
| 52 | using __locale_t = locale_t; | 52 | using __locale_t _LIBCPP_NODEBUG = locale_t; |
| 53 | 53 | ||
| 54 | #if defined(_LIBCPP_BUILDING_LIBRARY) | 54 | #if defined(_LIBCPP_BUILDING_LIBRARY) |
| 55 | using __lconv_t = std::lconv; | 55 | using __lconv_t _LIBCPP_NODEBUG = std::lconv; |
| 56 | 56 | ||
| 57 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) { | 57 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) { |
| 58 | return ::newlocale(__category_mask, __name, __loc); | 58 | return ::newlocale(__category_mask, __name, __loc); |
lib/libcxx/include/__locale_dir/support/linux.h created+281| ... | @@ -0,0 +1,281 @@ | ||
| 1 | //===-----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_LINUX_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_LINUX_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__cstddef/size_t.h> | ||
| 14 | #include <__std_mbstate_t.h> | ||
| 15 | #include <__utility/forward.h> | ||
| 16 | #include <clocale> // std::lconv | ||
| 17 | #include <cstdio> | ||
| 18 | #include <cstdlib> | ||
| 19 | #include <ctype.h> | ||
| 20 | #include <stdarg.h> | ||
| 21 | #include <string.h> | ||
| 22 | #include <time.h> | ||
| 23 | #if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 24 | # include <cwchar> | ||
| 25 | # include <wctype.h> | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 29 | # pragma GCC system_header | ||
| 30 | #endif | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | namespace __locale { | ||
| 34 | |||
| 35 | struct __locale_guard { | ||
| 36 | _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {} | ||
| 37 | |||
| 38 | _LIBCPP_HIDE_FROM_ABI ~__locale_guard() { | ||
| 39 | if (__old_loc_) | ||
| 40 | ::uselocale(__old_loc_); | ||
| 41 | } | ||
| 42 | |||
| 43 | locale_t __old_loc_; | ||
| 44 | |||
| 45 | __locale_guard(__locale_guard const&) = delete; | ||
| 46 | __locale_guard& operator=(__locale_guard const&) = delete; | ||
| 47 | }; | ||
| 48 | |||
| 49 | // | ||
| 50 | // Locale management | ||
| 51 | // | ||
| 52 | #define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK | ||
| 53 | #define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK | ||
| 54 | #define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK | ||
| 55 | #define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK | ||
| 56 | #define _LIBCPP_TIME_MASK LC_TIME_MASK | ||
| 57 | #define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK | ||
| 58 | #define _LIBCPP_ALL_MASK LC_ALL_MASK | ||
| 59 | #define _LIBCPP_LC_ALL LC_ALL | ||
| 60 | |||
| 61 | using __locale_t _LIBCPP_NODEBUG = ::locale_t; | ||
| 62 | |||
| 63 | #if defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 64 | using __lconv_t _LIBCPP_NODEBUG = std::lconv; | ||
| 65 | |||
| 66 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) { | ||
| 67 | return ::newlocale(__category_mask, __locale, __base); | ||
| 68 | } | ||
| 69 | |||
| 70 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); } | ||
| 71 | |||
| 72 | inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) { | ||
| 73 | return ::setlocale(__category, __locale); | ||
| 74 | } | ||
| 75 | |||
| 76 | inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { | ||
| 77 | __locale_guard __current(__loc); | ||
| 78 | return std::localeconv(); | ||
| 79 | } | ||
| 80 | #endif // _LIBCPP_BUILDING_LIBRARY | ||
| 81 | |||
| 82 | // | ||
| 83 | // Strtonum functions | ||
| 84 | // | ||
| 85 | inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) { | ||
| 86 | return ::strtof_l(__nptr, __endptr, __loc); | ||
| 87 | } | ||
| 88 | |||
| 89 | inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) { | ||
| 90 | return ::strtod_l(__nptr, __endptr, __loc); | ||
| 91 | } | ||
| 92 | |||
| 93 | inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) { | ||
| 94 | return ::strtold_l(__nptr, __endptr, __loc); | ||
| 95 | } | ||
| 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 | // | ||
| 117 | // Character manipulation functions | ||
| 118 | // | ||
| 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) | ||
| 124 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return toupper_l(__c, __loc); } | ||
| 125 | |||
| 126 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return tolower_l(__c, __loc); } | ||
| 127 | |||
| 128 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { | ||
| 129 | return strcoll_l(__s1, __s2, __loc); | ||
| 130 | } | ||
| 131 | |||
| 132 | inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) { | ||
| 133 | return strxfrm_l(__dest, __src, __n, __loc); | ||
| 134 | } | ||
| 135 | |||
| 136 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 137 | inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) { | ||
| 138 | return iswctype_l(__c, __type, __loc); | ||
| 139 | } | ||
| 140 | |||
| 141 | inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return iswspace_l(__c, __loc); } | ||
| 142 | |||
| 143 | inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return iswprint_l(__c, __loc); } | ||
| 144 | |||
| 145 | inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return iswcntrl_l(__c, __loc); } | ||
| 146 | |||
| 147 | inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return iswupper_l(__c, __loc); } | ||
| 148 | |||
| 149 | inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return iswlower_l(__c, __loc); } | ||
| 150 | |||
| 151 | inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return iswalpha_l(__c, __loc); } | ||
| 152 | |||
| 153 | inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t __loc) { return iswblank_l(__c, __loc); } | ||
| 154 | |||
| 155 | inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return iswdigit_l(__c, __loc); } | ||
| 156 | |||
| 157 | inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return iswpunct_l(__c, __loc); } | ||
| 158 | |||
| 159 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return iswxdigit_l(__c, __loc); } | ||
| 160 | |||
| 161 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return towupper_l(__c, __loc); } | ||
| 162 | |||
| 163 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return towlower_l(__c, __loc); } | ||
| 164 | |||
| 165 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) { | ||
| 166 | return wcscoll_l(__ws1, __ws2, __loc); | ||
| 167 | } | ||
| 168 | |||
| 169 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) { | ||
| 170 | return wcsxfrm_l(__dest, __src, __n, __loc); | ||
| 171 | } | ||
| 172 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 173 | |||
| 174 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 175 | __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) { | ||
| 176 | return strftime_l(__s, __max, __format, __tm, __loc); | ||
| 177 | } | ||
| 178 | |||
| 179 | // | ||
| 180 | // Other functions | ||
| 181 | // | ||
| 182 | inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) { | ||
| 183 | __locale_guard __current(__loc); | ||
| 184 | return MB_CUR_MAX; | ||
| 185 | } | ||
| 186 | |||
| 187 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 188 | inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t __loc) { | ||
| 189 | __locale_guard __current(__loc); | ||
| 190 | return std::btowc(__c); | ||
| 191 | } | ||
| 192 | |||
| 193 | inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t __loc) { | ||
| 194 | __locale_guard __current(__loc); | ||
| 195 | return std::wctob(__c); | ||
| 196 | } | ||
| 197 | |||
| 198 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 199 | __wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) { | ||
| 200 | __locale_guard __current(__loc); | ||
| 201 | return ::wcsnrtombs(__dest, __src, __nwc, __len, __ps); // non-standard | ||
| 202 | } | ||
| 203 | |||
| 204 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t __loc) { | ||
| 205 | __locale_guard __current(__loc); | ||
| 206 | return std::wcrtomb(__s, __wc, __ps); | ||
| 207 | } | ||
| 208 | |||
| 209 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 210 | __mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) { | ||
| 211 | __locale_guard __current(__loc); | ||
| 212 | return ::mbsnrtowcs(__dest, __src, __nms, __len, __ps); // non-standard | ||
| 213 | } | ||
| 214 | |||
| 215 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 216 | __mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | ||
| 217 | __locale_guard __current(__loc); | ||
| 218 | return std::mbrtowc(__pwc, __s, __n, __ps); | ||
| 219 | } | ||
| 220 | |||
| 221 | inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) { | ||
| 222 | __locale_guard __current(__loc); | ||
| 223 | return std::mbtowc(__pwc, __pmb, __max); | ||
| 224 | } | ||
| 225 | |||
| 226 | inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | ||
| 227 | __locale_guard __current(__loc); | ||
| 228 | return std::mbrlen(__s, __n, __ps); | ||
| 229 | } | ||
| 230 | |||
| 231 | inline _LIBCPP_HIDE_FROM_ABI size_t | ||
| 232 | __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) { | ||
| 233 | __locale_guard __current(__loc); | ||
| 234 | return std::mbsrtowcs(__dest, __src, __len, __ps); | ||
| 235 | } | ||
| 236 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 237 | #endif // _LIBCPP_BUILDING_LIBRARY | ||
| 238 | |||
| 239 | #ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs | ||
| 240 | _LIBCPP_HIDE_FROM_ABI | ||
| 241 | #endif | ||
| 242 | inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( | ||
| 243 | char* __s, size_t __n, __locale_t __loc, const char* __format, ...) { | ||
| 244 | va_list __va; | ||
| 245 | va_start(__va, __format); | ||
| 246 | __locale_guard __current(__loc); | ||
| 247 | int __res = std::vsnprintf(__s, __n, __format, __va); | ||
| 248 | va_end(__va); | ||
| 249 | return __res; | ||
| 250 | } | ||
| 251 | |||
| 252 | #ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs | ||
| 253 | _LIBCPP_HIDE_FROM_ABI | ||
| 254 | #endif | ||
| 255 | inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( | ||
| 256 | char** __s, __locale_t __loc, const char* __format, ...) { | ||
| 257 | va_list __va; | ||
| 258 | va_start(__va, __format); | ||
| 259 | __locale_guard __current(__loc); | ||
| 260 | int __res = ::vasprintf(__s, __format, __va); // non-standard | ||
| 261 | va_end(__va); | ||
| 262 | return __res; | ||
| 263 | } | ||
| 264 | |||
| 265 | #ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs | ||
| 266 | _LIBCPP_HIDE_FROM_ABI | ||
| 267 | #endif | ||
| 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 | ||
| 279 | _LIBCPP_END_NAMESPACE_STD | ||
| 280 | |||
| 281 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_LINUX_H | ||
lib/libcxx/include/__locale_dir/support/netbsd.h+2| ... | @@ -6,6 +6,8 @@ | ... | @@ -6,6 +6,8 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | /* zig patch: https://github.com/llvm/llvm-project/pull/143055 */ | ||
| 10 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H | 11 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H | 12 | #define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H |
| 11 | 13 |
lib/libcxx/include/__locale_dir/support/no_locale/characters.h-6| ... | @@ -29,12 +29,6 @@ namespace __locale { | ... | @@ -29,12 +29,6 @@ namespace __locale { |
| 29 | // | 29 | // |
| 30 | // Character manipulation functions | 30 | // Character manipulation functions |
| 31 | // | 31 | // |
| 32 | #if defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 33 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t) { return std::islower(__c); } | ||
| 34 | |||
| 35 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t) { return std::isupper(__c); } | ||
| 36 | #endif | ||
| 37 | |||
| 38 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t) { return std::isdigit(__c); } | 32 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t) { return std::isdigit(__c); } |
| 39 | 33 | ||
| 40 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t) { return std::isxdigit(__c); } | 34 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t) { return std::isxdigit(__c); } |
lib/libcxx/include/__locale_dir/support/windows.h+2-8| ... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | namespace __locale { | 30 | namespace __locale { |
| 31 | 31 | ||
| 32 | using __lconv_t = std::lconv; | 32 | using __lconv_t _LIBCPP_NODEBUG = std::lconv; |
| 33 | 33 | ||
| 34 | class __lconv_storage { | 34 | class __lconv_storage { |
| 35 | public: | 35 | public: |
| ... | @@ -197,12 +197,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | ... | @@ -197,12 +197,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { |
| 197 | // | 197 | // |
| 198 | // Character manipulation functions | 198 | // Character manipulation functions |
| 199 | // | 199 | // |
| 200 | #if defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 201 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return _islower_l(__c, __loc); } | ||
| 202 | |||
| 203 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return _isupper_l(__c, __loc); } | ||
| 204 | #endif | ||
| 205 | |||
| 206 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return _isdigit_l(__c, __loc); } | 200 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return _isdigit_l(__c, __loc); } |
| 207 | 201 | ||
| 208 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return _isxdigit_l(__c, __loc); } | 202 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return _isxdigit_l(__c, __loc); } |
| ... | @@ -317,7 +311,7 @@ struct __locale_guard { | ... | @@ -317,7 +311,7 @@ struct __locale_guard { |
| 317 | if (std::strcmp(__l.__get_locale(), __lc) != 0) { | 311 | if (std::strcmp(__l.__get_locale(), __lc) != 0) { |
| 318 | __locale_all = _strdup(__lc); | 312 | __locale_all = _strdup(__lc); |
| 319 | if (__locale_all == nullptr) | 313 | if (__locale_all == nullptr) |
| 320 | __throw_bad_alloc(); | 314 | std::__throw_bad_alloc(); |
| 321 | __locale::__setlocale(LC_ALL, __l.__get_locale()); | 315 | __locale::__setlocale(LC_ALL, __l.__get_locale()); |
| 322 | } | 316 | } |
| 323 | } | 317 | } |
lib/libcxx/include/__locale_dir/time.h created+766| ... | @@ -0,0 +1,766 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_TIME_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_TIME_H | ||
| 11 | |||
| 12 | #include <__algorithm/copy.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__locale_dir/get_c_locale.h> | ||
| 15 | #include <__locale_dir/scan_keyword.h> | ||
| 16 | #include <ios> | ||
| 17 | |||
| 18 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 19 | |||
| 20 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | # endif | ||
| 23 | |||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 25 | |||
| 26 | template <class _CharT, class _InputIterator> | ||
| 27 | _LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits( | ||
| 28 | _InputIterator& __b, _InputIterator __e, ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n) { | ||
| 29 | // Precondition: __n >= 1 | ||
| 30 | if (__b == __e) { | ||
| 31 | __err |= ios_base::eofbit | ios_base::failbit; | ||
| 32 | return 0; | ||
| 33 | } | ||
| 34 | // get first digit | ||
| 35 | _CharT __c = *__b; | ||
| 36 | if (!__ct.is(ctype_base::digit, __c)) { | ||
| 37 | __err |= ios_base::failbit; | ||
| 38 | return 0; | ||
| 39 | } | ||
| 40 | int __r = __ct.narrow(__c, 0) - '0'; | ||
| 41 | for (++__b, (void)--__n; __b != __e && __n > 0; ++__b, (void)--__n) { | ||
| 42 | // get next digit | ||
| 43 | __c = *__b; | ||
| 44 | if (!__ct.is(ctype_base::digit, __c)) | ||
| 45 | return __r; | ||
| 46 | __r = __r * 10 + __ct.narrow(__c, 0) - '0'; | ||
| 47 | } | ||
| 48 | if (__b == __e) | ||
| 49 | __err |= ios_base::eofbit; | ||
| 50 | return __r; | ||
| 51 | } | ||
| 52 | |||
| 53 | class _LIBCPP_EXPORTED_FROM_ABI time_base { | ||
| 54 | public: | ||
| 55 | enum dateorder { no_order, dmy, mdy, ymd, ydm }; | ||
| 56 | }; | ||
| 57 | |||
| 58 | template <class _CharT> | ||
| 59 | class __time_get_c_storage { | ||
| 60 | protected: | ||
| 61 | typedef basic_string<_CharT> string_type; | ||
| 62 | |||
| 63 | virtual const string_type* __weeks() const; | ||
| 64 | virtual const string_type* __months() const; | ||
| 65 | virtual const string_type* __am_pm() const; | ||
| 66 | virtual const string_type& __c() const; | ||
| 67 | virtual const string_type& __r() const; | ||
| 68 | virtual const string_type& __x() const; | ||
| 69 | virtual const string_type& __X() const; | ||
| 70 | |||
| 71 | _LIBCPP_HIDE_FROM_ABI ~__time_get_c_storage() {} | ||
| 72 | }; | ||
| 73 | |||
| 74 | template <> | ||
| 75 | _LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__weeks() const; | ||
| 76 | template <> | ||
| 77 | _LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__months() const; | ||
| 78 | template <> | ||
| 79 | _LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__am_pm() const; | ||
| 80 | template <> | ||
| 81 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__c() const; | ||
| 82 | template <> | ||
| 83 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__r() const; | ||
| 84 | template <> | ||
| 85 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const; | ||
| 86 | template <> | ||
| 87 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const; | ||
| 88 | |||
| 89 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 90 | template <> | ||
| 91 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const; | ||
| 92 | template <> | ||
| 93 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__months() const; | ||
| 94 | template <> | ||
| 95 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__am_pm() const; | ||
| 96 | template <> | ||
| 97 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__c() const; | ||
| 98 | template <> | ||
| 99 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__r() const; | ||
| 100 | template <> | ||
| 101 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const; | ||
| 102 | template <> | ||
| 103 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const; | ||
| 104 | # endif | ||
| 105 | |||
| 106 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | ||
| 107 | class time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { | ||
| 108 | public: | ||
| 109 | typedef _CharT char_type; | ||
| 110 | typedef _InputIterator iter_type; | ||
| 111 | typedef time_base::dateorder dateorder; | ||
| 112 | typedef basic_string<char_type> string_type; | ||
| 113 | |||
| 114 | _LIBCPP_HIDE_FROM_ABI explicit time_get(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 115 | |||
| 116 | _LIBCPP_HIDE_FROM_ABI dateorder date_order() const { return this->do_date_order(); } | ||
| 117 | |||
| 118 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 119 | get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 120 | return do_get_time(__b, __e, __iob, __err, __tm); | ||
| 121 | } | ||
| 122 | |||
| 123 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 124 | get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 125 | return do_get_date(__b, __e, __iob, __err, __tm); | ||
| 126 | } | ||
| 127 | |||
| 128 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 129 | get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 130 | return do_get_weekday(__b, __e, __iob, __err, __tm); | ||
| 131 | } | ||
| 132 | |||
| 133 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 134 | get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 135 | return do_get_monthname(__b, __e, __iob, __err, __tm); | ||
| 136 | } | ||
| 137 | |||
| 138 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 139 | get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 140 | return do_get_year(__b, __e, __iob, __err, __tm); | ||
| 141 | } | ||
| 142 | |||
| 143 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 144 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod = 0) | ||
| 145 | const { | ||
| 146 | return do_get(__b, __e, __iob, __err, __tm, __fmt, __mod); | ||
| 147 | } | ||
| 148 | |||
| 149 | iter_type | ||
| 150 | get(iter_type __b, | ||
| 151 | iter_type __e, | ||
| 152 | ios_base& __iob, | ||
| 153 | ios_base::iostate& __err, | ||
| 154 | tm* __tm, | ||
| 155 | const char_type* __fmtb, | ||
| 156 | const char_type* __fmte) const; | ||
| 157 | |||
| 158 | static locale::id id; | ||
| 159 | |||
| 160 | protected: | ||
| 161 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get() override {} | ||
| 162 | |||
| 163 | virtual dateorder do_date_order() const; | ||
| 164 | virtual iter_type | ||
| 165 | do_get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 166 | virtual iter_type | ||
| 167 | do_get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 168 | virtual iter_type | ||
| 169 | do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 170 | virtual iter_type | ||
| 171 | do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 172 | virtual iter_type | ||
| 173 | do_get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 174 | virtual iter_type do_get( | ||
| 175 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod) const; | ||
| 176 | |||
| 177 | private: | ||
| 178 | void __get_white_space(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 179 | void __get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 180 | |||
| 181 | void __get_weekdayname( | ||
| 182 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 183 | void __get_monthname( | ||
| 184 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 185 | void __get_day(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 186 | void | ||
| 187 | __get_month(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 188 | void | ||
| 189 | __get_year(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 190 | void | ||
| 191 | __get_year4(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 192 | void | ||
| 193 | __get_hour(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 194 | void | ||
| 195 | __get_12_hour(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 196 | void | ||
| 197 | __get_am_pm(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 198 | void | ||
| 199 | __get_minute(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 200 | void | ||
| 201 | __get_second(int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 202 | void | ||
| 203 | __get_weekday(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 204 | void __get_day_year_num( | ||
| 205 | int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 206 | }; | ||
| 207 | |||
| 208 | template <class _CharT, class _InputIterator> | ||
| 209 | locale::id time_get<_CharT, _InputIterator>::id; | ||
| 210 | |||
| 211 | // time_get primitives | ||
| 212 | |||
| 213 | template <class _CharT, class _InputIterator> | ||
| 214 | void time_get<_CharT, _InputIterator>::__get_weekdayname( | ||
| 215 | int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 216 | // Note: ignoring case comes from the POSIX strptime spec | ||
| 217 | const string_type* __wk = this->__weeks(); | ||
| 218 | ptrdiff_t __i = std::__scan_keyword(__b, __e, __wk, __wk + 14, __ct, __err, false) - __wk; | ||
| 219 | if (__i < 14) | ||
| 220 | __w = __i % 7; | ||
| 221 | } | ||
| 222 | |||
| 223 | template <class _CharT, class _InputIterator> | ||
| 224 | void time_get<_CharT, _InputIterator>::__get_monthname( | ||
| 225 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 226 | // Note: ignoring case comes from the POSIX strptime spec | ||
| 227 | const string_type* __month = this->__months(); | ||
| 228 | ptrdiff_t __i = std::__scan_keyword(__b, __e, __month, __month + 24, __ct, __err, false) - __month; | ||
| 229 | if (__i < 24) | ||
| 230 | __m = __i % 12; | ||
| 231 | } | ||
| 232 | |||
| 233 | template <class _CharT, class _InputIterator> | ||
| 234 | void time_get<_CharT, _InputIterator>::__get_day( | ||
| 235 | int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 236 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 237 | if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31) | ||
| 238 | __d = __t; | ||
| 239 | else | ||
| 240 | __err |= ios_base::failbit; | ||
| 241 | } | ||
| 242 | |||
| 243 | template <class _CharT, class _InputIterator> | ||
| 244 | void time_get<_CharT, _InputIterator>::__get_month( | ||
| 245 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 246 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1; | ||
| 247 | if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11) | ||
| 248 | __m = __t; | ||
| 249 | else | ||
| 250 | __err |= ios_base::failbit; | ||
| 251 | } | ||
| 252 | |||
| 253 | template <class _CharT, class _InputIterator> | ||
| 254 | void time_get<_CharT, _InputIterator>::__get_year( | ||
| 255 | int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 256 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4); | ||
| 257 | if (!(__err & ios_base::failbit)) { | ||
| 258 | if (__t < 69) | ||
| 259 | __t += 2000; | ||
| 260 | else if (69 <= __t && __t <= 99) | ||
| 261 | __t += 1900; | ||
| 262 | __y = __t - 1900; | ||
| 263 | } | ||
| 264 | } | ||
| 265 | |||
| 266 | template <class _CharT, class _InputIterator> | ||
| 267 | void time_get<_CharT, _InputIterator>::__get_year4( | ||
| 268 | int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 269 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4); | ||
| 270 | if (!(__err & ios_base::failbit)) | ||
| 271 | __y = __t - 1900; | ||
| 272 | } | ||
| 273 | |||
| 274 | template <class _CharT, class _InputIterator> | ||
| 275 | void time_get<_CharT, _InputIterator>::__get_hour( | ||
| 276 | int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 277 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 278 | if (!(__err & ios_base::failbit) && __t <= 23) | ||
| 279 | __h = __t; | ||
| 280 | else | ||
| 281 | __err |= ios_base::failbit; | ||
| 282 | } | ||
| 283 | |||
| 284 | template <class _CharT, class _InputIterator> | ||
| 285 | void time_get<_CharT, _InputIterator>::__get_12_hour( | ||
| 286 | int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 287 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 288 | if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12) | ||
| 289 | __h = __t; | ||
| 290 | else | ||
| 291 | __err |= ios_base::failbit; | ||
| 292 | } | ||
| 293 | |||
| 294 | template <class _CharT, class _InputIterator> | ||
| 295 | void time_get<_CharT, _InputIterator>::__get_minute( | ||
| 296 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 297 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 298 | if (!(__err & ios_base::failbit) && __t <= 59) | ||
| 299 | __m = __t; | ||
| 300 | else | ||
| 301 | __err |= ios_base::failbit; | ||
| 302 | } | ||
| 303 | |||
| 304 | template <class _CharT, class _InputIterator> | ||
| 305 | void time_get<_CharT, _InputIterator>::__get_second( | ||
| 306 | int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 307 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 308 | if (!(__err & ios_base::failbit) && __t <= 60) | ||
| 309 | __s = __t; | ||
| 310 | else | ||
| 311 | __err |= ios_base::failbit; | ||
| 312 | } | ||
| 313 | |||
| 314 | template <class _CharT, class _InputIterator> | ||
| 315 | void time_get<_CharT, _InputIterator>::__get_weekday( | ||
| 316 | int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 317 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 1); | ||
| 318 | if (!(__err & ios_base::failbit) && __t <= 6) | ||
| 319 | __w = __t; | ||
| 320 | else | ||
| 321 | __err |= ios_base::failbit; | ||
| 322 | } | ||
| 323 | |||
| 324 | template <class _CharT, class _InputIterator> | ||
| 325 | void time_get<_CharT, _InputIterator>::__get_day_year_num( | ||
| 326 | int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 327 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 3); | ||
| 328 | if (!(__err & ios_base::failbit) && __t <= 365) | ||
| 329 | __d = __t; | ||
| 330 | else | ||
| 331 | __err |= ios_base::failbit; | ||
| 332 | } | ||
| 333 | |||
| 334 | template <class _CharT, class _InputIterator> | ||
| 335 | void time_get<_CharT, _InputIterator>::__get_white_space( | ||
| 336 | iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 337 | for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b) | ||
| 338 | ; | ||
| 339 | if (__b == __e) | ||
| 340 | __err |= ios_base::eofbit; | ||
| 341 | } | ||
| 342 | |||
| 343 | template <class _CharT, class _InputIterator> | ||
| 344 | void time_get<_CharT, _InputIterator>::__get_am_pm( | ||
| 345 | int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 346 | const string_type* __ap = this->__am_pm(); | ||
| 347 | if (__ap[0].size() + __ap[1].size() == 0) { | ||
| 348 | __err |= ios_base::failbit; | ||
| 349 | return; | ||
| 350 | } | ||
| 351 | ptrdiff_t __i = std::__scan_keyword(__b, __e, __ap, __ap + 2, __ct, __err, false) - __ap; | ||
| 352 | if (__i == 0 && __h == 12) | ||
| 353 | __h = 0; | ||
| 354 | else if (__i == 1 && __h < 12) | ||
| 355 | __h += 12; | ||
| 356 | } | ||
| 357 | |||
| 358 | template <class _CharT, class _InputIterator> | ||
| 359 | void time_get<_CharT, _InputIterator>::__get_percent( | ||
| 360 | iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 361 | if (__b == __e) { | ||
| 362 | __err |= ios_base::eofbit | ios_base::failbit; | ||
| 363 | return; | ||
| 364 | } | ||
| 365 | if (__ct.narrow(*__b, 0) != '%') | ||
| 366 | __err |= ios_base::failbit; | ||
| 367 | else if (++__b == __e) | ||
| 368 | __err |= ios_base::eofbit; | ||
| 369 | } | ||
| 370 | |||
| 371 | // time_get end primitives | ||
| 372 | |||
| 373 | template <class _CharT, class _InputIterator> | ||
| 374 | _InputIterator time_get<_CharT, _InputIterator>::get( | ||
| 375 | iter_type __b, | ||
| 376 | iter_type __e, | ||
| 377 | ios_base& __iob, | ||
| 378 | ios_base::iostate& __err, | ||
| 379 | tm* __tm, | ||
| 380 | const char_type* __fmtb, | ||
| 381 | const char_type* __fmte) const { | ||
| 382 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 383 | __err = ios_base::goodbit; | ||
| 384 | while (__fmtb != __fmte && __err == ios_base::goodbit) { | ||
| 385 | if (__b == __e) { | ||
| 386 | __err = ios_base::failbit; | ||
| 387 | break; | ||
| 388 | } | ||
| 389 | if (__ct.narrow(*__fmtb, 0) == '%') { | ||
| 390 | if (++__fmtb == __fmte) { | ||
| 391 | __err = ios_base::failbit; | ||
| 392 | break; | ||
| 393 | } | ||
| 394 | char __cmd = __ct.narrow(*__fmtb, 0); | ||
| 395 | char __opt = '\0'; | ||
| 396 | if (__cmd == 'E' || __cmd == '0') { | ||
| 397 | if (++__fmtb == __fmte) { | ||
| 398 | __err = ios_base::failbit; | ||
| 399 | break; | ||
| 400 | } | ||
| 401 | __opt = __cmd; | ||
| 402 | __cmd = __ct.narrow(*__fmtb, 0); | ||
| 403 | } | ||
| 404 | __b = do_get(__b, __e, __iob, __err, __tm, __cmd, __opt); | ||
| 405 | ++__fmtb; | ||
| 406 | } else if (__ct.is(ctype_base::space, *__fmtb)) { | ||
| 407 | for (++__fmtb; __fmtb != __fmte && __ct.is(ctype_base::space, *__fmtb); ++__fmtb) | ||
| 408 | ; | ||
| 409 | for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b) | ||
| 410 | ; | ||
| 411 | } else if (__ct.toupper(*__b) == __ct.toupper(*__fmtb)) { | ||
| 412 | ++__b; | ||
| 413 | ++__fmtb; | ||
| 414 | } else | ||
| 415 | __err = ios_base::failbit; | ||
| 416 | } | ||
| 417 | if (__b == __e) | ||
| 418 | __err |= ios_base::eofbit; | ||
| 419 | return __b; | ||
| 420 | } | ||
| 421 | |||
| 422 | template <class _CharT, class _InputIterator> | ||
| 423 | typename time_get<_CharT, _InputIterator>::dateorder time_get<_CharT, _InputIterator>::do_date_order() const { | ||
| 424 | return mdy; | ||
| 425 | } | ||
| 426 | |||
| 427 | template <class _CharT, class _InputIterator> | ||
| 428 | _InputIterator time_get<_CharT, _InputIterator>::do_get_time( | ||
| 429 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 430 | const char_type __fmt[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'}; | ||
| 431 | return get(__b, __e, __iob, __err, __tm, __fmt, __fmt + sizeof(__fmt) / sizeof(__fmt[0])); | ||
| 432 | } | ||
| 433 | |||
| 434 | template <class _CharT, class _InputIterator> | ||
| 435 | _InputIterator time_get<_CharT, _InputIterator>::do_get_date( | ||
| 436 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 437 | const string_type& __fmt = this->__x(); | ||
| 438 | return get(__b, __e, __iob, __err, __tm, __fmt.data(), __fmt.data() + __fmt.size()); | ||
| 439 | } | ||
| 440 | |||
| 441 | template <class _CharT, class _InputIterator> | ||
| 442 | _InputIterator time_get<_CharT, _InputIterator>::do_get_weekday( | ||
| 443 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 444 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 445 | __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct); | ||
| 446 | return __b; | ||
| 447 | } | ||
| 448 | |||
| 449 | template <class _CharT, class _InputIterator> | ||
| 450 | _InputIterator time_get<_CharT, _InputIterator>::do_get_monthname( | ||
| 451 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 452 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 453 | __get_monthname(__tm->tm_mon, __b, __e, __err, __ct); | ||
| 454 | return __b; | ||
| 455 | } | ||
| 456 | |||
| 457 | template <class _CharT, class _InputIterator> | ||
| 458 | _InputIterator time_get<_CharT, _InputIterator>::do_get_year( | ||
| 459 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 460 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 461 | __get_year(__tm->tm_year, __b, __e, __err, __ct); | ||
| 462 | return __b; | ||
| 463 | } | ||
| 464 | |||
| 465 | template <class _CharT, class _InputIterator> | ||
| 466 | _InputIterator time_get<_CharT, _InputIterator>::do_get( | ||
| 467 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char) const { | ||
| 468 | __err = ios_base::goodbit; | ||
| 469 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 470 | switch (__fmt) { | ||
| 471 | case 'a': | ||
| 472 | case 'A': | ||
| 473 | __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct); | ||
| 474 | break; | ||
| 475 | case 'b': | ||
| 476 | case 'B': | ||
| 477 | case 'h': | ||
| 478 | __get_monthname(__tm->tm_mon, __b, __e, __err, __ct); | ||
| 479 | break; | ||
| 480 | case 'c': { | ||
| 481 | const string_type& __fm = this->__c(); | ||
| 482 | __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size()); | ||
| 483 | } break; | ||
| 484 | case 'd': | ||
| 485 | case 'e': | ||
| 486 | __get_day(__tm->tm_mday, __b, __e, __err, __ct); | ||
| 487 | break; | ||
| 488 | case 'D': { | ||
| 489 | const char_type __fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'}; | ||
| 490 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 491 | } break; | ||
| 492 | case 'F': { | ||
| 493 | const char_type __fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'}; | ||
| 494 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 495 | } break; | ||
| 496 | case 'H': | ||
| 497 | __get_hour(__tm->tm_hour, __b, __e, __err, __ct); | ||
| 498 | break; | ||
| 499 | case 'I': | ||
| 500 | __get_12_hour(__tm->tm_hour, __b, __e, __err, __ct); | ||
| 501 | break; | ||
| 502 | case 'j': | ||
| 503 | __get_day_year_num(__tm->tm_yday, __b, __e, __err, __ct); | ||
| 504 | break; | ||
| 505 | case 'm': | ||
| 506 | __get_month(__tm->tm_mon, __b, __e, __err, __ct); | ||
| 507 | break; | ||
| 508 | case 'M': | ||
| 509 | __get_minute(__tm->tm_min, __b, __e, __err, __ct); | ||
| 510 | break; | ||
| 511 | case 'n': | ||
| 512 | case 't': | ||
| 513 | __get_white_space(__b, __e, __err, __ct); | ||
| 514 | break; | ||
| 515 | case 'p': | ||
| 516 | __get_am_pm(__tm->tm_hour, __b, __e, __err, __ct); | ||
| 517 | break; | ||
| 518 | case 'r': { | ||
| 519 | const char_type __fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'}; | ||
| 520 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 521 | } break; | ||
| 522 | case 'R': { | ||
| 523 | const char_type __fm[] = {'%', 'H', ':', '%', 'M'}; | ||
| 524 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 525 | } break; | ||
| 526 | case 'S': | ||
| 527 | __get_second(__tm->tm_sec, __b, __e, __err, __ct); | ||
| 528 | break; | ||
| 529 | case 'T': { | ||
| 530 | const char_type __fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'}; | ||
| 531 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 532 | } break; | ||
| 533 | case 'w': | ||
| 534 | __get_weekday(__tm->tm_wday, __b, __e, __err, __ct); | ||
| 535 | break; | ||
| 536 | case 'x': | ||
| 537 | return do_get_date(__b, __e, __iob, __err, __tm); | ||
| 538 | case 'X': { | ||
| 539 | const string_type& __fm = this->__X(); | ||
| 540 | __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size()); | ||
| 541 | } break; | ||
| 542 | case 'y': | ||
| 543 | __get_year(__tm->tm_year, __b, __e, __err, __ct); | ||
| 544 | break; | ||
| 545 | case 'Y': | ||
| 546 | __get_year4(__tm->tm_year, __b, __e, __err, __ct); | ||
| 547 | break; | ||
| 548 | case '%': | ||
| 549 | __get_percent(__b, __e, __err, __ct); | ||
| 550 | break; | ||
| 551 | default: | ||
| 552 | __err |= ios_base::failbit; | ||
| 553 | } | ||
| 554 | return __b; | ||
| 555 | } | ||
| 556 | |||
| 557 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>; | ||
| 558 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 559 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>; | ||
| 560 | # endif | ||
| 561 | |||
| 562 | class _LIBCPP_EXPORTED_FROM_ABI __time_get { | ||
| 563 | protected: | ||
| 564 | __locale::__locale_t __loc_; | ||
| 565 | |||
| 566 | __time_get(const char* __nm); | ||
| 567 | __time_get(const string& __nm); | ||
| 568 | ~__time_get(); | ||
| 569 | }; | ||
| 570 | |||
| 571 | template <class _CharT> | ||
| 572 | class __time_get_storage : public __time_get { | ||
| 573 | protected: | ||
| 574 | typedef basic_string<_CharT> string_type; | ||
| 575 | |||
| 576 | string_type __weeks_[14]; | ||
| 577 | string_type __months_[24]; | ||
| 578 | string_type __am_pm_[2]; | ||
| 579 | string_type __c_; | ||
| 580 | string_type __r_; | ||
| 581 | string_type __x_; | ||
| 582 | string_type __X_; | ||
| 583 | |||
| 584 | explicit __time_get_storage(const char* __nm); | ||
| 585 | explicit __time_get_storage(const string& __nm); | ||
| 586 | |||
| 587 | _LIBCPP_HIDE_FROM_ABI ~__time_get_storage() {} | ||
| 588 | |||
| 589 | time_base::dateorder __do_date_order() const; | ||
| 590 | |||
| 591 | private: | ||
| 592 | void init(const ctype<_CharT>&); | ||
| 593 | string_type __analyze(char __fmt, const ctype<_CharT>&); | ||
| 594 | }; | ||
| 595 | |||
| 596 | # define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ | ||
| 597 | template <> \ | ||
| 598 | _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ | ||
| 599 | template <> \ | ||
| 600 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | ||
| 601 | template <> \ | ||
| 602 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | ||
| 603 | template <> \ | ||
| 604 | _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | ||
| 605 | template <> \ | ||
| 606 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ | ||
| 607 | char, const ctype<_CharT>&); \ | ||
| 608 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ | ||
| 609 | const; \ | ||
| 610 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | ||
| 611 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | ||
| 612 | extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | ||
| 613 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ | ||
| 614 | __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); | ||
| 615 | |||
| 616 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) | ||
| 617 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 618 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t) | ||
| 619 | # endif | ||
| 620 | # undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION | ||
| 621 | |||
| 622 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | ||
| 623 | class time_get_byname : public time_get<_CharT, _InputIterator>, private __time_get_storage<_CharT> { | ||
| 624 | public: | ||
| 625 | typedef time_base::dateorder dateorder; | ||
| 626 | typedef _InputIterator iter_type; | ||
| 627 | typedef _CharT char_type; | ||
| 628 | typedef basic_string<char_type> string_type; | ||
| 629 | |||
| 630 | _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const char* __nm, size_t __refs = 0) | ||
| 631 | : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {} | ||
| 632 | _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const string& __nm, size_t __refs = 0) | ||
| 633 | : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {} | ||
| 634 | |||
| 635 | protected: | ||
| 636 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get_byname() override {} | ||
| 637 | |||
| 638 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL dateorder do_date_order() const override { return this->__do_date_order(); } | ||
| 639 | |||
| 640 | private: | ||
| 641 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __weeks() const override { return this->__weeks_; } | ||
| 642 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __months() const override { return this->__months_; } | ||
| 643 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __am_pm() const override { return this->__am_pm_; } | ||
| 644 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __c() const override { return this->__c_; } | ||
| 645 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __r() const override { return this->__r_; } | ||
| 646 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __x() const override { return this->__x_; } | ||
| 647 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __X() const override { return this->__X_; } | ||
| 648 | }; | ||
| 649 | |||
| 650 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>; | ||
| 651 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 652 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>; | ||
| 653 | # endif | ||
| 654 | |||
| 655 | class _LIBCPP_EXPORTED_FROM_ABI __time_put { | ||
| 656 | __locale::__locale_t __loc_; | ||
| 657 | |||
| 658 | protected: | ||
| 659 | _LIBCPP_HIDE_FROM_ABI __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {} | ||
| 660 | __time_put(const char* __nm); | ||
| 661 | __time_put(const string& __nm); | ||
| 662 | ~__time_put(); | ||
| 663 | void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; | ||
| 664 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 665 | void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; | ||
| 666 | # endif | ||
| 667 | }; | ||
| 668 | |||
| 669 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 670 | class time_put : public locale::facet, private __time_put { | ||
| 671 | public: | ||
| 672 | typedef _CharT char_type; | ||
| 673 | typedef _OutputIterator iter_type; | ||
| 674 | |||
| 675 | _LIBCPP_HIDE_FROM_ABI explicit time_put(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 676 | |||
| 677 | iter_type | ||
| 678 | put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe) | ||
| 679 | const; | ||
| 680 | |||
| 681 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 682 | put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, char __fmt, char __mod = 0) const { | ||
| 683 | return do_put(__s, __iob, __fl, __tm, __fmt, __mod); | ||
| 684 | } | ||
| 685 | |||
| 686 | static locale::id id; | ||
| 687 | |||
| 688 | protected: | ||
| 689 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put() override {} | ||
| 690 | virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const; | ||
| 691 | |||
| 692 | _LIBCPP_HIDE_FROM_ABI explicit time_put(const char* __nm, size_t __refs) : locale::facet(__refs), __time_put(__nm) {} | ||
| 693 | _LIBCPP_HIDE_FROM_ABI explicit time_put(const string& __nm, size_t __refs) | ||
| 694 | : locale::facet(__refs), __time_put(__nm) {} | ||
| 695 | }; | ||
| 696 | |||
| 697 | template <class _CharT, class _OutputIterator> | ||
| 698 | locale::id time_put<_CharT, _OutputIterator>::id; | ||
| 699 | |||
| 700 | template <class _CharT, class _OutputIterator> | ||
| 701 | _OutputIterator time_put<_CharT, _OutputIterator>::put( | ||
| 702 | iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe) | ||
| 703 | const { | ||
| 704 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 705 | for (; __pb != __pe; ++__pb) { | ||
| 706 | if (__ct.narrow(*__pb, 0) == '%') { | ||
| 707 | if (++__pb == __pe) { | ||
| 708 | *__s++ = __pb[-1]; | ||
| 709 | break; | ||
| 710 | } | ||
| 711 | char __mod = 0; | ||
| 712 | char __fmt = __ct.narrow(*__pb, 0); | ||
| 713 | if (__fmt == 'E' || __fmt == 'O') { | ||
| 714 | if (++__pb == __pe) { | ||
| 715 | *__s++ = __pb[-2]; | ||
| 716 | *__s++ = __pb[-1]; | ||
| 717 | break; | ||
| 718 | } | ||
| 719 | __mod = __fmt; | ||
| 720 | __fmt = __ct.narrow(*__pb, 0); | ||
| 721 | } | ||
| 722 | __s = do_put(__s, __iob, __fl, __tm, __fmt, __mod); | ||
| 723 | } else | ||
| 724 | *__s++ = *__pb; | ||
| 725 | } | ||
| 726 | return __s; | ||
| 727 | } | ||
| 728 | |||
| 729 | template <class _CharT, class _OutputIterator> | ||
| 730 | _OutputIterator time_put<_CharT, _OutputIterator>::do_put( | ||
| 731 | iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const { | ||
| 732 | char_type __nar[100]; | ||
| 733 | char_type* __nb = __nar; | ||
| 734 | char_type* __ne = __nb + 100; | ||
| 735 | __do_put(__nb, __ne, __tm, __fmt, __mod); | ||
| 736 | return std::copy(__nb, __ne, __s); | ||
| 737 | } | ||
| 738 | |||
| 739 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>; | ||
| 740 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 741 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>; | ||
| 742 | # endif | ||
| 743 | |||
| 744 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 745 | class time_put_byname : public time_put<_CharT, _OutputIterator> { | ||
| 746 | public: | ||
| 747 | _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const char* __nm, size_t __refs = 0) | ||
| 748 | : time_put<_CharT, _OutputIterator>(__nm, __refs) {} | ||
| 749 | |||
| 750 | _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const string& __nm, size_t __refs = 0) | ||
| 751 | : time_put<_CharT, _OutputIterator>(__nm, __refs) {} | ||
| 752 | |||
| 753 | protected: | ||
| 754 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put_byname() override {} | ||
| 755 | }; | ||
| 756 | |||
| 757 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>; | ||
| 758 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 759 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>; | ||
| 760 | # endif | ||
| 761 | |||
| 762 | _LIBCPP_END_NAMESPACE_STD | ||
| 763 | |||
| 764 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 765 | |||
| 766 | #endif // _LIBCPP___LOCALE_DIR_TIME_H | ||
lib/libcxx/include/__locale_dir/wbuffer_convert.h created+430| ... | @@ -0,0 +1,430 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_WBUFFER_CONVERT_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_WBUFFER_CONVERT_H | ||
| 11 | |||
| 12 | #include <__algorithm/reverse.h> | ||
| 13 | #include <__config> | ||
| 14 | #include <__string/char_traits.h> | ||
| 15 | #include <ios> | ||
| 16 | #include <streambuf> | ||
| 17 | |||
| 18 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 19 | |||
| 20 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 21 | # pragma GCC system_header | ||
| 22 | # endif | ||
| 23 | |||
| 24 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 25 | |||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | # include <__undef_macros> | ||
| 28 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 30 | |||
| 31 | template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> > | ||
| 32 | class _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert : public basic_streambuf<_Elem, _Tr> { | ||
| 33 | public: | ||
| 34 | // types: | ||
| 35 | typedef _Elem char_type; | ||
| 36 | typedef _Tr traits_type; | ||
| 37 | typedef typename traits_type::int_type int_type; | ||
| 38 | typedef typename traits_type::pos_type pos_type; | ||
| 39 | typedef typename traits_type::off_type off_type; | ||
| 40 | typedef typename _Codecvt::state_type state_type; | ||
| 41 | |||
| 42 | private: | ||
| 43 | char* __extbuf_; | ||
| 44 | const char* __extbufnext_; | ||
| 45 | const char* __extbufend_; | ||
| 46 | char __extbuf_min_[8]; | ||
| 47 | size_t __ebs_; | ||
| 48 | char_type* __intbuf_; | ||
| 49 | size_t __ibs_; | ||
| 50 | streambuf* __bufptr_; | ||
| 51 | _Codecvt* __cv_; | ||
| 52 | state_type __st_; | ||
| 53 | ios_base::openmode __cm_; | ||
| 54 | bool __owns_eb_; | ||
| 55 | bool __owns_ib_; | ||
| 56 | bool __always_noconv_; | ||
| 57 | |||
| 58 | public: | ||
| 59 | # ifndef _LIBCPP_CXX03_LANG | ||
| 60 | _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {} | ||
| 61 | explicit _LIBCPP_HIDE_FROM_ABI | ||
| 62 | wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); | ||
| 63 | # else | ||
| 64 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI | ||
| 65 | wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); | ||
| 66 | # endif | ||
| 67 | |||
| 68 | _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert(); | ||
| 69 | |||
| 70 | _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf() const { return __bufptr_; } | ||
| 71 | _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf(streambuf* __bytebuf) { | ||
| 72 | streambuf* __r = __bufptr_; | ||
| 73 | __bufptr_ = __bytebuf; | ||
| 74 | return __r; | ||
| 75 | } | ||
| 76 | |||
| 77 | wbuffer_convert(const wbuffer_convert&) = delete; | ||
| 78 | wbuffer_convert& operator=(const wbuffer_convert&) = delete; | ||
| 79 | |||
| 80 | _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; } | ||
| 81 | |||
| 82 | protected: | ||
| 83 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type underflow(); | ||
| 84 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type pbackfail(int_type __c = traits_type::eof()); | ||
| 85 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type overflow(int_type __c = traits_type::eof()); | ||
| 86 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n); | ||
| 87 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type | ||
| 88 | seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch = ios_base::in | ios_base::out); | ||
| 89 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type | ||
| 90 | seekpos(pos_type __sp, ios_base::openmode __wch = ios_base::in | ios_base::out); | ||
| 91 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int sync(); | ||
| 92 | |||
| 93 | private: | ||
| 94 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool __read_mode(); | ||
| 95 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __write_mode(); | ||
| 96 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL wbuffer_convert* __close(); | ||
| 97 | }; | ||
| 98 | |||
| 99 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 100 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 101 | wbuffer_convert<_Codecvt, _Elem, _Tr>::wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state) | ||
| 102 | : __extbuf_(nullptr), | ||
| 103 | __extbufnext_(nullptr), | ||
| 104 | __extbufend_(nullptr), | ||
| 105 | __ebs_(0), | ||
| 106 | __intbuf_(0), | ||
| 107 | __ibs_(0), | ||
| 108 | __bufptr_(__bytebuf), | ||
| 109 | __cv_(__pcvt), | ||
| 110 | __st_(__state), | ||
| 111 | __cm_(0), | ||
| 112 | __owns_eb_(false), | ||
| 113 | __owns_ib_(false), | ||
| 114 | __always_noconv_(__cv_ ? __cv_->always_noconv() : false) { | ||
| 115 | setbuf(0, 4096); | ||
| 116 | } | ||
| 117 | |||
| 118 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 119 | wbuffer_convert<_Codecvt, _Elem, _Tr>::~wbuffer_convert() { | ||
| 120 | __close(); | ||
| 121 | delete __cv_; | ||
| 122 | if (__owns_eb_) | ||
| 123 | delete[] __extbuf_; | ||
| 124 | if (__owns_ib_) | ||
| 125 | delete[] __intbuf_; | ||
| 126 | } | ||
| 127 | |||
| 128 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 129 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() { | ||
| 130 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 131 | if (__cv_ == 0 || __bufptr_ == nullptr) | ||
| 132 | return traits_type::eof(); | ||
| 133 | bool __initial = __read_mode(); | ||
| 134 | char_type __1buf; | ||
| 135 | if (this->gptr() == 0) | ||
| 136 | this->setg(std::addressof(__1buf), std::addressof(__1buf) + 1, std::addressof(__1buf) + 1); | ||
| 137 | const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4); | ||
| 138 | int_type __c = traits_type::eof(); | ||
| 139 | if (this->gptr() == this->egptr()) { | ||
| 140 | std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); | ||
| 141 | if (__always_noconv_) { | ||
| 142 | streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz); | ||
| 143 | __nmemb = __bufptr_->sgetn((char*)this->eback() + __unget_sz, __nmemb); | ||
| 144 | if (__nmemb != 0) { | ||
| 145 | this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb); | ||
| 146 | __c = *this->gptr(); | ||
| 147 | } | ||
| 148 | } else { | ||
| 149 | if (__extbufend_ != __extbufnext_) { | ||
| 150 | _LIBCPP_ASSERT_NON_NULL(__extbufnext_ != nullptr, "underflow moving from nullptr"); | ||
| 151 | _LIBCPP_ASSERT_NON_NULL(__extbuf_ != nullptr, "underflow moving into nullptr"); | ||
| 152 | std::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); | ||
| 153 | } | ||
| 154 | __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); | ||
| 155 | __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); | ||
| 156 | streamsize __nmemb = std::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz), | ||
| 157 | static_cast<streamsize>(__extbufend_ - __extbufnext_)); | ||
| 158 | codecvt_base::result __r; | ||
| 159 | // FIXME: Do we ever need to restore the state here? | ||
| 160 | // state_type __svs = __st_; | ||
| 161 | streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb); | ||
| 162 | if (__nr != 0) { | ||
| 163 | __extbufend_ = __extbufnext_ + __nr; | ||
| 164 | char_type* __inext; | ||
| 165 | __r = __cv_->in( | ||
| 166 | __st_, __extbuf_, __extbufend_, __extbufnext_, this->eback() + __unget_sz, this->egptr(), __inext); | ||
| 167 | if (__r == codecvt_base::noconv) { | ||
| 168 | this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)const_cast<char*>(__extbufend_)); | ||
| 169 | __c = *this->gptr(); | ||
| 170 | } else if (__inext != this->eback() + __unget_sz) { | ||
| 171 | this->setg(this->eback(), this->eback() + __unget_sz, __inext); | ||
| 172 | __c = *this->gptr(); | ||
| 173 | } | ||
| 174 | } | ||
| 175 | } | ||
| 176 | } else | ||
| 177 | __c = *this->gptr(); | ||
| 178 | if (this->eback() == std::addressof(__1buf)) | ||
| 179 | this->setg(0, 0, 0); | ||
| 180 | return __c; | ||
| 181 | } | ||
| 182 | |||
| 183 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 184 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 185 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type | ||
| 186 | wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) { | ||
| 187 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 188 | if (__cv_ != 0 && __bufptr_ && this->eback() < this->gptr()) { | ||
| 189 | if (traits_type::eq_int_type(__c, traits_type::eof())) { | ||
| 190 | this->gbump(-1); | ||
| 191 | return traits_type::not_eof(__c); | ||
| 192 | } | ||
| 193 | if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) { | ||
| 194 | this->gbump(-1); | ||
| 195 | *this->gptr() = traits_type::to_char_type(__c); | ||
| 196 | return __c; | ||
| 197 | } | ||
| 198 | } | ||
| 199 | return traits_type::eof(); | ||
| 200 | } | ||
| 201 | |||
| 202 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 203 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 204 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) { | ||
| 205 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 206 | if (__cv_ == 0 || !__bufptr_) | ||
| 207 | return traits_type::eof(); | ||
| 208 | __write_mode(); | ||
| 209 | char_type __1buf; | ||
| 210 | char_type* __pb_save = this->pbase(); | ||
| 211 | char_type* __epb_save = this->epptr(); | ||
| 212 | if (!traits_type::eq_int_type(__c, traits_type::eof())) { | ||
| 213 | if (this->pptr() == 0) | ||
| 214 | this->setp(std::addressof(__1buf), std::addressof(__1buf) + 1); | ||
| 215 | *this->pptr() = traits_type::to_char_type(__c); | ||
| 216 | this->pbump(1); | ||
| 217 | } | ||
| 218 | if (this->pptr() != this->pbase()) { | ||
| 219 | if (__always_noconv_) { | ||
| 220 | streamsize __nmemb = static_cast<streamsize>(this->pptr() - this->pbase()); | ||
| 221 | if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb) | ||
| 222 | return traits_type::eof(); | ||
| 223 | } else { | ||
| 224 | char* __extbe = __extbuf_; | ||
| 225 | codecvt_base::result __r; | ||
| 226 | do { | ||
| 227 | const char_type* __e; | ||
| 228 | __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe); | ||
| 229 | if (__e == this->pbase()) | ||
| 230 | return traits_type::eof(); | ||
| 231 | if (__r == codecvt_base::noconv) { | ||
| 232 | streamsize __nmemb = static_cast<size_t>(this->pptr() - this->pbase()); | ||
| 233 | if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb) | ||
| 234 | return traits_type::eof(); | ||
| 235 | } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) { | ||
| 236 | streamsize __nmemb = static_cast<size_t>(__extbe - __extbuf_); | ||
| 237 | if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb) | ||
| 238 | return traits_type::eof(); | ||
| 239 | if (__r == codecvt_base::partial) { | ||
| 240 | this->setp(const_cast<char_type*>(__e), this->pptr()); | ||
| 241 | this->__pbump(this->epptr() - this->pbase()); | ||
| 242 | } | ||
| 243 | } else | ||
| 244 | return traits_type::eof(); | ||
| 245 | } while (__r == codecvt_base::partial); | ||
| 246 | } | ||
| 247 | this->setp(__pb_save, __epb_save); | ||
| 248 | } | ||
| 249 | return traits_type::not_eof(__c); | ||
| 250 | } | ||
| 251 | |||
| 252 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 253 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 254 | basic_streambuf<_Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) { | ||
| 255 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 256 | this->setg(0, 0, 0); | ||
| 257 | this->setp(0, 0); | ||
| 258 | if (__owns_eb_) | ||
| 259 | delete[] __extbuf_; | ||
| 260 | if (__owns_ib_) | ||
| 261 | delete[] __intbuf_; | ||
| 262 | __ebs_ = __n; | ||
| 263 | if (__ebs_ > sizeof(__extbuf_min_)) { | ||
| 264 | if (__always_noconv_ && __s) { | ||
| 265 | __extbuf_ = (char*)__s; | ||
| 266 | __owns_eb_ = false; | ||
| 267 | } else { | ||
| 268 | __extbuf_ = new char[__ebs_]; | ||
| 269 | __owns_eb_ = true; | ||
| 270 | } | ||
| 271 | } else { | ||
| 272 | __extbuf_ = __extbuf_min_; | ||
| 273 | __ebs_ = sizeof(__extbuf_min_); | ||
| 274 | __owns_eb_ = false; | ||
| 275 | } | ||
| 276 | if (!__always_noconv_) { | ||
| 277 | __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_)); | ||
| 278 | if (__s && __ibs_ >= sizeof(__extbuf_min_)) { | ||
| 279 | __intbuf_ = __s; | ||
| 280 | __owns_ib_ = false; | ||
| 281 | } else { | ||
| 282 | __intbuf_ = new char_type[__ibs_]; | ||
| 283 | __owns_ib_ = true; | ||
| 284 | } | ||
| 285 | } else { | ||
| 286 | __ibs_ = 0; | ||
| 287 | __intbuf_ = 0; | ||
| 288 | __owns_ib_ = false; | ||
| 289 | } | ||
| 290 | return this; | ||
| 291 | } | ||
| 292 | |||
| 293 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 294 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 295 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type | ||
| 296 | wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __om) { | ||
| 297 | int __width = __cv_->encoding(); | ||
| 298 | if (__cv_ == 0 || !__bufptr_ || (__width <= 0 && __off != 0) || sync()) | ||
| 299 | return pos_type(off_type(-1)); | ||
| 300 | // __width > 0 || __off == 0, now check __way | ||
| 301 | if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end) | ||
| 302 | return pos_type(off_type(-1)); | ||
| 303 | pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om); | ||
| 304 | __r.state(__st_); | ||
| 305 | return __r; | ||
| 306 | } | ||
| 307 | |||
| 308 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 309 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type | ||
| 310 | wbuffer_convert<_Codecvt, _Elem, _Tr>::seekpos(pos_type __sp, ios_base::openmode __wch) { | ||
| 311 | if (__cv_ == 0 || !__bufptr_ || sync()) | ||
| 312 | return pos_type(off_type(-1)); | ||
| 313 | if (__bufptr_->pubseekpos(__sp, __wch) == pos_type(off_type(-1))) | ||
| 314 | return pos_type(off_type(-1)); | ||
| 315 | return __sp; | ||
| 316 | } | ||
| 317 | |||
| 318 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 319 | int wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() { | ||
| 320 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 321 | if (__cv_ == 0 || !__bufptr_) | ||
| 322 | return 0; | ||
| 323 | if (__cm_ & ios_base::out) { | ||
| 324 | if (this->pptr() != this->pbase()) | ||
| 325 | if (overflow() == traits_type::eof()) | ||
| 326 | return -1; | ||
| 327 | codecvt_base::result __r; | ||
| 328 | do { | ||
| 329 | char* __extbe; | ||
| 330 | __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe); | ||
| 331 | streamsize __nmemb = static_cast<streamsize>(__extbe - __extbuf_); | ||
| 332 | if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb) | ||
| 333 | return -1; | ||
| 334 | } while (__r == codecvt_base::partial); | ||
| 335 | if (__r == codecvt_base::error) | ||
| 336 | return -1; | ||
| 337 | if (__bufptr_->pubsync()) | ||
| 338 | return -1; | ||
| 339 | } else if (__cm_ & ios_base::in) { | ||
| 340 | off_type __c; | ||
| 341 | if (__always_noconv_) | ||
| 342 | __c = this->egptr() - this->gptr(); | ||
| 343 | else { | ||
| 344 | int __width = __cv_->encoding(); | ||
| 345 | __c = __extbufend_ - __extbufnext_; | ||
| 346 | if (__width > 0) | ||
| 347 | __c += __width * (this->egptr() - this->gptr()); | ||
| 348 | else { | ||
| 349 | if (this->gptr() != this->egptr()) { | ||
| 350 | std::reverse(this->gptr(), this->egptr()); | ||
| 351 | codecvt_base::result __r; | ||
| 352 | const char_type* __e = this->gptr(); | ||
| 353 | char* __extbe; | ||
| 354 | do { | ||
| 355 | __r = __cv_->out(__st_, __e, this->egptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe); | ||
| 356 | switch (__r) { | ||
| 357 | case codecvt_base::noconv: | ||
| 358 | __c += this->egptr() - this->gptr(); | ||
| 359 | break; | ||
| 360 | case codecvt_base::ok: | ||
| 361 | case codecvt_base::partial: | ||
| 362 | __c += __extbe - __extbuf_; | ||
| 363 | break; | ||
| 364 | default: | ||
| 365 | return -1; | ||
| 366 | } | ||
| 367 | } while (__r == codecvt_base::partial); | ||
| 368 | } | ||
| 369 | } | ||
| 370 | } | ||
| 371 | if (__bufptr_->pubseekoff(-__c, ios_base::cur, __cm_) == pos_type(off_type(-1))) | ||
| 372 | return -1; | ||
| 373 | this->setg(0, 0, 0); | ||
| 374 | __cm_ = 0; | ||
| 375 | } | ||
| 376 | return 0; | ||
| 377 | } | ||
| 378 | |||
| 379 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 380 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 381 | bool wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode() { | ||
| 382 | if (!(__cm_ & ios_base::in)) { | ||
| 383 | this->setp(0, 0); | ||
| 384 | if (__always_noconv_) | ||
| 385 | this->setg((char_type*)__extbuf_, (char_type*)__extbuf_ + __ebs_, (char_type*)__extbuf_ + __ebs_); | ||
| 386 | else | ||
| 387 | this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_); | ||
| 388 | __cm_ = ios_base::in; | ||
| 389 | return true; | ||
| 390 | } | ||
| 391 | return false; | ||
| 392 | } | ||
| 393 | |||
| 394 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 395 | void wbuffer_convert<_Codecvt, _Elem, _Tr>::__write_mode() { | ||
| 396 | if (!(__cm_ & ios_base::out)) { | ||
| 397 | this->setg(0, 0, 0); | ||
| 398 | if (__ebs_ > sizeof(__extbuf_min_)) { | ||
| 399 | if (__always_noconv_) | ||
| 400 | this->setp((char_type*)__extbuf_, (char_type*)__extbuf_ + (__ebs_ - 1)); | ||
| 401 | else | ||
| 402 | this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1)); | ||
| 403 | } else | ||
| 404 | this->setp(0, 0); | ||
| 405 | __cm_ = ios_base::out; | ||
| 406 | } | ||
| 407 | } | ||
| 408 | |||
| 409 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 410 | wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() { | ||
| 411 | wbuffer_convert* __rt = nullptr; | ||
| 412 | if (__cv_ != nullptr && __bufptr_ != nullptr) { | ||
| 413 | __rt = this; | ||
| 414 | if ((__cm_ & ios_base::out) && sync()) | ||
| 415 | __rt = nullptr; | ||
| 416 | } | ||
| 417 | return __rt; | ||
| 418 | } | ||
| 419 | |||
| 420 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 421 | |||
| 422 | _LIBCPP_END_NAMESPACE_STD | ||
| 423 | |||
| 424 | _LIBCPP_POP_MACROS | ||
| 425 | |||
| 426 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 427 | |||
| 428 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 429 | |||
| 430 | #endif // _LIBCPP___LOCALE_DIR_WBUFFER_CONVERT_H | ||
lib/libcxx/include/__locale_dir/wstring_convert.h created+254| ... | @@ -0,0 +1,254 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_WSTRING_CONVERT_H | ||
| 10 | #define _LIBCPP___LOCALE_DIR_WSTRING_CONVERT_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__locale> | ||
| 14 | #include <__memory/allocator.h> | ||
| 15 | #include <string> | ||
| 16 | |||
| 17 | #if _LIBCPP_HAS_LOCALIZATION | ||
| 18 | |||
| 19 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 20 | # pragma GCC system_header | ||
| 21 | # endif | ||
| 22 | |||
| 23 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 24 | |||
| 25 | _LIBCPP_PUSH_MACROS | ||
| 26 | # include <__undef_macros> | ||
| 27 | |||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 29 | |||
| 30 | template <class _Codecvt, | ||
| 31 | class _Elem = wchar_t, | ||
| 32 | class _WideAlloc = allocator<_Elem>, | ||
| 33 | class _ByteAlloc = allocator<char> > | ||
| 34 | class _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert { | ||
| 35 | public: | ||
| 36 | typedef basic_string<char, char_traits<char>, _ByteAlloc> byte_string; | ||
| 37 | typedef basic_string<_Elem, char_traits<_Elem>, _WideAlloc> wide_string; | ||
| 38 | typedef typename _Codecvt::state_type state_type; | ||
| 39 | typedef typename wide_string::traits_type::int_type int_type; | ||
| 40 | |||
| 41 | private: | ||
| 42 | byte_string __byte_err_string_; | ||
| 43 | wide_string __wide_err_string_; | ||
| 44 | _Codecvt* __cvtptr_; | ||
| 45 | state_type __cvtstate_; | ||
| 46 | size_t __cvtcount_; | ||
| 47 | |||
| 48 | public: | ||
| 49 | # ifndef _LIBCPP_CXX03_LANG | ||
| 50 | _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {} | ||
| 51 | _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt); | ||
| 52 | # else | ||
| 53 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt); | ||
| 54 | # endif | ||
| 55 | |||
| 56 | _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state); | ||
| 57 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI | ||
| 58 | wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); | ||
| 59 | # ifndef _LIBCPP_CXX03_LANG | ||
| 60 | _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc); | ||
| 61 | # endif | ||
| 62 | _LIBCPP_HIDE_FROM_ABI ~wstring_convert(); | ||
| 63 | |||
| 64 | wstring_convert(const wstring_convert& __wc) = delete; | ||
| 65 | wstring_convert& operator=(const wstring_convert& __wc) = delete; | ||
| 66 | |||
| 67 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); } | ||
| 68 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) { | ||
| 69 | return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr)); | ||
| 70 | } | ||
| 71 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const byte_string& __str) { | ||
| 72 | return from_bytes(__str.data(), __str.data() + __str.size()); | ||
| 73 | } | ||
| 74 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __first, const char* __last); | ||
| 75 | |||
| 76 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) { | ||
| 77 | return to_bytes(std::addressof(__wchar), std::addressof(__wchar) + 1); | ||
| 78 | } | ||
| 79 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __wptr) { | ||
| 80 | return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr)); | ||
| 81 | } | ||
| 82 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const wide_string& __wstr) { | ||
| 83 | return to_bytes(__wstr.data(), __wstr.data() + __wstr.size()); | ||
| 84 | } | ||
| 85 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __first, const _Elem* __last); | ||
| 86 | |||
| 87 | _LIBCPP_HIDE_FROM_ABI size_t converted() const _NOEXCEPT { return __cvtcount_; } | ||
| 88 | _LIBCPP_HIDE_FROM_ABI state_type state() const { return __cvtstate_; } | ||
| 89 | }; | ||
| 90 | |||
| 91 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 92 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 93 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt) | ||
| 94 | : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) {} | ||
| 95 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 96 | |||
| 97 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 98 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt, state_type __state) | ||
| 99 | : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) {} | ||
| 100 | |||
| 101 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 102 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert( | ||
| 103 | const byte_string& __byte_err, const wide_string& __wide_err) | ||
| 104 | : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err), __cvtstate_(), __cvtcount_(0) { | ||
| 105 | __cvtptr_ = new _Codecvt; | ||
| 106 | } | ||
| 107 | |||
| 108 | # ifndef _LIBCPP_CXX03_LANG | ||
| 109 | |||
| 110 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 111 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc) | ||
| 112 | : __byte_err_string_(std::move(__wc.__byte_err_string_)), | ||
| 113 | __wide_err_string_(std::move(__wc.__wide_err_string_)), | ||
| 114 | __cvtptr_(__wc.__cvtptr_), | ||
| 115 | __cvtstate_(__wc.__cvtstate_), | ||
| 116 | __cvtcount_(__wc.__cvtcount_) { | ||
| 117 | __wc.__cvtptr_ = nullptr; | ||
| 118 | } | ||
| 119 | |||
| 120 | # endif // _LIBCPP_CXX03_LANG | ||
| 121 | |||
| 122 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 123 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 124 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::~wstring_convert() { | ||
| 125 | delete __cvtptr_; | ||
| 126 | } | ||
| 127 | |||
| 128 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 129 | typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wide_string | ||
| 130 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::from_bytes(const char* __frm, const char* __frm_end) { | ||
| 131 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 132 | __cvtcount_ = 0; | ||
| 133 | if (__cvtptr_ != nullptr) { | ||
| 134 | wide_string __ws(2 * (__frm_end - __frm), _Elem()); | ||
| 135 | if (__frm != __frm_end) | ||
| 136 | __ws.resize(__ws.capacity()); | ||
| 137 | codecvt_base::result __r = codecvt_base::ok; | ||
| 138 | state_type __st = __cvtstate_; | ||
| 139 | if (__frm != __frm_end) { | ||
| 140 | _Elem* __to = std::addressof(__ws[0]); | ||
| 141 | _Elem* __to_end = __to + __ws.size(); | ||
| 142 | const char* __frm_nxt; | ||
| 143 | do { | ||
| 144 | _Elem* __to_nxt; | ||
| 145 | __r = __cvtptr_->in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); | ||
| 146 | __cvtcount_ += __frm_nxt - __frm; | ||
| 147 | if (__frm_nxt == __frm) { | ||
| 148 | __r = codecvt_base::error; | ||
| 149 | } else if (__r == codecvt_base::noconv) { | ||
| 150 | __ws.resize(__to - std::addressof(__ws[0])); | ||
| 151 | // This only gets executed if _Elem is char | ||
| 152 | __ws.append((const _Elem*)__frm, (const _Elem*)__frm_end); | ||
| 153 | __frm = __frm_nxt; | ||
| 154 | __r = codecvt_base::ok; | ||
| 155 | } else if (__r == codecvt_base::ok) { | ||
| 156 | __ws.resize(__to_nxt - std::addressof(__ws[0])); | ||
| 157 | __frm = __frm_nxt; | ||
| 158 | } else if (__r == codecvt_base::partial) { | ||
| 159 | ptrdiff_t __s = __to_nxt - std::addressof(__ws[0]); | ||
| 160 | __ws.resize(2 * __s); | ||
| 161 | __to = std::addressof(__ws[0]) + __s; | ||
| 162 | __to_end = std::addressof(__ws[0]) + __ws.size(); | ||
| 163 | __frm = __frm_nxt; | ||
| 164 | } | ||
| 165 | } while (__r == codecvt_base::partial && __frm_nxt < __frm_end); | ||
| 166 | } | ||
| 167 | if (__r == codecvt_base::ok) | ||
| 168 | return __ws; | ||
| 169 | } | ||
| 170 | |||
| 171 | if (__wide_err_string_.empty()) | ||
| 172 | std::__throw_range_error("wstring_convert: from_bytes error"); | ||
| 173 | |||
| 174 | return __wide_err_string_; | ||
| 175 | } | ||
| 176 | |||
| 177 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 178 | typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::byte_string | ||
| 179 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem* __frm, const _Elem* __frm_end) { | ||
| 180 | __cvtcount_ = 0; | ||
| 181 | if (__cvtptr_ != nullptr) { | ||
| 182 | byte_string __bs(2 * (__frm_end - __frm), char()); | ||
| 183 | if (__frm != __frm_end) | ||
| 184 | __bs.resize(__bs.capacity()); | ||
| 185 | codecvt_base::result __r = codecvt_base::ok; | ||
| 186 | state_type __st = __cvtstate_; | ||
| 187 | if (__frm != __frm_end) { | ||
| 188 | char* __to = std::addressof(__bs[0]); | ||
| 189 | char* __to_end = __to + __bs.size(); | ||
| 190 | const _Elem* __frm_nxt; | ||
| 191 | do { | ||
| 192 | char* __to_nxt; | ||
| 193 | __r = __cvtptr_->out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); | ||
| 194 | __cvtcount_ += __frm_nxt - __frm; | ||
| 195 | if (__frm_nxt == __frm) { | ||
| 196 | __r = codecvt_base::error; | ||
| 197 | } else if (__r == codecvt_base::noconv) { | ||
| 198 | __bs.resize(__to - std::addressof(__bs[0])); | ||
| 199 | // This only gets executed if _Elem is char | ||
| 200 | __bs.append((const char*)__frm, (const char*)__frm_end); | ||
| 201 | __frm = __frm_nxt; | ||
| 202 | __r = codecvt_base::ok; | ||
| 203 | } else if (__r == codecvt_base::ok) { | ||
| 204 | __bs.resize(__to_nxt - std::addressof(__bs[0])); | ||
| 205 | __frm = __frm_nxt; | ||
| 206 | } else if (__r == codecvt_base::partial) { | ||
| 207 | ptrdiff_t __s = __to_nxt - std::addressof(__bs[0]); | ||
| 208 | __bs.resize(2 * __s); | ||
| 209 | __to = std::addressof(__bs[0]) + __s; | ||
| 210 | __to_end = std::addressof(__bs[0]) + __bs.size(); | ||
| 211 | __frm = __frm_nxt; | ||
| 212 | } | ||
| 213 | } while (__r == codecvt_base::partial && __frm_nxt < __frm_end); | ||
| 214 | } | ||
| 215 | if (__r == codecvt_base::ok) { | ||
| 216 | size_t __s = __bs.size(); | ||
| 217 | __bs.resize(__bs.capacity()); | ||
| 218 | char* __to = std::addressof(__bs[0]) + __s; | ||
| 219 | char* __to_end = __to + __bs.size(); | ||
| 220 | do { | ||
| 221 | char* __to_nxt; | ||
| 222 | __r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt); | ||
| 223 | if (__r == codecvt_base::noconv) { | ||
| 224 | __bs.resize(__to - std::addressof(__bs[0])); | ||
| 225 | __r = codecvt_base::ok; | ||
| 226 | } else if (__r == codecvt_base::ok) { | ||
| 227 | __bs.resize(__to_nxt - std::addressof(__bs[0])); | ||
| 228 | } else if (__r == codecvt_base::partial) { | ||
| 229 | ptrdiff_t __sp = __to_nxt - std::addressof(__bs[0]); | ||
| 230 | __bs.resize(2 * __sp); | ||
| 231 | __to = std::addressof(__bs[0]) + __sp; | ||
| 232 | __to_end = std::addressof(__bs[0]) + __bs.size(); | ||
| 233 | } | ||
| 234 | } while (__r == codecvt_base::partial); | ||
| 235 | if (__r == codecvt_base::ok) | ||
| 236 | return __bs; | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | if (__byte_err_string_.empty()) | ||
| 241 | std::__throw_range_error("wstring_convert: to_bytes error"); | ||
| 242 | |||
| 243 | return __byte_err_string_; | ||
| 244 | } | ||
| 245 | |||
| 246 | _LIBCPP_END_NAMESPACE_STD | ||
| 247 | |||
| 248 | _LIBCPP_POP_MACROS | ||
| 249 | |||
| 250 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 251 | |||
| 252 | #endif // _LIBCPP_HAS_LOCALIZATION | ||
| 253 | |||
| 254 | #endif // _LIBCPP___LOCALE_DIR_WSTRING_CONVERT_H | ||
lib/libcxx/include/__log_hardening_failure created+42| ... | @@ -0,0 +1,42 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___LOG_HARDENING_FAILURE | ||
| 11 | #define _LIBCPP___LOG_HARDENING_FAILURE | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | // Hardening logging is not available in the C++03 mode; moreover, it is currently only available in the experimental | ||
| 20 | // library. | ||
| 21 | #if _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC && !defined(_LIBCPP_CXX03_LANG) | ||
| 22 | |||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 24 | |||
| 25 | // This function should never be called directly from the code -- it should only be called through the | ||
| 26 | // `_LIBCPP_LOG_HARDENING_FAILURE` macro. | ||
| 27 | [[__gnu__::__cold__]] _LIBCPP_EXPORTED_FROM_ABI void __log_hardening_failure(const char* __message) noexcept; | ||
| 28 | |||
| 29 | // _LIBCPP_LOG_HARDENING_FAILURE(message) | ||
| 30 | // | ||
| 31 | // This macro is used to log an error without terminating the program (as is the case for hardening failures if the | ||
| 32 | // `observe` assertion semantic is used). | ||
| 33 | |||
| 34 | # if !defined(_LIBCPP_LOG_HARDENING_FAILURE) | ||
| 35 | # define _LIBCPP_LOG_HARDENING_FAILURE(__message) ::std::__log_hardening_failure(__message) | ||
| 36 | # endif // !defined(_LIBCPP_LOG_HARDENING_FAILURE) | ||
| 37 | |||
| 38 | _LIBCPP_END_NAMESPACE_STD | ||
| 39 | |||
| 40 | #endif // _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC && !defined(_LIBCPP_CXX03_LANG) | ||
| 41 | |||
| 42 | #endif // _LIBCPP___LOG_HARDENING_FAILURE | ||
lib/libcxx/include/__math/abs.h+24| ... | @@ -39,6 +39,30 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | ... | @@ -39,6 +39,30 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 39 | return __builtin_fabs((double)__x); | 39 | return __builtin_fabs((double)__x); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | // abs | ||
| 43 | |||
| 44 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline float abs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } | ||
| 45 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline double abs(double __x) _NOEXCEPT { return __builtin_fabs(__x); } | ||
| 46 | |||
| 47 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline long double abs(long double __x) _NOEXCEPT { | ||
| 48 | return __builtin_fabsl(__x); | ||
| 49 | } | ||
| 50 | |||
| 51 | template <class = int> | ||
| 52 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline int abs(int __x) _NOEXCEPT { | ||
| 53 | return __builtin_abs(__x); | ||
| 54 | } | ||
| 55 | |||
| 56 | template <class = int> | ||
| 57 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline long abs(long __x) _NOEXCEPT { | ||
| 58 | return __builtin_labs(__x); | ||
| 59 | } | ||
| 60 | |||
| 61 | template <class = int> | ||
| 62 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline long long abs(long long __x) _NOEXCEPT { | ||
| 63 | return __builtin_llabs(__x); | ||
| 64 | } | ||
| 65 | |||
| 42 | } // namespace __math | 66 | } // namespace __math |
| 43 | 67 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | 68 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__math/copysign.h+1-1| ... | @@ -33,7 +33,7 @@ namespace __math { | ... | @@ -33,7 +33,7 @@ namespace __math { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 35 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 36 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT { | 36 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
| 37 | return ::__builtin_copysign(__x, __y); | 37 | return ::__builtin_copysign(__x, __y); |
| 38 | } | 38 | } |
| 39 | 39 |
lib/libcxx/include/__math/exponential_functions.h+2-2| ... | @@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _ | ... | @@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _ |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 160 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 161 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type pow(_A1 __x, _A2 __y) _NOEXCEPT { | 161 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> pow(_A1 __x, _A2 __y) _NOEXCEPT { |
| 162 | using __result_type = typename __promote<_A1, _A2>::type; | 162 | using __result_type = __promote_t<_A1, _A2>; |
| 163 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 163 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 164 | return __math::pow((__result_type)__x, (__result_type)__y); | 164 | return __math::pow((__result_type)__x, (__result_type)__y); |
| 165 | } | 165 | } |
lib/libcxx/include/__math/fdim.h+2-2| ... | @@ -35,8 +35,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) | ... | @@ -35,8 +35,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 37 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 38 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fdim(_A1 __x, _A2 __y) _NOEXCEPT { | 38 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fdim(_A1 __x, _A2 __y) _NOEXCEPT { |
| 39 | using __result_type = typename __promote<_A1, _A2>::type; | 39 | using __result_type = __promote_t<_A1, _A2>; |
| 40 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 40 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 41 | return __math::fdim((__result_type)__x, (__result_type)__y); | 41 | return __math::fdim((__result_type)__x, (__result_type)__y); |
| 42 | } | 42 | } |
lib/libcxx/include/__math/fma.h+2-2| ... | @@ -40,8 +40,8 @@ template <class _A1, | ... | @@ -40,8 +40,8 @@ template <class _A1, |
| 40 | class _A2, | 40 | class _A2, |
| 41 | class _A3, | 41 | class _A3, |
| 42 | __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0> | 42 | __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0> |
| 43 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { | 43 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { |
| 44 | using __result_type = typename __promote<_A1, _A2, _A3>::type; | 44 | using __result_type = __promote_t<_A1, _A2, _A3>; |
| 45 | static_assert( | 45 | static_assert( |
| 46 | !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value), | 46 | !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value), |
| 47 | ""); | 47 | ""); |
lib/libcxx/include/__math/hypot.h+4-4| ... | @@ -43,8 +43,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) | ... | @@ -43,8 +43,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 45 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 46 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type hypot(_A1 __x, _A2 __y) _NOEXCEPT { | 46 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> hypot(_A1 __x, _A2 __y) _NOEXCEPT { |
| 47 | using __result_type = typename __promote<_A1, _A2>::type; | 47 | using __result_type = __promote_t<_A1, _A2>; |
| 48 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 48 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 49 | return __math::hypot((__result_type)__x, (__result_type)__y); | 49 | return __math::hypot((__result_type)__x, (__result_type)__y); |
| 50 | } | 50 | } |
| ... | @@ -91,8 +91,8 @@ template <class _A1, | ... | @@ -91,8 +91,8 @@ template <class _A1, |
| 91 | class _A2, | 91 | class _A2, |
| 92 | class _A3, | 92 | class _A3, |
| 93 | std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 > | 93 | std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 > |
| 94 | _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { | 94 | _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { |
| 95 | using __result_type = typename __promote<_A1, _A2, _A3>::type; | 95 | using __result_type = __promote_t<_A1, _A2, _A3>; |
| 96 | static_assert(!( | 96 | static_assert(!( |
| 97 | std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>)); | 97 | std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>)); |
| 98 | return __math::__hypot( | 98 | return __math::__hypot( |
lib/libcxx/include/__math/inverse_trigonometric_functions.h+2-2| ... | @@ -86,8 +86,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) | ... | @@ -86,8 +86,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 88 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 89 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type atan2(_A1 __y, _A2 __x) _NOEXCEPT { | 89 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> atan2(_A1 __y, _A2 __x) _NOEXCEPT { |
| 90 | using __result_type = typename __promote<_A1, _A2>::type; | 90 | using __result_type = __promote_t<_A1, _A2>; |
| 91 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 91 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 92 | return __math::atan2((__result_type)__y, (__result_type)__x); | 92 | return __math::atan2((__result_type)__y, (__result_type)__x); |
| 93 | } | 93 | } |
lib/libcxx/include/__math/min_max.h+4-4| ... | @@ -39,8 +39,8 @@ template <class = int> | ... | @@ -39,8 +39,8 @@ template <class = int> |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 41 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 42 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { | 42 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fmax(_A1 __x, _A2 __y) _NOEXCEPT { |
| 43 | using __result_type = typename __promote<_A1, _A2>::type; | 43 | using __result_type = __promote_t<_A1, _A2>; |
| 44 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 44 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 45 | return __math::fmax((__result_type)__x, (__result_type)__y); | 45 | return __math::fmax((__result_type)__x, (__result_type)__y); |
| 46 | } | 46 | } |
| ... | @@ -61,8 +61,8 @@ template <class = int> | ... | @@ -61,8 +61,8 @@ template <class = int> |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 63 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 64 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { | 64 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fmin(_A1 __x, _A2 __y) _NOEXCEPT { |
| 65 | using __result_type = typename __promote<_A1, _A2>::type; | 65 | using __result_type = __promote_t<_A1, _A2>; |
| 66 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 66 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 67 | return __math::fmin((__result_type)__x, (__result_type)__y); | 67 | return __math::fmin((__result_type)__x, (__result_type)__y); |
| 68 | } | 68 | } |
lib/libcxx/include/__math/modulo.h+2-2| ... | @@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) | ... | @@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 39 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 40 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmod(_A1 __x, _A2 __y) _NOEXCEPT { | 40 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fmod(_A1 __x, _A2 __y) _NOEXCEPT { |
| 41 | using __result_type = typename __promote<_A1, _A2>::type; | 41 | using __result_type = __promote_t<_A1, _A2>; |
| 42 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 42 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 43 | return __math::fmod((__result_type)__x, (__result_type)__y); | 43 | return __math::fmod((__result_type)__x, (__result_type)__y); |
| 44 | } | 44 | } |
lib/libcxx/include/__math/remainder.h+4-4| ... | @@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double | ... | @@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 39 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 40 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remainder(_A1 __x, _A2 __y) _NOEXCEPT { | 40 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> remainder(_A1 __x, _A2 __y) _NOEXCEPT { |
| 41 | using __result_type = typename __promote<_A1, _A2>::type; | 41 | using __result_type = __promote_t<_A1, _A2>; |
| 42 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 42 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 43 | return __math::remainder((__result_type)__x, (__result_type)__y); | 43 | return __math::remainder((__result_type)__x, (__result_type)__y); |
| 44 | } | 44 | } |
| ... | @@ -59,8 +59,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y | ... | @@ -59,8 +59,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 61 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 62 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT { | 62 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT { |
| 63 | using __result_type = typename __promote<_A1, _A2>::type; | 63 | using __result_type = __promote_t<_A1, _A2>; |
| 64 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 64 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 65 | return __math::remquo((__result_type)__x, (__result_type)__y, __z); | 65 | return __math::remquo((__result_type)__x, (__result_type)__y, __z); |
| 66 | } | 66 | } |
lib/libcxx/include/__math/rounding_functions.h+2-2| ... | @@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double | ... | @@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 160 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 161 | inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type nextafter(_A1 __x, _A2 __y) _NOEXCEPT { | 161 | inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> nextafter(_A1 __x, _A2 __y) _NOEXCEPT { |
| 162 | using __result_type = typename __promote<_A1, _A2>::type; | 162 | using __result_type = __promote_t<_A1, _A2>; |
| 163 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); | 163 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 164 | return __math::nextafter((__result_type)__x, (__result_type)__y); | 164 | return __math::nextafter((__result_type)__x, (__result_type)__y); |
| 165 | } | 165 | } |
lib/libcxx/include/__math/traits.h+7-13| ... | @@ -13,7 +13,6 @@ | ... | @@ -13,7 +13,6 @@ |
| 13 | #include <__type_traits/enable_if.h> | 13 | #include <__type_traits/enable_if.h> |
| 14 | #include <__type_traits/is_arithmetic.h> | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | #include <__type_traits/is_integral.h> | 15 | #include <__type_traits/is_integral.h> |
| 16 | #include <__type_traits/is_signed.h> | ||
| 17 | #include <__type_traits/promote.h> | 16 | #include <__type_traits/promote.h> |
| 18 | 17 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -51,16 +50,11 @@ template <class = void> | ... | @@ -51,16 +50,11 @@ template <class = void> |
| 51 | return __builtin_signbit(__x); | 50 | return __builtin_signbit(__x); |
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0> | 53 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 55 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { | 54 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { |
| 56 | return __x < 0; | 55 | return __x < 0; |
| 57 | } | 56 | } |
| 58 | 57 | ||
| 59 | template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0> | ||
| 60 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { | ||
| 61 | return false; | ||
| 62 | } | ||
| 63 | |||
| 64 | // isfinite | 58 | // isfinite |
| 65 | 59 | ||
| 66 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | 60 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| ... | @@ -151,7 +145,7 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | ... | @@ -151,7 +145,7 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 151 | 145 | ||
| 152 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 146 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 153 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { | 147 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 154 | using type = typename __promote<_A1, _A2>::type; | 148 | using type = __promote_t<_A1, _A2>; |
| 155 | return __builtin_isgreater((type)__x, (type)__y); | 149 | return __builtin_isgreater((type)__x, (type)__y); |
| 156 | } | 150 | } |
| 157 | 151 | ||
| ... | @@ -159,7 +153,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar | ... | @@ -159,7 +153,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar |
| 159 | 153 | ||
| 160 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 154 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 161 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { | 155 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 162 | using type = typename __promote<_A1, _A2>::type; | 156 | using type = __promote_t<_A1, _A2>; |
| 163 | return __builtin_isgreaterequal((type)__x, (type)__y); | 157 | return __builtin_isgreaterequal((type)__x, (type)__y); |
| 164 | } | 158 | } |
| 165 | 159 | ||
| ... | @@ -167,7 +161,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar | ... | @@ -167,7 +161,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar |
| 167 | 161 | ||
| 168 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 162 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 169 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { | 163 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { |
| 170 | using type = typename __promote<_A1, _A2>::type; | 164 | using type = __promote_t<_A1, _A2>; |
| 171 | return __builtin_isless((type)__x, (type)__y); | 165 | return __builtin_isless((type)__x, (type)__y); |
| 172 | } | 166 | } |
| 173 | 167 | ||
| ... | @@ -175,7 +169,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar | ... | @@ -175,7 +169,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar |
| 175 | 169 | ||
| 176 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 170 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 177 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { | 171 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { |
| 178 | using type = typename __promote<_A1, _A2>::type; | 172 | using type = __promote_t<_A1, _A2>; |
| 179 | return __builtin_islessequal((type)__x, (type)__y); | 173 | return __builtin_islessequal((type)__x, (type)__y); |
| 180 | } | 174 | } |
| 181 | 175 | ||
| ... | @@ -183,7 +177,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar | ... | @@ -183,7 +177,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar |
| 183 | 177 | ||
| 184 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 178 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 185 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { | 179 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { |
| 186 | using type = typename __promote<_A1, _A2>::type; | 180 | using type = __promote_t<_A1, _A2>; |
| 187 | return __builtin_islessgreater((type)__x, (type)__y); | 181 | return __builtin_islessgreater((type)__x, (type)__y); |
| 188 | } | 182 | } |
| 189 | 183 | ||
| ... | @@ -191,7 +185,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar | ... | @@ -191,7 +185,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar |
| 191 | 185 | ||
| 192 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> | 186 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 193 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { | 187 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { |
| 194 | using type = typename __promote<_A1, _A2>::type; | 188 | using type = __promote_t<_A1, _A2>; |
| 195 | return __builtin_isunordered((type)__x, (type)__y); | 189 | return __builtin_isunordered((type)__x, (type)__y); |
| 196 | } | 190 | } |
| 197 | 191 |
lib/libcxx/include/__mbstate_t.h+4-4| ... | @@ -43,12 +43,12 @@ | ... | @@ -43,12 +43,12 @@ |
| 43 | # include <bits/types/mbstate_t.h> // works on most Unixes | 43 | # include <bits/types/mbstate_t.h> // works on most Unixes |
| 44 | #elif __has_include(<sys/_types/_mbstate_t.h>) | 44 | #elif __has_include(<sys/_types/_mbstate_t.h>) |
| 45 | # include <sys/_types/_mbstate_t.h> // works on Darwin | 45 | # include <sys/_types/_mbstate_t.h> // works on Darwin |
| 46 | #elif _LIBCPP_HAS_WIDE_CHARACTERS && __has_include_next(<wchar.h>) | 46 | #elif __has_include_next(<wchar.h>) |
| 47 | # include_next <wchar.h> // fall back to the C standard provider of mbstate_t | 47 | # include_next <wchar.h> // use the C standard provider of mbstate_t if present |
| 48 | #elif __has_include_next(<uchar.h>) | 48 | #elif __has_include_next(<uchar.h>) |
| 49 | # include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible | 49 | # include_next <uchar.h> // Try <uchar.h> in absence of <wchar.h> for mbstate_t |
| 50 | #else | 50 | #else |
| 51 | # error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform." | 51 | # error "We don't know how to get the definition of mbstate_t on your platform." |
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | #endif // _LIBCPP___MBSTATE_T_H | 54 | #endif // _LIBCPP___MBSTATE_T_H |
lib/libcxx/include/__mdspan/aligned_accessor.h created+87| ... | @@ -0,0 +1,87 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | // Kokkos v. 4.0 | ||
| 9 | // Copyright (2022) National Technology & Engineering | ||
| 10 | // Solutions of Sandia, LLC (NTESS). | ||
| 11 | // | ||
| 12 | // Under the terms of Contract DE-NA0003525 with NTESS, | ||
| 13 | // the U.S. Government retains certain rights in this software. | ||
| 14 | // | ||
| 15 | //===---------------------------------------------------------------------===// | ||
| 16 | |||
| 17 | #ifndef _LIBCPP___MDSPAN_ALIGNED_ACCESSOR_H | ||
| 18 | #define _LIBCPP___MDSPAN_ALIGNED_ACCESSOR_H | ||
| 19 | |||
| 20 | #include <__config> | ||
| 21 | #include <__cstddef/size_t.h> | ||
| 22 | #include <__mdspan/default_accessor.h> | ||
| 23 | #include <__memory/assume_aligned.h> | ||
| 24 | #include <__type_traits/is_abstract.h> | ||
| 25 | #include <__type_traits/is_array.h> | ||
| 26 | #include <__type_traits/is_convertible.h> | ||
| 27 | #include <__type_traits/remove_const.h> | ||
| 28 | |||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 30 | # pragma GCC system_header | ||
| 31 | #endif | ||
| 32 | |||
| 33 | _LIBCPP_PUSH_MACROS | ||
| 34 | #include <__undef_macros> | ||
| 35 | |||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 37 | |||
| 38 | #if _LIBCPP_STD_VER >= 26 | ||
| 39 | |||
| 40 | template <class _ElementType, size_t _ByteAlignment> | ||
| 41 | struct aligned_accessor { | ||
| 42 | static_assert(_ByteAlignment != 0 && (_ByteAlignment & (_ByteAlignment - 1)) == 0, | ||
| 43 | "aligned_accessor: byte alignment must be a power of two"); | ||
| 44 | static_assert(_ByteAlignment >= alignof(_ElementType), "aligned_accessor: insufficient byte alignment"); | ||
| 45 | static_assert(!is_array_v<_ElementType>, "aligned_accessor: template argument may not be an array type"); | ||
| 46 | static_assert(!is_abstract_v<_ElementType>, "aligned_accessor: template argument may not be an abstract class"); | ||
| 47 | |||
| 48 | using offset_policy = default_accessor<_ElementType>; | ||
| 49 | using element_type = _ElementType; | ||
| 50 | using reference = _ElementType&; | ||
| 51 | using data_handle_type = _ElementType*; | ||
| 52 | |||
| 53 | static constexpr size_t byte_alignment = _ByteAlignment; | ||
| 54 | |||
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr aligned_accessor() noexcept = default; | ||
| 56 | |||
| 57 | template <class _OtherElementType, size_t _OtherByteAlignment> | ||
| 58 | requires(is_convertible_v<_OtherElementType (*)[], element_type (*)[]> && _OtherByteAlignment >= byte_alignment) | ||
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr aligned_accessor(aligned_accessor<_OtherElementType, _OtherByteAlignment>) noexcept {} | ||
| 60 | |||
| 61 | template <class _OtherElementType> | ||
| 62 | requires(is_convertible_v<_OtherElementType (*)[], element_type (*)[]>) | ||
| 63 | _LIBCPP_HIDE_FROM_ABI explicit constexpr aligned_accessor(default_accessor<_OtherElementType>) noexcept {} | ||
| 64 | |||
| 65 | template <class _OtherElementType> | ||
| 66 | requires(is_convertible_v<element_type (*)[], _OtherElementType (*)[]>) | ||
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr operator default_accessor<_OtherElementType>() const noexcept { | ||
| 68 | return {}; | ||
| 69 | } | ||
| 70 | |||
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr reference access(data_handle_type __p, size_t __i) const noexcept { | ||
| 72 | return std::assume_aligned<byte_alignment>(__p)[__i]; | ||
| 73 | } | ||
| 74 | |||
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr typename offset_policy::data_handle_type | ||
| 76 | offset(data_handle_type __p, size_t __i) const noexcept { | ||
| 77 | return std::assume_aligned<byte_alignment>(__p) + __i; | ||
| 78 | } | ||
| 79 | }; | ||
| 80 | |||
| 81 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 82 | |||
| 83 | _LIBCPP_END_NAMESPACE_STD | ||
| 84 | |||
| 85 | _LIBCPP_POP_MACROS | ||
| 86 | |||
| 87 | #endif // _LIBCPP___MDSPAN_ALIGNED_ACCESSOR_H | ||
lib/libcxx/include/__mdspan/extents.h+5-5| ... | @@ -21,11 +21,10 @@ | ... | @@ -21,11 +21,10 @@ |
| 21 | #include <__config> | 21 | #include <__config> |
| 22 | 22 | ||
| 23 | #include <__concepts/arithmetic.h> | 23 | #include <__concepts/arithmetic.h> |
| 24 | #include <__cstddef/byte.h> | ||
| 25 | #include <__type_traits/common_type.h> | 24 | #include <__type_traits/common_type.h> |
| 25 | #include <__type_traits/integer_traits.h> | ||
| 26 | #include <__type_traits/is_convertible.h> | 26 | #include <__type_traits/is_convertible.h> |
| 27 | #include <__type_traits/is_nothrow_constructible.h> | 27 | #include <__type_traits/is_nothrow_constructible.h> |
| 28 | #include <__type_traits/is_same.h> | ||
| 29 | #include <__type_traits/make_unsigned.h> | 28 | #include <__type_traits/make_unsigned.h> |
| 30 | #include <__utility/integer_sequence.h> | 29 | #include <__utility/integer_sequence.h> |
| 31 | #include <__utility/unreachable.h> | 30 | #include <__utility/unreachable.h> |
| ... | @@ -283,7 +282,8 @@ public: | ... | @@ -283,7 +282,8 @@ public: |
| 283 | using size_type = make_unsigned_t<index_type>; | 282 | using size_type = make_unsigned_t<index_type>; |
| 284 | using rank_type = size_t; | 283 | using rank_type = size_t; |
| 285 | 284 | ||
| 286 | static_assert(__libcpp_integer<index_type>, "extents::index_type must be a signed or unsigned integer type"); | 285 | static_assert(__signed_or_unsigned_integer<index_type>, |
| 286 | "extents::index_type must be a signed or unsigned integer type"); | ||
| 287 | static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...), | 287 | static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...), |
| 288 | "extents ctor: arguments must be representable as index_type and nonnegative"); | 288 | "extents ctor: arguments must be representable as index_type and nonnegative"); |
| 289 | 289 | ||
| ... | @@ -440,13 +440,13 @@ struct __make_dextents; | ... | @@ -440,13 +440,13 @@ struct __make_dextents; |
| 440 | 440 | ||
| 441 | template <class _IndexType, size_t _Rank, size_t... _ExtentsPack> | 441 | template <class _IndexType, size_t _Rank, size_t... _ExtentsPack> |
| 442 | struct __make_dextents< _IndexType, _Rank, extents<_IndexType, _ExtentsPack...>> { | 442 | struct __make_dextents< _IndexType, _Rank, extents<_IndexType, _ExtentsPack...>> { |
| 443 | using type = | 443 | using type _LIBCPP_NODEBUG = |
| 444 | typename __make_dextents< _IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>::type; | 444 | typename __make_dextents< _IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>::type; |
| 445 | }; | 445 | }; |
| 446 | 446 | ||
| 447 | template <class _IndexType, size_t... _ExtentsPack> | 447 | template <class _IndexType, size_t... _ExtentsPack> |
| 448 | struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { | 448 | struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { |
| 449 | using type = extents<_IndexType, _ExtentsPack...>; | 449 | using type _LIBCPP_NODEBUG = extents<_IndexType, _ExtentsPack...>; |
| 450 | }; | 450 | }; |
| 451 | 451 | ||
| 452 | } // namespace __mdspan_detail | 452 | } // namespace __mdspan_detail |
lib/libcxx/include/__mdspan/layout_left.h+2-1| ... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
| 21 | #include <__config> | 21 | #include <__config> |
| 22 | #include <__fwd/mdspan.h> | 22 | #include <__fwd/mdspan.h> |
| 23 | #include <__mdspan/extents.h> | 23 | #include <__mdspan/extents.h> |
| 24 | #include <__memory/addressof.h> | ||
| 24 | #include <__type_traits/common_type.h> | 25 | #include <__type_traits/common_type.h> |
| 25 | #include <__type_traits/is_constructible.h> | 26 | #include <__type_traits/is_constructible.h> |
| 26 | #include <__type_traits/is_convertible.h> | 27 | #include <__type_traits/is_convertible.h> |
| ... | @@ -58,7 +59,7 @@ private: | ... | @@ -58,7 +59,7 @@ private: |
| 58 | 59 | ||
| 59 | index_type __prod = __ext.extent(0); | 60 | index_type __prod = __ext.extent(0); |
| 60 | for (rank_type __r = 1; __r < extents_type::rank(); __r++) { | 61 | for (rank_type __r = 1; __r < extents_type::rank(); __r++) { |
| 61 | bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), &__prod); | 62 | bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), std::addressof(__prod)); |
| 62 | if (__overflowed) | 63 | if (__overflowed) |
| 63 | return false; | 64 | return false; |
| 64 | } | 65 | } |
lib/libcxx/include/__mdspan/layout_right.h+2-1| ... | @@ -22,6 +22,7 @@ | ... | @@ -22,6 +22,7 @@ |
| 22 | #include <__cstddef/size_t.h> | 22 | #include <__cstddef/size_t.h> |
| 23 | #include <__fwd/mdspan.h> | 23 | #include <__fwd/mdspan.h> |
| 24 | #include <__mdspan/extents.h> | 24 | #include <__mdspan/extents.h> |
| 25 | #include <__memory/addressof.h> | ||
| 25 | #include <__type_traits/common_type.h> | 26 | #include <__type_traits/common_type.h> |
| 26 | #include <__type_traits/is_constructible.h> | 27 | #include <__type_traits/is_constructible.h> |
| 27 | #include <__type_traits/is_convertible.h> | 28 | #include <__type_traits/is_convertible.h> |
| ... | @@ -58,7 +59,7 @@ private: | ... | @@ -58,7 +59,7 @@ private: |
| 58 | 59 | ||
| 59 | index_type __prod = __ext.extent(0); | 60 | index_type __prod = __ext.extent(0); |
| 60 | for (rank_type __r = 1; __r < extents_type::rank(); __r++) { | 61 | for (rank_type __r = 1; __r < extents_type::rank(); __r++) { |
| 61 | bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), &__prod); | 62 | bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), std::addressof(__prod)); |
| 62 | if (__overflowed) | 63 | if (__overflowed) |
| 63 | return false; | 64 | return false; |
| 64 | } | 65 | } |
lib/libcxx/include/__mdspan/layout_stride.h+6-4| ... | @@ -22,6 +22,7 @@ | ... | @@ -22,6 +22,7 @@ |
| 22 | #include <__config> | 22 | #include <__config> |
| 23 | #include <__fwd/mdspan.h> | 23 | #include <__fwd/mdspan.h> |
| 24 | #include <__mdspan/extents.h> | 24 | #include <__mdspan/extents.h> |
| 25 | #include <__memory/addressof.h> | ||
| 25 | #include <__type_traits/common_type.h> | 26 | #include <__type_traits/common_type.h> |
| 26 | #include <__type_traits/is_constructible.h> | 27 | #include <__type_traits/is_constructible.h> |
| 27 | #include <__type_traits/is_convertible.h> | 28 | #include <__type_traits/is_convertible.h> |
| ... | @@ -86,7 +87,7 @@ private: | ... | @@ -86,7 +87,7 @@ private: |
| 86 | 87 | ||
| 87 | index_type __prod = __ext.extent(0); | 88 | index_type __prod = __ext.extent(0); |
| 88 | for (rank_type __r = 1; __r < __rank_; __r++) { | 89 | for (rank_type __r = 1; __r < __rank_; __r++) { |
| 89 | bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), &__prod); | 90 | bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), std::addressof(__prod)); |
| 90 | if (__overflowed) | 91 | if (__overflowed) |
| 91 | return false; | 92 | return false; |
| 92 | } | 93 | } |
| ... | @@ -109,11 +110,12 @@ private: | ... | @@ -109,11 +110,12 @@ private: |
| 109 | } | 110 | } |
| 110 | if (__ext.extent(__r) == static_cast<index_type>(0)) | 111 | if (__ext.extent(__r) == static_cast<index_type>(0)) |
| 111 | return true; | 112 | return true; |
| 112 | index_type __prod = (__ext.extent(__r) - 1); | 113 | index_type __prod = (__ext.extent(__r) - 1); |
| 113 | bool __overflowed_mul = __builtin_mul_overflow(__prod, static_cast<index_type>(__strides[__r]), &__prod); | 114 | bool __overflowed_mul = |
| 115 | __builtin_mul_overflow(__prod, static_cast<index_type>(__strides[__r]), std::addressof(__prod)); | ||
| 114 | if (__overflowed_mul) | 116 | if (__overflowed_mul) |
| 115 | return false; | 117 | return false; |
| 116 | bool __overflowed_add = __builtin_add_overflow(__size, __prod, &__size); | 118 | bool __overflowed_add = __builtin_add_overflow(__size, __prod, std::addressof(__size)); |
| 117 | if (__overflowed_add) | 119 | if (__overflowed_add) |
| 118 | return false; | 120 | return false; |
| 119 | } | 121 | } |
lib/libcxx/include/__mdspan/mdspan.h+7-5| ... | @@ -20,8 +20,10 @@ | ... | @@ -20,8 +20,10 @@ |
| 20 | #include <__assert> | 20 | #include <__assert> |
| 21 | #include <__config> | 21 | #include <__config> |
| 22 | #include <__fwd/mdspan.h> | 22 | #include <__fwd/mdspan.h> |
| 23 | #include <__mdspan/aligned_accessor.h> | ||
| 23 | #include <__mdspan/default_accessor.h> | 24 | #include <__mdspan/default_accessor.h> |
| 24 | #include <__mdspan/extents.h> | 25 | #include <__mdspan/extents.h> |
| 26 | #include <__memory/addressof.h> | ||
| 25 | #include <__type_traits/extent.h> | 27 | #include <__type_traits/extent.h> |
| 26 | #include <__type_traits/is_abstract.h> | 28 | #include <__type_traits/is_abstract.h> |
| 27 | #include <__type_traits/is_array.h> | 29 | #include <__type_traits/is_array.h> |
| ... | @@ -215,7 +217,7 @@ public: | ... | @@ -215,7 +217,7 @@ public: |
| 215 | _LIBCPP_ASSERT_UNCATEGORIZED( | 217 | _LIBCPP_ASSERT_UNCATEGORIZED( |
| 216 | false == ([&]<size_t... _Idxs>(index_sequence<_Idxs...>) { | 218 | false == ([&]<size_t... _Idxs>(index_sequence<_Idxs...>) { |
| 217 | size_type __prod = 1; | 219 | size_type __prod = 1; |
| 218 | return (__builtin_mul_overflow(__prod, extent(_Idxs), &__prod) || ... || false); | 220 | return (__builtin_mul_overflow(__prod, extent(_Idxs), std::addressof(__prod)) || ... || false); |
| 219 | }(make_index_sequence<rank()>())), | 221 | }(make_index_sequence<rank()>())), |
| 220 | "mdspan: size() is not representable as size_type"); | 222 | "mdspan: size() is not representable as size_type"); |
| 221 | return [&]<size_t... _Idxs>(index_sequence<_Idxs...>) { | 223 | return [&]<size_t... _Idxs>(index_sequence<_Idxs...>) { |
| ... | @@ -266,13 +268,13 @@ private: | ... | @@ -266,13 +268,13 @@ private: |
| 266 | # if _LIBCPP_STD_VER >= 26 | 268 | # if _LIBCPP_STD_VER >= 26 |
| 267 | template <class _ElementType, class... _OtherIndexTypes> | 269 | template <class _ElementType, class... _OtherIndexTypes> |
| 268 | requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0)) | 270 | requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0)) |
| 269 | explicit mdspan(_ElementType*, | 271 | explicit mdspan(_ElementType*, _OtherIndexTypes...) |
| 270 | _OtherIndexTypes...) -> mdspan<_ElementType, extents<size_t, __maybe_static_ext<_OtherIndexTypes>...>>; | 272 | -> mdspan<_ElementType, extents<size_t, __maybe_static_ext<_OtherIndexTypes>...>>; |
| 271 | # else | 273 | # else |
| 272 | template <class _ElementType, class... _OtherIndexTypes> | 274 | template <class _ElementType, class... _OtherIndexTypes> |
| 273 | requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0)) | 275 | requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0)) |
| 274 | explicit mdspan(_ElementType*, | 276 | explicit mdspan(_ElementType*, _OtherIndexTypes...) |
| 275 | _OtherIndexTypes...) -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>; | 277 | -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>; |
| 276 | # endif | 278 | # endif |
| 277 | 279 | ||
| 278 | template <class _Pointer> | 280 | template <class _Pointer> |
lib/libcxx/include/__memory/addressof.h+2-2| ... | @@ -23,7 +23,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a | ... | @@ -23,7 +23,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a |
| 23 | return __builtin_addressof(__x); | 23 | return __builtin_addressof(__x); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | #if _LIBCPP_HAS_OBJC_ARC | 26 | #if __has_feature(objc_arc) |
| 27 | // Objective-C++ Automatic Reference Counting uses qualified pointers | 27 | // Objective-C++ Automatic Reference Counting uses qualified pointers |
| 28 | // that require special addressof() signatures. | 28 | // that require special addressof() signatures. |
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| ... | @@ -31,7 +31,7 @@ inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEP | ... | @@ -31,7 +31,7 @@ inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEP |
| 31 | return &__x; | 31 | return &__x; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | # if _LIBCPP_HAS_OBJC_ARC_WEAK | 34 | # if __has_feature(objc_arc_weak) |
| 35 | template <class _Tp> | 35 | template <class _Tp> |
| 36 | inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT { | 36 | inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT { |
| 37 | return &__x; | 37 | return &__x; |
lib/libcxx/include/__memory/allocation_guard.h+11-9| ... | @@ -49,24 +49,26 @@ struct __allocation_guard { | ... | @@ -49,24 +49,26 @@ struct __allocation_guard { |
| 49 | using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type; | 49 | using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type; |
| 50 | 50 | ||
| 51 | template <class _AllocT> // we perform the allocator conversion inside the constructor | 51 | template <class _AllocT> // we perform the allocator conversion inside the constructor |
| 52 | _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n) | 52 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n) |
| 53 | : __alloc_(std::move(__alloc)), | 53 | : __alloc_(std::move(__alloc)), |
| 54 | __n_(__n), | 54 | __n_(__n), |
| 55 | __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important | 55 | __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important |
| 56 | {} | 56 | {} |
| 57 | 57 | ||
| 58 | _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); } | 58 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); } |
| 59 | 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete; | 60 | __allocation_guard(const __allocation_guard&) = delete; |
| 61 | _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT | 61 | __allocation_guard& operator=(const __allocation_guard& __other) = delete; |
| 62 | |||
| 63 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT | ||
| 62 | : __alloc_(std::move(__other.__alloc_)), | 64 | : __alloc_(std::move(__other.__alloc_)), |
| 63 | __n_(__other.__n_), | 65 | __n_(__other.__n_), |
| 64 | __ptr_(__other.__ptr_) { | 66 | __ptr_(__other.__ptr_) { |
| 65 | __other.__ptr_ = nullptr; | 67 | __other.__ptr_ = nullptr; |
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(const __allocation_guard& __other) = delete; | 70 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard& |
| 69 | _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(__allocation_guard&& __other) _NOEXCEPT { | 71 | operator=(__allocation_guard&& __other) _NOEXCEPT { |
| 70 | if (std::addressof(__other) != this) { | 72 | if (std::addressof(__other) != this) { |
| 71 | __destroy(); | 73 | __destroy(); |
| 72 | 74 | ||
| ... | @@ -79,17 +81,17 @@ struct __allocation_guard { | ... | @@ -79,17 +81,17 @@ struct __allocation_guard { |
| 79 | return *this; | 81 | return *this; |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | _LIBCPP_HIDE_FROM_ABI _Pointer | 84 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer |
| 83 | __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++ | 85 | __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++ |
| 84 | _Pointer __tmp = __ptr_; | 86 | _Pointer __tmp = __ptr_; |
| 85 | __ptr_ = nullptr; | 87 | __ptr_ = nullptr; |
| 86 | return __tmp; | 88 | return __tmp; |
| 87 | } | 89 | } |
| 88 | 90 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; } | 91 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; } |
| 90 | 92 | ||
| 91 | private: | 93 | private: |
| 92 | _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT { | 94 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT { |
| 93 | if (__ptr_ != nullptr) { | 95 | if (__ptr_ != nullptr) { |
| 94 | allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_); | 96 | allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_); |
| 95 | } | 97 | } |
lib/libcxx/include/__memory/allocator.h+3-3| ... | @@ -38,7 +38,7 @@ class allocator; | ... | @@ -38,7 +38,7 @@ class allocator; |
| 38 | // These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17. | 38 | // These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17. |
| 39 | // Specializing allocator<void> is deprecated, but not using it. | 39 | // Specializing allocator<void> is deprecated, but not using it. |
| 40 | template <> | 40 | template <> |
| 41 | class _LIBCPP_TEMPLATE_VIS allocator<void> { | 41 | class allocator<void> { |
| 42 | public: | 42 | public: |
| 43 | _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; | 43 | _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; |
| 44 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; | 44 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; |
| ... | @@ -77,7 +77,7 @@ struct __non_trivial_if<true, _Unique> { | ... | @@ -77,7 +77,7 @@ struct __non_trivial_if<true, _Unique> { |
| 77 | // allocator<void> trivial in C++20. | 77 | // allocator<void> trivial in C++20. |
| 78 | 78 | ||
| 79 | template <class _Tp> | 79 | template <class _Tp> |
| 80 | class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > { | 80 | class allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > { |
| 81 | static_assert(!is_const<_Tp>::value, "std::allocator does not support const types"); | 81 | static_assert(!is_const<_Tp>::value, "std::allocator does not support const types"); |
| 82 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); | 82 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); |
| 83 | 83 | ||
| ... | @@ -98,7 +98,7 @@ public: | ... | @@ -98,7 +98,7 @@ public: |
| 98 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { | 98 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { |
| 99 | static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type"); | 99 | static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type"); |
| 100 | if (__n > allocator_traits<allocator>::max_size(*this)) | 100 | if (__n > allocator_traits<allocator>::max_size(*this)) |
| 101 | __throw_bad_array_new_length(); | 101 | std::__throw_bad_array_new_length(); |
| 102 | if (__libcpp_is_constant_evaluated()) { | 102 | if (__libcpp_is_constant_evaluated()) { |
| 103 | return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); | 103 | return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); |
| 104 | } else { | 104 | } else { |
lib/libcxx/include/__memory/allocator_arg_t.h+1-1| ... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { | 26 | struct allocator_arg_t { |
| 27 | explicit allocator_arg_t() = default; | 27 | explicit allocator_arg_t() = default; |
| 28 | }; | 28 | }; |
| 29 | 29 |
lib/libcxx/include/__memory/allocator_traits.h+87-120| ... | @@ -36,12 +36,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -36,12 +36,7 @@ _LIBCPP_PUSH_MACROS |
| 36 | 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 38 | 38 | ||
| 39 | #define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \ | 39 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 40 | template <class _Tp, class = void> \ | ||
| 41 | struct NAME : false_type {}; \ | ||
| 42 | template <class _Tp> \ | ||
| 43 | struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {} | ||
| 44 | |||
| 45 | // __pointer | 40 | // __pointer |
| 46 | template <class _Tp> | 41 | template <class _Tp> |
| 47 | using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; | 42 | using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; |
| ... | @@ -49,50 +44,45 @@ using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; | ... | @@ -49,50 +44,45 @@ using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; |
| 49 | template <class _Tp, class _Alloc> | 44 | template <class _Tp, class _Alloc> |
| 50 | using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >; | 45 | using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >; |
| 51 | 46 | ||
| 52 | // __const_pointer | 47 | // This trait returns _Alias<_Alloc> if that's well-formed, and _Ptr rebound to _Tp otherwise |
| 53 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); | 48 | template <class _Alloc, template <class> class _Alias, class _Ptr, class _Tp, class = void> |
| 54 | template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> | 49 | struct __rebind_or_alias_pointer { |
| 55 | struct __const_pointer { | ||
| 56 | using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer; | ||
| 57 | }; | ||
| 58 | template <class _Tp, class _Ptr, class _Alloc> | ||
| 59 | struct __const_pointer<_Tp, _Ptr, _Alloc, false> { | ||
| 60 | #ifdef _LIBCPP_CXX03_LANG | 50 | #ifdef _LIBCPP_CXX03_LANG |
| 61 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other; | 51 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<_Tp>::other; |
| 62 | #else | 52 | #else |
| 63 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>; | 53 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<_Tp>; |
| 64 | #endif | 54 | #endif |
| 65 | }; | 55 | }; |
| 66 | 56 | ||
| 67 | // __void_pointer | 57 | template <class _Ptr, class _Alloc, class _Tp, template <class> class _Alias> |
| 68 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer); | 58 | struct __rebind_or_alias_pointer<_Alloc, _Alias, _Ptr, _Tp, __void_t<_Alias<_Alloc> > > { |
| 69 | template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> | 59 | using type _LIBCPP_NODEBUG = _Alias<_Alloc>; |
| 70 | struct __void_pointer { | ||
| 71 | using type _LIBCPP_NODEBUG = typename _Alloc::void_pointer; | ||
| 72 | }; | 60 | }; |
| 61 | |||
| 62 | // __const_pointer | ||
| 63 | template <class _Alloc> | ||
| 64 | using __const_pointer_member _LIBCPP_NODEBUG = typename _Alloc::const_pointer; | ||
| 65 | |||
| 66 | template <class _Tp, class _Ptr, class _Alloc> | ||
| 67 | using __const_pointer_t _LIBCPP_NODEBUG = | ||
| 68 | typename __rebind_or_alias_pointer<_Alloc, __const_pointer_member, _Ptr, const _Tp>::type; | ||
| 69 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 70 | |||
| 71 | // __void_pointer | ||
| 72 | template <class _Alloc> | ||
| 73 | using __void_pointer_member _LIBCPP_NODEBUG = typename _Alloc::void_pointer; | ||
| 74 | |||
| 73 | template <class _Ptr, class _Alloc> | 75 | template <class _Ptr, class _Alloc> |
| 74 | struct __void_pointer<_Ptr, _Alloc, false> { | 76 | using __void_pointer_t _LIBCPP_NODEBUG = |
| 75 | #ifdef _LIBCPP_CXX03_LANG | 77 | typename __rebind_or_alias_pointer<_Alloc, __void_pointer_member, _Ptr, void>::type; |
| 76 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>::other; | ||
| 77 | #else | ||
| 78 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>; | ||
| 79 | #endif | ||
| 80 | }; | ||
| 81 | 78 | ||
| 82 | // __const_void_pointer | 79 | // __const_void_pointer |
| 83 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer); | 80 | template <class _Alloc> |
| 84 | template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> | 81 | using __const_void_pointer_member _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer; |
| 85 | struct __const_void_pointer { | 82 | |
| 86 | using type _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer; | ||
| 87 | }; | ||
| 88 | template <class _Ptr, class _Alloc> | 83 | template <class _Ptr, class _Alloc> |
| 89 | struct __const_void_pointer<_Ptr, _Alloc, false> { | 84 | using __const_void_pointer_t _LIBCPP_NODEBUG = |
| 90 | #ifdef _LIBCPP_CXX03_LANG | 85 | typename __rebind_or_alias_pointer<_Alloc, __const_void_pointer_member, _Ptr, const void>::type; |
| 91 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>::other; | ||
| 92 | #else | ||
| 93 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>; | ||
| 94 | #endif | ||
| 95 | }; | ||
| 96 | 86 | ||
| 97 | // __size_type | 87 | // __size_type |
| 98 | template <class _Tp> | 88 | template <class _Tp> |
| ... | @@ -102,13 +92,13 @@ template <class _Alloc, class _DiffType> | ... | @@ -102,13 +92,13 @@ template <class _Alloc, class _DiffType> |
| 102 | using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>; | 92 | using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>; |
| 103 | 93 | ||
| 104 | // __alloc_traits_difference_type | 94 | // __alloc_traits_difference_type |
| 105 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); | 95 | template <class _Alloc, class _Ptr, class = void> |
| 106 | template <class _Alloc, class _Ptr, bool = __has_alloc_traits_difference_type<_Alloc>::value> | ||
| 107 | struct __alloc_traits_difference_type { | 96 | struct __alloc_traits_difference_type { |
| 108 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type; | 97 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type; |
| 109 | }; | 98 | }; |
| 99 | |||
| 110 | template <class _Alloc, class _Ptr> | 100 | template <class _Alloc, class _Ptr> |
| 111 | struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { | 101 | struct __alloc_traits_difference_type<_Alloc, _Ptr, __void_t<typename _Alloc::difference_type> > { |
| 112 | using type _LIBCPP_NODEBUG = typename _Alloc::difference_type; | 102 | using type _LIBCPP_NODEBUG = typename _Alloc::difference_type; |
| 113 | }; | 103 | }; |
| 114 | 104 | ||
| ... | @@ -138,6 +128,7 @@ template <class _Alloc> | ... | @@ -138,6 +128,7 @@ template <class _Alloc> |
| 138 | using __propagate_on_container_swap _LIBCPP_NODEBUG = | 128 | using __propagate_on_container_swap _LIBCPP_NODEBUG = |
| 139 | __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>; | 129 | __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>; |
| 140 | 130 | ||
| 131 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 141 | // __is_always_equal | 132 | // __is_always_equal |
| 142 | template <class _Tp> | 133 | template <class _Tp> |
| 143 | using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal; | 134 | using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal; |
| ... | @@ -147,15 +138,14 @@ using __is_always_equal _LIBCPP_NODEBUG = | ... | @@ -147,15 +138,14 @@ using __is_always_equal _LIBCPP_NODEBUG = |
| 147 | __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>; | 138 | __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>; |
| 148 | 139 | ||
| 149 | // __allocator_traits_rebind | 140 | // __allocator_traits_rebind |
| 150 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 151 | template <class _Tp, class _Up, class = void> | 141 | template <class _Tp, class _Up, class = void> |
| 152 | struct __has_rebind_other : false_type {}; | 142 | inline const bool __has_rebind_other_v = false; |
| 153 | template <class _Tp, class _Up> | 143 | template <class _Tp, class _Up> |
| 154 | struct __has_rebind_other<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other> > : true_type {}; | 144 | inline const bool __has_rebind_other_v<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other> > = true; |
| 155 | 145 | ||
| 156 | template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> | 146 | template <class _Tp, class _Up, bool = __has_rebind_other_v<_Tp, _Up> > |
| 157 | struct __allocator_traits_rebind { | 147 | struct __allocator_traits_rebind { |
| 158 | static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement rebind"); | 148 | static_assert(__has_rebind_other_v<_Tp, _Up>, "This allocator has to implement rebind"); |
| 159 | using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; | 149 | using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; |
| 160 | }; | 150 | }; |
| 161 | template <template <class, class...> class _Alloc, class _Tp, class... _Args, class _Up> | 151 | template <template <class, class...> class _Alloc, class _Tp, class... _Args, class _Up> |
| ... | @@ -173,53 +163,52 @@ using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_ | ... | @@ -173,53 +163,52 @@ using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_ |
| 173 | 163 | ||
| 174 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 164 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 175 | 165 | ||
| 176 | // __has_allocate_hint | 166 | // __has_allocate_hint_v |
| 177 | template <class _Alloc, class _SizeType, class _ConstVoidPtr, class = void> | 167 | template <class _Alloc, class _SizeType, class _ConstVoidPtr, class = void> |
| 178 | struct __has_allocate_hint : false_type {}; | 168 | inline const bool __has_allocate_hint_v = false; |
| 179 | 169 | ||
| 180 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 170 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> |
| 181 | struct __has_allocate_hint< | 171 | inline const bool __has_allocate_hint_v< |
| 182 | _Alloc, | 172 | _Alloc, |
| 183 | _SizeType, | 173 | _SizeType, |
| 184 | _ConstVoidPtr, | 174 | _ConstVoidPtr, |
| 185 | decltype((void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))> | 175 | decltype((void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))> = true; |
| 186 | : true_type {}; | ||
| 187 | 176 | ||
| 188 | // __has_construct | 177 | // __has_construct_v |
| 189 | template <class, class _Alloc, class... _Args> | 178 | template <class, class _Alloc, class... _Args> |
| 190 | struct __has_construct_impl : false_type {}; | 179 | inline const bool __has_construct_impl = false; |
| 191 | 180 | ||
| 192 | template <class _Alloc, class... _Args> | 181 | template <class _Alloc, class... _Args> |
| 193 | struct __has_construct_impl<decltype((void)std::declval<_Alloc>().construct(std::declval<_Args>()...)), | 182 | inline const bool |
| 194 | _Alloc, | 183 | __has_construct_impl<decltype((void)std::declval<_Alloc>().construct(std::declval<_Args>()...)), _Alloc, _Args...> = |
| 195 | _Args...> : true_type {}; | 184 | true; |
| 196 | 185 | ||
| 197 | template <class _Alloc, class... _Args> | 186 | template <class _Alloc, class... _Args> |
| 198 | struct __has_construct : __has_construct_impl<void, _Alloc, _Args...> {}; | 187 | inline const bool __has_construct_v = __has_construct_impl<void, _Alloc, _Args...>; |
| 199 | 188 | ||
| 200 | // __has_destroy | 189 | // __has_destroy_v |
| 201 | template <class _Alloc, class _Pointer, class = void> | 190 | template <class _Alloc, class _Pointer, class = void> |
| 202 | struct __has_destroy : false_type {}; | 191 | inline const bool __has_destroy_v = false; |
| 203 | 192 | ||
| 204 | template <class _Alloc, class _Pointer> | 193 | template <class _Alloc, class _Pointer> |
| 205 | struct __has_destroy<_Alloc, _Pointer, decltype((void)std::declval<_Alloc>().destroy(std::declval<_Pointer>()))> | 194 | inline const bool |
| 206 | : true_type {}; | 195 | __has_destroy_v<_Alloc, _Pointer, decltype((void)std::declval<_Alloc>().destroy(std::declval<_Pointer>()))> = true; |
| 207 | 196 | ||
| 208 | // __has_max_size | 197 | // __has_max_size_v |
| 209 | template <class _Alloc, class = void> | 198 | template <class _Alloc, class = void> |
| 210 | struct __has_max_size : false_type {}; | 199 | inline const bool __has_max_size_v = false; |
| 211 | 200 | ||
| 212 | template <class _Alloc> | 201 | template <class _Alloc> |
| 213 | struct __has_max_size<_Alloc, decltype((void)std::declval<_Alloc&>().max_size())> : true_type {}; | 202 | inline const bool __has_max_size_v<_Alloc, decltype((void)std::declval<_Alloc&>().max_size())> = true; |
| 214 | 203 | ||
| 215 | // __has_select_on_container_copy_construction | 204 | // __has_select_on_container_copy_construction_v |
| 216 | template <class _Alloc, class = void> | 205 | template <class _Alloc, class = void> |
| 217 | struct __has_select_on_container_copy_construction : false_type {}; | 206 | inline const bool __has_select_on_container_copy_construction_v = false; |
| 218 | 207 | ||
| 219 | template <class _Alloc> | 208 | template <class _Alloc> |
| 220 | struct __has_select_on_container_copy_construction< | 209 | inline const bool __has_select_on_container_copy_construction_v< |
| 221 | _Alloc, | 210 | _Alloc, |
| 222 | decltype((void)std::declval<_Alloc>().select_on_container_copy_construction())> : true_type {}; | 211 | decltype((void)std::declval<_Alloc>().select_on_container_copy_construction())> = true; |
| 223 | 212 | ||
| 224 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 213 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 225 | 214 | ||
| ... | @@ -235,13 +224,13 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); | ... | @@ -235,13 +224,13 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); |
| 235 | #endif // _LIBCPP_STD_VER | 224 | #endif // _LIBCPP_STD_VER |
| 236 | 225 | ||
| 237 | template <class _Alloc> | 226 | template <class _Alloc> |
| 238 | struct _LIBCPP_TEMPLATE_VIS allocator_traits { | 227 | struct allocator_traits { |
| 239 | using allocator_type = _Alloc; | 228 | using allocator_type = _Alloc; |
| 240 | using value_type = typename allocator_type::value_type; | 229 | using value_type = typename allocator_type::value_type; |
| 241 | using pointer = __pointer<value_type, allocator_type>; | 230 | using pointer = __pointer<value_type, allocator_type>; |
| 242 | using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type; | 231 | using const_pointer = __const_pointer_t<value_type, pointer, allocator_type>; |
| 243 | using void_pointer = typename __void_pointer<pointer, allocator_type>::type; | 232 | using void_pointer = __void_pointer_t<pointer, allocator_type>; |
| 244 | using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type; | 233 | using const_void_pointer = __const_void_pointer_t<pointer, allocator_type>; |
| 245 | using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type; | 234 | using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type; |
| 246 | using size_type = __size_type<allocator_type, difference_type>; | 235 | using size_type = __size_type<allocator_type, difference_type>; |
| 247 | using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment<allocator_type>; | 236 | using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment<allocator_type>; |
| ... | @@ -270,16 +259,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { | ... | @@ -270,16 +259,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 270 | return __a.allocate(__n); | 259 | return __a.allocate(__n); |
| 271 | } | 260 | } |
| 272 | 261 | ||
| 273 | template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> | 262 | template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint_v<_Ap, size_type, const_void_pointer>, int> = 0> |
| 274 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | 263 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer |
| 275 | allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { | 264 | allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { |
| 276 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 265 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 277 | return __a.allocate(__n, __hint); | 266 | return __a.allocate(__n, __hint); |
| 278 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 267 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 279 | } | 268 | } |
| 280 | template <class _Ap = _Alloc, | 269 | template <class _Ap = _Alloc, __enable_if_t<!__has_allocate_hint_v<_Ap, size_type, const_void_pointer>, int> = 0> |
| 281 | class = void, | ||
| 282 | __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> | ||
| 283 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | 270 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer |
| 284 | allocate(allocator_type& __a, size_type __n, const_void_pointer) { | 271 | allocate(allocator_type& __a, size_type __n, const_void_pointer) { |
| 285 | return __a.allocate(__n); | 272 | return __a.allocate(__n); |
| ... | @@ -302,52 +289,47 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { | ... | @@ -302,52 +289,47 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 302 | __a.deallocate(__p, __n); | 289 | __a.deallocate(__p, __n); |
| 303 | } | 290 | } |
| 304 | 291 | ||
| 305 | template <class _Tp, class... _Args, __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0> | 292 | template <class _Tp, class... _Args, __enable_if_t<__has_construct_v<allocator_type, _Tp*, _Args...>, int> = 0> |
| 306 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void | 293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void |
| 307 | construct(allocator_type& __a, _Tp* __p, _Args&&... __args) { | 294 | construct(allocator_type& __a, _Tp* __p, _Args&&... __args) { |
| 308 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 295 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 309 | __a.construct(__p, std::forward<_Args>(__args)...); | 296 | __a.construct(__p, std::forward<_Args>(__args)...); |
| 310 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 297 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 311 | } | 298 | } |
| 312 | template <class _Tp, | 299 | template <class _Tp, class... _Args, __enable_if_t<!__has_construct_v<allocator_type, _Tp*, _Args...>, int> = 0> |
| 313 | class... _Args, | ||
| 314 | class = void, | ||
| 315 | __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0> | ||
| 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void | 300 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void |
| 317 | construct(allocator_type&, _Tp* __p, _Args&&... __args) { | 301 | construct(allocator_type&, _Tp* __p, _Args&&... __args) { |
| 318 | std::__construct_at(__p, std::forward<_Args>(__args)...); | 302 | std::__construct_at(__p, std::forward<_Args>(__args)...); |
| 319 | } | 303 | } |
| 320 | 304 | ||
| 321 | template <class _Tp, __enable_if_t<__has_destroy<allocator_type, _Tp*>::value, int> = 0> | 305 | template <class _Tp, __enable_if_t<__has_destroy_v<allocator_type, _Tp*>, int> = 0> |
| 322 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type& __a, _Tp* __p) { | 306 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type& __a, _Tp* __p) { |
| 323 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 307 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 324 | __a.destroy(__p); | 308 | __a.destroy(__p); |
| 325 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 309 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 326 | } | 310 | } |
| 327 | template <class _Tp, class = void, __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value, int> = 0> | 311 | template <class _Tp, __enable_if_t<!__has_destroy_v<allocator_type, _Tp*>, int> = 0> |
| 328 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) { | 312 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) { |
| 329 | std::__destroy_at(__p); | 313 | std::__destroy_at(__p); |
| 330 | } | 314 | } |
| 331 | 315 | ||
| 332 | template <class _Ap = _Alloc, __enable_if_t<__has_max_size<const _Ap>::value, int> = 0> | 316 | template <class _Ap = _Alloc, __enable_if_t<__has_max_size_v<const _Ap>, int> = 0> |
| 333 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT { | 317 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT { |
| 334 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 318 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 335 | return __a.max_size(); | 319 | return __a.max_size(); |
| 336 | _LIBCPP_SUPPRESS_DEPRECATED_POP | 320 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 337 | } | 321 | } |
| 338 | template <class _Ap = _Alloc, class = void, __enable_if_t<!__has_max_size<const _Ap>::value, int> = 0> | 322 | template <class _Ap = _Alloc, __enable_if_t<!__has_max_size_v<const _Ap>, int> = 0> |
| 339 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT { | 323 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT { |
| 340 | return numeric_limits<size_type>::max() / sizeof(value_type); | 324 | return numeric_limits<size_type>::max() / sizeof(value_type); |
| 341 | } | 325 | } |
| 342 | 326 | ||
| 343 | template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value, int> = 0> | 327 | template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction_v<const _Ap>, int> = 0> |
| 344 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type | 328 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type |
| 345 | select_on_container_copy_construction(const allocator_type& __a) { | 329 | select_on_container_copy_construction(const allocator_type& __a) { |
| 346 | return __a.select_on_container_copy_construction(); | 330 | return __a.select_on_container_copy_construction(); |
| 347 | } | 331 | } |
| 348 | template <class _Ap = _Alloc, | 332 | template <class _Ap = _Alloc, __enable_if_t<!__has_select_on_container_copy_construction_v<const _Ap>, int> = 0> |
| 349 | class = void, | ||
| 350 | __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value, int> = 0> | ||
| 351 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type | 333 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type |
| 352 | select_on_container_copy_construction(const allocator_type& __a) { | 334 | select_on_container_copy_construction(const allocator_type& __a) { |
| 353 | return __a; | 335 | return __a; |
| ... | @@ -370,42 +352,27 @@ struct __check_valid_allocator : true_type { | ... | @@ -370,42 +352,27 @@ struct __check_valid_allocator : true_type { |
| 370 | "original allocator"); | 352 | "original allocator"); |
| 371 | }; | 353 | }; |
| 372 | 354 | ||
| 373 | // __is_default_allocator | 355 | // __is_default_allocator_v |
| 374 | template <class _Tp> | 356 | template <class _Tp> |
| 375 | struct __is_default_allocator : false_type {}; | 357 | inline const bool __is_std_allocator_v = false; |
| 376 | |||
| 377 | template <class> | ||
| 378 | class allocator; | ||
| 379 | 358 | ||
| 380 | template <class _Tp> | 359 | template <class _Tp> |
| 381 | struct __is_default_allocator<allocator<_Tp> > : true_type {}; | 360 | inline const bool __is_std_allocator_v<allocator<_Tp> > = true; |
| 382 | |||
| 383 | // __is_cpp17_move_insertable | ||
| 384 | template <class _Alloc, class = void> | ||
| 385 | struct __is_cpp17_move_insertable : is_move_constructible<typename _Alloc::value_type> {}; | ||
| 386 | 361 | ||
| 362 | // __is_cpp17_move_insertable_v | ||
| 387 | template <class _Alloc> | 363 | template <class _Alloc> |
| 388 | struct __is_cpp17_move_insertable< | 364 | inline const bool __is_cpp17_move_insertable_v = |
| 389 | _Alloc, | 365 | is_move_constructible<typename _Alloc::value_type>::value || |
| 390 | __enable_if_t< !__is_default_allocator<_Alloc>::value && | 366 | (!__is_std_allocator_v<_Alloc> && |
| 391 | __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value > > | 367 | __has_construct_v<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>); |
| 392 | : true_type {}; | ||
| 393 | |||
| 394 | // __is_cpp17_copy_insertable | ||
| 395 | template <class _Alloc, class = void> | ||
| 396 | struct __is_cpp17_copy_insertable | ||
| 397 | : integral_constant<bool, | ||
| 398 | is_copy_constructible<typename _Alloc::value_type>::value && | ||
| 399 | __is_cpp17_move_insertable<_Alloc>::value > {}; | ||
| 400 | 368 | ||
| 369 | // __is_cpp17_copy_insertable_v | ||
| 401 | template <class _Alloc> | 370 | template <class _Alloc> |
| 402 | struct __is_cpp17_copy_insertable< | 371 | inline const bool __is_cpp17_copy_insertable_v = |
| 403 | _Alloc, | 372 | __is_cpp17_move_insertable_v<_Alloc> && |
| 404 | __enable_if_t< !__is_default_allocator<_Alloc>::value && | 373 | (is_copy_constructible<typename _Alloc::value_type>::value || |
| 405 | __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value > > | 374 | (!__is_std_allocator_v<_Alloc> && |
| 406 | : __is_cpp17_move_insertable<_Alloc> {}; | 375 | __has_construct_v<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>)); |
| 407 | |||
| 408 | #undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX | ||
| 409 | 376 | ||
| 410 | _LIBCPP_END_NAMESPACE_STD | 377 | _LIBCPP_END_NAMESPACE_STD |
| 411 | 378 |
lib/libcxx/include/__memory/auto_ptr.h+2-2| ... | @@ -26,7 +26,7 @@ struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref { | ... | @@ -26,7 +26,7 @@ struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref { |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | template <class _Tp> | 28 | template <class _Tp> |
| 29 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr { | 29 | class _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr { |
| 30 | private: | 30 | private: |
| 31 | _Tp* __ptr_; | 31 | _Tp* __ptr_; |
| 32 | 32 | ||
| ... | @@ -80,7 +80,7 @@ public: | ... | @@ -80,7 +80,7 @@ public: |
| 80 | }; | 80 | }; |
| 81 | 81 | ||
| 82 | template <> | 82 | template <> |
| 83 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void> { | 83 | class _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void> { |
| 84 | public: | 84 | public: |
| 85 | typedef void element_type; | 85 | typedef void element_type; |
| 86 | }; | 86 | }; |
lib/libcxx/include/__memory/compressed_pair.h+50-19| ... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
| 15 | #include <__type_traits/datasizeof.h> | 15 | #include <__type_traits/datasizeof.h> |
| 16 | #include <__type_traits/is_empty.h> | 16 | #include <__type_traits/is_empty.h> |
| 17 | #include <__type_traits/is_final.h> | 17 | #include <__type_traits/is_final.h> |
| 18 | #include <__type_traits/is_reference.h> | ||
| 19 | 18 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | # pragma GCC system_header | 20 | # pragma GCC system_header |
| ... | @@ -63,9 +62,17 @@ inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp); | ... | @@ -63,9 +62,17 @@ inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp); |
| 63 | template <class _Tp> | 62 | template <class _Tp> |
| 64 | inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*); | 63 | inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*); |
| 65 | 64 | ||
| 66 | template <class _ToPad, | 65 | template <class _ToPad> |
| 67 | bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || | 66 | inline const bool __is_reference_or_unpadded_object = |
| 68 | is_reference<_ToPad>::value || sizeof(_ToPad) == __datasizeof_v<_ToPad>)> | 67 | (is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || sizeof(_ToPad) == __datasizeof_v<_ToPad>; |
| 68 | |||
| 69 | template <class _Tp> | ||
| 70 | inline const bool __is_reference_or_unpadded_object<_Tp&> = true; | ||
| 71 | |||
| 72 | template <class _Tp> | ||
| 73 | inline const bool __is_reference_or_unpadded_object<_Tp&&> = true; | ||
| 74 | |||
| 75 | template <class _ToPad, bool _Empty = __is_reference_or_unpadded_object<_ToPad> > | ||
| 69 | class __compressed_pair_padding { | 76 | class __compressed_pair_padding { |
| 70 | char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {}; | 77 | char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {}; |
| 71 | }; | 78 | }; |
| ... | @@ -73,21 +80,45 @@ class __compressed_pair_padding { | ... | @@ -73,21 +80,45 @@ class __compressed_pair_padding { |
| 73 | template <class _ToPad> | 80 | template <class _ToPad> |
| 74 | class __compressed_pair_padding<_ToPad, true> {}; | 81 | class __compressed_pair_padding<_ToPad, true> {}; |
| 75 | 82 | ||
| 76 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ | 83 | // TODO: Fix the ABI for GCC as well once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121637 is fixed |
| 77 | _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \ | 84 | # ifdef _LIBCPP_COMPILER_GCC |
| 78 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | 85 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ |
| 79 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | 86 | _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \ |
| 80 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _) | 87 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ |
| 81 | 88 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | |
| 82 | # define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \ | 89 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _) |
| 83 | _LIBCPP_NO_UNIQUE_ADDRESS \ | 90 | |
| 84 | __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \ | 91 | # define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \ |
| 85 | __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \ | 92 | _LIBCPP_NO_UNIQUE_ADDRESS \ |
| 86 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | 93 | __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \ |
| 87 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | 94 | __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \ |
| 88 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ | 95 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ |
| 89 | _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \ | 96 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ |
| 90 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _) | 97 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ |
| 98 | _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \ | ||
| 99 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _) | ||
| 100 | # else | ||
| 101 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ | ||
| 102 | struct { \ | ||
| 103 | _LIBCPP_NO_UNIQUE_ADDRESS \ | ||
| 104 | __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \ | ||
| 105 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | ||
| 106 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | ||
| 107 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ | ||
| 108 | } | ||
| 109 | |||
| 110 | # define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \ | ||
| 111 | struct { \ | ||
| 112 | _LIBCPP_NO_UNIQUE_ADDRESS \ | ||
| 113 | __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \ | ||
| 114 | __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \ | ||
| 115 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | ||
| 116 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | ||
| 117 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ | ||
| 118 | _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \ | ||
| 119 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _); \ | ||
| 120 | } | ||
| 121 | # endif | ||
| 91 | 122 | ||
| 92 | #else | 123 | #else |
| 93 | # define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ | 124 | # define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ |
lib/libcxx/include/__memory/construct_at.h+4-38| ... | @@ -12,14 +12,12 @@ | ... | @@ -12,14 +12,12 @@ |
| 12 | 12 | ||
| 13 | #include <__assert> | 13 | #include <__assert> |
| 14 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__iterator/access.h> | ||
| 16 | #include <__memory/addressof.h> | 15 | #include <__memory/addressof.h> |
| 17 | #include <__new/placement_new_delete.h> | 16 | #include <__new/placement_new_delete.h> |
| 18 | #include <__type_traits/enable_if.h> | 17 | #include <__type_traits/enable_if.h> |
| 19 | #include <__type_traits/is_array.h> | 18 | #include <__type_traits/is_array.h> |
| 20 | #include <__utility/declval.h> | 19 | #include <__utility/declval.h> |
| 21 | #include <__utility/forward.h> | 20 | #include <__utility/forward.h> |
| 22 | #include <__utility/move.h> | ||
| 23 | 21 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | # pragma GCC system_header | 23 | # pragma GCC system_header |
| ... | @@ -57,9 +55,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l | ... | @@ -57,9 +55,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l |
| 57 | // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` | 55 | // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` |
| 58 | // taking an array). | 56 | // taking an array). |
| 59 | 57 | ||
| 60 | template <class _ForwardIterator> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); | ||
| 62 | |||
| 63 | template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> | 58 | template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> |
| 64 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { | 59 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { |
| 65 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); | 60 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); |
| ... | @@ -68,30 +63,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc | ... | @@ -68,30 +63,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc |
| 68 | 63 | ||
| 69 | #if _LIBCPP_STD_VER >= 20 | 64 | #if _LIBCPP_STD_VER >= 20 |
| 70 | template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0> | 65 | template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0> |
| 71 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { | 66 | _LIBCPP_HIDE_FROM_ABI constexpr void __destroy_at(_Tp* __loc) { |
| 72 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); | 67 | _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); |
| 73 | std::__destroy(std::begin(*__loc), std::end(*__loc)); | 68 | for (auto&& __val : *__loc) |
| 69 | std::__destroy_at(std::addressof(__val)); | ||
| 74 | } | 70 | } |
| 75 | #endif | 71 | #endif |
| 76 | 72 | ||
| 77 | template <class _ForwardIterator> | ||
| 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | ||
| 79 | __destroy(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 80 | for (; __first != __last; ++__first) | ||
| 81 | std::__destroy_at(std::addressof(*__first)); | ||
| 82 | return __first; | ||
| 83 | } | ||
| 84 | |||
| 85 | template <class _BidirectionalIterator> | ||
| 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator | ||
| 87 | __reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) { | ||
| 88 | while (__last != __first) { | ||
| 89 | --__last; | ||
| 90 | std::__destroy_at(std::addressof(*__last)); | ||
| 91 | } | ||
| 92 | return __last; | ||
| 93 | } | ||
| 94 | |||
| 95 | #if _LIBCPP_STD_VER >= 17 | 73 | #if _LIBCPP_STD_VER >= 17 |
| 96 | 74 | ||
| 97 | template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> | 75 | template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> |
| ... | @@ -101,23 +79,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) | ... | @@ -101,23 +79,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) |
| 101 | 79 | ||
| 102 | # if _LIBCPP_STD_VER >= 20 | 80 | # if _LIBCPP_STD_VER >= 20 |
| 103 | template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0> | 81 | template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0> |
| 104 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) { | 82 | _LIBCPP_HIDE_FROM_ABI constexpr void destroy_at(_Tp* __loc) { |
| 105 | std::__destroy_at(__loc); | 83 | std::__destroy_at(__loc); |
| 106 | } | 84 | } |
| 107 | # endif | 85 | # endif |
| 108 | 86 | ||
| 109 | template <class _ForwardIterator> | ||
| 110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 111 | (void)std::__destroy(std::move(__first), std::move(__last)); | ||
| 112 | } | ||
| 113 | |||
| 114 | template <class _ForwardIterator, class _Size> | ||
| 115 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { | ||
| 116 | for (; __n > 0; (void)++__first, --__n) | ||
| 117 | std::__destroy_at(std::addressof(*__first)); | ||
| 118 | return __first; | ||
| 119 | } | ||
| 120 | |||
| 121 | #endif // _LIBCPP_STD_VER >= 17 | 87 | #endif // _LIBCPP_STD_VER >= 17 |
| 122 | 88 | ||
| 123 | _LIBCPP_END_NAMESPACE_STD | 89 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__memory/destroy.h created+71| ... | @@ -0,0 +1,71 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___MEMORY_DESTROY_H | ||
| 10 | #define _LIBCPP___MEMORY_DESTROY_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__memory/addressof.h> | ||
| 14 | #include <__memory/allocator_traits.h> | ||
| 15 | #include <__memory/construct_at.h> | ||
| 16 | #include <__utility/move.h> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_PUSH_MACROS | ||
| 23 | #include <__undef_macros> | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | |||
| 27 | template <class _ForwardIterator> | ||
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | ||
| 29 | __destroy(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 30 | for (; __first != __last; ++__first) | ||
| 31 | std::__destroy_at(std::addressof(*__first)); | ||
| 32 | return __first; | ||
| 33 | } | ||
| 34 | |||
| 35 | template <class _BidirectionalIterator> | ||
| 36 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator | ||
| 37 | __reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) { | ||
| 38 | while (__last != __first) { | ||
| 39 | --__last; | ||
| 40 | std::__destroy_at(std::addressof(*__last)); | ||
| 41 | } | ||
| 42 | return __last; | ||
| 43 | } | ||
| 44 | |||
| 45 | // Destroy all elements in [__first, __last) from left to right using allocator destruction. | ||
| 46 | template <class _Alloc, class _Iter, class _Sent> | ||
| 47 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | ||
| 48 | __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) { | ||
| 49 | for (; __first != __last; ++__first) | ||
| 50 | allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__first)); | ||
| 51 | } | ||
| 52 | |||
| 53 | #if _LIBCPP_STD_VER >= 17 | ||
| 54 | template <class _ForwardIterator> | ||
| 55 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 56 | (void)std::__destroy(std::move(__first), std::move(__last)); | ||
| 57 | } | ||
| 58 | |||
| 59 | template <class _ForwardIterator, class _Size> | ||
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { | ||
| 61 | for (; __n > 0; (void)++__first, --__n) | ||
| 62 | std::__destroy_at(std::addressof(*__first)); | ||
| 63 | return __first; | ||
| 64 | } | ||
| 65 | #endif | ||
| 66 | |||
| 67 | _LIBCPP_END_NAMESPACE_STD | ||
| 68 | |||
| 69 | _LIBCPP_POP_MACROS | ||
| 70 | |||
| 71 | #endif // _LIBCPP___MEMORY_DESTROY_H | ||
lib/libcxx/include/__memory/inout_ptr.h+1-1| ... | @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | #if _LIBCPP_STD_VER >= 23 | 35 | #if _LIBCPP_STD_VER >= 23 |
| 36 | 36 | ||
| 37 | template <class _Smart, class _Pointer, class... _Args> | 37 | template <class _Smart, class _Pointer, class... _Args> |
| 38 | class _LIBCPP_TEMPLATE_VIS inout_ptr_t { | 38 | class inout_ptr_t { |
| 39 | static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr."); | 39 | static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr."); |
| 40 | 40 | ||
| 41 | public: | 41 | public: |
lib/libcxx/include/__memory/is_sufficiently_aligned.h created+34| ... | @@ -0,0 +1,34 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___MEMORY_IS_SUFFICIENTLY_ALIGNED_H | ||
| 11 | #define _LIBCPP___MEMORY_IS_SUFFICIENTLY_ALIGNED_H | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | #include <__cstddef/size_t.h> | ||
| 15 | #include <cstdint> | ||
| 16 | |||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 18 | # pragma GCC system_header | ||
| 19 | #endif | ||
| 20 | |||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 22 | |||
| 23 | #if _LIBCPP_STD_VER >= 26 | ||
| 24 | |||
| 25 | template <size_t _Alignment, class _Tp> | ||
| 26 | _LIBCPP_HIDE_FROM_ABI bool is_sufficiently_aligned(_Tp* __ptr) { | ||
| 27 | return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0; | ||
| 28 | } | ||
| 29 | |||
| 30 | #endif // _LIBCPP_STD_VER >= 26 | ||
| 31 | |||
| 32 | _LIBCPP_END_NAMESPACE_STD | ||
| 33 | |||
| 34 | #endif // _LIBCPP___MEMORY_IS_SUFFICIENTLY_ALIGNED_H | ||
lib/libcxx/include/__memory/out_ptr.h+1-1| ... | @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | #if _LIBCPP_STD_VER >= 23 | 34 | #if _LIBCPP_STD_VER >= 23 |
| 35 | 35 | ||
| 36 | template <class _Smart, class _Pointer, class... _Args> | 36 | template <class _Smart, class _Pointer, class... _Args> |
| 37 | class _LIBCPP_TEMPLATE_VIS out_ptr_t { | 37 | class out_ptr_t { |
| 38 | static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0, | 38 | static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0, |
| 39 | "Using std::shared_ptr<> without a deleter in std::out_ptr is not supported."); | 39 | "Using std::shared_ptr<> without a deleter in std::out_ptr is not supported."); |
| 40 | 40 |
lib/libcxx/include/__memory/pointer_traits.h+52-90| ... | @@ -16,11 +16,13 @@ | ... | @@ -16,11 +16,13 @@ |
| 16 | #include <__type_traits/conditional.h> | 16 | #include <__type_traits/conditional.h> |
| 17 | #include <__type_traits/conjunction.h> | 17 | #include <__type_traits/conjunction.h> |
| 18 | #include <__type_traits/decay.h> | 18 | #include <__type_traits/decay.h> |
| 19 | #include <__type_traits/detected_or.h> | ||
| 19 | #include <__type_traits/enable_if.h> | 20 | #include <__type_traits/enable_if.h> |
| 20 | #include <__type_traits/integral_constant.h> | 21 | #include <__type_traits/integral_constant.h> |
| 21 | #include <__type_traits/is_class.h> | 22 | #include <__type_traits/is_class.h> |
| 22 | #include <__type_traits/is_function.h> | 23 | #include <__type_traits/is_function.h> |
| 23 | #include <__type_traits/is_void.h> | 24 | #include <__type_traits/is_void.h> |
| 25 | #include <__type_traits/nat.h> | ||
| 24 | #include <__type_traits/void_t.h> | 26 | #include <__type_traits/void_t.h> |
| 25 | #include <__utility/declval.h> | 27 | #include <__utility/declval.h> |
| 26 | #include <__utility/forward.h> | 28 | #include <__utility/forward.h> |
| ... | @@ -34,67 +36,37 @@ _LIBCPP_PUSH_MACROS | ... | @@ -34,67 +36,37 @@ _LIBCPP_PUSH_MACROS |
| 34 | 36 | ||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 38 | ||
| 37 | // clang-format off | ||
| 38 | #define _LIBCPP_CLASS_TRAITS_HAS_XXX(NAME, PROPERTY) \ | ||
| 39 | template <class _Tp, class = void> \ | ||
| 40 | struct NAME : false_type {}; \ | ||
| 41 | template <class _Tp> \ | ||
| 42 | struct NAME<_Tp, __void_t<typename _Tp::PROPERTY> > : true_type {} | ||
| 43 | // clang-format on | ||
| 44 | |||
| 45 | _LIBCPP_CLASS_TRAITS_HAS_XXX(__has_pointer, pointer); | ||
| 46 | _LIBCPP_CLASS_TRAITS_HAS_XXX(__has_element_type, element_type); | ||
| 47 | |||
| 48 | template <class _Ptr, bool = __has_element_type<_Ptr>::value> | ||
| 49 | struct __pointer_traits_element_type {}; | ||
| 50 | |||
| 51 | template <class _Ptr> | 39 | template <class _Ptr> |
| 52 | struct __pointer_traits_element_type<_Ptr, true> { | 40 | struct __pointer_traits_element_type_impl {}; |
| 53 | using type _LIBCPP_NODEBUG = typename _Ptr::element_type; | ||
| 54 | }; | ||
| 55 | 41 | ||
| 56 | template <template <class, class...> class _Sp, class _Tp, class... _Args> | 42 | template <template <class, class...> class _Sp, class _Tp, class... _Args> |
| 57 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> { | 43 | struct __pointer_traits_element_type_impl<_Sp<_Tp, _Args...> > { |
| 58 | using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::element_type; | ||
| 59 | }; | ||
| 60 | |||
| 61 | template <template <class, class...> class _Sp, class _Tp, class... _Args> | ||
| 62 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> { | ||
| 63 | using type _LIBCPP_NODEBUG = _Tp; | 44 | using type _LIBCPP_NODEBUG = _Tp; |
| 64 | }; | 45 | }; |
| 65 | 46 | ||
| 66 | template <class _Tp, class = void> | 47 | template <class _Ptr, class = void> |
| 67 | struct __has_difference_type : false_type {}; | 48 | struct __pointer_traits_element_type : __pointer_traits_element_type_impl<_Ptr> {}; |
| 68 | |||
| 69 | template <class _Tp> | ||
| 70 | struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : true_type {}; | ||
| 71 | |||
| 72 | template <class _Ptr, bool = __has_difference_type<_Ptr>::value> | ||
| 73 | struct __pointer_traits_difference_type { | ||
| 74 | using type _LIBCPP_NODEBUG = ptrdiff_t; | ||
| 75 | }; | ||
| 76 | 49 | ||
| 77 | template <class _Ptr> | 50 | template <class _Ptr> |
| 78 | struct __pointer_traits_difference_type<_Ptr, true> { | 51 | struct __pointer_traits_element_type<_Ptr, __void_t<typename _Ptr::element_type> > { |
| 79 | using type _LIBCPP_NODEBUG = typename _Ptr::difference_type; | 52 | using type _LIBCPP_NODEBUG = typename _Ptr::element_type; |
| 80 | }; | 53 | }; |
| 81 | 54 | ||
| 82 | template <class _Tp, class _Up> | 55 | template <class _Tp, class _Up> |
| 83 | struct __has_rebind { | 56 | struct __pointer_traits_rebind_impl { |
| 84 | private: | 57 | static_assert(false, "Cannot rebind pointer; did you forget to add a rebind member to your pointer?"); |
| 85 | template <class _Xp> | 58 | }; |
| 86 | static false_type __test(...); | ||
| 87 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 88 | template <class _Xp> | ||
| 89 | static true_type __test(typename _Xp::template rebind<_Up>* = 0); | ||
| 90 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 91 | 59 | ||
| 92 | public: | 60 | template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up> |
| 93 | static const bool value = decltype(__test<_Tp>(0))::value; | 61 | struct __pointer_traits_rebind_impl<_Sp<_Tp, _Args...>, _Up> { |
| 62 | using type _LIBCPP_NODEBUG = _Sp<_Up, _Args...>; | ||
| 94 | }; | 63 | }; |
| 95 | 64 | ||
| 96 | template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> | 65 | template <class _Tp, class _Up, class = void> |
| 97 | struct __pointer_traits_rebind { | 66 | struct __pointer_traits_rebind : __pointer_traits_rebind_impl<_Tp, _Up> {}; |
| 67 | |||
| 68 | template <class _Tp, class _Up> | ||
| 69 | struct __pointer_traits_rebind<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up> > > { | ||
| 98 | #ifndef _LIBCPP_CXX03_LANG | 70 | #ifndef _LIBCPP_CXX03_LANG |
| 99 | using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>; | 71 | using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>; |
| 100 | #else | 72 | #else |
| ... | @@ -102,19 +74,8 @@ struct __pointer_traits_rebind { | ... | @@ -102,19 +74,8 @@ struct __pointer_traits_rebind { |
| 102 | #endif | 74 | #endif |
| 103 | }; | 75 | }; |
| 104 | 76 | ||
| 105 | template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up> | 77 | template <class _Tp> |
| 106 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> { | 78 | using __difference_type_member _LIBCPP_NODEBUG = typename _Tp::difference_type; |
| 107 | #ifndef _LIBCPP_CXX03_LANG | ||
| 108 | using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>; | ||
| 109 | #else | ||
| 110 | using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>::other; | ||
| 111 | #endif | ||
| 112 | }; | ||
| 113 | |||
| 114 | template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up> | ||
| 115 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> { | ||
| 116 | typedef _Sp<_Up, _Args...> type; | ||
| 117 | }; | ||
| 118 | 79 | ||
| 119 | template <class _Ptr, class = void> | 80 | template <class _Ptr, class = void> |
| 120 | struct __pointer_traits_impl {}; | 81 | struct __pointer_traits_impl {}; |
| ... | @@ -123,7 +84,7 @@ template <class _Ptr> | ... | @@ -123,7 +84,7 @@ template <class _Ptr> |
| 123 | struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_type<_Ptr>::type> > { | 84 | struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_type<_Ptr>::type> > { |
| 124 | typedef _Ptr pointer; | 85 | typedef _Ptr pointer; |
| 125 | typedef typename __pointer_traits_element_type<pointer>::type element_type; | 86 | typedef typename __pointer_traits_element_type<pointer>::type element_type; |
| 126 | typedef typename __pointer_traits_difference_type<pointer>::type difference_type; | 87 | using difference_type = __detected_or_t<ptrdiff_t, __difference_type_member, pointer>; |
| 127 | 88 | ||
| 128 | #ifndef _LIBCPP_CXX03_LANG | 89 | #ifndef _LIBCPP_CXX03_LANG |
| 129 | template <class _Up> | 90 | template <class _Up> |
| ... | @@ -135,9 +96,6 @@ struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_ty | ... | @@ -135,9 +96,6 @@ struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_ty |
| 135 | }; | 96 | }; |
| 136 | #endif // _LIBCPP_CXX03_LANG | 97 | #endif // _LIBCPP_CXX03_LANG |
| 137 | 98 | ||
| 138 | private: | ||
| 139 | struct __nat {}; | ||
| 140 | |||
| 141 | public: | 99 | public: |
| 142 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | 100 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer |
| 143 | pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) { | 101 | pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) { |
| ... | @@ -146,10 +104,10 @@ public: | ... | @@ -146,10 +104,10 @@ public: |
| 146 | }; | 104 | }; |
| 147 | 105 | ||
| 148 | template <class _Ptr> | 106 | template <class _Ptr> |
| 149 | struct _LIBCPP_TEMPLATE_VIS pointer_traits : __pointer_traits_impl<_Ptr> {}; | 107 | struct pointer_traits : __pointer_traits_impl<_Ptr> {}; |
| 150 | 108 | ||
| 151 | template <class _Tp> | 109 | template <class _Tp> |
| 152 | struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> { | 110 | struct pointer_traits<_Tp*> { |
| 153 | typedef _Tp* pointer; | 111 | typedef _Tp* pointer; |
| 154 | typedef _Tp element_type; | 112 | typedef _Tp element_type; |
| 155 | typedef ptrdiff_t difference_type; | 113 | typedef ptrdiff_t difference_type; |
| ... | @@ -164,9 +122,6 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> { | ... | @@ -164,9 +122,6 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> { |
| 164 | }; | 122 | }; |
| 165 | #endif | 123 | #endif |
| 166 | 124 | ||
| 167 | private: | ||
| 168 | struct __nat {}; | ||
| 169 | |||
| 170 | public: | 125 | public: |
| 171 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | 126 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer |
| 172 | pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) _NOEXCEPT { | 127 | pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) _NOEXCEPT { |
| ... | @@ -245,8 +200,8 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept { | ... | @@ -245,8 +200,8 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept { |
| 245 | } | 200 | } |
| 246 | 201 | ||
| 247 | template <class _Pointer> | 202 | template <class _Pointer> |
| 248 | inline _LIBCPP_HIDE_FROM_ABI constexpr auto | 203 | inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(const _Pointer& __p) noexcept |
| 249 | to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) { | 204 | -> decltype(std::__to_address(__p)) { |
| 250 | return std::__to_address(__p); | 205 | return std::__to_address(__p); |
| 251 | } | 206 | } |
| 252 | #endif | 207 | #endif |
| ... | @@ -257,40 +212,35 @@ template <class _Tp> | ... | @@ -257,40 +212,35 @@ template <class _Tp> |
| 257 | struct __pointer_of {}; | 212 | struct __pointer_of {}; |
| 258 | 213 | ||
| 259 | template <class _Tp> | 214 | template <class _Tp> |
| 260 | requires(__has_pointer<_Tp>::value) | 215 | concept __has_pointer_member = requires { typename _Tp::pointer; }; |
| 216 | |||
| 217 | template <class _Tp> | ||
| 218 | concept __has_element_type_member = requires { typename _Tp::element_type; }; | ||
| 219 | |||
| 220 | template <class _Tp> | ||
| 221 | requires __has_pointer_member<_Tp> | ||
| 261 | struct __pointer_of<_Tp> { | 222 | struct __pointer_of<_Tp> { |
| 262 | using type = typename _Tp::pointer; | 223 | using type _LIBCPP_NODEBUG = typename _Tp::pointer; |
| 263 | }; | 224 | }; |
| 264 | 225 | ||
| 265 | template <class _Tp> | 226 | template <class _Tp> |
| 266 | requires(!__has_pointer<_Tp>::value && __has_element_type<_Tp>::value) | 227 | requires(!__has_pointer_member<_Tp> && __has_element_type_member<_Tp>) |
| 267 | struct __pointer_of<_Tp> { | 228 | struct __pointer_of<_Tp> { |
| 268 | using type = typename _Tp::element_type*; | 229 | using type _LIBCPP_NODEBUG = typename _Tp::element_type*; |
| 269 | }; | 230 | }; |
| 270 | 231 | ||
| 271 | template <class _Tp> | 232 | template <class _Tp> |
| 272 | requires(!__has_pointer<_Tp>::value && !__has_element_type<_Tp>::value && | 233 | requires(!__has_pointer_member<_Tp> && !__has_element_type_member<_Tp> && |
| 273 | __has_element_type<pointer_traits<_Tp>>::value) | 234 | __has_element_type_member<pointer_traits<_Tp>>) |
| 274 | struct __pointer_of<_Tp> { | 235 | struct __pointer_of<_Tp> { |
| 275 | using type = typename pointer_traits<_Tp>::element_type*; | 236 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Tp>::element_type*; |
| 276 | }; | 237 | }; |
| 277 | 238 | ||
| 278 | template <typename _Tp> | 239 | template <typename _Tp> |
| 279 | using __pointer_of_t _LIBCPP_NODEBUG = typename __pointer_of<_Tp>::type; | 240 | using __pointer_of_t _LIBCPP_NODEBUG = typename __pointer_of<_Tp>::type; |
| 280 | 241 | ||
| 281 | template <class _Tp, class _Up> | ||
| 282 | struct __pointer_of_or { | ||
| 283 | using type _LIBCPP_NODEBUG = _Up; | ||
| 284 | }; | ||
| 285 | |||
| 286 | template <class _Tp, class _Up> | ||
| 287 | requires requires { typename __pointer_of_t<_Tp>; } | ||
| 288 | struct __pointer_of_or<_Tp, _Up> { | ||
| 289 | using type _LIBCPP_NODEBUG = __pointer_of_t<_Tp>; | ||
| 290 | }; | ||
| 291 | |||
| 292 | template <typename _Tp, typename _Up> | 242 | template <typename _Tp, typename _Up> |
| 293 | using __pointer_of_or_t _LIBCPP_NODEBUG = typename __pointer_of_or<_Tp, _Up>::type; | 243 | using __pointer_of_or_t _LIBCPP_NODEBUG = __detected_or_t<_Up, __pointer_of_t, _Tp>; |
| 294 | 244 | ||
| 295 | template <class _Smart> | 245 | template <class _Smart> |
| 296 | concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); }; | 246 | concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); }; |
| ... | @@ -302,6 +252,18 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p | ... | @@ -302,6 +252,18 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p |
| 302 | 252 | ||
| 303 | #endif | 253 | #endif |
| 304 | 254 | ||
| 255 | // This function ensures safe conversions between fancy pointers at compile-time, where we avoid casts from/to | ||
| 256 | // `__void_pointer` by obtaining the underlying raw pointer from the fancy pointer using `std::to_address`, | ||
| 257 | // then dereferencing it to retrieve the pointed-to object, and finally constructing the target fancy pointer | ||
| 258 | // to that object using the `std::pointer_traits<>::pinter_to` function. | ||
| 259 | template <class _PtrTo, class _PtrFrom> | ||
| 260 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) { | ||
| 261 | using __ptr_traits = pointer_traits<_PtrTo>; | ||
| 262 | using __element_type = typename __ptr_traits::element_type; | ||
| 263 | return __p ? __ptr_traits::pointer_to(*static_cast<__element_type*>(std::addressof(*__p))) | ||
| 264 | : static_cast<_PtrTo>(nullptr); | ||
| 265 | } | ||
| 266 | |||
| 305 | _LIBCPP_END_NAMESPACE_STD | 267 | _LIBCPP_END_NAMESPACE_STD |
| 306 | 268 | ||
| 307 | _LIBCPP_POP_MACROS | 269 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__memory/ranges_construct_at.h-35| ... | @@ -61,41 +61,6 @@ inline namespace __cpo { | ... | @@ -61,41 +61,6 @@ inline namespace __cpo { |
| 61 | inline constexpr auto destroy_at = __destroy_at{}; | 61 | inline constexpr auto destroy_at = __destroy_at{}; |
| 62 | } // namespace __cpo | 62 | } // namespace __cpo |
| 63 | 63 | ||
| 64 | // destroy | ||
| 65 | |||
| 66 | struct __destroy { | ||
| 67 | template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> | ||
| 68 | requires destructible<iter_value_t<_InputIterator>> | ||
| 69 | _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { | ||
| 70 | return std::__destroy(std::move(__first), std::move(__last)); | ||
| 71 | } | ||
| 72 | |||
| 73 | template <__nothrow_input_range _InputRange> | ||
| 74 | requires destructible<range_value_t<_InputRange>> | ||
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept { | ||
| 76 | return (*this)(ranges::begin(__range), ranges::end(__range)); | ||
| 77 | } | ||
| 78 | }; | ||
| 79 | |||
| 80 | inline namespace __cpo { | ||
| 81 | inline constexpr auto destroy = __destroy{}; | ||
| 82 | } // namespace __cpo | ||
| 83 | |||
| 84 | // destroy_n | ||
| 85 | |||
| 86 | struct __destroy_n { | ||
| 87 | template <__nothrow_input_iterator _InputIterator> | ||
| 88 | requires destructible<iter_value_t<_InputIterator>> | ||
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator | ||
| 90 | operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept { | ||
| 91 | return std::destroy_n(std::move(__first), __n); | ||
| 92 | } | ||
| 93 | }; | ||
| 94 | |||
| 95 | inline namespace __cpo { | ||
| 96 | inline constexpr auto destroy_n = __destroy_n{}; | ||
| 97 | } // namespace __cpo | ||
| 98 | |||
| 99 | } // namespace ranges | 64 | } // namespace ranges |
| 100 | 65 | ||
| 101 | #endif // _LIBCPP_STD_VER >= 20 | 66 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__memory/ranges_destroy.h created+79| ... | @@ -0,0 +1,79 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___MEMORY_RANGES_DESTROY_H | ||
| 11 | #define _LIBCPP___MEMORY_RANGES_DESTROY_H | ||
| 12 | |||
| 13 | #include <__concepts/destructible.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/incrementable_traits.h> | ||
| 16 | #include <__iterator/iterator_traits.h> | ||
| 17 | #include <__memory/concepts.h> | ||
| 18 | #include <__memory/destroy.h> | ||
| 19 | #include <__ranges/access.h> | ||
| 20 | #include <__ranges/concepts.h> | ||
| 21 | #include <__ranges/dangling.h> | ||
| 22 | #include <__utility/move.h> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | _LIBCPP_PUSH_MACROS | ||
| 29 | #include <__undef_macros> | ||
| 30 | |||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 32 | |||
| 33 | #if _LIBCPP_STD_VER >= 20 | ||
| 34 | namespace ranges { | ||
| 35 | |||
| 36 | // destroy | ||
| 37 | |||
| 38 | struct __destroy { | ||
| 39 | template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> | ||
| 40 | requires destructible<iter_value_t<_InputIterator>> | ||
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { | ||
| 42 | return std::__destroy(std::move(__first), std::move(__last)); | ||
| 43 | } | ||
| 44 | |||
| 45 | template <__nothrow_input_range _InputRange> | ||
| 46 | requires destructible<range_value_t<_InputRange>> | ||
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept { | ||
| 48 | return (*this)(ranges::begin(__range), ranges::end(__range)); | ||
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 52 | inline namespace __cpo { | ||
| 53 | inline constexpr auto destroy = __destroy{}; | ||
| 54 | } // namespace __cpo | ||
| 55 | |||
| 56 | // destroy_n | ||
| 57 | |||
| 58 | struct __destroy_n { | ||
| 59 | template <__nothrow_input_iterator _InputIterator> | ||
| 60 | requires destructible<iter_value_t<_InputIterator>> | ||
| 61 | _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator | ||
| 62 | operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept { | ||
| 63 | return std::destroy_n(std::move(__first), __n); | ||
| 64 | } | ||
| 65 | }; | ||
| 66 | |||
| 67 | inline namespace __cpo { | ||
| 68 | inline constexpr auto destroy_n = __destroy_n{}; | ||
| 69 | } // namespace __cpo | ||
| 70 | |||
| 71 | } // namespace ranges | ||
| 72 | |||
| 73 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 74 | |||
| 75 | _LIBCPP_END_NAMESPACE_STD | ||
| 76 | |||
| 77 | _LIBCPP_POP_MACROS | ||
| 78 | |||
| 79 | #endif // _LIBCPP___MEMORY_RANGES_DESTROY_H | ||
lib/libcxx/include/__memory/raw_storage_iterator.h+1-1| ... | @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | ||
| 31 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 31 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 32 | template <class _OutputIterator, class _Tp> | 32 | template <class _OutputIterator, class _Tp> |
| 33 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator | 33 | class _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator |
| 34 | # if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) | 34 | # if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) |
| 35 | : public iterator<output_iterator_tag, void, void, void, void> | 35 | : public iterator<output_iterator_tag, void, void, void, void> |
| 36 | # endif | 36 | # endif |
lib/libcxx/include/__memory/shared_count.h+3-2| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___MEMORY_SHARED_COUNT_H | 10 | #define _LIBCPP___MEMORY_SHARED_COUNT_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__memory/addressof.h> | ||
| 13 | #include <typeinfo> | 14 | #include <typeinfo> |
| 14 | 15 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -52,7 +53,7 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* | ... | @@ -52,7 +53,7 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* |
| 52 | template <class _Tp> | 53 | template <class _Tp> |
| 53 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT { | 54 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT { |
| 54 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS | 55 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS |
| 55 | return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED); | 56 | return __atomic_add_fetch(std::addressof(__t), 1, __ATOMIC_RELAXED); |
| 56 | #else | 57 | #else |
| 57 | return __t += 1; | 58 | return __t += 1; |
| 58 | #endif | 59 | #endif |
| ... | @@ -61,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _N | ... | @@ -61,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _N |
| 61 | template <class _Tp> | 62 | template <class _Tp> |
| 62 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { | 63 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { |
| 63 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS | 64 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS |
| 64 | return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL); | 65 | return __atomic_add_fetch(std::addressof(__t), -1, __ATOMIC_ACQ_REL); |
| 65 | #else | 66 | #else |
| 66 | return __t -= 1; | 67 | return __t -= 1; |
| 67 | #endif | 68 | #endif |
lib/libcxx/include/__memory/shared_ptr.h+23-19| ... | @@ -29,11 +29,12 @@ | ... | @@ -29,11 +29,12 @@ |
| 29 | #include <__memory/auto_ptr.h> | 29 | #include <__memory/auto_ptr.h> |
| 30 | #include <__memory/compressed_pair.h> | 30 | #include <__memory/compressed_pair.h> |
| 31 | #include <__memory/construct_at.h> | 31 | #include <__memory/construct_at.h> |
| 32 | #include <__memory/destroy.h> | ||
| 32 | #include <__memory/pointer_traits.h> | 33 | #include <__memory/pointer_traits.h> |
| 33 | #include <__memory/shared_count.h> | 34 | #include <__memory/shared_count.h> |
| 34 | #include <__memory/uninitialized_algorithms.h> | 35 | #include <__memory/uninitialized_algorithms.h> |
| 35 | #include <__memory/unique_ptr.h> | 36 | #include <__memory/unique_ptr.h> |
| 36 | #include <__type_traits/add_lvalue_reference.h> | 37 | #include <__type_traits/add_reference.h> |
| 37 | #include <__type_traits/conditional.h> | 38 | #include <__type_traits/conditional.h> |
| 38 | #include <__type_traits/conjunction.h> | 39 | #include <__type_traits/conjunction.h> |
| 39 | #include <__type_traits/disjunction.h> | 40 | #include <__type_traits/disjunction.h> |
| ... | @@ -89,7 +90,7 @@ public: | ... | @@ -89,7 +90,7 @@ public: |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | template <class _Tp> | 92 | template <class _Tp> |
| 92 | class _LIBCPP_TEMPLATE_VIS weak_ptr; | 93 | class weak_ptr; |
| 93 | 94 | ||
| 94 | template <class _Tp, class _Dp, class _Alloc> | 95 | template <class _Tp, class _Dp, class _Alloc> |
| 95 | class __shared_ptr_pointer : public __shared_weak_count { | 96 | class __shared_ptr_pointer : public __shared_weak_count { |
| ... | @@ -217,7 +218,7 @@ private: | ... | @@ -217,7 +218,7 @@ private: |
| 217 | 218 | ||
| 218 | struct __shared_ptr_dummy_rebind_allocator_type; | 219 | struct __shared_ptr_dummy_rebind_allocator_type; |
| 219 | template <> | 220 | template <> |
| 220 | class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type> { | 221 | class allocator<__shared_ptr_dummy_rebind_allocator_type> { |
| 221 | public: | 222 | public: |
| 222 | template <class _Other> | 223 | template <class _Other> |
| 223 | struct rebind { | 224 | struct rebind { |
| ... | @@ -226,7 +227,7 @@ public: | ... | @@ -226,7 +227,7 @@ public: |
| 226 | }; | 227 | }; |
| 227 | 228 | ||
| 228 | template <class _Tp> | 229 | template <class _Tp> |
| 229 | class _LIBCPP_TEMPLATE_VIS enable_shared_from_this; | 230 | class enable_shared_from_this; |
| 230 | 231 | ||
| 231 | // http://eel.is/c++draft/util.sharedptr#util.smartptr.shared.general-6 | 232 | // http://eel.is/c++draft/util.sharedptr#util.smartptr.shared.general-6 |
| 232 | // A pointer type Y* is said to be compatible with a pointer type T* | 233 | // A pointer type Y* is said to be compatible with a pointer type T* |
| ... | @@ -303,7 +304,7 @@ using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG = | ... | @@ -303,7 +304,7 @@ using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG = |
| 303 | #endif | 304 | #endif |
| 304 | 305 | ||
| 305 | template <class _Tp> | 306 | template <class _Tp> |
| 306 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { | 307 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI shared_ptr { |
| 307 | struct __nullptr_sfinae_tag {}; | 308 | struct __nullptr_sfinae_tag {}; |
| 308 | 309 | ||
| 309 | public: | 310 | public: |
| ... | @@ -315,8 +316,10 @@ public: | ... | @@ -315,8 +316,10 @@ public: |
| 315 | #endif | 316 | #endif |
| 316 | 317 | ||
| 317 | // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require | 318 | // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require |
| 318 | // any bookkeeping, so it's always trivially relocatable. | 319 | // any bookkeeping, so it's always trivially relocatable. It is also replaceable because assignment just rebinds the |
| 320 | // shared_ptr to manage a different object. | ||
| 319 | using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr; | 321 | using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr; |
| 322 | using __replaceable _LIBCPP_NODEBUG = shared_ptr; | ||
| 320 | 323 | ||
| 321 | private: | 324 | private: |
| 322 | element_type* __ptr_; | 325 | element_type* __ptr_; |
| ... | @@ -496,7 +499,7 @@ public: | ... | @@ -496,7 +499,7 @@ public: |
| 496 | _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r) | 499 | _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r) |
| 497 | : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) { | 500 | : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) { |
| 498 | if (__cntrl_ == nullptr) | 501 | if (__cntrl_ == nullptr) |
| 499 | __throw_bad_weak_ptr(); | 502 | std::__throw_bad_weak_ptr(); |
| 500 | } | 503 | } |
| 501 | 504 | ||
| 502 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | 505 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) |
| ... | @@ -710,9 +713,9 @@ private: | ... | @@ -710,9 +713,9 @@ private: |
| 710 | struct __shared_ptr_default_delete<_Yp[], _Un> : default_delete<_Yp[]> {}; | 713 | struct __shared_ptr_default_delete<_Yp[], _Un> : default_delete<_Yp[]> {}; |
| 711 | 714 | ||
| 712 | template <class _Up> | 715 | template <class _Up> |
| 713 | friend class _LIBCPP_TEMPLATE_VIS shared_ptr; | 716 | friend class shared_ptr; |
| 714 | template <class _Up> | 717 | template <class _Up> |
| 715 | friend class _LIBCPP_TEMPLATE_VIS weak_ptr; | 718 | friend class weak_ptr; |
| 716 | }; | 719 | }; |
| 717 | 720 | ||
| 718 | #if _LIBCPP_STD_VER >= 17 | 721 | #if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1201,7 +1204,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXC | ... | @@ -1201,7 +1204,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXC |
| 1201 | #endif // _LIBCPP_HAS_RTTI | 1204 | #endif // _LIBCPP_HAS_RTTI |
| 1202 | 1205 | ||
| 1203 | template <class _Tp> | 1206 | template <class _Tp> |
| 1204 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr { | 1207 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI weak_ptr { |
| 1205 | public: | 1208 | public: |
| 1206 | #if _LIBCPP_STD_VER >= 17 | 1209 | #if _LIBCPP_STD_VER >= 17 |
| 1207 | typedef remove_extent_t<_Tp> element_type; | 1210 | typedef remove_extent_t<_Tp> element_type; |
| ... | @@ -1210,8 +1213,9 @@ public: | ... | @@ -1210,8 +1213,9 @@ public: |
| 1210 | #endif | 1213 | #endif |
| 1211 | 1214 | ||
| 1212 | // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require | 1215 | // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require |
| 1213 | // any bookkeeping, so it's always trivially relocatable. | 1216 | // any bookkeeping, so it's always trivially relocatable. It's also replaceable for the same reason. |
| 1214 | using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr; | 1217 | using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr; |
| 1218 | using __replaceable _LIBCPP_NODEBUG = weak_ptr; | ||
| 1215 | 1219 | ||
| 1216 | private: | 1220 | private: |
| 1217 | element_type* __ptr_; | 1221 | element_type* __ptr_; |
| ... | @@ -1262,9 +1266,9 @@ public: | ... | @@ -1262,9 +1266,9 @@ public: |
| 1262 | } | 1266 | } |
| 1263 | 1267 | ||
| 1264 | template <class _Up> | 1268 | template <class _Up> |
| 1265 | friend class _LIBCPP_TEMPLATE_VIS weak_ptr; | 1269 | friend class weak_ptr; |
| 1266 | template <class _Up> | 1270 | template <class _Up> |
| 1267 | friend class _LIBCPP_TEMPLATE_VIS shared_ptr; | 1271 | friend class shared_ptr; |
| 1268 | }; | 1272 | }; |
| 1269 | 1273 | ||
| 1270 | #if _LIBCPP_STD_VER >= 17 | 1274 | #if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1382,7 +1386,7 @@ struct owner_less; | ... | @@ -1382,7 +1386,7 @@ struct owner_less; |
| 1382 | #endif | 1386 | #endif |
| 1383 | 1387 | ||
| 1384 | template <class _Tp> | 1388 | template <class _Tp> |
| 1385 | struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> { | 1389 | struct owner_less<shared_ptr<_Tp> > : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> { |
| 1386 | _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT { | 1390 | _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT { |
| 1387 | return __x.owner_before(__y); | 1391 | return __x.owner_before(__y); |
| 1388 | } | 1392 | } |
| ... | @@ -1395,7 +1399,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > : __binary_function<sha | ... | @@ -1395,7 +1399,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > : __binary_function<sha |
| 1395 | }; | 1399 | }; |
| 1396 | 1400 | ||
| 1397 | template <class _Tp> | 1401 | template <class _Tp> |
| 1398 | struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> { | 1402 | struct owner_less<weak_ptr<_Tp> > : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> { |
| 1399 | _LIBCPP_HIDE_FROM_ABI bool operator()(weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT { | 1403 | _LIBCPP_HIDE_FROM_ABI bool operator()(weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT { |
| 1400 | return __x.owner_before(__y); | 1404 | return __x.owner_before(__y); |
| 1401 | } | 1405 | } |
| ... | @@ -1409,7 +1413,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > : __binary_function<weak_ | ... | @@ -1409,7 +1413,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > : __binary_function<weak_ |
| 1409 | 1413 | ||
| 1410 | #if _LIBCPP_STD_VER >= 17 | 1414 | #if _LIBCPP_STD_VER >= 17 |
| 1411 | template <> | 1415 | template <> |
| 1412 | struct _LIBCPP_TEMPLATE_VIS owner_less<void> { | 1416 | struct owner_less<void> { |
| 1413 | template <class _Tp, class _Up> | 1417 | template <class _Tp, class _Up> |
| 1414 | _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT { | 1418 | _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT { |
| 1415 | return __x.owner_before(__y); | 1419 | return __x.owner_before(__y); |
| ... | @@ -1431,7 +1435,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<void> { | ... | @@ -1431,7 +1435,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<void> { |
| 1431 | #endif | 1435 | #endif |
| 1432 | 1436 | ||
| 1433 | template <class _Tp> | 1437 | template <class _Tp> |
| 1434 | class _LIBCPP_TEMPLATE_VIS enable_shared_from_this { | 1438 | class enable_shared_from_this { |
| 1435 | mutable weak_ptr<_Tp> __weak_this_; | 1439 | mutable weak_ptr<_Tp> __weak_this_; |
| 1436 | 1440 | ||
| 1437 | protected: | 1441 | protected: |
| ... | @@ -1455,10 +1459,10 @@ public: | ... | @@ -1455,10 +1459,10 @@ public: |
| 1455 | }; | 1459 | }; |
| 1456 | 1460 | ||
| 1457 | template <class _Tp> | 1461 | template <class _Tp> |
| 1458 | struct _LIBCPP_TEMPLATE_VIS hash; | 1462 | struct hash; |
| 1459 | 1463 | ||
| 1460 | template <class _Tp> | 1464 | template <class _Tp> |
| 1461 | struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> > { | 1465 | struct hash<shared_ptr<_Tp> > { |
| 1462 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | 1466 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1463 | _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> argument_type; | 1467 | _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> argument_type; |
| 1464 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | 1468 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; |
lib/libcxx/include/__memory/uninitialized_algorithms.h+13-20| ... | @@ -16,11 +16,13 @@ | ... | @@ -16,11 +16,13 @@ |
| 16 | #include <__algorithm/unwrap_range.h> | 16 | #include <__algorithm/unwrap_range.h> |
| 17 | #include <__config> | 17 | #include <__config> |
| 18 | #include <__cstddef/size_t.h> | 18 | #include <__cstddef/size_t.h> |
| 19 | #include <__fwd/memory.h> | ||
| 19 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 20 | #include <__iterator/reverse_iterator.h> | 21 | #include <__iterator/reverse_iterator.h> |
| 21 | #include <__memory/addressof.h> | 22 | #include <__memory/addressof.h> |
| 22 | #include <__memory/allocator_traits.h> | 23 | #include <__memory/allocator_traits.h> |
| 23 | #include <__memory/construct_at.h> | 24 | #include <__memory/construct_at.h> |
| 25 | #include <__memory/destroy.h> | ||
| 24 | #include <__memory/pointer_traits.h> | 26 | #include <__memory/pointer_traits.h> |
| 25 | #include <__type_traits/enable_if.h> | 27 | #include <__type_traits/enable_if.h> |
| 26 | #include <__type_traits/extent.h> | 28 | #include <__type_traits/extent.h> |
| ... | @@ -31,7 +33,6 @@ | ... | @@ -31,7 +33,6 @@ |
| 31 | #include <__type_traits/is_trivially_constructible.h> | 33 | #include <__type_traits/is_trivially_constructible.h> |
| 32 | #include <__type_traits/is_trivially_relocatable.h> | 34 | #include <__type_traits/is_trivially_relocatable.h> |
| 33 | #include <__type_traits/is_unbounded_array.h> | 35 | #include <__type_traits/is_unbounded_array.h> |
| 34 | #include <__type_traits/negation.h> | ||
| 35 | #include <__type_traits/remove_const.h> | 36 | #include <__type_traits/remove_const.h> |
| 36 | #include <__type_traits/remove_extent.h> | 37 | #include <__type_traits/remove_extent.h> |
| 37 | #include <__utility/exception_guard.h> | 38 | #include <__utility/exception_guard.h> |
| ... | @@ -511,14 +512,6 @@ __uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _B | ... | @@ -511,14 +512,6 @@ __uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _B |
| 511 | 512 | ||
| 512 | #endif // _LIBCPP_STD_VER >= 17 | 513 | #endif // _LIBCPP_STD_VER >= 17 |
| 513 | 514 | ||
| 514 | // Destroy all elements in [__first, __last) from left to right using allocator destruction. | ||
| 515 | template <class _Alloc, class _Iter, class _Sent> | ||
| 516 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | ||
| 517 | __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) { | ||
| 518 | for (; __first != __last; ++__first) | ||
| 519 | allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first)); | ||
| 520 | } | ||
| 521 | |||
| 522 | template <class _Alloc, class _Iter> | 515 | template <class _Alloc, class _Iter> |
| 523 | class _AllocatorDestroyRangeReverse { | 516 | class _AllocatorDestroyRangeReverse { |
| 524 | public: | 517 | public: |
| ... | @@ -556,17 +549,17 @@ __uninitialized_allocator_copy_impl(_Alloc& __alloc, _Iter1 __first1, _Sent1 __l | ... | @@ -556,17 +549,17 @@ __uninitialized_allocator_copy_impl(_Alloc& __alloc, _Iter1 __first1, _Sent1 __l |
| 556 | } | 549 | } |
| 557 | 550 | ||
| 558 | template <class _Alloc, class _Type> | 551 | template <class _Alloc, class _Type> |
| 559 | struct __allocator_has_trivial_copy_construct : _Not<__has_construct<_Alloc, _Type*, const _Type&> > {}; | 552 | inline const bool __allocator_has_trivial_copy_construct_v = !__has_construct_v<_Alloc, _Type*, const _Type&>; |
| 560 | 553 | ||
| 561 | template <class _Type> | 554 | template <class _Type> |
| 562 | struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_type {}; | 555 | inline const bool __allocator_has_trivial_copy_construct_v<allocator<_Type>, _Type> = true; |
| 563 | 556 | ||
| 564 | template <class _Alloc, | 557 | template <class _Alloc, |
| 565 | class _In, | 558 | class _In, |
| 566 | class _Out, | 559 | class _Out, |
| 567 | __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value && | 560 | __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value && |
| 568 | is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && | 561 | is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && |
| 569 | __allocator_has_trivial_copy_construct<_Alloc, _In>::value, | 562 | __allocator_has_trivial_copy_construct_v<_Alloc, _In>, |
| 570 | int> = 0> | 563 | int> = 0> |
| 571 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out* | 564 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out* |
| 572 | __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) { | 565 | __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) { |
| ... | @@ -592,16 +585,16 @@ __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, | ... | @@ -592,16 +585,16 @@ __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, |
| 592 | } | 585 | } |
| 593 | 586 | ||
| 594 | template <class _Alloc, class _Type> | 587 | template <class _Alloc, class _Type> |
| 595 | struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {}; | 588 | inline const bool __allocator_has_trivial_move_construct_v = !__has_construct_v<_Alloc, _Type*, _Type&&>; |
| 596 | 589 | ||
| 597 | template <class _Type> | 590 | template <class _Type> |
| 598 | struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {}; | 591 | inline const bool __allocator_has_trivial_move_construct_v<allocator<_Type>, _Type> = true; |
| 599 | 592 | ||
| 600 | template <class _Alloc, class _Tp> | 593 | template <class _Alloc, class _Tp> |
| 601 | struct __allocator_has_trivial_destroy : _Not<__has_destroy<_Alloc, _Tp*> > {}; | 594 | inline const bool __allocator_has_trivial_destroy_v = !__has_destroy_v<_Alloc, _Tp*>; |
| 602 | 595 | ||
| 603 | template <class _Tp, class _Up> | 596 | template <class _Tp, class _Up> |
| 604 | struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {}; | 597 | inline const bool __allocator_has_trivial_destroy_v<allocator<_Tp>, _Up> = true; |
| 605 | 598 | ||
| 606 | // __uninitialized_allocator_relocate relocates the objects in [__first, __last) into __result. | 599 | // __uninitialized_allocator_relocate relocates the objects in [__first, __last) into __result. |
| 607 | // Relocation means that the objects in [__first, __last) are placed into __result as-if by move-construct and destroy, | 600 | // Relocation means that the objects in [__first, __last) are placed into __result as-if by move-construct and destroy, |
| ... | @@ -620,11 +613,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocat | ... | @@ -620,11 +613,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocat |
| 620 | _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) { | 613 | _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) { |
| 621 | static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, ""); | 614 | static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, ""); |
| 622 | using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type; | 615 | using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type; |
| 623 | static_assert(__is_cpp17_move_insertable<_Alloc>::value, | 616 | static_assert( |
| 624 | "The specified type does not meet the requirements of Cpp17MoveInsertable"); | 617 | __is_cpp17_move_insertable_v<_Alloc>, "The specified type does not meet the requirements of Cpp17MoveInsertable"); |
| 625 | if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_ValueType>::value || | 618 | if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_ValueType>::value || |
| 626 | !__allocator_has_trivial_move_construct<_Alloc, _ValueType>::value || | 619 | !__allocator_has_trivial_move_construct_v<_Alloc, _ValueType> || |
| 627 | !__allocator_has_trivial_destroy<_Alloc, _ValueType>::value) { | 620 | !__allocator_has_trivial_destroy_v<_Alloc, _ValueType>) { |
| 628 | auto __destruct_first = __result; | 621 | auto __destruct_first = __result; |
| 629 | auto __guard = std::__make_exception_guard( | 622 | auto __guard = std::__make_exception_guard( |
| 630 | _AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>(__alloc, __destruct_first, __result)); | 623 | _AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>(__alloc, __destruct_first, __result)); |
lib/libcxx/include/__memory/unique_ptr.h+28-36| ... | @@ -24,7 +24,7 @@ | ... | @@ -24,7 +24,7 @@ |
| 24 | #include <__memory/auto_ptr.h> | 24 | #include <__memory/auto_ptr.h> |
| 25 | #include <__memory/compressed_pair.h> | 25 | #include <__memory/compressed_pair.h> |
| 26 | #include <__memory/pointer_traits.h> | 26 | #include <__memory/pointer_traits.h> |
| 27 | #include <__type_traits/add_lvalue_reference.h> | 27 | #include <__type_traits/add_reference.h> |
| 28 | #include <__type_traits/common_type.h> | 28 | #include <__type_traits/common_type.h> |
| 29 | #include <__type_traits/conditional.h> | 29 | #include <__type_traits/conditional.h> |
| 30 | #include <__type_traits/dependent_type.h> | 30 | #include <__type_traits/dependent_type.h> |
| ... | @@ -39,6 +39,7 @@ | ... | @@ -39,6 +39,7 @@ |
| 39 | #include <__type_traits/is_function.h> | 39 | #include <__type_traits/is_function.h> |
| 40 | #include <__type_traits/is_pointer.h> | 40 | #include <__type_traits/is_pointer.h> |
| 41 | #include <__type_traits/is_reference.h> | 41 | #include <__type_traits/is_reference.h> |
| 42 | #include <__type_traits/is_replaceable.h> | ||
| 42 | #include <__type_traits/is_same.h> | 43 | #include <__type_traits/is_same.h> |
| 43 | #include <__type_traits/is_swappable.h> | 44 | #include <__type_traits/is_swappable.h> |
| 44 | #include <__type_traits/is_trivially_relocatable.h> | 45 | #include <__type_traits/is_trivially_relocatable.h> |
| ... | @@ -62,13 +63,11 @@ _LIBCPP_PUSH_MACROS | ... | @@ -62,13 +63,11 @@ _LIBCPP_PUSH_MACROS |
| 62 | _LIBCPP_BEGIN_NAMESPACE_STD | 63 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 63 | 64 | ||
| 64 | template <class _Tp> | 65 | template <class _Tp> |
| 65 | struct _LIBCPP_TEMPLATE_VIS default_delete { | 66 | struct default_delete { |
| 66 | static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types"); | 67 | static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types"); |
| 67 | #ifndef _LIBCPP_CXX03_LANG | 68 | |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default; | 69 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; |
| 69 | #else | 70 | |
| 70 | _LIBCPP_HIDE_FROM_ABI default_delete() {} | ||
| 71 | #endif | ||
| 72 | template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0> | 71 | template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0> |
| 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up>&) _NOEXCEPT {} | 72 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up>&) _NOEXCEPT {} |
| 74 | 73 | ||
| ... | @@ -80,35 +79,24 @@ struct _LIBCPP_TEMPLATE_VIS default_delete { | ... | @@ -80,35 +79,24 @@ struct _LIBCPP_TEMPLATE_VIS default_delete { |
| 80 | }; | 79 | }; |
| 81 | 80 | ||
| 82 | template <class _Tp> | 81 | template <class _Tp> |
| 83 | struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> { | 82 | struct default_delete<_Tp[]> { |
| 84 | private: | 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; |
| 85 | template <class _Up> | ||
| 86 | struct _EnableIfConvertible : enable_if<is_convertible<_Up (*)[], _Tp (*)[]>::value> {}; | ||
| 87 | 84 | ||
| 88 | public: | 85 | template <class _Up, __enable_if_t<is_convertible<_Up (*)[], _Tp (*)[]>::value, int> = 0> |
| 89 | #ifndef _LIBCPP_CXX03_LANG | 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up[]>&) _NOEXCEPT {} |
| 90 | _LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default; | ||
| 91 | #else | ||
| 92 | _LIBCPP_HIDE_FROM_ABI default_delete() {} | ||
| 93 | #endif | ||
| 94 | |||
| 95 | template <class _Up> | ||
| 96 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 | ||
| 97 | default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {} | ||
| 98 | 87 | ||
| 99 | template <class _Up> | 88 | template <class _Up, __enable_if_t<is_convertible<_Up (*)[], _Tp (*)[]>::value, int> = 0> |
| 100 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type | 89 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Up* __ptr) const _NOEXCEPT { |
| 101 | operator()(_Up* __ptr) const _NOEXCEPT { | ||
| 102 | static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type"); | 90 | static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type"); |
| 103 | delete[] __ptr; | 91 | delete[] __ptr; |
| 104 | } | 92 | } |
| 105 | }; | 93 | }; |
| 106 | 94 | ||
| 107 | template <class _Deleter> | 95 | template <class _Deleter> |
| 108 | struct __is_default_deleter : false_type {}; | 96 | inline const bool __is_default_deleter_v = false; |
| 109 | 97 | ||
| 110 | template <class _Tp> | 98 | template <class _Tp> |
| 111 | struct __is_default_deleter<default_delete<_Tp> > : true_type {}; | 99 | inline const bool __is_default_deleter_v<default_delete<_Tp> > = true; |
| 112 | 100 | ||
| 113 | template <class _Deleter> | 101 | template <class _Deleter> |
| 114 | struct __unique_ptr_deleter_sfinae { | 102 | struct __unique_ptr_deleter_sfinae { |
| ... | @@ -139,7 +127,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> { | ... | @@ -139,7 +127,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> { |
| 139 | #endif | 127 | #endif |
| 140 | 128 | ||
| 141 | template <class _Tp, class _Dp = default_delete<_Tp> > | 129 | template <class _Tp, class _Dp = default_delete<_Tp> > |
| 142 | class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr { | 130 | class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr { |
| 143 | public: | 131 | public: |
| 144 | typedef _Tp element_type; | 132 | typedef _Tp element_type; |
| 145 | typedef _Dp deleter_type; | 133 | typedef _Dp deleter_type; |
| ... | @@ -157,6 +145,8 @@ public: | ... | @@ -157,6 +145,8 @@ public: |
| 157 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, | 145 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, |
| 158 | unique_ptr, | 146 | unique_ptr, |
| 159 | void>; | 147 | void>; |
| 148 | using __replaceable _LIBCPP_NODEBUG = | ||
| 149 | __conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>; | ||
| 160 | 150 | ||
| 161 | private: | 151 | private: |
| 162 | _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); | 152 | _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); |
| ... | @@ -313,7 +303,7 @@ public: | ... | @@ -313,7 +303,7 @@ public: |
| 313 | // We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>. | 303 | // We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>. |
| 314 | // There are a few cases where bounds checking can be implemented: | 304 | // There are a few cases where bounds checking can be implemented: |
| 315 | // | 305 | // |
| 316 | // 1. When an array cookie (see [1]) exists at the beginning of the array allocation, we are | 306 | // 1. When an array cookie exists at the beginning of the array allocation, we are |
| 317 | // able to reuse that cookie to extract the size of the array and perform bounds checking. | 307 | // able to reuse that cookie to extract the size of the array and perform bounds checking. |
| 318 | // An array cookie is a size inserted at the beginning of the allocation by the compiler. | 308 | // An array cookie is a size inserted at the beginning of the allocation by the compiler. |
| 319 | // That size is inserted implicitly when doing `new T[n]` in some cases (as of writing this | 309 | // That size is inserted implicitly when doing `new T[n]` in some cases (as of writing this |
| ... | @@ -355,7 +345,7 @@ struct __unique_ptr_array_bounds_stateless { | ... | @@ -355,7 +345,7 @@ struct __unique_ptr_array_bounds_stateless { |
| 355 | 345 | ||
| 356 | template <class _Deleter, | 346 | template <class _Deleter, |
| 357 | class _Tp, | 347 | class _Tp, |
| 358 | __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0> | 348 | __enable_if_t<__is_default_deleter_v<_Deleter> && __has_array_cookie<_Tp>::value, int> = 0> |
| 359 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { | 349 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { |
| 360 | // In constant expressions, we can't check the array cookie so we just pretend that the index | 350 | // In constant expressions, we can't check the array cookie so we just pretend that the index |
| 361 | // is in-bounds. The compiler catches invalid accesses anyway. | 351 | // is in-bounds. The compiler catches invalid accesses anyway. |
| ... | @@ -367,7 +357,7 @@ struct __unique_ptr_array_bounds_stateless { | ... | @@ -367,7 +357,7 @@ struct __unique_ptr_array_bounds_stateless { |
| 367 | 357 | ||
| 368 | template <class _Deleter, | 358 | template <class _Deleter, |
| 369 | class _Tp, | 359 | class _Tp, |
| 370 | __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0> | 360 | __enable_if_t<!__is_default_deleter_v<_Deleter> || !__has_array_cookie<_Tp>::value, int> = 0> |
| 371 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const { | 361 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const { |
| 372 | return true; // If we don't have an array cookie, we assume the access is in-bounds | 362 | return true; // If we don't have an array cookie, we assume the access is in-bounds |
| 373 | } | 363 | } |
| ... | @@ -385,7 +375,7 @@ struct __unique_ptr_array_bounds_stored { | ... | @@ -385,7 +375,7 @@ struct __unique_ptr_array_bounds_stored { |
| 385 | // Use the array cookie if there's one | 375 | // Use the array cookie if there's one |
| 386 | template <class _Deleter, | 376 | template <class _Deleter, |
| 387 | class _Tp, | 377 | class _Tp, |
| 388 | __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0> | 378 | __enable_if_t<__is_default_deleter_v<_Deleter> && __has_array_cookie<_Tp>::value, int> = 0> |
| 389 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { | 379 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { |
| 390 | if (__libcpp_is_constant_evaluated()) | 380 | if (__libcpp_is_constant_evaluated()) |
| 391 | return true; | 381 | return true; |
| ... | @@ -396,7 +386,7 @@ struct __unique_ptr_array_bounds_stored { | ... | @@ -396,7 +386,7 @@ struct __unique_ptr_array_bounds_stored { |
| 396 | // Otherwise, fall back on the stored size (if any) | 386 | // Otherwise, fall back on the stored size (if any) |
| 397 | template <class _Deleter, | 387 | template <class _Deleter, |
| 398 | class _Tp, | 388 | class _Tp, |
| 399 | __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0> | 389 | __enable_if_t<!__is_default_deleter_v<_Deleter> || !__has_array_cookie<_Tp>::value, int> = 0> |
| 400 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const { | 390 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const { |
| 401 | return __index < __size_; | 391 | return __index < __size_; |
| 402 | } | 392 | } |
| ... | @@ -406,7 +396,7 @@ private: | ... | @@ -406,7 +396,7 @@ private: |
| 406 | }; | 396 | }; |
| 407 | 397 | ||
| 408 | template <class _Tp, class _Dp> | 398 | template <class _Tp, class _Dp> |
| 409 | class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> { | 399 | class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> { |
| 410 | public: | 400 | public: |
| 411 | typedef _Tp element_type; | 401 | typedef _Tp element_type; |
| 412 | typedef _Dp deleter_type; | 402 | typedef _Dp deleter_type; |
| ... | @@ -423,6 +413,8 @@ public: | ... | @@ -423,6 +413,8 @@ public: |
| 423 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, | 413 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, |
| 424 | unique_ptr, | 414 | unique_ptr, |
| 425 | void>; | 415 | void>; |
| 416 | using __replaceable _LIBCPP_NODEBUG = | ||
| 417 | __conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>; | ||
| 426 | 418 | ||
| 427 | private: | 419 | private: |
| 428 | template <class _Up, class _OtherDeleter> | 420 | template <class _Up, class _OtherDeleter> |
| ... | @@ -796,13 +788,13 @@ void make_unique_for_overwrite(_Args&&...) = delete; | ... | @@ -796,13 +788,13 @@ void make_unique_for_overwrite(_Args&&...) = delete; |
| 796 | #endif // _LIBCPP_STD_VER >= 20 | 788 | #endif // _LIBCPP_STD_VER >= 20 |
| 797 | 789 | ||
| 798 | template <class _Tp> | 790 | template <class _Tp> |
| 799 | struct _LIBCPP_TEMPLATE_VIS hash; | 791 | struct hash; |
| 800 | 792 | ||
| 801 | template <class _Tp, class _Dp> | 793 | template <class _Tp, class _Dp> |
| 802 | #ifdef _LIBCPP_CXX03_LANG | 794 | #ifdef _LIBCPP_CXX03_LANG |
| 803 | struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> > | 795 | struct hash<unique_ptr<_Tp, _Dp> > |
| 804 | #else | 796 | #else |
| 805 | struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> > | 797 | struct hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> > |
| 806 | #endif | 798 | #endif |
| 807 | { | 799 | { |
| 808 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | 800 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
lib/libcxx/include/__memory/uses_allocator.h+1-1| ... | @@ -40,7 +40,7 @@ template <class _Tp, class _Alloc> | ... | @@ -40,7 +40,7 @@ template <class _Tp, class _Alloc> |
| 40 | struct __uses_allocator<_Tp, _Alloc, false> : public false_type {}; | 40 | struct __uses_allocator<_Tp, _Alloc, false> : public false_type {}; |
| 41 | 41 | ||
| 42 | template <class _Tp, class _Alloc> | 42 | template <class _Tp, class _Alloc> |
| 43 | struct _LIBCPP_TEMPLATE_VIS uses_allocator : public __uses_allocator<_Tp, _Alloc> {}; | 43 | struct uses_allocator : public __uses_allocator<_Tp, _Alloc> {}; |
| 44 | 44 | ||
| 45 | #if _LIBCPP_STD_VER >= 17 | 45 | #if _LIBCPP_STD_VER >= 17 |
| 46 | template <class _Tp, class _Alloc> | 46 | template <class _Tp, class _Alloc> |
lib/libcxx/include/__memory/uses_allocator_construction.h+1-8| ... | @@ -14,7 +14,6 @@ | ... | @@ -14,7 +14,6 @@ |
| 14 | #include <__memory/uses_allocator.h> | 14 | #include <__memory/uses_allocator.h> |
| 15 | #include <__tuple/tuple_like_no_subrange.h> | 15 | #include <__tuple/tuple_like_no_subrange.h> |
| 16 | #include <__type_traits/enable_if.h> | 16 | #include <__type_traits/enable_if.h> |
| 17 | #include <__type_traits/is_same.h> | ||
| 18 | #include <__type_traits/remove_cv.h> | 17 | #include <__type_traits/remove_cv.h> |
| 19 | #include <__utility/declval.h> | 18 | #include <__utility/declval.h> |
| 20 | #include <__utility/pair.h> | 19 | #include <__utility/pair.h> |
| ... | @@ -31,14 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -31,14 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 30 | ||
| 32 | #if _LIBCPP_STD_VER >= 17 | 31 | #if _LIBCPP_STD_VER >= 17 |
| 33 | 32 | ||
| 34 | template <class _Type> | ||
| 35 | inline constexpr bool __is_std_pair = false; | ||
| 36 | |||
| 37 | template <class _Type1, class _Type2> | ||
| 38 | inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true; | ||
| 39 | |||
| 40 | template <class _Tp> | 33 | template <class _Tp> |
| 41 | inline constexpr bool __is_cv_std_pair = __is_std_pair<remove_cv_t<_Tp>>; | 34 | inline constexpr bool __is_cv_std_pair = __is_pair_v<remove_cv_t<_Tp>>; |
| 42 | 35 | ||
| 43 | template <class _Tp, class = void> | 36 | template <class _Tp, class = void> |
| 44 | struct __uses_allocator_construction_args; | 37 | struct __uses_allocator_construction_args; |
lib/libcxx/include/__memory_resource/polymorphic_allocator.h+2-2| ... | @@ -41,7 +41,7 @@ template <class _ValueType | ... | @@ -41,7 +41,7 @@ template <class _ValueType |
| 41 | = byte | 41 | = byte |
| 42 | # endif | 42 | # endif |
| 43 | > | 43 | > |
| 44 | class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator { | 44 | class _LIBCPP_AVAILABILITY_PMR polymorphic_allocator { |
| 45 | 45 | ||
| 46 | public: | 46 | public: |
| 47 | using value_type = _ValueType; | 47 | using value_type = _ValueType; |
| ... | @@ -64,7 +64,7 @@ public: | ... | @@ -64,7 +64,7 @@ public: |
| 64 | 64 | ||
| 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) { | 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) { |
| 66 | if (__n > __max_size()) { | 66 | if (__n > __max_size()) { |
| 67 | __throw_bad_array_new_length(); | 67 | std::__throw_bad_array_new_length(); |
| 68 | } | 68 | } |
| 69 | return static_cast<_ValueType*>(__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType))); | 69 | return static_cast<_ValueType*>(__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType))); |
| 70 | } | 70 | } |
lib/libcxx/include/__mutex/lock_guard.h+4-6| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Mutex> | 21 | template <class _Mutex> |
| 22 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) lock_guard { | 22 | class _LIBCPP_SCOPED_LOCKABLE lock_guard { |
| 23 | public: | 23 | public: |
| 24 | typedef _Mutex mutex_type; | 24 | typedef _Mutex mutex_type; |
| 25 | 25 | ||
| ... | @@ -27,16 +27,14 @@ private: | ... | @@ -27,16 +27,14 @@ private: |
| 27 | mutex_type& __m_; | 27 | mutex_type& __m_; |
| 28 | 28 | ||
| 29 | public: | 29 | public: |
| 30 | [[__nodiscard__]] | 30 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_ACQUIRE_CAPABILITY(__m) |
| 31 | _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) | ||
| 32 | : __m_(__m) { | 31 | : __m_(__m) { |
| 33 | __m_.lock(); | 32 | __m_.lock(); |
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) | 35 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_REQUIRES_CAPABILITY(__m) |
| 37 | _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) | ||
| 38 | : __m_(__m) {} | 36 | : __m_(__m) {} |
| 39 | _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } | 37 | _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI ~lock_guard() { __m_.unlock(); } |
| 40 | 38 | ||
| 41 | lock_guard(lock_guard const&) = delete; | 39 | lock_guard(lock_guard const&) = delete; |
| 42 | lock_guard& operator=(lock_guard const&) = delete; | 40 | lock_guard& operator=(lock_guard const&) = delete; |
lib/libcxx/include/__mutex/mutex.h+4-4| ... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex { | 24 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_CAPABILITY("mutex") mutex { |
| 25 | __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER; | 25 | __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER; |
| 26 | 26 | ||
| 27 | public: | 27 | public: |
| ... | @@ -36,9 +36,9 @@ public: | ... | @@ -36,9 +36,9 @@ public: |
| 36 | ~mutex() _NOEXCEPT; | 36 | ~mutex() _NOEXCEPT; |
| 37 | # endif | 37 | # endif |
| 38 | 38 | ||
| 39 | void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability()); | 39 | _LIBCPP_ACQUIRE_CAPABILITY() void lock(); |
| 40 | bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true)); | 40 | _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock() _NOEXCEPT; |
| 41 | void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()); | 41 | _LIBCPP_RELEASE_CAPABILITY void unlock() _NOEXCEPT; |
| 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 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; } |
lib/libcxx/include/__mutex/once_flag.h+6-5| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__functional/invoke.h> | 13 | #include <__functional/invoke.h> |
| 14 | #include <__memory/addressof.h> | ||
| 14 | #include <__memory/shared_count.h> // __libcpp_acquire_load | 15 | #include <__memory/shared_count.h> // __libcpp_acquire_load |
| 15 | #include <__tuple/tuple_indices.h> | 16 | #include <__tuple/tuple_indices.h> |
| 16 | #include <__tuple/tuple_size.h> | 17 | #include <__tuple/tuple_size.h> |
| ... | @@ -30,7 +31,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -30,7 +31,7 @@ _LIBCPP_PUSH_MACROS |
| 30 | 31 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 33 | ||
| 33 | struct _LIBCPP_TEMPLATE_VIS once_flag; | 34 | struct once_flag; |
| 34 | 35 | ||
| 35 | #ifndef _LIBCPP_CXX03_LANG | 36 | #ifndef _LIBCPP_CXX03_LANG |
| 36 | 37 | ||
| ... | @@ -47,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, const _Callable&); | ... | @@ -47,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, const _Callable&); |
| 47 | 48 | ||
| 48 | #endif // _LIBCPP_CXX03_LANG | 49 | #endif // _LIBCPP_CXX03_LANG |
| 49 | 50 | ||
| 50 | struct _LIBCPP_TEMPLATE_VIS once_flag { | 51 | struct once_flag { |
| 51 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(_Unset) {} | 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(_Unset) {} |
| 52 | once_flag(const once_flag&) = delete; | 53 | once_flag(const once_flag&) = delete; |
| 53 | once_flag& operator=(const once_flag&) = delete; | 54 | once_flag& operator=(const once_flag&) = delete; |
| ... | @@ -128,7 +129,7 @@ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __fun | ... | @@ -128,7 +129,7 @@ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __fun |
| 128 | typedef tuple<_Callable&&, _Args&&...> _Gp; | 129 | typedef tuple<_Callable&&, _Args&&...> _Gp; |
| 129 | _Gp __f(std::forward<_Callable>(__func), std::forward<_Args>(__args)...); | 130 | _Gp __f(std::forward<_Callable>(__func), std::forward<_Args>(__args)...); |
| 130 | __call_once_param<_Gp> __p(__f); | 131 | __call_once_param<_Gp> __p(__f); |
| 131 | std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>); | 132 | std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<_Gp>)); |
| 132 | } | 133 | } |
| 133 | } | 134 | } |
| 134 | 135 | ||
| ... | @@ -138,7 +139,7 @@ template <class _Callable> | ... | @@ -138,7 +139,7 @@ template <class _Callable> |
| 138 | inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) { | 139 | inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) { |
| 139 | if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { | 140 | if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { |
| 140 | __call_once_param<_Callable> __p(__func); | 141 | __call_once_param<_Callable> __p(__func); |
| 141 | std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); | 142 | std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<_Callable>)); |
| 142 | } | 143 | } |
| 143 | } | 144 | } |
| 144 | 145 | ||
| ... | @@ -146,7 +147,7 @@ template <class _Callable> | ... | @@ -146,7 +147,7 @@ template <class _Callable> |
| 146 | inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable& __func) { | 147 | inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable& __func) { |
| 147 | if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { | 148 | if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { |
| 148 | __call_once_param<const _Callable> __p(__func); | 149 | __call_once_param<const _Callable> __p(__func); |
| 149 | std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>); | 150 | std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<const _Callable>)); |
| 150 | } | 151 | } |
| 151 | } | 152 | } |
| 152 | 153 |
lib/libcxx/include/__mutex/unique_lock.h+10-10| ... | @@ -25,7 +25,7 @@ | ... | @@ -25,7 +25,7 @@ |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _Mutex> | 27 | template <class _Mutex> |
| 28 | class _LIBCPP_TEMPLATE_VIS unique_lock { | 28 | class unique_lock { |
| 29 | public: | 29 | public: |
| 30 | typedef _Mutex mutex_type; | 30 | typedef _Mutex mutex_type; |
| 31 | 31 | ||
| ... | @@ -116,9 +116,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock); | ... | @@ -116,9 +116,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock); |
| 116 | template <class _Mutex> | 116 | template <class _Mutex> |
| 117 | _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() { | 117 | _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() { |
| 118 | if (__m_ == nullptr) | 118 | if (__m_ == nullptr) |
| 119 | __throw_system_error(EPERM, "unique_lock::lock: references null mutex"); | 119 | std::__throw_system_error(EPERM, "unique_lock::lock: references null mutex"); |
| 120 | if (__owns_) | 120 | if (__owns_) |
| 121 | __throw_system_error(EDEADLK, "unique_lock::lock: already locked"); | 121 | std::__throw_system_error(EDEADLK, "unique_lock::lock: already locked"); |
| 122 | __m_->lock(); | 122 | __m_->lock(); |
| 123 | __owns_ = true; | 123 | __owns_ = true; |
| 124 | } | 124 | } |
| ... | @@ -126,9 +126,9 @@ _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() { | ... | @@ -126,9 +126,9 @@ _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() { |
| 126 | template <class _Mutex> | 126 | template <class _Mutex> |
| 127 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() { | 127 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() { |
| 128 | if (__m_ == nullptr) | 128 | if (__m_ == nullptr) |
| 129 | __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex"); | 129 | std::__throw_system_error(EPERM, "unique_lock::try_lock: references null mutex"); |
| 130 | if (__owns_) | 130 | if (__owns_) |
| 131 | __throw_system_error(EDEADLK, "unique_lock::try_lock: already locked"); | 131 | std::__throw_system_error(EDEADLK, "unique_lock::try_lock: already locked"); |
| 132 | __owns_ = __m_->try_lock(); | 132 | __owns_ = __m_->try_lock(); |
| 133 | return __owns_; | 133 | return __owns_; |
| 134 | } | 134 | } |
| ... | @@ -137,9 +137,9 @@ template <class _Mutex> | ... | @@ -137,9 +137,9 @@ template <class _Mutex> |
| 137 | template <class _Rep, class _Period> | 137 | template <class _Rep, class _Period> |
| 138 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | 138 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { |
| 139 | if (__m_ == nullptr) | 139 | if (__m_ == nullptr) |
| 140 | __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex"); | 140 | std::__throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex"); |
| 141 | if (__owns_) | 141 | if (__owns_) |
| 142 | __throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked"); | 142 | std::__throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked"); |
| 143 | __owns_ = __m_->try_lock_for(__d); | 143 | __owns_ = __m_->try_lock_for(__d); |
| 144 | return __owns_; | 144 | return __owns_; |
| 145 | } | 145 | } |
| ... | @@ -148,9 +148,9 @@ template <class _Mutex> | ... | @@ -148,9 +148,9 @@ template <class _Mutex> |
| 148 | template <class _Clock, class _Duration> | 148 | template <class _Clock, class _Duration> |
| 149 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | 149 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { |
| 150 | if (__m_ == nullptr) | 150 | if (__m_ == nullptr) |
| 151 | __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex"); | 151 | std::__throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex"); |
| 152 | if (__owns_) | 152 | if (__owns_) |
| 153 | __throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked"); | 153 | std::__throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked"); |
| 154 | __owns_ = __m_->try_lock_until(__t); | 154 | __owns_ = __m_->try_lock_until(__t); |
| 155 | return __owns_; | 155 | return __owns_; |
| 156 | } | 156 | } |
| ... | @@ -158,7 +158,7 @@ _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::tim | ... | @@ -158,7 +158,7 @@ _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::tim |
| 158 | template <class _Mutex> | 158 | template <class _Mutex> |
| 159 | _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() { | 159 | _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() { |
| 160 | if (!__owns_) | 160 | if (!__owns_) |
| 161 | __throw_system_error(EPERM, "unique_lock::unlock: not locked"); | 161 | std::__throw_system_error(EPERM, "unique_lock::unlock: not locked"); |
| 162 | __m_->unlock(); | 162 | __m_->unlock(); |
| 163 | __owns_ = false; | 163 | __owns_ = false; |
| 164 | } | 164 | } |
lib/libcxx/include/__new/align_val_t.h+2-3| ... | @@ -16,8 +16,7 @@ | ... | @@ -16,8 +16,7 @@ |
| 16 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | // purposefully not using versioning namespace | 19 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 20 | namespace std { | ||
| 21 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) | 20 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) |
| 22 | # ifndef _LIBCPP_CXX03_LANG | 21 | # ifndef _LIBCPP_CXX03_LANG |
| 23 | enum class align_val_t : size_t {}; | 22 | enum class align_val_t : size_t {}; |
| ... | @@ -25,6 +24,6 @@ enum class align_val_t : size_t {}; | ... | @@ -25,6 +24,6 @@ enum class align_val_t : size_t {}; |
| 25 | enum align_val_t { __zero = 0, __max = (size_t)-1 }; | 24 | enum align_val_t { __zero = 0, __max = (size_t)-1 }; |
| 26 | # endif | 25 | # endif |
| 27 | #endif | 26 | #endif |
| 28 | } // namespace std | 27 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 29 | 28 | ||
| 30 | #endif // _LIBCPP___NEW_ALIGN_VAL_T_H | 29 | #endif // _LIBCPP___NEW_ALIGN_VAL_T_H |
lib/libcxx/include/__new/allocate.h+20-51| ... | @@ -31,37 +31,16 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(siz | ... | @@ -31,37 +31,16 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(siz |
| 31 | #endif | 31 | #endif |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | template <class... _Args> | ||
| 35 | _LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) { | ||
| 36 | #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) | ||
| 37 | return __builtin_operator_new(__args...); | ||
| 38 | #else | ||
| 39 | return ::operator new(__args...); | ||
| 40 | #endif | ||
| 41 | } | ||
| 42 | |||
| 43 | template <class... _Args> | ||
| 44 | _LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT { | ||
| 45 | #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) | ||
| 46 | __builtin_operator_delete(__args...); | ||
| 47 | #else | ||
| 48 | ::operator delete(__args...); | ||
| 49 | #endif | ||
| 50 | } | ||
| 51 | |||
| 52 | template <class _Tp> | 34 | template <class _Tp> |
| 53 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp* | 35 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp* |
| 54 | __libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) { | 36 | __libcpp_allocate(__element_count __n, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) { |
| 55 | size_t __size = static_cast<size_t>(__n) * sizeof(_Tp); | 37 | size_t __size = static_cast<size_t>(__n) * sizeof(_Tp); |
| 56 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION | 38 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION |
| 57 | if (__is_overaligned_for_new(__align)) { | 39 | if (__is_overaligned_for_new(__align)) |
| 58 | const align_val_t __align_val = static_cast<align_val_t>(__align); | 40 | return static_cast<_Tp*>(__builtin_operator_new(__size, static_cast<align_val_t>(__align))); |
| 59 | return static_cast<_Tp*>(std::__libcpp_operator_new(__size, __align_val)); | ||
| 60 | } | ||
| 61 | #endif | 41 | #endif |
| 62 | 42 | ||
| 63 | (void)__align; | 43 | return static_cast<_Tp*>(__builtin_operator_new(__size)); |
| 64 | return static_cast<_Tp*>(std::__libcpp_operator_new(__size)); | ||
| 65 | } | 44 | } |
| 66 | 45 | ||
| 67 | #if _LIBCPP_HAS_SIZED_DEALLOCATION | 46 | #if _LIBCPP_HAS_SIZED_DEALLOCATION |
| ... | @@ -71,39 +50,29 @@ __libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) { | ... | @@ -71,39 +50,29 @@ __libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) { |
| 71 | #endif | 50 | #endif |
| 72 | 51 | ||
| 73 | template <class _Tp> | 52 | template <class _Tp> |
| 74 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate( | 53 | inline _LIBCPP_HIDE_FROM_ABI void |
| 75 | __type_identity_t<_Tp>* __ptr, __element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT { | 54 | __libcpp_deallocate(__type_identity_t<_Tp>* __ptr, |
| 76 | size_t __size = static_cast<size_t>(__n) * sizeof(_Tp); | 55 | __element_count __n, |
| 77 | (void)__size; | 56 | [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT { |
| 78 | #if !_LIBCPP_HAS_ALIGNED_ALLOCATION | 57 | [[__maybe_unused__]] size_t __size = static_cast<size_t>(__n) * sizeof(_Tp); |
| 79 | (void)__align; | 58 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION |
| 80 | return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size)); | 59 | if (__is_overaligned_for_new(__align)) |
| 81 | #else | 60 | return __builtin_operator_delete( |
| 82 | if (__is_overaligned_for_new(__align)) { | 61 | __ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), static_cast<align_val_t>(__align)); |
| 83 | const align_val_t __align_val = static_cast<align_val_t>(__align); | ||
| 84 | return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), __align_val); | ||
| 85 | } else { | ||
| 86 | return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size)); | ||
| 87 | } | ||
| 88 | #endif | 62 | #endif |
| 63 | return __builtin_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size)); | ||
| 89 | } | 64 | } |
| 90 | 65 | ||
| 91 | #undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION | 66 | #undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION |
| 92 | 67 | ||
| 93 | template <class _Tp> | 68 | template <class _Tp> |
| 94 | inline _LIBCPP_HIDE_FROM_ABI void | 69 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized( |
| 95 | __libcpp_deallocate_unsized(__type_identity_t<_Tp>* __ptr, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT { | 70 | __type_identity_t<_Tp>* __ptr, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT { |
| 96 | #if !_LIBCPP_HAS_ALIGNED_ALLOCATION | 71 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION |
| 97 | (void)__align; | 72 | if (__is_overaligned_for_new(__align)) |
| 98 | return std::__libcpp_operator_delete(__ptr); | 73 | return __builtin_operator_delete(__ptr, static_cast<align_val_t>(__align)); |
| 99 | #else | ||
| 100 | if (__is_overaligned_for_new(__align)) { | ||
| 101 | const align_val_t __align_val = static_cast<align_val_t>(__align); | ||
| 102 | return std::__libcpp_operator_delete(__ptr, __align_val); | ||
| 103 | } else { | ||
| 104 | return std::__libcpp_operator_delete(__ptr); | ||
| 105 | } | ||
| 106 | #endif | 74 | #endif |
| 75 | return __builtin_operator_delete(__ptr); | ||
| 107 | } | 76 | } |
| 108 | _LIBCPP_END_NAMESPACE_STD | 77 | _LIBCPP_END_NAMESPACE_STD |
| 109 | 78 |
lib/libcxx/include/__new/destroying_delete_t.h+2-3| ... | @@ -16,15 +16,14 @@ | ... | @@ -16,15 +16,14 @@ |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | #if _LIBCPP_STD_VER >= 20 | 18 | #if _LIBCPP_STD_VER >= 20 |
| 19 | // purposefully not using versioning namespace | 19 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 20 | namespace std { | ||
| 21 | // Enable the declaration even if the compiler doesn't support the language | 20 | // Enable the declaration even if the compiler doesn't support the language |
| 22 | // feature. | 21 | // feature. |
| 23 | struct destroying_delete_t { | 22 | struct destroying_delete_t { |
| 24 | explicit destroying_delete_t() = default; | 23 | explicit destroying_delete_t() = default; |
| 25 | }; | 24 | }; |
| 26 | inline constexpr destroying_delete_t destroying_delete{}; | 25 | inline constexpr destroying_delete_t destroying_delete{}; |
| 27 | } // namespace std | 26 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 28 | #endif | 27 | #endif |
| 29 | 28 | ||
| 30 | #endif // _LIBCPP___NEW_DESTROYING_DELETE_T_H | 29 | #endif // _LIBCPP___NEW_DESTROYING_DELETE_T_H |
lib/libcxx/include/__new/exceptions.h+2-3| ... | @@ -17,8 +17,7 @@ | ... | @@ -17,8 +17,7 @@ |
| 17 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | // purposefully not using versioning namespace | 20 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 21 | namespace std { | ||
| 22 | #if !defined(_LIBCPP_ABI_VCRUNTIME) | 21 | #if !defined(_LIBCPP_ABI_VCRUNTIME) |
| 23 | 22 | ||
| 24 | class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception { | 23 | class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception { |
| ... | @@ -69,6 +68,6 @@ public: | ... | @@ -69,6 +68,6 @@ public: |
| 69 | _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode"); | 68 | _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode"); |
| 70 | #endif | 69 | #endif |
| 71 | } | 70 | } |
| 72 | } // namespace std | 71 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 73 | 72 | ||
| 74 | #endif // _LIBCPP___NEW_EXCEPTIONS_H | 73 | #endif // _LIBCPP___NEW_EXCEPTIONS_H |
lib/libcxx/include/__new/new_handler.h+2-3| ... | @@ -18,12 +18,11 @@ | ... | @@ -18,12 +18,11 @@ |
| 18 | #if defined(_LIBCPP_ABI_VCRUNTIME) | 18 | #if defined(_LIBCPP_ABI_VCRUNTIME) |
| 19 | # include <new.h> | 19 | # include <new.h> |
| 20 | #else | 20 | #else |
| 21 | // purposefully not using versioning namespace | 21 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 22 | namespace std { | ||
| 23 | typedef void (*new_handler)(); | 22 | typedef void (*new_handler)(); |
| 24 | _LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT; | 23 | _LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT; |
| 25 | _LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT; | 24 | _LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT; |
| 26 | } // namespace std | 25 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 27 | #endif // _LIBCPP_ABI_VCRUNTIME | 26 | #endif // _LIBCPP_ABI_VCRUNTIME |
| 28 | 27 | ||
| 29 | #endif // _LIBCPP___NEW_NEW_HANDLER_H | 28 | #endif // _LIBCPP___NEW_NEW_HANDLER_H |
lib/libcxx/include/__new/nothrow_t.h+2-3| ... | @@ -18,13 +18,12 @@ | ... | @@ -18,13 +18,12 @@ |
| 18 | #if defined(_LIBCPP_ABI_VCRUNTIME) | 18 | #if defined(_LIBCPP_ABI_VCRUNTIME) |
| 19 | # include <new.h> | 19 | # include <new.h> |
| 20 | #else | 20 | #else |
| 21 | // purposefully not using versioning namespace | 21 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 22 | namespace std { | ||
| 23 | struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t { | 22 | struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t { |
| 24 | explicit nothrow_t() = default; | 23 | explicit nothrow_t() = default; |
| 25 | }; | 24 | }; |
| 26 | extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow; | 25 | extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow; |
| 27 | } // namespace std | 26 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 28 | #endif // _LIBCPP_ABI_VCRUNTIME | 27 | #endif // _LIBCPP_ABI_VCRUNTIME |
| 29 | 28 | ||
| 30 | #endif // _LIBCPP___NEW_NOTHROW_T_H | 29 | #endif // _LIBCPP___NEW_NOTHROW_T_H |
lib/libcxx/include/__node_handle+7-6| ... | @@ -62,6 +62,7 @@ public: | ... | @@ -62,6 +62,7 @@ public: |
| 62 | #include <__config> | 62 | #include <__config> |
| 63 | #include <__memory/allocator_traits.h> | 63 | #include <__memory/allocator_traits.h> |
| 64 | #include <__memory/pointer_traits.h> | 64 | #include <__memory/pointer_traits.h> |
| 65 | #include <__type_traits/is_specialization.h> | ||
| 65 | #include <optional> | 66 | #include <optional> |
| 66 | 67 | ||
| 67 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 68 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -80,7 +81,7 @@ template <class _NodeType, class _Alloc> | ... | @@ -80,7 +81,7 @@ template <class _NodeType, class _Alloc> |
| 80 | struct __generic_container_node_destructor; | 81 | struct __generic_container_node_destructor; |
| 81 | 82 | ||
| 82 | template <class _NodeType, class _Alloc, template <class, class> class _MapOrSetSpecifics> | 83 | template <class _NodeType, class _Alloc, template <class, class> class _MapOrSetSpecifics> |
| 83 | class _LIBCPP_TEMPLATE_VIS __basic_node_handle | 84 | class __basic_node_handle |
| 84 | : public _MapOrSetSpecifics< _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>> { | 85 | : public _MapOrSetSpecifics< _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>> { |
| 85 | template <class _Tp, class _Compare, class _Allocator> | 86 | template <class _Tp, class _Compare, class _Allocator> |
| 86 | friend class __tree; | 87 | friend class __tree; |
| ... | @@ -175,15 +176,15 @@ struct __set_node_handle_specifics { | ... | @@ -175,15 +176,15 @@ struct __set_node_handle_specifics { |
| 175 | 176 | ||
| 176 | template <class _NodeType, class _Derived> | 177 | template <class _NodeType, class _Derived> |
| 177 | struct __map_node_handle_specifics { | 178 | struct __map_node_handle_specifics { |
| 178 | typedef typename _NodeType::__node_value_type::key_type key_type; | 179 | using key_type = __remove_const_t<typename _NodeType::__node_value_type::first_type>; |
| 179 | typedef typename _NodeType::__node_value_type::mapped_type mapped_type; | 180 | using mapped_type = typename _NodeType::__node_value_type::second_type; |
| 180 | 181 | ||
| 181 | _LIBCPP_HIDE_FROM_ABI key_type& key() const { | 182 | _LIBCPP_HIDE_FROM_ABI key_type& key() const { |
| 182 | return static_cast<_Derived const*>(this)->__ptr_->__get_value().__ref().first; | 183 | return const_cast<key_type&>(static_cast<_Derived const*>(this)->__ptr_->__get_value().first); |
| 183 | } | 184 | } |
| 184 | 185 | ||
| 185 | _LIBCPP_HIDE_FROM_ABI mapped_type& mapped() const { | 186 | _LIBCPP_HIDE_FROM_ABI mapped_type& mapped() const { |
| 186 | return static_cast<_Derived const*>(this)->__ptr_->__get_value().__ref().second; | 187 | return static_cast<_Derived const*>(this)->__ptr_->__get_value().second; |
| 187 | } | 188 | } |
| 188 | }; | 189 | }; |
| 189 | 190 | ||
| ... | @@ -194,7 +195,7 @@ template <class _NodeType, class _Alloc> | ... | @@ -194,7 +195,7 @@ template <class _NodeType, class _Alloc> |
| 194 | using __map_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>; | 195 | using __map_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>; |
| 195 | 196 | ||
| 196 | template <class _Iterator, class _NodeType> | 197 | template <class _Iterator, class _NodeType> |
| 197 | struct _LIBCPP_TEMPLATE_VIS __insert_return_type { | 198 | struct __insert_return_type { |
| 198 | _Iterator position; | 199 | _Iterator position; |
| 199 | bool inserted; | 200 | bool inserted; |
| 200 | _NodeType node; | 201 | _NodeType node; |
lib/libcxx/include/__numeric/gcd_lcm.h+3-2| ... | @@ -10,15 +10,16 @@ | ... | @@ -10,15 +10,16 @@ |
| 10 | #ifndef _LIBCPP___NUMERIC_GCD_LCM_H | 10 | #ifndef _LIBCPP___NUMERIC_GCD_LCM_H |
| 11 | #define _LIBCPP___NUMERIC_GCD_LCM_H | 11 | #define _LIBCPP___NUMERIC_GCD_LCM_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/min.h> | ||
| 14 | #include <__assert> | 13 | #include <__assert> |
| 15 | #include <__bit/countr.h> | 14 | #include <__bit/countr.h> |
| 16 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__memory/addressof.h> | ||
| 17 | #include <__type_traits/common_type.h> | 17 | #include <__type_traits/common_type.h> |
| 18 | #include <__type_traits/is_integral.h> | 18 | #include <__type_traits/is_integral.h> |
| 19 | #include <__type_traits/is_same.h> | 19 | #include <__type_traits/is_same.h> |
| 20 | #include <__type_traits/is_signed.h> | 20 | #include <__type_traits/is_signed.h> |
| 21 | #include <__type_traits/make_unsigned.h> | 21 | #include <__type_traits/make_unsigned.h> |
| 22 | #include <__type_traits/remove_cv.h> | ||
| 22 | #include <limits> | 23 | #include <limits> |
| 23 | 24 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -115,7 +116,7 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) { | ... | @@ -115,7 +116,7 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) { |
| 115 | _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n); | 116 | _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n); |
| 116 | _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); | 117 | _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); |
| 117 | _Rp __res; | 118 | _Rp __res; |
| 118 | [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, &__res); | 119 | [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, std::addressof(__res)); |
| 119 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm"); | 120 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm"); |
| 120 | return __res; | 121 | return __res; |
| 121 | } | 122 | } |
lib/libcxx/include/__numeric/ranges_iota.h created+65| ... | @@ -0,0 +1,65 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___NUMERIC_RANGES_IOTA_H | ||
| 11 | #define _LIBCPP___NUMERIC_RANGES_IOTA_H | ||
| 12 | |||
| 13 | #include <__algorithm/out_value_result.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__iterator/concepts.h> | ||
| 16 | #include <__ranges/access.h> | ||
| 17 | #include <__ranges/concepts.h> | ||
| 18 | #include <__ranges/dangling.h> | ||
| 19 | #include <__utility/as_const.h> | ||
| 20 | #include <__utility/move.h> | ||
| 21 | |||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 23 | # pragma GCC system_header | ||
| 24 | #endif | ||
| 25 | |||
| 26 | _LIBCPP_PUSH_MACROS | ||
| 27 | #include <__undef_macros> | ||
| 28 | |||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 30 | |||
| 31 | #if _LIBCPP_STD_VER >= 23 | ||
| 32 | namespace ranges { | ||
| 33 | template <typename _Out, typename _Tp> | ||
| 34 | using iota_result = ranges::out_value_result<_Out, _Tp>; | ||
| 35 | |||
| 36 | struct __iota_fn { | ||
| 37 | public: | ||
| 38 | template <input_or_output_iterator _Out, sentinel_for<_Out> _Sent, weakly_incrementable _Tp> | ||
| 39 | requires indirectly_writable<_Out, const _Tp&> | ||
| 40 | _LIBCPP_HIDE_FROM_ABI static constexpr iota_result<_Out, _Tp> operator()(_Out __first, _Sent __last, _Tp __value) { | ||
| 41 | while (__first != __last) { | ||
| 42 | *__first = std::as_const(__value); | ||
| 43 | ++__first; | ||
| 44 | ++__value; | ||
| 45 | } | ||
| 46 | return {std::move(__first), std::move(__value)}; | ||
| 47 | } | ||
| 48 | |||
| 49 | template <weakly_incrementable _Tp, ranges::output_range<const _Tp&> _Range> | ||
| 50 | _LIBCPP_HIDE_FROM_ABI static constexpr iota_result<ranges::borrowed_iterator_t<_Range>, _Tp> | ||
| 51 | operator()(_Range&& __r, _Tp __value) { | ||
| 52 | return operator()(ranges::begin(__r), ranges::end(__r), std::move(__value)); | ||
| 53 | } | ||
| 54 | }; | ||
| 55 | |||
| 56 | inline constexpr auto iota = __iota_fn{}; | ||
| 57 | } // namespace ranges | ||
| 58 | |||
| 59 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 60 | |||
| 61 | _LIBCPP_END_NAMESPACE_STD | ||
| 62 | |||
| 63 | _LIBCPP_POP_MACROS | ||
| 64 | |||
| 65 | #endif // _LIBCPP___NUMERIC_RANGES_IOTA_H | ||
lib/libcxx/include/__numeric/saturation_arithmetic.h+19-18| ... | @@ -11,8 +11,9 @@ | ... | @@ -11,8 +11,9 @@ |
| 11 | #define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H | 11 | #define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H |
| 12 | 12 | ||
| 13 | #include <__assert> | 13 | #include <__assert> |
| 14 | #include <__concepts/arithmetic.h> | ||
| 15 | #include <__config> | 14 | #include <__config> |
| 15 | #include <__memory/addressof.h> | ||
| 16 | #include <__type_traits/integer_traits.h> | ||
| 16 | #include <__utility/cmp.h> | 17 | #include <__utility/cmp.h> |
| 17 | #include <limits> | 18 | #include <limits> |
| 18 | 19 | ||
| ... | @@ -27,12 +28,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -27,12 +28,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 28 | ||
| 28 | #if _LIBCPP_STD_VER >= 20 | 29 | #if _LIBCPP_STD_VER >= 20 |
| 29 | 30 | ||
| 30 | template <__libcpp_integer _Tp> | 31 | template <__signed_or_unsigned_integer _Tp> |
| 31 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { | 32 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { |
| 32 | if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum)) | 33 | if (_Tp __sum; !__builtin_add_overflow(__x, __y, std::addressof(__sum))) |
| 33 | return __sum; | 34 | return __sum; |
| 34 | // Handle overflow | 35 | // Handle overflow |
| 35 | if constexpr (__libcpp_unsigned_integer<_Tp>) { | 36 | if constexpr (__unsigned_integer<_Tp>) { |
| 36 | return std::numeric_limits<_Tp>::max(); | 37 | return std::numeric_limits<_Tp>::max(); |
| 37 | } else { | 38 | } else { |
| 38 | // Signed addition overflow | 39 | // Signed addition overflow |
| ... | @@ -45,12 +46,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -45,12 +46,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept { |
| 45 | } | 46 | } |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | template <__libcpp_integer _Tp> | 49 | template <__signed_or_unsigned_integer _Tp> |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { | 50 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { |
| 50 | if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub)) | 51 | if (_Tp __sub; !__builtin_sub_overflow(__x, __y, std::addressof(__sub))) |
| 51 | return __sub; | 52 | return __sub; |
| 52 | // Handle overflow | 53 | // Handle overflow |
| 53 | if constexpr (__libcpp_unsigned_integer<_Tp>) { | 54 | if constexpr (__unsigned_integer<_Tp>) { |
| 54 | // Overflows if (x < y) | 55 | // Overflows if (x < y) |
| 55 | return std::numeric_limits<_Tp>::min(); | 56 | return std::numeric_limits<_Tp>::min(); |
| 56 | } else { | 57 | } else { |
| ... | @@ -64,12 +65,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -64,12 +65,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept { |
| 64 | } | 65 | } |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | template <__libcpp_integer _Tp> | 68 | template <__signed_or_unsigned_integer _Tp> |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept { | 69 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept { |
| 69 | if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul)) | 70 | if (_Tp __mul; !__builtin_mul_overflow(__x, __y, std::addressof(__mul))) |
| 70 | return __mul; | 71 | return __mul; |
| 71 | // Handle overflow | 72 | // Handle overflow |
| 72 | if constexpr (__libcpp_unsigned_integer<_Tp>) { | 73 | if constexpr (__unsigned_integer<_Tp>) { |
| 73 | return std::numeric_limits<_Tp>::max(); | 74 | return std::numeric_limits<_Tp>::max(); |
| 74 | } else { | 75 | } else { |
| 75 | // Signed multiplication overflow | 76 | // Signed multiplication overflow |
| ... | @@ -80,10 +81,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -80,10 +81,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept { |
| 80 | } | 81 | } |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | template <__libcpp_integer _Tp> | 84 | template <__signed_or_unsigned_integer _Tp> |
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept { | 85 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept { |
| 85 | _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined"); | 86 | _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined"); |
| 86 | if constexpr (__libcpp_unsigned_integer<_Tp>) { | 87 | if constexpr (__unsigned_integer<_Tp>) { |
| 87 | return __x / __y; | 88 | return __x / __y; |
| 88 | } else { | 89 | } else { |
| 89 | // Handle signed division overflow | 90 | // Handle signed division overflow |
| ... | @@ -93,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept { | ... | @@ -93,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept { |
| 93 | } | 94 | } |
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | template <__libcpp_integer _Rp, __libcpp_integer _Tp> | 97 | template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp> |
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { | 98 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { |
| 98 | // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be | 99 | // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be |
| 99 | // optimized out by the compiler. | 100 | // optimized out by the compiler. |
| ... | @@ -111,27 +112,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { | ... | @@ -111,27 +112,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { |
| 111 | 112 | ||
| 112 | #if _LIBCPP_STD_VER >= 26 | 113 | #if _LIBCPP_STD_VER >= 26 |
| 113 | 114 | ||
| 114 | template <__libcpp_integer _Tp> | 115 | template <__signed_or_unsigned_integer _Tp> |
| 115 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { | 116 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { |
| 116 | return std::__add_sat(__x, __y); | 117 | return std::__add_sat(__x, __y); |
| 117 | } | 118 | } |
| 118 | 119 | ||
| 119 | template <__libcpp_integer _Tp> | 120 | template <__signed_or_unsigned_integer _Tp> |
| 120 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { | 121 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { |
| 121 | return std::__sub_sat(__x, __y); | 122 | return std::__sub_sat(__x, __y); |
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | template <__libcpp_integer _Tp> | 125 | template <__signed_or_unsigned_integer _Tp> |
| 125 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { | 126 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { |
| 126 | return std::__mul_sat(__x, __y); | 127 | return std::__mul_sat(__x, __y); |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | template <__libcpp_integer _Tp> | 130 | template <__signed_or_unsigned_integer _Tp> |
| 130 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { | 131 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { |
| 131 | return std::__div_sat(__x, __y); | 132 | return std::__div_sat(__x, __y); |
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | template <__libcpp_integer _Rp, __libcpp_integer _Tp> | 135 | template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp> |
| 135 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { | 136 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { |
| 136 | return std::__saturate_cast<_Rp>(__x); | 137 | return std::__saturate_cast<_Rp>(__x); |
| 137 | } | 138 | } |
lib/libcxx/include/__ostream/basic_ostream.h+12-9| ... | @@ -15,6 +15,10 @@ | ... | @@ -15,6 +15,10 @@ |
| 15 | 15 | ||
| 16 | # include <__exception/operations.h> | 16 | # include <__exception/operations.h> |
| 17 | # include <__fwd/memory.h> | 17 | # include <__fwd/memory.h> |
| 18 | # include <__iterator/ostreambuf_iterator.h> | ||
| 19 | # include <__locale_dir/num.h> | ||
| 20 | # include <__locale_dir/pad_and_output.h> | ||
| 21 | # include <__memory/addressof.h> | ||
| 18 | # include <__memory/unique_ptr.h> | 22 | # include <__memory/unique_ptr.h> |
| 19 | # include <__new/exceptions.h> | 23 | # include <__new/exceptions.h> |
| 20 | # include <__ostream/put_character_sequence.h> | 24 | # include <__ostream/put_character_sequence.h> |
| ... | @@ -26,7 +30,6 @@ | ... | @@ -26,7 +30,6 @@ |
| 26 | # include <__utility/declval.h> | 30 | # include <__utility/declval.h> |
| 27 | # include <bitset> | 31 | # include <bitset> |
| 28 | # include <ios> | 32 | # include <ios> |
| 29 | # include <locale> | ||
| 30 | # include <streambuf> | 33 | # include <streambuf> |
| 31 | # include <string_view> | 34 | # include <string_view> |
| 32 | 35 | ||
| ... | @@ -40,7 +43,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -40,7 +43,7 @@ _LIBCPP_PUSH_MACROS |
| 40 | _LIBCPP_BEGIN_NAMESPACE_STD | 43 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 44 | ||
| 42 | template <class _CharT, class _Traits> | 45 | template <class _CharT, class _Traits> |
| 43 | class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Traits> { | 46 | class basic_ostream : virtual public basic_ios<_CharT, _Traits> { |
| 44 | public: | 47 | public: |
| 45 | // types (inherited from basic_ios (27.5.4)): | 48 | // types (inherited from basic_ios (27.5.4)): |
| 46 | typedef _CharT char_type; | 49 | typedef _CharT char_type; |
| ... | @@ -70,7 +73,7 @@ protected: | ... | @@ -70,7 +73,7 @@ protected: |
| 70 | 73 | ||
| 71 | public: | 74 | public: |
| 72 | // 27.7.2.4 Prefix/suffix: | 75 | // 27.7.2.4 Prefix/suffix: |
| 73 | class _LIBCPP_TEMPLATE_VIS sentry; | 76 | class sentry; |
| 74 | 77 | ||
| 75 | // 27.7.2.6 Formatted output: | 78 | // 27.7.2.6 Formatted output: |
| 76 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) { | 79 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) { |
| ... | @@ -180,7 +183,7 @@ protected: | ... | @@ -180,7 +183,7 @@ protected: |
| 180 | }; | 183 | }; |
| 181 | 184 | ||
| 182 | template <class _CharT, class _Traits> | 185 | template <class _CharT, class _Traits> |
| 183 | class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry { | 186 | class basic_ostream<_CharT, _Traits>::sentry { |
| 184 | bool __ok_; | 187 | bool __ok_; |
| 185 | basic_ostream<_CharT, _Traits>& __os_; | 188 | basic_ostream<_CharT, _Traits>& __os_; |
| 186 | 189 | ||
| ... | @@ -339,7 +342,7 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const | ... | @@ -339,7 +342,7 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const |
| 339 | 342 | ||
| 340 | template <class _CharT, class _Traits> | 343 | template <class _CharT, class _Traits> |
| 341 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) { | 344 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) { |
| 342 | return std::__put_character_sequence(__os, &__c, 1); | 345 | return std::__put_character_sequence(__os, std::addressof(__c), 1); |
| 343 | } | 346 | } |
| 344 | 347 | ||
| 345 | template <class _CharT, class _Traits> | 348 | template <class _CharT, class _Traits> |
| ... | @@ -353,9 +356,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ | ... | @@ -353,9 +356,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ |
| 353 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | 356 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; |
| 354 | if (std::__pad_and_output( | 357 | if (std::__pad_and_output( |
| 355 | _Ip(__os), | 358 | _Ip(__os), |
| 356 | &__c, | 359 | std::addressof(__c), |
| 357 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c, | 360 | std::addressof(__c) + (((__os.flags() & ios_base::adjustfield) == ios_base::left) ? 1 : 0), |
| 358 | &__c + 1, | 361 | std::addressof(__c) + 1, |
| 359 | __os, | 362 | __os, |
| 360 | __os.fill()) | 363 | __os.fill()) |
| 361 | .failed()) | 364 | .failed()) |
| ... | @@ -407,7 +410,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { | ... | @@ -407,7 +410,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { |
| 407 | if (__len > __bs) { | 410 | if (__len > __bs) { |
| 408 | __wb = (_CharT*)malloc(__len * sizeof(_CharT)); | 411 | __wb = (_CharT*)malloc(__len * sizeof(_CharT)); |
| 409 | if (__wb == 0) | 412 | if (__wb == 0) |
| 410 | __throw_bad_alloc(); | 413 | std::__throw_bad_alloc(); |
| 411 | __h.reset(__wb); | 414 | __h.reset(__wb); |
| 412 | } | 415 | } |
| 413 | for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p) | 416 | for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p) |
lib/libcxx/include/__ostream/print.h+3-13| ... | @@ -18,8 +18,8 @@ | ... | @@ -18,8 +18,8 @@ |
| 18 | # include <__ostream/basic_ostream.h> | 18 | # include <__ostream/basic_ostream.h> |
| 19 | # include <format> | 19 | # include <format> |
| 20 | # include <ios> | 20 | # include <ios> |
| 21 | # include <locale> | ||
| 22 | # include <print> | 21 | # include <print> |
| 22 | # include <streambuf> | ||
| 23 | 23 | ||
| 24 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 24 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | # pragma GCC system_header | 25 | # pragma GCC system_header |
| ... | @@ -49,21 +49,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ | ... | @@ -49,21 +49,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ |
| 49 | if (__write_nl) | 49 | if (__write_nl) |
| 50 | __o += '\n'; | 50 | __o += '\n'; |
| 51 | 51 | ||
| 52 | const char* __str = __o.data(); | ||
| 53 | size_t __len = __o.size(); | ||
| 54 | |||
| 55 | # if _LIBCPP_HAS_EXCEPTIONS | 52 | # if _LIBCPP_HAS_EXCEPTIONS |
| 56 | try { | 53 | try { |
| 57 | # endif // _LIBCPP_HAS_EXCEPTIONS | 54 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 58 | typedef ostreambuf_iterator<char> _Ip; | 55 | if (auto __rdbuf = __os.rdbuf(); |
| 59 | if (std::__pad_and_output( | 56 | !__rdbuf || __rdbuf->sputn(__o.data(), __o.size()) != static_cast<streamsize>(__o.size())) |
| 60 | _Ip(__os), | ||
| 61 | __str, | ||
| 62 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str, | ||
| 63 | __str + __len, | ||
| 64 | __os, | ||
| 65 | __os.fill()) | ||
| 66 | .failed()) | ||
| 67 | __os.setstate(ios_base::badbit | ios_base::failbit); | 57 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 68 | 58 | ||
| 69 | # if _LIBCPP_HAS_EXCEPTIONS | 59 | # if _LIBCPP_HAS_EXCEPTIONS |
lib/libcxx/include/__pstl/backends/libdispatch.h+1| ... | @@ -22,6 +22,7 @@ | ... | @@ -22,6 +22,7 @@ |
| 22 | #include <__iterator/move_iterator.h> | 22 | #include <__iterator/move_iterator.h> |
| 23 | #include <__memory/allocator.h> | 23 | #include <__memory/allocator.h> |
| 24 | #include <__memory/construct_at.h> | 24 | #include <__memory/construct_at.h> |
| 25 | #include <__memory/destroy.h> | ||
| 25 | #include <__memory/unique_ptr.h> | 26 | #include <__memory/unique_ptr.h> |
| 26 | #include <__new/exceptions.h> | 27 | #include <__new/exceptions.h> |
| 27 | #include <__numeric/reduce.h> | 28 | #include <__numeric/reduce.h> |
lib/libcxx/include/__random/bernoulli_distribution.h+2-2| ... | @@ -23,12 +23,12 @@ _LIBCPP_PUSH_MACROS | ... | @@ -23,12 +23,12 @@ _LIBCPP_PUSH_MACROS |
| 23 | 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | class _LIBCPP_TEMPLATE_VIS bernoulli_distribution { | 26 | class bernoulli_distribution { |
| 27 | public: | 27 | public: |
| 28 | // types | 28 | // types |
| 29 | typedef bool result_type; | 29 | typedef bool result_type; |
| 30 | 30 | ||
| 31 | class _LIBCPP_TEMPLATE_VIS param_type { | 31 | class param_type { |
| 32 | double __p_; | 32 | double __p_; |
| 33 | 33 | ||
| 34 | public: | 34 | public: |
lib/libcxx/include/__random/binomial_distribution.h+2-2| ... | @@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS | ... | @@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _IntType = int> | 27 | template <class _IntType = int> |
| 28 | class _LIBCPP_TEMPLATE_VIS binomial_distribution { | 28 | class binomial_distribution { |
| 29 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | 29 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); |
| 30 | 30 | ||
| 31 | public: | 31 | public: |
| 32 | // types | 32 | // types |
| 33 | typedef _IntType result_type; | 33 | typedef _IntType result_type; |
| 34 | 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type { | 35 | class param_type { |
| 36 | result_type __t_; | 36 | result_type __t_; |
| 37 | double __p_; | 37 | double __p_; |
| 38 | double __pr_; | 38 | double __pr_; |
lib/libcxx/include/__random/cauchy_distribution.h+2-2| ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | template <class _RealType = double> | 28 | template <class _RealType = double> |
| 29 | class _LIBCPP_TEMPLATE_VIS cauchy_distribution { | 29 | class cauchy_distribution { |
| 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 31 | "RealType must be a supported floating-point type"); | 31 | "RealType must be a supported floating-point type"); |
| 32 | 32 | ||
| ... | @@ -34,7 +34,7 @@ public: | ... | @@ -34,7 +34,7 @@ public: |
| 34 | // types | 34 | // types |
| 35 | typedef _RealType result_type; | 35 | typedef _RealType result_type; |
| 36 | 36 | ||
| 37 | class _LIBCPP_TEMPLATE_VIS param_type { | 37 | class param_type { |
| 38 | result_type __a_; | 38 | result_type __a_; |
| 39 | result_type __b_; | 39 | result_type __b_; |
| 40 | 40 |
lib/libcxx/include/__random/chi_squared_distribution.h+2-2| ... | @@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _RealType = double> | 27 | template <class _RealType = double> |
| 28 | class _LIBCPP_TEMPLATE_VIS chi_squared_distribution { | 28 | class chi_squared_distribution { |
| 29 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 29 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 30 | "RealType must be a supported floating-point type"); | 30 | "RealType must be a supported floating-point type"); |
| 31 | 31 | ||
| ... | @@ -33,7 +33,7 @@ public: | ... | @@ -33,7 +33,7 @@ public: |
| 33 | // types | 33 | // types |
| 34 | typedef _RealType result_type; | 34 | typedef _RealType result_type; |
| 35 | 35 | ||
| 36 | class _LIBCPP_TEMPLATE_VIS param_type { | 36 | class param_type { |
| 37 | result_type __n_; | 37 | result_type __n_; |
| 38 | 38 | ||
| 39 | public: | 39 | public: |
lib/libcxx/include/__random/clamp_to_integral.h+1-1| ... | @@ -43,7 +43,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float( | ... | @@ -43,7 +43,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float( |
| 43 | template <class _IntT, class _RealT> | 43 | template <class _IntT, class _RealT> |
| 44 | _LIBCPP_HIDE_FROM_ABI _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT { | 44 | _LIBCPP_HIDE_FROM_ABI _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT { |
| 45 | using _Lim = numeric_limits<_IntT>; | 45 | using _Lim = numeric_limits<_IntT>; |
| 46 | const _IntT __max_val = __max_representable_int_for_float<_IntT, _RealT>(); | 46 | const _IntT __max_val = std::__max_representable_int_for_float<_IntT, _RealT>(); |
| 47 | if (__r >= ::nextafter(static_cast<_RealT>(__max_val), INFINITY)) { | 47 | if (__r >= ::nextafter(static_cast<_RealT>(__max_val), INFINITY)) { |
| 48 | return _Lim::max(); | 48 | return _Lim::max(); |
| 49 | } else if (__r <= _Lim::lowest()) { | 49 | } else if (__r <= _Lim::lowest()) { |
lib/libcxx/include/__random/discard_block_engine.h+1-1| ... | @@ -28,7 +28,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -28,7 +28,7 @@ _LIBCPP_PUSH_MACROS |
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | ||
| 30 | template <class _Engine, size_t __p, size_t __r> | 30 | template <class _Engine, size_t __p, size_t __r> |
| 31 | class _LIBCPP_TEMPLATE_VIS discard_block_engine { | 31 | class discard_block_engine { |
| 32 | _Engine __e_; | 32 | _Engine __e_; |
| 33 | int __n_; | 33 | int __n_; |
| 34 | 34 |
lib/libcxx/include/__random/discrete_distribution.h+2-2| ... | @@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS | ... | @@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS |
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | ||
| 30 | template <class _IntType = int> | 30 | template <class _IntType = int> |
| 31 | class _LIBCPP_TEMPLATE_VIS discrete_distribution { | 31 | class discrete_distribution { |
| 32 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | 32 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); |
| 33 | 33 | ||
| 34 | public: | 34 | public: |
| 35 | // types | 35 | // types |
| 36 | typedef _IntType result_type; | 36 | typedef _IntType result_type; |
| 37 | 37 | ||
| 38 | class _LIBCPP_TEMPLATE_VIS param_type { | 38 | class param_type { |
| 39 | vector<double> __p_; | 39 | vector<double> __p_; |
| 40 | 40 | ||
| 41 | public: | 41 | public: |
lib/libcxx/include/__random/exponential_distribution.h+2-2| ... | @@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS |
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | template <class _RealType = double> | 29 | template <class _RealType = double> |
| 30 | class _LIBCPP_TEMPLATE_VIS exponential_distribution { | 30 | class exponential_distribution { |
| 31 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 31 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 32 | "RealType must be a supported floating-point type"); | 32 | "RealType must be a supported floating-point type"); |
| 33 | 33 | ||
| ... | @@ -35,7 +35,7 @@ public: | ... | @@ -35,7 +35,7 @@ public: |
| 35 | // types | 35 | // types |
| 36 | typedef _RealType result_type; | 36 | typedef _RealType result_type; |
| 37 | 37 | ||
| 38 | class _LIBCPP_TEMPLATE_VIS param_type { | 38 | class param_type { |
| 39 | result_type __lambda_; | 39 | result_type __lambda_; |
| 40 | 40 | ||
| 41 | public: | 41 | public: |
lib/libcxx/include/__random/extreme_value_distribution.h+2-2| ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | template <class _RealType = double> | 28 | template <class _RealType = double> |
| 29 | class _LIBCPP_TEMPLATE_VIS extreme_value_distribution { | 29 | class extreme_value_distribution { |
| 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 31 | "RealType must be a supported floating-point type"); | 31 | "RealType must be a supported floating-point type"); |
| 32 | 32 | ||
| ... | @@ -34,7 +34,7 @@ public: | ... | @@ -34,7 +34,7 @@ public: |
| 34 | // types | 34 | // types |
| 35 | typedef _RealType result_type; | 35 | typedef _RealType result_type; |
| 36 | 36 | ||
| 37 | class _LIBCPP_TEMPLATE_VIS param_type { | 37 | class param_type { |
| 38 | result_type __a_; | 38 | result_type __a_; |
| 39 | result_type __b_; | 39 | result_type __b_; |
| 40 | 40 |
lib/libcxx/include/__random/fisher_f_distribution.h+2-2| ... | @@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _RealType = double> | 27 | template <class _RealType = double> |
| 28 | class _LIBCPP_TEMPLATE_VIS fisher_f_distribution { | 28 | class fisher_f_distribution { |
| 29 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 29 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 30 | "RealType must be a supported floating-point type"); | 30 | "RealType must be a supported floating-point type"); |
| 31 | 31 | ||
| ... | @@ -33,7 +33,7 @@ public: | ... | @@ -33,7 +33,7 @@ public: |
| 33 | // types | 33 | // types |
| 34 | typedef _RealType result_type; | 34 | typedef _RealType result_type; |
| 35 | 35 | ||
| 36 | class _LIBCPP_TEMPLATE_VIS param_type { | 36 | class param_type { |
| 37 | result_type __m_; | 37 | result_type __m_; |
| 38 | result_type __n_; | 38 | result_type __n_; |
| 39 | 39 |
lib/libcxx/include/__random/gamma_distribution.h+2-2| ... | @@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS |
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | template <class _RealType = double> | 29 | template <class _RealType = double> |
| 30 | class _LIBCPP_TEMPLATE_VIS gamma_distribution { | 30 | class gamma_distribution { |
| 31 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 31 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 32 | "RealType must be a supported floating-point type"); | 32 | "RealType must be a supported floating-point type"); |
| 33 | 33 | ||
| ... | @@ -35,7 +35,7 @@ public: | ... | @@ -35,7 +35,7 @@ public: |
| 35 | // types | 35 | // types |
| 36 | typedef _RealType result_type; | 36 | typedef _RealType result_type; |
| 37 | 37 | ||
| 38 | class _LIBCPP_TEMPLATE_VIS param_type { | 38 | class param_type { |
| 39 | result_type __alpha_; | 39 | result_type __alpha_; |
| 40 | result_type __beta_; | 40 | result_type __beta_; |
| 41 | 41 |
lib/libcxx/include/__random/geometric_distribution.h+2-2| ... | @@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS | ... | @@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _IntType = int> | 27 | template <class _IntType = int> |
| 28 | class _LIBCPP_TEMPLATE_VIS geometric_distribution { | 28 | class geometric_distribution { |
| 29 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | 29 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); |
| 30 | 30 | ||
| 31 | public: | 31 | public: |
| 32 | // types | 32 | // types |
| 33 | typedef _IntType result_type; | 33 | typedef _IntType result_type; |
| 34 | 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type { | 35 | class param_type { |
| 36 | double __p_; | 36 | double __p_; |
| 37 | 37 | ||
| 38 | public: | 38 | public: |
lib/libcxx/include/__random/independent_bits_engine.h+1-1| ... | @@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS |
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | ||
| 33 | template <class _Engine, size_t __w, class _UIntType> | 33 | template <class _Engine, size_t __w, class _UIntType> |
| 34 | class _LIBCPP_TEMPLATE_VIS independent_bits_engine { | 34 | class independent_bits_engine { |
| 35 | template <class _UInt, _UInt _R0, size_t _Wp, size_t _Mp> | 35 | template <class _UInt, _UInt _R0, size_t _Wp, size_t _Mp> |
| 36 | class __get_n { | 36 | class __get_n { |
| 37 | static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits; | 37 | static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits; |
lib/libcxx/include/__random/linear_congruential_engine.h+2-2| ... | @@ -220,7 +220,7 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(-1), __mode> { | ... | @@ -220,7 +220,7 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(-1), __mode> { |
| 220 | }; | 220 | }; |
| 221 | 221 | ||
| 222 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | 222 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> |
| 223 | class _LIBCPP_TEMPLATE_VIS linear_congruential_engine; | 223 | class linear_congruential_engine; |
| 224 | 224 | ||
| 225 | template <class _CharT, class _Traits, class _Up, _Up _Ap, _Up _Cp, _Up _Np> | 225 | template <class _CharT, class _Traits, class _Up, _Up _Ap, _Up _Cp, _Up _Np> |
| 226 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | 226 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| ... | @@ -231,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& | ... | @@ -231,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| 231 | operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); | 231 | operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); |
| 232 | 232 | ||
| 233 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | 233 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> |
| 234 | class _LIBCPP_TEMPLATE_VIS linear_congruential_engine { | 234 | class linear_congruential_engine { |
| 235 | public: | 235 | public: |
| 236 | // types | 236 | // types |
| 237 | typedef _UIntType result_type; | 237 | typedef _UIntType result_type; |
lib/libcxx/include/__random/lognormal_distribution.h+2-2| ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | template <class _RealType = double> | 28 | template <class _RealType = double> |
| 29 | class _LIBCPP_TEMPLATE_VIS lognormal_distribution { | 29 | class lognormal_distribution { |
| 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 31 | "RealType must be a supported floating-point type"); | 31 | "RealType must be a supported floating-point type"); |
| 32 | 32 | ||
| ... | @@ -34,7 +34,7 @@ public: | ... | @@ -34,7 +34,7 @@ public: |
| 34 | // types | 34 | // types |
| 35 | typedef _RealType result_type; | 35 | typedef _RealType result_type; |
| 36 | 36 | ||
| 37 | class _LIBCPP_TEMPLATE_VIS param_type { | 37 | class param_type { |
| 38 | result_type __m_; | 38 | result_type __m_; |
| 39 | result_type __s_; | 39 | result_type __s_; |
| 40 | 40 |
lib/libcxx/include/__random/mersenne_twister_engine.h+2-2| ... | @@ -42,7 +42,7 @@ template <class _UIntType, | ... | @@ -42,7 +42,7 @@ template <class _UIntType, |
| 42 | _UIntType __c, | 42 | _UIntType __c, |
| 43 | size_t __l, | 43 | size_t __l, |
| 44 | _UIntType __f> | 44 | _UIntType __f> |
| 45 | class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine; | 45 | class mersenne_twister_engine; |
| 46 | 46 | ||
| 47 | template <class _UInt, | 47 | template <class _UInt, |
| 48 | size_t _Wp, | 48 | size_t _Wp, |
| ... | @@ -134,7 +134,7 @@ template <class _UIntType, | ... | @@ -134,7 +134,7 @@ template <class _UIntType, |
| 134 | _UIntType __c, | 134 | _UIntType __c, |
| 135 | size_t __l, | 135 | size_t __l, |
| 136 | _UIntType __f> | 136 | _UIntType __f> |
| 137 | class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine { | 137 | class mersenne_twister_engine { |
| 138 | public: | 138 | public: |
| 139 | // types | 139 | // types |
| 140 | typedef _UIntType result_type; | 140 | typedef _UIntType result_type; |
lib/libcxx/include/__random/negative_binomial_distribution.h+2-2| ... | @@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS | ... | @@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS |
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | ||
| 30 | template <class _IntType = int> | 30 | template <class _IntType = int> |
| 31 | class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution { | 31 | class negative_binomial_distribution { |
| 32 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | 32 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); |
| 33 | 33 | ||
| 34 | public: | 34 | public: |
| 35 | // types | 35 | // types |
| 36 | typedef _IntType result_type; | 36 | typedef _IntType result_type; |
| 37 | 37 | ||
| 38 | class _LIBCPP_TEMPLATE_VIS param_type { | 38 | class param_type { |
| 39 | result_type __k_; | 39 | result_type __k_; |
| 40 | double __p_; | 40 | double __p_; |
| 41 | 41 |
lib/libcxx/include/__random/normal_distribution.h+2-2| ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | template <class _RealType = double> | 28 | template <class _RealType = double> |
| 29 | class _LIBCPP_TEMPLATE_VIS normal_distribution { | 29 | class normal_distribution { |
| 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 31 | "RealType must be a supported floating-point type"); | 31 | "RealType must be a supported floating-point type"); |
| 32 | 32 | ||
| ... | @@ -34,7 +34,7 @@ public: | ... | @@ -34,7 +34,7 @@ public: |
| 34 | // types | 34 | // types |
| 35 | typedef _RealType result_type; | 35 | typedef _RealType result_type; |
| 36 | 36 | ||
| 37 | class _LIBCPP_TEMPLATE_VIS param_type { | 37 | class param_type { |
| 38 | result_type __mean_; | 38 | result_type __mean_; |
| 39 | result_type __stddev_; | 39 | result_type __stddev_; |
| 40 | 40 |
lib/libcxx/include/__random/piecewise_constant_distribution.h+2-2| ... | @@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS |
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | ||
| 31 | template <class _RealType = double> | 31 | template <class _RealType = double> |
| 32 | class _LIBCPP_TEMPLATE_VIS piecewise_constant_distribution { | 32 | class piecewise_constant_distribution { |
| 33 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 33 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 34 | "RealType must be a supported floating-point type"); | 34 | "RealType must be a supported floating-point type"); |
| 35 | 35 | ||
| ... | @@ -37,7 +37,7 @@ public: | ... | @@ -37,7 +37,7 @@ public: |
| 37 | // types | 37 | // types |
| 38 | typedef _RealType result_type; | 38 | typedef _RealType result_type; |
| 39 | 39 | ||
| 40 | class _LIBCPP_TEMPLATE_VIS param_type { | 40 | class param_type { |
| 41 | vector<result_type> __b_; | 41 | vector<result_type> __b_; |
| 42 | vector<result_type> __densities_; | 42 | vector<result_type> __densities_; |
| 43 | vector<result_type> __areas_; | 43 | vector<result_type> __areas_; |
lib/libcxx/include/__random/piecewise_linear_distribution.h+2-2| ... | @@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS |
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | ||
| 32 | template <class _RealType = double> | 32 | template <class _RealType = double> |
| 33 | class _LIBCPP_TEMPLATE_VIS piecewise_linear_distribution { | 33 | class piecewise_linear_distribution { |
| 34 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 34 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 35 | "RealType must be a supported floating-point type"); | 35 | "RealType must be a supported floating-point type"); |
| 36 | 36 | ||
| ... | @@ -38,7 +38,7 @@ public: | ... | @@ -38,7 +38,7 @@ public: |
| 38 | // types | 38 | // types |
| 39 | typedef _RealType result_type; | 39 | typedef _RealType result_type; |
| 40 | 40 | ||
| 41 | class _LIBCPP_TEMPLATE_VIS param_type { | 41 | class param_type { |
| 42 | vector<result_type> __b_; | 42 | vector<result_type> __b_; |
| 43 | vector<result_type> __densities_; | 43 | vector<result_type> __densities_; |
| 44 | vector<result_type> __areas_; | 44 | vector<result_type> __areas_; |
lib/libcxx/include/__random/poisson_distribution.h+2-2| ... | @@ -29,14 +29,14 @@ _LIBCPP_PUSH_MACROS | ... | @@ -29,14 +29,14 @@ _LIBCPP_PUSH_MACROS |
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | ||
| 31 | template <class _IntType = int> | 31 | template <class _IntType = int> |
| 32 | class _LIBCPP_TEMPLATE_VIS poisson_distribution { | 32 | class poisson_distribution { |
| 33 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | 33 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); |
| 34 | 34 | ||
| 35 | public: | 35 | public: |
| 36 | // types | 36 | // types |
| 37 | typedef _IntType result_type; | 37 | typedef _IntType result_type; |
| 38 | 38 | ||
| 39 | class _LIBCPP_TEMPLATE_VIS param_type { | 39 | class param_type { |
| 40 | double __mean_; | 40 | double __mean_; |
| 41 | double __s_; | 41 | double __s_; |
| 42 | double __d_; | 42 | double __d_; |
lib/libcxx/include/__random/seed_seq.h+1-1| ... | @@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS |
| 30 | 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | ||
| 33 | class _LIBCPP_TEMPLATE_VIS seed_seq { | 33 | class seed_seq { |
| 34 | public: | 34 | public: |
| 35 | // types | 35 | // types |
| 36 | typedef uint32_t result_type; | 36 | typedef uint32_t result_type; |
lib/libcxx/include/__random/shuffle_order_engine.h+1-1| ... | @@ -52,7 +52,7 @@ public: | ... | @@ -52,7 +52,7 @@ public: |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | template <class _Engine, size_t __k> | 54 | template <class _Engine, size_t __k> |
| 55 | class _LIBCPP_TEMPLATE_VIS shuffle_order_engine { | 55 | class shuffle_order_engine { |
| 56 | static_assert(0 < __k, "shuffle_order_engine invalid parameters"); | 56 | static_assert(0 < __k, "shuffle_order_engine invalid parameters"); |
| 57 | 57 | ||
| 58 | public: | 58 | public: |
lib/libcxx/include/__random/student_t_distribution.h+2-2| ... | @@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS |
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | ||
| 29 | template <class _RealType = double> | 29 | template <class _RealType = double> |
| 30 | class _LIBCPP_TEMPLATE_VIS student_t_distribution { | 30 | class student_t_distribution { |
| 31 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 31 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 32 | "RealType must be a supported floating-point type"); | 32 | "RealType must be a supported floating-point type"); |
| 33 | 33 | ||
| ... | @@ -35,7 +35,7 @@ public: | ... | @@ -35,7 +35,7 @@ public: |
| 35 | // types | 35 | // types |
| 36 | typedef _RealType result_type; | 36 | typedef _RealType result_type; |
| 37 | 37 | ||
| 38 | class _LIBCPP_TEMPLATE_VIS param_type { | 38 | class param_type { |
| 39 | result_type __n_; | 39 | result_type __n_; |
| 40 | 40 | ||
| 41 | public: | 41 | public: |
lib/libcxx/include/__random/subtract_with_carry_engine.h+2-2| ... | @@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS |
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | ||
| 32 | template <class _UIntType, size_t __w, size_t __s, size_t __r> | 32 | template <class _UIntType, size_t __w, size_t __s, size_t __r> |
| 33 | class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine; | 33 | class subtract_with_carry_engine; |
| 34 | 34 | ||
| 35 | template <class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | 35 | template <class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> |
| 36 | _LIBCPP_HIDE_FROM_ABI bool operator==(const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | 36 | _LIBCPP_HIDE_FROM_ABI bool operator==(const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, |
| ... | @@ -49,7 +49,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& | ... | @@ -49,7 +49,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| 49 | operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | 49 | operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); |
| 50 | 50 | ||
| 51 | template <class _UIntType, size_t __w, size_t __s, size_t __r> | 51 | template <class _UIntType, size_t __w, size_t __s, size_t __r> |
| 52 | class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine { | 52 | class subtract_with_carry_engine { |
| 53 | public: | 53 | public: |
| 54 | // types | 54 | // types |
| 55 | typedef _UIntType result_type; | 55 | typedef _UIntType result_type; |
lib/libcxx/include/__random/uniform_real_distribution.h+2-2| ... | @@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _RealType = double> | 27 | template <class _RealType = double> |
| 28 | class _LIBCPP_TEMPLATE_VIS uniform_real_distribution { | 28 | class uniform_real_distribution { |
| 29 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 29 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 30 | "RealType must be a supported floating-point type"); | 30 | "RealType must be a supported floating-point type"); |
| 31 | 31 | ||
| ... | @@ -33,7 +33,7 @@ public: | ... | @@ -33,7 +33,7 @@ public: |
| 33 | // types | 33 | // types |
| 34 | typedef _RealType result_type; | 34 | typedef _RealType result_type; |
| 35 | 35 | ||
| 36 | class _LIBCPP_TEMPLATE_VIS param_type { | 36 | class param_type { |
| 37 | result_type __a_; | 37 | result_type __a_; |
| 38 | result_type __b_; | 38 | result_type __b_; |
| 39 | 39 |
lib/libcxx/include/__random/weibull_distribution.h+2-2| ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | template <class _RealType = double> | 28 | template <class _RealType = double> |
| 29 | class _LIBCPP_TEMPLATE_VIS weibull_distribution { | 29 | class weibull_distribution { |
| 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, | 30 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value, |
| 31 | "RealType must be a supported floating-point type"); | 31 | "RealType must be a supported floating-point type"); |
| 32 | 32 | ||
| ... | @@ -34,7 +34,7 @@ public: | ... | @@ -34,7 +34,7 @@ public: |
| 34 | // types | 34 | // types |
| 35 | typedef _RealType result_type; | 35 | typedef _RealType result_type; |
| 36 | 36 | ||
| 37 | class _LIBCPP_TEMPLATE_VIS param_type { | 37 | class param_type { |
| 38 | result_type __a_; | 38 | result_type __a_; |
| 39 | result_type __b_; | 39 | result_type __b_; |
| 40 | 40 |
lib/libcxx/include/__ranges/concepts.h+40| ... | @@ -10,7 +10,9 @@ | ... | @@ -10,7 +10,9 @@ |
| 10 | #ifndef _LIBCPP___RANGES_CONCEPTS_H | 10 | #ifndef _LIBCPP___RANGES_CONCEPTS_H |
| 11 | #define _LIBCPP___RANGES_CONCEPTS_H | 11 | #define _LIBCPP___RANGES_CONCEPTS_H |
| 12 | 12 | ||
| 13 | #include <__concepts/common_reference_with.h> | ||
| 13 | #include <__concepts/constructible.h> | 14 | #include <__concepts/constructible.h> |
| 15 | #include <__concepts/convertible_to.h> | ||
| 14 | #include <__concepts/movable.h> | 16 | #include <__concepts/movable.h> |
| 15 | #include <__concepts/same_as.h> | 17 | #include <__concepts/same_as.h> |
| 16 | #include <__config> | 18 | #include <__config> |
| ... | @@ -25,6 +27,8 @@ | ... | @@ -25,6 +27,8 @@ |
| 25 | #include <__ranges/enable_view.h> | 27 | #include <__ranges/enable_view.h> |
| 26 | #include <__ranges/size.h> | 28 | #include <__ranges/size.h> |
| 27 | #include <__type_traits/add_pointer.h> | 29 | #include <__type_traits/add_pointer.h> |
| 30 | #include <__type_traits/common_reference.h> | ||
| 31 | #include <__type_traits/common_type.h> | ||
| 28 | #include <__type_traits/is_reference.h> | 32 | #include <__type_traits/is_reference.h> |
| 29 | #include <__type_traits/remove_cvref.h> | 33 | #include <__type_traits/remove_cvref.h> |
| 30 | #include <__type_traits/remove_reference.h> | 34 | #include <__type_traits/remove_reference.h> |
| ... | @@ -133,6 +137,42 @@ concept viewable_range = | ... | @@ -133,6 +137,42 @@ concept viewable_range = |
| 133 | (is_lvalue_reference_v<_Tp> || | 137 | (is_lvalue_reference_v<_Tp> || |
| 134 | (movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>)))); | 138 | (movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>)))); |
| 135 | 139 | ||
| 140 | # if _LIBCPP_STD_VER >= 23 | ||
| 141 | |||
| 142 | template <class... _Rs> | ||
| 143 | using __concat_reference_t _LIBCPP_NODEBUG = common_reference_t<range_reference_t<_Rs>...>; | ||
| 144 | |||
| 145 | template <class... _Rs> | ||
| 146 | using __concat_value_t _LIBCPP_NODEBUG = common_type_t<range_value_t<_Rs>...>; | ||
| 147 | |||
| 148 | template <class... _Rs> | ||
| 149 | using __concat_rvalue_reference_t _LIBCPP_NODEBUG = common_reference_t<range_rvalue_reference_t<_Rs>...>; | ||
| 150 | |||
| 151 | template <class _Ref, class _RRef, class _It> | ||
| 152 | concept __concat_indirectly_readable_impl = requires(const _It __it) { | ||
| 153 | { *__it } -> convertible_to<_Ref>; | ||
| 154 | { ranges::iter_move(__it) } -> convertible_to<_RRef>; | ||
| 155 | }; | ||
| 156 | |||
| 157 | template <class... _Rs> | ||
| 158 | concept __concat_indirectly_readable = | ||
| 159 | common_reference_with<__concat_reference_t<_Rs...>&&, __concat_value_t<_Rs...>&> && | ||
| 160 | common_reference_with<__concat_reference_t<_Rs...>&&, __concat_rvalue_reference_t<_Rs...>&&> && | ||
| 161 | common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, const __concat_value_t<_Rs...>&> && | ||
| 162 | (__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>, | ||
| 163 | __concat_rvalue_reference_t<_Rs...>, | ||
| 164 | iterator_t<_Rs>> && | ||
| 165 | ...); | ||
| 166 | |||
| 167 | template <class... _Rs> | ||
| 168 | concept __concatable = requires { | ||
| 169 | typename __concat_reference_t<_Rs...>; | ||
| 170 | typename __concat_value_t<_Rs...>; | ||
| 171 | typename __concat_rvalue_reference_t<_Rs...>; | ||
| 172 | } && __concat_indirectly_readable<_Rs...>; | ||
| 173 | |||
| 174 | # endif // _LIBCPP_STD_VER >= 23 | ||
| 175 | |||
| 136 | } // namespace ranges | 176 | } // namespace ranges |
| 137 | 177 | ||
| 138 | #endif // _LIBCPP_STD_VER >= 20 | 178 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__ranges/drop_view.h+4-4| ... | @@ -185,22 +185,22 @@ struct __passthrough_type; | ... | @@ -185,22 +185,22 @@ struct __passthrough_type; |
| 185 | 185 | ||
| 186 | template <class _Tp, size_t _Extent> | 186 | template <class _Tp, size_t _Extent> |
| 187 | struct __passthrough_type<span<_Tp, _Extent>> { | 187 | struct __passthrough_type<span<_Tp, _Extent>> { |
| 188 | using type = span<_Tp>; | 188 | using type _LIBCPP_NODEBUG = span<_Tp>; |
| 189 | }; | 189 | }; |
| 190 | 190 | ||
| 191 | template <class _CharT, class _Traits> | 191 | template <class _CharT, class _Traits> |
| 192 | struct __passthrough_type<basic_string_view<_CharT, _Traits>> { | 192 | struct __passthrough_type<basic_string_view<_CharT, _Traits>> { |
| 193 | using type = basic_string_view<_CharT, _Traits>; | 193 | using type _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>; |
| 194 | }; | 194 | }; |
| 195 | 195 | ||
| 196 | template <class _Np, class _Bound> | 196 | template <class _Np, class _Bound> |
| 197 | struct __passthrough_type<iota_view<_Np, _Bound>> { | 197 | struct __passthrough_type<iota_view<_Np, _Bound>> { |
| 198 | using type = iota_view<_Np, _Bound>; | 198 | using type _LIBCPP_NODEBUG = iota_view<_Np, _Bound>; |
| 199 | }; | 199 | }; |
| 200 | 200 | ||
| 201 | template <class _Iter, class _Sent, subrange_kind _Kind> | 201 | template <class _Iter, class _Sent, subrange_kind _Kind> |
| 202 | struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { | 202 | struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { |
| 203 | using type = subrange<_Iter, _Sent, _Kind>; | 203 | using type _LIBCPP_NODEBUG = subrange<_Iter, _Sent, _Kind>; |
| 204 | }; | 204 | }; |
| 205 | 205 | ||
| 206 | template <class _Tp> | 206 | template <class _Tp> |
lib/libcxx/include/__ranges/elements_view.h+1-1| ... | @@ -197,7 +197,7 @@ class elements_view<_View, _Np>::__iterator | ... | @@ -197,7 +197,7 @@ class elements_view<_View, _Np>::__iterator |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | public: | 199 | public: |
| 200 | using iterator_concept = decltype(__get_iterator_concept()); | 200 | using iterator_concept = decltype(__iterator::__get_iterator_concept()); |
| 201 | using value_type = remove_cvref_t<tuple_element_t<_Np, range_value_t<_Base>>>; | 201 | using value_type = remove_cvref_t<tuple_element_t<_Np, range_value_t<_Base>>>; |
| 202 | using difference_type = range_difference_t<_Base>; | 202 | using difference_type = range_difference_t<_Base>; |
| 203 | 203 |
lib/libcxx/include/__ranges/enable_view.h+3-4| ... | @@ -14,7 +14,6 @@ | ... | @@ -14,7 +14,6 @@ |
| 14 | #include <__concepts/same_as.h> | 14 | #include <__concepts/same_as.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__type_traits/is_class.h> | 16 | #include <__type_traits/is_class.h> |
| 17 | #include <__type_traits/is_convertible.h> | ||
| 18 | #include <__type_traits/remove_cv.h> | 17 | #include <__type_traits/remove_cv.h> |
| 19 | 18 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -34,12 +33,12 @@ template <class _Derived> | ... | @@ -34,12 +33,12 @@ template <class _Derived> |
| 34 | class view_interface; | 33 | class view_interface; |
| 35 | 34 | ||
| 36 | template <class _Op, class _Yp> | 35 | template <class _Op, class _Yp> |
| 37 | requires is_convertible_v<_Op*, view_interface<_Yp>*> | 36 | requires(!same_as<_Op, view_interface<_Yp>>) |
| 38 | void __is_derived_from_view_interface(const _Op*, const view_interface<_Yp>*); | 37 | void __is_derived_from_view_interface(view_interface<_Yp>*); |
| 39 | 38 | ||
| 40 | template <class _Tp> | 39 | template <class _Tp> |
| 41 | inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires { | 40 | inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires { |
| 42 | ranges::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr); | 41 | ranges::__is_derived_from_view_interface<remove_cv_t<_Tp>>((remove_cv_t<_Tp>*)nullptr); |
| 43 | }; | 42 | }; |
| 44 | 43 | ||
| 45 | } // namespace ranges | 44 | } // namespace ranges |
lib/libcxx/include/__ranges/join_with_view.h created+460| ... | @@ -0,0 +1,460 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___RANGES_JOIN_WITH_VIEW_H | ||
| 11 | #define _LIBCPP___RANGES_JOIN_WITH_VIEW_H | ||
| 12 | |||
| 13 | #include <__concepts/common_reference_with.h> | ||
| 14 | #include <__concepts/common_with.h> | ||
| 15 | #include <__concepts/constructible.h> | ||
| 16 | #include <__concepts/convertible_to.h> | ||
| 17 | #include <__concepts/derived_from.h> | ||
| 18 | #include <__concepts/equality_comparable.h> | ||
| 19 | #include <__config> | ||
| 20 | #include <__functional/bind_back.h> | ||
| 21 | #include <__iterator/concepts.h> | ||
| 22 | #include <__iterator/incrementable_traits.h> | ||
| 23 | #include <__iterator/iter_move.h> | ||
| 24 | #include <__iterator/iter_swap.h> | ||
| 25 | #include <__iterator/iterator_traits.h> | ||
| 26 | #include <__memory/addressof.h> | ||
| 27 | #include <__ranges/access.h> | ||
| 28 | #include <__ranges/all.h> | ||
| 29 | #include <__ranges/concepts.h> | ||
| 30 | #include <__ranges/non_propagating_cache.h> | ||
| 31 | #include <__ranges/range_adaptor.h> | ||
| 32 | #include <__ranges/single_view.h> | ||
| 33 | #include <__ranges/view_interface.h> | ||
| 34 | #include <__type_traits/conditional.h> | ||
| 35 | #include <__type_traits/decay.h> | ||
| 36 | #include <__type_traits/is_reference.h> | ||
| 37 | #include <__type_traits/maybe_const.h> | ||
| 38 | #include <__utility/as_const.h> | ||
| 39 | #include <__utility/as_lvalue.h> | ||
| 40 | #include <__utility/empty.h> | ||
| 41 | #include <__utility/forward.h> | ||
| 42 | #include <__utility/move.h> | ||
| 43 | #include <variant> | ||
| 44 | |||
| 45 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 46 | # pragma GCC system_header | ||
| 47 | #endif | ||
| 48 | |||
| 49 | _LIBCPP_PUSH_MACROS | ||
| 50 | #include <__undef_macros> | ||
| 51 | |||
| 52 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 53 | |||
| 54 | #if _LIBCPP_STD_VER >= 23 | ||
| 55 | |||
| 56 | namespace ranges { | ||
| 57 | template <class _Range> | ||
| 58 | concept __bidirectional_common = bidirectional_range<_Range> && common_range<_Range>; | ||
| 59 | |||
| 60 | template <input_range _View, forward_range _Pattern> | ||
| 61 | requires view<_View> && input_range<range_reference_t<_View>> && view<_Pattern> && | ||
| 62 | __concatable<range_reference_t<_View>, _Pattern> | ||
| 63 | class join_with_view : public view_interface<join_with_view<_View, _Pattern>> { | ||
| 64 | using _InnerRng _LIBCPP_NODEBUG = range_reference_t<_View>; | ||
| 65 | |||
| 66 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | ||
| 67 | |||
| 68 | static constexpr bool _UseOuterItCache = !forward_range<_View>; | ||
| 69 | using _OuterItCache _LIBCPP_NODEBUG = | ||
| 70 | _If<_UseOuterItCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | ||
| 71 | _LIBCPP_NO_UNIQUE_ADDRESS _OuterItCache __outer_it_; | ||
| 72 | |||
| 73 | static constexpr bool _UseInnerCache = !is_reference_v<_InnerRng>; | ||
| 74 | using _InnerCache _LIBCPP_NODEBUG = | ||
| 75 | _If<_UseInnerCache, __non_propagating_cache<remove_cvref_t<_InnerRng>>, __empty_cache>; | ||
| 76 | _LIBCPP_NO_UNIQUE_ADDRESS _InnerCache __inner_; | ||
| 77 | |||
| 78 | _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern(); | ||
| 79 | |||
| 80 | template <bool _Const> | ||
| 81 | struct __iterator; | ||
| 82 | |||
| 83 | template <bool _Const> | ||
| 84 | struct __sentinel; | ||
| 85 | |||
| 86 | public: | ||
| 87 | _LIBCPP_HIDE_FROM_ABI join_with_view() | ||
| 88 | requires default_initializable<_View> && default_initializable<_Pattern> | ||
| 89 | = default; | ||
| 90 | |||
| 91 | _LIBCPP_HIDE_FROM_ABI constexpr explicit join_with_view(_View __base, _Pattern __pattern) | ||
| 92 | : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {} | ||
| 93 | |||
| 94 | template <input_range _Range> | ||
| 95 | requires constructible_from<_View, views::all_t<_Range>> && | ||
| 96 | constructible_from<_Pattern, single_view<range_value_t<_InnerRng>>> | ||
| 97 | _LIBCPP_HIDE_FROM_ABI constexpr explicit join_with_view(_Range&& __r, range_value_t<_InnerRng> __e) | ||
| 98 | : __base_(views::all(std::forward<_Range>(__r))), __pattern_(views::single(std::move(__e))) {} | ||
| 99 | |||
| 100 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& | ||
| 101 | requires copy_constructible<_View> | ||
| 102 | { | ||
| 103 | return __base_; | ||
| 104 | } | ||
| 105 | |||
| 106 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | ||
| 107 | |||
| 108 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { | ||
| 109 | if constexpr (forward_range<_View>) { | ||
| 110 | constexpr bool __use_const = __simple_view<_View> && is_reference_v<_InnerRng> && __simple_view<_Pattern>; | ||
| 111 | return __iterator<__use_const>{*this, ranges::begin(__base_)}; | ||
| 112 | } else { | ||
| 113 | __outer_it_.__emplace(ranges::begin(__base_)); | ||
| 114 | return __iterator<false>{*this}; | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const | ||
| 119 | requires forward_range<const _View> && forward_range<const _Pattern> && | ||
| 120 | is_reference_v<range_reference_t<const _View>> && input_range<range_reference_t<const _View>> && | ||
| 121 | __concatable<range_reference_t<const _View>, const _Pattern> | ||
| 122 | { | ||
| 123 | return __iterator<true>{*this, ranges::begin(__base_)}; | ||
| 124 | } | ||
| 125 | |||
| 126 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() { | ||
| 127 | constexpr bool __use_const = __simple_view<_View> && __simple_view<_Pattern>; | ||
| 128 | if constexpr (forward_range<_View> && is_reference_v<_InnerRng> && forward_range<_InnerRng> && | ||
| 129 | common_range<_View> && common_range<_InnerRng>) | ||
| 130 | return __iterator<__use_const>{*this, ranges::end(__base_)}; | ||
| 131 | else | ||
| 132 | return __sentinel<__use_const>{*this}; | ||
| 133 | } | ||
| 134 | |||
| 135 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const | ||
| 136 | requires forward_range<const _View> && forward_range<const _Pattern> && | ||
| 137 | is_reference_v<range_reference_t<const _View>> && input_range<range_reference_t<const _View>> && | ||
| 138 | __concatable<range_reference_t<const _View>, const _Pattern> | ||
| 139 | { | ||
| 140 | using _InnerConstRng = range_reference_t<const _View>; | ||
| 141 | if constexpr (forward_range<_InnerConstRng> && common_range<const _View> && common_range<_InnerConstRng>) | ||
| 142 | return __iterator<true>{*this, ranges::end(__base_)}; | ||
| 143 | else | ||
| 144 | return __sentinel<true>{*this}; | ||
| 145 | } | ||
| 146 | }; | ||
| 147 | |||
| 148 | template <class _Range, class _Pattern> | ||
| 149 | join_with_view(_Range&&, _Pattern&&) -> join_with_view<views::all_t<_Range>, views::all_t<_Pattern>>; | ||
| 150 | |||
| 151 | template <input_range _Range> | ||
| 152 | join_with_view(_Range&&, range_value_t<range_reference_t<_Range>>) | ||
| 153 | -> join_with_view<views::all_t<_Range>, single_view<range_value_t<range_reference_t<_Range>>>>; | ||
| 154 | |||
| 155 | template <class _Base, class _PatternBase, class _InnerBase = range_reference_t<_Base>> | ||
| 156 | struct __join_with_view_iterator_category {}; | ||
| 157 | |||
| 158 | template <class _Base, class _PatternBase, class _InnerBase> | ||
| 159 | requires is_reference_v<_InnerBase> && forward_range<_Base> && forward_range<_InnerBase> | ||
| 160 | struct __join_with_view_iterator_category<_Base, _PatternBase, _InnerBase> { | ||
| 161 | private: | ||
| 162 | static consteval auto __get_iterator_category() noexcept { | ||
| 163 | using _OuterC = iterator_traits<iterator_t<_Base>>::iterator_category; | ||
| 164 | using _InnerC = iterator_traits<iterator_t<_InnerBase>>::iterator_category; | ||
| 165 | using _PatternC = iterator_traits<iterator_t<_PatternBase>>::iterator_category; | ||
| 166 | |||
| 167 | if constexpr (!is_reference_v<common_reference_t<iter_reference_t<iterator_t<_InnerBase>>, | ||
| 168 | iter_reference_t<iterator_t<_PatternBase>>>>) | ||
| 169 | return input_iterator_tag{}; | ||
| 170 | else if constexpr (derived_from<_OuterC, bidirectional_iterator_tag> && | ||
| 171 | derived_from<_InnerC, bidirectional_iterator_tag> && | ||
| 172 | derived_from<_PatternC, bidirectional_iterator_tag> && common_range<_InnerBase> && | ||
| 173 | common_range<_PatternBase>) | ||
| 174 | return bidirectional_iterator_tag{}; | ||
| 175 | else if constexpr (derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag> && | ||
| 176 | derived_from<_PatternC, forward_iterator_tag>) | ||
| 177 | return forward_iterator_tag{}; | ||
| 178 | else | ||
| 179 | return input_iterator_tag{}; | ||
| 180 | } | ||
| 181 | |||
| 182 | public: | ||
| 183 | using iterator_category = decltype(__get_iterator_category()); | ||
| 184 | }; | ||
| 185 | |||
| 186 | template <input_range _View, forward_range _Pattern> | ||
| 187 | requires view<_View> && input_range<range_reference_t<_View>> && view<_Pattern> && | ||
| 188 | __concatable<range_reference_t<_View>, _Pattern> | ||
| 189 | template <bool _Const> | ||
| 190 | struct join_with_view<_View, _Pattern>::__iterator | ||
| 191 | : public __join_with_view_iterator_category<__maybe_const<_Const, _View>, __maybe_const<_Const, _Pattern>> { | ||
| 192 | private: | ||
| 193 | friend join_with_view; | ||
| 194 | |||
| 195 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_with_view>; | ||
| 196 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | ||
| 197 | using _InnerBase _LIBCPP_NODEBUG = range_reference_t<_Base>; | ||
| 198 | using _PatternBase _LIBCPP_NODEBUG = __maybe_const<_Const, _Pattern>; | ||
| 199 | |||
| 200 | using _OuterIter _LIBCPP_NODEBUG = iterator_t<_Base>; | ||
| 201 | using _InnerIter _LIBCPP_NODEBUG = iterator_t<_InnerBase>; | ||
| 202 | using _PatternIter _LIBCPP_NODEBUG = iterator_t<_PatternBase>; | ||
| 203 | |||
| 204 | static_assert(!_Const || forward_range<_Base>, "Const can only be true when Base models forward_range."); | ||
| 205 | |||
| 206 | static constexpr bool __ref_is_glvalue = is_reference_v<_InnerBase>; | ||
| 207 | |||
| 208 | _Parent* __parent_ = nullptr; | ||
| 209 | |||
| 210 | static constexpr bool _OuterIterPresent = forward_range<_Base>; | ||
| 211 | using _OuterIterType _LIBCPP_NODEBUG = _If<_OuterIterPresent, _OuterIter, std::__empty>; | ||
| 212 | _LIBCPP_NO_UNIQUE_ADDRESS _OuterIterType __outer_it_ = _OuterIterType(); | ||
| 213 | |||
| 214 | variant<_PatternIter, _InnerIter> __inner_it_; | ||
| 215 | |||
| 216 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(_Parent& __parent, _OuterIter __outer) | ||
| 217 | requires forward_range<_Base> | ||
| 218 | : __parent_(std::addressof(__parent)), __outer_it_(std::move(__outer)) { | ||
| 219 | if (__get_outer() != ranges::end(__parent_->__base_)) { | ||
| 220 | __inner_it_.template emplace<1>(ranges::begin(__update_inner())); | ||
| 221 | __satisfy(); | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(_Parent& __parent) | ||
| 226 | requires(!forward_range<_Base>) | ||
| 227 | : __parent_(std::addressof(__parent)) { | ||
| 228 | if (__get_outer() != ranges::end(__parent_->__base_)) { | ||
| 229 | __inner_it_.template emplace<1>(ranges::begin(__update_inner())); | ||
| 230 | __satisfy(); | ||
| 231 | } | ||
| 232 | } | ||
| 233 | |||
| 234 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _OuterIter& __get_outer() { | ||
| 235 | if constexpr (forward_range<_Base>) | ||
| 236 | return __outer_it_; | ||
| 237 | else | ||
| 238 | return *__parent_->__outer_it_; | ||
| 239 | } | ||
| 240 | |||
| 241 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _OuterIter& __get_outer() const { | ||
| 242 | if constexpr (forward_range<_Base>) | ||
| 243 | return __outer_it_; | ||
| 244 | else | ||
| 245 | return *__parent_->__outer_it_; | ||
| 246 | } | ||
| 247 | |||
| 248 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __update_inner() { | ||
| 249 | if constexpr (__ref_is_glvalue) | ||
| 250 | return std::__as_lvalue(*__get_outer()); | ||
| 251 | else | ||
| 252 | return __parent_->__inner_.__emplace_from([this]() -> decltype(auto) { return *__get_outer(); }); | ||
| 253 | } | ||
| 254 | |||
| 255 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __get_inner() { | ||
| 256 | if constexpr (__ref_is_glvalue) | ||
| 257 | return std::__as_lvalue(*__get_outer()); | ||
| 258 | else | ||
| 259 | return *__parent_->__inner_; | ||
| 260 | } | ||
| 261 | |||
| 262 | _LIBCPP_HIDE_FROM_ABI constexpr void __satisfy() { | ||
| 263 | while (true) { | ||
| 264 | if (__inner_it_.index() == 0) { | ||
| 265 | if (std::get<0>(__inner_it_) != ranges::end(__parent_->__pattern_)) | ||
| 266 | break; | ||
| 267 | |||
| 268 | __inner_it_.template emplace<1>(ranges::begin(__update_inner())); | ||
| 269 | } else { | ||
| 270 | if (std::get<1>(__inner_it_) != ranges::end(__get_inner())) | ||
| 271 | break; | ||
| 272 | |||
| 273 | if (++__get_outer() == ranges::end(__parent_->__base_)) { | ||
| 274 | if constexpr (__ref_is_glvalue) | ||
| 275 | __inner_it_.template emplace<0>(); | ||
| 276 | |||
| 277 | break; | ||
| 278 | } | ||
| 279 | |||
| 280 | __inner_it_.template emplace<0>(ranges::begin(__parent_->__pattern_)); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | [[nodiscard]] static consteval auto __get_iterator_concept() noexcept { | ||
| 286 | if constexpr (__ref_is_glvalue && bidirectional_range<_Base> && __bidirectional_common<_InnerBase> && | ||
| 287 | __bidirectional_common<_PatternBase>) | ||
| 288 | return bidirectional_iterator_tag{}; | ||
| 289 | else if constexpr (__ref_is_glvalue && forward_range<_Base> && forward_range<_InnerBase>) | ||
| 290 | return forward_iterator_tag{}; | ||
| 291 | else | ||
| 292 | return input_iterator_tag{}; | ||
| 293 | } | ||
| 294 | |||
| 295 | public: | ||
| 296 | using iterator_concept = decltype(__get_iterator_concept()); | ||
| 297 | using value_type = common_type_t<iter_value_t<_InnerIter>, iter_value_t<_PatternIter>>; | ||
| 298 | using difference_type = | ||
| 299 | common_type_t<iter_difference_t<_OuterIter>, iter_difference_t<_InnerIter>, iter_difference_t<_PatternIter>>; | ||
| 300 | |||
| 301 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; | ||
| 302 | |||
| 303 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i) | ||
| 304 | requires _Const && convertible_to<iterator_t<_View>, _OuterIter> && | ||
| 305 | convertible_to<iterator_t<_InnerRng>, _InnerIter> && convertible_to<iterator_t<_Pattern>, _PatternIter> | ||
| 306 | : __parent_(__i.__parent_), __outer_it_(std::move(__i.__outer_it_)) { | ||
| 307 | if (__i.__inner_it_.index() == 0) { | ||
| 308 | __inner_it_.template emplace<0>(std::get<0>(std::move(__i.__inner_it_))); | ||
| 309 | } else { | ||
| 310 | __inner_it_.template emplace<1>(std::get<1>(std::move(__i.__inner_it_))); | ||
| 311 | } | ||
| 312 | } | ||
| 313 | |||
| 314 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { | ||
| 315 | using __reference = common_reference_t<iter_reference_t<_InnerIter>, iter_reference_t<_PatternIter>>; | ||
| 316 | return std::visit([](auto& __it) -> __reference { return *__it; }, __inner_it_); | ||
| 317 | } | ||
| 318 | |||
| 319 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { | ||
| 320 | std::visit([](auto& __it) { ++__it; }, __inner_it_); | ||
| 321 | __satisfy(); | ||
| 322 | return *this; | ||
| 323 | } | ||
| 324 | |||
| 325 | _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { ++*this; } | ||
| 326 | |||
| 327 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) | ||
| 328 | requires __ref_is_glvalue && forward_iterator<_OuterIter> && forward_iterator<_InnerIter> | ||
| 329 | { | ||
| 330 | __iterator __tmp = *this; | ||
| 331 | ++*this; | ||
| 332 | return __tmp; | ||
| 333 | } | ||
| 334 | |||
| 335 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() | ||
| 336 | requires __ref_is_glvalue | ||
| 337 | && bidirectional_range<_Base> && __bidirectional_common<_InnerBase> && __bidirectional_common<_PatternBase> | ||
| 338 | { | ||
| 339 | if (__outer_it_ == ranges::end(__parent_->__base_)) { | ||
| 340 | auto&& __inner = *--__outer_it_; | ||
| 341 | __inner_it_.template emplace<1>(ranges::end(__inner)); | ||
| 342 | } | ||
| 343 | |||
| 344 | while (true) { | ||
| 345 | if (__inner_it_.index() == 0) { | ||
| 346 | auto& __it = std::get<0>(__inner_it_); | ||
| 347 | if (__it == ranges::begin(__parent_->__pattern_)) { | ||
| 348 | auto&& __inner = *--__outer_it_; | ||
| 349 | __inner_it_.template emplace<1>(ranges::end(__inner)); | ||
| 350 | } else | ||
| 351 | break; | ||
| 352 | } else { | ||
| 353 | auto& __it = std::get<1>(__inner_it_); | ||
| 354 | auto&& __inner = *__outer_it_; | ||
| 355 | if (__it == ranges::begin(__inner)) | ||
| 356 | __inner_it_.template emplace<0>(ranges::end(__parent_->__pattern_)); | ||
| 357 | else | ||
| 358 | break; | ||
| 359 | } | ||
| 360 | } | ||
| 361 | |||
| 362 | std::visit([](auto& __it) { --__it; }, __inner_it_); | ||
| 363 | return *this; | ||
| 364 | } | ||
| 365 | |||
| 366 | _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int) | ||
| 367 | requires __ref_is_glvalue | ||
| 368 | && bidirectional_range<_Base> && __bidirectional_common<_InnerBase> && __bidirectional_common<_PatternBase> | ||
| 369 | { | ||
| 370 | __iterator __tmp = *this; | ||
| 371 | --*this; | ||
| 372 | return __tmp; | ||
| 373 | } | ||
| 374 | |||
| 375 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) | ||
| 376 | requires __ref_is_glvalue && forward_range<_Base> && equality_comparable<_InnerIter> | ||
| 377 | { | ||
| 378 | return __x.__outer_it_ == __y.__outer_it_ && __x.__inner_it_ == __y.__inner_it_; | ||
| 379 | } | ||
| 380 | |||
| 381 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __x) { | ||
| 382 | using __rvalue_reference = | ||
| 383 | common_reference_t<iter_rvalue_reference_t<_InnerIter>, iter_rvalue_reference_t<_PatternIter>>; | ||
| 384 | return std::visit<__rvalue_reference>(ranges::iter_move, __x.__inner_it_); | ||
| 385 | } | ||
| 386 | |||
| 387 | _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __x, const __iterator& __y) | ||
| 388 | requires indirectly_swappable<_InnerIter, _PatternIter> | ||
| 389 | { | ||
| 390 | std::visit(ranges::iter_swap, __x.__inner_it_, __y.__inner_it_); | ||
| 391 | } | ||
| 392 | }; | ||
| 393 | |||
| 394 | template <input_range _View, forward_range _Pattern> | ||
| 395 | requires view<_View> && input_range<range_reference_t<_View>> && view<_Pattern> && | ||
| 396 | __concatable<range_reference_t<_View>, _Pattern> | ||
| 397 | template <bool _Const> | ||
| 398 | struct join_with_view<_View, _Pattern>::__sentinel { | ||
| 399 | private: | ||
| 400 | friend join_with_view; | ||
| 401 | |||
| 402 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_with_view>; | ||
| 403 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | ||
| 404 | |||
| 405 | _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>(); | ||
| 406 | |||
| 407 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(_Parent& __parent) : __end_(ranges::end(__parent.__base_)) {} | ||
| 408 | |||
| 409 | template <bool _OtherConst> | ||
| 410 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto& __get_outer_of(const __iterator<_OtherConst>& __x) { | ||
| 411 | return __x.__get_outer(); | ||
| 412 | } | ||
| 413 | |||
| 414 | public: | ||
| 415 | _LIBCPP_HIDE_FROM_ABI __sentinel() = default; | ||
| 416 | |||
| 417 | _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __s) | ||
| 418 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> | ||
| 419 | : __end_(std::move(__s.__end_)) {} | ||
| 420 | |||
| 421 | template <bool _OtherConst> | ||
| 422 | requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> | ||
| 423 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool | ||
| 424 | operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | ||
| 425 | return __get_outer_of(__x) == __y.__end_; | ||
| 426 | } | ||
| 427 | }; | ||
| 428 | |||
| 429 | namespace views { | ||
| 430 | namespace __join_with_view { | ||
| 431 | struct __fn { | ||
| 432 | template <class _Range, class _Pattern> | ||
| 433 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const | ||
| 434 | noexcept(noexcept(/**/ join_with_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))) | ||
| 435 | -> decltype(/*--*/ join_with_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) { | ||
| 436 | return /*-------------*/ join_with_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); | ||
| 437 | } | ||
| 438 | |||
| 439 | template <class _Pattern> | ||
| 440 | requires constructible_from<decay_t<_Pattern>, _Pattern> | ||
| 441 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const | ||
| 442 | noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) { | ||
| 443 | return __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); | ||
| 444 | } | ||
| 445 | }; | ||
| 446 | } // namespace __join_with_view | ||
| 447 | |||
| 448 | inline namespace __cpo { | ||
| 449 | inline constexpr auto join_with = __join_with_view::__fn{}; | ||
| 450 | } // namespace __cpo | ||
| 451 | } // namespace views | ||
| 452 | } // namespace ranges | ||
| 453 | |||
| 454 | #endif // _LIBCPP_STD_VER >= 23 | ||
| 455 | |||
| 456 | _LIBCPP_END_NAMESPACE_STD | ||
| 457 | |||
| 458 | _LIBCPP_POP_MACROS | ||
| 459 | |||
| 460 | #endif // _LIBCPP___RANGES_JOIN_WITH_VIEW_H | ||
lib/libcxx/include/__ranges/non_propagating_cache.h+1-1| ... | @@ -36,7 +36,7 @@ namespace ranges { | ... | @@ -36,7 +36,7 @@ namespace ranges { |
| 36 | // may refer to internal details of the source view. | 36 | // may refer to internal details of the source view. |
| 37 | template <class _Tp> | 37 | template <class _Tp> |
| 38 | requires is_object_v<_Tp> | 38 | requires is_object_v<_Tp> |
| 39 | class _LIBCPP_TEMPLATE_VIS __non_propagating_cache { | 39 | class __non_propagating_cache { |
| 40 | struct __from_tag {}; | 40 | struct __from_tag {}; |
| 41 | struct __forward_tag {}; | 41 | struct __forward_tag {}; |
| 42 | 42 |
lib/libcxx/include/__ranges/repeat_view.h+2-2| ... | @@ -52,12 +52,12 @@ concept __integer_like_with_usable_difference_type = | ... | @@ -52,12 +52,12 @@ concept __integer_like_with_usable_difference_type = |
| 52 | 52 | ||
| 53 | template <class _Tp> | 53 | template <class _Tp> |
| 54 | struct __repeat_view_iterator_difference { | 54 | struct __repeat_view_iterator_difference { |
| 55 | using type = _IotaDiffT<_Tp>; | 55 | using type _LIBCPP_NODEBUG = _IotaDiffT<_Tp>; |
| 56 | }; | 56 | }; |
| 57 | 57 | ||
| 58 | template <__signed_integer_like _Tp> | 58 | template <__signed_integer_like _Tp> |
| 59 | struct __repeat_view_iterator_difference<_Tp> { | 59 | struct __repeat_view_iterator_difference<_Tp> { |
| 60 | using type = _Tp; | 60 | using type _LIBCPP_NODEBUG = _Tp; |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | template <class _Tp> | 63 | template <class _Tp> |
lib/libcxx/include/__ranges/reverse_view.h+2-2| ... | @@ -144,13 +144,13 @@ inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_I | ... | @@ -144,13 +144,13 @@ inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_I |
| 144 | 144 | ||
| 145 | template <class _Tp> | 145 | template <class _Tp> |
| 146 | struct __unwrapped_reverse_subrange { | 146 | struct __unwrapped_reverse_subrange { |
| 147 | using type = | 147 | using type _LIBCPP_NODEBUG = |
| 148 | void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics | 148 | void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics |
| 149 | }; | 149 | }; |
| 150 | 150 | ||
| 151 | template <class _Iter, subrange_kind _Kind> | 151 | template <class _Iter, subrange_kind _Kind> |
| 152 | struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> { | 152 | struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> { |
| 153 | using type = subrange<_Iter, _Iter, _Kind>; | 153 | using type _LIBCPP_NODEBUG = subrange<_Iter, _Iter, _Kind>; |
| 154 | }; | 154 | }; |
| 155 | 155 | ||
| 156 | struct __fn : __range_adaptor_closure<__fn> { | 156 | struct __fn : __range_adaptor_closure<__fn> { |
lib/libcxx/include/__ranges/subrange.h+5-5| ... | @@ -72,7 +72,7 @@ template <input_or_output_iterator _Iter, | ... | @@ -72,7 +72,7 @@ template <input_or_output_iterator _Iter, |
| 72 | sentinel_for<_Iter> _Sent = _Iter, | 72 | sentinel_for<_Iter> _Sent = _Iter, |
| 73 | subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter> ? subrange_kind::sized : subrange_kind::unsized> | 73 | subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter> ? subrange_kind::sized : subrange_kind::unsized> |
| 74 | requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) | 74 | requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) |
| 75 | class _LIBCPP_TEMPLATE_VIS subrange : public view_interface<subrange<_Iter, _Sent, _Kind>> { | 75 | class subrange : public view_interface<subrange<_Iter, _Sent, _Kind>> { |
| 76 | public: | 76 | public: |
| 77 | // Note: this is an internal implementation detail that is public only for internal usage. | 77 | // Note: this is an internal implementation detail that is public only for internal usage. |
| 78 | static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>); | 78 | static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>); |
| ... | @@ -247,22 +247,22 @@ struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>> : integral_constant<size_t, 2 | ... | @@ -247,22 +247,22 @@ struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>> : integral_constant<size_t, 2 |
| 247 | 247 | ||
| 248 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> | 248 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> |
| 249 | struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> { | 249 | struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> { |
| 250 | using type = _Ip; | 250 | using type _LIBCPP_NODEBUG = _Ip; |
| 251 | }; | 251 | }; |
| 252 | 252 | ||
| 253 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> | 253 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> |
| 254 | struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> { | 254 | struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> { |
| 255 | using type = _Sp; | 255 | using type _LIBCPP_NODEBUG = _Sp; |
| 256 | }; | 256 | }; |
| 257 | 257 | ||
| 258 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> | 258 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> |
| 259 | struct tuple_element<0, const ranges::subrange<_Ip, _Sp, _Kp>> { | 259 | struct tuple_element<0, const ranges::subrange<_Ip, _Sp, _Kp>> { |
| 260 | using type = _Ip; | 260 | using type _LIBCPP_NODEBUG = _Ip; |
| 261 | }; | 261 | }; |
| 262 | 262 | ||
| 263 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> | 263 | template <class _Ip, class _Sp, ranges::subrange_kind _Kp> |
| 264 | struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> { | 264 | struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> { |
| 265 | using type = _Sp; | 265 | using type _LIBCPP_NODEBUG = _Sp; |
| 266 | }; | 266 | }; |
| 267 | 267 | ||
| 268 | #endif // _LIBCPP_STD_VER >= 20 | 268 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__ranges/take_view.h+3-3| ... | @@ -229,18 +229,18 @@ struct __passthrough_type; | ... | @@ -229,18 +229,18 @@ struct __passthrough_type; |
| 229 | 229 | ||
| 230 | template <class _Tp, size_t _Extent> | 230 | template <class _Tp, size_t _Extent> |
| 231 | struct __passthrough_type<span<_Tp, _Extent>> { | 231 | struct __passthrough_type<span<_Tp, _Extent>> { |
| 232 | using type = span<_Tp>; | 232 | using type _LIBCPP_NODEBUG = span<_Tp>; |
| 233 | }; | 233 | }; |
| 234 | 234 | ||
| 235 | template <class _CharT, class _Traits> | 235 | template <class _CharT, class _Traits> |
| 236 | struct __passthrough_type<basic_string_view<_CharT, _Traits>> { | 236 | struct __passthrough_type<basic_string_view<_CharT, _Traits>> { |
| 237 | using type = basic_string_view<_CharT, _Traits>; | 237 | using type _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>; |
| 238 | }; | 238 | }; |
| 239 | 239 | ||
| 240 | template <class _Iter, class _Sent, subrange_kind _Kind> | 240 | template <class _Iter, class _Sent, subrange_kind _Kind> |
| 241 | requires requires { typename subrange<_Iter>; } | 241 | requires requires { typename subrange<_Iter>; } |
| 242 | struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { | 242 | struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { |
| 243 | using type = subrange<_Iter>; | 243 | using type _LIBCPP_NODEBUG = subrange<_Iter>; |
| 244 | }; | 244 | }; |
| 245 | 245 | ||
| 246 | template <class _Tp> | 246 | template <class _Tp> |
lib/libcxx/include/__ranges/to.h+4-2| ... | @@ -26,7 +26,9 @@ | ... | @@ -26,7 +26,9 @@ |
| 26 | #include <__ranges/size.h> | 26 | #include <__ranges/size.h> |
| 27 | #include <__ranges/transform_view.h> | 27 | #include <__ranges/transform_view.h> |
| 28 | #include <__type_traits/add_pointer.h> | 28 | #include <__type_traits/add_pointer.h> |
| 29 | #include <__type_traits/is_class.h> | ||
| 29 | #include <__type_traits/is_const.h> | 30 | #include <__type_traits/is_const.h> |
| 31 | #include <__type_traits/is_union.h> | ||
| 30 | #include <__type_traits/is_volatile.h> | 32 | #include <__type_traits/is_volatile.h> |
| 31 | #include <__type_traits/type_identity.h> | 33 | #include <__type_traits/type_identity.h> |
| 32 | #include <__utility/declval.h> | 34 | #include <__utility/declval.h> |
| ... | @@ -81,7 +83,7 @@ template <class _Container, input_range _Range, class... _Args> | ... | @@ -81,7 +83,7 @@ template <class _Container, input_range _Range, class... _Args> |
| 81 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); | 83 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); |
| 82 | static_assert( | 84 | static_assert( |
| 83 | !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); | 85 | !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); |
| 84 | 86 | static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type or union type"); | |
| 85 | // First see if the non-recursive case applies -- the conversion target is either: | 87 | // First see if the non-recursive case applies -- the conversion target is either: |
| 86 | // - a range with a convertible value type; | 88 | // - a range with a convertible value type; |
| 87 | // - a non-range type which might support being created from the input argument(s) (e.g. an `optional`). | 89 | // - a non-range type which might support being created from the input argument(s) (e.g. an `optional`). |
| ... | @@ -208,7 +210,7 @@ template <class _Container, class... _Args> | ... | @@ -208,7 +210,7 @@ template <class _Container, class... _Args> |
| 208 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); | 210 | static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const"); |
| 209 | static_assert( | 211 | static_assert( |
| 210 | !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); | 212 | !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); |
| 211 | 213 | static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type or union type"); | |
| 212 | auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static | 214 | auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static |
| 213 | requires requires { // | 215 | requires requires { // |
| 214 | /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); | 216 | /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); |
lib/libcxx/include/__ranges/transform_view.h+6-5| ... | @@ -38,6 +38,7 @@ | ... | @@ -38,6 +38,7 @@ |
| 38 | #include <__type_traits/is_nothrow_constructible.h> | 38 | #include <__type_traits/is_nothrow_constructible.h> |
| 39 | #include <__type_traits/is_object.h> | 39 | #include <__type_traits/is_object.h> |
| 40 | #include <__type_traits/is_reference.h> | 40 | #include <__type_traits/is_reference.h> |
| 41 | #include <__type_traits/is_referenceable.h> | ||
| 41 | #include <__type_traits/maybe_const.h> | 42 | #include <__type_traits/maybe_const.h> |
| 42 | #include <__type_traits/remove_cvref.h> | 43 | #include <__type_traits/remove_cvref.h> |
| 43 | #include <__utility/forward.h> | 44 | #include <__utility/forward.h> |
| ... | @@ -63,7 +64,7 @@ concept __regular_invocable_with_range_ref = regular_invocable<_Fn, range_refere | ... | @@ -63,7 +64,7 @@ concept __regular_invocable_with_range_ref = regular_invocable<_Fn, range_refere |
| 63 | template <class _View, class _Fn> | 64 | template <class _View, class _Fn> |
| 64 | concept __transform_view_constraints = | 65 | concept __transform_view_constraints = |
| 65 | view<_View> && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_View>> && | 66 | view<_View> && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_View>> && |
| 66 | __can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>; | 67 | __is_referenceable_v<invoke_result_t<_Fn&, range_reference_t<_View>>>; |
| 67 | 68 | ||
| 68 | # if _LIBCPP_STD_VER >= 23 | 69 | # if _LIBCPP_STD_VER >= 23 |
| 69 | template <input_range _View, move_constructible _Fn> | 70 | template <input_range _View, move_constructible _Fn> |
| ... | @@ -136,22 +137,22 @@ transform_view(_Range&&, _Fn) -> transform_view<views::all_t<_Range>, _Fn>; | ... | @@ -136,22 +137,22 @@ transform_view(_Range&&, _Fn) -> transform_view<views::all_t<_Range>, _Fn>; |
| 136 | 137 | ||
| 137 | template <class _View> | 138 | template <class _View> |
| 138 | struct __transform_view_iterator_concept { | 139 | struct __transform_view_iterator_concept { |
| 139 | using type = input_iterator_tag; | 140 | using type _LIBCPP_NODEBUG = input_iterator_tag; |
| 140 | }; | 141 | }; |
| 141 | 142 | ||
| 142 | template <random_access_range _View> | 143 | template <random_access_range _View> |
| 143 | struct __transform_view_iterator_concept<_View> { | 144 | struct __transform_view_iterator_concept<_View> { |
| 144 | using type = random_access_iterator_tag; | 145 | using type _LIBCPP_NODEBUG = random_access_iterator_tag; |
| 145 | }; | 146 | }; |
| 146 | 147 | ||
| 147 | template <bidirectional_range _View> | 148 | template <bidirectional_range _View> |
| 148 | struct __transform_view_iterator_concept<_View> { | 149 | struct __transform_view_iterator_concept<_View> { |
| 149 | using type = bidirectional_iterator_tag; | 150 | using type _LIBCPP_NODEBUG = bidirectional_iterator_tag; |
| 150 | }; | 151 | }; |
| 151 | 152 | ||
| 152 | template <forward_range _View> | 153 | template <forward_range _View> |
| 153 | struct __transform_view_iterator_concept<_View> { | 154 | struct __transform_view_iterator_concept<_View> { |
| 154 | using type = forward_iterator_tag; | 155 | using type _LIBCPP_NODEBUG = forward_iterator_tag; |
| 155 | }; | 156 | }; |
| 156 | 157 | ||
| 157 | template <class, class> | 158 | template <class, class> |
lib/libcxx/include/__ranges/zip_view.h+23-1| ... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
| 23 | #include <__iterator/iter_move.h> | 23 | #include <__iterator/iter_move.h> |
| 24 | #include <__iterator/iter_swap.h> | 24 | #include <__iterator/iter_swap.h> |
| 25 | #include <__iterator/iterator_traits.h> | 25 | #include <__iterator/iterator_traits.h> |
| 26 | #include <__iterator/product_iterator.h> | ||
| 26 | #include <__ranges/access.h> | 27 | #include <__ranges/access.h> |
| 27 | #include <__ranges/all.h> | 28 | #include <__ranges/all.h> |
| 28 | #include <__ranges/concepts.h> | 29 | #include <__ranges/concepts.h> |
| ... | @@ -251,8 +252,12 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base | ... | @@ -251,8 +252,12 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base |
| 251 | 252 | ||
| 252 | friend class zip_view<_Views...>; | 253 | friend class zip_view<_Views...>; |
| 253 | 254 | ||
| 255 | static constexpr bool __is_zip_view_iterator = true; | ||
| 256 | |||
| 257 | friend struct __product_iterator_traits<__iterator>; | ||
| 258 | |||
| 254 | public: | 259 | public: |
| 255 | using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>()); | 260 | using iterator_concept = decltype(ranges::__get_zip_view_iterator_tag<_Const, _Views...>()); |
| 256 | using value_type = tuple<range_value_t<__maybe_const<_Const, _Views>>...>; | 261 | using value_type = tuple<range_value_t<__maybe_const<_Const, _Views>>...>; |
| 257 | using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>; | 262 | using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>; |
| 258 | 263 | ||
| ... | @@ -468,6 +473,23 @@ inline constexpr auto zip = __zip::__fn{}; | ... | @@ -468,6 +473,23 @@ inline constexpr auto zip = __zip::__fn{}; |
| 468 | } // namespace views | 473 | } // namespace views |
| 469 | } // namespace ranges | 474 | } // namespace ranges |
| 470 | 475 | ||
| 476 | template <class _Iterator> | ||
| 477 | requires _Iterator::__is_zip_view_iterator | ||
| 478 | struct __product_iterator_traits<_Iterator> { | ||
| 479 | static constexpr size_t __size = tuple_size<decltype(std::declval<_Iterator>().__current_)>::value; | ||
| 480 | |||
| 481 | template <size_t _Nth, class _Iter> | ||
| 482 | requires(_Nth < __size) | ||
| 483 | _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_iterator_element(_Iter&& __it) { | ||
| 484 | return std::get<_Nth>(std::forward<_Iter>(__it).__current_); | ||
| 485 | } | ||
| 486 | |||
| 487 | template <class... _Iters> | ||
| 488 | _LIBCPP_HIDE_FROM_ABI static constexpr _Iterator __make_product_iterator(_Iters&&... __iters) { | ||
| 489 | return _Iterator(std::tuple(std::forward<_Iters>(__iters)...)); | ||
| 490 | } | ||
| 491 | }; | ||
| 492 | |||
| 471 | #endif // _LIBCPP_STD_VER >= 23 | 493 | #endif // _LIBCPP_STD_VER >= 23 |
| 472 | 494 | ||
| 473 | _LIBCPP_END_NAMESPACE_STD | 495 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__split_buffer+8-3| ... | @@ -28,6 +28,7 @@ | ... | @@ -28,6 +28,7 @@ |
| 28 | #include <__type_traits/integral_constant.h> | 28 | #include <__type_traits/integral_constant.h> |
| 29 | #include <__type_traits/is_nothrow_assignable.h> | 29 | #include <__type_traits/is_nothrow_assignable.h> |
| 30 | #include <__type_traits/is_nothrow_constructible.h> | 30 | #include <__type_traits/is_nothrow_constructible.h> |
| 31 | #include <__type_traits/is_replaceable.h> | ||
| 31 | #include <__type_traits/is_swappable.h> | 32 | #include <__type_traits/is_swappable.h> |
| 32 | #include <__type_traits/is_trivially_destructible.h> | 33 | #include <__type_traits/is_trivially_destructible.h> |
| 33 | #include <__type_traits/is_trivially_relocatable.h> | 34 | #include <__type_traits/is_trivially_relocatable.h> |
| ... | @@ -72,6 +73,10 @@ public: | ... | @@ -72,6 +73,10 @@ public: |
| 72 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | 73 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 73 | __split_buffer, | 74 | __split_buffer, |
| 74 | void>; | 75 | void>; |
| 76 | using __replaceable _LIBCPP_NODEBUG = | ||
| 77 | __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value, | ||
| 78 | __split_buffer, | ||
| 79 | void>; | ||
| 75 | 80 | ||
| 76 | pointer __first_; | 81 | pointer __first_; |
| 77 | pointer __begin_; | 82 | pointer __begin_; |
| ... | @@ -233,7 +238,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants | ... | @@ -233,7 +238,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants |
| 233 | // Postcondition: size() == size() + __n | 238 | // Postcondition: size() == size() + __n |
| 234 | template <class _Tp, class _Allocator> | 239 | template <class _Tp, class _Allocator> |
| 235 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) { | 240 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) { |
| 236 | _ConstructTransaction __tx(&this->__end_, __n); | 241 | _ConstructTransaction __tx(std::addressof(this->__end_), __n); |
| 237 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { | 242 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { |
| 238 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_)); | 243 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_)); |
| 239 | } | 244 | } |
| ... | @@ -248,7 +253,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_ | ... | @@ -248,7 +253,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_ |
| 248 | template <class _Tp, class _Allocator> | 253 | template <class _Tp, class _Allocator> |
| 249 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 254 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 250 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { | 255 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { |
| 251 | _ConstructTransaction __tx(&this->__end_, __n); | 256 | _ConstructTransaction __tx(std::addressof(this->__end_), __n); |
| 252 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { | 257 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { |
| 253 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x); | 258 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x); |
| 254 | } | 259 | } |
| ... | @@ -283,7 +288,7 @@ template <class _Tp, class _Allocator> | ... | @@ -283,7 +288,7 @@ template <class _Tp, class _Allocator> |
| 283 | template <class _ForwardIterator> | 288 | template <class _ForwardIterator> |
| 284 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 289 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 285 | __split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) { | 290 | __split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) { |
| 286 | _ConstructTransaction __tx(&this->__end_, __n); | 291 | _ConstructTransaction __tx(std::addressof(this->__end_), __n); |
| 287 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) { | 292 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) { |
| 288 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first); | 293 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first); |
| 289 | } | 294 | } |
lib/libcxx/include/__stop_token/atomic_unique_lock.h+1-1| ... | @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | // and LockedBit is the value of State when the lock bit is set, e.g 1 << 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 _LIBCPP_AVAILABILITY_SYNC __atomic_unique_lock { |
| 31 | static_assert(std::__libcpp_popcount(static_cast<unsigned long long>(_LockedBit)) == 1, | 31 | static_assert(std::__popcount(static_cast<unsigned long long>(_LockedBit)) == 1, |
| 32 | "LockedBit must be an integer where only one bit is set"); | 32 | "LockedBit must be an integer where only one bit is set"); |
| 33 | 33 | ||
| 34 | std::atomic<_State>& __state_; | 34 | std::atomic<_State>& __state_; |
lib/libcxx/include/__stop_token/intrusive_shared_ptr.h+2-1| ... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
| 14 | #include <__atomic/memory_order.h> | 14 | #include <__atomic/memory_order.h> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__cstddef/nullptr_t.h> | 16 | #include <__cstddef/nullptr_t.h> |
| 17 | #include <__memory/addressof.h> | ||
| 17 | #include <__type_traits/is_reference.h> | 18 | #include <__type_traits/is_reference.h> |
| 18 | #include <__utility/move.h> | 19 | #include <__utility/move.h> |
| 19 | #include <__utility/swap.h> | 20 | #include <__utility/swap.h> |
| ... | @@ -113,7 +114,7 @@ private: | ... | @@ -113,7 +114,7 @@ private: |
| 113 | 114 | ||
| 114 | _LIBCPP_HIDE_FROM_ABI static void __decrement_ref_count(_Tp& __obj) { | 115 | _LIBCPP_HIDE_FROM_ABI static void __decrement_ref_count(_Tp& __obj) { |
| 115 | if (__get_atomic_ref_count(__obj).fetch_sub(1, std::memory_order_acq_rel) == 1) { | 116 | if (__get_atomic_ref_count(__obj).fetch_sub(1, std::memory_order_acq_rel) == 1) { |
| 116 | delete &__obj; | 117 | delete std::addressof(__obj); |
| 117 | } | 118 | } |
| 118 | } | 119 | } |
| 119 | 120 |
lib/libcxx/include/__string/char_traits.h+7-14| ... | @@ -78,7 +78,7 @@ exposition-only to document what members a char_traits specialization should pro | ... | @@ -78,7 +78,7 @@ exposition-only to document what members a char_traits specialization should pro |
| 78 | // char_traits<char> | 78 | // char_traits<char> |
| 79 | 79 | ||
| 80 | template <> | 80 | template <> |
| 81 | struct _LIBCPP_TEMPLATE_VIS char_traits<char> { | 81 | struct char_traits<char> { |
| 82 | using char_type = char; | 82 | using char_type = char; |
| 83 | using int_type = int; | 83 | using int_type = int; |
| 84 | using off_type = streamoff; | 84 | using off_type = streamoff; |
| ... | @@ -132,8 +132,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> { | ... | @@ -132,8 +132,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> { |
| 132 | 132 | ||
| 133 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | 133 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 134 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | 134 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 135 | if (__n == 0) | ||
| 136 | return nullptr; | ||
| 137 | return std::__constexpr_memchr(__s, __a, __n); | 135 | return std::__constexpr_memchr(__s, __a, __n); |
| 138 | } | 136 | } |
| 139 | 137 | ||
| ... | @@ -236,7 +234,7 @@ struct __char_traits_base { | ... | @@ -236,7 +234,7 @@ struct __char_traits_base { |
| 236 | 234 | ||
| 237 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 235 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 238 | template <> | 236 | template <> |
| 239 | struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> { | 237 | struct char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> { |
| 240 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 238 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 241 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | 239 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { |
| 242 | if (__n == 0) | 240 | if (__n == 0) |
| ... | @@ -250,8 +248,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w | ... | @@ -250,8 +248,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w |
| 250 | 248 | ||
| 251 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* | 249 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type* |
| 252 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { | 250 | find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT { |
| 253 | if (__n == 0) | ||
| 254 | return nullptr; | ||
| 255 | return std::__constexpr_wmemchr(__s, __a, __n); | 251 | return std::__constexpr_wmemchr(__s, __a, __n); |
| 256 | } | 252 | } |
| 257 | }; | 253 | }; |
| ... | @@ -260,8 +256,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w | ... | @@ -260,8 +256,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w |
| 260 | #if _LIBCPP_HAS_CHAR8_T | 256 | #if _LIBCPP_HAS_CHAR8_T |
| 261 | 257 | ||
| 262 | template <> | 258 | template <> |
| 263 | struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> | 259 | struct char_traits<char8_t> : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> { |
| 264 | : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> { | ||
| 265 | static _LIBCPP_HIDE_FROM_ABI constexpr int | 260 | static _LIBCPP_HIDE_FROM_ABI constexpr int |
| 266 | compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept { | 261 | compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept { |
| 267 | return std::__constexpr_memcmp(__s1, __s2, __element_count(__n)); | 262 | return std::__constexpr_memcmp(__s1, __s2, __element_count(__n)); |
| ... | @@ -280,8 +275,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> | ... | @@ -280,8 +275,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> |
| 280 | #endif // _LIBCPP_HAS_CHAR8_T | 275 | #endif // _LIBCPP_HAS_CHAR8_T |
| 281 | 276 | ||
| 282 | template <> | 277 | template <> |
| 283 | struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> | 278 | struct char_traits<char16_t> : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> { |
| 284 | : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> { | ||
| 285 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 279 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 286 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | 280 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; |
| 287 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; | 281 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; |
| ... | @@ -315,8 +309,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const | ... | @@ -315,8 +309,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const |
| 315 | } | 309 | } |
| 316 | 310 | ||
| 317 | template <> | 311 | template <> |
| 318 | struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> | 312 | struct char_traits<char32_t> : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> { |
| 319 | : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> { | ||
| 320 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int | 313 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| 321 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | 314 | compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; |
| 322 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; | 315 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT; |
| ... | @@ -355,7 +348,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const | ... | @@ -355,7 +348,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const |
| 355 | template <class _CharT, class _SizeT, class _Traits, _SizeT __npos> | 348 | template <class _CharT, class _SizeT, class _Traits, _SizeT __npos> |
| 356 | inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI | 349 | inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI |
| 357 | __str_find(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT { | 350 | __str_find(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT { |
| 358 | if (__pos >= __sz) | 351 | if (__pos > __sz) |
| 359 | return __npos; | 352 | return __npos; |
| 360 | const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); | 353 | const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); |
| 361 | if (__r == nullptr) | 354 | if (__r == nullptr) |
| ... | @@ -534,7 +527,7 @@ __str_find_last_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) | ... | @@ -534,7 +527,7 @@ __str_find_last_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) |
| 534 | template <class _Ptr> | 527 | template <class _Ptr> |
| 535 | inline _LIBCPP_HIDE_FROM_ABI size_t __do_string_hash(_Ptr __p, _Ptr __e) { | 528 | inline _LIBCPP_HIDE_FROM_ABI size_t __do_string_hash(_Ptr __p, _Ptr __e) { |
| 536 | typedef typename iterator_traits<_Ptr>::value_type value_type; | 529 | typedef typename iterator_traits<_Ptr>::value_type value_type; |
| 537 | return __murmur2_or_cityhash<size_t>()(__p, (__e - __p) * sizeof(value_type)); | 530 | return std::__hash_memory(__p, (__e - __p) * sizeof(value_type)); |
| 538 | } | 531 | } |
| 539 | 532 | ||
| 540 | _LIBCPP_END_NAMESPACE_STD | 533 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__string/constexpr_c_functions.h+13-10| ... | @@ -146,7 +146,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_memchr(_Tp* | ... | @@ -146,7 +146,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_memchr(_Tp* |
| 146 | return nullptr; | 146 | return nullptr; |
| 147 | } else { | 147 | } else { |
| 148 | char __value_buffer = 0; | 148 | char __value_buffer = 0; |
| 149 | __builtin_memcpy(&__value_buffer, &__value, sizeof(char)); | 149 | __builtin_memcpy(&__value_buffer, std::addressof(__value), sizeof(char)); |
| 150 | return static_cast<_Tp*>(__builtin_memchr(__str, __value_buffer, __count)); | 150 | return static_cast<_Tp*>(__builtin_memchr(__str, __value_buffer, __count)); |
| 151 | } | 151 | } |
| 152 | } | 152 | } |
| ... | @@ -204,23 +204,26 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __assign_trivially_copy | ... | @@ -204,23 +204,26 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __assign_trivially_copy |
| 204 | return __dest; | 204 | return __dest; |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | template <class _Tp, class _Up, __enable_if_t<__is_always_bitcastable<_Up, _Tp>::value, int> = 0> | 207 | template <class _Tp, class _Up> |
| 208 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* | 208 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* |
| 209 | __constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) { | 209 | __constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) { |
| 210 | static_assert(__is_always_bitcastable<_Up, _Tp>::value); | ||
| 210 | size_t __count = static_cast<size_t>(__n); | 211 | size_t __count = static_cast<size_t>(__n); |
| 211 | if (__libcpp_is_constant_evaluated()) { | 212 | if (__libcpp_is_constant_evaluated()) { |
| 212 | #ifdef _LIBCPP_COMPILER_CLANG_BASED | 213 | #ifdef _LIBCPP_COMPILER_CLANG_BASED |
| 213 | if (is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value) { | 214 | if _LIBCPP_CONSTEXPR (is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value) { |
| 214 | ::__builtin_memmove(__dest, __src, __count * sizeof(_Tp)); | 215 | ::__builtin_memmove(__dest, __src, __count * sizeof(_Tp)); |
| 215 | return __dest; | 216 | return __dest; |
| 216 | } | 217 | } else |
| 217 | #endif | 218 | #endif |
| 218 | if (std::__is_pointer_in_range(__src, __src + __count, __dest)) { | 219 | { |
| 219 | for (; __count > 0; --__count) | 220 | if (std::__is_pointer_in_range(__src, __src + __count, __dest)) { |
| 220 | std::__assign_trivially_copyable(__dest[__count - 1], __src[__count - 1]); | 221 | for (; __count > 0; --__count) |
| 221 | } else { | 222 | std::__assign_trivially_copyable(__dest[__count - 1], __src[__count - 1]); |
| 222 | for (size_t __i = 0; __i != __count; ++__i) | 223 | } else { |
| 223 | std::__assign_trivially_copyable(__dest[__i], __src[__i]); | 224 | for (size_t __i = 0; __i != __count; ++__i) |
| 225 | std::__assign_trivially_copyable(__dest[__i], __src[__i]); | ||
| 226 | } | ||
| 224 | } | 227 | } |
| 225 | } else if (__count > 0) { | 228 | } else if (__count > 0) { |
| 226 | ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>); | 229 | ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>); |
lib/libcxx/include/__string/extern_template_lists.h+63-102| ... | @@ -17,116 +17,77 @@ | ... | @@ -17,116 +17,77 @@ |
| 17 | 17 | ||
| 18 | // clang-format off | 18 | // clang-format off |
| 19 | 19 | ||
| 20 | // We maintain 2 ABI lists: | 20 | // We maintain multiple ABI lists: |
| 21 | // - _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST | ||
| 21 | // - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST | 22 | // - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST |
| 22 | // - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST | 23 | // - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST |
| 23 | // As the name implies, the ABI lists define the V1 (Stable) and unstable ABI. | 24 | // As the name implies, the ABI lists define a common subset, the V1 (Stable) and unstable ABI. |
| 24 | // | 25 | // |
| 25 | // For unstable, we may explicitly remove function that are external in V1, | 26 | // For unstable, we may explicitly remove function that are external in V1. |
| 26 | // and add (new) external functions to better control inlining and compiler | ||
| 27 | // optimization opportunities. | ||
| 28 | // | 27 | // |
| 29 | // For stable, the ABI list should rarely change, except for adding new | 28 | // For stable, the ABI list should rarely change, except for adding new |
| 30 | // functions supporting new c++ version / API changes. Typically entries | 29 | // functions supporting new c++ version / API changes. Typically entries |
| 31 | // must never be removed from the stable list. | 30 | // must never be removed from the stable list. |
| 32 | #define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | 31 | #define _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST(Func, CharT) \ |
| 33 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | 32 | Func(void basic_string<CharT>::__init(const value_type*, size_type)) \ |
| 34 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | 33 | Func(void basic_string<CharT>::__init(size_type, value_type)) \ |
| 35 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | 34 | Func(basic_string<CharT>::basic_string(const basic_string&, size_type, size_type, const allocator<CharT>&)) \ |
| 36 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&)) \ | 35 | Func(basic_string<CharT>::~basic_string()) \ |
| 37 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | 36 | Func(basic_string<CharT>& basic_string<CharT>::operator=(value_type)) \ |
| 38 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \ | 37 | Func(basic_string<CharT>& basic_string<CharT>::assign(size_type, value_type)) \ |
| 39 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | 38 | Func(basic_string<CharT>& basic_string<CharT>::assign(const basic_string&, size_type, size_type)) \ |
| 40 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::~basic_string()) \ | 39 | Func(basic_string<CharT>& basic_string<CharT>::append(size_type, value_type)) \ |
| 41 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | 40 | Func(basic_string<CharT>& basic_string<CharT>::append(const value_type*)) \ |
| 42 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | 41 | Func(basic_string<CharT>& basic_string<CharT>::append(const value_type*, size_type)) \ |
| 43 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | 42 | Func(basic_string<CharT>& basic_string<CharT>::append(const basic_string&, size_type, size_type)) \ |
| 44 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type)) \ | 43 | Func(void basic_string<CharT>::push_back(value_type)) \ |
| 45 | _Func(_LIBCPP_EXPORTED_FROM_ABI const _CharType& basic_string<_CharType>::at(size_type) const) \ | 44 | Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, const value_type*)) \ |
| 46 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | 45 | Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, size_type, value_type)) \ |
| 47 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | 46 | Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, const value_type*, size_type)) \ |
| 48 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | 47 | Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, const basic_string&, size_type, size_type)) \ |
| 49 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \ | 48 | Func(basic_string<CharT>::iterator basic_string<CharT>::insert(basic_string::const_iterator, value_type)) \ |
| 50 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::reserve(size_type)) \ | 49 | Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, const value_type*)) \ |
| 51 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | 50 | Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, size_type, value_type)) \ |
| 52 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | 51 | Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, const value_type*, size_type)) \ |
| 53 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | 52 | Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, const basic_string&, size_type, size_type)) \ |
| 54 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ | 53 | Func(void basic_string<CharT>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, const value_type*)) \ |
| 55 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | 54 | Func(void basic_string<CharT>::resize(size_type, value_type)) \ |
| 56 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(size_type, value_type)) \ | 55 | Func(void basic_string<CharT>::reserve(size_type)) \ |
| 57 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | 56 | Func(basic_string<CharT>::size_type basic_string<CharT>::copy(value_type*, size_type, size_type) const) \ |
| 58 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | 57 | Func(basic_string<CharT>::size_type basic_string<CharT>::find(value_type, size_type) const) \ |
| 59 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ | 58 | Func(basic_string<CharT>::size_type basic_string<CharT>::find(const value_type*, size_type, size_type) const) \ |
| 60 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | 59 | Func(basic_string<CharT>::size_type basic_string<CharT>::rfind(value_type, size_type) const) \ |
| 61 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::push_back(value_type)) \ | 60 | Func(basic_string<CharT>::size_type basic_string<CharT>::rfind(const value_type*, size_type, size_type) const) \ |
| 62 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | 61 | Func(basic_string<CharT>::size_type basic_string<CharT>::find_first_of(const value_type*, size_type, size_type) const) \ |
| 63 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | 62 | Func(basic_string<CharT>::size_type basic_string<CharT>::find_last_of(const value_type*, size_type, size_type) const) \ |
| 64 | _Func(_LIBCPP_EXPORTED_FROM_ABI const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | 63 | Func(basic_string<CharT>::size_type basic_string<CharT>::find_first_not_of(const value_type*, size_type, size_type) const) \ |
| 65 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | 64 | Func(basic_string<CharT>::size_type basic_string<CharT>::find_last_not_of(const value_type*, size_type, size_type) const) \ |
| 66 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \ | 65 | Func(CharT& basic_string<CharT>::at(size_type)) \ |
| 67 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | 66 | Func(const CharT& basic_string<CharT>::at(size_type) const) \ |
| 68 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(value_type const*) const) \ | 67 | Func(int basic_string<CharT>::compare(const value_type*) const) \ |
| 69 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | 68 | Func(int basic_string<CharT>::compare(size_type, size_type, const value_type*) const) \ |
| 70 | _Func(_LIBCPP_EXPORTED_FROM_ABI _CharType& basic_string<_CharType>::at(size_type)) \ | 69 | Func(int basic_string<CharT>::compare(size_type, size_type, const value_type*, size_type) const) \ |
| 71 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \ | 70 | Func(int basic_string<CharT>::compare(size_type, size_type, const basic_string&, size_type, size_type) const) \ |
| 72 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | 71 | Func(const basic_string<CharT>::size_type basic_string<CharT>::npos) \ |
| 73 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | ||
| 74 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | ||
| 75 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \ | ||
| 76 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | ||
| 77 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | ||
| 78 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | ||
| 79 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::resize(size_type, value_type)) \ | ||
| 80 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | ||
| 81 | 72 | ||
| 82 | #define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | 73 | #define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(Func, CharT) \ |
| 83 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | 74 | _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST(Func, CharT) \ |
| 84 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | 75 | Func(basic_string<CharT>::basic_string(const basic_string&)) \ |
| 85 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | 76 | Func(basic_string<CharT>::basic_string(const basic_string&, const allocator<CharT>&)) \ |
| 86 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | 77 | Func(basic_string<CharT>& basic_string<CharT>::assign(const value_type*)) \ |
| 87 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | 78 | Func(basic_string<CharT>& basic_string<CharT>::assign(const value_type*, size_type)) \ |
| 88 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::~basic_string()) \ | 79 | Func(basic_string<CharT>& basic_string<CharT>::operator=(basic_string const&)) \ |
| 89 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | 80 | Func(void basic_string<CharT>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ |
| 90 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | 81 | Func(basic_string<CharT>& basic_string<CharT>::erase(size_type, size_type)) \ |
| 91 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | 82 | |
| 92 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type)) \ | 83 | #define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(Func, CharT) \ |
| 93 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \ | 84 | _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST(Func, CharT) \ |
| 94 | _Func(_LIBCPP_EXPORTED_FROM_ABI const _CharType& basic_string<_CharType>::at(size_type) const) \ | 85 | Func(void basic_string<CharT>::__init_copy_ctor_external(const value_type*, size_type)) \ |
| 95 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | 86 | Func(basic_string<CharT>& basic_string<CharT>::__assign_external(const value_type*, size_type)) \ |
| 96 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | 87 | Func(basic_string<CharT>& basic_string<CharT>::__assign_external(const value_type*)) \ |
| 97 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | 88 | Func(basic_string<CharT>& basic_string<CharT>::__assign_no_alias<false>(const value_type*, size_type)) \ |
| 98 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \ | 89 | Func(basic_string<CharT>& basic_string<CharT>::__assign_no_alias<true>(const value_type*, size_type)) \ |
| 99 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \ | 90 | Func(void basic_string<CharT>::__erase_external_with_move(size_type, size_type)) |
| 100 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::reserve(size_type)) \ | ||
| 101 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | ||
| 102 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | ||
| 103 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | ||
| 104 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ | ||
| 105 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | ||
| 106 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(size_type, value_type)) \ | ||
| 107 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | ||
| 108 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | ||
| 109 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | ||
| 110 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \ | ||
| 111 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \ | ||
| 112 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::push_back(value_type)) \ | ||
| 113 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | ||
| 114 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | ||
| 115 | _Func(_LIBCPP_EXPORTED_FROM_ABI const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | ||
| 116 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | ||
| 117 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \ | ||
| 118 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | ||
| 119 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(value_type const*) const) \ | ||
| 120 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | ||
| 121 | _Func(_LIBCPP_EXPORTED_FROM_ABI _CharType& basic_string<_CharType>::at(size_type)) \ | ||
| 122 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | ||
| 123 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | ||
| 124 | _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | ||
| 125 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | ||
| 126 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | ||
| 127 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | ||
| 128 | _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::resize(size_type, value_type)) \ | ||
| 129 | _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | ||
| 130 | 91 | ||
| 131 | // clang-format on | 92 | // clang-format on |
| 132 | 93 |
lib/libcxx/include/__system_error/error_category.h+2-2| ... | @@ -67,8 +67,8 @@ public: | ... | @@ -67,8 +67,8 @@ public: |
| 67 | string message(int __ev) const override; | 67 | string message(int __ev) const override; |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | __attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT; | 70 | [[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT; |
| 71 | __attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT; | 71 | [[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT; |
| 72 | 72 | ||
| 73 | _LIBCPP_END_NAMESPACE_STD | 73 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 74 |
lib/libcxx/include/__system_error/error_code.h+2-2| ... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | ||
| 28 | template <class _Tp> | 28 | template <class _Tp> |
| 29 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public false_type {}; | 29 | struct is_error_code_enum : public false_type {}; |
| 30 | 30 | ||
| 31 | #if _LIBCPP_STD_VER >= 17 | 31 | #if _LIBCPP_STD_VER >= 17 |
| 32 | template <class _Tp> | 32 | template <class _Tp> |
| ... | @@ -131,7 +131,7 @@ inline _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const error_code& __x, | ... | @@ -131,7 +131,7 @@ inline _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const error_code& __x, |
| 131 | #endif // _LIBCPP_STD_VER <= 17 | 131 | #endif // _LIBCPP_STD_VER <= 17 |
| 132 | 132 | ||
| 133 | template <> | 133 | template <> |
| 134 | struct _LIBCPP_TEMPLATE_VIS hash<error_code> : public __unary_function<error_code, size_t> { | 134 | struct hash<error_code> : public __unary_function<error_code, size_t> { |
| 135 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_code& __ec) const _NOEXCEPT { | 135 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_code& __ec) const _NOEXCEPT { |
| 136 | return static_cast<size_t>(__ec.value()); | 136 | return static_cast<size_t>(__ec.value()); |
| 137 | } | 137 | } |
lib/libcxx/include/__system_error/error_condition.h+4-4| ... | @@ -25,7 +25,7 @@ | ... | @@ -25,7 +25,7 @@ |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _Tp> | 27 | template <class _Tp> |
| 28 | struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum : public false_type {}; | 28 | struct is_error_condition_enum : public false_type {}; |
| 29 | 29 | ||
| 30 | #if _LIBCPP_STD_VER >= 17 | 30 | #if _LIBCPP_STD_VER >= 17 |
| 31 | template <class _Tp> | 31 | template <class _Tp> |
| ... | @@ -33,11 +33,11 @@ inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>:: | ... | @@ -33,11 +33,11 @@ inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>:: |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | template <> | 35 | template <> |
| 36 | struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc> : true_type {}; | 36 | struct is_error_condition_enum<errc> : true_type {}; |
| 37 | 37 | ||
| 38 | #ifdef _LIBCPP_CXX03_LANG | 38 | #ifdef _LIBCPP_CXX03_LANG |
| 39 | template <> | 39 | template <> |
| 40 | struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx> : true_type {}; | 40 | struct is_error_condition_enum<errc::__lx> : true_type {}; |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | namespace __adl_only { | 43 | namespace __adl_only { |
| ... | @@ -118,7 +118,7 @@ operator<=>(const error_condition& __x, const error_condition& __y) noexcept { | ... | @@ -118,7 +118,7 @@ operator<=>(const error_condition& __x, const error_condition& __y) noexcept { |
| 118 | #endif // _LIBCPP_STD_VER <= 17 | 118 | #endif // _LIBCPP_STD_VER <= 17 |
| 119 | 119 | ||
| 120 | template <> | 120 | template <> |
| 121 | struct _LIBCPP_TEMPLATE_VIS hash<error_condition> : public __unary_function<error_condition, size_t> { | 121 | struct hash<error_condition> : public __unary_function<error_condition, size_t> { |
| 122 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_condition& __ec) const _NOEXCEPT { | 122 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_condition& __ec) const _NOEXCEPT { |
| 123 | return static_cast<size_t>(__ec.value()); | 123 | return static_cast<size_t>(__ec.value()); |
| 124 | } | 124 | } |
lib/libcxx/include/__thread/formatter.h+1-1| ... | @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | # if _LIBCPP_HAS_THREADS | 34 | # if _LIBCPP_HAS_THREADS |
| 35 | 35 | ||
| 36 | template <__fmt_char_type _CharT> | 36 | template <__fmt_char_type _CharT> |
| 37 | struct _LIBCPP_TEMPLATE_VIS formatter<__thread_id, _CharT> { | 37 | struct formatter<__thread_id, _CharT> { |
| 38 | public: | 38 | public: |
| 39 | template <class _ParseContext> | 39 | template <class _ParseContext> |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | 40 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
lib/libcxx/include/__thread/id.h+2-2| ... | @@ -34,7 +34,7 @@ _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT; | ... | @@ -34,7 +34,7 @@ _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT; |
| 34 | template <> | 34 | template <> |
| 35 | struct hash<__thread_id>; | 35 | struct hash<__thread_id>; |
| 36 | 36 | ||
| 37 | class _LIBCPP_TEMPLATE_VIS __thread_id { | 37 | class __thread_id { |
| 38 | // FIXME: pthread_t is a pointer on Darwin but a long on Linux. | 38 | // FIXME: pthread_t is a pointer on Darwin but a long on Linux. |
| 39 | // NULL is the no-thread value on Darwin. Someone needs to check | 39 | // NULL is the no-thread value on Darwin. Someone needs to check |
| 40 | // on other platforms. We assume 0 works everywhere for now. | 40 | // on other platforms. We assume 0 works everywhere for now. |
| ... | @@ -72,7 +72,7 @@ private: | ... | @@ -72,7 +72,7 @@ private: |
| 72 | 72 | ||
| 73 | friend __thread_id this_thread::get_id() _NOEXCEPT; | 73 | friend __thread_id this_thread::get_id() _NOEXCEPT; |
| 74 | friend class _LIBCPP_EXPORTED_FROM_ABI thread; | 74 | friend class _LIBCPP_EXPORTED_FROM_ABI thread; |
| 75 | friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>; | 75 | friend struct hash<__thread_id>; |
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT { | 78 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT { |
lib/libcxx/include/__thread/support/windows.h+2-4| ... | @@ -28,12 +28,10 @@ using __libcpp_timespec_t = ::timespec; | ... | @@ -28,12 +28,10 @@ using __libcpp_timespec_t = ::timespec; |
| 28 | typedef void* __libcpp_mutex_t; | 28 | typedef void* __libcpp_mutex_t; |
| 29 | #define _LIBCPP_MUTEX_INITIALIZER 0 | 29 | #define _LIBCPP_MUTEX_INITIALIZER 0 |
| 30 | 30 | ||
| 31 | #if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__) | 31 | #if defined(_WIN64) |
| 32 | typedef void* __libcpp_recursive_mutex_t[6]; | ||
| 33 | #elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__) | ||
| 34 | typedef void* __libcpp_recursive_mutex_t[5]; | 32 | typedef void* __libcpp_recursive_mutex_t[5]; |
| 35 | #else | 33 | #else |
| 36 | # error Unsupported architecture | 34 | typedef void* __libcpp_recursive_mutex_t[6]; |
| 37 | #endif | 35 | #endif |
| 38 | 36 | ||
| 39 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m); | 37 | _LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m); |
lib/libcxx/include/__thread/thread.h+65-69| ... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
| 16 | #include <__exception/terminate.h> | 16 | #include <__exception/terminate.h> |
| 17 | #include <__functional/hash.h> | 17 | #include <__functional/hash.h> |
| 18 | #include <__functional/unary_function.h> | 18 | #include <__functional/unary_function.h> |
| 19 | #include <__locale> | ||
| 20 | #include <__memory/addressof.h> | ||
| 19 | #include <__memory/unique_ptr.h> | 21 | #include <__memory/unique_ptr.h> |
| 20 | #include <__mutex/mutex.h> | 22 | #include <__mutex/mutex.h> |
| 21 | #include <__system_error/throw_system_error.h> | 23 | #include <__system_error/throw_system_error.h> |
| ... | @@ -29,7 +31,6 @@ | ... | @@ -29,7 +31,6 @@ |
| 29 | #include <tuple> | 31 | #include <tuple> |
| 30 | 32 | ||
| 31 | #if _LIBCPP_HAS_LOCALIZATION | 33 | #if _LIBCPP_HAS_LOCALIZATION |
| 32 | # include <locale> | ||
| 33 | # include <sstream> | 34 | # include <sstream> |
| 34 | #endif | 35 | #endif |
| 35 | 36 | ||
| ... | @@ -100,7 +101,7 @@ template <class _Tp> | ... | @@ -100,7 +101,7 @@ template <class _Tp> |
| 100 | __thread_specific_ptr<_Tp>::__thread_specific_ptr() { | 101 | __thread_specific_ptr<_Tp>::__thread_specific_ptr() { |
| 101 | int __ec = __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit); | 102 | int __ec = __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit); |
| 102 | if (__ec) | 103 | if (__ec) |
| 103 | __throw_system_error(__ec, "__thread_specific_ptr construction failed"); | 104 | std::__throw_system_error(__ec, "__thread_specific_ptr construction failed"); |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | template <class _Tp> | 107 | template <class _Tp> |
| ... | @@ -118,7 +119,7 @@ void __thread_specific_ptr<_Tp>::set_pointer(pointer __p) { | ... | @@ -118,7 +119,7 @@ void __thread_specific_ptr<_Tp>::set_pointer(pointer __p) { |
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | template <> | 121 | template <> |
| 121 | struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> : public __unary_function<__thread_id, size_t> { | 122 | struct hash<__thread_id> : public __unary_function<__thread_id, size_t> { |
| 122 | _LIBCPP_HIDE_FROM_ABI size_t operator()(__thread_id __v) const _NOEXCEPT { | 123 | _LIBCPP_HIDE_FROM_ABI size_t operator()(__thread_id __v) const _NOEXCEPT { |
| 123 | return hash<__libcpp_thread_id>()(__v.__id_); | 124 | return hash<__libcpp_thread_id>()(__v.__id_); |
| 124 | } | 125 | } |
| ... | @@ -151,47 +152,6 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { | ... | @@ -151,47 +152,6 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { |
| 151 | } | 152 | } |
| 152 | # endif // _LIBCPP_HAS_LOCALIZATION | 153 | # endif // _LIBCPP_HAS_LOCALIZATION |
| 153 | 154 | ||
| 154 | class _LIBCPP_EXPORTED_FROM_ABI thread { | ||
| 155 | __libcpp_thread_t __t_; | ||
| 156 | |||
| 157 | thread(const thread&); | ||
| 158 | thread& operator=(const thread&); | ||
| 159 | |||
| 160 | public: | ||
| 161 | typedef __thread_id id; | ||
| 162 | typedef __libcpp_thread_t native_handle_type; | ||
| 163 | |||
| 164 | _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} | ||
| 165 | # ifndef _LIBCPP_CXX03_LANG | ||
| 166 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0> | ||
| 167 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args); | ||
| 168 | # else // _LIBCPP_CXX03_LANG | ||
| 169 | template <class _Fp> | ||
| 170 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f); | ||
| 171 | # endif | ||
| 172 | ~thread(); | ||
| 173 | |||
| 174 | _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; } | ||
| 175 | |||
| 176 | _LIBCPP_HIDE_FROM_ABI thread& operator=(thread&& __t) _NOEXCEPT { | ||
| 177 | if (!__libcpp_thread_isnull(&__t_)) | ||
| 178 | terminate(); | ||
| 179 | __t_ = __t.__t_; | ||
| 180 | __t.__t_ = _LIBCPP_NULL_THREAD; | ||
| 181 | return *this; | ||
| 182 | } | ||
| 183 | |||
| 184 | _LIBCPP_HIDE_FROM_ABI void swap(thread& __t) _NOEXCEPT { std::swap(__t_, __t.__t_); } | ||
| 185 | |||
| 186 | _LIBCPP_HIDE_FROM_ABI bool joinable() const _NOEXCEPT { return !__libcpp_thread_isnull(&__t_); } | ||
| 187 | void join(); | ||
| 188 | void detach(); | ||
| 189 | _LIBCPP_HIDE_FROM_ABI id get_id() const _NOEXCEPT { return __libcpp_thread_get_id(&__t_); } | ||
| 190 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() _NOEXCEPT { return __t_; } | ||
| 191 | |||
| 192 | static unsigned hardware_concurrency() _NOEXCEPT; | ||
| 193 | }; | ||
| 194 | |||
| 195 | # ifndef _LIBCPP_CXX03_LANG | 155 | # ifndef _LIBCPP_CXX03_LANG |
| 196 | 156 | ||
| 197 | template <class _TSp, class _Fp, class... _Args, size_t... _Indices> | 157 | template <class _TSp, class _Fp, class... _Args, size_t... _Indices> |
| ... | @@ -209,19 +169,6 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) { | ... | @@ -209,19 +169,6 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) { |
| 209 | return nullptr; | 169 | return nullptr; |
| 210 | } | 170 | } |
| 211 | 171 | ||
| 212 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> > | ||
| 213 | thread::thread(_Fp&& __f, _Args&&... __args) { | ||
| 214 | typedef unique_ptr<__thread_struct> _TSPtr; | ||
| 215 | _TSPtr __tsp(new __thread_struct); | ||
| 216 | typedef tuple<_TSPtr, __decay_t<_Fp>, __decay_t<_Args>...> _Gp; | ||
| 217 | unique_ptr<_Gp> __p(new _Gp(std::move(__tsp), std::forward<_Fp>(__f), std::forward<_Args>(__args)...)); | ||
| 218 | int __ec = std::__libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get()); | ||
| 219 | if (__ec == 0) | ||
| 220 | __p.release(); | ||
| 221 | else | ||
| 222 | __throw_system_error(__ec, "thread constructor failed"); | ||
| 223 | } | ||
| 224 | |||
| 225 | # else // _LIBCPP_CXX03_LANG | 172 | # else // _LIBCPP_CXX03_LANG |
| 226 | 173 | ||
| 227 | template <class _Fp> | 174 | template <class _Fp> |
| ... | @@ -242,20 +189,69 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy_cxx03(void* __vp) { | ... | @@ -242,20 +189,69 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy_cxx03(void* __vp) { |
| 242 | return nullptr; | 189 | return nullptr; |
| 243 | } | 190 | } |
| 244 | 191 | ||
| 245 | template <class _Fp> | ||
| 246 | thread::thread(_Fp __f) { | ||
| 247 | typedef __thread_invoke_pair<_Fp> _InvokePair; | ||
| 248 | typedef unique_ptr<_InvokePair> _PairPtr; | ||
| 249 | _PairPtr __pp(new _InvokePair(__f)); | ||
| 250 | int __ec = std::__libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get()); | ||
| 251 | if (__ec == 0) | ||
| 252 | __pp.release(); | ||
| 253 | else | ||
| 254 | __throw_system_error(__ec, "thread constructor failed"); | ||
| 255 | } | ||
| 256 | |||
| 257 | # endif // _LIBCPP_CXX03_LANG | 192 | # endif // _LIBCPP_CXX03_LANG |
| 258 | 193 | ||
| 194 | class _LIBCPP_EXPORTED_FROM_ABI thread { | ||
| 195 | __libcpp_thread_t __t_; | ||
| 196 | |||
| 197 | thread(const thread&); | ||
| 198 | thread& operator=(const thread&); | ||
| 199 | |||
| 200 | public: | ||
| 201 | typedef __thread_id id; | ||
| 202 | typedef __libcpp_thread_t native_handle_type; | ||
| 203 | |||
| 204 | _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} | ||
| 205 | |||
| 206 | # ifndef _LIBCPP_CXX03_LANG | ||
| 207 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0> | ||
| 208 | _LIBCPP_HIDE_FROM_ABI explicit thread(_Fp&& __f, _Args&&... __args) { | ||
| 209 | typedef unique_ptr<__thread_struct> _TSPtr; | ||
| 210 | _TSPtr __tsp(new __thread_struct); | ||
| 211 | typedef tuple<_TSPtr, __decay_t<_Fp>, __decay_t<_Args>...> _Gp; | ||
| 212 | unique_ptr<_Gp> __p(new _Gp(std::move(__tsp), std::forward<_Fp>(__f), std::forward<_Args>(__args)...)); | ||
| 213 | int __ec = std::__libcpp_thread_create(&__t_, std::addressof(__thread_proxy<_Gp>), __p.get()); | ||
| 214 | if (__ec == 0) | ||
| 215 | __p.release(); | ||
| 216 | else | ||
| 217 | __throw_system_error(__ec, "thread constructor failed"); | ||
| 218 | } | ||
| 219 | # else // _LIBCPP_CXX03_LANG | ||
| 220 | template <class _Fp> | ||
| 221 | _LIBCPP_HIDE_FROM_ABI explicit thread(_Fp __f) { | ||
| 222 | typedef __thread_invoke_pair<_Fp> _InvokePair; | ||
| 223 | typedef unique_ptr<_InvokePair> _PairPtr; | ||
| 224 | _PairPtr __pp(new _InvokePair(__f)); | ||
| 225 | int __ec = std::__libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get()); | ||
| 226 | if (__ec == 0) | ||
| 227 | __pp.release(); | ||
| 228 | else | ||
| 229 | __throw_system_error(__ec, "thread constructor failed"); | ||
| 230 | } | ||
| 231 | # endif | ||
| 232 | ~thread(); | ||
| 233 | |||
| 234 | _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; } | ||
| 235 | |||
| 236 | _LIBCPP_HIDE_FROM_ABI thread& operator=(thread&& __t) _NOEXCEPT { | ||
| 237 | if (!__libcpp_thread_isnull(&__t_)) | ||
| 238 | terminate(); | ||
| 239 | __t_ = __t.__t_; | ||
| 240 | __t.__t_ = _LIBCPP_NULL_THREAD; | ||
| 241 | return *this; | ||
| 242 | } | ||
| 243 | |||
| 244 | _LIBCPP_HIDE_FROM_ABI void swap(thread& __t) _NOEXCEPT { std::swap(__t_, __t.__t_); } | ||
| 245 | |||
| 246 | _LIBCPP_HIDE_FROM_ABI bool joinable() const _NOEXCEPT { return !__libcpp_thread_isnull(&__t_); } | ||
| 247 | void join(); | ||
| 248 | void detach(); | ||
| 249 | _LIBCPP_HIDE_FROM_ABI id get_id() const _NOEXCEPT { return __libcpp_thread_get_id(&__t_); } | ||
| 250 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() _NOEXCEPT { return __t_; } | ||
| 251 | |||
| 252 | static unsigned hardware_concurrency() _NOEXCEPT; | ||
| 253 | }; | ||
| 254 | |||
| 259 | inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); } | 255 | inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); } |
| 260 | 256 | ||
| 261 | #endif // _LIBCPP_HAS_THREADS | 257 | #endif // _LIBCPP_HAS_THREADS |
lib/libcxx/include/__tree+269-361| ... | @@ -13,6 +13,9 @@ | ... | @@ -13,6 +13,9 @@ |
| 13 | #include <__algorithm/min.h> | 13 | #include <__algorithm/min.h> |
| 14 | #include <__assert> | 14 | #include <__assert> |
| 15 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__fwd/map.h> | ||
| 17 | #include <__fwd/pair.h> | ||
| 18 | #include <__fwd/set.h> | ||
| 16 | #include <__iterator/distance.h> | 19 | #include <__iterator/distance.h> |
| 17 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__iterator/next.h> | 21 | #include <__iterator/next.h> |
| ... | @@ -23,6 +26,7 @@ | ... | @@ -23,6 +26,7 @@ |
| 23 | #include <__memory/swap_allocator.h> | 26 | #include <__memory/swap_allocator.h> |
| 24 | #include <__memory/unique_ptr.h> | 27 | #include <__memory/unique_ptr.h> |
| 25 | #include <__type_traits/can_extract_key.h> | 28 | #include <__type_traits/can_extract_key.h> |
| 29 | #include <__type_traits/copy_cvref.h> | ||
| 26 | #include <__type_traits/enable_if.h> | 30 | #include <__type_traits/enable_if.h> |
| 27 | #include <__type_traits/invoke.h> | 31 | #include <__type_traits/invoke.h> |
| 28 | #include <__type_traits/is_const.h> | 32 | #include <__type_traits/is_const.h> |
| ... | @@ -31,6 +35,7 @@ | ... | @@ -31,6 +35,7 @@ |
| 31 | #include <__type_traits/is_nothrow_constructible.h> | 35 | #include <__type_traits/is_nothrow_constructible.h> |
| 32 | #include <__type_traits/is_same.h> | 36 | #include <__type_traits/is_same.h> |
| 33 | #include <__type_traits/is_swappable.h> | 37 | #include <__type_traits/is_swappable.h> |
| 38 | #include <__type_traits/remove_const.h> | ||
| 34 | #include <__type_traits/remove_const_ref.h> | 39 | #include <__type_traits/remove_const_ref.h> |
| 35 | #include <__type_traits/remove_cvref.h> | 40 | #include <__type_traits/remove_cvref.h> |
| 36 | #include <__utility/forward.h> | 41 | #include <__utility/forward.h> |
| ... | @@ -48,21 +53,12 @@ _LIBCPP_PUSH_MACROS | ... | @@ -48,21 +53,12 @@ _LIBCPP_PUSH_MACROS |
| 48 | 53 | ||
| 49 | _LIBCPP_BEGIN_NAMESPACE_STD | 54 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 50 | 55 | ||
| 51 | template <class, class, class, class> | ||
| 52 | class _LIBCPP_TEMPLATE_VIS map; | ||
| 53 | template <class, class, class, class> | ||
| 54 | class _LIBCPP_TEMPLATE_VIS multimap; | ||
| 55 | template <class, class, class> | ||
| 56 | class _LIBCPP_TEMPLATE_VIS set; | ||
| 57 | template <class, class, class> | ||
| 58 | class _LIBCPP_TEMPLATE_VIS multiset; | ||
| 59 | |||
| 60 | template <class _Tp, class _Compare, class _Allocator> | 56 | template <class _Tp, class _Compare, class _Allocator> |
| 61 | class __tree; | 57 | class __tree; |
| 62 | template <class _Tp, class _NodePtr, class _DiffType> | 58 | template <class _Tp, class _NodePtr, class _DiffType> |
| 63 | class _LIBCPP_TEMPLATE_VIS __tree_iterator; | 59 | class __tree_iterator; |
| 64 | template <class _Tp, class _ConstNodePtr, class _DiffType> | 60 | template <class _Tp, class _ConstNodePtr, class _DiffType> |
| 65 | class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; | 61 | class __tree_const_iterator; |
| 66 | 62 | ||
| 67 | template <class _Pointer> | 63 | template <class _Pointer> |
| 68 | class __tree_end_node; | 64 | class __tree_end_node; |
| ... | @@ -77,9 +73,9 @@ struct __value_type; | ... | @@ -77,9 +73,9 @@ struct __value_type; |
| 77 | template <class _Allocator> | 73 | template <class _Allocator> |
| 78 | class __map_node_destructor; | 74 | class __map_node_destructor; |
| 79 | template <class _TreeIterator> | 75 | template <class _TreeIterator> |
| 80 | class _LIBCPP_TEMPLATE_VIS __map_iterator; | 76 | class __map_iterator; |
| 81 | template <class _TreeIterator> | 77 | template <class _TreeIterator> |
| 82 | class _LIBCPP_TEMPLATE_VIS __map_const_iterator; | 78 | class __map_const_iterator; |
| 83 | 79 | ||
| 84 | /* | 80 | /* |
| 85 | 81 | ||
| ... | @@ -142,7 +138,7 @@ unsigned __tree_sub_invariant(_NodePtr __x) { | ... | @@ -142,7 +138,7 @@ unsigned __tree_sub_invariant(_NodePtr __x) { |
| 142 | } | 138 | } |
| 143 | 139 | ||
| 144 | // Determines if the red black tree rooted at __root is a proper red black tree. | 140 | // Determines if the red black tree rooted at __root is a proper red black tree. |
| 145 | // __root == nullptr is a proper tree. Returns true is __root is a proper | 141 | // __root == nullptr is a proper tree. Returns true if __root is a proper |
| 146 | // red black tree, else returns false. | 142 | // red black tree, else returns false. |
| 147 | template <class _NodePtr> | 143 | template <class _NodePtr> |
| 148 | _LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) { | 144 | _LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) { |
| ... | @@ -510,119 +506,42 @@ template <class _One> | ... | @@ -510,119 +506,42 @@ template <class _One> |
| 510 | struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {}; | 506 | struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {}; |
| 511 | 507 | ||
| 512 | template <class _Tp> | 508 | template <class _Tp> |
| 513 | struct __tree_key_value_types { | 509 | struct __get_tree_key_type { |
| 514 | typedef _Tp key_type; | 510 | using type _LIBCPP_NODEBUG = _Tp; |
| 515 | typedef _Tp __node_value_type; | ||
| 516 | typedef _Tp __container_value_type; | ||
| 517 | static const bool __is_map = false; | ||
| 518 | |||
| 519 | _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Tp const& __v) { return __v; } | ||
| 520 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __v) { return __v; } | ||
| 521 | _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { return std::addressof(__n); } | ||
| 522 | _LIBCPP_HIDE_FROM_ABI static __container_value_type&& __move(__node_value_type& __v) { return std::move(__v); } | ||
| 523 | }; | 511 | }; |
| 524 | 512 | ||
| 525 | template <class _Key, class _Tp> | 513 | template <class _Key, class _ValueT> |
| 526 | struct __tree_key_value_types<__value_type<_Key, _Tp> > { | 514 | struct __get_tree_key_type<__value_type<_Key, _ValueT> > { |
| 527 | typedef _Key key_type; | 515 | using type _LIBCPP_NODEBUG = _Key; |
| 528 | typedef _Tp mapped_type; | ||
| 529 | typedef __value_type<_Key, _Tp> __node_value_type; | ||
| 530 | typedef pair<const _Key, _Tp> __container_value_type; | ||
| 531 | typedef __container_value_type __map_value_type; | ||
| 532 | static const bool __is_map = true; | ||
| 533 | |||
| 534 | _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__node_value_type const& __t) { | ||
| 535 | return __t.__get_value().first; | ||
| 536 | } | ||
| 537 | |||
| 538 | template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0> | ||
| 539 | _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Up& __t) { | ||
| 540 | return __t.first; | ||
| 541 | } | ||
| 542 | |||
| 543 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __t) { | ||
| 544 | return __t.__get_value(); | ||
| 545 | } | ||
| 546 | |||
| 547 | template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0> | ||
| 548 | _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { | ||
| 549 | return __t; | ||
| 550 | } | ||
| 551 | |||
| 552 | _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { | ||
| 553 | return std::addressof(__n.__get_value()); | ||
| 554 | } | ||
| 555 | |||
| 556 | _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); } | ||
| 557 | }; | 516 | }; |
| 558 | 517 | ||
| 559 | template <class _VoidPtr> | 518 | template <class _Tp> |
| 560 | struct __tree_node_base_types { | 519 | using __get_tree_key_type_t _LIBCPP_NODEBUG = typename __get_tree_key_type<_Tp>::type; |
| 561 | typedef _VoidPtr __void_pointer; | ||
| 562 | |||
| 563 | typedef __tree_node_base<__void_pointer> __node_base_type; | ||
| 564 | typedef __rebind_pointer_t<_VoidPtr, __node_base_type> __node_base_pointer; | ||
| 565 | |||
| 566 | typedef __tree_end_node<__node_base_pointer> __end_node_type; | ||
| 567 | typedef __rebind_pointer_t<_VoidPtr, __end_node_type> __end_node_pointer; | ||
| 568 | typedef __end_node_pointer __parent_pointer; | ||
| 569 | |||
| 570 | // TODO(LLVM 22): Remove this check | ||
| 571 | #ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | ||
| 572 | static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == | ||
| 573 | _LIBCPP_ALIGNOF(__end_node_pointer), | ||
| 574 | "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy " | ||
| 575 | "pointer type that thas a different representation depending on whether it points to a __tree base " | ||
| 576 | "pointer or a __tree node pointer (both of which are implementation details of the standard library). " | ||
| 577 | "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your " | ||
| 578 | "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this " | ||
| 579 | "diagnostic."); | ||
| 580 | #endif | ||
| 581 | 520 | ||
| 582 | private: | 521 | template <class _Tp> |
| 583 | static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value, | 522 | struct __get_node_value_type { |
| 584 | "_VoidPtr does not point to unqualified void type"); | 523 | using type _LIBCPP_NODEBUG = _Tp; |
| 585 | }; | 524 | }; |
| 586 | 525 | ||
| 587 | template <class _Tp, class _AllocPtr, class _KVTypes = __tree_key_value_types<_Tp>, bool = _KVTypes::__is_map> | 526 | template <class _Key, class _ValueT> |
| 588 | struct __tree_map_pointer_types {}; | 527 | struct __get_node_value_type<__value_type<_Key, _ValueT> > { |
| 589 | 528 | using type _LIBCPP_NODEBUG = pair<const _Key, _ValueT>; | |
| 590 | template <class _Tp, class _AllocPtr, class _KVTypes> | ||
| 591 | struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> { | ||
| 592 | typedef typename _KVTypes::__map_value_type _Mv; | ||
| 593 | typedef __rebind_pointer_t<_AllocPtr, _Mv> __map_value_type_pointer; | ||
| 594 | typedef __rebind_pointer_t<_AllocPtr, const _Mv> __const_map_value_type_pointer; | ||
| 595 | }; | 529 | }; |
| 596 | 530 | ||
| 531 | template <class _Tp> | ||
| 532 | using __get_node_value_type_t _LIBCPP_NODEBUG = typename __get_node_value_type<_Tp>::type; | ||
| 533 | |||
| 597 | template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type> | 534 | template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type> |
| 598 | struct __tree_node_types; | 535 | struct __tree_node_types; |
| 599 | 536 | ||
| 600 | template <class _NodePtr, class _Tp, class _VoidPtr> | 537 | template <class _NodePtr, class _Tp, class _VoidPtr> |
| 601 | struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> > | 538 | struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> > { |
| 602 | : public __tree_node_base_types<_VoidPtr>, __tree_key_value_types<_Tp>, __tree_map_pointer_types<_Tp, _VoidPtr> { | 539 | using __node_base_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_node_base<_VoidPtr> >; |
| 603 | typedef __tree_node_base_types<_VoidPtr> __base; | 540 | using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_end_node<__node_base_pointer> >; |
| 604 | typedef __tree_key_value_types<_Tp> __key_base; | ||
| 605 | typedef __tree_map_pointer_types<_Tp, _VoidPtr> __map_pointer_base; | ||
| 606 | |||
| 607 | public: | ||
| 608 | typedef typename pointer_traits<_NodePtr>::element_type __node_type; | ||
| 609 | typedef _NodePtr __node_pointer; | ||
| 610 | |||
| 611 | typedef _Tp __node_value_type; | ||
| 612 | typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer; | ||
| 613 | typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer; | ||
| 614 | typedef typename __base::__end_node_pointer __iter_pointer; | ||
| 615 | 541 | ||
| 616 | private: | 542 | private: |
| 617 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); | 543 | static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value, |
| 618 | static_assert(is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value, | 544 | "_VoidPtr does not point to unqualified void type"); |
| 619 | "_VoidPtr does not rebind to _NodePtr."); | ||
| 620 | }; | ||
| 621 | |||
| 622 | template <class _ValueTp, class _VoidPtr> | ||
| 623 | struct __make_tree_node_types { | ||
| 624 | typedef __rebind_pointer_t<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> > _NodePtr; | ||
| 625 | typedef __tree_node_types<_NodePtr> type; | ||
| 626 | }; | 545 | }; |
| 627 | 546 | ||
| 628 | // node | 547 | // node |
| ... | @@ -637,20 +556,19 @@ public: | ... | @@ -637,20 +556,19 @@ public: |
| 637 | }; | 556 | }; |
| 638 | 557 | ||
| 639 | template <class _VoidPtr> | 558 | template <class _VoidPtr> |
| 640 | class _LIBCPP_STANDALONE_DEBUG __tree_node_base : public __tree_node_base_types<_VoidPtr>::__end_node_type { | 559 | class _LIBCPP_STANDALONE_DEBUG |
| 641 | typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes; | 560 | __tree_node_base : public __tree_end_node<__rebind_pointer_t<_VoidPtr, __tree_node_base<_VoidPtr> > > { |
| 642 | |||
| 643 | public: | 561 | public: |
| 644 | typedef typename _NodeBaseTypes::__node_base_pointer pointer; | 562 | using pointer = __rebind_pointer_t<_VoidPtr, __tree_node_base>; |
| 645 | typedef typename _NodeBaseTypes::__parent_pointer __parent_pointer; | 563 | using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_end_node<pointer> >; |
| 646 | 564 | ||
| 647 | pointer __right_; | 565 | pointer __right_; |
| 648 | __parent_pointer __parent_; | 566 | __end_node_pointer __parent_; |
| 649 | bool __is_black_; | 567 | bool __is_black_; |
| 650 | 568 | ||
| 651 | _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast<pointer>(__parent_); } | 569 | _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast<pointer>(__parent_); } |
| 652 | 570 | ||
| 653 | _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); } | 571 | _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__end_node_pointer>(__p); } |
| 654 | 572 | ||
| 655 | ~__tree_node_base() = delete; | 573 | ~__tree_node_base() = delete; |
| 656 | __tree_node_base(__tree_node_base const&) = delete; | 574 | __tree_node_base(__tree_node_base const&) = delete; |
| ... | @@ -660,11 +578,11 @@ public: | ... | @@ -660,11 +578,11 @@ public: |
| 660 | template <class _Tp, class _VoidPtr> | 578 | template <class _Tp, class _VoidPtr> |
| 661 | class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> { | 579 | class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> { |
| 662 | public: | 580 | public: |
| 663 | typedef _Tp __node_value_type; | 581 | using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>; |
| 664 | 582 | ||
| 665 | __node_value_type __value_; | 583 | __node_value_type __value_; |
| 666 | 584 | ||
| 667 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } | 585 | _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; } |
| 668 | 586 | ||
| 669 | ~__tree_node() = delete; | 587 | ~__tree_node() = delete; |
| 670 | __tree_node(__tree_node const&) = delete; | 588 | __tree_node(__tree_node const&) = delete; |
| ... | @@ -680,7 +598,6 @@ public: | ... | @@ -680,7 +598,6 @@ public: |
| 680 | typedef typename __alloc_traits::pointer pointer; | 598 | typedef typename __alloc_traits::pointer pointer; |
| 681 | 599 | ||
| 682 | private: | 600 | private: |
| 683 | typedef __tree_node_types<pointer> _NodeTypes; | ||
| 684 | allocator_type& __na_; | 601 | allocator_type& __na_; |
| 685 | 602 | ||
| 686 | public: | 603 | public: |
| ... | @@ -695,7 +612,7 @@ public: | ... | @@ -695,7 +612,7 @@ public: |
| 695 | 612 | ||
| 696 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { | 613 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 697 | if (__value_constructed) | 614 | if (__value_constructed) |
| 698 | __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_)); | 615 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_)); |
| 699 | if (__p) | 616 | if (__p) |
| 700 | __alloc_traits::deallocate(__na_, __p, 1); | 617 | __alloc_traits::deallocate(__na_, __p, 1); |
| 701 | } | 618 | } |
| ... | @@ -714,22 +631,20 @@ struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> : | ... | @@ -714,22 +631,20 @@ struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> : |
| 714 | #endif | 631 | #endif |
| 715 | 632 | ||
| 716 | template <class _Tp, class _NodePtr, class _DiffType> | 633 | template <class _Tp, class _NodePtr, class _DiffType> |
| 717 | class _LIBCPP_TEMPLATE_VIS __tree_iterator { | 634 | class __tree_iterator { |
| 718 | typedef __tree_node_types<_NodePtr> _NodeTypes; | 635 | typedef __tree_node_types<_NodePtr> _NodeTypes; |
| 719 | typedef _NodePtr __node_pointer; | 636 | typedef _NodePtr __node_pointer; |
| 720 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; | 637 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; |
| 721 | typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; | 638 | typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; |
| 722 | typedef typename _NodeTypes::__iter_pointer __iter_pointer; | ||
| 723 | typedef pointer_traits<__node_pointer> __pointer_traits; | ||
| 724 | 639 | ||
| 725 | __iter_pointer __ptr_; | 640 | __end_node_pointer __ptr_; |
| 726 | 641 | ||
| 727 | public: | 642 | public: |
| 728 | typedef bidirectional_iterator_tag iterator_category; | 643 | using iterator_category = bidirectional_iterator_tag; |
| 729 | typedef _Tp value_type; | 644 | using value_type = __get_node_value_type_t<_Tp>; |
| 730 | typedef _DiffType difference_type; | 645 | using difference_type = _DiffType; |
| 731 | typedef value_type& reference; | 646 | using reference = value_type&; |
| 732 | typedef typename _NodeTypes::__node_value_type_pointer pointer; | 647 | using pointer = __rebind_pointer_t<_NodePtr, value_type>; |
| 733 | 648 | ||
| 734 | _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT | 649 | _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT |
| 735 | #if _LIBCPP_STD_VER >= 14 | 650 | #if _LIBCPP_STD_VER >= 14 |
| ... | @@ -742,8 +657,7 @@ public: | ... | @@ -742,8 +657,7 @@ public: |
| 742 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); } | 657 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); } |
| 743 | 658 | ||
| 744 | _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() { | 659 | _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() { |
| 745 | __ptr_ = static_cast<__iter_pointer>( | 660 | __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)); |
| 746 | std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_))); | ||
| 747 | return *this; | 661 | return *this; |
| 748 | } | 662 | } |
| 749 | _LIBCPP_HIDE_FROM_ABI __tree_iterator operator++(int) { | 663 | _LIBCPP_HIDE_FROM_ABI __tree_iterator operator++(int) { |
| ... | @@ -753,8 +667,7 @@ public: | ... | @@ -753,8 +667,7 @@ public: |
| 753 | } | 667 | } |
| 754 | 668 | ||
| 755 | _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator--() { | 669 | _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator--() { |
| 756 | __ptr_ = static_cast<__iter_pointer>( | 670 | __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_)); |
| 757 | std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_pointer>(__ptr_))); | ||
| 758 | return *this; | 671 | return *this; |
| 759 | } | 672 | } |
| 760 | _LIBCPP_HIDE_FROM_ABI __tree_iterator operator--(int) { | 673 | _LIBCPP_HIDE_FROM_ABI __tree_iterator operator--(int) { |
| ... | @@ -777,36 +690,35 @@ private: | ... | @@ -777,36 +690,35 @@ private: |
| 777 | template <class, class, class> | 690 | template <class, class, class> |
| 778 | friend class __tree; | 691 | friend class __tree; |
| 779 | template <class, class, class> | 692 | template <class, class, class> |
| 780 | friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; | 693 | friend class __tree_const_iterator; |
| 781 | template <class> | 694 | template <class> |
| 782 | friend class _LIBCPP_TEMPLATE_VIS __map_iterator; | 695 | friend class __map_iterator; |
| 783 | template <class, class, class, class> | 696 | template <class, class, class, class> |
| 784 | friend class _LIBCPP_TEMPLATE_VIS map; | 697 | friend class map; |
| 785 | template <class, class, class, class> | 698 | template <class, class, class, class> |
| 786 | friend class _LIBCPP_TEMPLATE_VIS multimap; | 699 | friend class multimap; |
| 787 | template <class, class, class> | 700 | template <class, class, class> |
| 788 | friend class _LIBCPP_TEMPLATE_VIS set; | 701 | friend class set; |
| 789 | template <class, class, class> | 702 | template <class, class, class> |
| 790 | friend class _LIBCPP_TEMPLATE_VIS multiset; | 703 | friend class multiset; |
| 791 | }; | 704 | }; |
| 792 | 705 | ||
| 793 | template <class _Tp, class _NodePtr, class _DiffType> | 706 | template <class _Tp, class _NodePtr, class _DiffType> |
| 794 | class _LIBCPP_TEMPLATE_VIS __tree_const_iterator { | 707 | class __tree_const_iterator { |
| 795 | typedef __tree_node_types<_NodePtr> _NodeTypes; | 708 | typedef __tree_node_types<_NodePtr> _NodeTypes; |
| 796 | typedef typename _NodeTypes::__node_pointer __node_pointer; | 709 | // NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing |
| 710 | using __node_pointer = _NodePtr; | ||
| 797 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; | 711 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; |
| 798 | typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; | 712 | typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; |
| 799 | typedef typename _NodeTypes::__iter_pointer __iter_pointer; | ||
| 800 | typedef pointer_traits<__node_pointer> __pointer_traits; | ||
| 801 | 713 | ||
| 802 | __iter_pointer __ptr_; | 714 | __end_node_pointer __ptr_; |
| 803 | 715 | ||
| 804 | public: | 716 | public: |
| 805 | typedef bidirectional_iterator_tag iterator_category; | 717 | using iterator_category = bidirectional_iterator_tag; |
| 806 | typedef _Tp value_type; | 718 | using value_type = __get_node_value_type_t<_Tp>; |
| 807 | typedef _DiffType difference_type; | 719 | using difference_type = _DiffType; |
| 808 | typedef const value_type& reference; | 720 | using reference = const value_type&; |
| 809 | typedef typename _NodeTypes::__const_node_value_type_pointer pointer; | 721 | using pointer = __rebind_pointer_t<_NodePtr, const value_type>; |
| 810 | 722 | ||
| 811 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT | 723 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT |
| 812 | #if _LIBCPP_STD_VER >= 14 | 724 | #if _LIBCPP_STD_VER >= 14 |
| ... | @@ -816,7 +728,7 @@ public: | ... | @@ -816,7 +728,7 @@ public: |
| 816 | } | 728 | } |
| 817 | 729 | ||
| 818 | private: | 730 | private: |
| 819 | typedef __tree_iterator<value_type, __node_pointer, difference_type> __non_const_iterator; | 731 | typedef __tree_iterator<_Tp, __node_pointer, difference_type> __non_const_iterator; |
| 820 | 732 | ||
| 821 | public: | 733 | public: |
| 822 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} | 734 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} |
| ... | @@ -825,8 +737,7 @@ public: | ... | @@ -825,8 +737,7 @@ public: |
| 825 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); } | 737 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); } |
| 826 | 738 | ||
| 827 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() { | 739 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() { |
| 828 | __ptr_ = static_cast<__iter_pointer>( | 740 | __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)); |
| 829 | std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_))); | ||
| 830 | return *this; | 741 | return *this; |
| 831 | } | 742 | } |
| 832 | 743 | ||
| ... | @@ -837,8 +748,7 @@ public: | ... | @@ -837,8 +748,7 @@ public: |
| 837 | } | 748 | } |
| 838 | 749 | ||
| 839 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator--() { | 750 | _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator--() { |
| 840 | __ptr_ = static_cast<__iter_pointer>( | 751 | __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_)); |
| 841 | std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_pointer>(__ptr_))); | ||
| 842 | return *this; | 752 | return *this; |
| 843 | } | 753 | } |
| 844 | 754 | ||
| ... | @@ -863,15 +773,15 @@ private: | ... | @@ -863,15 +773,15 @@ private: |
| 863 | template <class, class, class> | 773 | template <class, class, class> |
| 864 | friend class __tree; | 774 | friend class __tree; |
| 865 | template <class, class, class, class> | 775 | template <class, class, class, class> |
| 866 | friend class _LIBCPP_TEMPLATE_VIS map; | 776 | friend class map; |
| 867 | template <class, class, class, class> | 777 | template <class, class, class, class> |
| 868 | friend class _LIBCPP_TEMPLATE_VIS multimap; | 778 | friend class multimap; |
| 869 | template <class, class, class> | 779 | template <class, class, class> |
| 870 | friend class _LIBCPP_TEMPLATE_VIS set; | 780 | friend class set; |
| 871 | template <class, class, class> | 781 | template <class, class, class> |
| 872 | friend class _LIBCPP_TEMPLATE_VIS multiset; | 782 | friend class multiset; |
| 873 | template <class> | 783 | template <class> |
| 874 | friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; | 784 | friend class __map_const_iterator; |
| 875 | }; | 785 | }; |
| 876 | 786 | ||
| 877 | template <class _Tp, class _Compare> | 787 | template <class _Tp, class _Compare> |
| ... | @@ -884,42 +794,50 @@ int __diagnose_non_const_comparator(); | ... | @@ -884,42 +794,50 @@ int __diagnose_non_const_comparator(); |
| 884 | template <class _Tp, class _Compare, class _Allocator> | 794 | template <class _Tp, class _Compare, class _Allocator> |
| 885 | class __tree { | 795 | class __tree { |
| 886 | public: | 796 | public: |
| 887 | typedef _Tp value_type; | 797 | using value_type = __get_node_value_type_t<_Tp>; |
| 888 | typedef _Compare value_compare; | 798 | typedef _Compare value_compare; |
| 889 | typedef _Allocator allocator_type; | 799 | typedef _Allocator allocator_type; |
| 890 | 800 | ||
| 891 | private: | 801 | private: |
| 892 | typedef allocator_traits<allocator_type> __alloc_traits; | 802 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 893 | typedef typename __make_tree_node_types<value_type, typename __alloc_traits::void_pointer>::type _NodeTypes; | 803 | using key_type = __get_tree_key_type_t<_Tp>; |
| 894 | typedef typename _NodeTypes::key_type key_type; | ||
| 895 | 804 | ||
| 896 | public: | 805 | public: |
| 897 | typedef typename _NodeTypes::__node_value_type __node_value_type; | ||
| 898 | typedef typename _NodeTypes::__container_value_type __container_value_type; | ||
| 899 | |||
| 900 | typedef typename __alloc_traits::pointer pointer; | 806 | typedef typename __alloc_traits::pointer pointer; |
| 901 | typedef typename __alloc_traits::const_pointer const_pointer; | 807 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 902 | typedef typename __alloc_traits::size_type size_type; | 808 | typedef typename __alloc_traits::size_type size_type; |
| 903 | typedef typename __alloc_traits::difference_type difference_type; | 809 | typedef typename __alloc_traits::difference_type difference_type; |
| 904 | 810 | ||
| 905 | public: | 811 | public: |
| 906 | typedef typename _NodeTypes::__void_pointer __void_pointer; | 812 | using __void_pointer _LIBCPP_NODEBUG = typename __alloc_traits::void_pointer; |
| 907 | 813 | ||
| 908 | typedef typename _NodeTypes::__node_type __node; | 814 | using __node _LIBCPP_NODEBUG = __tree_node<_Tp, __void_pointer>; |
| 909 | typedef typename _NodeTypes::__node_pointer __node_pointer; | 815 | // NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing |
| 816 | using __node_pointer = __rebind_pointer_t<__void_pointer, __node>; | ||
| 910 | 817 | ||
| 911 | typedef typename _NodeTypes::__node_base_type __node_base; | 818 | using __node_base _LIBCPP_NODEBUG = __tree_node_base<__void_pointer>; |
| 912 | typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; | 819 | using __node_base_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __node_base>; |
| 913 | 820 | ||
| 914 | typedef typename _NodeTypes::__end_node_type __end_node_t; | 821 | using __end_node_t _LIBCPP_NODEBUG = __tree_end_node<__node_base_pointer>; |
| 915 | typedef typename _NodeTypes::__end_node_pointer __end_node_ptr; | 822 | using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __end_node_t>; |
| 916 | 823 | ||
| 917 | typedef typename _NodeTypes::__parent_pointer __parent_pointer; | 824 | using __parent_pointer _LIBCPP_NODEBUG = __end_node_pointer; // TODO: Remove this once the uses in <map> are removed |
| 918 | typedef typename _NodeTypes::__iter_pointer __iter_pointer; | ||
| 919 | 825 | ||
| 920 | typedef __rebind_alloc<__alloc_traits, __node> __node_allocator; | 826 | typedef __rebind_alloc<__alloc_traits, __node> __node_allocator; |
| 921 | typedef allocator_traits<__node_allocator> __node_traits; | 827 | typedef allocator_traits<__node_allocator> __node_traits; |
| 922 | 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 | |||
| 923 | private: | 841 | private: |
| 924 | // check for sane allocator pointer rebinding semantics. Rebinding the | 842 | // check for sane allocator pointer rebinding semantics. Rebinding the |
| 925 | // allocator for a new pointer type should be exactly the same as rebinding | 843 | // allocator for a new pointer type should be exactly the same as rebinding |
| ... | @@ -932,24 +850,23 @@ private: | ... | @@ -932,24 +850,23 @@ private: |
| 932 | "Allocator does not rebind pointers in a sane manner."); | 850 | "Allocator does not rebind pointers in a sane manner."); |
| 933 | 851 | ||
| 934 | private: | 852 | private: |
| 935 | __iter_pointer __begin_node_; | 853 | __end_node_pointer __begin_node_; |
| 936 | _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_); | 854 | _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_); |
| 937 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_); | 855 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_); |
| 938 | 856 | ||
| 939 | public: | 857 | public: |
| 940 | _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT { | 858 | _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() _NOEXCEPT { |
| 941 | return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__end_node_)); | 859 | return pointer_traits<__end_node_pointer>::pointer_to(__end_node_); |
| 942 | } | 860 | } |
| 943 | _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT { | 861 | _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() const _NOEXCEPT { |
| 944 | return static_cast<__iter_pointer>( | 862 | return pointer_traits<__end_node_pointer>::pointer_to(const_cast<__end_node_t&>(__end_node_)); |
| 945 | pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__end_node_))); | ||
| 946 | } | 863 | } |
| 947 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; } | 864 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; } |
| 948 | 865 | ||
| 949 | private: | 866 | private: |
| 950 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } | 867 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } |
| 951 | _LIBCPP_HIDE_FROM_ABI __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; } | 868 | _LIBCPP_HIDE_FROM_ABI __end_node_pointer& __begin_node() _NOEXCEPT { return __begin_node_; } |
| 952 | _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } | 869 | _LIBCPP_HIDE_FROM_ABI const __end_node_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } |
| 953 | 870 | ||
| 954 | public: | 871 | public: |
| 955 | _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } | 872 | _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } |
| ... | @@ -971,8 +888,8 @@ public: | ... | @@ -971,8 +888,8 @@ public: |
| 971 | return std::addressof(__end_node()->__left_); | 888 | return std::addressof(__end_node()->__left_); |
| 972 | } | 889 | } |
| 973 | 890 | ||
| 974 | typedef __tree_iterator<value_type, __node_pointer, difference_type> iterator; | 891 | typedef __tree_iterator<_Tp, __node_pointer, difference_type> iterator; |
| 975 | typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator; | 892 | typedef __tree_const_iterator<_Tp, __node_pointer, difference_type> const_iterator; |
| 976 | 893 | ||
| 977 | _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_( | 894 | _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_( |
| 978 | is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value); | 895 | is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value); |
| ... | @@ -987,9 +904,12 @@ public: | ... | @@ -987,9 +904,12 @@ public: |
| 987 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_( | 904 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_( |
| 988 | is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value); | 905 | is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value); |
| 989 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a); | 906 | _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a); |
| 990 | _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t) _NOEXCEPT_( | 907 | _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t) |
| 991 | __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<value_compare>::value&& | 908 | _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value && |
| 992 | is_nothrow_move_assignable<__node_allocator>::value); | 909 | ((__node_traits::propagate_on_container_move_assignment::value && |
| 910 | is_nothrow_move_assignable<__node_allocator>::value) || | ||
| 911 | allocator_traits<__node_allocator>::is_always_equal::value)); | ||
| 912 | |||
| 993 | _LIBCPP_HIDE_FROM_ABI ~__tree(); | 913 | _LIBCPP_HIDE_FROM_ABI ~__tree(); |
| 994 | 914 | ||
| 995 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node()); } | 915 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node()); } |
| ... | @@ -1035,7 +955,7 @@ public: | ... | @@ -1035,7 +955,7 @@ public: |
| 1035 | 955 | ||
| 1036 | template <class _First, | 956 | template <class _First, |
| 1037 | class _Second, | 957 | class _Second, |
| 1038 | __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0> | 958 | __enable_if_t<__can_extract_map_key<_First, key_type, value_type>::value, int> = 0> |
| 1039 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) { | 959 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) { |
| 1040 | return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s)); | 960 | return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s)); |
| 1041 | } | 961 | } |
| ... | @@ -1067,7 +987,7 @@ public: | ... | @@ -1067,7 +987,7 @@ public: |
| 1067 | 987 | ||
| 1068 | template <class _First, | 988 | template <class _First, |
| 1069 | class _Second, | 989 | class _Second, |
| 1070 | __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0> | 990 | __enable_if_t<__can_extract_map_key<_First, key_type, value_type>::value, int> = 0> |
| 1071 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { | 991 | _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { |
| 1072 | return __emplace_hint_unique_key_args(__p, __f, std::forward<_First>(__f), std::forward<_Second>(__s)).first; | 992 | return __emplace_hint_unique_key_args(__p, __f, std::forward<_First>(__f), std::forward<_Second>(__s)).first; |
| 1073 | } | 993 | } |
| ... | @@ -1095,52 +1015,28 @@ public: | ... | @@ -1095,52 +1015,28 @@ public: |
| 1095 | return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first; | 1015 | return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first; |
| 1096 | } | 1016 | } |
| 1097 | 1017 | ||
| 1098 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(const __container_value_type& __v) { | 1018 | template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0> |
| 1099 | return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v); | 1019 | _LIBCPP_HIDE_FROM_ABI void |
| 1100 | } | 1020 | __insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) { |
| 1101 | 1021 | __emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second)); | |
| 1102 | _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, const __container_value_type& __v) { | ||
| 1103 | return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v).first; | ||
| 1104 | } | ||
| 1105 | |||
| 1106 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(__container_value_type&& __v) { | ||
| 1107 | return __emplace_unique_key_args(_NodeTypes::__get_key(__v), std::move(__v)); | ||
| 1108 | } | ||
| 1109 | |||
| 1110 | _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, __container_value_type&& __v) { | ||
| 1111 | return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), std::move(__v)).first; | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0> | ||
| 1115 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Vp&& __v) { | ||
| 1116 | return __emplace_unique(std::forward<_Vp>(__v)); | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0> | ||
| 1120 | _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, _Vp&& __v) { | ||
| 1121 | return __emplace_hint_unique(__p, std::forward<_Vp>(__v)); | ||
| 1122 | } | ||
| 1123 | |||
| 1124 | _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(__container_value_type&& __v) { | ||
| 1125 | return __emplace_multi(std::move(__v)); | ||
| 1126 | } | 1022 | } |
| 1127 | 1023 | ||
| 1128 | _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, __container_value_type&& __v) { | 1024 | template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0> |
| 1129 | return __emplace_hint_multi(__p, std::move(__v)); | 1025 | _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) { |
| 1026 | __emplace_hint_unique(__p, std::move(__value)); | ||
| 1130 | } | 1027 | } |
| 1131 | 1028 | ||
| 1132 | template <class _Vp> | 1029 | template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0> |
| 1133 | _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(_Vp&& __v) { | 1030 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) { |
| 1134 | return __emplace_multi(std::forward<_Vp>(__v)); | 1031 | __emplace_hint_multi(__p, const_cast<key_type&&>(__value.first), std::move(__value.second)); |
| 1135 | } | 1032 | } |
| 1136 | 1033 | ||
| 1137 | template <class _Vp> | 1034 | template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0> |
| 1138 | _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, _Vp&& __v) { | 1035 | _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) { |
| 1139 | return __emplace_hint_multi(__p, std::forward<_Vp>(__v)); | 1036 | __emplace_hint_multi(__p, std::move(__value)); |
| 1140 | } | 1037 | } |
| 1141 | 1038 | ||
| 1142 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> | 1039 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __node_assign_unique(const value_type& __v, __node_pointer __dest); |
| 1143 | __node_assign_unique(const __container_value_type& __v, __node_pointer __dest); | ||
| 1144 | 1040 | ||
| 1145 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd); | 1041 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd); |
| 1146 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); | 1042 | _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); |
| ... | @@ -1176,7 +1072,7 @@ public: | ... | @@ -1176,7 +1072,7 @@ public: |
| 1176 | _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k); | 1072 | _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k); |
| 1177 | 1073 | ||
| 1178 | _LIBCPP_HIDE_FROM_ABI void | 1074 | _LIBCPP_HIDE_FROM_ABI void |
| 1179 | __insert_node_at(__parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT; | 1075 | __insert_node_at(__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT; |
| 1180 | 1076 | ||
| 1181 | template <class _Key> | 1077 | template <class _Key> |
| 1182 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __v); | 1078 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __v); |
| ... | @@ -1193,27 +1089,27 @@ public: | ... | @@ -1193,27 +1089,27 @@ public: |
| 1193 | return __lower_bound(__v, __root(), __end_node()); | 1089 | return __lower_bound(__v, __root(), __end_node()); |
| 1194 | } | 1090 | } |
| 1195 | template <class _Key> | 1091 | template <class _Key> |
| 1196 | _LIBCPP_HIDE_FROM_ABI iterator __lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result); | 1092 | _LIBCPP_HIDE_FROM_ABI iterator __lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result); |
| 1197 | template <class _Key> | 1093 | template <class _Key> |
| 1198 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Key& __v) const { | 1094 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Key& __v) const { |
| 1199 | return __lower_bound(__v, __root(), __end_node()); | 1095 | return __lower_bound(__v, __root(), __end_node()); |
| 1200 | } | 1096 | } |
| 1201 | template <class _Key> | 1097 | template <class _Key> |
| 1202 | _LIBCPP_HIDE_FROM_ABI const_iterator | 1098 | _LIBCPP_HIDE_FROM_ABI const_iterator |
| 1203 | __lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) const; | 1099 | __lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const; |
| 1204 | template <class _Key> | 1100 | template <class _Key> |
| 1205 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Key& __v) { | 1101 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Key& __v) { |
| 1206 | return __upper_bound(__v, __root(), __end_node()); | 1102 | return __upper_bound(__v, __root(), __end_node()); |
| 1207 | } | 1103 | } |
| 1208 | template <class _Key> | 1104 | template <class _Key> |
| 1209 | _LIBCPP_HIDE_FROM_ABI iterator __upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result); | 1105 | _LIBCPP_HIDE_FROM_ABI iterator __upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result); |
| 1210 | template <class _Key> | 1106 | template <class _Key> |
| 1211 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Key& __v) const { | 1107 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Key& __v) const { |
| 1212 | return __upper_bound(__v, __root(), __end_node()); | 1108 | return __upper_bound(__v, __root(), __end_node()); |
| 1213 | } | 1109 | } |
| 1214 | template <class _Key> | 1110 | template <class _Key> |
| 1215 | _LIBCPP_HIDE_FROM_ABI const_iterator | 1111 | _LIBCPP_HIDE_FROM_ABI const_iterator |
| 1216 | __upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) const; | 1112 | __upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const; |
| 1217 | template <class _Key> | 1113 | template <class _Key> |
| 1218 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k); | 1114 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k); |
| 1219 | template <class _Key> | 1115 | template <class _Key> |
| ... | @@ -1229,28 +1125,17 @@ public: | ... | @@ -1229,28 +1125,17 @@ public: |
| 1229 | 1125 | ||
| 1230 | _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT; | 1126 | _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT; |
| 1231 | 1127 | ||
| 1232 | private: | ||
| 1233 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__parent_pointer& __parent, const key_type& __v); | ||
| 1234 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__parent_pointer& __parent, const key_type& __v); | ||
| 1235 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& | ||
| 1236 | __find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v); | ||
| 1237 | // FIXME: Make this function const qualified. Unfortunately doing so | 1128 | // FIXME: Make this function const qualified. Unfortunately doing so |
| 1238 | // breaks existing code which uses non-const callable comparators. | 1129 | // breaks existing code which uses non-const callable comparators. |
| 1239 | template <class _Key> | 1130 | template <class _Key> |
| 1240 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v); | 1131 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__end_node_pointer& __parent, const _Key& __v); |
| 1241 | template <class _Key> | 1132 | template <class _Key> |
| 1242 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v) const { | 1133 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__end_node_pointer& __parent, const _Key& __v) const { |
| 1243 | return const_cast<__tree*>(this)->__find_equal(__parent, __v); | 1134 | return const_cast<__tree*>(this)->__find_equal(__parent, __v); |
| 1244 | } | 1135 | } |
| 1245 | template <class _Key> | 1136 | template <class _Key> |
| 1246 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& | 1137 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& |
| 1247 | __find_equal(const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v); | 1138 | __find_equal(const_iterator __hint, __end_node_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v); |
| 1248 | |||
| 1249 | template <class... _Args> | ||
| 1250 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args); | ||
| 1251 | |||
| 1252 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI | ||
| 1253 | _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT; | ||
| 1254 | 1139 | ||
| 1255 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) { | 1140 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) { |
| 1256 | __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); | 1141 | __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); |
| ... | @@ -1263,6 +1148,20 @@ private: | ... | @@ -1263,6 +1148,20 @@ private: |
| 1263 | } | 1148 | } |
| 1264 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {} | 1149 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {} |
| 1265 | 1150 | ||
| 1151 | private: | ||
| 1152 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__end_node_pointer& __parent, const value_type& __v); | ||
| 1153 | |||
| 1154 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__end_node_pointer& __parent, const value_type& __v); | ||
| 1155 | |||
| 1156 | _LIBCPP_HIDE_FROM_ABI __node_base_pointer& | ||
| 1157 | __find_leaf(const_iterator __hint, __end_node_pointer& __parent, const value_type& __v); | ||
| 1158 | |||
| 1159 | template <class... _Args> | ||
| 1160 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args); | ||
| 1161 | |||
| 1162 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI | ||
| 1163 | _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT; | ||
| 1164 | |||
| 1266 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type); | 1165 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type); |
| 1267 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_( | 1166 | _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_( |
| 1268 | is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value); | 1167 | is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value); |
| ... | @@ -1279,6 +1178,21 @@ private: | ... | @@ -1279,6 +1178,21 @@ private: |
| 1279 | } | 1178 | } |
| 1280 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} | 1179 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} |
| 1281 | 1180 | ||
| 1181 | template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0> | ||
| 1182 | _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) { | ||
| 1183 | using __key_type = __remove_const_t<typename value_type::first_type>; | ||
| 1184 | |||
| 1185 | // This is technically UB, since the object was constructed as `const`. | ||
| 1186 | // Clang doesn't optimize on this currently though. | ||
| 1187 | const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first); | ||
| 1188 | __lhs.second = std::forward<_From>(__rhs).second; | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0> | ||
| 1192 | _LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) { | ||
| 1193 | __lhs = std::forward<_From>(__rhs); | ||
| 1194 | } | ||
| 1195 | |||
| 1282 | struct _DetachedTreeCache { | 1196 | struct _DetachedTreeCache { |
| 1283 | _LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT | 1197 | _LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT |
| 1284 | : __t_(__t), | 1198 | : __t_(__t), |
| ... | @@ -1315,11 +1229,6 @@ private: | ... | @@ -1315,11 +1229,6 @@ private: |
| 1315 | __node_pointer __cache_root_; | 1229 | __node_pointer __cache_root_; |
| 1316 | __node_pointer __cache_elem_; | 1230 | __node_pointer __cache_elem_; |
| 1317 | }; | 1231 | }; |
| 1318 | |||
| 1319 | template <class, class, class, class> | ||
| 1320 | friend class _LIBCPP_TEMPLATE_VIS map; | ||
| 1321 | template <class, class, class, class> | ||
| 1322 | friend class _LIBCPP_TEMPLATE_VIS multimap; | ||
| 1323 | }; | 1232 | }; |
| 1324 | 1233 | ||
| 1325 | template <class _Tp, class _Compare, class _Allocator> | 1234 | template <class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1331,13 +1240,13 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT | ... | @@ -1331,13 +1240,13 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT |
| 1331 | 1240 | ||
| 1332 | template <class _Tp, class _Compare, class _Allocator> | 1241 | template <class _Tp, class _Compare, class _Allocator> |
| 1333 | __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) | 1242 | __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) |
| 1334 | : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0) { | 1243 | : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) { |
| 1335 | __begin_node() = __end_node(); | 1244 | __begin_node() = __end_node(); |
| 1336 | } | 1245 | } |
| 1337 | 1246 | ||
| 1338 | template <class _Tp, class _Compare, class _Allocator> | 1247 | template <class _Tp, class _Compare, class _Allocator> |
| 1339 | __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) | 1248 | __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) |
| 1340 | : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) { | 1249 | : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) { |
| 1341 | __begin_node() = __end_node(); | 1250 | __begin_node() = __end_node(); |
| 1342 | } | 1251 | } |
| 1343 | 1252 | ||
| ... | @@ -1397,8 +1306,8 @@ template <class _ForwardIterator> | ... | @@ -1397,8 +1306,8 @@ template <class _ForwardIterator> |
| 1397 | void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) { | 1306 | void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) { |
| 1398 | typedef iterator_traits<_ForwardIterator> _ITraits; | 1307 | typedef iterator_traits<_ForwardIterator> _ITraits; |
| 1399 | typedef typename _ITraits::value_type _ItValueType; | 1308 | typedef typename _ITraits::value_type _ItValueType; |
| 1400 | static_assert(is_same<_ItValueType, __container_value_type>::value, | 1309 | static_assert( |
| 1401 | "__assign_unique may only be called with the containers value type"); | 1310 | is_same<_ItValueType, value_type>::value, "__assign_unique may only be called with the containers value type"); |
| 1402 | static_assert( | 1311 | static_assert( |
| 1403 | __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator"); | 1312 | __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator"); |
| 1404 | if (size() != 0) { | 1313 | if (size() != 0) { |
| ... | @@ -1409,7 +1318,7 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first | ... | @@ -1409,7 +1318,7 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first |
| 1409 | } | 1318 | } |
| 1410 | } | 1319 | } |
| 1411 | for (; __first != __last; ++__first) | 1320 | for (; __first != __last; ++__first) |
| 1412 | __insert_unique(*__first); | 1321 | __emplace_unique(*__first); |
| 1413 | } | 1322 | } |
| 1414 | 1323 | ||
| 1415 | template <class _Tp, class _Compare, class _Allocator> | 1324 | template <class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1418,24 +1327,23 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _ | ... | @@ -1418,24 +1327,23 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _ |
| 1418 | typedef iterator_traits<_InputIterator> _ITraits; | 1327 | typedef iterator_traits<_InputIterator> _ITraits; |
| 1419 | typedef typename _ITraits::value_type _ItValueType; | 1328 | typedef typename _ITraits::value_type _ItValueType; |
| 1420 | static_assert( | 1329 | static_assert( |
| 1421 | (is_same<_ItValueType, __container_value_type>::value || is_same<_ItValueType, __node_value_type>::value), | 1330 | is_same<_ItValueType, value_type>::value, "__assign_multi may only be called with the containers value_type"); |
| 1422 | "__assign_multi may only be called with the containers value type" | ||
| 1423 | " or the nodes value type"); | ||
| 1424 | if (size() != 0) { | 1331 | if (size() != 0) { |
| 1425 | _DetachedTreeCache __cache(this); | 1332 | _DetachedTreeCache __cache(this); |
| 1426 | for (; __cache.__get() && __first != __last; ++__first) { | 1333 | for (; __cache.__get() && __first != __last; ++__first) { |
| 1427 | __cache.__get()->__value_ = *__first; | 1334 | __assign_value(__cache.__get()->__value_, *__first); |
| 1428 | __node_insert_multi(__cache.__get()); | 1335 | __node_insert_multi(__cache.__get()); |
| 1429 | __cache.__advance(); | 1336 | __cache.__advance(); |
| 1430 | } | 1337 | } |
| 1431 | } | 1338 | } |
| 1339 | const_iterator __e = end(); | ||
| 1432 | for (; __first != __last; ++__first) | 1340 | for (; __first != __last; ++__first) |
| 1433 | __insert_multi(_NodeTypes::__get_value(*__first)); | 1341 | __emplace_hint_multi(__e, *__first); |
| 1434 | } | 1342 | } |
| 1435 | 1343 | ||
| 1436 | template <class _Tp, class _Compare, class _Allocator> | 1344 | template <class _Tp, class _Compare, class _Allocator> |
| 1437 | __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) | 1345 | __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) |
| 1438 | : __begin_node_(__iter_pointer()), | 1346 | : __begin_node_(), |
| 1439 | __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), | 1347 | __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), |
| 1440 | __size_(0), | 1348 | __size_(0), |
| 1441 | __value_comp_(__t.value_comp()) { | 1349 | __value_comp_(__t.value_comp()) { |
| ... | @@ -1453,7 +1361,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( | ... | @@ -1453,7 +1361,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( |
| 1453 | if (size() == 0) | 1361 | if (size() == 0) |
| 1454 | __begin_node() = __end_node(); | 1362 | __begin_node() = __end_node(); |
| 1455 | else { | 1363 | else { |
| 1456 | __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); | 1364 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); |
| 1457 | __t.__begin_node() = __t.__end_node(); | 1365 | __t.__begin_node() = __t.__end_node(); |
| 1458 | __t.__end_node()->__left_ = nullptr; | 1366 | __t.__end_node()->__left_ = nullptr; |
| 1459 | __t.size() = 0; | 1367 | __t.size() = 0; |
| ... | @@ -1469,7 +1377,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __ | ... | @@ -1469,7 +1377,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __ |
| 1469 | else { | 1377 | else { |
| 1470 | __begin_node() = __t.__begin_node(); | 1378 | __begin_node() = __t.__begin_node(); |
| 1471 | __end_node()->__left_ = __t.__end_node()->__left_; | 1379 | __end_node()->__left_ = __t.__end_node()->__left_; |
| 1472 | __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); | 1380 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); |
| 1473 | size() = __t.size(); | 1381 | size() = __t.size(); |
| 1474 | __t.__begin_node() = __t.__end_node(); | 1382 | __t.__begin_node() = __t.__end_node(); |
| 1475 | __t.__end_node()->__left_ = nullptr; | 1383 | __t.__end_node()->__left_ = nullptr; |
| ... | @@ -1492,7 +1400,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) | ... | @@ -1492,7 +1400,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) |
| 1492 | if (size() == 0) | 1400 | if (size() == 0) |
| 1493 | __begin_node() = __end_node(); | 1401 | __begin_node() = __end_node(); |
| 1494 | else { | 1402 | else { |
| 1495 | __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); | 1403 | __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node()); |
| 1496 | __t.__begin_node() = __t.__end_node(); | 1404 | __t.__begin_node() = __t.__end_node(); |
| 1497 | __t.__end_node()->__left_ = nullptr; | 1405 | __t.__end_node()->__left_ = nullptr; |
| 1498 | __t.size() = 0; | 1406 | __t.size() = 0; |
| ... | @@ -1509,22 +1417,23 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) { | ... | @@ -1509,22 +1417,23 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) { |
| 1509 | if (size() != 0) { | 1417 | if (size() != 0) { |
| 1510 | _DetachedTreeCache __cache(this); | 1418 | _DetachedTreeCache __cache(this); |
| 1511 | while (__cache.__get() != nullptr && __t.size() != 0) { | 1419 | while (__cache.__get() != nullptr && __t.size() != 0) { |
| 1512 | __cache.__get()->__value_ = std::move(__t.remove(__t.begin())->__value_); | 1420 | __assign_value(__cache.__get()->__value_, std::move(__t.remove(__t.begin())->__value_)); |
| 1513 | __node_insert_multi(__cache.__get()); | 1421 | __node_insert_multi(__cache.__get()); |
| 1514 | __cache.__advance(); | 1422 | __cache.__advance(); |
| 1515 | } | 1423 | } |
| 1516 | } | 1424 | } |
| 1517 | while (__t.size() != 0) | 1425 | while (__t.size() != 0) { |
| 1518 | __insert_multi(__e, _NodeTypes::__move(__t.remove(__t.begin())->__value_)); | 1426 | __insert_multi_from_orphaned_node(__e, std::move(__t.remove(__t.begin())->__value_)); |
| 1427 | } | ||
| 1519 | } | 1428 | } |
| 1520 | } | 1429 | } |
| 1521 | 1430 | ||
| 1522 | template <class _Tp, class _Compare, class _Allocator> | 1431 | template <class _Tp, class _Compare, class _Allocator> |
| 1523 | __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) _NOEXCEPT_( | 1432 | __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) |
| 1524 | __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<value_compare>::value&& | 1433 | _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value && |
| 1525 | is_nothrow_move_assignable<__node_allocator>::value) | 1434 | ((__node_traits::propagate_on_container_move_assignment::value && |
| 1526 | 1435 | is_nothrow_move_assignable<__node_allocator>::value) || | |
| 1527 | { | 1436 | allocator_traits<__node_allocator>::is_always_equal::value)) { |
| 1528 | __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); | 1437 | __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); |
| 1529 | return *this; | 1438 | return *this; |
| 1530 | } | 1439 | } |
| ... | @@ -1541,7 +1450,7 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { | ... | @@ -1541,7 +1450,7 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { |
| 1541 | destroy(static_cast<__node_pointer>(__nd->__left_)); | 1450 | destroy(static_cast<__node_pointer>(__nd->__left_)); |
| 1542 | destroy(static_cast<__node_pointer>(__nd->__right_)); | 1451 | destroy(static_cast<__node_pointer>(__nd->__right_)); |
| 1543 | __node_allocator& __na = __node_alloc(); | 1452 | __node_allocator& __na = __node_alloc(); |
| 1544 | __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_)); | 1453 | __node_traits::destroy(__na, std::addressof(__nd->__value_)); |
| 1545 | __node_traits::deallocate(__na, __nd, 1); | 1454 | __node_traits::deallocate(__na, __nd, 1); |
| 1546 | } | 1455 | } |
| 1547 | } | 1456 | } |
| ... | @@ -1564,11 +1473,11 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) | ... | @@ -1564,11 +1473,11 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) |
| 1564 | if (size() == 0) | 1473 | if (size() == 0) |
| 1565 | __begin_node() = __end_node(); | 1474 | __begin_node() = __end_node(); |
| 1566 | else | 1475 | else |
| 1567 | __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); | 1476 | __end_node()->__left_->__parent_ = __end_node(); |
| 1568 | if (__t.size() == 0) | 1477 | if (__t.size() == 0) |
| 1569 | __t.__begin_node() = __t.__end_node(); | 1478 | __t.__begin_node() = __t.__end_node(); |
| 1570 | else | 1479 | else |
| 1571 | __t.__end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__t.__end_node()); | 1480 | __t.__end_node()->__left_->__parent_ = __t.__end_node(); |
| 1572 | } | 1481 | } |
| 1573 | 1482 | ||
| 1574 | template <class _Tp, class _Compare, class _Allocator> | 1483 | template <class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1584,7 +1493,7 @@ void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT { | ... | @@ -1584,7 +1493,7 @@ void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT { |
| 1584 | // Return reference to null leaf | 1493 | // Return reference to null leaf |
| 1585 | template <class _Tp, class _Compare, class _Allocator> | 1494 | template <class _Tp, class _Compare, class _Allocator> |
| 1586 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& | 1495 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& |
| 1587 | __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, const key_type& __v) { | 1496 | __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent, const value_type& __v) { |
| 1588 | __node_pointer __nd = __root(); | 1497 | __node_pointer __nd = __root(); |
| 1589 | if (__nd != nullptr) { | 1498 | if (__nd != nullptr) { |
| 1590 | while (true) { | 1499 | while (true) { |
| ... | @@ -1592,20 +1501,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c | ... | @@ -1592,20 +1501,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c |
| 1592 | if (__nd->__right_ != nullptr) | 1501 | if (__nd->__right_ != nullptr) |
| 1593 | __nd = static_cast<__node_pointer>(__nd->__right_); | 1502 | __nd = static_cast<__node_pointer>(__nd->__right_); |
| 1594 | else { | 1503 | else { |
| 1595 | __parent = static_cast<__parent_pointer>(__nd); | 1504 | __parent = static_cast<__end_node_pointer>(__nd); |
| 1596 | return __nd->__right_; | 1505 | return __nd->__right_; |
| 1597 | } | 1506 | } |
| 1598 | } else { | 1507 | } else { |
| 1599 | if (__nd->__left_ != nullptr) | 1508 | if (__nd->__left_ != nullptr) |
| 1600 | __nd = static_cast<__node_pointer>(__nd->__left_); | 1509 | __nd = static_cast<__node_pointer>(__nd->__left_); |
| 1601 | else { | 1510 | else { |
| 1602 | __parent = static_cast<__parent_pointer>(__nd); | 1511 | __parent = static_cast<__end_node_pointer>(__nd); |
| 1603 | return __parent->__left_; | 1512 | return __parent->__left_; |
| 1604 | } | 1513 | } |
| 1605 | } | 1514 | } |
| 1606 | } | 1515 | } |
| 1607 | } | 1516 | } |
| 1608 | __parent = static_cast<__parent_pointer>(__end_node()); | 1517 | __parent = __end_node(); |
| 1609 | return __parent->__left_; | 1518 | return __parent->__left_; |
| 1610 | } | 1519 | } |
| 1611 | 1520 | ||
| ... | @@ -1614,7 +1523,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c | ... | @@ -1614,7 +1523,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c |
| 1614 | // Return reference to null leaf | 1523 | // Return reference to null leaf |
| 1615 | template <class _Tp, class _Compare, class _Allocator> | 1524 | template <class _Tp, class _Compare, class _Allocator> |
| 1616 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& | 1525 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& |
| 1617 | __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, const key_type& __v) { | 1526 | __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent, const value_type& __v) { |
| 1618 | __node_pointer __nd = __root(); | 1527 | __node_pointer __nd = __root(); |
| 1619 | if (__nd != nullptr) { | 1528 | if (__nd != nullptr) { |
| 1620 | while (true) { | 1529 | while (true) { |
| ... | @@ -1622,20 +1531,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, | ... | @@ -1622,20 +1531,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, |
| 1622 | if (__nd->__left_ != nullptr) | 1531 | if (__nd->__left_ != nullptr) |
| 1623 | __nd = static_cast<__node_pointer>(__nd->__left_); | 1532 | __nd = static_cast<__node_pointer>(__nd->__left_); |
| 1624 | else { | 1533 | else { |
| 1625 | __parent = static_cast<__parent_pointer>(__nd); | 1534 | __parent = static_cast<__end_node_pointer>(__nd); |
| 1626 | return __parent->__left_; | 1535 | return __parent->__left_; |
| 1627 | } | 1536 | } |
| 1628 | } else { | 1537 | } else { |
| 1629 | if (__nd->__right_ != nullptr) | 1538 | if (__nd->__right_ != nullptr) |
| 1630 | __nd = static_cast<__node_pointer>(__nd->__right_); | 1539 | __nd = static_cast<__node_pointer>(__nd->__right_); |
| 1631 | else { | 1540 | else { |
| 1632 | __parent = static_cast<__parent_pointer>(__nd); | 1541 | __parent = static_cast<__end_node_pointer>(__nd); |
| 1633 | return __nd->__right_; | 1542 | return __nd->__right_; |
| 1634 | } | 1543 | } |
| 1635 | } | 1544 | } |
| 1636 | } | 1545 | } |
| 1637 | } | 1546 | } |
| 1638 | __parent = static_cast<__parent_pointer>(__end_node()); | 1547 | __parent = __end_node(); |
| 1639 | return __parent->__left_; | 1548 | return __parent->__left_; |
| 1640 | } | 1549 | } |
| 1641 | 1550 | ||
| ... | @@ -1646,8 +1555,8 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, | ... | @@ -1646,8 +1555,8 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, |
| 1646 | // Set __parent to parent of null leaf | 1555 | // Set __parent to parent of null leaf |
| 1647 | // Return reference to null leaf | 1556 | // Return reference to null leaf |
| 1648 | template <class _Tp, class _Compare, class _Allocator> | 1557 | template <class _Tp, class _Compare, class _Allocator> |
| 1649 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& | 1558 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_leaf( |
| 1650 | __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v) { | 1559 | const_iterator __hint, __end_node_pointer& __parent, const value_type& __v) { |
| 1651 | if (__hint == end() || !value_comp()(*__hint, __v)) // check before | 1560 | if (__hint == end() || !value_comp()(*__hint, __v)) // check before |
| 1652 | { | 1561 | { |
| 1653 | // __v <= *__hint | 1562 | // __v <= *__hint |
| ... | @@ -1655,10 +1564,10 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p | ... | @@ -1655,10 +1564,10 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p |
| 1655 | if (__prior == begin() || !value_comp()(__v, *--__prior)) { | 1564 | if (__prior == begin() || !value_comp()(__v, *--__prior)) { |
| 1656 | // *prev(__hint) <= __v <= *__hint | 1565 | // *prev(__hint) <= __v <= *__hint |
| 1657 | if (__hint.__ptr_->__left_ == nullptr) { | 1566 | if (__hint.__ptr_->__left_ == nullptr) { |
| 1658 | __parent = static_cast<__parent_pointer>(__hint.__ptr_); | 1567 | __parent = static_cast<__end_node_pointer>(__hint.__ptr_); |
| 1659 | return __parent->__left_; | 1568 | return __parent->__left_; |
| 1660 | } else { | 1569 | } else { |
| 1661 | __parent = static_cast<__parent_pointer>(__prior.__ptr_); | 1570 | __parent = static_cast<__end_node_pointer>(__prior.__ptr_); |
| 1662 | return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; | 1571 | return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; |
| 1663 | } | 1572 | } |
| 1664 | } | 1573 | } |
| ... | @@ -1676,7 +1585,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p | ... | @@ -1676,7 +1585,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p |
| 1676 | template <class _Tp, class _Compare, class _Allocator> | 1585 | template <class _Tp, class _Compare, class _Allocator> |
| 1677 | template <class _Key> | 1586 | template <class _Key> |
| 1678 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& | 1587 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& |
| 1679 | __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, const _Key& __v) { | 1588 | __tree<_Tp, _Compare, _Allocator>::__find_equal(__end_node_pointer& __parent, const _Key& __v) { |
| 1680 | __node_pointer __nd = __root(); | 1589 | __node_pointer __nd = __root(); |
| 1681 | __node_base_pointer* __nd_ptr = __root_ptr(); | 1590 | __node_base_pointer* __nd_ptr = __root_ptr(); |
| 1682 | if (__nd != nullptr) { | 1591 | if (__nd != nullptr) { |
| ... | @@ -1686,7 +1595,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons | ... | @@ -1686,7 +1595,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons |
| 1686 | __nd_ptr = std::addressof(__nd->__left_); | 1595 | __nd_ptr = std::addressof(__nd->__left_); |
| 1687 | __nd = static_cast<__node_pointer>(__nd->__left_); | 1596 | __nd = static_cast<__node_pointer>(__nd->__left_); |
| 1688 | } else { | 1597 | } else { |
| 1689 | __parent = static_cast<__parent_pointer>(__nd); | 1598 | __parent = static_cast<__end_node_pointer>(__nd); |
| 1690 | return __parent->__left_; | 1599 | return __parent->__left_; |
| 1691 | } | 1600 | } |
| 1692 | } else if (value_comp()(__nd->__value_, __v)) { | 1601 | } else if (value_comp()(__nd->__value_, __v)) { |
| ... | @@ -1694,16 +1603,16 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons | ... | @@ -1694,16 +1603,16 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons |
| 1694 | __nd_ptr = std::addressof(__nd->__right_); | 1603 | __nd_ptr = std::addressof(__nd->__right_); |
| 1695 | __nd = static_cast<__node_pointer>(__nd->__right_); | 1604 | __nd = static_cast<__node_pointer>(__nd->__right_); |
| 1696 | } else { | 1605 | } else { |
| 1697 | __parent = static_cast<__parent_pointer>(__nd); | 1606 | __parent = static_cast<__end_node_pointer>(__nd); |
| 1698 | return __nd->__right_; | 1607 | return __nd->__right_; |
| 1699 | } | 1608 | } |
| 1700 | } else { | 1609 | } else { |
| 1701 | __parent = static_cast<__parent_pointer>(__nd); | 1610 | __parent = static_cast<__end_node_pointer>(__nd); |
| 1702 | return *__nd_ptr; | 1611 | return *__nd_ptr; |
| 1703 | } | 1612 | } |
| 1704 | } | 1613 | } |
| 1705 | } | 1614 | } |
| 1706 | __parent = static_cast<__parent_pointer>(__end_node()); | 1615 | __parent = __end_node(); |
| 1707 | return __parent->__left_; | 1616 | return __parent->__left_; |
| 1708 | } | 1617 | } |
| 1709 | 1618 | ||
| ... | @@ -1717,7 +1626,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons | ... | @@ -1717,7 +1626,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons |
| 1717 | template <class _Tp, class _Compare, class _Allocator> | 1626 | template <class _Tp, class _Compare, class _Allocator> |
| 1718 | template <class _Key> | 1627 | template <class _Key> |
| 1719 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal( | 1628 | typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal( |
| 1720 | const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v) { | 1629 | const_iterator __hint, __end_node_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v) { |
| 1721 | if (__hint == end() || value_comp()(__v, *__hint)) // check before | 1630 | if (__hint == end() || value_comp()(__v, *__hint)) // check before |
| 1722 | { | 1631 | { |
| 1723 | // __v < *__hint | 1632 | // __v < *__hint |
| ... | @@ -1725,10 +1634,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co | ... | @@ -1725,10 +1634,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co |
| 1725 | if (__prior == begin() || value_comp()(*--__prior, __v)) { | 1634 | if (__prior == begin() || value_comp()(*--__prior, __v)) { |
| 1726 | // *prev(__hint) < __v < *__hint | 1635 | // *prev(__hint) < __v < *__hint |
| 1727 | if (__hint.__ptr_->__left_ == nullptr) { | 1636 | if (__hint.__ptr_->__left_ == nullptr) { |
| 1728 | __parent = static_cast<__parent_pointer>(__hint.__ptr_); | 1637 | __parent = __hint.__ptr_; |
| 1729 | return __parent->__left_; | 1638 | return __parent->__left_; |
| 1730 | } else { | 1639 | } else { |
| 1731 | __parent = static_cast<__parent_pointer>(__prior.__ptr_); | 1640 | __parent = __prior.__ptr_; |
| 1732 | return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; | 1641 | return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; |
| 1733 | } | 1642 | } |
| 1734 | } | 1643 | } |
| ... | @@ -1741,10 +1650,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co | ... | @@ -1741,10 +1650,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co |
| 1741 | if (__next == end() || value_comp()(__v, *__next)) { | 1650 | if (__next == end() || value_comp()(__v, *__next)) { |
| 1742 | // *__hint < __v < *std::next(__hint) | 1651 | // *__hint < __v < *std::next(__hint) |
| 1743 | if (__hint.__get_np()->__right_ == nullptr) { | 1652 | if (__hint.__get_np()->__right_ == nullptr) { |
| 1744 | __parent = static_cast<__parent_pointer>(__hint.__ptr_); | 1653 | __parent = __hint.__ptr_; |
| 1745 | return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_; | 1654 | return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_; |
| 1746 | } else { | 1655 | } else { |
| 1747 | __parent = static_cast<__parent_pointer>(__next.__ptr_); | 1656 | __parent = __next.__ptr_; |
| 1748 | return __parent->__left_; | 1657 | return __parent->__left_; |
| 1749 | } | 1658 | } |
| 1750 | } | 1659 | } |
| ... | @@ -1752,21 +1661,21 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co | ... | @@ -1752,21 +1661,21 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co |
| 1752 | return __find_equal(__parent, __v); | 1661 | return __find_equal(__parent, __v); |
| 1753 | } | 1662 | } |
| 1754 | // else __v == *__hint | 1663 | // else __v == *__hint |
| 1755 | __parent = static_cast<__parent_pointer>(__hint.__ptr_); | 1664 | __parent = __hint.__ptr_; |
| 1756 | __dummy = static_cast<__node_base_pointer>(__hint.__ptr_); | 1665 | __dummy = static_cast<__node_base_pointer>(__hint.__ptr_); |
| 1757 | return __dummy; | 1666 | return __dummy; |
| 1758 | } | 1667 | } |
| 1759 | 1668 | ||
| 1760 | template <class _Tp, class _Compare, class _Allocator> | 1669 | template <class _Tp, class _Compare, class _Allocator> |
| 1761 | void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( | 1670 | void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( |
| 1762 | __parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT { | 1671 | __end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT { |
| 1763 | __new_node->__left_ = nullptr; | 1672 | __new_node->__left_ = nullptr; |
| 1764 | __new_node->__right_ = nullptr; | 1673 | __new_node->__right_ = nullptr; |
| 1765 | __new_node->__parent_ = __parent; | 1674 | __new_node->__parent_ = __parent; |
| 1766 | // __new_node->__is_black_ is initialized in __tree_balance_after_insert | 1675 | // __new_node->__is_black_ is initialized in __tree_balance_after_insert |
| 1767 | __child = __new_node; | 1676 | __child = __new_node; |
| 1768 | if (__begin_node()->__left_ != nullptr) | 1677 | if (__begin_node()->__left_ != nullptr) |
| 1769 | __begin_node() = static_cast<__iter_pointer>(__begin_node()->__left_); | 1678 | __begin_node() = static_cast<__end_node_pointer>(__begin_node()->__left_); |
| 1770 | std::__tree_balance_after_insert(__end_node()->__left_, __child); | 1679 | std::__tree_balance_after_insert(__end_node()->__left_, __child); |
| 1771 | ++size(); | 1680 | ++size(); |
| 1772 | } | 1681 | } |
| ... | @@ -1775,7 +1684,7 @@ template <class _Tp, class _Compare, class _Allocator> | ... | @@ -1775,7 +1684,7 @@ template <class _Tp, class _Compare, class _Allocator> |
| 1775 | template <class _Key, class... _Args> | 1684 | template <class _Key, class... _Args> |
| 1776 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | 1685 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> |
| 1777 | __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) { | 1686 | __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) { |
| 1778 | __parent_pointer __parent; | 1687 | __end_node_pointer __parent; |
| 1779 | __node_base_pointer& __child = __find_equal(__parent, __k); | 1688 | __node_base_pointer& __child = __find_equal(__parent, __k); |
| 1780 | __node_pointer __r = static_cast<__node_pointer>(__child); | 1689 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 1781 | bool __inserted = false; | 1690 | bool __inserted = false; |
| ... | @@ -1793,7 +1702,7 @@ template <class _Key, class... _Args> | ... | @@ -1793,7 +1702,7 @@ template <class _Key, class... _Args> |
| 1793 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | 1702 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> |
| 1794 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( | 1703 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( |
| 1795 | const_iterator __p, _Key const& __k, _Args&&... __args) { | 1704 | const_iterator __p, _Key const& __k, _Args&&... __args) { |
| 1796 | __parent_pointer __parent; | 1705 | __end_node_pointer __parent; |
| 1797 | __node_base_pointer __dummy; | 1706 | __node_base_pointer __dummy; |
| 1798 | __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k); | 1707 | __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k); |
| 1799 | __node_pointer __r = static_cast<__node_pointer>(__child); | 1708 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| ... | @@ -1811,10 +1720,9 @@ template <class _Tp, class _Compare, class _Allocator> | ... | @@ -1811,10 +1720,9 @@ template <class _Tp, class _Compare, class _Allocator> |
| 1811 | template <class... _Args> | 1720 | template <class... _Args> |
| 1812 | typename __tree<_Tp, _Compare, _Allocator>::__node_holder | 1721 | typename __tree<_Tp, _Compare, _Allocator>::__node_holder |
| 1813 | __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { | 1722 | __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { |
| 1814 | static_assert(!__is_tree_value_type<_Args...>::value, "Cannot construct from __value_type"); | ||
| 1815 | __node_allocator& __na = __node_alloc(); | 1723 | __node_allocator& __na = __node_alloc(); |
| 1816 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1724 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1817 | __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), std::forward<_Args>(__args)...); | 1725 | __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...); |
| 1818 | __h.get_deleter().__value_constructed = true; | 1726 | __h.get_deleter().__value_constructed = true; |
| 1819 | return __h; | 1727 | return __h; |
| 1820 | } | 1728 | } |
| ... | @@ -1824,7 +1732,7 @@ template <class... _Args> | ... | @@ -1824,7 +1732,7 @@ template <class... _Args> |
| 1824 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | 1732 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> |
| 1825 | __tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { | 1733 | __tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { |
| 1826 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | 1734 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); |
| 1827 | __parent_pointer __parent; | 1735 | __end_node_pointer __parent; |
| 1828 | __node_base_pointer& __child = __find_equal(__parent, __h->__value_); | 1736 | __node_base_pointer& __child = __find_equal(__parent, __h->__value_); |
| 1829 | __node_pointer __r = static_cast<__node_pointer>(__child); | 1737 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 1830 | bool __inserted = false; | 1738 | bool __inserted = false; |
| ... | @@ -1841,7 +1749,7 @@ template <class... _Args> | ... | @@ -1841,7 +1749,7 @@ template <class... _Args> |
| 1841 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 1749 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1842 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) { | 1750 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) { |
| 1843 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | 1751 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); |
| 1844 | __parent_pointer __parent; | 1752 | __end_node_pointer __parent; |
| 1845 | __node_base_pointer __dummy; | 1753 | __node_base_pointer __dummy; |
| 1846 | __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_); | 1754 | __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_); |
| 1847 | __node_pointer __r = static_cast<__node_pointer>(__child); | 1755 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| ... | @@ -1857,8 +1765,8 @@ template <class... _Args> | ... | @@ -1857,8 +1765,8 @@ template <class... _Args> |
| 1857 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 1765 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1858 | __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { | 1766 | __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { |
| 1859 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | 1767 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); |
| 1860 | __parent_pointer __parent; | 1768 | __end_node_pointer __parent; |
| 1861 | __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_)); | 1769 | __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_); |
| 1862 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | 1770 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
| 1863 | return iterator(static_cast<__node_pointer>(__h.release())); | 1771 | return iterator(static_cast<__node_pointer>(__h.release())); |
| 1864 | } | 1772 | } |
| ... | @@ -1868,21 +1776,21 @@ template <class... _Args> | ... | @@ -1868,21 +1776,21 @@ template <class... _Args> |
| 1868 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 1776 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1869 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) { | 1777 | __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) { |
| 1870 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); | 1778 | __node_holder __h = __construct_node(std::forward<_Args>(__args)...); |
| 1871 | __parent_pointer __parent; | 1779 | __end_node_pointer __parent; |
| 1872 | __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_)); | 1780 | __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_); |
| 1873 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | 1781 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
| 1874 | return iterator(static_cast<__node_pointer>(__h.release())); | 1782 | return iterator(static_cast<__node_pointer>(__h.release())); |
| 1875 | } | 1783 | } |
| 1876 | 1784 | ||
| 1877 | template <class _Tp, class _Compare, class _Allocator> | 1785 | template <class _Tp, class _Compare, class _Allocator> |
| 1878 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> | 1786 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> |
| 1879 | __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd) { | 1787 | __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const value_type& __v, __node_pointer __nd) { |
| 1880 | __parent_pointer __parent; | 1788 | __end_node_pointer __parent; |
| 1881 | __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__v)); | 1789 | __node_base_pointer& __child = __find_equal(__parent, __v); |
| 1882 | __node_pointer __r = static_cast<__node_pointer>(__child); | 1790 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 1883 | bool __inserted = false; | 1791 | bool __inserted = false; |
| 1884 | if (__child == nullptr) { | 1792 | if (__child == nullptr) { |
| 1885 | __nd->__value_ = __v; | 1793 | __assign_value(__nd->__value_, __v); |
| 1886 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); | 1794 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); |
| 1887 | __r = __nd; | 1795 | __r = __nd; |
| 1888 | __inserted = true; | 1796 | __inserted = true; |
| ... | @@ -1893,8 +1801,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_ | ... | @@ -1893,8 +1801,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_ |
| 1893 | template <class _Tp, class _Compare, class _Allocator> | 1801 | template <class _Tp, class _Compare, class _Allocator> |
| 1894 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 1802 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1895 | __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { | 1803 | __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { |
| 1896 | __parent_pointer __parent; | 1804 | __end_node_pointer __parent; |
| 1897 | __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_)); | 1805 | __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__value_); |
| 1898 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); | 1806 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); |
| 1899 | return iterator(__nd); | 1807 | return iterator(__nd); |
| 1900 | } | 1808 | } |
| ... | @@ -1902,8 +1810,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { | ... | @@ -1902,8 +1810,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { |
| 1902 | template <class _Tp, class _Compare, class _Allocator> | 1810 | template <class _Tp, class _Compare, class _Allocator> |
| 1903 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 1811 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 1904 | __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) { | 1812 | __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) { |
| 1905 | __parent_pointer __parent; | 1813 | __end_node_pointer __parent; |
| 1906 | __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_)); | 1814 | __node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__value_); |
| 1907 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); | 1815 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); |
| 1908 | return iterator(__nd); | 1816 | return iterator(__nd); |
| 1909 | } | 1817 | } |
| ... | @@ -1929,7 +1837,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n | ... | @@ -1929,7 +1837,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n |
| 1929 | return _InsertReturnType{end(), false, _NodeHandle()}; | 1837 | return _InsertReturnType{end(), false, _NodeHandle()}; |
| 1930 | 1838 | ||
| 1931 | __node_pointer __ptr = __nh.__ptr_; | 1839 | __node_pointer __ptr = __nh.__ptr_; |
| 1932 | __parent_pointer __parent; | 1840 | __end_node_pointer __parent; |
| 1933 | __node_base_pointer& __child = __find_equal(__parent, __ptr->__value_); | 1841 | __node_base_pointer& __child = __find_equal(__parent, __ptr->__value_); |
| 1934 | if (__child != nullptr) | 1842 | if (__child != nullptr) |
| 1935 | return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)}; | 1843 | return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)}; |
| ... | @@ -1947,7 +1855,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __ | ... | @@ -1947,7 +1855,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __ |
| 1947 | return end(); | 1855 | return end(); |
| 1948 | 1856 | ||
| 1949 | __node_pointer __ptr = __nh.__ptr_; | 1857 | __node_pointer __ptr = __nh.__ptr_; |
| 1950 | __parent_pointer __parent; | 1858 | __end_node_pointer __parent; |
| 1951 | __node_base_pointer __dummy; | 1859 | __node_base_pointer __dummy; |
| 1952 | __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, __ptr->__value_); | 1860 | __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, __ptr->__value_); |
| 1953 | __node_pointer __r = static_cast<__node_pointer>(__child); | 1861 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| ... | @@ -1983,8 +1891,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg | ... | @@ -1983,8 +1891,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg |
| 1983 | 1891 | ||
| 1984 | for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) { | 1892 | for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) { |
| 1985 | __node_pointer __src_ptr = __i.__get_np(); | 1893 | __node_pointer __src_ptr = __i.__get_np(); |
| 1986 | __parent_pointer __parent; | 1894 | __end_node_pointer __parent; |
| 1987 | __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__src_ptr->__value_)); | 1895 | __node_base_pointer& __child = __find_equal(__parent, __src_ptr->__value_); |
| 1988 | ++__i; | 1896 | ++__i; |
| 1989 | if (__child != nullptr) | 1897 | if (__child != nullptr) |
| 1990 | continue; | 1898 | continue; |
| ... | @@ -2000,8 +1908,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh | ... | @@ -2000,8 +1908,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh |
| 2000 | if (__nh.empty()) | 1908 | if (__nh.empty()) |
| 2001 | return end(); | 1909 | return end(); |
| 2002 | __node_pointer __ptr = __nh.__ptr_; | 1910 | __node_pointer __ptr = __nh.__ptr_; |
| 2003 | __parent_pointer __parent; | 1911 | __end_node_pointer __parent; |
| 2004 | __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__ptr->__value_)); | 1912 | __node_base_pointer& __child = __find_leaf_high(__parent, __ptr->__value_); |
| 2005 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); | 1913 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); |
| 2006 | __nh.__release_ptr(); | 1914 | __nh.__release_ptr(); |
| 2007 | return iterator(__ptr); | 1915 | return iterator(__ptr); |
| ... | @@ -2015,8 +1923,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h | ... | @@ -2015,8 +1923,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h |
| 2015 | return end(); | 1923 | return end(); |
| 2016 | 1924 | ||
| 2017 | __node_pointer __ptr = __nh.__ptr_; | 1925 | __node_pointer __ptr = __nh.__ptr_; |
| 2018 | __parent_pointer __parent; | 1926 | __end_node_pointer __parent; |
| 2019 | __node_base_pointer& __child = __find_leaf(__hint, __parent, _NodeTypes::__get_key(__ptr->__value_)); | 1927 | __node_base_pointer& __child = __find_leaf(__hint, __parent, __ptr->__value_); |
| 2020 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); | 1928 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); |
| 2021 | __nh.__release_ptr(); | 1929 | __nh.__release_ptr(); |
| 2022 | return iterator(__ptr); | 1930 | return iterator(__ptr); |
| ... | @@ -2029,8 +1937,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg | ... | @@ -2029,8 +1937,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg |
| 2029 | 1937 | ||
| 2030 | for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) { | 1938 | for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) { |
| 2031 | __node_pointer __src_ptr = __i.__get_np(); | 1939 | __node_pointer __src_ptr = __i.__get_np(); |
| 2032 | __parent_pointer __parent; | 1940 | __end_node_pointer __parent; |
| 2033 | __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__src_ptr->__value_)); | 1941 | __node_base_pointer& __child = __find_leaf_high(__parent, __src_ptr->__value_); |
| 2034 | ++__i; | 1942 | ++__i; |
| 2035 | __source.__remove_node_pointer(__src_ptr); | 1943 | __source.__remove_node_pointer(__src_ptr); |
| 2036 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr)); | 1944 | __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr)); |
| ... | @@ -2044,7 +1952,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo | ... | @@ -2044,7 +1952,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo |
| 2044 | __node_pointer __np = __p.__get_np(); | 1952 | __node_pointer __np = __p.__get_np(); |
| 2045 | iterator __r = __remove_node_pointer(__np); | 1953 | iterator __r = __remove_node_pointer(__np); |
| 2046 | __node_allocator& __na = __node_alloc(); | 1954 | __node_allocator& __na = __node_alloc(); |
| 2047 | __node_traits::destroy(__na, _NodeTypes::__get_ptr(const_cast<__node_value_type&>(*__p))); | 1955 | __node_traits::destroy(__na, std::addressof(const_cast<value_type&>(*__p))); |
| 2048 | __node_traits::deallocate(__na, __np, 1); | 1956 | __node_traits::deallocate(__na, __np, 1); |
| 2049 | return __r; | 1957 | return __r; |
| 2050 | } | 1958 | } |
| ... | @@ -2118,17 +2026,17 @@ template <class _Tp, class _Compare, class _Allocator> | ... | @@ -2118,17 +2026,17 @@ template <class _Tp, class _Compare, class _Allocator> |
| 2118 | template <class _Key> | 2026 | template <class _Key> |
| 2119 | typename __tree<_Tp, _Compare, _Allocator>::size_type | 2027 | typename __tree<_Tp, _Compare, _Allocator>::size_type |
| 2120 | __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const { | 2028 | __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const { |
| 2121 | __iter_pointer __result = __end_node(); | 2029 | __end_node_pointer __result = __end_node(); |
| 2122 | __node_pointer __rt = __root(); | 2030 | __node_pointer __rt = __root(); |
| 2123 | while (__rt != nullptr) { | 2031 | while (__rt != nullptr) { |
| 2124 | if (value_comp()(__k, __rt->__value_)) { | 2032 | if (value_comp()(__k, __rt->__value_)) { |
| 2125 | __result = static_cast<__iter_pointer>(__rt); | 2033 | __result = static_cast<__end_node_pointer>(__rt); |
| 2126 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2034 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2127 | } else if (value_comp()(__rt->__value_, __k)) | 2035 | } else if (value_comp()(__rt->__value_, __k)) |
| 2128 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2036 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2129 | else | 2037 | else |
| 2130 | return std::distance( | 2038 | return std::distance( |
| 2131 | __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), | 2039 | __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), |
| 2132 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | 2040 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); |
| 2133 | } | 2041 | } |
| 2134 | return 0; | 2042 | return 0; |
| ... | @@ -2137,10 +2045,10 @@ __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const { | ... | @@ -2137,10 +2045,10 @@ __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const { |
| 2137 | template <class _Tp, class _Compare, class _Allocator> | 2045 | template <class _Tp, class _Compare, class _Allocator> |
| 2138 | template <class _Key> | 2046 | template <class _Key> |
| 2139 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 2047 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 2140 | __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) { | 2048 | __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) { |
| 2141 | while (__root != nullptr) { | 2049 | while (__root != nullptr) { |
| 2142 | if (!value_comp()(__root->__value_, __v)) { | 2050 | if (!value_comp()(__root->__value_, __v)) { |
| 2143 | __result = static_cast<__iter_pointer>(__root); | 2051 | __result = static_cast<__end_node_pointer>(__root); |
| 2144 | __root = static_cast<__node_pointer>(__root->__left_); | 2052 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2145 | } else | 2053 | } else |
| 2146 | __root = static_cast<__node_pointer>(__root->__right_); | 2054 | __root = static_cast<__node_pointer>(__root->__right_); |
| ... | @@ -2151,10 +2059,10 @@ __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer | ... | @@ -2151,10 +2059,10 @@ __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer |
| 2151 | template <class _Tp, class _Compare, class _Allocator> | 2059 | template <class _Tp, class _Compare, class _Allocator> |
| 2152 | template <class _Key> | 2060 | template <class _Key> |
| 2153 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound( | 2061 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound( |
| 2154 | const _Key& __v, __node_pointer __root, __iter_pointer __result) const { | 2062 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) const { |
| 2155 | while (__root != nullptr) { | 2063 | while (__root != nullptr) { |
| 2156 | if (!value_comp()(__root->__value_, __v)) { | 2064 | if (!value_comp()(__root->__value_, __v)) { |
| 2157 | __result = static_cast<__iter_pointer>(__root); | 2065 | __result = static_cast<__end_node_pointer>(__root); |
| 2158 | __root = static_cast<__node_pointer>(__root->__left_); | 2066 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2159 | } else | 2067 | } else |
| 2160 | __root = static_cast<__node_pointer>(__root->__right_); | 2068 | __root = static_cast<__node_pointer>(__root->__right_); |
| ... | @@ -2165,10 +2073,10 @@ typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, | ... | @@ -2165,10 +2073,10 @@ typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, |
| 2165 | template <class _Tp, class _Compare, class _Allocator> | 2073 | template <class _Tp, class _Compare, class _Allocator> |
| 2166 | template <class _Key> | 2074 | template <class _Key> |
| 2167 | typename __tree<_Tp, _Compare, _Allocator>::iterator | 2075 | typename __tree<_Tp, _Compare, _Allocator>::iterator |
| 2168 | __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) { | 2076 | __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) { |
| 2169 | while (__root != nullptr) { | 2077 | while (__root != nullptr) { |
| 2170 | if (value_comp()(__v, __root->__value_)) { | 2078 | if (value_comp()(__v, __root->__value_)) { |
| 2171 | __result = static_cast<__iter_pointer>(__root); | 2079 | __result = static_cast<__end_node_pointer>(__root); |
| 2172 | __root = static_cast<__node_pointer>(__root->__left_); | 2080 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2173 | } else | 2081 | } else |
| 2174 | __root = static_cast<__node_pointer>(__root->__right_); | 2082 | __root = static_cast<__node_pointer>(__root->__right_); |
| ... | @@ -2179,10 +2087,10 @@ __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer | ... | @@ -2179,10 +2087,10 @@ __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer |
| 2179 | template <class _Tp, class _Compare, class _Allocator> | 2087 | template <class _Tp, class _Compare, class _Allocator> |
| 2180 | template <class _Key> | 2088 | template <class _Key> |
| 2181 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound( | 2089 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound( |
| 2182 | const _Key& __v, __node_pointer __root, __iter_pointer __result) const { | 2090 | const _Key& __v, __node_pointer __root, __end_node_pointer __result) const { |
| 2183 | while (__root != nullptr) { | 2091 | while (__root != nullptr) { |
| 2184 | if (value_comp()(__v, __root->__value_)) { | 2092 | if (value_comp()(__v, __root->__value_)) { |
| 2185 | __result = static_cast<__iter_pointer>(__root); | 2093 | __result = static_cast<__end_node_pointer>(__root); |
| 2186 | __root = static_cast<__node_pointer>(__root->__left_); | 2094 | __root = static_cast<__node_pointer>(__root->__left_); |
| 2187 | } else | 2095 | } else |
| 2188 | __root = static_cast<__node_pointer>(__root->__right_); | 2096 | __root = static_cast<__node_pointer>(__root->__right_); |
| ... | @@ -2195,17 +2103,17 @@ template <class _Key> | ... | @@ -2195,17 +2103,17 @@ template <class _Key> |
| 2195 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> | 2103 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> |
| 2196 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) { | 2104 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) { |
| 2197 | typedef pair<iterator, iterator> _Pp; | 2105 | typedef pair<iterator, iterator> _Pp; |
| 2198 | __iter_pointer __result = __end_node(); | 2106 | __end_node_pointer __result = __end_node(); |
| 2199 | __node_pointer __rt = __root(); | 2107 | __node_pointer __rt = __root(); |
| 2200 | while (__rt != nullptr) { | 2108 | while (__rt != nullptr) { |
| 2201 | if (value_comp()(__k, __rt->__value_)) { | 2109 | if (value_comp()(__k, __rt->__value_)) { |
| 2202 | __result = static_cast<__iter_pointer>(__rt); | 2110 | __result = static_cast<__end_node_pointer>(__rt); |
| 2203 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2111 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2204 | } else if (value_comp()(__rt->__value_, __k)) | 2112 | } else if (value_comp()(__rt->__value_, __k)) |
| 2205 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2113 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2206 | else | 2114 | else |
| 2207 | return _Pp(iterator(__rt), | 2115 | return _Pp(iterator(__rt), |
| 2208 | iterator(__rt->__right_ != nullptr ? static_cast<__iter_pointer>(std::__tree_min(__rt->__right_)) | 2116 | iterator(__rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) |
| 2209 | : __result)); | 2117 | : __result)); |
| 2210 | } | 2118 | } |
| 2211 | return _Pp(iterator(__result), iterator(__result)); | 2119 | return _Pp(iterator(__result), iterator(__result)); |
| ... | @@ -2217,11 +2125,11 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, | ... | @@ -2217,11 +2125,11 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, |
| 2217 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> | 2125 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> |
| 2218 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const { | 2126 | __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const { |
| 2219 | typedef pair<const_iterator, const_iterator> _Pp; | 2127 | typedef pair<const_iterator, const_iterator> _Pp; |
| 2220 | __iter_pointer __result = __end_node(); | 2128 | __end_node_pointer __result = __end_node(); |
| 2221 | __node_pointer __rt = __root(); | 2129 | __node_pointer __rt = __root(); |
| 2222 | while (__rt != nullptr) { | 2130 | while (__rt != nullptr) { |
| 2223 | if (value_comp()(__k, __rt->__value_)) { | 2131 | if (value_comp()(__k, __rt->__value_)) { |
| 2224 | __result = static_cast<__iter_pointer>(__rt); | 2132 | __result = static_cast<__end_node_pointer>(__rt); |
| 2225 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2133 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2226 | } else if (value_comp()(__rt->__value_, __k)) | 2134 | } else if (value_comp()(__rt->__value_, __k)) |
| 2227 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2135 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| ... | @@ -2229,7 +2137,7 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const { | ... | @@ -2229,7 +2137,7 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const { |
| 2229 | return _Pp( | 2137 | return _Pp( |
| 2230 | const_iterator(__rt), | 2138 | const_iterator(__rt), |
| 2231 | const_iterator( | 2139 | const_iterator( |
| 2232 | __rt->__right_ != nullptr ? static_cast<__iter_pointer>(std::__tree_min(__rt->__right_)) : __result)); | 2140 | __rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) : __result)); |
| 2233 | } | 2141 | } |
| 2234 | return _Pp(const_iterator(__result), const_iterator(__result)); | 2142 | return _Pp(const_iterator(__result), const_iterator(__result)); |
| 2235 | } | 2143 | } |
| ... | @@ -2239,16 +2147,16 @@ template <class _Key> | ... | @@ -2239,16 +2147,16 @@ template <class _Key> |
| 2239 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> | 2147 | pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator> |
| 2240 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) { | 2148 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) { |
| 2241 | typedef pair<iterator, iterator> _Pp; | 2149 | typedef pair<iterator, iterator> _Pp; |
| 2242 | __iter_pointer __result = __end_node(); | 2150 | __end_node_pointer __result = __end_node(); |
| 2243 | __node_pointer __rt = __root(); | 2151 | __node_pointer __rt = __root(); |
| 2244 | while (__rt != nullptr) { | 2152 | while (__rt != nullptr) { |
| 2245 | if (value_comp()(__k, __rt->__value_)) { | 2153 | if (value_comp()(__k, __rt->__value_)) { |
| 2246 | __result = static_cast<__iter_pointer>(__rt); | 2154 | __result = static_cast<__end_node_pointer>(__rt); |
| 2247 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2155 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2248 | } else if (value_comp()(__rt->__value_, __k)) | 2156 | } else if (value_comp()(__rt->__value_, __k)) |
| 2249 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2157 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2250 | else | 2158 | else |
| 2251 | return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), | 2159 | return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), |
| 2252 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | 2160 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); |
| 2253 | } | 2161 | } |
| 2254 | return _Pp(iterator(__result), iterator(__result)); | 2162 | return _Pp(iterator(__result), iterator(__result)); |
| ... | @@ -2260,16 +2168,16 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, | ... | @@ -2260,16 +2168,16 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator, |
| 2260 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> | 2168 | typename __tree<_Tp, _Compare, _Allocator>::const_iterator> |
| 2261 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const { | 2169 | __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const { |
| 2262 | typedef pair<const_iterator, const_iterator> _Pp; | 2170 | typedef pair<const_iterator, const_iterator> _Pp; |
| 2263 | __iter_pointer __result = __end_node(); | 2171 | __end_node_pointer __result = __end_node(); |
| 2264 | __node_pointer __rt = __root(); | 2172 | __node_pointer __rt = __root(); |
| 2265 | while (__rt != nullptr) { | 2173 | while (__rt != nullptr) { |
| 2266 | if (value_comp()(__k, __rt->__value_)) { | 2174 | if (value_comp()(__k, __rt->__value_)) { |
| 2267 | __result = static_cast<__iter_pointer>(__rt); | 2175 | __result = static_cast<__end_node_pointer>(__rt); |
| 2268 | __rt = static_cast<__node_pointer>(__rt->__left_); | 2176 | __rt = static_cast<__node_pointer>(__rt->__left_); |
| 2269 | } else if (value_comp()(__rt->__value_, __k)) | 2177 | } else if (value_comp()(__rt->__value_, __k)) |
| 2270 | __rt = static_cast<__node_pointer>(__rt->__right_); | 2178 | __rt = static_cast<__node_pointer>(__rt->__right_); |
| 2271 | else | 2179 | else |
| 2272 | return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), | 2180 | return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)), |
| 2273 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); | 2181 | __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); |
| 2274 | } | 2182 | } |
| 2275 | return _Pp(const_iterator(__result), const_iterator(__result)); | 2183 | return _Pp(const_iterator(__result), const_iterator(__result)); |
| ... | @@ -2281,9 +2189,9 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT { | ... | @@ -2281,9 +2189,9 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT { |
| 2281 | __node_pointer __np = __p.__get_np(); | 2189 | __node_pointer __np = __p.__get_np(); |
| 2282 | if (__begin_node() == __p.__ptr_) { | 2190 | if (__begin_node() == __p.__ptr_) { |
| 2283 | if (__np->__right_ != nullptr) | 2191 | if (__np->__right_ != nullptr) |
| 2284 | __begin_node() = static_cast<__iter_pointer>(__np->__right_); | 2192 | __begin_node() = static_cast<__end_node_pointer>(__np->__right_); |
| 2285 | else | 2193 | else |
| 2286 | __begin_node() = static_cast<__iter_pointer>(__np->__parent_); | 2194 | __begin_node() = static_cast<__end_node_pointer>(__np->__parent_); |
| 2287 | } | 2195 | } |
| 2288 | --size(); | 2196 | --size(); |
| 2289 | std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); | 2197 | std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np)); |
lib/libcxx/include/__tuple/make_tuple_types.h+1-1| ... | @@ -60,7 +60,7 @@ struct __make_tuple_types { | ... | @@ -60,7 +60,7 @@ struct __make_tuple_types { |
| 60 | static_assert(_Sp <= _Ep, "__make_tuple_types input error"); | 60 | static_assert(_Sp <= _Ep, "__make_tuple_types input error"); |
| 61 | using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>; | 61 | using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>; |
| 62 | using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; | 62 | using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; |
| 63 | using type = typename _Maker::template __apply_quals<_Tp>; | 63 | using type _LIBCPP_NODEBUG = typename _Maker::template __apply_quals<_Tp>; |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | template <class... _Types, size_t _Ep> | 66 | template <class... _Types, size_t _Ep> |
lib/libcxx/include/__tuple/sfinae_helpers.h+1-1| ... | @@ -58,7 +58,7 @@ struct __tuple_constructible<_Tp, _Up, true, true> | ... | @@ -58,7 +58,7 @@ struct __tuple_constructible<_Tp, _Up, true, true> |
| 58 | typename __make_tuple_types<_Up>::type > {}; | 58 | typename __make_tuple_types<_Up>::type > {}; |
| 59 | 59 | ||
| 60 | template <size_t _Ip, class... _Tp> | 60 | template <size_t _Ip, class... _Tp> |
| 61 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > { | 61 | struct tuple_element<_Ip, tuple<_Tp...> > { |
| 62 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type; | 62 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type; |
| 63 | }; | 63 | }; |
| 64 | 64 |
lib/libcxx/include/__tuple/tuple_element.h+5-5| ... | @@ -21,27 +21,27 @@ | ... | @@ -21,27 +21,27 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | template <size_t _Ip, class _Tp> | 23 | template <size_t _Ip, class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS tuple_element; | 24 | struct tuple_element; |
| 25 | 25 | ||
| 26 | template <size_t _Ip, class _Tp> | 26 | template <size_t _Ip, class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> { | 27 | struct tuple_element<_Ip, const _Tp> { |
| 28 | using type _LIBCPP_NODEBUG = const typename tuple_element<_Ip, _Tp>::type; | 28 | using type _LIBCPP_NODEBUG = const typename tuple_element<_Ip, _Tp>::type; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | template <size_t _Ip, class _Tp> | 31 | template <size_t _Ip, class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> { | 32 | struct tuple_element<_Ip, volatile _Tp> { |
| 33 | using type _LIBCPP_NODEBUG = volatile typename tuple_element<_Ip, _Tp>::type; | 33 | using type _LIBCPP_NODEBUG = volatile typename tuple_element<_Ip, _Tp>::type; |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | template <size_t _Ip, class _Tp> | 36 | template <size_t _Ip, class _Tp> |
| 37 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> { | 37 | struct tuple_element<_Ip, const volatile _Tp> { |
| 38 | using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type; | 38 | using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type; |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | #ifndef _LIBCPP_CXX03_LANG | 41 | #ifndef _LIBCPP_CXX03_LANG |
| 42 | 42 | ||
| 43 | template <size_t _Ip, class... _Types> | 43 | template <size_t _Ip, class... _Types> |
| 44 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > { | 44 | struct tuple_element<_Ip, __tuple_types<_Types...> > { |
| 45 | static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); | 45 | static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); |
| 46 | using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>; | 46 | using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>; |
| 47 | }; | 47 | }; |
lib/libcxx/include/__tuple/tuple_size.h+11-14| ... | @@ -25,45 +25,42 @@ | ... | @@ -25,45 +25,42 @@ |
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | template <class _Tp> | 27 | template <class _Tp> |
| 28 | struct _LIBCPP_TEMPLATE_VIS tuple_size; | 28 | struct tuple_size; |
| 29 | 29 | ||
| 30 | #if !defined(_LIBCPP_CXX03_LANG) | 30 | #if !defined(_LIBCPP_CXX03_LANG) |
| 31 | template <class _Tp, class...> | 31 | template <class _Tp, class...> |
| 32 | using __enable_if_tuple_size_imp _LIBCPP_NODEBUG = _Tp; | 32 | using __enable_if_tuple_size_imp _LIBCPP_NODEBUG = _Tp; |
| 33 | 33 | ||
| 34 | template <class _Tp> | 34 | template <class _Tp> |
| 35 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< const _Tp, | 35 | struct tuple_size< |
| 36 | __enable_if_t<!is_volatile<_Tp>::value>, | 36 | __enable_if_tuple_size_imp<const _Tp, __enable_if_t<!is_volatile<_Tp>::value>, decltype(tuple_size<_Tp>::value)>> |
| 37 | integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> | ||
| 38 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; | 37 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; |
| 39 | 38 | ||
| 40 | template <class _Tp> | 39 | template <class _Tp> |
| 41 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp, | 40 | struct tuple_size< |
| 42 | __enable_if_t<!is_const<_Tp>::value>, | 41 | __enable_if_tuple_size_imp<volatile _Tp, __enable_if_t<!is_const<_Tp>::value>, decltype(tuple_size<_Tp>::value)>> |
| 43 | integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> | ||
| 44 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; | 42 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; |
| 45 | 43 | ||
| 46 | template <class _Tp> | 44 | template <class _Tp> |
| 47 | struct _LIBCPP_TEMPLATE_VIS | 45 | struct tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, decltype(tuple_size<_Tp>::value)>> |
| 48 | tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> | ||
| 49 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; | 46 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; |
| 50 | 47 | ||
| 51 | #else | 48 | #else |
| 52 | template <class _Tp> | 49 | template <class _Tp> |
| 53 | struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {}; | 50 | struct tuple_size<const _Tp> : public tuple_size<_Tp> {}; |
| 54 | template <class _Tp> | 51 | template <class _Tp> |
| 55 | struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {}; | 52 | struct tuple_size<volatile _Tp> : public tuple_size<_Tp> {}; |
| 56 | template <class _Tp> | 53 | template <class _Tp> |
| 57 | struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {}; | 54 | struct tuple_size<const volatile _Tp> : public tuple_size<_Tp> {}; |
| 58 | #endif | 55 | #endif |
| 59 | 56 | ||
| 60 | #ifndef _LIBCPP_CXX03_LANG | 57 | #ifndef _LIBCPP_CXX03_LANG |
| 61 | 58 | ||
| 62 | template <class... _Tp> | 59 | template <class... _Tp> |
| 63 | struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; | 60 | struct tuple_size<tuple<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; |
| 64 | 61 | ||
| 65 | template <class... _Tp> | 62 | template <class... _Tp> |
| 66 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; | 63 | struct tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {}; |
| 67 | 64 | ||
| 68 | # if _LIBCPP_STD_VER >= 17 | 65 | # if _LIBCPP_STD_VER >= 17 |
| 69 | template <class _Tp> | 66 | template <class _Tp> |
lib/libcxx/include/__type_traits/add_cv_quals.h+3-3| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | template <class _Tp> | 20 | template <class _Tp> |
| 21 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_const { | 21 | struct _LIBCPP_NO_SPECIALIZATIONS add_const { |
| 22 | using type _LIBCPP_NODEBUG = const _Tp; | 22 | using type _LIBCPP_NODEBUG = const _Tp; |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| ... | @@ -28,7 +28,7 @@ using add_const_t = typename add_const<_Tp>::type; | ... | @@ -28,7 +28,7 @@ using add_const_t = typename add_const<_Tp>::type; |
| 28 | #endif | 28 | #endif |
| 29 | 29 | ||
| 30 | template <class _Tp> | 30 | template <class _Tp> |
| 31 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_cv { | 31 | struct _LIBCPP_NO_SPECIALIZATIONS add_cv { |
| 32 | using type _LIBCPP_NODEBUG = const volatile _Tp; | 32 | using type _LIBCPP_NODEBUG = const volatile _Tp; |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| ... | @@ -38,7 +38,7 @@ using add_cv_t = typename add_cv<_Tp>::type; | ... | @@ -38,7 +38,7 @@ using add_cv_t = typename add_cv<_Tp>::type; |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | template <class _Tp> | 40 | template <class _Tp> |
| 41 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_volatile { | 41 | struct _LIBCPP_NO_SPECIALIZATIONS add_volatile { |
| 42 | using type _LIBCPP_NODEBUG = volatile _Tp; | 42 | using type _LIBCPP_NODEBUG = volatile _Tp; |
| 43 | }; | 43 | }; |
| 44 | 44 |
lib/libcxx/include/__type_traits/add_lvalue_reference.h deleted-54| ... | @@ -1,54 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/is_referenceable.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if __has_builtin(__add_lvalue_reference) | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp); | ||
| 25 | |||
| 26 | #else | ||
| 27 | |||
| 28 | template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value> | ||
| 29 | struct __add_lvalue_reference_impl { | ||
| 30 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 31 | }; | ||
| 32 | template <class _Tp > | ||
| 33 | struct __add_lvalue_reference_impl<_Tp, true> { | ||
| 34 | using type _LIBCPP_NODEBUG = _Tp&; | ||
| 35 | }; | ||
| 36 | |||
| 37 | template <class _Tp> | ||
| 38 | using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type; | ||
| 39 | |||
| 40 | #endif // __has_builtin(__add_lvalue_reference) | ||
| 41 | |||
| 42 | template <class _Tp> | ||
| 43 | struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference { | ||
| 44 | using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>; | ||
| 45 | }; | ||
| 46 | |||
| 47 | #if _LIBCPP_STD_VER >= 14 | ||
| 48 | template <class _Tp> | ||
| 49 | using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>; | ||
| 50 | #endif | ||
| 51 | |||
| 52 | _LIBCPP_END_NAMESPACE_STD | ||
| 53 | |||
| 54 | #endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | ||
lib/libcxx/include/__type_traits/add_pointer.h+14-4| ... | @@ -20,13 +20,23 @@ | ... | @@ -20,13 +20,23 @@ |
| 20 | 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | #if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer) | 23 | #if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) |
| 24 | 24 | ||
| 25 | template <class _Tp> | ||
| 26 | struct _LIBCPP_NO_SPECIALIZATIONS add_pointer { | ||
| 27 | using type _LIBCPP_NODEBUG = __add_pointer(_Tp); | ||
| 28 | }; | ||
| 29 | |||
| 30 | # ifdef _LIBCPP_COMPILER_GCC | ||
| 31 | template <class _Tp> | ||
| 32 | using __add_pointer_t _LIBCPP_NODEBUG = typename add_pointer<_Tp>::type; | ||
| 33 | # else | ||
| 25 | template <class _Tp> | 34 | template <class _Tp> |
| 26 | using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp); | 35 | using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp); |
| 36 | # endif | ||
| 27 | 37 | ||
| 28 | #else | 38 | #else |
| 29 | template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value> | 39 | template <class _Tp, bool = __is_referenceable_v<_Tp> || is_void<_Tp>::value> |
| 30 | struct __add_pointer_impl { | 40 | struct __add_pointer_impl { |
| 31 | using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*; | 41 | using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*; |
| 32 | }; | 42 | }; |
| ... | @@ -38,13 +48,13 @@ struct __add_pointer_impl<_Tp, false> { | ... | @@ -38,13 +48,13 @@ struct __add_pointer_impl<_Tp, false> { |
| 38 | template <class _Tp> | 48 | template <class _Tp> |
| 39 | using __add_pointer_t = typename __add_pointer_impl<_Tp>::type; | 49 | using __add_pointer_t = typename __add_pointer_impl<_Tp>::type; |
| 40 | 50 | ||
| 41 | #endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer) | ||
| 42 | |||
| 43 | template <class _Tp> | 51 | template <class _Tp> |
| 44 | struct _LIBCPP_NO_SPECIALIZATIONS add_pointer { | 52 | struct _LIBCPP_NO_SPECIALIZATIONS add_pointer { |
| 45 | using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>; | 53 | using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>; |
| 46 | }; | 54 | }; |
| 47 | 55 | ||
| 56 | #endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) | ||
| 57 | |||
| 48 | #if _LIBCPP_STD_VER >= 14 | 58 | #if _LIBCPP_STD_VER >= 14 |
| 49 | template <class _Tp> | 59 | template <class _Tp> |
| 50 | using add_pointer_t = __add_pointer_t<_Tp>; | 60 | using add_pointer_t = __add_pointer_t<_Tp>; |
lib/libcxx/include/__type_traits/add_reference.h created+58| ... | @@ -0,0 +1,58 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | template <class _Tp> | ||
| 21 | struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference { | ||
| 22 | using type _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp); | ||
| 23 | }; | ||
| 24 | |||
| 25 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 26 | template <class _Tp> | ||
| 27 | using __add_lvalue_reference_t _LIBCPP_NODEBUG = typename add_lvalue_reference<_Tp>::type; | ||
| 28 | #else | ||
| 29 | template <class _Tp> | ||
| 30 | using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp); | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #if _LIBCPP_STD_VER >= 14 | ||
| 34 | template <class _Tp> | ||
| 35 | using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>; | ||
| 36 | #endif | ||
| 37 | |||
| 38 | template <class _Tp> | ||
| 39 | struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference { | ||
| 40 | using type _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp); | ||
| 41 | }; | ||
| 42 | |||
| 43 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 44 | template <class _Tp> | ||
| 45 | using __add_rvalue_reference_t _LIBCPP_NODEBUG = typename add_rvalue_reference<_Tp>::type; | ||
| 46 | #else | ||
| 47 | template <class _Tp> | ||
| 48 | using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp); | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #if _LIBCPP_STD_VER >= 14 | ||
| 52 | template <class _Tp> | ||
| 53 | using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>; | ||
| 54 | #endif | ||
| 55 | |||
| 56 | _LIBCPP_END_NAMESPACE_STD | ||
| 57 | |||
| 58 | #endif // _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H | ||
lib/libcxx/include/__type_traits/add_rvalue_reference.h deleted-54| ... | @@ -1,54 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/is_referenceable.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if __has_builtin(__add_rvalue_reference) | ||
| 22 | |||
| 23 | template <class _Tp> | ||
| 24 | using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp); | ||
| 25 | |||
| 26 | #else | ||
| 27 | |||
| 28 | template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value> | ||
| 29 | struct __add_rvalue_reference_impl { | ||
| 30 | using type _LIBCPP_NODEBUG = _Tp; | ||
| 31 | }; | ||
| 32 | template <class _Tp > | ||
| 33 | struct __add_rvalue_reference_impl<_Tp, true> { | ||
| 34 | using type _LIBCPP_NODEBUG = _Tp&&; | ||
| 35 | }; | ||
| 36 | |||
| 37 | template <class _Tp> | ||
| 38 | using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type; | ||
| 39 | |||
| 40 | #endif // __has_builtin(__add_rvalue_reference) | ||
| 41 | |||
| 42 | template <class _Tp> | ||
| 43 | struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference { | ||
| 44 | using type = __add_rvalue_reference_t<_Tp>; | ||
| 45 | }; | ||
| 46 | |||
| 47 | #if _LIBCPP_STD_VER >= 14 | ||
| 48 | template <class _Tp> | ||
| 49 | using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>; | ||
| 50 | #endif | ||
| 51 | |||
| 52 | _LIBCPP_END_NAMESPACE_STD | ||
| 53 | |||
| 54 | #endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | ||
lib/libcxx/include/__type_traits/aligned_storage.h+1-1| ... | @@ -68,7 +68,7 @@ struct __find_max_align<__type_list<_Head, _Tail...>, _Len> | ... | @@ -68,7 +68,7 @@ struct __find_max_align<__type_list<_Head, _Tail...>, _Len> |
| 68 | __select_align<_Len, _Head::value, __find_max_align<__type_list<_Tail...>, _Len>::value>::value> {}; | 68 | __select_align<_Len, _Head::value, __find_max_align<__type_list<_Tail...>, _Len>::value>::value> {}; |
| 69 | 69 | ||
| 70 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> | 70 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
| 71 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS aligned_storage { | 71 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_storage { |
| 72 | union _ALIGNAS(_Align) type { | 72 | union _ALIGNAS(_Align) type { |
| 73 | unsigned char __data[(_Len + _Align - 1) / _Align * _Align]; | 73 | unsigned char __data[(_Len + _Align - 1) / _Align * _Align]; |
| 74 | }; | 74 | }; |
lib/libcxx/include/__type_traits/alignment_of.h+1-2| ... | @@ -20,8 +20,7 @@ | ... | @@ -20,8 +20,7 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _Tp> | 22 | template <class _Tp> |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS alignment_of | 23 | struct _LIBCPP_NO_SPECIALIZATIONS alignment_of : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; |
| 24 | : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; | ||
| 25 | 24 | ||
| 26 | #if _LIBCPP_STD_VER >= 17 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 27 | template <class _Tp> | 26 | template <class _Tp> |
lib/libcxx/include/__type_traits/common_reference.h+22-12| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H | 10 | #define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_pointer.h> | ||
| 13 | #include <__type_traits/common_type.h> | 14 | #include <__type_traits/common_type.h> |
| 14 | #include <__type_traits/copy_cv.h> | 15 | #include <__type_traits/copy_cv.h> |
| 15 | #include <__type_traits/copy_cvref.h> | 16 | #include <__type_traits/copy_cvref.h> |
| ... | @@ -109,11 +110,18 @@ struct __common_ref {}; | ... | @@ -109,11 +110,18 @@ struct __common_ref {}; |
| 109 | // Note C: For the common_reference trait applied to a parameter pack [...] | 110 | // Note C: For the common_reference trait applied to a parameter pack [...] |
| 110 | 111 | ||
| 111 | template <class...> | 112 | template <class...> |
| 112 | struct common_reference; | 113 | struct _LIBCPP_NO_SPECIALIZATIONS common_reference; |
| 113 | 114 | ||
| 114 | template <class... _Types> | 115 | template <class... _Types> |
| 115 | using common_reference_t = typename common_reference<_Types...>::type; | 116 | using common_reference_t = typename common_reference<_Types...>::type; |
| 116 | 117 | ||
| 118 | template <class, class, template <class> class, template <class> class> | ||
| 119 | struct basic_common_reference {}; | ||
| 120 | |||
| 121 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 122 | # if __has_warning("-Winvalid-specialization") | ||
| 123 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | ||
| 124 | # endif | ||
| 117 | // bullet 1 - sizeof...(T) == 0 | 125 | // bullet 1 - sizeof...(T) == 0 |
| 118 | template <> | 126 | template <> |
| 119 | struct common_reference<> {}; | 127 | struct common_reference<> {}; |
| ... | @@ -121,7 +129,7 @@ struct common_reference<> {}; | ... | @@ -121,7 +129,7 @@ struct common_reference<> {}; |
| 121 | // bullet 2 - sizeof...(T) == 1 | 129 | // bullet 2 - sizeof...(T) == 1 |
| 122 | template <class _Tp> | 130 | template <class _Tp> |
| 123 | struct common_reference<_Tp> { | 131 | struct common_reference<_Tp> { |
| 124 | using type = _Tp; | 132 | using type _LIBCPP_NODEBUG = _Tp; |
| 125 | }; | 133 | }; |
| 126 | 134 | ||
| 127 | // bullet 3 - sizeof...(T) == 2 | 135 | // bullet 3 - sizeof...(T) == 2 |
| ... | @@ -132,22 +140,23 @@ struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> | ... | @@ -132,22 +140,23 @@ struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> |
| 132 | template <class _Tp, class _Up> | 140 | template <class _Tp, class _Up> |
| 133 | struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {}; | 141 | struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {}; |
| 134 | 142 | ||
| 135 | // sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then | 143 | // sub-bullet 1 - Let R be COMMON-REF(T1, T2). If T1 and T2 are reference types, R is well-formed, and |
| 136 | // the member typedef `type` denotes that type. | 144 | // is_convertible_v<add_pointer_t<T1>, add_pointer_t<R>> && is_convertible_v<add_pointer_t<T2>, add_pointer_t<R>> is |
| 145 | // true, then the member typedef type denotes R. | ||
| 146 | |||
| 137 | template <class _Tp, class _Up> | 147 | template <class _Tp, class _Up> |
| 138 | struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {}; | 148 | struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {}; |
| 139 | 149 | ||
| 140 | template <class _Tp, class _Up> | 150 | template <class _Tp, class _Up> |
| 141 | requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } | 151 | requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } && |
| 152 | is_convertible_v<add_pointer_t<_Tp>, add_pointer_t<__common_ref_t<_Tp, _Up>>> && | ||
| 153 | is_convertible_v<add_pointer_t<_Up>, add_pointer_t<__common_ref_t<_Tp, _Up>>> | ||
| 142 | struct __common_reference_sub_bullet1<_Tp, _Up> { | 154 | struct __common_reference_sub_bullet1<_Tp, _Up> { |
| 143 | using type = __common_ref_t<_Tp, _Up>; | 155 | using type _LIBCPP_NODEBUG = __common_ref_t<_Tp, _Up>; |
| 144 | }; | 156 | }; |
| 145 | 157 | ||
| 146 | // sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type | 158 | // sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type |
| 147 | // is well-formed, then the member typedef `type` denotes that type. | 159 | // is well-formed, then the member typedef `type` denotes that type. |
| 148 | template <class, class, template <class> class, template <class> class> | ||
| 149 | struct basic_common_reference {}; | ||
| 150 | |||
| 151 | template <class _Tp, class _Up> | 160 | template <class _Tp, class _Up> |
| 152 | using __basic_common_reference_t _LIBCPP_NODEBUG = | 161 | using __basic_common_reference_t _LIBCPP_NODEBUG = |
| 153 | typename basic_common_reference<remove_cvref_t<_Tp>, | 162 | typename basic_common_reference<remove_cvref_t<_Tp>, |
| ... | @@ -158,7 +167,7 @@ using __basic_common_reference_t _LIBCPP_NODEBUG = | ... | @@ -158,7 +167,7 @@ using __basic_common_reference_t _LIBCPP_NODEBUG = |
| 158 | template <class _Tp, class _Up> | 167 | template <class _Tp, class _Up> |
| 159 | requires requires { typename __basic_common_reference_t<_Tp, _Up>; } | 168 | requires requires { typename __basic_common_reference_t<_Tp, _Up>; } |
| 160 | struct __common_reference_sub_bullet2<_Tp, _Up> { | 169 | struct __common_reference_sub_bullet2<_Tp, _Up> { |
| 161 | using type = __basic_common_reference_t<_Tp, _Up>; | 170 | using type _LIBCPP_NODEBUG = __basic_common_reference_t<_Tp, _Up>; |
| 162 | }; | 171 | }; |
| 163 | 172 | ||
| 164 | // sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed, | 173 | // sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed, |
| ... | @@ -166,7 +175,7 @@ struct __common_reference_sub_bullet2<_Tp, _Up> { | ... | @@ -166,7 +175,7 @@ struct __common_reference_sub_bullet2<_Tp, _Up> { |
| 166 | template <class _Tp, class _Up> | 175 | template <class _Tp, class _Up> |
| 167 | requires requires { typename __cond_res<_Tp, _Up>; } | 176 | requires requires { typename __cond_res<_Tp, _Up>; } |
| 168 | struct __common_reference_sub_bullet3<_Tp, _Up> { | 177 | struct __common_reference_sub_bullet3<_Tp, _Up> { |
| 169 | using type = __cond_res<_Tp, _Up>; | 178 | using type _LIBCPP_NODEBUG = __cond_res<_Tp, _Up>; |
| 170 | }; | 179 | }; |
| 171 | 180 | ||
| 172 | // sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed, | 181 | // sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed, |
| ... | @@ -180,10 +189,11 @@ struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {}; | ... | @@ -180,10 +189,11 @@ struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {}; |
| 180 | template <class _Tp, class _Up, class _Vp, class... _Rest> | 189 | template <class _Tp, class _Up, class _Vp, class... _Rest> |
| 181 | requires requires { typename common_reference_t<_Tp, _Up>; } | 190 | requires requires { typename common_reference_t<_Tp, _Up>; } |
| 182 | struct common_reference<_Tp, _Up, _Vp, _Rest...> : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> {}; | 191 | struct common_reference<_Tp, _Up, _Vp, _Rest...> : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> {}; |
| 192 | _LIBCPP_DIAGNOSTIC_POP | ||
| 183 | 193 | ||
| 184 | // bullet 5 - Otherwise, there shall be no member `type`. | 194 | // bullet 5 - Otherwise, there shall be no member `type`. |
| 185 | template <class...> | 195 | template <class...> |
| 186 | struct common_reference {}; | 196 | struct _LIBCPP_NO_SPECIALIZATIONS common_reference {}; |
| 187 | 197 | ||
| 188 | #endif // _LIBCPP_STD_VER >= 20 | 198 | #endif // _LIBCPP_STD_VER >= 20 |
| 189 | 199 |
lib/libcxx/include/__type_traits/common_type.h+6-7| ... | @@ -48,7 +48,7 @@ struct __common_type3 {}; | ... | @@ -48,7 +48,7 @@ struct __common_type3 {}; |
| 48 | // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." | 48 | // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." |
| 49 | template <class _Tp, class _Up> | 49 | template <class _Tp, class _Up> |
| 50 | struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> { | 50 | struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> { |
| 51 | using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; | 51 | using type _LIBCPP_NODEBUG = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | template <class _Tp, class _Up, class = void> | 54 | template <class _Tp, class _Up, class = void> |
| ... | @@ -70,7 +70,7 @@ struct __common_type_impl {}; | ... | @@ -70,7 +70,7 @@ struct __common_type_impl {}; |
| 70 | template <class... _Tp> | 70 | template <class... _Tp> |
| 71 | struct __common_types; | 71 | struct __common_types; |
| 72 | template <class... _Tp> | 72 | template <class... _Tp> |
| 73 | struct _LIBCPP_TEMPLATE_VIS common_type; | 73 | struct common_type; |
| 74 | 74 | ||
| 75 | template <class _Tp, class _Up> | 75 | template <class _Tp, class _Up> |
| 76 | struct __common_type_impl< __common_types<_Tp, _Up>, __void_t<typename common_type<_Tp, _Up>::type> > { | 76 | struct __common_type_impl< __common_types<_Tp, _Up>, __void_t<typename common_type<_Tp, _Up>::type> > { |
| ... | @@ -84,18 +84,18 @@ struct __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...>, __void_t<type | ... | @@ -84,18 +84,18 @@ struct __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...>, __void_t<type |
| 84 | // bullet 1 - sizeof...(Tp) == 0 | 84 | // bullet 1 - sizeof...(Tp) == 0 |
| 85 | 85 | ||
| 86 | template <> | 86 | template <> |
| 87 | struct _LIBCPP_TEMPLATE_VIS common_type<> {}; | 87 | struct common_type<> {}; |
| 88 | 88 | ||
| 89 | // bullet 2 - sizeof...(Tp) == 1 | 89 | // bullet 2 - sizeof...(Tp) == 1 |
| 90 | 90 | ||
| 91 | template <class _Tp> | 91 | template <class _Tp> |
| 92 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> : public common_type<_Tp, _Tp> {}; | 92 | struct common_type<_Tp> : public common_type<_Tp, _Tp> {}; |
| 93 | 93 | ||
| 94 | // bullet 3 - sizeof...(Tp) == 2 | 94 | // bullet 3 - sizeof...(Tp) == 2 |
| 95 | 95 | ||
| 96 | // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." | 96 | // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." |
| 97 | template <class _Tp, class _Up> | 97 | template <class _Tp, class _Up> |
| 98 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> | 98 | struct common_type<_Tp, _Up> |
| 99 | : __conditional_t<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value, | 99 | : __conditional_t<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value, |
| 100 | __common_type2_imp<_Tp, _Up>, | 100 | __common_type2_imp<_Tp, _Up>, |
| 101 | common_type<__decay_t<_Tp>, __decay_t<_Up> > > {}; | 101 | common_type<__decay_t<_Tp>, __decay_t<_Up> > > {}; |
| ... | @@ -103,8 +103,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> | ... | @@ -103,8 +103,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> |
| 103 | // bullet 4 - sizeof...(Tp) > 2 | 103 | // bullet 4 - sizeof...(Tp) > 2 |
| 104 | 104 | ||
| 105 | template <class _Tp, class _Up, class _Vp, class... _Rest> | 105 | template <class _Tp, class _Up, class _Vp, class... _Rest> |
| 106 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp, _Rest...> | 106 | struct common_type<_Tp, _Up, _Vp, _Rest...> : __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...> > {}; |
| 107 | : __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...> > {}; | ||
| 108 | 107 | ||
| 109 | #endif | 108 | #endif |
| 110 | 109 |
lib/libcxx/include/__type_traits/conditional.h+2-2| ... | @@ -36,7 +36,7 @@ template <bool _Cond, class _IfRes, class _ElseRes> | ... | @@ -36,7 +36,7 @@ template <bool _Cond, class _IfRes, class _ElseRes> |
| 36 | using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>; | 36 | using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>; |
| 37 | 37 | ||
| 38 | template <bool _Bp, class _If, class _Then> | 38 | template <bool _Bp, class _If, class _Then> |
| 39 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS conditional { | 39 | struct _LIBCPP_NO_SPECIALIZATIONS conditional { |
| 40 | using type _LIBCPP_NODEBUG = _If; | 40 | using type _LIBCPP_NODEBUG = _If; |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| ... | @@ -45,7 +45,7 @@ _LIBCPP_DIAGNOSTIC_PUSH | ... | @@ -45,7 +45,7 @@ _LIBCPP_DIAGNOSTIC_PUSH |
| 45 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | 45 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") |
| 46 | #endif | 46 | #endif |
| 47 | template <class _If, class _Then> | 47 | template <class _If, class _Then> |
| 48 | struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> { | 48 | struct conditional<false, _If, _Then> { |
| 49 | using type _LIBCPP_NODEBUG = _Then; | 49 | using type _LIBCPP_NODEBUG = _Then; |
| 50 | }; | 50 | }; |
| 51 | _LIBCPP_DIAGNOSTIC_POP | 51 | _LIBCPP_DIAGNOSTIC_POP |
lib/libcxx/include/__type_traits/container_traits.h+3| ... | @@ -36,6 +36,9 @@ struct __container_traits { | ... | @@ -36,6 +36,9 @@ struct __container_traits { |
| 36 | // `insert(...)` or `emplace(...)` has strong exception guarantee, that is, if the function | 36 | // `insert(...)` or `emplace(...)` has strong exception guarantee, that is, if the function |
| 37 | // exits via an exception, the original container is unaffected | 37 | // exits via an exception, the original container is unaffected |
| 38 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = false; | 38 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = false; |
| 39 | |||
| 40 | // A trait that tells whether a container supports `reserve(n)` member function. | ||
| 41 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 39 | }; | 42 | }; |
| 40 | 43 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | 44 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/copy_cvref.h+1-2| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H | 10 | #define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_reference.h> |
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/copy_cv.h> | 14 | #include <__type_traits/copy_cv.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__type_traits/decay.h+6-38| ... | @@ -10,14 +10,6 @@ | ... | @@ -10,14 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_DECAY_H | 10 | #define _LIBCPP___TYPE_TRAITS_DECAY_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_pointer.h> | ||
| 14 | #include <__type_traits/conditional.h> | ||
| 15 | #include <__type_traits/is_array.h> | ||
| 16 | #include <__type_traits/is_function.h> | ||
| 17 | #include <__type_traits/is_referenceable.h> | ||
| 18 | #include <__type_traits/remove_cv.h> | ||
| 19 | #include <__type_traits/remove_extent.h> | ||
| 20 | #include <__type_traits/remove_reference.h> | ||
| 21 | 13 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -25,42 +17,18 @@ | ... | @@ -25,42 +17,18 @@ |
| 25 | 17 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 19 | ||
| 28 | #if __has_builtin(__decay) | ||
| 29 | template <class _Tp> | ||
| 30 | using __decay_t _LIBCPP_NODEBUG = __decay(_Tp); | ||
| 31 | |||
| 32 | template <class _Tp> | 20 | template <class _Tp> |
| 33 | struct _LIBCPP_NO_SPECIALIZATIONS decay { | 21 | struct _LIBCPP_NO_SPECIALIZATIONS decay { |
| 34 | using type _LIBCPP_NODEBUG = __decay_t<_Tp>; | 22 | using type _LIBCPP_NODEBUG = __decay(_Tp); |
| 35 | }; | ||
| 36 | |||
| 37 | #else | ||
| 38 | template <class _Up, bool> | ||
| 39 | struct __decay { | ||
| 40 | using type _LIBCPP_NODEBUG = __remove_cv_t<_Up>; | ||
| 41 | }; | ||
| 42 | |||
| 43 | template <class _Up> | ||
| 44 | struct __decay<_Up, true> { | ||
| 45 | public: | ||
| 46 | using type _LIBCPP_NODEBUG = | ||
| 47 | __conditional_t<is_array<_Up>::value, | ||
| 48 | __add_pointer_t<__remove_extent_t<_Up> >, | ||
| 49 | __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >; | ||
| 50 | }; | 23 | }; |
| 51 | 24 | ||
| 25 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 52 | template <class _Tp> | 26 | template <class _Tp> |
| 53 | struct _LIBCPP_TEMPLATE_VIS decay { | 27 | using __decay_t _LIBCPP_NODEBUG = typename decay<_Tp>::type; |
| 54 | private: | 28 | #else |
| 55 | using _Up _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>; | ||
| 56 | |||
| 57 | public: | ||
| 58 | using type _LIBCPP_NODEBUG = typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type; | ||
| 59 | }; | ||
| 60 | |||
| 61 | template <class _Tp> | 29 | template <class _Tp> |
| 62 | using __decay_t = typename decay<_Tp>::type; | 30 | using __decay_t _LIBCPP_NODEBUG = __decay(_Tp); |
| 63 | #endif // __has_builtin(__decay) | 31 | #endif |
| 64 | 32 | ||
| 65 | #if _LIBCPP_STD_VER >= 14 | 33 | #if _LIBCPP_STD_VER >= 14 |
| 66 | template <class _Tp> | 34 | template <class _Tp> |
lib/libcxx/include/__type_traits/dependent_type.h+1-1| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | template <class _Tp, bool> | 20 | template <class _Tp, bool> |
| 21 | struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; | 21 | struct __dependent_type : public _Tp {}; |
| 22 | 22 | ||
| 23 | _LIBCPP_END_NAMESPACE_STD | 23 | _LIBCPP_END_NAMESPACE_STD |
| 24 | 24 |
lib/libcxx/include/__type_traits/desugars_to.h+12| ... | @@ -52,6 +52,18 @@ struct __totally_ordered_less_tag {}; | ... | @@ -52,6 +52,18 @@ struct __totally_ordered_less_tag {}; |
| 52 | template <class _CanonicalTag, class _Operation, class... _Args> | 52 | template <class _CanonicalTag, class _Operation, class... _Args> |
| 53 | inline const bool __desugars_to_v = false; | 53 | inline const bool __desugars_to_v = false; |
| 54 | 54 | ||
| 55 | // For the purpose of determining whether something desugars to something else, | ||
| 56 | // we disregard const and ref qualifiers on the operation itself. | ||
| 57 | template <class _CanonicalTag, class _Operation, class... _Args> | ||
| 58 | inline const bool __desugars_to_v<_CanonicalTag, _Operation const, _Args...> = | ||
| 59 | __desugars_to_v<_CanonicalTag, _Operation, _Args...>; | ||
| 60 | template <class _CanonicalTag, class _Operation, class... _Args> | ||
| 61 | inline const bool __desugars_to_v<_CanonicalTag, _Operation&, _Args...> = | ||
| 62 | __desugars_to_v<_CanonicalTag, _Operation, _Args...>; | ||
| 63 | template <class _CanonicalTag, class _Operation, class... _Args> | ||
| 64 | inline const bool __desugars_to_v<_CanonicalTag, _Operation&&, _Args...> = | ||
| 65 | __desugars_to_v<_CanonicalTag, _Operation, _Args...>; | ||
| 66 | |||
| 55 | _LIBCPP_END_NAMESPACE_STD | 67 | _LIBCPP_END_NAMESPACE_STD |
| 56 | 68 | ||
| 57 | #endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H | 69 | #endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H |
lib/libcxx/include/__type_traits/enable_if.h+2-2| ... | @@ -18,14 +18,14 @@ | ... | @@ -18,14 +18,14 @@ |
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | template <bool, class _Tp = void> | 20 | template <bool, class _Tp = void> |
| 21 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS enable_if{}; | 21 | struct _LIBCPP_NO_SPECIALIZATIONS enable_if{}; |
| 22 | 22 | ||
| 23 | _LIBCPP_DIAGNOSTIC_PUSH | 23 | _LIBCPP_DIAGNOSTIC_PUSH |
| 24 | #if __has_warning("-Winvalid-specialization") | 24 | #if __has_warning("-Winvalid-specialization") |
| 25 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | 25 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") |
| 26 | #endif | 26 | #endif |
| 27 | template <class _Tp> | 27 | template <class _Tp> |
| 28 | struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> { | 28 | struct enable_if<true, _Tp> { |
| 29 | typedef _Tp type; | 29 | typedef _Tp type; |
| 30 | }; | 30 | }; |
| 31 | _LIBCPP_DIAGNOSTIC_POP | 31 | _LIBCPP_DIAGNOSTIC_POP |
lib/libcxx/include/__type_traits/extent.h+6-6| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if __has_builtin(__array_extent) | 22 | #if __has_builtin(__array_extent) |
| 23 | 23 | ||
| 24 | template <class _Tp, size_t _Dim = 0> | 24 | template <class _Tp, size_t _Dim = 0> |
| 25 | struct _LIBCPP_NO_SPECIALIZATIONS _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {}; | 25 | struct _LIBCPP_NO_SPECIALIZATIONS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {}; |
| 26 | 26 | ||
| 27 | # if _LIBCPP_STD_VER >= 17 | 27 | # if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp, unsigned _Ip = 0> | 28 | template <class _Tp, unsigned _Ip = 0> |
| ... | @@ -32,15 +32,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t extent_v = __array_extent(_Tp | ... | @@ -32,15 +32,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t extent_v = __array_extent(_Tp |
| 32 | #else // __has_builtin(__array_extent) | 32 | #else // __has_builtin(__array_extent) |
| 33 | 33 | ||
| 34 | template <class _Tp, unsigned _Ip = 0> | 34 | template <class _Tp, unsigned _Ip = 0> |
| 35 | struct _LIBCPP_TEMPLATE_VIS extent : public integral_constant<size_t, 0> {}; | 35 | struct extent : public integral_constant<size_t, 0> {}; |
| 36 | template <class _Tp> | 36 | template <class _Tp> |
| 37 | struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> : public integral_constant<size_t, 0> {}; | 37 | struct extent<_Tp[], 0> : public integral_constant<size_t, 0> {}; |
| 38 | template <class _Tp, unsigned _Ip> | 38 | template <class _Tp, unsigned _Ip> |
| 39 | struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {}; | 39 | struct extent<_Tp[], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {}; |
| 40 | template <class _Tp, size_t _Np> | 40 | template <class _Tp, size_t _Np> |
| 41 | struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> : public integral_constant<size_t, _Np> {}; | 41 | struct extent<_Tp[_Np], 0> : public integral_constant<size_t, _Np> {}; |
| 42 | template <class _Tp, size_t _Np, unsigned _Ip> | 42 | template <class _Tp, size_t _Np, unsigned _Ip> |
| 43 | struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {}; | 43 | struct extent<_Tp[_Np], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {}; |
| 44 | 44 | ||
| 45 | # if _LIBCPP_STD_VER >= 17 | 45 | # if _LIBCPP_STD_VER >= 17 |
| 46 | template <class _Tp, unsigned _Ip = 0> | 46 | template <class _Tp, unsigned _Ip = 0> |
lib/libcxx/include/__type_traits/has_unique_object_representation.h+2-8| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/integral_constant.h> |
| 14 | #include <__type_traits/remove_all_extents.h> | ||
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -22,13 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,13 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER >= 17 | 21 | #if _LIBCPP_STD_VER >= 17 |
| 23 | 22 | ||
| 24 | template <class _Tp> | 23 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations | 24 | struct _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations |
| 26 | // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents | 25 | : integral_constant<bool, __has_unique_object_representations(_Tp)> {}; |
| 27 | // even though it should not be necessary. This was reported to the compilers: | ||
| 28 | // - Clang: https://github.com/llvm/llvm-project/issues/95311 | ||
| 29 | // - GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115476 | ||
| 30 | // remove_all_extents_t can be removed once all the compilers we support have fixed this bug. | ||
| 31 | : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {}; | ||
| 32 | 26 | ||
| 33 | template <class _Tp> | 27 | template <class _Tp> |
| 34 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v = | 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v = |
lib/libcxx/include/__type_traits/has_virtual_destructor.h+1-1| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_virtual_destructor | 22 | struct _LIBCPP_NO_SPECIALIZATIONS has_virtual_destructor |
| 23 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; | 23 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; |
| 24 | 24 | ||
| 25 | #if _LIBCPP_STD_VER >= 17 | 25 | #if _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/__type_traits/integer_traits.h created+73| ... | @@ -0,0 +1,73 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | |||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 15 | # pragma GCC system_header | ||
| 16 | #endif | ||
| 17 | |||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 19 | |||
| 20 | // This trait is to determine whether a type is a /signed integer type/ | ||
| 21 | // See [basic.fundamental]/p1 | ||
| 22 | template <class _Tp> | ||
| 23 | inline const bool __is_signed_integer_v = false; | ||
| 24 | template <> | ||
| 25 | inline const bool __is_signed_integer_v<signed char> = true; | ||
| 26 | template <> | ||
| 27 | inline const bool __is_signed_integer_v<signed short> = true; | ||
| 28 | template <> | ||
| 29 | inline const bool __is_signed_integer_v<signed int> = true; | ||
| 30 | template <> | ||
| 31 | inline const bool __is_signed_integer_v<signed long> = true; | ||
| 32 | template <> | ||
| 33 | inline const bool __is_signed_integer_v<signed long long> = true; | ||
| 34 | #if _LIBCPP_HAS_INT128 | ||
| 35 | template <> | ||
| 36 | inline const bool __is_signed_integer_v<__int128_t> = true; | ||
| 37 | #endif | ||
| 38 | |||
| 39 | // This trait is to determine whether a type is an /unsigned integer type/ | ||
| 40 | // See [basic.fundamental]/p2 | ||
| 41 | template <class _Tp> | ||
| 42 | inline const bool __is_unsigned_integer_v = false; | ||
| 43 | template <> | ||
| 44 | inline const bool __is_unsigned_integer_v<unsigned char> = true; | ||
| 45 | template <> | ||
| 46 | inline const bool __is_unsigned_integer_v<unsigned short> = true; | ||
| 47 | template <> | ||
| 48 | inline const bool __is_unsigned_integer_v<unsigned int> = true; | ||
| 49 | template <> | ||
| 50 | inline const bool __is_unsigned_integer_v<unsigned long> = true; | ||
| 51 | template <> | ||
| 52 | inline const bool __is_unsigned_integer_v<unsigned long long> = true; | ||
| 53 | #if _LIBCPP_HAS_INT128 | ||
| 54 | template <> | ||
| 55 | inline const bool __is_unsigned_integer_v<__uint128_t> = true; | ||
| 56 | #endif | ||
| 57 | |||
| 58 | #if _LIBCPP_STD_VER >= 20 | ||
| 59 | template <class _Tp> | ||
| 60 | concept __signed_integer = __is_signed_integer_v<_Tp>; | ||
| 61 | |||
| 62 | template <class _Tp> | ||
| 63 | concept __unsigned_integer = __is_unsigned_integer_v<_Tp>; | ||
| 64 | |||
| 65 | // This isn't called __integer, because an integer type according to [basic.fundamental]/p11 is the same as an integral | ||
| 66 | // type. An integral type is _not_ the same set of types as signed and unsigned integer types combined. | ||
| 67 | template <class _Tp> | ||
| 68 | concept __signed_or_unsigned_integer = __signed_integer<_Tp> || __unsigned_integer<_Tp>; | ||
| 69 | #endif | ||
| 70 | |||
| 71 | _LIBCPP_END_NAMESPACE_STD | ||
| 72 | |||
| 73 | #endif // _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H | ||
lib/libcxx/include/__type_traits/integral_constant.h+1-1| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | template <class _Tp, _Tp __v> | 20 | template <class _Tp, _Tp __v> |
| 21 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS integral_constant { | 21 | struct _LIBCPP_NO_SPECIALIZATIONS integral_constant { |
| 22 | static inline _LIBCPP_CONSTEXPR const _Tp value = __v; | 22 | static inline _LIBCPP_CONSTEXPR const _Tp value = __v; |
| 23 | typedef _Tp value_type; | 23 | typedef _Tp value_type; |
| 24 | typedef integral_constant type; | 24 | typedef integral_constant type; |
lib/libcxx/include/__type_traits/invoke.h+110-37| ... | @@ -22,6 +22,7 @@ | ... | @@ -22,6 +22,7 @@ |
| 22 | #include <__type_traits/is_same.h> | 22 | #include <__type_traits/is_same.h> |
| 23 | #include <__type_traits/is_void.h> | 23 | #include <__type_traits/is_void.h> |
| 24 | #include <__type_traits/nat.h> | 24 | #include <__type_traits/nat.h> |
| 25 | #include <__type_traits/void_t.h> | ||
| 25 | #include <__utility/declval.h> | 26 | #include <__utility/declval.h> |
| 26 | #include <__utility/forward.h> | 27 | #include <__utility/forward.h> |
| 27 | 28 | ||
| ... | @@ -41,19 +42,22 @@ | ... | @@ -41,19 +42,22 @@ |
| 41 | // return std::invoke_r(std::forward<Args>(args)...); | 42 | // return std::invoke_r(std::forward<Args>(args)...); |
| 42 | // } | 43 | // } |
| 43 | // | 44 | // |
| 44 | // template <class Ret, class Func, class... Args> | ||
| 45 | // inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>; | ||
| 46 | // | ||
| 47 | // template <class Func, class... Args> | 45 | // template <class Func, class... Args> |
| 48 | // struct __is_invocable : is_invocable<Func, Args...> {}; | 46 | // struct __is_invocable : is_invocable<Func, Args...> {}; |
| 49 | // | 47 | // |
| 50 | // template <class Func, class... Args> | 48 | // template <class Func, class... Args> |
| 51 | // inline const bool __is_invocable_v = is_invocable_v<Func, Args...>; | 49 | // inline const bool __is_invocable_v = is_invocable_v<Func, Args...>; |
| 52 | // | 50 | // |
| 51 | // template <class Ret, class Func, class... Args> | ||
| 52 | // inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>; | ||
| 53 | // | ||
| 53 | // template <class Func, class... Args> | 54 | // template <class Func, class... Args> |
| 54 | // inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>; | 55 | // inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>; |
| 55 | // | 56 | // |
| 56 | // template <class Func, class... Args> | 57 | // template <class Func, class... Args> |
| 58 | // inline const bool __is_nothrow_invocable_r_v = is_nothrow_invocable_r_v<Func, Args...>; | ||
| 59 | // | ||
| 60 | // template <class Func, class... Args> | ||
| 57 | // struct __invoke_result : invoke_result {}; | 61 | // struct __invoke_result : invoke_result {}; |
| 58 | // | 62 | // |
| 59 | // template <class Func, class... Args> | 63 | // template <class Func, class... Args> |
| ... | @@ -61,6 +65,72 @@ | ... | @@ -61,6 +65,72 @@ |
| 61 | 65 | ||
| 62 | _LIBCPP_BEGIN_NAMESPACE_STD | 66 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 63 | 67 | ||
| 68 | #if __has_builtin(__builtin_invoke) | ||
| 69 | |||
| 70 | template <class, class... _Args> | ||
| 71 | struct __invoke_result_impl {}; | ||
| 72 | |||
| 73 | template <class... _Args> | ||
| 74 | struct __invoke_result_impl<__void_t<decltype(__builtin_invoke(std::declval<_Args>()...))>, _Args...> { | ||
| 75 | using type _LIBCPP_NODEBUG = decltype(__builtin_invoke(std::declval<_Args>()...)); | ||
| 76 | }; | ||
| 77 | |||
| 78 | template <class... _Args> | ||
| 79 | using __invoke_result _LIBCPP_NODEBUG = __invoke_result_impl<void, _Args...>; | ||
| 80 | |||
| 81 | template <class... _Args> | ||
| 82 | using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Args...>::type; | ||
| 83 | |||
| 84 | template <class... _Args> | ||
| 85 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __invoke_result_t<_Args...> __invoke(_Args&&... __args) | ||
| 86 | _NOEXCEPT_(noexcept(__builtin_invoke(std::forward<_Args>(__args)...))) { | ||
| 87 | return __builtin_invoke(std::forward<_Args>(__args)...); | ||
| 88 | } | ||
| 89 | |||
| 90 | template <class _Void, class... _Args> | ||
| 91 | inline const bool __is_invocable_impl = false; | ||
| 92 | |||
| 93 | template <class... _Args> | ||
| 94 | inline const bool __is_invocable_impl<__void_t<__invoke_result_t<_Args...> >, _Args...> = true; | ||
| 95 | |||
| 96 | template <class... _Args> | ||
| 97 | inline const bool __is_invocable_v = __is_invocable_impl<void, _Args...>; | ||
| 98 | |||
| 99 | template <class... _Args> | ||
| 100 | struct __is_invocable : integral_constant<bool, __is_invocable_v<_Args...> > {}; | ||
| 101 | |||
| 102 | template <class _Ret, bool, class... _Args> | ||
| 103 | inline const bool __is_invocable_r_impl = false; | ||
| 104 | |||
| 105 | template <class _Ret, class... _Args> | ||
| 106 | inline const bool __is_invocable_r_impl<_Ret, true, _Args...> = | ||
| 107 | __is_core_convertible<__invoke_result_t<_Args...>, _Ret>::value || is_void<_Ret>::value; | ||
| 108 | |||
| 109 | template <class _Ret, class... _Args> | ||
| 110 | inline const bool __is_invocable_r_v = __is_invocable_r_impl<_Ret, __is_invocable_v<_Args...>, _Args...>; | ||
| 111 | |||
| 112 | template <bool __is_invocable, class... _Args> | ||
| 113 | inline const bool __is_nothrow_invocable_impl = false; | ||
| 114 | |||
| 115 | template <class... _Args> | ||
| 116 | inline const bool __is_nothrow_invocable_impl<true, _Args...> = noexcept(__builtin_invoke(std::declval<_Args>()...)); | ||
| 117 | |||
| 118 | template <class... _Args> | ||
| 119 | inline const bool __is_nothrow_invocable_v = __is_nothrow_invocable_impl<__is_invocable_v<_Args...>, _Args...>; | ||
| 120 | |||
| 121 | template <bool __is_invocable, class _Ret, class... _Args> | ||
| 122 | inline const bool __is_nothrow_invocable_r_impl = false; | ||
| 123 | |||
| 124 | template <class _Ret, class... _Args> | ||
| 125 | inline const bool __is_nothrow_invocable_r_impl<true, _Ret, _Args...> = | ||
| 126 | __is_nothrow_core_convertible_v<__invoke_result_t<_Args...>, _Ret> || is_void<_Ret>::value; | ||
| 127 | |||
| 128 | template <class _Ret, class... _Args> | ||
| 129 | inline const bool __is_nothrow_invocable_r_v = | ||
| 130 | __is_nothrow_invocable_r_impl<__is_nothrow_invocable_v<_Args...>, _Ret, _Args...>; | ||
| 131 | |||
| 132 | #else // __has_builtin(__builtin_invoke) | ||
| 133 | |||
| 64 | template <class _DecayedFp> | 134 | template <class _DecayedFp> |
| 65 | struct __member_pointer_class_type {}; | 135 | struct __member_pointer_class_type {}; |
| 66 | 136 | ||
| ... | @@ -211,21 +281,21 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> { | ... | @@ -211,21 +281,21 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> { |
| 211 | template <class _Tp> | 281 | template <class _Tp> |
| 212 | static void __test_noexcept(_Tp) _NOEXCEPT; | 282 | static void __test_noexcept(_Tp) _NOEXCEPT; |
| 213 | 283 | ||
| 214 | #ifdef _LIBCPP_CXX03_LANG | 284 | # ifdef _LIBCPP_CXX03_LANG |
| 215 | static const bool value = false; | 285 | static const bool value = false; |
| 216 | #else | 286 | # else |
| 217 | static const bool value = | 287 | static const bool value = |
| 218 | noexcept(_ThisT::__test_noexcept<_Ret>(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...))); | 288 | noexcept(_ThisT::__test_noexcept<_Ret>(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...))); |
| 219 | #endif | 289 | # endif |
| 220 | }; | 290 | }; |
| 221 | 291 | ||
| 222 | template <class _Ret, class _Fp, class... _Args> | 292 | template <class _Ret, class _Fp, class... _Args> |
| 223 | struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> { | 293 | struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> { |
| 224 | #ifdef _LIBCPP_CXX03_LANG | 294 | # ifdef _LIBCPP_CXX03_LANG |
| 225 | static const bool value = false; | 295 | static const bool value = false; |
| 226 | #else | 296 | # else |
| 227 | static const bool value = noexcept(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)); | 297 | static const bool value = noexcept(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)); |
| 228 | #endif | 298 | # endif |
| 229 | }; | 299 | }; |
| 230 | 300 | ||
| 231 | template <class _Ret, class _Fp, class... _Args> | 301 | template <class _Ret, class _Fp, class... _Args> |
| ... | @@ -236,22 +306,6 @@ template <class _Fp, class... _Args> | ... | @@ -236,22 +306,6 @@ template <class _Fp, class... _Args> |
| 236 | using __nothrow_invokable _LIBCPP_NODEBUG = | 306 | using __nothrow_invokable _LIBCPP_NODEBUG = |
| 237 | __nothrow_invokable_r_imp<__is_invocable<_Fp, _Args...>::value, true, void, _Fp, _Args...>; | 307 | __nothrow_invokable_r_imp<__is_invocable<_Fp, _Args...>::value, true, void, _Fp, _Args...>; |
| 238 | 308 | ||
| 239 | template <class _Ret, bool = is_void<_Ret>::value> | ||
| 240 | struct __invoke_void_return_wrapper { | ||
| 241 | template <class... _Args> | ||
| 242 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static _Ret __call(_Args&&... __args) { | ||
| 243 | return std::__invoke(std::forward<_Args>(__args)...); | ||
| 244 | } | ||
| 245 | }; | ||
| 246 | |||
| 247 | template <class _Ret> | ||
| 248 | struct __invoke_void_return_wrapper<_Ret, true> { | ||
| 249 | template <class... _Args> | ||
| 250 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void __call(_Args&&... __args) { | ||
| 251 | std::__invoke(std::forward<_Args>(__args)...); | ||
| 252 | } | ||
| 253 | }; | ||
| 254 | |||
| 255 | template <class _Func, class... _Args> | 309 | template <class _Func, class... _Args> |
| 256 | inline const bool __is_invocable_v = __is_invocable<_Func, _Args...>::value; | 310 | inline const bool __is_invocable_v = __is_invocable<_Func, _Args...>::value; |
| 257 | 311 | ||
| ... | @@ -261,6 +315,9 @@ inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::val | ... | @@ -261,6 +315,9 @@ inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::val |
| 261 | template <class _Func, class... _Args> | 315 | template <class _Func, class... _Args> |
| 262 | inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value; | 316 | inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value; |
| 263 | 317 | ||
| 318 | template <class _Ret, class _Func, class... _Args> | ||
| 319 | inline const bool __is_nothrow_invocable_r_v = __nothrow_invokable_r<_Ret, _Func, _Args...>::value; | ||
| 320 | |||
| 264 | template <class _Func, class... _Args> | 321 | template <class _Func, class... _Args> |
| 265 | struct __invoke_result | 322 | struct __invoke_result |
| 266 | : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {}; | 323 | : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {}; |
| ... | @@ -268,6 +325,24 @@ struct __invoke_result | ... | @@ -268,6 +325,24 @@ struct __invoke_result |
| 268 | template <class _Func, class... _Args> | 325 | template <class _Func, class... _Args> |
| 269 | using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type; | 326 | using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type; |
| 270 | 327 | ||
| 328 | #endif // __has_builtin(__builtin_invoke_r) | ||
| 329 | |||
| 330 | template <class _Ret, bool = is_void<_Ret>::value> | ||
| 331 | struct __invoke_void_return_wrapper { | ||
| 332 | template <class... _Args> | ||
| 333 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static _Ret __call(_Args&&... __args) { | ||
| 334 | return std::__invoke(std::forward<_Args>(__args)...); | ||
| 335 | } | ||
| 336 | }; | ||
| 337 | |||
| 338 | template <class _Ret> | ||
| 339 | struct __invoke_void_return_wrapper<_Ret, true> { | ||
| 340 | template <class... _Args> | ||
| 341 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void __call(_Args&&... __args) { | ||
| 342 | std::__invoke(std::forward<_Args>(__args)...); | ||
| 343 | } | ||
| 344 | }; | ||
| 345 | |||
| 271 | template <class _Ret, class... _Args> | 346 | template <class _Ret, class... _Args> |
| 272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... __args) { | 347 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... __args) { |
| 273 | return __invoke_void_return_wrapper<_Ret>::__call(std::forward<_Args>(__args)...); | 348 | return __invoke_void_return_wrapper<_Ret>::__call(std::forward<_Args>(__args)...); |
| ... | @@ -278,11 +353,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... _ | ... | @@ -278,11 +353,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... _ |
| 278 | // is_invocable | 353 | // is_invocable |
| 279 | 354 | ||
| 280 | template <class _Fn, class... _Args> | 355 | template <class _Fn, class... _Args> |
| 281 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...>> {}; | 356 | struct _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...> > {}; |
| 282 | 357 | ||
| 283 | template <class _Ret, class _Fn, class... _Args> | 358 | template <class _Ret, class _Fn, class... _Args> |
| 284 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable_r | 359 | struct _LIBCPP_NO_SPECIALIZATIONS is_invocable_r : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {}; |
| 285 | : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {}; | ||
| 286 | 360 | ||
| 287 | template <class _Fn, class... _Args> | 361 | template <class _Fn, class... _Args> |
| 288 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>; | 362 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>; |
| ... | @@ -293,27 +367,26 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocab | ... | @@ -293,27 +367,26 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocab |
| 293 | // is_nothrow_invocable | 367 | // is_nothrow_invocable |
| 294 | 368 | ||
| 295 | template <class _Fn, class... _Args> | 369 | template <class _Fn, class... _Args> |
| 296 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable | 370 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable : bool_constant<__is_nothrow_invocable_v<_Fn, _Args...> > {}; |
| 297 | : bool_constant<__nothrow_invokable<_Fn, _Args...>::value> {}; | ||
| 298 | 371 | ||
| 299 | template <class _Ret, class _Fn, class... _Args> | 372 | template <class _Ret, class _Fn, class... _Args> |
| 300 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r | 373 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r |
| 301 | : bool_constant<__nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; | 374 | : bool_constant<__is_nothrow_invocable_r_v<_Ret, _Fn, _Args...>> {}; |
| 302 | 375 | ||
| 303 | template <class _Fn, class... _Args> | 376 | template <class _Fn, class... _Args> |
| 304 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value; | 377 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = __is_nothrow_invocable_v<_Fn, _Args...>; |
| 305 | 378 | ||
| 306 | template <class _Ret, class _Fn, class... _Args> | 379 | template <class _Ret, class _Fn, class... _Args> |
| 307 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v = | 380 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v = |
| 308 | is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; | 381 | __is_nothrow_invocable_r_v<_Ret, _Fn, _Args...>; |
| 309 | 382 | ||
| 310 | template <class _Fn, class... _Args> | 383 | template <class _Fn, class... _Args> |
| 311 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {}; | 384 | struct _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {}; |
| 312 | 385 | ||
| 313 | template <class _Fn, class... _Args> | 386 | template <class _Fn, class... _Args> |
| 314 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; | 387 | using invoke_result_t = __invoke_result_t<_Fn, _Args...>; |
| 315 | 388 | ||
| 316 | #endif // _LIBCPP_STD_VER >= 17 | 389 | #endif |
| 317 | 390 | ||
| 318 | _LIBCPP_END_NAMESPACE_STD | 391 | _LIBCPP_END_NAMESPACE_STD |
| 319 | 392 |
lib/libcxx/include/__type_traits/is_abstract.h+1-2| ... | @@ -19,8 +19,7 @@ | ... | @@ -19,8 +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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_abstract | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_abstract : integral_constant<bool, __is_abstract(_Tp)> {}; |
| 23 | : public integral_constant<bool, __is_abstract(_Tp)> {}; | ||
| 24 | 23 | ||
| 25 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 26 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_aggregate.h+1-2| ... | @@ -21,8 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,8 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | #if _LIBCPP_STD_VER >= 17 | 21 | #if _LIBCPP_STD_VER >= 17 |
| 22 | 22 | ||
| 23 | template <class _Tp> | 23 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_aggregate | 24 | struct _LIBCPP_NO_SPECIALIZATIONS is_aggregate : integral_constant<bool, __is_aggregate(_Tp)> {}; |
| 25 | : public integral_constant<bool, __is_aggregate(_Tp)> {}; | ||
| 26 | 25 | ||
| 27 | template <class _Tp> | 26 | template <class _Tp> |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_aggregate_v = __is_aggregate(_Tp); | 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_aggregate_v = __is_aggregate(_Tp); |
lib/libcxx/include/__type_traits/is_arithmetic.h+2-2| ... | @@ -21,8 +21,8 @@ | ... | @@ -21,8 +21,8 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | template <class _Tp> | 23 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_arithmetic | 24 | struct _LIBCPP_NO_SPECIALIZATIONS is_arithmetic |
| 25 | : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {}; | 25 | : integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {}; |
| 26 | 26 | ||
| 27 | #if _LIBCPP_STD_VER >= 17 | 27 | #if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp> | 28 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_array.h+3-23| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/integral_constant.h> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -19,32 +18,13 @@ | ... | @@ -19,32 +18,13 @@ |
| 19 | 18 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 20 | ||
| 22 | #if __has_builtin(__is_array) && \ | ||
| 23 | (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900)) | ||
| 24 | |||
| 25 | template <class _Tp> | 21 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_array : _BoolConstant<__is_array(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_array : _BoolConstant<__is_array(_Tp)> {}; |
| 27 | 23 | ||
| 28 | # if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 29 | template <class _Tp> | 25 | template <class _Tp> |
| 30 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp); | 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp); |
| 31 | # endif | 27 | #endif |
| 32 | |||
| 33 | #else | ||
| 34 | |||
| 35 | template <class _Tp> | ||
| 36 | struct _LIBCPP_TEMPLATE_VIS is_array : public false_type {}; | ||
| 37 | template <class _Tp> | ||
| 38 | struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> : public true_type {}; | ||
| 39 | template <class _Tp, size_t _Np> | ||
| 40 | struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> : public true_type {}; | ||
| 41 | |||
| 42 | # if _LIBCPP_STD_VER >= 17 | ||
| 43 | template <class _Tp> | ||
| 44 | inline constexpr bool is_array_v = is_array<_Tp>::value; | ||
| 45 | # endif | ||
| 46 | |||
| 47 | #endif // __has_builtin(__is_array) | ||
| 48 | 28 | ||
| 49 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 50 | 30 |
lib/libcxx/include/__type_traits/is_assignable.h+6-8| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_reference.h> |
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -21,7 +20,7 @@ | ... | @@ -21,7 +20,7 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 21 | ||
| 23 | template <class _Tp, class _Up> | 22 | template <class _Tp, class _Up> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {}; | 23 | struct _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {}; |
| 25 | 24 | ||
| 26 | #if _LIBCPP_STD_VER >= 17 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 27 | template <class _Tp, class _Arg> | 26 | template <class _Tp, class _Arg> |
| ... | @@ -29,9 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_assignable_v = __is_assignab | ... | @@ -29,9 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_assignable_v = __is_assignab |
| 29 | #endif | 28 | #endif |
| 30 | 29 | ||
| 31 | template <class _Tp> | 30 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_assignable | 31 | struct _LIBCPP_NO_SPECIALIZATIONS is_copy_assignable |
| 33 | : public integral_constant<bool, | 32 | : integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; |
| 34 | __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 35 | 33 | ||
| 36 | #if _LIBCPP_STD_VER >= 17 | 34 | #if _LIBCPP_STD_VER >= 17 |
| 37 | template <class _Tp> | 35 | template <class _Tp> |
| ... | @@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_assignable_v = is_copy_ | ... | @@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_assignable_v = is_copy_ |
| 39 | #endif | 37 | #endif |
| 40 | 38 | ||
| 41 | template <class _Tp> | 39 | template <class _Tp> |
| 42 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_assignable | 40 | struct _LIBCPP_NO_SPECIALIZATIONS is_move_assignable |
| 43 | : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; | 41 | : integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; |
| 44 | 42 | ||
| 45 | #if _LIBCPP_STD_VER >= 17 | 43 | #if _LIBCPP_STD_VER >= 17 |
| 46 | template <class _Tp> | 44 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_base_of.h+2-4| ... | @@ -19,8 +19,7 @@ | ... | @@ -19,8 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Bp, class _Dp> | 21 | template <class _Bp, class _Dp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_base_of | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_base_of : integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; |
| 23 | : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; | ||
| 24 | 23 | ||
| 25 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 26 | template <class _Bp, class _Dp> | 25 | template <class _Bp, class _Dp> |
| ... | @@ -31,8 +30,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_base_of_v = __is_base_of(_Bp | ... | @@ -31,8 +30,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_base_of_v = __is_base_of(_Bp |
| 31 | # if __has_builtin(__builtin_is_virtual_base_of) | 30 | # if __has_builtin(__builtin_is_virtual_base_of) |
| 32 | 31 | ||
| 33 | template <class _Base, class _Derived> | 32 | template <class _Base, class _Derived> |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_virtual_base_of | 33 | struct _LIBCPP_NO_SPECIALIZATIONS is_virtual_base_of : bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {}; |
| 35 | : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {}; | ||
| 36 | 34 | ||
| 37 | template <class _Base, class _Derived> | 35 | template <class _Base, class _Derived> |
| 38 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived); | 36 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived); |
lib/libcxx/include/__type_traits/is_bounded_array.h+5-16| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/integral_constant.h> |
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -19,26 +18,16 @@ | ... | @@ -19,26 +18,16 @@ |
| 19 | 18 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 20 | ||
| 22 | template <class> | 21 | template <class _Tp> |
| 23 | inline const bool __is_bounded_array_v = false; | 22 | inline const bool __is_bounded_array_v = __is_bounded_array(_Tp); |
| 24 | template <class _Tp, size_t _Np> | ||
| 25 | inline const bool __is_bounded_array_v<_Tp[_Np]> = true; | ||
| 26 | 23 | ||
| 27 | #if _LIBCPP_STD_VER >= 20 | 24 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 25 | ||
| 29 | template <class> | 26 | template <class _Tp> |
| 30 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : false_type {}; | 27 | struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : bool_constant<__is_bounded_array(_Tp)> {}; |
| 31 | |||
| 32 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 33 | # if __has_warning("-Winvalid-specialization") | ||
| 34 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | ||
| 35 | # endif | ||
| 36 | template <class _Tp, size_t _Np> | ||
| 37 | struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; | ||
| 38 | _LIBCPP_DIAGNOSTIC_POP | ||
| 39 | 28 | ||
| 40 | template <class _Tp> | 29 | template <class _Tp> |
| 41 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value; | 30 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp); |
| 42 | 31 | ||
| 43 | #endif | 32 | #endif |
| 44 | 33 |
lib/libcxx/include/__type_traits/is_char_like_type.h+4-2| ... | @@ -12,7 +12,8 @@ | ... | @@ -12,7 +12,8 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/conjunction.h> | 13 | #include <__type_traits/conjunction.h> |
| 14 | #include <__type_traits/is_standard_layout.h> | 14 | #include <__type_traits/is_standard_layout.h> |
| 15 | #include <__type_traits/is_trivial.h> | 15 | #include <__type_traits/is_trivially_constructible.h> |
| 16 | #include <__type_traits/is_trivially_copyable.h> | ||
| 16 | 17 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 19 | # pragma GCC system_header |
| ... | @@ -21,7 +22,8 @@ | ... | @@ -21,7 +22,8 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 23 | ||
| 23 | template <class _CharT> | 24 | template <class _CharT> |
| 24 | using _IsCharLikeType _LIBCPP_NODEBUG = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; | 25 | using _IsCharLikeType _LIBCPP_NODEBUG = |
| 26 | _And<is_standard_layout<_CharT>, is_trivially_default_constructible<_CharT>, is_trivially_copyable<_CharT> >; | ||
| 25 | 27 | ||
| 26 | _LIBCPP_END_NAMESPACE_STD | 28 | _LIBCPP_END_NAMESPACE_STD |
| 27 | 29 |
lib/libcxx/include/__type_traits/is_class.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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_class : public integral_constant<bool, __is_class(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_class : integral_constant<bool, __is_class(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_compound.h+2-2| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if __has_builtin(__is_compound) | 22 | #if __has_builtin(__is_compound) |
| 23 | 23 | ||
| 24 | template <class _Tp> | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_compound : _BoolConstant<__is_compound(_Tp)> {}; | 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_compound : _BoolConstant<__is_compound(_Tp)> {}; |
| 26 | 26 | ||
| 27 | # if _LIBCPP_STD_VER >= 17 | 27 | # if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp> | 28 | template <class _Tp> |
| ... | @@ -32,7 +32,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_compound_v = __is_compound(_ | ... | @@ -32,7 +32,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_compound_v = __is_compound(_ |
| 32 | #else // __has_builtin(__is_compound) | 32 | #else // __has_builtin(__is_compound) |
| 33 | 33 | ||
| 34 | template <class _Tp> | 34 | template <class _Tp> |
| 35 | struct _LIBCPP_TEMPLATE_VIS is_compound : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; | 35 | struct is_compound : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; |
| 36 | 36 | ||
| 37 | # if _LIBCPP_STD_VER >= 17 | 37 | # if _LIBCPP_STD_VER >= 17 |
| 38 | template <class _Tp> | 38 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_const.h+3-19| ... | @@ -18,29 +18,13 @@ | ... | @@ -18,29 +18,13 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if __has_builtin(__is_const) | ||
| 22 | |||
| 23 | template <class _Tp> | 21 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_const : _BoolConstant<__is_const(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_const : _BoolConstant<__is_const(_Tp)> {}; |
| 25 | 23 | ||
| 26 | # if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 27 | template <class _Tp> | 25 | template <class _Tp> |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_const_v = __is_const(_Tp); | 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_const_v = __is_const(_Tp); |
| 29 | # endif | 27 | #endif |
| 30 | |||
| 31 | #else | ||
| 32 | |||
| 33 | template <class _Tp> | ||
| 34 | struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; | ||
| 35 | template <class _Tp> | ||
| 36 | struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; | ||
| 37 | |||
| 38 | # if _LIBCPP_STD_VER >= 17 | ||
| 39 | template <class _Tp> | ||
| 40 | inline constexpr bool is_const_v = is_const<_Tp>::value; | ||
| 41 | # endif | ||
| 42 | |||
| 43 | #endif // __has_builtin(__is_const) | ||
| 44 | 28 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 30 |
lib/libcxx/include/__type_traits/is_constructible.h+7-10| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H | 10 | #define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_reference.h> |
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -21,8 +20,7 @@ | ... | @@ -21,8 +20,7 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 21 | ||
| 23 | template <class _Tp, class... _Args> | 22 | template <class _Tp, class... _Args> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_constructible | 23 | struct _LIBCPP_NO_SPECIALIZATIONS is_constructible : integral_constant<bool, __is_constructible(_Tp, _Args...)> {}; |
| 25 | : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {}; | ||
| 26 | 24 | ||
| 27 | #if _LIBCPP_STD_VER >= 17 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp, class... _Args> | 26 | template <class _Tp, class... _Args> |
| ... | @@ -30,8 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_constructible_v = __is_const | ... | @@ -30,8 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_constructible_v = __is_const |
| 30 | #endif | 28 | #endif |
| 31 | 29 | ||
| 32 | template <class _Tp> | 30 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_constructible | 31 | struct _LIBCPP_NO_SPECIALIZATIONS is_copy_constructible |
| 34 | : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; | 32 | : integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; |
| 35 | 33 | ||
| 36 | #if _LIBCPP_STD_VER >= 17 | 34 | #if _LIBCPP_STD_VER >= 17 |
| 37 | template <class _Tp> | 35 | template <class _Tp> |
| ... | @@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_constructible_v = is_co | ... | @@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_constructible_v = is_co |
| 39 | #endif | 37 | #endif |
| 40 | 38 | ||
| 41 | template <class _Tp> | 39 | template <class _Tp> |
| 42 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_constructible | 40 | struct _LIBCPP_NO_SPECIALIZATIONS is_move_constructible |
| 43 | : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | 41 | : integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; |
| 44 | 42 | ||
| 45 | #if _LIBCPP_STD_VER >= 17 | 43 | #if _LIBCPP_STD_VER >= 17 |
| 46 | template <class _Tp> | 44 | template <class _Tp> |
| ... | @@ -48,8 +46,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_constructible_v = is_mo | ... | @@ -48,8 +46,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_constructible_v = is_mo |
| 48 | #endif | 46 | #endif |
| 49 | 47 | ||
| 50 | template <class _Tp> | 48 | template <class _Tp> |
| 51 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_default_constructible | 49 | struct _LIBCPP_NO_SPECIALIZATIONS is_default_constructible : integral_constant<bool, __is_constructible(_Tp)> {}; |
| 52 | : public integral_constant<bool, __is_constructible(_Tp)> {}; | ||
| 53 | 50 | ||
| 54 | #if _LIBCPP_STD_VER >= 17 | 51 | #if _LIBCPP_STD_VER >= 17 |
| 55 | template <class _Tp> | 52 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_convertible.h+11-2| ... | @@ -19,14 +19,23 @@ | ... | @@ -19,14 +19,23 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _T1, class _T2> | 21 | template <class _T1, class _T2> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_convertible | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_convertible : integral_constant<bool, __is_convertible(_T1, _T2)> {}; |
| 23 | : public integral_constant<bool, __is_convertible(_T1, _T2)> {}; | ||
| 24 | 23 | ||
| 25 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 26 | template <class _From, class _To> | 25 | template <class _From, class _To> |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To); | 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To); |
| 28 | #endif | 27 | #endif |
| 29 | 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 20 | ||
| 30 | |||
| 31 | template <class _Tp, class _Up> | ||
| 32 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {}; | ||
| 33 | |||
| 34 | template <class _Tp, class _Up> | ||
| 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up); | ||
| 36 | |||
| 37 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 38 | |||
| 30 | _LIBCPP_END_NAMESPACE_STD | 39 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 40 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H | 41 | #endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H |
lib/libcxx/include/__type_traits/is_core_convertible.h+22-3| ... | @@ -24,11 +24,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,11 +24,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | // and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later. | 24 | // and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later. |
| 25 | 25 | ||
| 26 | template <class _Tp, class _Up, class = void> | 26 | template <class _Tp, class _Up, class = void> |
| 27 | struct __is_core_convertible : public false_type {}; | 27 | inline const bool __is_core_convertible_v = false; |
| 28 | 28 | ||
| 29 | template <class _Tp, class _Up> | 29 | template <class _Tp, class _Up> |
| 30 | struct __is_core_convertible<_Tp, _Up, decltype(static_cast<void (*)(_Up)>(0)(static_cast<_Tp (*)()>(0)()))> | 30 | inline const bool |
| 31 | : public true_type {}; | 31 | __is_core_convertible_v<_Tp, _Up, decltype(static_cast<void (*)(_Up)>(0)(static_cast<_Tp (*)()>(0)()))> = true; |
| 32 | |||
| 33 | template <class _Tp, class _Up> | ||
| 34 | using __is_core_convertible _LIBCPP_NODEBUG = integral_constant<bool, __is_core_convertible_v<_Tp, _Up> >; | ||
| 35 | |||
| 36 | #if _LIBCPP_STD_VER >= 20 | ||
| 37 | |||
| 38 | template <class _Tp, class _Up> | ||
| 39 | concept __core_convertible_to = __is_core_convertible_v<_Tp, _Up>; | ||
| 40 | |||
| 41 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 42 | |||
| 43 | template <class _Tp, class _Up, bool = __is_core_convertible_v<_Tp, _Up> > | ||
| 44 | inline const bool __is_nothrow_core_convertible_v = false; | ||
| 45 | |||
| 46 | #ifndef _LIBCPP_CXX03_LANG | ||
| 47 | template <class _Tp, class _Up> | ||
| 48 | inline const bool __is_nothrow_core_convertible_v<_Tp, _Up, true> = | ||
| 49 | noexcept(static_cast<void (*)(_Up) noexcept>(0)(static_cast<_Tp (*)() noexcept>(0)())); | ||
| 50 | #endif | ||
| 32 | 51 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | 52 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 53 |
lib/libcxx/include/__type_traits/is_destructible.h+8-8| ... | @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | #if __has_builtin(__is_destructible) | 25 | #if __has_builtin(__is_destructible) |
| 26 | 26 | ||
| 27 | template <class _Tp> | 27 | template <class _Tp> |
| 28 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_destructible : _BoolConstant<__is_destructible(_Tp)> {}; | 28 | struct _LIBCPP_NO_SPECIALIZATIONS is_destructible : _BoolConstant<__is_destructible(_Tp)> {}; |
| 29 | 29 | ||
| 30 | # if _LIBCPP_STD_VER >= 17 | 30 | # if _LIBCPP_STD_VER >= 17 |
| 31 | template <class _Tp> | 31 | template <class _Tp> |
| ... | @@ -62,28 +62,28 @@ struct __destructible_imp; | ... | @@ -62,28 +62,28 @@ struct __destructible_imp; |
| 62 | 62 | ||
| 63 | template <class _Tp> | 63 | template <class _Tp> |
| 64 | struct __destructible_imp<_Tp, false> | 64 | struct __destructible_imp<_Tp, false> |
| 65 | : public integral_constant<bool, __is_destructor_wellformed<__remove_all_extents_t<_Tp> >::value> {}; | 65 | : integral_constant<bool, __is_destructor_wellformed<__remove_all_extents_t<_Tp> >::value> {}; |
| 66 | 66 | ||
| 67 | template <class _Tp> | 67 | template <class _Tp> |
| 68 | struct __destructible_imp<_Tp, true> : public true_type {}; | 68 | struct __destructible_imp<_Tp, true> : true_type {}; |
| 69 | 69 | ||
| 70 | template <class _Tp, bool> | 70 | template <class _Tp, bool> |
| 71 | struct __destructible_false; | 71 | struct __destructible_false; |
| 72 | 72 | ||
| 73 | template <class _Tp> | 73 | template <class _Tp> |
| 74 | struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {}; | 74 | struct __destructible_false<_Tp, false> : __destructible_imp<_Tp, is_reference<_Tp>::value> {}; |
| 75 | 75 | ||
| 76 | template <class _Tp> | 76 | template <class _Tp> |
| 77 | struct __destructible_false<_Tp, true> : public false_type {}; | 77 | struct __destructible_false<_Tp, true> : false_type {}; |
| 78 | 78 | ||
| 79 | template <class _Tp> | 79 | template <class _Tp> |
| 80 | struct is_destructible : public __destructible_false<_Tp, is_function<_Tp>::value> {}; | 80 | struct is_destructible : __destructible_false<_Tp, is_function<_Tp>::value> {}; |
| 81 | 81 | ||
| 82 | template <class _Tp> | 82 | template <class _Tp> |
| 83 | struct is_destructible<_Tp[]> : public false_type {}; | 83 | struct is_destructible<_Tp[]> : false_type {}; |
| 84 | 84 | ||
| 85 | template <> | 85 | template <> |
| 86 | struct is_destructible<void> : public false_type {}; | 86 | struct is_destructible<void> : false_type {}; |
| 87 | 87 | ||
| 88 | # if _LIBCPP_STD_VER >= 17 | 88 | # if _LIBCPP_STD_VER >= 17 |
| 89 | template <class _Tp> | 89 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_empty.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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_empty : public integral_constant<bool, __is_empty(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_empty : integral_constant<bool, __is_empty(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_enum.h+2-2| ... | @@ -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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_enum : public integral_constant<bool, __is_enum(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_enum : integral_constant<bool, __is_enum(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| ... | @@ -29,7 +29,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_enum_v = __is_enum(_Tp); | ... | @@ -29,7 +29,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_enum_v = __is_enum(_Tp); |
| 29 | #if _LIBCPP_STD_VER >= 23 | 29 | #if _LIBCPP_STD_VER >= 23 |
| 30 | 30 | ||
| 31 | template <class _Tp> | 31 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {}; | 32 | struct _LIBCPP_NO_SPECIALIZATIONS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {}; |
| 33 | 33 | ||
| 34 | template <class _Tp> | 34 | template <class _Tp> |
| 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); | 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); |
lib/libcxx/include/__type_traits/is_final.h+2-2| ... | @@ -19,11 +19,11 @@ | ... | @@ -19,11 +19,11 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {}; | 22 | struct __libcpp_is_final : integral_constant<bool, __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> |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_final : public integral_constant<bool, __is_final(_Tp)> {}; | 26 | struct _LIBCPP_NO_SPECIALIZATIONS is_final : integral_constant<bool, __is_final(_Tp)> {}; |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 17 | 29 | #if _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/__type_traits/is_floating_point.h+5-6| ... | @@ -20,15 +20,14 @@ | ... | @@ -20,15 +20,14 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_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 : public false_type {}; | 23 | template <class _Tp> struct __libcpp_is_floating_point : false_type {}; |
| 24 | template <> struct __libcpp_is_floating_point<float> : public true_type {}; | 24 | template <> struct __libcpp_is_floating_point<float> : true_type {}; |
| 25 | template <> struct __libcpp_is_floating_point<double> : public true_type {}; | 25 | template <> struct __libcpp_is_floating_point<double> : true_type {}; |
| 26 | template <> struct __libcpp_is_floating_point<long double> : public true_type {}; | 26 | template <> struct __libcpp_is_floating_point<long double> : true_type {}; |
| 27 | // clang-format on | 27 | // clang-format on |
| 28 | 28 | ||
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| 30 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_floating_point | 30 | struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point : __libcpp_is_floating_point<__remove_cv_t<_Tp> > {}; |
| 31 | : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {}; | ||
| 32 | 31 | ||
| 33 | #if _LIBCPP_STD_VER >= 17 | 32 | #if _LIBCPP_STD_VER >= 17 |
| 34 | template <class _Tp> | 33 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_function.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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_fundamental.h+3-3| ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if __has_builtin(__is_fundamental) | 23 | #if __has_builtin(__is_fundamental) |
| 24 | 24 | ||
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {}; | 26 | struct _LIBCPP_NO_SPECIALIZATIONS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {}; |
| 27 | 27 | ||
| 28 | # if _LIBCPP_STD_VER >= 17 | 28 | # if _LIBCPP_STD_VER >= 17 |
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| ... | @@ -33,8 +33,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_fundamental_v = __is_fundame | ... | @@ -33,8 +33,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_fundamental_v = __is_fundame |
| 33 | #else // __has_builtin(__is_fundamental) | 33 | #else // __has_builtin(__is_fundamental) |
| 34 | 34 | ||
| 35 | template <class _Tp> | 35 | template <class _Tp> |
| 36 | struct _LIBCPP_TEMPLATE_VIS is_fundamental | 36 | struct is_fundamental |
| 37 | : public integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {}; | 37 | : integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {}; |
| 38 | 38 | ||
| 39 | # if _LIBCPP_STD_VER >= 17 | 39 | # if _LIBCPP_STD_VER >= 17 |
| 40 | template <class _Tp> | 40 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_implicit_lifetime.h+1-2| ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | # if __has_builtin(__builtin_is_implicit_lifetime) | 22 | # if __has_builtin(__builtin_is_implicit_lifetime) |
| 23 | 23 | ||
| 24 | template <class _Tp> | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_implicit_lifetime | 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_implicit_lifetime : bool_constant<__builtin_is_implicit_lifetime(_Tp)> {}; |
| 26 | : public bool_constant<__builtin_is_implicit_lifetime(_Tp)> {}; | ||
| 27 | 26 | ||
| 28 | template <class _Tp> | 27 | template <class _Tp> |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp); | 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp); |
lib/libcxx/include/__type_traits/is_integral.h+13-13| ... | @@ -19,6 +19,18 @@ | ... | @@ -19,6 +19,18 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #if __has_builtin(__is_integral) | ||
| 23 | |||
| 24 | template <class _Tp> | ||
| 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {}; | ||
| 26 | |||
| 27 | # if _LIBCPP_STD_VER >= 17 | ||
| 28 | template <class _Tp> | ||
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_integral_v = __is_integral(_Tp); | ||
| 30 | # endif | ||
| 31 | |||
| 32 | #else | ||
| 33 | |||
| 22 | // clang-format off | 34 | // clang-format off |
| 23 | template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; }; | 35 | template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; }; |
| 24 | template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; }; | 36 | template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; }; |
| ... | @@ -47,20 +59,8 @@ template <> struct __libcpp_is_integral<__uint128_t> { enum { va | ... | @@ -47,20 +59,8 @@ template <> struct __libcpp_is_integral<__uint128_t> { enum { va |
| 47 | #endif | 59 | #endif |
| 48 | // clang-format on | 60 | // clang-format on |
| 49 | 61 | ||
| 50 | #if __has_builtin(__is_integral) | ||
| 51 | |||
| 52 | template <class _Tp> | ||
| 53 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {}; | ||
| 54 | |||
| 55 | # if _LIBCPP_STD_VER >= 17 | ||
| 56 | template <class _Tp> | ||
| 57 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_integral_v = __is_integral(_Tp); | ||
| 58 | # endif | ||
| 59 | |||
| 60 | #else | ||
| 61 | |||
| 62 | template <class _Tp> | 62 | template <class _Tp> |
| 63 | struct _LIBCPP_TEMPLATE_VIS is_integral : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {}; | 63 | struct is_integral : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {}; |
| 64 | 64 | ||
| 65 | # if _LIBCPP_STD_VER >= 17 | 65 | # if _LIBCPP_STD_VER >= 17 |
| 66 | template <class _Tp> | 66 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_literal_type.h+2-2| ... | @@ -20,8 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -20,8 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) | 21 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| 22 | template <class _Tp> | 22 | template <class _Tp> |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type | 23 | struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type |
| 24 | : public integral_constant<bool, __is_literal_type(_Tp)> {}; | 24 | : integral_constant<bool, __is_literal_type(_Tp)> {}; |
| 25 | 25 | ||
| 26 | # if _LIBCPP_STD_VER >= 17 | 26 | # if _LIBCPP_STD_VER >= 17 |
| 27 | template <class _Tp> | 27 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_member_pointer.h+3-5| ... | @@ -19,15 +19,13 @@ | ... | @@ -19,15 +19,13 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {}; |
| 23 | 23 | ||
| 24 | template <class _Tp> | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_object_pointer | 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {}; |
| 26 | : _BoolConstant<__is_member_object_pointer(_Tp)> {}; | ||
| 27 | 26 | ||
| 28 | template <class _Tp> | 27 | template <class _Tp> |
| 29 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_function_pointer | 28 | struct _LIBCPP_NO_SPECIALIZATIONS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {}; |
| 30 | : _BoolConstant<__is_member_function_pointer(_Tp)> {}; | ||
| 31 | 29 | ||
| 32 | #if _LIBCPP_STD_VER >= 17 | 30 | #if _LIBCPP_STD_VER >= 17 |
| 33 | template <class _Tp> | 31 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+8-12| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_reference.h> |
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -21,8 +20,8 @@ | ... | @@ -21,8 +20,8 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 21 | ||
| 23 | template <class _Tp, class _Arg> | 22 | template <class _Tp, class _Arg> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_assignable | 23 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_assignable : integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> { |
| 25 | : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {}; | 24 | }; |
| 26 | 25 | ||
| 27 | #if _LIBCPP_STD_VER >= 17 | 26 | #if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp, class _Arg> | 27 | template <class _Tp, class _Arg> |
| ... | @@ -30,10 +29,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_assignable_v = __is_ | ... | @@ -30,10 +29,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_assignable_v = __is_ |
| 30 | #endif | 29 | #endif |
| 31 | 30 | ||
| 32 | template <class _Tp> | 31 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_assignable | 32 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_assignable |
| 34 | : public integral_constant< | 33 | : integral_constant<bool, |
| 35 | bool, | 34 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; |
| 36 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; | ||
| 37 | 35 | ||
| 38 | #if _LIBCPP_STD_VER >= 17 | 36 | #if _LIBCPP_STD_VER >= 17 |
| 39 | template <class _Tp> | 37 | template <class _Tp> |
| ... | @@ -41,10 +39,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v = | ... | @@ -41,10 +39,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v = |
| 41 | #endif | 39 | #endif |
| 42 | 40 | ||
| 43 | template <class _Tp> | 41 | template <class _Tp> |
| 44 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_assignable | 42 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_assignable |
| 45 | : public integral_constant<bool, | 43 | : integral_constant<bool, __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; |
| 46 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> { | ||
| 47 | }; | ||
| 48 | 44 | ||
| 49 | #if _LIBCPP_STD_VER >= 17 | 45 | #if _LIBCPP_STD_VER >= 17 |
| 50 | template <class _Tp> | 46 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+9-10| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_reference.h> |
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -21,8 +20,8 @@ | ... | @@ -21,8 +20,8 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 21 | ||
| 23 | template < class _Tp, class... _Args> | 22 | template < class _Tp, class... _Args> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_constructible | 23 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_constructible |
| 25 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; | 24 | : integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; |
| 26 | 25 | ||
| 27 | #if _LIBCPP_STD_VER >= 17 | 26 | #if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp, class... _Args> | 27 | template <class _Tp, class... _Args> |
| ... | @@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_constructible_v = | ... | @@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_constructible_v = |
| 31 | #endif | 30 | #endif |
| 32 | 31 | ||
| 33 | template <class _Tp> | 32 | template <class _Tp> |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_constructible | 33 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_constructible |
| 35 | : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; | 34 | : integral_constant<bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; |
| 36 | 35 | ||
| 37 | #if _LIBCPP_STD_VER >= 17 | 36 | #if _LIBCPP_STD_VER >= 17 |
| 38 | template <class _Tp> | 37 | template <class _Tp> |
| ... | @@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_constructible_v | ... | @@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_constructible_v |
| 41 | #endif | 40 | #endif |
| 42 | 41 | ||
| 43 | template <class _Tp> | 42 | template <class _Tp> |
| 44 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_constructible | 43 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_constructible |
| 45 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | 44 | : integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; |
| 46 | 45 | ||
| 47 | #if _LIBCPP_STD_VER >= 17 | 46 | #if _LIBCPP_STD_VER >= 17 |
| 48 | template <class _Tp> | 47 | template <class _Tp> |
| ... | @@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_constructible_v | ... | @@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_constructible_v |
| 51 | #endif | 50 | #endif |
| 52 | 51 | ||
| 53 | template <class _Tp> | 52 | template <class _Tp> |
| 54 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_default_constructible | 53 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_default_constructible |
| 55 | : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {}; | 54 | : integral_constant<bool, __is_nothrow_constructible(_Tp)> {}; |
| 56 | 55 | ||
| 57 | #if _LIBCPP_STD_VER >= 17 | 56 | #if _LIBCPP_STD_VER >= 17 |
| 58 | template <class _Tp> | 57 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_nothrow_convertible.h deleted-62| ... | @@ -1,62 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/conjunction.h> | ||
| 14 | #include <__type_traits/disjunction.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | ||
| 16 | #include <__type_traits/is_convertible.h> | ||
| 17 | #include <__type_traits/is_void.h> | ||
| 18 | #include <__type_traits/lazy.h> | ||
| 19 | #include <__utility/declval.h> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | |||
| 27 | #if _LIBCPP_STD_VER >= 20 | ||
| 28 | |||
| 29 | # if __has_builtin(__is_nothrow_convertible) | ||
| 30 | |||
| 31 | template <class _Tp, class _Up> | ||
| 32 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {}; | ||
| 33 | |||
| 34 | template <class _Tp, class _Up> | ||
| 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up); | ||
| 36 | |||
| 37 | # else // __has_builtin(__is_nothrow_convertible) | ||
| 38 | |||
| 39 | template <typename _Tp> | ||
| 40 | void __test_noexcept(_Tp) noexcept; | ||
| 41 | |||
| 42 | template <typename _Fm, typename _To> | ||
| 43 | bool_constant<noexcept(std::__test_noexcept<_To>(std::declval<_Fm>()))> __is_nothrow_convertible_test(); | ||
| 44 | |||
| 45 | template <typename _Fm, typename _To> | ||
| 46 | struct __is_nothrow_convertible_helper : decltype(__is_nothrow_convertible_test<_Fm, _To>()) {}; | ||
| 47 | |||
| 48 | template <typename _Fm, typename _To> | ||
| 49 | struct is_nothrow_convertible | ||
| 50 | : _Or<_And<is_void<_To>, is_void<_Fm>>, | ||
| 51 | _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To> > >::type {}; | ||
| 52 | |||
| 53 | template <typename _Fm, typename _To> | ||
| 54 | inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; | ||
| 55 | |||
| 56 | # endif // __has_builtin(__is_nothrow_convertible) | ||
| 57 | |||
| 58 | #endif // _LIBCPP_STD_VER >= 20 | ||
| 59 | |||
| 60 | _LIBCPP_END_NAMESPACE_STD | ||
| 61 | |||
| 62 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H | ||
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+7-10| ... | @@ -24,8 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -24,8 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | #if __has_builtin(__is_nothrow_destructible) | 24 | #if __has_builtin(__is_nothrow_destructible) |
| 25 | 25 | ||
| 26 | template <class _Tp> | 26 | template <class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_destructible | 27 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_destructible : integral_constant<bool, __is_nothrow_destructible(_Tp)> {}; |
| 28 | : integral_constant<bool, __is_nothrow_destructible(_Tp)> {}; | ||
| 29 | 28 | ||
| 30 | #else | 29 | #else |
| 31 | 30 | ||
| ... | @@ -33,24 +32,22 @@ template <bool, class _Tp> | ... | @@ -33,24 +32,22 @@ template <bool, class _Tp> |
| 33 | struct __libcpp_is_nothrow_destructible; | 32 | struct __libcpp_is_nothrow_destructible; |
| 34 | 33 | ||
| 35 | template <class _Tp> | 34 | template <class _Tp> |
| 36 | struct __libcpp_is_nothrow_destructible<false, _Tp> : public false_type {}; | 35 | struct __libcpp_is_nothrow_destructible<false, _Tp> : false_type {}; |
| 37 | 36 | ||
| 38 | template <class _Tp> | 37 | template <class _Tp> |
| 39 | struct __libcpp_is_nothrow_destructible<true, _Tp> | 38 | struct __libcpp_is_nothrow_destructible<true, _Tp> : integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) > {}; |
| 40 | : public integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) > {}; | ||
| 41 | 39 | ||
| 42 | template <class _Tp> | 40 | template <class _Tp> |
| 43 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible | 41 | struct is_nothrow_destructible : __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> {}; |
| 44 | : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> {}; | ||
| 45 | 42 | ||
| 46 | template <class _Tp, size_t _Ns> | 43 | template <class _Tp, size_t _Ns> |
| 47 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> : public is_nothrow_destructible<_Tp> {}; | 44 | struct is_nothrow_destructible<_Tp[_Ns]> : is_nothrow_destructible<_Tp> {}; |
| 48 | 45 | ||
| 49 | template <class _Tp> | 46 | template <class _Tp> |
| 50 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> : public true_type {}; | 47 | struct is_nothrow_destructible<_Tp&> : true_type {}; |
| 51 | 48 | ||
| 52 | template <class _Tp> | 49 | template <class _Tp> |
| 53 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {}; | 50 | struct is_nothrow_destructible<_Tp&&> : true_type {}; |
| 54 | 51 | ||
| 55 | #endif // __has_builtin(__is_nothrow_destructible) | 52 | #endif // __has_builtin(__is_nothrow_destructible) |
| 56 | 53 |
lib/libcxx/include/__type_traits/is_null_pointer.h+1-2| ... | @@ -24,8 +24,7 @@ inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t); | ... | @@ -24,8 +24,7 @@ inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t); |
| 24 | 24 | ||
| 25 | #if _LIBCPP_STD_VER >= 14 | 25 | #if _LIBCPP_STD_VER >= 14 |
| 26 | template <class _Tp> | 26 | template <class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_null_pointer | 27 | struct _LIBCPP_NO_SPECIALIZATIONS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {}; |
| 28 | : integral_constant<bool, __is_null_pointer_v<_Tp>> {}; | ||
| 29 | 28 | ||
| 30 | # if _LIBCPP_STD_VER >= 17 | 29 | # if _LIBCPP_STD_VER >= 17 |
| 31 | template <class _Tp> | 30 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_object.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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_object : _BoolConstant<__is_object(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_object : _BoolConstant<__is_object(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_pod.h+2-2| ... | @@ -19,11 +19,11 @@ | ... | @@ -19,11 +19,11 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {}; | 22 | struct _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS is_pod : integral_constant<bool, __is_pod(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp); | 26 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp); |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_pointer.h+1-35| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/integral_constant.h> |
| 14 | #include <__type_traits/remove_cv.h> | ||
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -19,47 +18,14 @@ | ... | @@ -19,47 +18,14 @@ |
| 19 | 18 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 20 | ||
| 22 | #if __has_builtin(__is_pointer) | ||
| 23 | |||
| 24 | template <class _Tp> | 21 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pointer : _BoolConstant<__is_pointer(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_pointer : _BoolConstant<__is_pointer(_Tp)> {}; |
| 26 | 23 | ||
| 27 | # if _LIBCPP_STD_VER >= 17 | 24 | # if _LIBCPP_STD_VER >= 17 |
| 28 | template <class _Tp> | 25 | template <class _Tp> |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pointer_v = __is_pointer(_Tp); | 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pointer_v = __is_pointer(_Tp); |
| 30 | # endif | 27 | # endif |
| 31 | 28 | ||
| 32 | #else // __has_builtin(__is_pointer) | ||
| 33 | |||
| 34 | template <class _Tp> | ||
| 35 | struct __libcpp_is_pointer : public false_type {}; | ||
| 36 | template <class _Tp> | ||
| 37 | struct __libcpp_is_pointer<_Tp*> : public true_type {}; | ||
| 38 | |||
| 39 | template <class _Tp> | ||
| 40 | struct __libcpp_remove_objc_qualifiers { | ||
| 41 | typedef _Tp type; | ||
| 42 | }; | ||
| 43 | # if _LIBCPP_HAS_OBJC_ARC | ||
| 44 | // clang-format off | ||
| 45 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; | ||
| 46 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; | ||
| 47 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; | ||
| 48 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; | ||
| 49 | // clang-format on | ||
| 50 | # endif | ||
| 51 | |||
| 52 | template <class _Tp> | ||
| 53 | struct _LIBCPP_TEMPLATE_VIS is_pointer | ||
| 54 | : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<__remove_cv_t<_Tp> >::type> {}; | ||
| 55 | |||
| 56 | # if _LIBCPP_STD_VER >= 17 | ||
| 57 | template <class _Tp> | ||
| 58 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; | ||
| 59 | # endif | ||
| 60 | |||
| 61 | #endif // __has_builtin(__is_pointer) | ||
| 62 | |||
| 63 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 64 | 30 | ||
| 65 | #endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H | 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H |
lib/libcxx/include/__type_traits/is_polymorphic.h+1-2| ... | @@ -19,8 +19,7 @@ | ... | @@ -19,8 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_polymorphic | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_polymorphic : integral_constant<bool, __is_polymorphic(_Tp)> {}; |
| 23 | : public integral_constant<bool, __is_polymorphic(_Tp)> {}; | ||
| 24 | 23 | ||
| 25 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 26 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_reference.h+7-9| ... | @@ -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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_reference : _BoolConstant<__is_reference(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_reference : _BoolConstant<__is_reference(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| ... | @@ -29,12 +29,10 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_reference_v = __is_reference | ... | @@ -29,12 +29,10 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_reference_v = __is_reference |
| 29 | #if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) | 29 | #if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) |
| 30 | 30 | ||
| 31 | template <class _Tp> | 31 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { | 32 | struct _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {}; |
| 33 | }; | ||
| 34 | 33 | ||
| 35 | template <class _Tp> | 34 | template <class _Tp> |
| 36 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { | 35 | struct _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {}; |
| 37 | }; | ||
| 38 | 36 | ||
| 39 | # if _LIBCPP_STD_VER >= 17 | 37 | # if _LIBCPP_STD_VER >= 17 |
| 40 | template <class _Tp> | 38 | template <class _Tp> |
| ... | @@ -46,14 +44,14 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_rvalue_reference_v = __is_rv | ... | @@ -46,14 +44,14 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_rvalue_reference_v = __is_rv |
| 46 | #else // __has_builtin(__is_lvalue_reference) | 44 | #else // __has_builtin(__is_lvalue_reference) |
| 47 | 45 | ||
| 48 | template <class _Tp> | 46 | template <class _Tp> |
| 49 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; | 47 | struct is_lvalue_reference : false_type {}; |
| 50 | template <class _Tp> | 48 | template <class _Tp> |
| 51 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; | 49 | struct is_lvalue_reference<_Tp&> : true_type {}; |
| 52 | 50 | ||
| 53 | template <class _Tp> | 51 | template <class _Tp> |
| 54 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; | 52 | struct is_rvalue_reference : false_type {}; |
| 55 | template <class _Tp> | 53 | template <class _Tp> |
| 56 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; | 54 | struct is_rvalue_reference<_Tp&&> : true_type {}; |
| 57 | 55 | ||
| 58 | # if _LIBCPP_STD_VER >= 17 | 56 | # if _LIBCPP_STD_VER >= 17 |
| 59 | template <class _Tp> | 57 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_reference_wrapper.h+3-3| ... | @@ -21,11 +21,11 @@ | ... | @@ -21,11 +21,11 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | ||
| 23 | template <class _Tp> | 23 | template <class _Tp> |
| 24 | struct __is_reference_wrapper_impl : public false_type {}; | 24 | struct __is_reference_wrapper_impl : false_type {}; |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| 26 | struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {}; | 26 | struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : true_type {}; |
| 27 | template <class _Tp> | 27 | template <class _Tp> |
| 28 | struct __is_reference_wrapper : public __is_reference_wrapper_impl<__remove_cv_t<_Tp> > {}; | 28 | struct __is_reference_wrapper : __is_reference_wrapper_impl<__remove_cv_t<_Tp> > {}; |
| 29 | 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | 30 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 31 |
lib/libcxx/include/__type_traits/is_referenceable.h+8-15| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/void_t.h> |
| 14 | #include <__type_traits/is_same.h> | ||
| 15 | 14 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 16 | # pragma GCC system_header |
| ... | @@ -19,22 +18,16 @@ | ... | @@ -19,22 +18,16 @@ |
| 19 | 18 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 20 | ||
| 22 | #if __has_builtin(__is_referenceable) | 21 | template <class _Tp, class = void> |
| 22 | inline const bool __is_referenceable_v = false; | ||
| 23 | |||
| 23 | template <class _Tp> | 24 | template <class _Tp> |
| 24 | struct __libcpp_is_referenceable : integral_constant<bool, __is_referenceable(_Tp)> {}; | 25 | inline const bool __is_referenceable_v<_Tp, __void_t<_Tp&> > = true; |
| 25 | #else | ||
| 26 | struct __libcpp_is_referenceable_impl { | ||
| 27 | template <class _Tp> | ||
| 28 | static _Tp& __test(int); | ||
| 29 | template <class _Tp> | ||
| 30 | static false_type __test(...); | ||
| 31 | }; | ||
| 32 | 26 | ||
| 27 | #if _LIBCPP_STD_VER >= 20 | ||
| 33 | template <class _Tp> | 28 | template <class _Tp> |
| 34 | struct __libcpp_is_referenceable | 29 | concept __referenceable = __is_referenceable_v<_Tp>; |
| 35 | : integral_constant<bool, _IsNotSame<decltype(__libcpp_is_referenceable_impl::__test<_Tp>(0)), false_type>::value> { | 30 | #endif |
| 36 | }; | ||
| 37 | #endif // __has_builtin(__is_referenceable) | ||
| 38 | 31 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | 32 | _LIBCPP_END_NAMESPACE_STD |
| 40 | 33 |
lib/libcxx/include/__type_traits/is_replaceable.h created+61| ... | @@ -0,0 +1,61 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_REPLACEABLE_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_REPLACEABLE_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/enable_if.h> | ||
| 14 | #include <__type_traits/integral_constant.h> | ||
| 15 | #include <__type_traits/is_same.h> | ||
| 16 | #include <__type_traits/is_trivially_copyable.h> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | // A type is replaceable if, with `x` and `y` being different objects, `x = std::move(y)` is equivalent to: | ||
| 25 | // | ||
| 26 | // std::destroy_at(&x) | ||
| 27 | // std::construct_at(&x, std::move(y)) | ||
| 28 | // | ||
| 29 | // This allows turning a move-assignment into a sequence of destroy + move-construct, which | ||
| 30 | // is often more efficient. This is especially relevant when the move-construct is in fact | ||
| 31 | // part of a trivial relocation from somewhere else, in which case there is a huge win. | ||
| 32 | // | ||
| 33 | // Note that this requires language support in order to be really effective, but we | ||
| 34 | // currently emulate the base template with something very conservative. | ||
| 35 | template <class _Tp, class = void> | ||
| 36 | struct __is_replaceable : is_trivially_copyable<_Tp> {}; | ||
| 37 | |||
| 38 | template <class _Tp> | ||
| 39 | struct __is_replaceable<_Tp, __enable_if_t<is_same<_Tp, typename _Tp::__replaceable>::value> > : true_type {}; | ||
| 40 | |||
| 41 | template <class _Tp> | ||
| 42 | inline const bool __is_replaceable_v = __is_replaceable<_Tp>::value; | ||
| 43 | |||
| 44 | // Determines whether an allocator member of a container is replaceable. | ||
| 45 | // | ||
| 46 | // First, we require the allocator type to be considered replaceable. If not, then something fishy might be | ||
| 47 | // happening. Assuming the allocator type is replaceable, we conclude replaceability of the allocator as a | ||
| 48 | // member of the container if the allocator always compares equal (in which case propagation doesn't matter), | ||
| 49 | // or if the allocator always propagates on assignment, which is required in order for move construction and | ||
| 50 | // assignment to be equivalent. | ||
| 51 | template <class _AllocatorTraits> | ||
| 52 | struct __container_allocator_is_replaceable | ||
| 53 | : integral_constant<bool, | ||
| 54 | __is_replaceable_v<typename _AllocatorTraits::allocator_type> && | ||
| 55 | (_AllocatorTraits::is_always_equal::value || | ||
| 56 | (_AllocatorTraits::propagate_on_container_move_assignment::value && | ||
| 57 | _AllocatorTraits::propagate_on_container_copy_assignment::value))> {}; | ||
| 58 | |||
| 59 | _LIBCPP_END_NAMESPACE_STD | ||
| 60 | |||
| 61 | #endif // _LIBCPP___TYPE_TRAITS_IS_REPLACEABLE_H | ||
lib/libcxx/include/__type_traits/is_same.h+1-1| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp, class _Up> | 21 | template <class _Tp, class _Up> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_same : _BoolConstant<__is_same(_Tp, _Up)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_same : _BoolConstant<__is_same(_Tp, _Up)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp, class _Up> | 25 | template <class _Tp, class _Up> |
lib/libcxx/include/__type_traits/is_scalar.h+5-5| ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | #if __has_builtin(__is_scalar) | 26 | #if __has_builtin(__is_scalar) |
| 27 | 27 | ||
| 28 | template <class _Tp> | 28 | template <class _Tp> |
| 29 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scalar : _BoolConstant<__is_scalar(_Tp)> {}; | 29 | struct _LIBCPP_NO_SPECIALIZATIONS is_scalar : _BoolConstant<__is_scalar(_Tp)> {}; |
| 30 | 30 | ||
| 31 | # if _LIBCPP_STD_VER >= 17 | 31 | # if _LIBCPP_STD_VER >= 17 |
| 32 | template <class _Tp> | 32 | template <class _Tp> |
| ... | @@ -37,15 +37,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scalar_v = __is_scalar(_Tp); | ... | @@ -37,15 +37,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scalar_v = __is_scalar(_Tp); |
| 37 | 37 | ||
| 38 | template <class _Tp> | 38 | template <class _Tp> |
| 39 | struct __is_block : false_type {}; | 39 | struct __is_block : false_type {}; |
| 40 | # if _LIBCPP_HAS_EXTENSION_BLOCKS | 40 | # if __has_extension(blocks) |
| 41 | template <class _Rp, class... _Args> | 41 | template <class _Rp, class... _Args> |
| 42 | struct __is_block<_Rp (^)(_Args...)> : true_type {}; | 42 | struct __is_block<_Rp (^)(_Args...)> : true_type {}; |
| 43 | # endif | 43 | # endif |
| 44 | 44 | ||
| 45 | // clang-format off | 45 | // clang-format off |
| 46 | template <class _Tp> | 46 | template <class _Tp> |
| 47 | struct _LIBCPP_TEMPLATE_VIS is_scalar | 47 | struct is_scalar |
| 48 | : public integral_constant< | 48 | : integral_constant< |
| 49 | bool, is_arithmetic<_Tp>::value || | 49 | bool, is_arithmetic<_Tp>::value || |
| 50 | is_member_pointer<_Tp>::value || | 50 | is_member_pointer<_Tp>::value || |
| 51 | is_pointer<_Tp>::value || | 51 | is_pointer<_Tp>::value || |
| ... | @@ -55,7 +55,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar | ... | @@ -55,7 +55,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar |
| 55 | // clang-format on | 55 | // clang-format on |
| 56 | 56 | ||
| 57 | template <> | 57 | template <> |
| 58 | struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; | 58 | struct is_scalar<nullptr_t> : true_type {}; |
| 59 | 59 | ||
| 60 | # if _LIBCPP_STD_VER >= 17 | 60 | # if _LIBCPP_STD_VER >= 17 |
| 61 | template <class _Tp> | 61 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_signed.h+5-12| ... | @@ -12,7 +12,6 @@ | ... | @@ -12,7 +12,6 @@ |
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/integral_constant.h> |
| 14 | #include <__type_traits/is_arithmetic.h> | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | #include <__type_traits/is_integral.h> | ||
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| ... | @@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if __has_builtin(__is_signed) | 22 | #if __has_builtin(__is_signed) |
| 24 | 23 | ||
| 25 | template <class _Tp> | 24 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {}; | 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {}; |
| 27 | 26 | ||
| 28 | # if _LIBCPP_STD_VER >= 17 | 27 | # if _LIBCPP_STD_VER >= 17 |
| 29 | template <class _Tp> | 28 | template <class _Tp> |
| ... | @@ -32,24 +31,18 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_signed_v = __is_signed(_Tp); | ... | @@ -32,24 +31,18 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_signed_v = __is_signed(_Tp); |
| 32 | 31 | ||
| 33 | #else // __has_builtin(__is_signed) | 32 | #else // __has_builtin(__is_signed) |
| 34 | 33 | ||
| 35 | template <class _Tp, bool = is_integral<_Tp>::value> | ||
| 36 | struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {}; | ||
| 37 | |||
| 38 | template <class _Tp> | ||
| 39 | struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point | ||
| 40 | |||
| 41 | template <class _Tp, bool = is_arithmetic<_Tp>::value> | 34 | template <class _Tp, bool = is_arithmetic<_Tp>::value> |
| 42 | struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; | 35 | inline constexpr bool __is_signed_v = false; |
| 43 | 36 | ||
| 44 | template <class _Tp> | 37 | template <class _Tp> |
| 45 | struct __libcpp_is_signed<_Tp, false> : public false_type {}; | 38 | inline constexpr bool __is_signed_v<_Tp, true> = _Tp(-1) < _Tp(0); |
| 46 | 39 | ||
| 47 | template <class _Tp> | 40 | template <class _Tp> |
| 48 | struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; | 41 | struct is_signed : integral_constant<bool, __is_signed_v<_Tp>> {}; |
| 49 | 42 | ||
| 50 | # if _LIBCPP_STD_VER >= 17 | 43 | # if _LIBCPP_STD_VER >= 17 |
| 51 | template <class _Tp> | 44 | template <class _Tp> |
| 52 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; | 45 | inline constexpr bool is_signed_v = __is_signed_v<_Tp>; |
| 53 | # endif | 46 | # endif |
| 54 | 47 | ||
| 55 | #endif // __has_builtin(__is_signed) | 48 | #endif // __has_builtin(__is_signed) |
lib/libcxx/include/__type_traits/is_signed_integer.h deleted-35| ... | @@ -1,35 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | // clang-format off | ||
| 22 | template <class _Tp> struct __libcpp_is_signed_integer : public false_type {}; | ||
| 23 | template <> struct __libcpp_is_signed_integer<signed char> : public true_type {}; | ||
| 24 | template <> struct __libcpp_is_signed_integer<signed short> : public true_type {}; | ||
| 25 | template <> struct __libcpp_is_signed_integer<signed int> : public true_type {}; | ||
| 26 | template <> struct __libcpp_is_signed_integer<signed long> : public true_type {}; | ||
| 27 | template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {}; | ||
| 28 | #if _LIBCPP_HAS_INT128 | ||
| 29 | template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; | ||
| 30 | #endif | ||
| 31 | // clang-format on | ||
| 32 | |||
| 33 | _LIBCPP_END_NAMESPACE_STD | ||
| 34 | |||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H | ||
lib/libcxx/include/__type_traits/is_standard_layout.h+1-2| ... | @@ -19,8 +19,7 @@ | ... | @@ -19,8 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_standard_layout | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_standard_layout : integral_constant<bool, __is_standard_layout(_Tp)> {}; |
| 23 | : public integral_constant<bool, __is_standard_layout(_Tp)> {}; | ||
| 24 | 23 | ||
| 25 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 26 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_swappable.h+5-8| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | 13 | #include <__cstddef/size_t.h> |
| 14 | #include <__type_traits/add_lvalue_reference.h> | 14 | #include <__type_traits/add_reference.h> |
| 15 | #include <__type_traits/enable_if.h> | 15 | #include <__type_traits/enable_if.h> |
| 16 | #include <__type_traits/integral_constant.h> | 16 | #include <__type_traits/integral_constant.h> |
| 17 | #include <__type_traits/is_assignable.h> | 17 | #include <__type_traits/is_assignable.h> |
| ... | @@ -77,30 +77,27 @@ template <class _Tp, class _Up> | ... | @@ -77,30 +77,27 @@ template <class _Tp, class _Up> |
| 77 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>; | 77 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>; |
| 78 | 78 | ||
| 79 | template <class _Tp, class _Up> | 79 | template <class _Tp, class _Up> |
| 80 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable_with | 80 | struct _LIBCPP_NO_SPECIALIZATIONS is_swappable_with : bool_constant<is_swappable_with_v<_Tp, _Up>> {}; |
| 81 | : bool_constant<is_swappable_with_v<_Tp, _Up>> {}; | ||
| 82 | 81 | ||
| 83 | template <class _Tp> | 82 | template <class _Tp> |
| 84 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_v = | 83 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_v = |
| 85 | is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; | 84 | is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; |
| 86 | 85 | ||
| 87 | template <class _Tp> | 86 | template <class _Tp> |
| 88 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable : bool_constant<is_swappable_v<_Tp>> {}; | 87 | struct _LIBCPP_NO_SPECIALIZATIONS is_swappable : bool_constant<is_swappable_v<_Tp>> {}; |
| 89 | 88 | ||
| 90 | template <class _Tp, class _Up> | 89 | template <class _Tp, class _Up> |
| 91 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>; | 90 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>; |
| 92 | 91 | ||
| 93 | template <class _Tp, class _Up> | 92 | template <class _Tp, class _Up> |
| 94 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable_with | 93 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable_with : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {}; |
| 95 | : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {}; | ||
| 96 | 94 | ||
| 97 | template <class _Tp> | 95 | template <class _Tp> |
| 98 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_v = | 96 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_v = |
| 99 | is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; | 97 | is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; |
| 100 | 98 | ||
| 101 | template <class _Tp> | 99 | template <class _Tp> |
| 102 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable | 100 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable : bool_constant<is_nothrow_swappable_v<_Tp>> {}; |
| 103 | : bool_constant<is_nothrow_swappable_v<_Tp>> {}; | ||
| 104 | 101 | ||
| 105 | #endif // _LIBCPP_STD_VER >= 17 | 102 | #endif // _LIBCPP_STD_VER >= 17 |
| 106 | 103 |
lib/libcxx/include/__type_traits/is_trivial.h+5-2| ... | @@ -19,11 +19,14 @@ | ... | @@ -19,11 +19,14 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> { | 22 | struct _LIBCPP_DEPRECATED_IN_CXX26_( |
| 23 | }; | 23 | "Consider using is_trivially_copyable<T>::value && is_trivially_default_constructible<T>::value instead.") |
| 24 | _LIBCPP_NO_SPECIALIZATIONS is_trivial : integral_constant<bool, __is_trivial(_Tp)> {}; | ||
| 24 | 25 | ||
| 25 | #if _LIBCPP_STD_VER >= 17 | 26 | #if _LIBCPP_STD_VER >= 17 |
| 26 | template <class _Tp> | 27 | template <class _Tp> |
| 28 | _LIBCPP_DEPRECATED_IN_CXX26_( | ||
| 29 | "Consider using is_trivially_copyable_v<T> && is_trivially_default_constructible_v<T> instead.") | ||
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp); | 30 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp); |
| 28 | #endif | 31 | #endif |
| 29 | 32 |
lib/libcxx/include/__type_traits/is_trivially_assignable.h+6-8| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_reference.h> |
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -30,8 +29,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_assignable_v = __i | ... | @@ -30,8 +29,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_assignable_v = __i |
| 30 | #endif | 29 | #endif |
| 31 | 30 | ||
| 32 | template <class _Tp> | 31 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_assignable | 32 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_assignable |
| 34 | : public integral_constant< | 33 | : integral_constant< |
| 35 | bool, | 34 | bool, |
| 36 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; | 35 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; |
| 37 | 36 | ||
| ... | @@ -42,10 +41,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_assignable_v | ... | @@ -42,10 +41,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_assignable_v |
| 42 | #endif | 41 | #endif |
| 43 | 42 | ||
| 44 | template <class _Tp> | 43 | template <class _Tp> |
| 45 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_assignable | 44 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_assignable |
| 46 | : public integral_constant< | 45 | : integral_constant<bool, __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> { |
| 47 | bool, | 46 | }; |
| 48 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; | ||
| 49 | 47 | ||
| 50 | #if _LIBCPP_STD_VER >= 17 | 48 | #if _LIBCPP_STD_VER >= 17 |
| 51 | template <class _Tp> | 49 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_trivially_constructible.h+8-9| ... | @@ -10,8 +10,7 @@ | ... | @@ -10,8 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H | 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/add_lvalue_reference.h> | 13 | #include <__type_traits/add_reference.h> |
| 14 | #include <__type_traits/add_rvalue_reference.h> | ||
| 15 | #include <__type_traits/integral_constant.h> | 14 | #include <__type_traits/integral_constant.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -21,7 +20,7 @@ | ... | @@ -21,7 +20,7 @@ |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 21 | ||
| 23 | template <class _Tp, class... _Args> | 22 | template <class _Tp, class... _Args> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_constructible | 23 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_constructible |
| 25 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> {}; | 24 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> {}; |
| 26 | 25 | ||
| 27 | #if _LIBCPP_STD_VER >= 17 | 26 | #if _LIBCPP_STD_VER >= 17 |
| ... | @@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_constructible_v = | ... | @@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_constructible_v = |
| 31 | #endif | 30 | #endif |
| 32 | 31 | ||
| 33 | template <class _Tp> | 32 | template <class _Tp> |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_constructible | 33 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_constructible |
| 35 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; | 34 | : integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; |
| 36 | 35 | ||
| 37 | #if _LIBCPP_STD_VER >= 17 | 36 | #if _LIBCPP_STD_VER >= 17 |
| 38 | template <class _Tp> | 37 | template <class _Tp> |
| ... | @@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_constructible | ... | @@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_constructible |
| 41 | #endif | 40 | #endif |
| 42 | 41 | ||
| 43 | template <class _Tp> | 42 | template <class _Tp> |
| 44 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_constructible | 43 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_constructible |
| 45 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; | 44 | : integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; |
| 46 | 45 | ||
| 47 | #if _LIBCPP_STD_VER >= 17 | 46 | #if _LIBCPP_STD_VER >= 17 |
| 48 | template <class _Tp> | 47 | template <class _Tp> |
| ... | @@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_constructible | ... | @@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_constructible |
| 51 | #endif | 50 | #endif |
| 52 | 51 | ||
| 53 | template <class _Tp> | 52 | template <class _Tp> |
| 54 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_default_constructible | 53 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_default_constructible |
| 55 | : public integral_constant<bool, __is_trivially_constructible(_Tp)> {}; | 54 | : integral_constant<bool, __is_trivially_constructible(_Tp)> {}; |
| 56 | 55 | ||
| 57 | #if _LIBCPP_STD_VER >= 17 | 56 | #if _LIBCPP_STD_VER >= 17 |
| 58 | template <class _Tp> | 57 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_trivially_copyable.h+1-2| ... | @@ -20,8 +20,7 @@ | ... | @@ -20,8 +20,7 @@ |
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class _Tp> | 22 | template <class _Tp> |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copyable | 23 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_copyable : integral_constant<bool, __is_trivially_copyable(_Tp)> {}; |
| 24 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> {}; | ||
| 25 | 24 | ||
| 26 | #if _LIBCPP_STD_VER >= 17 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 27 | template <class _Tp> | 26 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_trivially_destructible.h+4-4| ... | @@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if __has_builtin(__is_trivially_destructible) | 22 | #if __has_builtin(__is_trivially_destructible) |
| 23 | 23 | ||
| 24 | template <class _Tp> | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_destructible | 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_destructible |
| 26 | : public integral_constant<bool, __is_trivially_destructible(_Tp)> {}; | 26 | : integral_constant<bool, __is_trivially_destructible(_Tp)> {}; |
| 27 | 27 | ||
| 28 | #elif __has_builtin(__has_trivial_destructor) | 28 | #elif __has_builtin(__has_trivial_destructor) |
| 29 | 29 | ||
| 30 | template <class _Tp> | 30 | template <class _Tp> |
| 31 | struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | 31 | struct is_trivially_destructible |
| 32 | : public integral_constant<bool, is_destructible<_Tp>::value&& __has_trivial_destructor(_Tp)> {}; | 32 | : integral_constant<bool, is_destructible<_Tp>::value&& __has_trivial_destructor(_Tp)> {}; |
| 33 | 33 | ||
| 34 | #else | 34 | #else |
| 35 | 35 |
lib/libcxx/include/__type_traits/is_unbounded_array.h+2-10| ... | @@ -25,19 +25,11 @@ inline const bool __is_unbounded_array_v<_Tp[]> = true; | ... | @@ -25,19 +25,11 @@ inline const bool __is_unbounded_array_v<_Tp[]> = true; |
| 25 | 25 | ||
| 26 | #if _LIBCPP_STD_VER >= 20 | 26 | #if _LIBCPP_STD_VER >= 20 |
| 27 | 27 | ||
| 28 | template <class> | ||
| 29 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : false_type {}; | ||
| 30 | |||
| 31 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 32 | # if __has_warning("-Winvalid-specialization") | ||
| 33 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | ||
| 34 | # endif | ||
| 35 | template <class _Tp> | 28 | template <class _Tp> |
| 36 | struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; | 29 | struct _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : bool_constant<__is_unbounded_array_v<_Tp>> {}; |
| 37 | _LIBCPP_DIAGNOSTIC_POP | ||
| 38 | 30 | ||
| 39 | template <class _Tp> | 31 | template <class _Tp> |
| 40 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; | 32 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = __is_unbounded_array_v<_Tp>; |
| 41 | 33 | ||
| 42 | #endif | 34 | #endif |
| 43 | 35 |
lib/libcxx/include/__type_traits/is_union.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_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_union : public integral_constant<bool, __is_union(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_union : integral_constant<bool, __is_union(_Tp)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_unsigned.h+5-12| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/integral_constant.h> |
| 14 | #include <__type_traits/is_arithmetic.h> | ||
| 15 | #include <__type_traits/is_integral.h> | 14 | #include <__type_traits/is_integral.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | #if __has_builtin(__is_unsigned) | 22 | #if __has_builtin(__is_unsigned) |
| 24 | 23 | ||
| 25 | template <class _Tp> | 24 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {}; | 25 | struct _LIBCPP_NO_SPECIALIZATIONS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {}; |
| 27 | 26 | ||
| 28 | # if _LIBCPP_STD_VER >= 17 | 27 | # if _LIBCPP_STD_VER >= 17 |
| 29 | template <class _Tp> | 28 | template <class _Tp> |
| ... | @@ -33,23 +32,17 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unsigned_v = __is_unsigned(_ | ... | @@ -33,23 +32,17 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unsigned_v = __is_unsigned(_ |
| 33 | #else // __has_builtin(__is_unsigned) | 32 | #else // __has_builtin(__is_unsigned) |
| 34 | 33 | ||
| 35 | template <class _Tp, bool = is_integral<_Tp>::value> | 34 | template <class _Tp, bool = is_integral<_Tp>::value> |
| 36 | struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {}; | 35 | inline constexpr bool __is_unsigned_v = false; |
| 37 | 36 | ||
| 38 | template <class _Tp> | 37 | template <class _Tp> |
| 39 | struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point | 38 | inline constexpr bool __is_unsigned_v<_Tp, true> = _Tp(0) < _Tp(-1); |
| 40 | |||
| 41 | template <class _Tp, bool = is_arithmetic<_Tp>::value> | ||
| 42 | struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; | ||
| 43 | |||
| 44 | template <class _Tp> | ||
| 45 | struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; | ||
| 46 | 39 | ||
| 47 | template <class _Tp> | 40 | template <class _Tp> |
| 48 | struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; | 41 | struct is_unsigned : integral_constant<bool, __is_unsigned_v<_Tp>> {}; |
| 49 | 42 | ||
| 50 | # if _LIBCPP_STD_VER >= 17 | 43 | # if _LIBCPP_STD_VER >= 17 |
| 51 | template <class _Tp> | 44 | template <class _Tp> |
| 52 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; | 45 | inline constexpr bool is_unsigned_v = __is_unsigned_v<_Tp>; |
| 53 | # endif | 46 | # endif |
| 54 | 47 | ||
| 55 | #endif // __has_builtin(__is_unsigned) | 48 | #endif // __has_builtin(__is_unsigned) |
lib/libcxx/include/__type_traits/is_unsigned_integer.h deleted-35| ... | @@ -1,35 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | // clang-format off | ||
| 22 | template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {}; | ||
| 23 | template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {}; | ||
| 24 | template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {}; | ||
| 25 | template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {}; | ||
| 26 | template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {}; | ||
| 27 | template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {}; | ||
| 28 | #if _LIBCPP_HAS_INT128 | ||
| 29 | template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; | ||
| 30 | #endif | ||
| 31 | // clang-format on | ||
| 32 | |||
| 33 | _LIBCPP_END_NAMESPACE_STD | ||
| 34 | |||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H | ||
lib/libcxx/include/__type_traits/is_void.h+1-1| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp> | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {}; |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | template <class _Tp> | 25 | template <class _Tp> |
lib/libcxx/include/__type_traits/is_volatile.h+3-19| ... | @@ -18,29 +18,13 @@ | ... | @@ -18,29 +18,13 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if __has_builtin(__is_volatile) | ||
| 22 | |||
| 23 | template <class _Tp> | 21 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_volatile : _BoolConstant<__is_volatile(_Tp)> {}; | 22 | struct _LIBCPP_NO_SPECIALIZATIONS is_volatile : _BoolConstant<__is_volatile(_Tp)> {}; |
| 25 | 23 | ||
| 26 | # if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 27 | template <class _Tp> | 25 | template <class _Tp> |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_volatile_v = __is_volatile(_Tp); | 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_volatile_v = __is_volatile(_Tp); |
| 29 | # endif | 27 | #endif |
| 30 | |||
| 31 | #else | ||
| 32 | |||
| 33 | template <class _Tp> | ||
| 34 | struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; | ||
| 35 | template <class _Tp> | ||
| 36 | struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; | ||
| 37 | |||
| 38 | # if _LIBCPP_STD_VER >= 17 | ||
| 39 | template <class _Tp> | ||
| 40 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; | ||
| 41 | # endif | ||
| 42 | |||
| 43 | #endif // __has_builtin(__is_volatile) | ||
| 44 | 28 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | 29 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 30 |
lib/libcxx/include/__type_traits/promote.h+16-20| ... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_PROMOTE_H | 10 | #define _LIBCPP___TYPE_TRAITS_PROMOTE_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | 13 | #include <__type_traits/enable_if.h> |
| 14 | #include <__type_traits/is_arithmetic.h> | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -19,28 +19,24 @@ | ... | @@ -19,28 +19,24 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | template <class... _Args> | 22 | float __promote_impl(float); |
| 23 | class __promote { | 23 | double __promote_impl(char); |
| 24 | static_assert((is_arithmetic<_Args>::value && ...)); | 24 | double __promote_impl(int); |
| 25 | 25 | double __promote_impl(unsigned); | |
| 26 | static float __test(float); | 26 | double __promote_impl(long); |
| 27 | static double __test(char); | 27 | double __promote_impl(unsigned long); |
| 28 | static double __test(int); | 28 | double __promote_impl(long long); |
| 29 | static double __test(unsigned); | 29 | double __promote_impl(unsigned long long); |
| 30 | static double __test(long); | ||
| 31 | static double __test(unsigned long); | ||
| 32 | static double __test(long long); | ||
| 33 | static double __test(unsigned long long); | ||
| 34 | #if _LIBCPP_HAS_INT128 | 30 | #if _LIBCPP_HAS_INT128 |
| 35 | static double __test(__int128_t); | 31 | double __promote_impl(__int128_t); |
| 36 | static double __test(__uint128_t); | 32 | double __promote_impl(__uint128_t); |
| 37 | #endif | 33 | #endif |
| 38 | static double __test(double); | 34 | double __promote_impl(double); |
| 39 | static long double __test(long double); | 35 | long double __promote_impl(long double); |
| 40 | 36 | ||
| 41 | public: | 37 | template <class... _Args> |
| 42 | using type = decltype((__test(_Args()) + ...)); | 38 | using __promote_t _LIBCPP_NODEBUG = |
| 43 | }; | 39 | decltype((__enable_if_t<(is_arithmetic<_Args>::value && ...)>)0, (std::__promote_impl(_Args()) + ...)); |
| 44 | 40 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | 41 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 42 |
lib/libcxx/include/__type_traits/rank.h+6-6| ... | @@ -19,25 +19,25 @@ | ... | @@ -19,25 +19,25 @@ |
| 19 | 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | // TODO: Enable using the builtin __array_rank when https://llvm.org/PR57133 is resolved | 22 | #if __has_builtin(__array_rank) && !defined(_LIBCPP_COMPILER_CLANG_BASED) || \ |
| 23 | #if __has_builtin(__array_rank) && 0 | 23 | (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2001) |
| 24 | 24 | ||
| 25 | template <class _Tp> | 25 | template <class _Tp> |
| 26 | struct rank : integral_constant<size_t, __array_rank(_Tp)> {}; | 26 | struct _LIBCPP_NO_SPECIALIZATIONS rank : integral_constant<size_t, __array_rank(_Tp)> {}; |
| 27 | 27 | ||
| 28 | #else | 28 | #else |
| 29 | 29 | ||
| 30 | template <class _Tp> | 30 | template <class _Tp> |
| 31 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {}; | 31 | struct _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {}; |
| 32 | 32 | ||
| 33 | _LIBCPP_DIAGNOSTIC_PUSH | 33 | _LIBCPP_DIAGNOSTIC_PUSH |
| 34 | # if __has_warning("-Winvalid-specialization") | 34 | # if __has_warning("-Winvalid-specialization") |
| 35 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | 35 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") |
| 36 | # endif | 36 | # endif |
| 37 | template <class _Tp> | 37 | template <class _Tp> |
| 38 | struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; | 38 | struct rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
| 39 | template <class _Tp, size_t _Np> | 39 | template <class _Tp, size_t _Np> |
| 40 | struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; | 40 | struct rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
| 41 | _LIBCPP_DIAGNOSTIC_POP | 41 | _LIBCPP_DIAGNOSTIC_POP |
| 42 | 42 | ||
| 43 | #endif // __has_builtin(__array_rank) | 43 | #endif // __has_builtin(__array_rank) |
lib/libcxx/include/__type_traits/reference_constructs_from_temporary.h created+44| ... | @@ -0,0 +1,44 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if _LIBCPP_STD_VER >= 23 && __has_builtin(__reference_constructs_from_temporary) | ||
| 22 | |||
| 23 | template <class _Tp, class _Up> | ||
| 24 | struct _LIBCPP_NO_SPECIALIZATIONS reference_constructs_from_temporary | ||
| 25 | : public bool_constant<__reference_constructs_from_temporary(_Tp, _Up)> {}; | ||
| 26 | |||
| 27 | template <class _Tp, class _Up> | ||
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_constructs_from_temporary_v = | ||
| 29 | __reference_constructs_from_temporary(_Tp, _Up); | ||
| 30 | |||
| 31 | #endif | ||
| 32 | |||
| 33 | #if __has_builtin(__reference_constructs_from_temporary) | ||
| 34 | template <class _Tp, class _Up> | ||
| 35 | 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 | |||
| 42 | _LIBCPP_END_NAMESPACE_STD | ||
| 43 | |||
| 44 | #endif // _LIBCPP___TYPE_TRAITS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY_H | ||
lib/libcxx/include/__type_traits/reference_converts_from_temporary.h created+35| ... | @@ -0,0 +1,35 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REFERENCE_CONVERTS_FROM_TEMPORARY_H | ||
| 10 | #define _LIBCPP___TYPE_TRAITS_REFERENCE_CONVERTS_FROM_TEMPORARY_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__type_traits/integral_constant.h> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if _LIBCPP_STD_VER >= 23 && __has_builtin(__reference_converts_from_temporary) | ||
| 22 | |||
| 23 | template <class _Tp, class _Up> | ||
| 24 | struct _LIBCPP_NO_SPECIALIZATIONS reference_converts_from_temporary | ||
| 25 | : public bool_constant<__reference_converts_from_temporary(_Tp, _Up)> {}; | ||
| 26 | |||
| 27 | template <class _Tp, class _Up> | ||
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_converts_from_temporary_v = | ||
| 29 | __reference_converts_from_temporary(_Tp, _Up); | ||
| 30 | |||
| 31 | #endif | ||
| 32 | |||
| 33 | _LIBCPP_END_NAMESPACE_STD | ||
| 34 | |||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_REFERENCE_CONVERTS_FROM_TEMPORARY_H | ||
lib/libcxx/include/__type_traits/remove_all_extents.h+4-18| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H | 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | ||
| 14 | 13 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -18,31 +17,18 @@ | ... | @@ -18,31 +17,18 @@ |
| 18 | 17 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 19 | ||
| 21 | #if __has_builtin(__remove_all_extents) | ||
| 22 | template <class _Tp> | 20 | template <class _Tp> |
| 23 | struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents { | 21 | struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents { |
| 24 | using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp); | 22 | using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp); |
| 25 | }; | 23 | }; |
| 26 | 24 | ||
| 25 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 27 | template <class _Tp> | 26 | template <class _Tp> |
| 28 | using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp); | 27 | using __remove_all_extents_t _LIBCPP_NODEBUG = typename remove_all_extents<_Tp>::type; |
| 29 | #else | 28 | #else |
| 30 | template <class _Tp> | 29 | template <class _Tp> |
| 31 | struct _LIBCPP_TEMPLATE_VIS remove_all_extents { | 30 | using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp); |
| 32 | typedef _Tp type; | 31 | #endif |
| 33 | }; | ||
| 34 | template <class _Tp> | ||
| 35 | struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> { | ||
| 36 | typedef typename remove_all_extents<_Tp>::type type; | ||
| 37 | }; | ||
| 38 | template <class _Tp, size_t _Np> | ||
| 39 | struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> { | ||
| 40 | typedef typename remove_all_extents<_Tp>::type type; | ||
| 41 | }; | ||
| 42 | |||
| 43 | template <class _Tp> | ||
| 44 | using __remove_all_extents_t = typename remove_all_extents<_Tp>::type; | ||
| 45 | #endif // __has_builtin(__remove_all_extents) | ||
| 46 | 32 | ||
| 47 | #if _LIBCPP_STD_VER >= 14 | 33 | #if _LIBCPP_STD_VER >= 14 |
| 48 | template <class _Tp> | 34 | template <class _Tp> |
lib/libcxx/include/__type_traits/remove_const.h+2-2| ... | @@ -27,11 +27,11 @@ template <class _Tp> | ... | @@ -27,11 +27,11 @@ template <class _Tp> |
| 27 | using __remove_const_t _LIBCPP_NODEBUG = __remove_const(_Tp); | 27 | using __remove_const_t _LIBCPP_NODEBUG = __remove_const(_Tp); |
| 28 | #else | 28 | #else |
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| 30 | struct _LIBCPP_TEMPLATE_VIS remove_const { | 30 | struct remove_const { |
| 31 | typedef _Tp type; | 31 | typedef _Tp type; |
| 32 | }; | 32 | }; |
| 33 | template <class _Tp> | 33 | template <class _Tp> |
| 34 | struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> { | 34 | struct remove_const<const _Tp> { |
| 35 | typedef _Tp type; | 35 | typedef _Tp type; |
| 36 | }; | 36 | }; |
| 37 | 37 |
lib/libcxx/include/__type_traits/remove_cvref.h-4| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H | 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/is_same.h> | ||
| 14 | 13 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -31,9 +30,6 @@ template <class _Tp> | ... | @@ -31,9 +30,6 @@ template <class _Tp> |
| 31 | using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp); | 30 | using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp); |
| 32 | #endif // __has_builtin(__remove_cvref) | 31 | #endif // __has_builtin(__remove_cvref) |
| 33 | 32 | ||
| 34 | template <class _Tp, class _Up> | ||
| 35 | using __is_same_uncvref _LIBCPP_NODEBUG = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >; | ||
| 36 | |||
| 37 | #if _LIBCPP_STD_VER >= 20 | 33 | #if _LIBCPP_STD_VER >= 20 |
| 38 | template <class _Tp> | 34 | template <class _Tp> |
| 39 | struct _LIBCPP_NO_SPECIALIZATIONS remove_cvref { | 35 | struct _LIBCPP_NO_SPECIALIZATIONS remove_cvref { |
lib/libcxx/include/__type_traits/remove_extent.h+4-18| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H | 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | ||
| 14 | 13 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 15 | # pragma GCC system_header |
| ... | @@ -18,31 +17,18 @@ | ... | @@ -18,31 +17,18 @@ |
| 18 | 17 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 19 | ||
| 21 | #if __has_builtin(__remove_extent) | ||
| 22 | template <class _Tp> | 20 | template <class _Tp> |
| 23 | struct _LIBCPP_NO_SPECIALIZATIONS remove_extent { | 21 | struct _LIBCPP_NO_SPECIALIZATIONS remove_extent { |
| 24 | using type _LIBCPP_NODEBUG = __remove_extent(_Tp); | 22 | using type _LIBCPP_NODEBUG = __remove_extent(_Tp); |
| 25 | }; | 23 | }; |
| 26 | 24 | ||
| 25 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 27 | template <class _Tp> | 26 | template <class _Tp> |
| 28 | using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp); | 27 | using __remove_extent_t _LIBCPP_NODEBUG = typename remove_extent<_Tp>::type; |
| 29 | #else | 28 | #else |
| 30 | template <class _Tp> | 29 | template <class _Tp> |
| 31 | struct _LIBCPP_TEMPLATE_VIS remove_extent { | 30 | using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp); |
| 32 | typedef _Tp type; | 31 | #endif |
| 33 | }; | ||
| 34 | template <class _Tp> | ||
| 35 | struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> { | ||
| 36 | typedef _Tp type; | ||
| 37 | }; | ||
| 38 | template <class _Tp, size_t _Np> | ||
| 39 | struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> { | ||
| 40 | typedef _Tp type; | ||
| 41 | }; | ||
| 42 | |||
| 43 | template <class _Tp> | ||
| 44 | using __remove_extent_t = typename remove_extent<_Tp>::type; | ||
| 45 | #endif // __has_builtin(__remove_extent) | ||
| 46 | 32 | ||
| 47 | #if _LIBCPP_STD_VER >= 14 | 33 | #if _LIBCPP_STD_VER >= 14 |
| 48 | template <class _Tp> | 34 | template <class _Tp> |
lib/libcxx/include/__type_traits/remove_pointer.h+5-5| ... | @@ -32,11 +32,11 @@ using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp); | ... | @@ -32,11 +32,11 @@ using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp); |
| 32 | # endif | 32 | # endif |
| 33 | #else | 33 | #else |
| 34 | // clang-format off | 34 | // clang-format off |
| 35 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {using type _LIBCPP_NODEBUG = _Tp;}; | 35 | template <class _Tp> struct remove_pointer {using type _LIBCPP_NODEBUG = _Tp;}; |
| 36 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;}; | 36 | template <class _Tp> struct remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;}; |
| 37 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;}; | 37 | template <class _Tp> struct remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;}; |
| 38 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;}; | 38 | template <class _Tp> struct remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;}; |
| 39 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;}; | 39 | template <class _Tp> struct remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;}; |
| 40 | // clang-format on | 40 | // clang-format on |
| 41 | 41 | ||
| 42 | template <class _Tp> | 42 | template <class _Tp> |
lib/libcxx/include/__type_traits/remove_volatile.h+2-2| ... | @@ -27,11 +27,11 @@ template <class _Tp> | ... | @@ -27,11 +27,11 @@ template <class _Tp> |
| 27 | using __remove_volatile_t _LIBCPP_NODEBUG = __remove_volatile(_Tp); | 27 | using __remove_volatile_t _LIBCPP_NODEBUG = __remove_volatile(_Tp); |
| 28 | #else | 28 | #else |
| 29 | template <class _Tp> | 29 | template <class _Tp> |
| 30 | struct _LIBCPP_TEMPLATE_VIS remove_volatile { | 30 | struct remove_volatile { |
| 31 | typedef _Tp type; | 31 | typedef _Tp type; |
| 32 | }; | 32 | }; |
| 33 | template <class _Tp> | 33 | template <class _Tp> |
| 34 | struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> { | 34 | struct remove_volatile<volatile _Tp> { |
| 35 | typedef _Tp type; | 35 | typedef _Tp type; |
| 36 | }; | 36 | }; |
| 37 | 37 |
lib/libcxx/include/__type_traits/result_of.h+1-1| ... | @@ -29,7 +29,7 @@ _LIBCPP_DIAGNOSTIC_PUSH | ... | @@ -29,7 +29,7 @@ _LIBCPP_DIAGNOSTIC_PUSH |
| 29 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | 29 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") |
| 30 | #endif | 30 | #endif |
| 31 | template <class _Fp, class... _Args> | 31 | template <class _Fp, class... _Args> |
| 32 | struct _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {}; | 32 | struct result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {}; |
| 33 | _LIBCPP_DIAGNOSTIC_POP | 33 | _LIBCPP_DIAGNOSTIC_POP |
| 34 | 34 | ||
| 35 | # if _LIBCPP_STD_VER >= 14 | 35 | # if _LIBCPP_STD_VER >= 14 |
lib/libcxx/include/__type_traits/strip_signature.h+18-18| ... | @@ -26,52 +26,52 @@ struct __strip_signature; | ... | @@ -26,52 +26,52 @@ struct __strip_signature; |
| 26 | 26 | ||
| 27 | template <class _Rp, class... _Args> | 27 | template <class _Rp, class... _Args> |
| 28 | struct __strip_signature<_Rp (*)(_Args...)> { | 28 | struct __strip_signature<_Rp (*)(_Args...)> { |
| 29 | using type = _Rp(_Args...); | 29 | using type _LIBCPP_NODEBUG = _Rp(_Args...); |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | template <class _Rp, class... _Args> | 32 | template <class _Rp, class... _Args> |
| 33 | struct __strip_signature<_Rp (*)(_Args...) noexcept> { | 33 | struct __strip_signature<_Rp (*)(_Args...) noexcept> { |
| 34 | using type = _Rp(_Args...); | 34 | using type _LIBCPP_NODEBUG = _Rp(_Args...); |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | # endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L | 37 | # endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L |
| 38 | 38 | ||
| 39 | // clang-format off | 39 | // clang-format off |
| 40 | template<class _Rp, class _Gp, class ..._Ap> | 40 | template<class _Rp, class _Gp, class ..._Ap> |
| 41 | struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); }; | 41 | struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 42 | template<class _Rp, class _Gp, class ..._Ap> | 42 | template<class _Rp, class _Gp, class ..._Ap> |
| 43 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); }; | 43 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 44 | template<class _Rp, class _Gp, class ..._Ap> | 44 | template<class _Rp, class _Gp, class ..._Ap> |
| 45 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); }; | 45 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 46 | template<class _Rp, class _Gp, class ..._Ap> | 46 | template<class _Rp, class _Gp, class ..._Ap> |
| 47 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); }; | 47 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 48 | 48 | ||
| 49 | template<class _Rp, class _Gp, class ..._Ap> | 49 | template<class _Rp, class _Gp, class ..._Ap> |
| 50 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); }; | 50 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 51 | template<class _Rp, class _Gp, class ..._Ap> | 51 | template<class _Rp, class _Gp, class ..._Ap> |
| 52 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); }; | 52 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 53 | template<class _Rp, class _Gp, class ..._Ap> | 53 | template<class _Rp, class _Gp, class ..._Ap> |
| 54 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); }; | 54 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 55 | template<class _Rp, class _Gp, class ..._Ap> | 55 | template<class _Rp, class _Gp, class ..._Ap> |
| 56 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); }; | 56 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 57 | 57 | ||
| 58 | template<class _Rp, class _Gp, class ..._Ap> | 58 | template<class _Rp, class _Gp, class ..._Ap> |
| 59 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); }; | 59 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 60 | template<class _Rp, class _Gp, class ..._Ap> | 60 | template<class _Rp, class _Gp, class ..._Ap> |
| 61 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); }; | 61 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 62 | template<class _Rp, class _Gp, class ..._Ap> | 62 | template<class _Rp, class _Gp, class ..._Ap> |
| 63 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); }; | 63 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 64 | template<class _Rp, class _Gp, class ..._Ap> | 64 | template<class _Rp, class _Gp, class ..._Ap> |
| 65 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); }; | 65 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 66 | 66 | ||
| 67 | template<class _Rp, class _Gp, class ..._Ap> | 67 | template<class _Rp, class _Gp, class ..._Ap> |
| 68 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); }; | 68 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 69 | template<class _Rp, class _Gp, class ..._Ap> | 69 | template<class _Rp, class _Gp, class ..._Ap> |
| 70 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); }; | 70 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 71 | template<class _Rp, class _Gp, class ..._Ap> | 71 | template<class _Rp, class _Gp, class ..._Ap> |
| 72 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); }; | 72 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 73 | template<class _Rp, class _Gp, class ..._Ap> | 73 | template<class _Rp, class _Gp, class ..._Ap> |
| 74 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); }; | 74 | struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); }; |
| 75 | // clang-format on | 75 | // clang-format on |
| 76 | 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | 77 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/underlying_type.h+11-2| ... | @@ -18,7 +18,7 @@ | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | template <class _Tp, bool = is_enum<_Tp>::value> | 21 | template <class _Tp, bool> |
| 22 | struct __underlying_type_impl; | 22 | struct __underlying_type_impl; |
| 23 | 23 | ||
| 24 | template <class _Tp> | 24 | template <class _Tp> |
| ... | @@ -32,9 +32,18 @@ struct __underlying_type_impl<_Tp, true> { | ... | @@ -32,9 +32,18 @@ struct __underlying_type_impl<_Tp, true> { |
| 32 | template <class _Tp> | 32 | template <class _Tp> |
| 33 | struct _LIBCPP_NO_SPECIALIZATIONS underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; | 33 | struct _LIBCPP_NO_SPECIALIZATIONS underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; |
| 34 | 34 | ||
| 35 | // GCC doesn't SFINAE away when using __underlying_type directly | ||
| 36 | #if !defined(_LIBCPP_COMPILER_GCC) | ||
| 37 | template <class _Tp> | ||
| 38 | using __underlying_type_t _LIBCPP_NODEBUG = __underlying_type(_Tp); | ||
| 39 | #else | ||
| 40 | template <class _Tp> | ||
| 41 | using __underlying_type_t _LIBCPP_NODEBUG = typename underlying_type<_Tp>::type; | ||
| 42 | #endif | ||
| 43 | |||
| 35 | #if _LIBCPP_STD_VER >= 14 | 44 | #if _LIBCPP_STD_VER >= 14 |
| 36 | template <class _Tp> | 45 | template <class _Tp> |
| 37 | using underlying_type_t = typename underlying_type<_Tp>::type; | 46 | using underlying_type_t = __underlying_type_t<_Tp>; |
| 38 | #endif | 47 | #endif |
| 39 | 48 | ||
| 40 | _LIBCPP_END_NAMESPACE_STD | 49 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__utility/cmp.h+8-8| ... | @@ -9,8 +9,8 @@ | ... | @@ -9,8 +9,8 @@ |
| 9 | #ifndef _LIBCPP___UTILITY_CMP_H | 9 | #ifndef _LIBCPP___UTILITY_CMP_H |
| 10 | #define _LIBCPP___UTILITY_CMP_H | 10 | #define _LIBCPP___UTILITY_CMP_H |
| 11 | 11 | ||
| 12 | #include <__concepts/arithmetic.h> | ||
| 13 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__type_traits/integer_traits.h> | ||
| 14 | #include <__type_traits/is_signed.h> | 14 | #include <__type_traits/is_signed.h> |
| 15 | #include <__type_traits/make_unsigned.h> | 15 | #include <__type_traits/make_unsigned.h> |
| 16 | #include <limits> | 16 | #include <limits> |
| ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | ||
| 27 | #if _LIBCPP_STD_VER >= 20 | 27 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 28 | ||
| 29 | template <__libcpp_integer _Tp, __libcpp_integer _Up> | 29 | 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 { | 30 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { |
| 31 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) | 31 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) |
| 32 | return __t == __u; | 32 | return __t == __u; |
| ... | @@ -36,12 +36,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { | ... | @@ -36,12 +36,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept { |
| 36 | return __u < 0 ? false : __t == make_unsigned_t<_Up>(__u); | 36 | return __u < 0 ? false : __t == make_unsigned_t<_Up>(__u); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | template <__libcpp_integer _Tp, __libcpp_integer _Up> | 39 | 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 { | 40 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_not_equal(_Tp __t, _Up __u) noexcept { |
| 41 | return !std::cmp_equal(__t, __u); | 41 | return !std::cmp_equal(__t, __u); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | template <__libcpp_integer _Tp, __libcpp_integer _Up> | 44 | 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 { | 45 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { |
| 46 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) | 46 | if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>) |
| 47 | return __t < __u; | 47 | return __t < __u; |
| ... | @@ -51,22 +51,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { | ... | @@ -51,22 +51,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept { |
| 51 | return __u < 0 ? false : __t < make_unsigned_t<_Up>(__u); | 51 | return __u < 0 ? false : __t < make_unsigned_t<_Up>(__u); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | template <__libcpp_integer _Tp, __libcpp_integer _Up> | 54 | 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 { | 55 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater(_Tp __t, _Up __u) noexcept { |
| 56 | return std::cmp_less(__u, __t); | 56 | return std::cmp_less(__u, __t); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | template <__libcpp_integer _Tp, __libcpp_integer _Up> | 59 | 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 { | 60 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less_equal(_Tp __t, _Up __u) noexcept { |
| 61 | return !std::cmp_greater(__t, __u); | 61 | return !std::cmp_greater(__t, __u); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | template <__libcpp_integer _Tp, __libcpp_integer _Up> | 64 | 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 { | 65 | _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater_equal(_Tp __t, _Up __u) noexcept { |
| 66 | return !std::cmp_less(__t, __u); | 66 | return !std::cmp_less(__t, __u); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | template <__libcpp_integer _Tp, __libcpp_integer _Up> | 69 | template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up> |
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr bool in_range(_Up __u) noexcept { | 70 | _LIBCPP_HIDE_FROM_ABI constexpr bool in_range(_Up __u) noexcept { |
| 71 | return std::cmp_less_equal(__u, numeric_limits<_Tp>::max()) && | 71 | return std::cmp_less_equal(__u, numeric_limits<_Tp>::max()) && |
| 72 | std::cmp_greater_equal(__u, numeric_limits<_Tp>::min()); | 72 | std::cmp_greater_equal(__u, numeric_limits<_Tp>::min()); |
lib/libcxx/include/__utility/convert_to_integral.h+1-1| ... | @@ -50,7 +50,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral | ... | @@ -50,7 +50,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral |
| 50 | 50 | ||
| 51 | template <class _Tp, bool = is_enum<_Tp>::value> | 51 | template <class _Tp, bool = is_enum<_Tp>::value> |
| 52 | struct __sfinae_underlying_type { | 52 | struct __sfinae_underlying_type { |
| 53 | typedef typename underlying_type<_Tp>::type type; | 53 | using type = __underlying_type_t<_Tp>; |
| 54 | typedef decltype(((type)1) + 0) __promoted_type; | 54 | typedef decltype(((type)1) + 0) __promoted_type; |
| 55 | }; | 55 | }; |
| 56 | 56 |
lib/libcxx/include/__utility/exception_guard.h+3-4| ... | @@ -6,13 +6,12 @@ | ... | @@ -6,13 +6,12 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #ifndef _LIBCPP___UTILITY_TRANSACTION_H | 9 | #ifndef _LIBCPP___UTILITY_EXCEPTION_GUARD_H |
| 10 | #define _LIBCPP___UTILITY_TRANSACTION_H | 10 | #define _LIBCPP___UTILITY_EXCEPTION_GUARD_H |
| 11 | 11 | ||
| 12 | #include <__assert> | 12 | #include <__assert> |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/is_nothrow_constructible.h> | 14 | #include <__type_traits/is_nothrow_constructible.h> |
| 15 | #include <__utility/exchange.h> | ||
| 16 | #include <__utility/move.h> | 15 | #include <__utility/move.h> |
| 17 | 16 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -141,4 +140,4 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -141,4 +140,4 @@ _LIBCPP_END_NAMESPACE_STD |
| 141 | 140 | ||
| 142 | _LIBCPP_POP_MACROS | 141 | _LIBCPP_POP_MACROS |
| 143 | 142 | ||
| 144 | #endif // _LIBCPP___UTILITY_TRANSACTION_H | 143 | #endif // _LIBCPP___UTILITY_EXCEPTION_GUARD_H |
lib/libcxx/include/__utility/in_place.h+2-2| ... | @@ -28,14 +28,14 @@ struct _LIBCPP_EXPORTED_FROM_ABI in_place_t { | ... | @@ -28,14 +28,14 @@ struct _LIBCPP_EXPORTED_FROM_ABI in_place_t { |
| 28 | inline constexpr in_place_t in_place{}; | 28 | inline constexpr in_place_t in_place{}; |
| 29 | 29 | ||
| 30 | template <class _Tp> | 30 | template <class _Tp> |
| 31 | struct _LIBCPP_TEMPLATE_VIS in_place_type_t { | 31 | struct in_place_type_t { |
| 32 | _LIBCPP_HIDE_FROM_ABI explicit in_place_type_t() = default; | 32 | _LIBCPP_HIDE_FROM_ABI explicit in_place_type_t() = default; |
| 33 | }; | 33 | }; |
| 34 | template <class _Tp> | 34 | template <class _Tp> |
| 35 | inline constexpr in_place_type_t<_Tp> in_place_type{}; | 35 | inline constexpr in_place_type_t<_Tp> in_place_type{}; |
| 36 | 36 | ||
| 37 | template <size_t _Idx> | 37 | template <size_t _Idx> |
| 38 | struct _LIBCPP_TEMPLATE_VIS in_place_index_t { | 38 | struct in_place_index_t { |
| 39 | _LIBCPP_HIDE_FROM_ABI explicit in_place_index_t() = default; | 39 | _LIBCPP_HIDE_FROM_ABI explicit in_place_index_t() = default; |
| 40 | }; | 40 | }; |
| 41 | template <size_t _Idx> | 41 | template <size_t _Idx> |
lib/libcxx/include/__utility/integer_sequence.h+1-1| ... | @@ -46,7 +46,7 @@ using __make_indices_imp _LIBCPP_NODEBUG = | ... | @@ -46,7 +46,7 @@ using __make_indices_imp _LIBCPP_NODEBUG = |
| 46 | #if _LIBCPP_STD_VER >= 14 | 46 | #if _LIBCPP_STD_VER >= 14 |
| 47 | 47 | ||
| 48 | template <class _Tp, _Tp... _Ip> | 48 | template <class _Tp, _Tp... _Ip> |
| 49 | struct _LIBCPP_TEMPLATE_VIS integer_sequence { | 49 | struct integer_sequence { |
| 50 | typedef _Tp value_type; | 50 | typedef _Tp value_type; |
| 51 | static_assert(is_integral<_Tp>::value, "std::integer_sequence can only be instantiated with an integral type"); | 51 | static_assert(is_integral<_Tp>::value, "std::integer_sequence can only be instantiated with an integral type"); |
| 52 | static _LIBCPP_HIDE_FROM_ABI constexpr size_t size() noexcept { return sizeof...(_Ip); } | 52 | static _LIBCPP_HIDE_FROM_ABI constexpr size_t size() noexcept { return sizeof...(_Ip); } |
lib/libcxx/include/__utility/no_destroy.h-1| ... | @@ -11,7 +11,6 @@ | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | ||
| 12 | #include <__config> | 12 | #include <__config> |
| 13 | #include <__new/placement_new_delete.h> | 13 | #include <__new/placement_new_delete.h> |
| 14 | #include <__type_traits/is_constant_evaluated.h> | ||
| 15 | #include <__utility/forward.h> | 14 | #include <__utility/forward.h> |
| 16 | 15 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__utility/pair.h+97-83| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__compare/common_comparison_category.h> | 12 | #include <__compare/common_comparison_category.h> |
| 13 | #include <__compare/synth_three_way.h> | 13 | #include <__compare/synth_three_way.h> |
| 14 | #include <__concepts/boolean_testable.h> | ||
| 14 | #include <__concepts/different_from.h> | 15 | #include <__concepts/different_from.h> |
| 15 | #include <__config> | 16 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | 17 | #include <__cstddef/size_t.h> |
| ... | @@ -23,7 +24,6 @@ | ... | @@ -23,7 +24,6 @@ |
| 23 | #include <__type_traits/common_reference.h> | 24 | #include <__type_traits/common_reference.h> |
| 24 | #include <__type_traits/common_type.h> | 25 | #include <__type_traits/common_type.h> |
| 25 | #include <__type_traits/conditional.h> | 26 | #include <__type_traits/conditional.h> |
| 26 | #include <__type_traits/decay.h> | ||
| 27 | #include <__type_traits/enable_if.h> | 27 | #include <__type_traits/enable_if.h> |
| 28 | #include <__type_traits/integral_constant.h> | 28 | #include <__type_traits/integral_constant.h> |
| 29 | #include <__type_traits/is_assignable.h> | 29 | #include <__type_traits/is_assignable.h> |
| ... | @@ -32,11 +32,11 @@ | ... | @@ -32,11 +32,11 @@ |
| 32 | #include <__type_traits/is_implicitly_default_constructible.h> | 32 | #include <__type_traits/is_implicitly_default_constructible.h> |
| 33 | #include <__type_traits/is_nothrow_assignable.h> | 33 | #include <__type_traits/is_nothrow_assignable.h> |
| 34 | #include <__type_traits/is_nothrow_constructible.h> | 34 | #include <__type_traits/is_nothrow_constructible.h> |
| 35 | #include <__type_traits/is_replaceable.h> | ||
| 35 | #include <__type_traits/is_same.h> | 36 | #include <__type_traits/is_same.h> |
| 36 | #include <__type_traits/is_swappable.h> | 37 | #include <__type_traits/is_swappable.h> |
| 37 | #include <__type_traits/is_trivially_relocatable.h> | 38 | #include <__type_traits/is_trivially_relocatable.h> |
| 38 | #include <__type_traits/nat.h> | 39 | #include <__type_traits/nat.h> |
| 39 | #include <__type_traits/remove_cvref.h> | ||
| 40 | #include <__type_traits/unwrap_ref.h> | 40 | #include <__type_traits/unwrap_ref.h> |
| 41 | #include <__utility/declval.h> | 41 | #include <__utility/declval.h> |
| 42 | #include <__utility/forward.h> | 42 | #include <__utility/forward.h> |
| ... | @@ -52,6 +52,33 @@ _LIBCPP_PUSH_MACROS | ... | @@ -52,6 +52,33 @@ _LIBCPP_PUSH_MACROS |
| 52 | 52 | ||
| 53 | _LIBCPP_BEGIN_NAMESPACE_STD | 53 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 54 | 54 | ||
| 55 | #ifndef _LIBCPP_CXX03_LANG | ||
| 56 | |||
| 57 | template <class _T1, class _T2> | ||
| 58 | struct __check_pair_construction { | ||
| 59 | template <int&...> | ||
| 60 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { | ||
| 61 | return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value; | ||
| 62 | } | ||
| 63 | |||
| 64 | template <int&...> | ||
| 65 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() { | ||
| 66 | return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value; | ||
| 67 | } | ||
| 68 | |||
| 69 | template <class _U1, class _U2> | ||
| 70 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible() { | ||
| 71 | return is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value; | ||
| 72 | } | ||
| 73 | |||
| 74 | template <class _U1, class _U2> | ||
| 75 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() { | ||
| 76 | return is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value; | ||
| 77 | } | ||
| 78 | }; | ||
| 79 | |||
| 80 | #endif | ||
| 81 | |||
| 55 | template <class, class> | 82 | template <class, class> |
| 56 | struct __non_trivially_copyable_base { | 83 | struct __non_trivially_copyable_base { |
| 57 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base() _NOEXCEPT {} | 84 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base() _NOEXCEPT {} |
| ... | @@ -60,7 +87,7 @@ struct __non_trivially_copyable_base { | ... | @@ -60,7 +87,7 @@ struct __non_trivially_copyable_base { |
| 60 | }; | 87 | }; |
| 61 | 88 | ||
| 62 | template <class _T1, class _T2> | 89 | template <class _T1, class _T2> |
| 63 | struct _LIBCPP_TEMPLATE_VIS pair | 90 | struct pair |
| 64 | #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) | 91 | #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) |
| 65 | : private __non_trivially_copyable_base<_T1, _T2> | 92 | : private __non_trivially_copyable_base<_T1, _T2> |
| 66 | #endif | 93 | #endif |
| ... | @@ -75,6 +102,7 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -75,6 +102,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 75 | __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value, | 102 | __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value, |
| 76 | pair, | 103 | pair, |
| 77 | void>; | 104 | void>; |
| 105 | using __replaceable _LIBCPP_NODEBUG = __conditional_t<__is_replaceable_v<_T1> && __is_replaceable_v<_T2>, pair, void>; | ||
| 78 | 106 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default; | 107 | _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default; |
| 80 | _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default; | 108 | _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default; |
| ... | @@ -107,40 +135,16 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -107,40 +135,16 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 107 | return *this; | 135 | return *this; |
| 108 | } | 136 | } |
| 109 | #else | 137 | #else |
| 110 | struct _CheckArgs { | 138 | template <class _CheckArgsDep = __check_pair_construction<_T1, _T2>, |
| 111 | template <int&...> | 139 | __enable_if_t<_CheckArgsDep::__enable_default(), int> = 0> |
| 112 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { | 140 | explicit(!_CheckArgsDep::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept( |
| 113 | return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value; | ||
| 114 | } | ||
| 115 | |||
| 116 | template <int&...> | ||
| 117 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() { | ||
| 118 | return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value; | ||
| 119 | } | ||
| 120 | |||
| 121 | template <class _U1, class _U2> | ||
| 122 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible() { | ||
| 123 | return is_constructible<first_type, _U1>::value && is_constructible<second_type, _U2>::value; | ||
| 124 | } | ||
| 125 | |||
| 126 | template <class _U1, class _U2> | ||
| 127 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() { | ||
| 128 | return is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value; | ||
| 129 | } | ||
| 130 | }; | ||
| 131 | |||
| 132 | template <bool _MaybeEnable> | ||
| 133 | using _CheckArgsDep _LIBCPP_NODEBUG = __conditional_t<_MaybeEnable, _CheckArgs, void>; | ||
| 134 | |||
| 135 | template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0> | ||
| 136 | explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept( | ||
| 137 | is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value) | 141 | is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value) |
| 138 | : first(), second() {} | 142 | : first(), second() {} |
| 139 | 143 | ||
| 140 | template <bool _Dummy = true, | 144 | template <class _CheckArgsDep = __check_pair_construction<_T1, _T2>, |
| 141 | __enable_if_t<_CheckArgsDep<_Dummy>::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0> | 145 | __enable_if_t<_CheckArgsDep::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0> |
| 142 | _LIBCPP_HIDE_FROM_ABI | 146 | _LIBCPP_HIDE_FROM_ABI |
| 143 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep<_Dummy>::template __is_implicit<_T1 const&, _T2 const&>()) | 147 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep::template __is_implicit<_T1 const&, _T2 const&>()) |
| 144 | pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value && | 148 | pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value && |
| 145 | is_nothrow_copy_constructible<second_type>::value) | 149 | is_nothrow_copy_constructible<second_type>::value) |
| 146 | : first(__t1), second(__t2) {} | 150 | : first(__t1), second(__t2) {} |
| ... | @@ -153,62 +157,64 @@ struct _LIBCPP_TEMPLATE_VIS pair | ... | @@ -153,62 +157,64 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 153 | class _U1, | 157 | class _U1, |
| 154 | class _U2, | 158 | class _U2, |
| 155 | # endif | 159 | # endif |
| 156 | __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0 > | 160 | __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int> = 0 > |
| 157 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>()) | 161 | _LIBCPP_HIDE_FROM_ABI |
| 162 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>()) | ||
| 158 | pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value && | 163 | pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value && |
| 159 | is_nothrow_constructible<second_type, _U2>::value) | 164 | is_nothrow_constructible<second_type, _U2>::value) |
| 160 | : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) { | 165 | : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) { |
| 161 | } | 166 | } |
| 162 | 167 | ||
| 163 | # if _LIBCPP_STD_VER >= 23 | 168 | # if _LIBCPP_STD_VER >= 23 |
| 164 | template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1&, _U2&>(), int> = 0> | 169 | template <class _U1, |
| 165 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>()) | 170 | class _U2, |
| 171 | __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1&, _U2&>(), int> = 0> | ||
| 172 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1&, _U2&>()) | ||
| 166 | pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value && | 173 | pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value && |
| 167 | is_nothrow_constructible<second_type, _U2&>::value)) | 174 | is_nothrow_constructible<second_type, _U2&>::value)) |
| 168 | : first(__p.first), second(__p.second) {} | 175 | : first(__p.first), second(__p.second) {} |
| 169 | # endif | 176 | # endif |
| 170 | 177 | ||
| 171 | template <class _U1, | 178 | template < |
| 172 | class _U2, | 179 | class _U1, |
| 173 | __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1 const&, _U2 const&>(), int> = 0> | 180 | class _U2, |
| 174 | _LIBCPP_HIDE_FROM_ABI | 181 | __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1 const&, _U2 const&>(), |
| 175 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1 const&, _U2 const&>()) | 182 | int> = 0> |
| 183 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit( | ||
| 184 | !__check_pair_construction<_T1, _T2>::template __is_implicit<_U1 const&, _U2 const&>()) | ||
| 176 | pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value && | 185 | pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value && |
| 177 | is_nothrow_constructible<second_type, _U2 const&>::value) | 186 | is_nothrow_constructible<second_type, _U2 const&>::value) |
| 178 | : first(__p.first), second(__p.second) {} | 187 | : first(__p.first), second(__p.second) {} |
| 179 | 188 | ||
| 180 | template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0> | 189 | template <class _U1, |
| 181 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>()) | 190 | class _U2, |
| 191 | __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int> = 0> | ||
| 192 | _LIBCPP_HIDE_FROM_ABI | ||
| 193 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>()) | ||
| 182 | pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value && | 194 | pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value && |
| 183 | is_nothrow_constructible<second_type, _U2&&>::value) | 195 | is_nothrow_constructible<second_type, _U2&&>::value) |
| 184 | : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {} | 196 | : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {} |
| 185 | 197 | ||
| 186 | # if _LIBCPP_STD_VER >= 23 | 198 | # if _LIBCPP_STD_VER >= 23 |
| 187 | template <class _U1, | 199 | template < |
| 188 | class _U2, | 200 | class _U1, |
| 189 | __enable_if_t<_CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>(), int> = 0> | 201 | class _U2, |
| 190 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>()) | 202 | __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<const _U1&&, const _U2&&>(), |
| 203 | int> = 0> | ||
| 204 | _LIBCPP_HIDE_FROM_ABI constexpr explicit( | ||
| 205 | !__check_pair_construction<_T1, _T2>::template __is_implicit<const _U1&&, const _U2&&>()) | ||
| 191 | pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value && | 206 | pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value && |
| 192 | is_nothrow_constructible<second_type, const _U2&&>::value) | 207 | is_nothrow_constructible<second_type, const _U2&&>::value) |
| 193 | : first(std::move(__p.first)), second(std::move(__p.second)) {} | 208 | : first(std::move(__p.first)), second(std::move(__p.second)) {} |
| 194 | # endif | 209 | # endif |
| 195 | 210 | ||
| 196 | # if _LIBCPP_STD_VER >= 23 | 211 | # if _LIBCPP_STD_VER >= 23 |
| 197 | // TODO: Remove this workaround in LLVM 20. The bug got fixed in Clang 18. | ||
| 198 | // This is a workaround for http://llvm.org/PR60710. We should be able to remove it once Clang is fixed. | ||
| 199 | template <class _PairLike> | ||
| 200 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __pair_like_explicit_wknd() { | ||
| 201 | if constexpr (__pair_like_no_subrange<_PairLike>) { | ||
| 202 | return !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> || | ||
| 203 | !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>; | ||
| 204 | } | ||
| 205 | return false; | ||
| 206 | } | ||
| 207 | |||
| 208 | template <__pair_like_no_subrange _PairLike> | 212 | template <__pair_like_no_subrange _PairLike> |
| 209 | requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> && | 213 | requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> && |
| 210 | is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>) | 214 | is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>) |
| 211 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(__pair_like_explicit_wknd<_PairLike>()) pair(_PairLike&& __p) | 215 | _LIBCPP_HIDE_FROM_ABI constexpr explicit( |
| 216 | !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> || | ||
| 217 | !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>) pair(_PairLike&& __p) | ||
| 212 | : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {} | 218 | : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {} |
| 213 | # endif | 219 | # endif |
| 214 | 220 | ||
| ... | @@ -450,7 +456,14 @@ pair(_T1, _T2) -> pair<_T1, _T2>; | ... | @@ -450,7 +456,14 @@ pair(_T1, _T2) -> pair<_T1, _T2>; |
| 450 | 456 | ||
| 451 | template <class _T1, class _T2, class _U1, class _U2> | 457 | template <class _T1, class _T2, class _U1, class _U2> |
| 452 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | 458 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool |
| 453 | operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) { | 459 | operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) |
| 460 | #if _LIBCPP_STD_VER >= 26 | ||
| 461 | requires requires { | ||
| 462 | { __x.first == __y.first } -> __boolean_testable; | ||
| 463 | { __x.second == __y.second } -> __boolean_testable; | ||
| 464 | } | ||
| 465 | #endif | ||
| 466 | { | ||
| 454 | return __x.first == __y.first && __x.second == __y.second; | 467 | return __x.first == __y.first && __x.second == __y.second; |
| 455 | } | 468 | } |
| 456 | 469 | ||
| ... | @@ -506,13 +519,14 @@ template <class _T1, class _T2, class _U1, class _U2, template <class> class _TQ | ... | @@ -506,13 +519,14 @@ template <class _T1, class _T2, class _U1, class _U2, template <class> class _TQ |
| 506 | typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>; | 519 | typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>; |
| 507 | } | 520 | } |
| 508 | struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> { | 521 | struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> { |
| 509 | using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>; | 522 | using type _LIBCPP_NODEBUG = |
| 523 | pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>; | ||
| 510 | }; | 524 | }; |
| 511 | 525 | ||
| 512 | template <class _T1, class _T2, class _U1, class _U2> | 526 | template <class _T1, class _T2, class _U1, class _U2> |
| 513 | requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; } | 527 | requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; } |
| 514 | struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> { | 528 | struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> { |
| 515 | using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; | 529 | using type _LIBCPP_NODEBUG = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; |
| 516 | }; | 530 | }; |
| 517 | #endif // _LIBCPP_STD_VER >= 23 | 531 | #endif // _LIBCPP_STD_VER >= 23 |
| 518 | 532 | ||
| ... | @@ -538,20 +552,20 @@ make_pair(_T1&& __t1, _T2&& __t2) { | ... | @@ -538,20 +552,20 @@ make_pair(_T1&& __t1, _T2&& __t2) { |
| 538 | } | 552 | } |
| 539 | 553 | ||
| 540 | template <class _T1, class _T2> | 554 | template <class _T1, class _T2> |
| 541 | struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> > : public integral_constant<size_t, 2> {}; | 555 | struct tuple_size<pair<_T1, _T2> > : public integral_constant<size_t, 2> {}; |
| 542 | 556 | ||
| 543 | template <size_t _Ip, class _T1, class _T2> | 557 | template <size_t _Ip, class _T1, class _T2> |
| 544 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> > { | 558 | struct tuple_element<_Ip, pair<_T1, _T2> > { |
| 545 | static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>"); | 559 | static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>"); |
| 546 | }; | 560 | }; |
| 547 | 561 | ||
| 548 | template <class _T1, class _T2> | 562 | template <class _T1, class _T2> |
| 549 | struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> > { | 563 | struct tuple_element<0, pair<_T1, _T2> > { |
| 550 | using type _LIBCPP_NODEBUG = _T1; | 564 | using type _LIBCPP_NODEBUG = _T1; |
| 551 | }; | 565 | }; |
| 552 | 566 | ||
| 553 | template <class _T1, class _T2> | 567 | template <class _T1, class _T2> |
| 554 | struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> > { | 568 | struct tuple_element<1, pair<_T1, _T2> > { |
| 555 | using type _LIBCPP_NODEBUG = _T2; | 569 | using type _LIBCPP_NODEBUG = _T2; |
| 556 | }; | 570 | }; |
| 557 | 571 | ||
| ... | @@ -631,42 +645,42 @@ get(const pair<_T1, _T2>&& __p) _NOEXCEPT { | ... | @@ -631,42 +645,42 @@ get(const pair<_T1, _T2>&& __p) _NOEXCEPT { |
| 631 | #if _LIBCPP_STD_VER >= 14 | 645 | #if _LIBCPP_STD_VER >= 14 |
| 632 | template <class _T1, class _T2> | 646 | template <class _T1, class _T2> |
| 633 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT { | 647 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT { |
| 634 | return __get_pair<0>::get(__p); | 648 | return __p.first; |
| 635 | } | 649 | } |
| 636 | 650 | ||
| 637 | template <class _T1, class _T2> | 651 | template <class _T1, class _T2> |
| 638 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT { | 652 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT { |
| 639 | return __get_pair<0>::get(__p); | 653 | return __p.first; |
| 640 | } | 654 | } |
| 641 | 655 | ||
| 642 | template <class _T1, class _T2> | 656 | template <class _T1, class _T2> |
| 643 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { | 657 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { |
| 644 | return __get_pair<0>::get(std::move(__p)); | 658 | return std::forward<_T1&&>(__p.first); |
| 645 | } | 659 | } |
| 646 | 660 | ||
| 647 | template <class _T1, class _T2> | 661 | template <class _T1, class _T2> |
| 648 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT { | 662 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT { |
| 649 | return __get_pair<0>::get(std::move(__p)); | 663 | return std::forward<_T1 const&&>(__p.first); |
| 650 | } | 664 | } |
| 651 | 665 | ||
| 652 | template <class _T1, class _T2> | 666 | template <class _T2, class _T1> |
| 653 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T2, _T1>& __p) _NOEXCEPT { | 667 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT { |
| 654 | return __get_pair<1>::get(__p); | 668 | return __p.second; |
| 655 | } | 669 | } |
| 656 | 670 | ||
| 657 | template <class _T1, class _T2> | 671 | template <class _T2, class _T1> |
| 658 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T2, _T1> const& __p) _NOEXCEPT { | 672 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT { |
| 659 | return __get_pair<1>::get(__p); | 673 | return __p.second; |
| 660 | } | 674 | } |
| 661 | 675 | ||
| 662 | template <class _T1, class _T2> | 676 | template <class _T2, class _T1> |
| 663 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T2, _T1>&& __p) _NOEXCEPT { | 677 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { |
| 664 | return __get_pair<1>::get(std::move(__p)); | 678 | return std::forward<_T2&&>(__p.second); |
| 665 | } | 679 | } |
| 666 | 680 | ||
| 667 | template <class _T1, class _T2> | 681 | template <class _T2, class _T1> |
| 668 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T2, _T1> const&& __p) _NOEXCEPT { | 682 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT { |
| 669 | return __get_pair<1>::get(std::move(__p)); | 683 | return std::forward<_T2 const&&>(__p.second); |
| 670 | } | 684 | } |
| 671 | 685 | ||
| 672 | #endif // _LIBCPP_STD_VER >= 14 | 686 | #endif // _LIBCPP_STD_VER >= 14 |
lib/libcxx/include/__utility/piecewise_construct.h+1-1| ... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | ||
| 20 | struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { | 20 | struct piecewise_construct_t { |
| 21 | explicit piecewise_construct_t() = default; | 21 | explicit piecewise_construct_t() = default; |
| 22 | }; | 22 | }; |
| 23 | 23 |
lib/libcxx/include/__utility/scope_guard.h-1| ... | @@ -10,7 +10,6 @@ | ... | @@ -10,7 +10,6 @@ |
| 10 | #ifndef _LIBCPP___UTILITY_SCOPE_GUARD_H | 10 | #ifndef _LIBCPP___UTILITY_SCOPE_GUARD_H |
| 11 | #define _LIBCPP___UTILITY_SCOPE_GUARD_H | 11 | #define _LIBCPP___UTILITY_SCOPE_GUARD_H |
| 12 | 12 | ||
| 13 | #include <__assert> | ||
| 14 | #include <__config> | 13 | #include <__config> |
| 15 | #include <__utility/move.h> | 14 | #include <__utility/move.h> |
| 16 | 15 |
lib/libcxx/include/__utility/swap.h-1| ... | @@ -17,7 +17,6 @@ | ... | @@ -17,7 +17,6 @@ |
| 17 | #include <__type_traits/is_nothrow_assignable.h> | 17 | #include <__type_traits/is_nothrow_assignable.h> |
| 18 | #include <__type_traits/is_nothrow_constructible.h> | 18 | #include <__type_traits/is_nothrow_constructible.h> |
| 19 | #include <__type_traits/is_swappable.h> | 19 | #include <__type_traits/is_swappable.h> |
| 20 | #include <__utility/declval.h> | ||
| 21 | #include <__utility/move.h> | 20 | #include <__utility/move.h> |
| 22 | 21 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__utility/to_underlying.h+2-2| ... | @@ -21,8 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -21,8 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | ||
| 22 | #ifndef _LIBCPP_CXX03_LANG | 22 | #ifndef _LIBCPP_CXX03_LANG |
| 23 | template <class _Tp> | 23 | template <class _Tp> |
| 24 | _LIBCPP_HIDE_FROM_ABI constexpr typename underlying_type<_Tp>::type __to_underlying(_Tp __val) noexcept { | 24 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr __underlying_type_t<_Tp> __to_underlying(_Tp __val) noexcept { |
| 25 | return static_cast<typename underlying_type<_Tp>::type>(__val); | 25 | return static_cast<__underlying_type_t<_Tp>>(__val); |
| 26 | } | 26 | } |
| 27 | #endif // !_LIBCPP_CXX03_LANG | 27 | #endif // !_LIBCPP_CXX03_LANG |
| 28 | 28 |
lib/libcxx/include/__variant/monostate.h+7-5| ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 17 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | ||
| 26 | struct _LIBCPP_TEMPLATE_VIS monostate {}; | 26 | struct monostate {}; |
| 27 | 27 | ||
| 28 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; } | 28 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; } |
| 29 | 29 | ||
| ... | @@ -48,11 +48,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noe | ... | @@ -48,11 +48,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noe |
| 48 | # endif // _LIBCPP_STD_VER >= 20 | 48 | # endif // _LIBCPP_STD_VER >= 20 |
| 49 | 49 | ||
| 50 | template <> | 50 | template <> |
| 51 | struct _LIBCPP_TEMPLATE_VIS hash<monostate> { | 51 | struct hash<monostate> { |
| 52 | using argument_type = monostate; | 52 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 53 | using result_type = size_t; | 53 | using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = monostate; |
| 54 | using result_type _LIBCPP_DEPRECATED_IN_CXX17 = size_t; | ||
| 55 | # endif | ||
| 54 | 56 | ||
| 55 | inline _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type&) const _NOEXCEPT { | 57 | inline _LIBCPP_HIDE_FROM_ABI size_t operator()(const monostate&) const noexcept { |
| 56 | return 66740831; // return a fundamentally attractive random value. | 58 | return 66740831; // return a fundamentally attractive random value. |
| 57 | } | 59 | } |
| 58 | }; | 60 | }; |
lib/libcxx/include/__vector/container_traits.h+3-1| ... | @@ -31,7 +31,9 @@ struct __container_traits<vector<_Tp, _Allocator> > { | ... | @@ -31,7 +31,9 @@ struct __container_traits<vector<_Tp, _Allocator> > { |
| 31 | // there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-Cpp17CopyInsertable T, | 31 | // there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-Cpp17CopyInsertable T, |
| 32 | // the effects are unspecified. | 32 | // the effects are unspecified. |
| 33 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | 33 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = |
| 34 | _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value; | 34 | is_nothrow_move_constructible<_Tp>::value || __is_cpp17_copy_insertable_v<_Allocator>; |
| 35 | |||
| 36 | static _LIBCPP_CONSTEXPR const bool __reservable = true; | ||
| 35 | }; | 37 | }; |
| 36 | 38 | ||
| 37 | _LIBCPP_END_NAMESPACE_STD | 39 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__vector/vector.h+66-60| ... | @@ -55,9 +55,11 @@ | ... | @@ -55,9 +55,11 @@ |
| 55 | #include <__type_traits/is_nothrow_assignable.h> | 55 | #include <__type_traits/is_nothrow_assignable.h> |
| 56 | #include <__type_traits/is_nothrow_constructible.h> | 56 | #include <__type_traits/is_nothrow_constructible.h> |
| 57 | #include <__type_traits/is_pointer.h> | 57 | #include <__type_traits/is_pointer.h> |
| 58 | #include <__type_traits/is_replaceable.h> | ||
| 58 | #include <__type_traits/is_same.h> | 59 | #include <__type_traits/is_same.h> |
| 59 | #include <__type_traits/is_trivially_relocatable.h> | 60 | #include <__type_traits/is_trivially_relocatable.h> |
| 60 | #include <__type_traits/type_identity.h> | 61 | #include <__type_traits/type_identity.h> |
| 62 | #include <__utility/declval.h> | ||
| 61 | #include <__utility/exception_guard.h> | 63 | #include <__utility/exception_guard.h> |
| 62 | #include <__utility/forward.h> | 64 | #include <__utility/forward.h> |
| 63 | #include <__utility/is_pointer_in_range.h> | 65 | #include <__utility/is_pointer_in_range.h> |
| ... | @@ -83,36 +85,33 @@ _LIBCPP_PUSH_MACROS | ... | @@ -83,36 +85,33 @@ _LIBCPP_PUSH_MACROS |
| 83 | _LIBCPP_BEGIN_NAMESPACE_STD | 85 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 84 | 86 | ||
| 85 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> | 87 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> |
| 86 | class _LIBCPP_TEMPLATE_VIS vector { | 88 | class vector { |
| 87 | private: | ||
| 88 | typedef allocator<_Tp> __default_allocator_type; | ||
| 89 | |||
| 90 | public: | 89 | public: |
| 91 | // | 90 | // |
| 92 | // Types | 91 | // Types |
| 93 | // | 92 | // |
| 94 | typedef vector __self; | 93 | using __self _LIBCPP_NODEBUG = vector; |
| 95 | typedef _Tp value_type; | 94 | using value_type = _Tp; |
| 96 | typedef _Allocator allocator_type; | 95 | using allocator_type = _Allocator; |
| 97 | typedef allocator_traits<allocator_type> __alloc_traits; | 96 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; |
| 98 | typedef value_type& reference; | 97 | using reference = value_type&; |
| 99 | typedef const value_type& const_reference; | 98 | using const_reference = const value_type&; |
| 100 | typedef typename __alloc_traits::size_type size_type; | 99 | using size_type = typename __alloc_traits::size_type; |
| 101 | typedef typename __alloc_traits::difference_type difference_type; | 100 | using difference_type = typename __alloc_traits::difference_type; |
| 102 | typedef typename __alloc_traits::pointer pointer; | 101 | using pointer = typename __alloc_traits::pointer; |
| 103 | typedef typename __alloc_traits::const_pointer const_pointer; | 102 | using const_pointer = typename __alloc_traits::const_pointer; |
| 104 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | 103 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR |
| 105 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's | 104 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's |
| 106 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is | 105 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is |
| 107 | // considered contiguous. | 106 | // considered contiguous. |
| 108 | typedef __bounded_iter<__wrap_iter<pointer> > iterator; | 107 | using iterator = __bounded_iter<__wrap_iter<pointer> >; |
| 109 | typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator; | 108 | using const_iterator = __bounded_iter<__wrap_iter<const_pointer> >; |
| 110 | #else | 109 | #else |
| 111 | typedef __wrap_iter<pointer> iterator; | 110 | using iterator = __wrap_iter<pointer>; |
| 112 | typedef __wrap_iter<const_pointer> const_iterator; | 111 | using const_iterator = __wrap_iter<const_pointer>; |
| 113 | #endif | 112 | #endif |
| 114 | typedef std::reverse_iterator<iterator> reverse_iterator; | 113 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 115 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 114 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| 116 | 115 | ||
| 117 | // A vector containers the following members which may be trivially relocatable: | 116 | // A vector containers the following members which may be trivially relocatable: |
| 118 | // - pointer: may be trivially relocatable, so it's checked | 117 | // - pointer: may be trivially relocatable, so it's checked |
| ... | @@ -122,6 +121,10 @@ public: | ... | @@ -122,6 +121,10 @@ public: |
| 122 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | 121 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 123 | vector, | 122 | vector, |
| 124 | void>; | 123 | void>; |
| 124 | using __replaceable _LIBCPP_NODEBUG = | ||
| 125 | __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value, | ||
| 126 | vector, | ||
| 127 | void>; | ||
| 125 | 128 | ||
| 126 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | 129 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 127 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | 130 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| ... | @@ -463,6 +466,15 @@ public: | ... | @@ -463,6 +466,15 @@ public: |
| 463 | emplace_back(_Args&&... __args); | 466 | emplace_back(_Args&&... __args); |
| 464 | #endif | 467 | #endif |
| 465 | 468 | ||
| 469 | template <class... _Args> | ||
| 470 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __emplace_back_assume_capacity(_Args&&... __args) { | ||
| 471 | _LIBCPP_ASSERT_INTERNAL( | ||
| 472 | size() < capacity(), "We assume that we have enough space to insert an element at the end of the vector"); | ||
| 473 | _ConstructTransaction __tx(*this, 1); | ||
| 474 | __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...); | ||
| 475 | ++__tx.__pos_; | ||
| 476 | } | ||
| 477 | |||
| 466 | #if _LIBCPP_STD_VER >= 23 | 478 | #if _LIBCPP_STD_VER >= 23 |
| 467 | template <_ContainerCompatibleRange<_Tp> _Range> | 479 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 468 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { | 480 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { |
| ... | @@ -558,7 +570,7 @@ private: | ... | @@ -558,7 +570,7 @@ private: |
| 558 | // Postcondition: size() == 0 | 570 | // Postcondition: size() == 0 |
| 559 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { | 571 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { |
| 560 | if (__n > max_size()) | 572 | if (__n > max_size()) |
| 561 | __throw_length_error(); | 573 | this->__throw_length_error(); |
| 562 | auto __allocation = std::__allocate_at_least(this->__alloc_, __n); | 574 | auto __allocation = std::__allocate_at_least(this->__alloc_, __n); |
| 563 | __begin_ = __allocation.ptr; | 575 | __begin_ = __allocation.ptr; |
| 564 | __end_ = __allocation.ptr; | 576 | __end_ = __allocation.ptr; |
| ... | @@ -605,6 +617,30 @@ private: | ... | @@ -605,6 +617,30 @@ private: |
| 605 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 617 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 606 | __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n); | 618 | __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n); |
| 607 | 619 | ||
| 620 | template <class _Iterator, | ||
| 621 | __enable_if_t<!is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0> | ||
| 622 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 623 | __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) { | ||
| 624 | for (pointer __end_position = __position + __n; __position != __end_position; ++__position, (void)++__first) { | ||
| 625 | __temp_value<value_type, _Allocator> __tmp(this->__alloc_, *__first); | ||
| 626 | *__position = std::move(__tmp.get()); | ||
| 627 | } | ||
| 628 | } | ||
| 629 | |||
| 630 | template <class _Iterator, | ||
| 631 | __enable_if_t<is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0> | ||
| 632 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | ||
| 633 | __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) { | ||
| 634 | #if _LIBCPP_STD_VER >= 23 | ||
| 635 | if constexpr (!forward_iterator<_Iterator>) { // Handles input-only sized ranges for insert_range | ||
| 636 | ranges::copy_n(std::move(__first), __n, __position); | ||
| 637 | } else | ||
| 638 | #endif | ||
| 639 | { | ||
| 640 | std::copy_n(__first, __n, __position); | ||
| 641 | } | ||
| 642 | } | ||
| 643 | |||
| 608 | template <class _InputIterator, class _Sentinel> | 644 | template <class _InputIterator, class _Sentinel> |
| 609 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | 645 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator |
| 610 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); | 646 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); |
| ... | @@ -685,47 +721,32 @@ private: | ... | @@ -685,47 +721,32 @@ private: |
| 685 | } | 721 | } |
| 686 | 722 | ||
| 687 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { | 723 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| 688 | (void)__current_size; | ||
| 689 | #if _LIBCPP_HAS_ASAN | ||
| 690 | __annotate_contiguous_container(data() + capacity(), data() + __current_size); | 724 | __annotate_contiguous_container(data() + capacity(), data() + __current_size); |
| 691 | #endif | ||
| 692 | } | 725 | } |
| 693 | 726 | ||
| 694 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { | 727 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { |
| 695 | #if _LIBCPP_HAS_ASAN | ||
| 696 | __annotate_contiguous_container(data() + size(), data() + capacity()); | 728 | __annotate_contiguous_container(data() + size(), data() + capacity()); |
| 697 | #endif | ||
| 698 | } | 729 | } |
| 699 | 730 | ||
| 700 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT { | 731 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT { |
| 701 | (void)__n; | ||
| 702 | #if _LIBCPP_HAS_ASAN | ||
| 703 | __annotate_contiguous_container(data() + size(), data() + size() + __n); | 732 | __annotate_contiguous_container(data() + size(), data() + size() + __n); |
| 704 | #endif | ||
| 705 | } | 733 | } |
| 706 | 734 | ||
| 707 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT { | 735 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT { |
| 708 | (void)__old_size; | ||
| 709 | #if _LIBCPP_HAS_ASAN | ||
| 710 | __annotate_contiguous_container(data() + __old_size, data() + size()); | 736 | __annotate_contiguous_container(data() + __old_size, data() + size()); |
| 711 | #endif | ||
| 712 | } | 737 | } |
| 713 | 738 | ||
| 714 | struct _ConstructTransaction { | 739 | struct _ConstructTransaction { |
| 715 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n) | 740 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n) |
| 716 | : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { | 741 | : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { |
| 717 | #if _LIBCPP_HAS_ASAN | ||
| 718 | __v_.__annotate_increase(__n); | 742 | __v_.__annotate_increase(__n); |
| 719 | #endif | ||
| 720 | } | 743 | } |
| 721 | 744 | ||
| 722 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { | 745 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { |
| 723 | __v_.__end_ = __pos_; | 746 | __v_.__end_ = __pos_; |
| 724 | #if _LIBCPP_HAS_ASAN | ||
| 725 | if (__pos_ != __new_end_) { | 747 | if (__pos_ != __new_end_) { |
| 726 | __v_.__annotate_shrink(__new_end_ - __v_.__begin_); | 748 | __v_.__annotate_shrink(__new_end_ - __v_.__begin_); |
| 727 | } | 749 | } |
| 728 | #endif | ||
| 729 | } | 750 | } |
| 730 | 751 | ||
| 731 | vector& __v_; | 752 | vector& __v_; |
| ... | @@ -736,13 +757,6 @@ private: | ... | @@ -736,13 +757,6 @@ private: |
| 736 | _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; | 757 | _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; |
| 737 | }; | 758 | }; |
| 738 | 759 | ||
| 739 | template <class... _Args> | ||
| 740 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) { | ||
| 741 | _ConstructTransaction __tx(*this, 1); | ||
| 742 | __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...); | ||
| 743 | ++__tx.__pos_; | ||
| 744 | } | ||
| 745 | |||
| 746 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { | 760 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { |
| 747 | pointer __soon_to_be_end = this->__end_; | 761 | pointer __soon_to_be_end = this->__end_; |
| 748 | while (__new_last != __soon_to_be_end) | 762 | while (__new_last != __soon_to_be_end) |
| ... | @@ -1130,7 +1144,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline | ... | @@ -1130,7 +1144,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline |
| 1130 | vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { | 1144 | vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { |
| 1131 | pointer __end = this->__end_; | 1145 | pointer __end = this->__end_; |
| 1132 | if (__end < this->__cap_) { | 1146 | if (__end < this->__cap_) { |
| 1133 | __construct_one_at_end(std::forward<_Args>(__args)...); | 1147 | __emplace_back_assume_capacity(std::forward<_Args>(__args)...); |
| 1134 | ++__end; | 1148 | ++__end; |
| 1135 | } else { | 1149 | } else { |
| 1136 | __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); | 1150 | __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); |
| ... | @@ -1184,7 +1198,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) | ... | @@ -1184,7 +1198,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) |
| 1184 | pointer __p = this->__begin_ + (__position - begin()); | 1198 | pointer __p = this->__begin_ + (__position - begin()); |
| 1185 | if (this->__end_ < this->__cap_) { | 1199 | if (this->__end_ < this->__cap_) { |
| 1186 | if (__p == this->__end_) { | 1200 | if (__p == this->__end_) { |
| 1187 | __construct_one_at_end(__x); | 1201 | __emplace_back_assume_capacity(__x); |
| 1188 | } else { | 1202 | } else { |
| 1189 | __move_range(__p, this->__end_, __p + 1); | 1203 | __move_range(__p, this->__end_, __p + 1); |
| 1190 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | 1204 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); |
| ... | @@ -1206,7 +1220,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { | ... | @@ -1206,7 +1220,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { |
| 1206 | pointer __p = this->__begin_ + (__position - begin()); | 1220 | pointer __p = this->__begin_ + (__position - begin()); |
| 1207 | if (this->__end_ < this->__cap_) { | 1221 | if (this->__end_ < this->__cap_) { |
| 1208 | if (__p == this->__end_) { | 1222 | if (__p == this->__end_) { |
| 1209 | __construct_one_at_end(std::move(__x)); | 1223 | __emplace_back_assume_capacity(std::move(__x)); |
| 1210 | } else { | 1224 | } else { |
| 1211 | __move_range(__p, this->__end_, __p + 1); | 1225 | __move_range(__p, this->__end_, __p + 1); |
| 1212 | *__p = std::move(__x); | 1226 | *__p = std::move(__x); |
| ... | @@ -1226,7 +1240,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { | ... | @@ -1226,7 +1240,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { |
| 1226 | pointer __p = this->__begin_ + (__position - begin()); | 1240 | pointer __p = this->__begin_ + (__position - begin()); |
| 1227 | if (this->__end_ < this->__cap_) { | 1241 | if (this->__end_ < this->__cap_) { |
| 1228 | if (__p == this->__end_) { | 1242 | if (__p == this->__end_) { |
| 1229 | __construct_one_at_end(std::forward<_Args>(__args)...); | 1243 | __emplace_back_assume_capacity(std::forward<_Args>(__args)...); |
| 1230 | } else { | 1244 | } else { |
| 1231 | __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...); | 1245 | __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...); |
| 1232 | __move_range(__p, this->__end_, __p + 1); | 1246 | __move_range(__p, this->__end_, __p + 1); |
| ... | @@ -1245,8 +1259,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | ... | @@ -1245,8 +1259,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator |
| 1245 | vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { | 1259 | vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { |
| 1246 | pointer __p = this->__begin_ + (__position - begin()); | 1260 | pointer __p = this->__begin_ + (__position - begin()); |
| 1247 | if (__n > 0) { | 1261 | if (__n > 0) { |
| 1248 | // We can't compare unrelated pointers inside constant expressions | 1262 | if (__n <= static_cast<size_type>(this->__cap_ - this->__end_)) { |
| 1249 | if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__cap_ - this->__end_)) { | ||
| 1250 | size_type __old_n = __n; | 1263 | size_type __old_n = __n; |
| 1251 | pointer __old_last = this->__end_; | 1264 | pointer __old_last = this->__end_; |
| 1252 | if (__n > static_cast<size_type>(this->__end_ - __p)) { | 1265 | if (__n > static_cast<size_type>(this->__end_ - __p)) { |
| ... | @@ -1257,7 +1270,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_ | ... | @@ -1257,7 +1270,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_ |
| 1257 | if (__n > 0) { | 1270 | if (__n > 0) { |
| 1258 | __move_range(__p, __old_last, __p + __old_n); | 1271 | __move_range(__p, __old_last, __p + __old_n); |
| 1259 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | 1272 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); |
| 1260 | if (__p <= __xr && __xr < this->__end_) | 1273 | if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x))) |
| 1261 | __xr += __old_n; | 1274 | __xr += __old_n; |
| 1262 | std::fill_n(__p, __n, *__xr); | 1275 | std::fill_n(__p, __n, *__xr); |
| 1263 | } | 1276 | } |
| ... | @@ -1278,7 +1291,7 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu | ... | @@ -1278,7 +1291,7 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu |
| 1278 | pointer __p = this->__begin_ + __off; | 1291 | pointer __p = this->__begin_ + __off; |
| 1279 | pointer __old_last = this->__end_; | 1292 | pointer __old_last = this->__end_; |
| 1280 | for (; this->__end_ != this->__cap_ && __first != __last; ++__first) | 1293 | for (; this->__end_ != this->__cap_ && __first != __last; ++__first) |
| 1281 | __construct_one_at_end(*__first); | 1294 | __emplace_back_assume_capacity(*__first); |
| 1282 | 1295 | ||
| 1283 | if (__first == __last) | 1296 | if (__first == __last) |
| 1284 | (void)std::rotate(__p, __old_last, this->__end_); | 1297 | (void)std::rotate(__p, __old_last, this->__end_); |
| ... | @@ -1325,19 +1338,12 @@ vector<_Tp, _Allocator>::__insert_with_size( | ... | @@ -1325,19 +1338,12 @@ vector<_Tp, _Allocator>::__insert_with_size( |
| 1325 | __construct_at_end(__m, __last, __n - __dx); | 1338 | __construct_at_end(__m, __last, __n - __dx); |
| 1326 | if (__dx > 0) { | 1339 | if (__dx > 0) { |
| 1327 | __move_range(__p, __old_last, __p + __n); | 1340 | __move_range(__p, __old_last, __p + __n); |
| 1328 | std::copy(__first, __m, __p); | 1341 | __insert_assign_n_unchecked(__first, __dx, __p); |
| 1329 | } | 1342 | } |
| 1330 | } | 1343 | } |
| 1331 | } else { | 1344 | } else { |
| 1332 | __move_range(__p, __old_last, __p + __n); | 1345 | __move_range(__p, __old_last, __p + __n); |
| 1333 | #if _LIBCPP_STD_VER >= 23 | 1346 | __insert_assign_n_unchecked(std::move(__first), __n, __p); |
| 1334 | if constexpr (!forward_iterator<_Iterator>) { | ||
| 1335 | ranges::copy_n(std::move(__first), __n, __p); | ||
| 1336 | } else | ||
| 1337 | #endif | ||
| 1338 | { | ||
| 1339 | std::copy_n(__first, __n, __p); | ||
| 1340 | } | ||
| 1341 | } | 1347 | } |
| 1342 | } else { | 1348 | } else { |
| 1343 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); | 1349 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); |
lib/libcxx/include/__vector/vector_bool.h+42-51| ... | @@ -10,14 +10,16 @@ | ... | @@ -10,14 +10,16 @@ |
| 10 | #define _LIBCPP___VECTOR_VECTOR_BOOL_H | 10 | #define _LIBCPP___VECTOR_VECTOR_BOOL_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/copy.h> | 12 | #include <__algorithm/copy.h> |
| 13 | #include <__algorithm/copy_backward.h> | ||
| 13 | #include <__algorithm/fill_n.h> | 14 | #include <__algorithm/fill_n.h> |
| 14 | #include <__algorithm/iterator_operations.h> | 15 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/max.h> | 16 | #include <__algorithm/max.h> |
| 17 | #include <__algorithm/rotate.h> | ||
| 16 | #include <__assert> | 18 | #include <__assert> |
| 17 | #include <__bit_reference> | 19 | #include <__bit_reference> |
| 18 | #include <__config> | 20 | #include <__config> |
| 19 | #include <__functional/unary_function.h> | 21 | #include <__functional/unary_function.h> |
| 20 | #include <__fwd/bit_reference.h> | 22 | #include <__fwd/bit_reference.h> // TODO: This is a workaround for https://github.com/llvm/llvm-project/issues/131814 |
| 21 | #include <__fwd/functional.h> | 23 | #include <__fwd/functional.h> |
| 22 | #include <__fwd/vector.h> | 24 | #include <__fwd/vector.h> |
| 23 | #include <__iterator/distance.h> | 25 | #include <__iterator/distance.h> |
| ... | @@ -73,38 +75,38 @@ struct __has_storage_type<vector<bool, _Allocator> > { | ... | @@ -73,38 +75,38 @@ struct __has_storage_type<vector<bool, _Allocator> > { |
| 73 | }; | 75 | }; |
| 74 | 76 | ||
| 75 | template <class _Allocator> | 77 | template <class _Allocator> |
| 76 | class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> { | 78 | class vector<bool, _Allocator> { |
| 77 | public: | 79 | public: |
| 78 | typedef vector __self; | 80 | using __self _LIBCPP_NODEBUG = vector; |
| 79 | typedef bool value_type; | 81 | using value_type = bool; |
| 80 | typedef _Allocator allocator_type; | 82 | using allocator_type = _Allocator; |
| 81 | typedef allocator_traits<allocator_type> __alloc_traits; | 83 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; |
| 82 | typedef typename __alloc_traits::size_type size_type; | 84 | using size_type = typename __alloc_traits::size_type; |
| 83 | typedef typename __alloc_traits::difference_type difference_type; | 85 | using difference_type = typename __alloc_traits::difference_type; |
| 84 | typedef size_type __storage_type; | 86 | using __storage_type _LIBCPP_NODEBUG = size_type; |
| 85 | typedef __bit_iterator<vector, false> pointer; | 87 | using pointer = __bit_iterator<vector, false>; |
| 86 | typedef __bit_iterator<vector, true> const_pointer; | 88 | using const_pointer = __bit_iterator<vector, true>; |
| 87 | typedef pointer iterator; | 89 | using iterator = pointer; |
| 88 | typedef const_pointer const_iterator; | 90 | using const_iterator = const_pointer; |
| 89 | typedef std::reverse_iterator<iterator> reverse_iterator; | 91 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 90 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 92 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| 91 | 93 | ||
| 92 | private: | 94 | private: |
| 93 | typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator; | 95 | using __storage_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, __storage_type>; |
| 94 | typedef allocator_traits<__storage_allocator> __storage_traits; | 96 | using __storage_traits _LIBCPP_NODEBUG = allocator_traits<__storage_allocator>; |
| 95 | typedef typename __storage_traits::pointer __storage_pointer; | 97 | using __storage_pointer _LIBCPP_NODEBUG = typename __storage_traits::pointer; |
| 96 | typedef typename __storage_traits::const_pointer __const_storage_pointer; | 98 | using __const_storage_pointer _LIBCPP_NODEBUG = typename __storage_traits::const_pointer; |
| 97 | 99 | ||
| 98 | __storage_pointer __begin_; | 100 | __storage_pointer __begin_; |
| 99 | size_type __size_; | 101 | size_type __size_; |
| 100 | _LIBCPP_COMPRESSED_PAIR(size_type, __cap_, __storage_allocator, __alloc_); | 102 | _LIBCPP_COMPRESSED_PAIR(size_type, __cap_, __storage_allocator, __alloc_); |
| 101 | 103 | ||
| 102 | public: | 104 | public: |
| 103 | typedef __bit_reference<vector> reference; | 105 | using reference = __bit_reference<vector>; |
| 104 | #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | 106 | #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL |
| 105 | using const_reference = bool; | 107 | using const_reference = bool; |
| 106 | #else | 108 | #else |
| 107 | typedef __bit_const_reference<vector> const_reference; | 109 | using const_reference = __bit_const_reference<vector>; |
| 108 | #endif | 110 | #endif |
| 109 | 111 | ||
| 110 | private: | 112 | private: |
| ... | @@ -445,7 +447,7 @@ private: | ... | @@ -445,7 +447,7 @@ private: |
| 445 | // Postcondition: size() == 0 | 447 | // Postcondition: size() == 0 |
| 446 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) { | 448 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) { |
| 447 | if (__n > max_size()) | 449 | if (__n > max_size()) |
| 448 | __throw_length_error(); | 450 | this->__throw_length_error(); |
| 449 | auto __allocation = std::__allocate_at_least(__alloc_, __external_cap_to_internal(__n)); | 451 | auto __allocation = std::__allocate_at_least(__alloc_, __external_cap_to_internal(__n)); |
| 450 | __begin_ = __allocation.ptr; | 452 | __begin_ = __allocation.ptr; |
| 451 | __size_ = 0; | 453 | __size_ = 0; |
| ... | @@ -510,14 +512,14 @@ private: | ... | @@ -510,14 +512,14 @@ private: |
| 510 | 512 | ||
| 511 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {} | 513 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {} |
| 512 | 514 | ||
| 513 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT; | 515 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT; |
| 514 | 516 | ||
| 515 | friend class __bit_reference<vector>; | 517 | friend class __bit_reference<vector>; |
| 516 | friend class __bit_const_reference<vector>; | 518 | friend class __bit_const_reference<vector>; |
| 517 | friend class __bit_iterator<vector, false>; | 519 | friend class __bit_iterator<vector, false>; |
| 518 | friend class __bit_iterator<vector, true>; | 520 | friend class __bit_iterator<vector, true>; |
| 519 | friend struct __bit_array<vector>; | 521 | friend struct __bit_array<vector>; |
| 520 | friend struct _LIBCPP_TEMPLATE_VIS hash<vector>; | 522 | friend struct hash<vector>; |
| 521 | }; | 523 | }; |
| 522 | 524 | ||
| 523 | template <class _Allocator> | 525 | template <class _Allocator> |
| ... | @@ -533,10 +535,8 @@ template <class _Allocator> | ... | @@ -533,10 +535,8 @@ template <class _Allocator> |
| 533 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type | 535 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type |
| 534 | vector<bool, _Allocator>::max_size() const _NOEXCEPT { | 536 | vector<bool, _Allocator>::max_size() const _NOEXCEPT { |
| 535 | size_type __amax = __storage_traits::max_size(__alloc_); | 537 | size_type __amax = __storage_traits::max_size(__alloc_); |
| 536 | size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always | 538 | size_type __nmax = numeric_limits<difference_type>::max(); |
| 537 | if (__nmax / __bits_per_word <= __amax) | 539 | return __nmax / __bits_per_word <= __amax ? __nmax : __internal_cap_to_external(__amax); |
| 538 | return __nmax; | ||
| 539 | return __internal_cap_to_external(__amax); | ||
| 540 | } | 540 | } |
| 541 | 541 | ||
| 542 | // Precondition: __new_size > capacity() | 542 | // Precondition: __new_size > capacity() |
| ... | @@ -549,40 +549,33 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const { | ... | @@ -549,40 +549,33 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const { |
| 549 | const size_type __cap = capacity(); | 549 | const size_type __cap = capacity(); |
| 550 | if (__cap >= __ms / 2) | 550 | if (__cap >= __ms / 2) |
| 551 | return __ms; | 551 | return __ms; |
| 552 | return std::max(2 * __cap, __align_it(__new_size)); | 552 | return std::max<size_type>(2 * __cap, __align_it(__new_size)); |
| 553 | } | 553 | } |
| 554 | 554 | ||
| 555 | // Default constructs __n objects starting at __end_ | 555 | // Default constructs __n objects starting at __end_ |
| 556 | // Precondition: __n > 0 | ||
| 557 | // Precondition: size() + __n <= capacity() | 556 | // Precondition: size() + __n <= capacity() |
| 558 | // Postcondition: size() == size() + __n | 557 | // Postcondition: size() == size() + __n |
| 559 | template <class _Allocator> | 558 | template <class _Allocator> |
| 560 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 559 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 561 | vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) { | 560 | vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) { |
| 562 | size_type __old_size = this->__size_; | 561 | _LIBCPP_ASSERT_INTERNAL( |
| 562 | capacity() >= size() + __n, "vector<bool>::__construct_at_end called with insufficient capacity"); | ||
| 563 | std::fill_n(end(), __n, __x); | ||
| 563 | this->__size_ += __n; | 564 | this->__size_ += __n; |
| 564 | if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) { | 565 | if (end().__ctz_ != 0) // Ensure uninitialized leading bits in the last word are set to zero |
| 565 | if (this->__size_ <= __bits_per_word) | 566 | std::fill_n(end(), __bits_per_word - end().__ctz_, 0); |
| 566 | this->__begin_[0] = __storage_type(0); | ||
| 567 | else | ||
| 568 | this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | ||
| 569 | } | ||
| 570 | std::fill_n(__make_iter(__old_size), __n, __x); | ||
| 571 | } | 567 | } |
| 572 | 568 | ||
| 573 | template <class _Allocator> | 569 | template <class _Allocator> |
| 574 | template <class _InputIterator, class _Sentinel> | 570 | template <class _InputIterator, class _Sentinel> |
| 575 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 571 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 576 | vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) { | 572 | vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) { |
| 577 | size_type __old_size = this->__size_; | 573 | _LIBCPP_ASSERT_INTERNAL( |
| 574 | capacity() >= size() + __n, "vector<bool>::__construct_at_end called with insufficient capacity"); | ||
| 575 | std::__copy(std::move(__first), std::move(__last), end()); | ||
| 578 | this->__size_ += __n; | 576 | this->__size_ += __n; |
| 579 | if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) { | 577 | if (end().__ctz_ != 0) // Ensure uninitialized leading bits in the last word are set to zero |
| 580 | if (this->__size_ <= __bits_per_word) | 578 | std::fill_n(end(), __bits_per_word - end().__ctz_, 0); |
| 581 | this->__begin_[0] = __storage_type(0); | ||
| 582 | else | ||
| 583 | this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | ||
| 584 | } | ||
| 585 | std::__copy(std::move(__first), std::move(__last), __make_iter(__old_size)); | ||
| 586 | } | 579 | } |
| 587 | 580 | ||
| 588 | template <class _Allocator> | 581 | template <class _Allocator> |
| ... | @@ -1100,7 +1093,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() cons | ... | @@ -1100,7 +1093,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() cons |
| 1100 | } | 1093 | } |
| 1101 | 1094 | ||
| 1102 | template <class _Allocator> | 1095 | template <class _Allocator> |
| 1103 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT { | 1096 | size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT { |
| 1104 | size_t __h = 0; | 1097 | size_t __h = 0; |
| 1105 | // do middle whole words | 1098 | // do middle whole words |
| 1106 | size_type __n = __size_; | 1099 | size_type __n = __size_; |
| ... | @@ -1116,10 +1109,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() con | ... | @@ -1116,10 +1109,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() con |
| 1116 | } | 1109 | } |
| 1117 | 1110 | ||
| 1118 | template <class _Allocator> | 1111 | template <class _Allocator> |
| 1119 | struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > | 1112 | struct hash<vector<bool, _Allocator> > : public __unary_function<vector<bool, _Allocator>, size_t> { |
| 1120 | : public __unary_function<vector<bool, _Allocator>, size_t> { | 1113 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT { |
| 1121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t | ||
| 1122 | operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT { | ||
| 1123 | return __vec.__hash_code(); | 1114 | return __vec.__hash_code(); |
| 1124 | } | 1115 | } |
| 1125 | }; | 1116 | }; |
lib/libcxx/include/__vector/vector_bool_formatter.h+1-1| ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | template <class _Tp, class _CharT> | 26 | template <class _Tp, class _CharT> |
| 27 | // Since is-vector-bool-reference is only used once it's inlined here. | 27 | // Since is-vector-bool-reference is only used once it's inlined here. |
| 28 | requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>> | 28 | requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>> |
| 29 | struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> { | 29 | struct formatter<_Tp, _CharT> { |
| 30 | private: | 30 | private: |
| 31 | formatter<bool, _CharT> __underlying_; | 31 | formatter<bool, _CharT> __underlying_; |
| 32 | 32 |
lib/libcxx/include/__verbose_abort+1-7| ... | @@ -18,16 +18,10 @@ | ... | @@ -18,16 +18,10 @@ |
| 18 | 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | ||
| 21 | #if defined(_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT) | ||
| 22 | # define _LIBCPP_VERBOSE_ABORT_NOEXCEPT | ||
| 23 | #else | ||
| 24 | # define _LIBCPP_VERBOSE_ABORT_NOEXCEPT _NOEXCEPT | ||
| 25 | #endif | ||
| 26 | |||
| 27 | // This function should never be called directly from the code -- it should only be called through | 21 | // This function should never be called directly from the code -- it should only be called through |
| 28 | // the _LIBCPP_VERBOSE_ABORT macro. | 22 | // the _LIBCPP_VERBOSE_ABORT macro. |
| 29 | [[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT( | 23 | [[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT( |
| 30 | __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT; | 24 | __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT; |
| 31 | 25 | ||
| 32 | // _LIBCPP_VERBOSE_ABORT(format, args...) | 26 | // _LIBCPP_VERBOSE_ABORT(format, args...) |
| 33 | // | 27 | // |
lib/libcxx/include/__verbose_trap created+36| ... | @@ -0,0 +1,36 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP___VERBOSE_TRAP | ||
| 11 | #define _LIBCPP___VERBOSE_TRAP | ||
| 12 | |||
| 13 | #include <__config> | ||
| 14 | |||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 16 | # pragma GCC system_header | ||
| 17 | #endif | ||
| 18 | |||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 20 | |||
| 21 | #if __has_builtin(__builtin_verbose_trap) | ||
| 22 | // AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream | ||
| 23 | // version before upstream Clang actually got the builtin. | ||
| 24 | // TODO: Remove once AppleClang supports the two-arguments version of the builtin. | ||
| 25 | # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700 | ||
| 26 | # define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap(message) | ||
| 27 | # else | ||
| 28 | # define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap("libc++", message) | ||
| 29 | # endif | ||
| 30 | #else | ||
| 31 | # define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap()) | ||
| 32 | #endif | ||
| 33 | |||
| 34 | _LIBCPP_END_NAMESPACE_STD | ||
| 35 | |||
| 36 | #endif // _LIBCPP___VERBOSE_TRAP | ||
lib/libcxx/include/algorithm+153-144| ... | @@ -45,6 +45,9 @@ namespace ranges { | ... | @@ -45,6 +45,9 @@ namespace ranges { |
| 45 | template <class I, class T> | 45 | template <class I, class T> |
| 46 | struct in_value_result; // since C++23 | 46 | struct in_value_result; // since C++23 |
| 47 | 47 | ||
| 48 | template <class O, class T> | ||
| 49 | struct out_value_result; // since C++23 | ||
| 50 | |||
| 48 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | 51 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, |
| 49 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20 | 52 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20 |
| 50 | constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {}); | 53 | constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {}); |
| ... | @@ -422,11 +425,12 @@ namespace ranges { | ... | @@ -422,11 +425,12 @@ namespace ranges { |
| 422 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | 425 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, |
| 423 | class Proj = identity> | 426 | class Proj = identity> |
| 424 | requires sortable<I, Comp, Proj> | 427 | requires sortable<I, Comp, Proj> |
| 425 | I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | 428 | constexpr I // constexpr since C++26 |
| 429 | ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | ||
| 426 | 430 | ||
| 427 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | 431 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> |
| 428 | requires sortable<iterator_t<R>, Comp, Proj> | 432 | requires sortable<iterator_t<R>, Comp, Proj> |
| 429 | borrowed_iterator_t<R> | 433 | constexpr borrowed_iterator_t<R> // constexpr since C++26 |
| 430 | ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | 434 | ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 |
| 431 | 435 | ||
| 432 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | 436 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, |
| ... | @@ -627,12 +631,14 @@ namespace ranges { | ... | @@ -627,12 +631,14 @@ namespace ranges { |
| 627 | template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity, | 631 | template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity, |
| 628 | indirect_unary_predicate<projected<I, Proj>> Pred> | 632 | indirect_unary_predicate<projected<I, Proj>> Pred> |
| 629 | requires permutable<I> | 633 | requires permutable<I> |
| 630 | subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20 | 634 | constexpr subrange<I> // constexpr since C++26 |
| 635 | stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20 | ||
| 631 | 636 | ||
| 632 | template<bidirectional_range R, class Proj = identity, | 637 | template<bidirectional_range R, class Proj = identity, |
| 633 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | 638 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> |
| 634 | requires permutable<iterator_t<R>> | 639 | requires permutable<iterator_t<R>> |
| 635 | borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20 | 640 | constexpr borrowed_subrange_t<R> // constexpr since C++26 |
| 641 | stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20 | ||
| 636 | 642 | ||
| 637 | template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2, | 643 | template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2, |
| 638 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | 644 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> |
| ... | @@ -1028,13 +1034,14 @@ namespace ranges { | ... | @@ -1028,13 +1034,14 @@ namespace ranges { |
| 1028 | template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less, | 1034 | template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less, |
| 1029 | class Proj = identity> | 1035 | class Proj = identity> |
| 1030 | requires sortable<I, Comp, Proj> | 1036 | requires sortable<I, Comp, Proj> |
| 1031 | I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20 | 1037 | constexpr I // constexpr since C++26 |
| 1038 | inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20 | ||
| 1032 | 1039 | ||
| 1033 | template<bidirectional_range R, class Comp = ranges::less, class Proj = identity> | 1040 | template<bidirectional_range R, class Comp = ranges::less, class Proj = identity> |
| 1034 | requires sortable<iterator_t<R>, Comp, Proj> | 1041 | requires sortable<iterator_t<R>, Comp, Proj> |
| 1035 | borrowed_iterator_t<R> | 1042 | constexpr borrowed_iterator_t<R> // constexpr since C++26 |
| 1036 | inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {}, | 1043 | inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {}, |
| 1037 | Proj proj = {}); // since C++20 | 1044 | Proj proj = {}); // since C++20 |
| 1038 | 1045 | ||
| 1039 | template<permutable I, sentinel_for<I> S, class Proj = identity, | 1046 | template<permutable I, sentinel_for<I> S, class Proj = identity, |
| 1040 | indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to> | 1047 | indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to> |
| ... | @@ -1165,84 +1172,84 @@ namespace ranges { | ... | @@ -1165,84 +1172,84 @@ namespace ranges { |
| 1165 | } | 1172 | } |
| 1166 | 1173 | ||
| 1167 | template <class InputIterator, class Predicate> | 1174 | template <class InputIterator, class Predicate> |
| 1168 | constexpr bool // constexpr in C++20 | 1175 | constexpr bool // constexpr since C++20 |
| 1169 | all_of(InputIterator first, InputIterator last, Predicate pred); | 1176 | all_of(InputIterator first, InputIterator last, Predicate pred); |
| 1170 | 1177 | ||
| 1171 | template <class InputIterator, class Predicate> | 1178 | template <class InputIterator, class Predicate> |
| 1172 | constexpr bool // constexpr in C++20 | 1179 | constexpr bool // constexpr since C++20 |
| 1173 | any_of(InputIterator first, InputIterator last, Predicate pred); | 1180 | any_of(InputIterator first, InputIterator last, Predicate pred); |
| 1174 | 1181 | ||
| 1175 | template <class InputIterator, class Predicate> | 1182 | template <class InputIterator, class Predicate> |
| 1176 | constexpr bool // constexpr in C++20 | 1183 | constexpr bool // constexpr since C++20 |
| 1177 | none_of(InputIterator first, InputIterator last, Predicate pred); | 1184 | none_of(InputIterator first, InputIterator last, Predicate pred); |
| 1178 | 1185 | ||
| 1179 | template <class InputIterator, class Function> | 1186 | template <class InputIterator, class Function> |
| 1180 | constexpr Function // constexpr in C++20 | 1187 | constexpr Function // constexpr since C++20 |
| 1181 | for_each(InputIterator first, InputIterator last, Function f); | 1188 | for_each(InputIterator first, InputIterator last, Function f); |
| 1182 | 1189 | ||
| 1183 | template<class InputIterator, class Size, class Function> | 1190 | template<class InputIterator, class Size, class Function> |
| 1184 | constexpr InputIterator // constexpr in C++20 | 1191 | constexpr InputIterator // constexpr since C++20 |
| 1185 | for_each_n(InputIterator first, Size n, Function f); // C++17 | 1192 | for_each_n(InputIterator first, Size n, Function f); // C++17 |
| 1186 | 1193 | ||
| 1187 | template <class InputIterator, class T> | 1194 | template <class InputIterator, class T> |
| 1188 | constexpr InputIterator // constexpr in C++20 | 1195 | constexpr InputIterator // constexpr since C++20 |
| 1189 | find(InputIterator first, InputIterator last, const T& value); | 1196 | find(InputIterator first, InputIterator last, const T& value); |
| 1190 | 1197 | ||
| 1191 | template <class InputIterator, class Predicate> | 1198 | template <class InputIterator, class Predicate> |
| 1192 | constexpr InputIterator // constexpr in C++20 | 1199 | constexpr InputIterator // constexpr since C++20 |
| 1193 | find_if(InputIterator first, InputIterator last, Predicate pred); | 1200 | find_if(InputIterator first, InputIterator last, Predicate pred); |
| 1194 | 1201 | ||
| 1195 | template<class InputIterator, class Predicate> | 1202 | template<class InputIterator, class Predicate> |
| 1196 | constexpr InputIterator // constexpr in C++20 | 1203 | constexpr InputIterator // constexpr since C++20 |
| 1197 | find_if_not(InputIterator first, InputIterator last, Predicate pred); | 1204 | find_if_not(InputIterator first, InputIterator last, Predicate pred); |
| 1198 | 1205 | ||
| 1199 | template <class ForwardIterator1, class ForwardIterator2> | 1206 | template <class ForwardIterator1, class ForwardIterator2> |
| 1200 | constexpr ForwardIterator1 // constexpr in C++20 | 1207 | constexpr ForwardIterator1 // constexpr since C++20 |
| 1201 | find_end(ForwardIterator1 first1, ForwardIterator1 last1, | 1208 | find_end(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1202 | ForwardIterator2 first2, ForwardIterator2 last2); | 1209 | ForwardIterator2 first2, ForwardIterator2 last2); |
| 1203 | 1210 | ||
| 1204 | template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> | 1211 | template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1205 | constexpr ForwardIterator1 // constexpr in C++20 | 1212 | constexpr ForwardIterator1 // constexpr since C++20 |
| 1206 | find_end(ForwardIterator1 first1, ForwardIterator1 last1, | 1213 | find_end(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1207 | ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); | 1214 | ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); |
| 1208 | 1215 | ||
| 1209 | template <class ForwardIterator1, class ForwardIterator2> | 1216 | template <class ForwardIterator1, class ForwardIterator2> |
| 1210 | constexpr ForwardIterator1 // constexpr in C++20 | 1217 | constexpr ForwardIterator1 // constexpr since C++20 |
| 1211 | find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, | 1218 | find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1212 | ForwardIterator2 first2, ForwardIterator2 last2); | 1219 | ForwardIterator2 first2, ForwardIterator2 last2); |
| 1213 | 1220 | ||
| 1214 | template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> | 1221 | template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1215 | constexpr ForwardIterator1 // constexpr in C++20 | 1222 | constexpr ForwardIterator1 // constexpr since C++20 |
| 1216 | find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, | 1223 | find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1217 | ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); | 1224 | ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); |
| 1218 | 1225 | ||
| 1219 | template <class ForwardIterator> | 1226 | template <class ForwardIterator> |
| 1220 | constexpr ForwardIterator // constexpr in C++20 | 1227 | constexpr ForwardIterator // constexpr since C++20 |
| 1221 | adjacent_find(ForwardIterator first, ForwardIterator last); | 1228 | adjacent_find(ForwardIterator first, ForwardIterator last); |
| 1222 | 1229 | ||
| 1223 | template <class ForwardIterator, class BinaryPredicate> | 1230 | template <class ForwardIterator, class BinaryPredicate> |
| 1224 | constexpr ForwardIterator // constexpr in C++20 | 1231 | constexpr ForwardIterator // constexpr since C++20 |
| 1225 | adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); | 1232 | adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); |
| 1226 | 1233 | ||
| 1227 | template <class InputIterator, class T> | 1234 | template <class InputIterator, class T> |
| 1228 | constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20 | 1235 | constexpr typename iterator_traits<InputIterator>::difference_type // constexpr since C++20 |
| 1229 | count(InputIterator first, InputIterator last, const T& value); | 1236 | count(InputIterator first, InputIterator last, const T& value); |
| 1230 | 1237 | ||
| 1231 | template <class InputIterator, class Predicate> | 1238 | template <class InputIterator, class Predicate> |
| 1232 | constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20 | 1239 | constexpr typename iterator_traits<InputIterator>::difference_type // constexpr since C++20 |
| 1233 | count_if(InputIterator first, InputIterator last, Predicate pred); | 1240 | count_if(InputIterator first, InputIterator last, Predicate pred); |
| 1234 | 1241 | ||
| 1235 | template <class InputIterator1, class InputIterator2> | 1242 | template <class InputIterator1, class InputIterator2> |
| 1236 | constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 | 1243 | constexpr pair<InputIterator1, InputIterator2> // constexpr since C++20 |
| 1237 | mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); | 1244 | mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); |
| 1238 | 1245 | ||
| 1239 | template <class InputIterator1, class InputIterator2> | 1246 | template <class InputIterator1, class InputIterator2> |
| 1240 | constexpr pair<InputIterator1, InputIterator2> | 1247 | constexpr pair<InputIterator1, InputIterator2> |
| 1241 | mismatch(InputIterator1 first1, InputIterator1 last1, | 1248 | mismatch(InputIterator1 first1, InputIterator1 last1, |
| 1242 | InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++20 | 1249 | InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr since C++20 |
| 1243 | 1250 | ||
| 1244 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> | 1251 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1245 | constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 | 1252 | constexpr pair<InputIterator1, InputIterator2> // constexpr since C++20 |
| 1246 | mismatch(InputIterator1 first1, InputIterator1 last1, | 1253 | mismatch(InputIterator1 first1, InputIterator1 last1, |
| 1247 | InputIterator2 first2, BinaryPredicate pred); | 1254 | InputIterator2 first2, BinaryPredicate pred); |
| 1248 | 1255 | ||
| ... | @@ -1250,19 +1257,19 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate> | ... | @@ -1250,19 +1257,19 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1250 | constexpr pair<InputIterator1, InputIterator2> | 1257 | constexpr pair<InputIterator1, InputIterator2> |
| 1251 | mismatch(InputIterator1 first1, InputIterator1 last1, | 1258 | mismatch(InputIterator1 first1, InputIterator1 last1, |
| 1252 | InputIterator2 first2, InputIterator2 last2, | 1259 | InputIterator2 first2, InputIterator2 last2, |
| 1253 | BinaryPredicate pred); // since C++14, constexpr in C++20 | 1260 | BinaryPredicate pred); // since C++14, constexpr since C++20 |
| 1254 | 1261 | ||
| 1255 | template <class InputIterator1, class InputIterator2> | 1262 | template <class InputIterator1, class InputIterator2> |
| 1256 | constexpr bool // constexpr in C++20 | 1263 | constexpr bool // constexpr since C++20 |
| 1257 | equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); | 1264 | equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); |
| 1258 | 1265 | ||
| 1259 | template <class InputIterator1, class InputIterator2> | 1266 | template <class InputIterator1, class InputIterator2> |
| 1260 | constexpr bool | 1267 | constexpr bool |
| 1261 | equal(InputIterator1 first1, InputIterator1 last1, | 1268 | equal(InputIterator1 first1, InputIterator1 last1, |
| 1262 | InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++20 | 1269 | InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr since C++20 |
| 1263 | 1270 | ||
| 1264 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> | 1271 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1265 | constexpr bool // constexpr in C++20 | 1272 | constexpr bool // constexpr since C++20 |
| 1266 | equal(InputIterator1 first1, InputIterator1 last1, | 1273 | equal(InputIterator1 first1, InputIterator1 last1, |
| 1267 | InputIterator2 first2, BinaryPredicate pred); | 1274 | InputIterator2 first2, BinaryPredicate pred); |
| 1268 | 1275 | ||
| ... | @@ -1270,20 +1277,20 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate> | ... | @@ -1270,20 +1277,20 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1270 | constexpr bool | 1277 | constexpr bool |
| 1271 | equal(InputIterator1 first1, InputIterator1 last1, | 1278 | equal(InputIterator1 first1, InputIterator1 last1, |
| 1272 | InputIterator2 first2, InputIterator2 last2, | 1279 | InputIterator2 first2, InputIterator2 last2, |
| 1273 | BinaryPredicate pred); // since C++14, constexpr in C++20 | 1280 | BinaryPredicate pred); // since C++14, constexpr since C++20 |
| 1274 | 1281 | ||
| 1275 | template<class ForwardIterator1, class ForwardIterator2> | 1282 | template<class ForwardIterator1, class ForwardIterator2> |
| 1276 | constexpr bool // constexpr in C++20 | 1283 | constexpr bool // constexpr since C++20 |
| 1277 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, | 1284 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1278 | ForwardIterator2 first2); | 1285 | ForwardIterator2 first2); |
| 1279 | 1286 | ||
| 1280 | template<class ForwardIterator1, class ForwardIterator2> | 1287 | template<class ForwardIterator1, class ForwardIterator2> |
| 1281 | constexpr bool | 1288 | constexpr bool |
| 1282 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, | 1289 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1283 | ForwardIterator2 first2, ForwardIterator2 last2); // since C++14, constexpr in C++20 | 1290 | ForwardIterator2 first2, ForwardIterator2 last2); // since C++14, constexpr since C++20 |
| 1284 | 1291 | ||
| 1285 | template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> | 1292 | template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1286 | constexpr bool // constexpr in C++20 | 1293 | constexpr bool // constexpr since C++20 |
| 1287 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, | 1294 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1288 | ForwardIterator2 first2, BinaryPredicate pred); | 1295 | ForwardIterator2 first2, BinaryPredicate pred); |
| 1289 | 1296 | ||
| ... | @@ -1291,42 +1298,42 @@ template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> | ... | @@ -1291,42 +1298,42 @@ template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1291 | constexpr bool | 1298 | constexpr bool |
| 1292 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, | 1299 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1293 | ForwardIterator2 first2, ForwardIterator2 last2, | 1300 | ForwardIterator2 first2, ForwardIterator2 last2, |
| 1294 | BinaryPredicate pred); // since C++14, constexpr in C++20 | 1301 | BinaryPredicate pred); // since C++14, constexpr since C++20 |
| 1295 | 1302 | ||
| 1296 | template <class ForwardIterator1, class ForwardIterator2> | 1303 | template <class ForwardIterator1, class ForwardIterator2> |
| 1297 | constexpr ForwardIterator1 // constexpr in C++20 | 1304 | constexpr ForwardIterator1 // constexpr since C++20 |
| 1298 | search(ForwardIterator1 first1, ForwardIterator1 last1, | 1305 | search(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1299 | ForwardIterator2 first2, ForwardIterator2 last2); | 1306 | ForwardIterator2 first2, ForwardIterator2 last2); |
| 1300 | 1307 | ||
| 1301 | template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> | 1308 | template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1302 | constexpr ForwardIterator1 // constexpr in C++20 | 1309 | constexpr ForwardIterator1 // constexpr since C++20 |
| 1303 | search(ForwardIterator1 first1, ForwardIterator1 last1, | 1310 | search(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1304 | ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); | 1311 | ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred); |
| 1305 | 1312 | ||
| 1306 | template <class ForwardIterator, class Size, class T> | 1313 | template <class ForwardIterator, class Size, class T> |
| 1307 | constexpr ForwardIterator // constexpr in C++20 | 1314 | constexpr ForwardIterator // constexpr since C++20 |
| 1308 | search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value); | 1315 | search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value); |
| 1309 | 1316 | ||
| 1310 | template <class ForwardIterator, class Size, class T, class BinaryPredicate> | 1317 | template <class ForwardIterator, class Size, class T, class BinaryPredicate> |
| 1311 | constexpr ForwardIterator // constexpr in C++20 | 1318 | constexpr ForwardIterator // constexpr since C++20 |
| 1312 | search_n(ForwardIterator first, ForwardIterator last, | 1319 | search_n(ForwardIterator first, ForwardIterator last, |
| 1313 | Size count, const T& value, BinaryPredicate pred); | 1320 | Size count, const T& value, BinaryPredicate pred); |
| 1314 | 1321 | ||
| 1315 | template <class InputIterator, class OutputIterator> | 1322 | template <class InputIterator, class OutputIterator> |
| 1316 | constexpr OutputIterator // constexpr in C++20 | 1323 | constexpr OutputIterator // constexpr since C++20 |
| 1317 | copy(InputIterator first, InputIterator last, OutputIterator result); | 1324 | copy(InputIterator first, InputIterator last, OutputIterator result); |
| 1318 | 1325 | ||
| 1319 | template<class InputIterator, class OutputIterator, class Predicate> | 1326 | template<class InputIterator, class OutputIterator, class Predicate> |
| 1320 | constexpr OutputIterator // constexpr in C++20 | 1327 | constexpr OutputIterator // constexpr since C++20 |
| 1321 | copy_if(InputIterator first, InputIterator last, | 1328 | copy_if(InputIterator first, InputIterator last, |
| 1322 | OutputIterator result, Predicate pred); | 1329 | OutputIterator result, Predicate pred); |
| 1323 | 1330 | ||
| 1324 | template<class InputIterator, class Size, class OutputIterator> | 1331 | template<class InputIterator, class Size, class OutputIterator> |
| 1325 | constexpr OutputIterator // constexpr in C++20 | 1332 | constexpr OutputIterator // constexpr since C++20 |
| 1326 | copy_n(InputIterator first, Size n, OutputIterator result); | 1333 | copy_n(InputIterator first, Size n, OutputIterator result); |
| 1327 | 1334 | ||
| 1328 | template <class BidirectionalIterator1, class BidirectionalIterator2> | 1335 | template <class BidirectionalIterator1, class BidirectionalIterator2> |
| 1329 | constexpr BidirectionalIterator2 // constexpr in C++20 | 1336 | constexpr BidirectionalIterator2 // constexpr since C++20 |
| 1330 | copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, | 1337 | copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, |
| 1331 | BidirectionalIterator2 result); | 1338 | BidirectionalIterator2 result); |
| 1332 | 1339 | ||
| ... | @@ -1341,7 +1348,7 @@ template<class BidirectionalIterator1, class BidirectionalIterator2> | ... | @@ -1341,7 +1348,7 @@ template<class BidirectionalIterator1, class BidirectionalIterator2> |
| 1341 | BidirectionalIterator2 result); | 1348 | BidirectionalIterator2 result); |
| 1342 | 1349 | ||
| 1343 | template <class ForwardIterator1, class ForwardIterator2> | 1350 | template <class ForwardIterator1, class ForwardIterator2> |
| 1344 | constexpr ForwardIterator2 // constexpr in C++20 | 1351 | constexpr ForwardIterator2 // constexpr since C++20 |
| 1345 | swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); | 1352 | swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); |
| 1346 | 1353 | ||
| 1347 | namespace ranges { | 1354 | namespace ranges { |
| ... | @@ -1360,97 +1367,97 @@ template<input_range R1, input_range R2> | ... | @@ -1360,97 +1367,97 @@ template<input_range R1, input_range R2> |
| 1360 | } | 1367 | } |
| 1361 | 1368 | ||
| 1362 | template <class ForwardIterator1, class ForwardIterator2> | 1369 | template <class ForwardIterator1, class ForwardIterator2> |
| 1363 | constexpr void // constexpr in C++20 | 1370 | constexpr void // constexpr since C++20 |
| 1364 | iter_swap(ForwardIterator1 a, ForwardIterator2 b); | 1371 | iter_swap(ForwardIterator1 a, ForwardIterator2 b); |
| 1365 | 1372 | ||
| 1366 | template <class InputIterator, class OutputIterator, class UnaryOperation> | 1373 | template <class InputIterator, class OutputIterator, class UnaryOperation> |
| 1367 | constexpr OutputIterator // constexpr in C++20 | 1374 | constexpr OutputIterator // constexpr since C++20 |
| 1368 | transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op); | 1375 | transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op); |
| 1369 | 1376 | ||
| 1370 | template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation> | 1377 | template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation> |
| 1371 | constexpr OutputIterator // constexpr in C++20 | 1378 | constexpr OutputIterator // constexpr since C++20 |
| 1372 | transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, | 1379 | transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, |
| 1373 | OutputIterator result, BinaryOperation binary_op); | 1380 | OutputIterator result, BinaryOperation binary_op); |
| 1374 | 1381 | ||
| 1375 | template <class ForwardIterator, class T> | 1382 | template <class ForwardIterator, class T> |
| 1376 | constexpr void // constexpr in C++20 | 1383 | constexpr void // constexpr since C++20 |
| 1377 | replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value); | 1384 | replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value); |
| 1378 | 1385 | ||
| 1379 | template <class ForwardIterator, class Predicate, class T> | 1386 | template <class ForwardIterator, class Predicate, class T> |
| 1380 | constexpr void // constexpr in C++20 | 1387 | constexpr void // constexpr since C++20 |
| 1381 | replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value); | 1388 | replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value); |
| 1382 | 1389 | ||
| 1383 | template <class InputIterator, class OutputIterator, class T> | 1390 | template <class InputIterator, class OutputIterator, class T> |
| 1384 | constexpr OutputIterator // constexpr in C++20 | 1391 | constexpr OutputIterator // constexpr since C++20 |
| 1385 | replace_copy(InputIterator first, InputIterator last, OutputIterator result, | 1392 | replace_copy(InputIterator first, InputIterator last, OutputIterator result, |
| 1386 | const T& old_value, const T& new_value); | 1393 | const T& old_value, const T& new_value); |
| 1387 | 1394 | ||
| 1388 | template <class InputIterator, class OutputIterator, class Predicate, class T> | 1395 | template <class InputIterator, class OutputIterator, class Predicate, class T> |
| 1389 | constexpr OutputIterator // constexpr in C++20 | 1396 | constexpr OutputIterator // constexpr since C++20 |
| 1390 | replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value); | 1397 | replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value); |
| 1391 | 1398 | ||
| 1392 | template <class ForwardIterator, class T> | 1399 | template <class ForwardIterator, class T> |
| 1393 | constexpr void // constexpr in C++20 | 1400 | constexpr void // constexpr since C++20 |
| 1394 | fill(ForwardIterator first, ForwardIterator last, const T& value); | 1401 | fill(ForwardIterator first, ForwardIterator last, const T& value); |
| 1395 | 1402 | ||
| 1396 | template <class OutputIterator, class Size, class T> | 1403 | template <class OutputIterator, class Size, class T> |
| 1397 | constexpr OutputIterator // constexpr in C++20 | 1404 | constexpr OutputIterator // constexpr since C++20 |
| 1398 | fill_n(OutputIterator first, Size n, const T& value); | 1405 | fill_n(OutputIterator first, Size n, const T& value); |
| 1399 | 1406 | ||
| 1400 | template <class ForwardIterator, class Generator> | 1407 | template <class ForwardIterator, class Generator> |
| 1401 | constexpr void // constexpr in C++20 | 1408 | constexpr void // constexpr since C++20 |
| 1402 | generate(ForwardIterator first, ForwardIterator last, Generator gen); | 1409 | generate(ForwardIterator first, ForwardIterator last, Generator gen); |
| 1403 | 1410 | ||
| 1404 | template <class OutputIterator, class Size, class Generator> | 1411 | template <class OutputIterator, class Size, class Generator> |
| 1405 | constexpr OutputIterator // constexpr in C++20 | 1412 | constexpr OutputIterator // constexpr since C++20 |
| 1406 | generate_n(OutputIterator first, Size n, Generator gen); | 1413 | generate_n(OutputIterator first, Size n, Generator gen); |
| 1407 | 1414 | ||
| 1408 | template <class ForwardIterator, class T> | 1415 | template <class ForwardIterator, class T> |
| 1409 | constexpr ForwardIterator // constexpr in C++20 | 1416 | constexpr ForwardIterator // constexpr since C++20 |
| 1410 | remove(ForwardIterator first, ForwardIterator last, const T& value); | 1417 | remove(ForwardIterator first, ForwardIterator last, const T& value); |
| 1411 | 1418 | ||
| 1412 | template <class ForwardIterator, class Predicate> | 1419 | template <class ForwardIterator, class Predicate> |
| 1413 | constexpr ForwardIterator // constexpr in C++20 | 1420 | constexpr ForwardIterator // constexpr since C++20 |
| 1414 | remove_if(ForwardIterator first, ForwardIterator last, Predicate pred); | 1421 | remove_if(ForwardIterator first, ForwardIterator last, Predicate pred); |
| 1415 | 1422 | ||
| 1416 | template <class InputIterator, class OutputIterator, class T> | 1423 | template <class InputIterator, class OutputIterator, class T> |
| 1417 | constexpr OutputIterator // constexpr in C++20 | 1424 | constexpr OutputIterator // constexpr since C++20 |
| 1418 | remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value); | 1425 | remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value); |
| 1419 | 1426 | ||
| 1420 | template <class InputIterator, class OutputIterator, class Predicate> | 1427 | template <class InputIterator, class OutputIterator, class Predicate> |
| 1421 | constexpr OutputIterator // constexpr in C++20 | 1428 | constexpr OutputIterator // constexpr since C++20 |
| 1422 | remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred); | 1429 | remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred); |
| 1423 | 1430 | ||
| 1424 | template <class ForwardIterator> | 1431 | template <class ForwardIterator> |
| 1425 | constexpr ForwardIterator // constexpr in C++20 | 1432 | constexpr ForwardIterator // constexpr since C++20 |
| 1426 | unique(ForwardIterator first, ForwardIterator last); | 1433 | unique(ForwardIterator first, ForwardIterator last); |
| 1427 | 1434 | ||
| 1428 | template <class ForwardIterator, class BinaryPredicate> | 1435 | template <class ForwardIterator, class BinaryPredicate> |
| 1429 | constexpr ForwardIterator // constexpr in C++20 | 1436 | constexpr ForwardIterator // constexpr since C++20 |
| 1430 | unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); | 1437 | unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred); |
| 1431 | 1438 | ||
| 1432 | template <class InputIterator, class OutputIterator> | 1439 | template <class InputIterator, class OutputIterator> |
| 1433 | constexpr OutputIterator // constexpr in C++20 | 1440 | constexpr OutputIterator // constexpr since C++20 |
| 1434 | unique_copy(InputIterator first, InputIterator last, OutputIterator result); | 1441 | unique_copy(InputIterator first, InputIterator last, OutputIterator result); |
| 1435 | 1442 | ||
| 1436 | template <class InputIterator, class OutputIterator, class BinaryPredicate> | 1443 | template <class InputIterator, class OutputIterator, class BinaryPredicate> |
| 1437 | constexpr OutputIterator // constexpr in C++20 | 1444 | constexpr OutputIterator // constexpr since C++20 |
| 1438 | unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred); | 1445 | unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred); |
| 1439 | 1446 | ||
| 1440 | template <class BidirectionalIterator> | 1447 | template <class BidirectionalIterator> |
| 1441 | constexpr void // constexpr in C++20 | 1448 | constexpr void // constexpr since C++20 |
| 1442 | reverse(BidirectionalIterator first, BidirectionalIterator last); | 1449 | reverse(BidirectionalIterator first, BidirectionalIterator last); |
| 1443 | 1450 | ||
| 1444 | template <class BidirectionalIterator, class OutputIterator> | 1451 | template <class BidirectionalIterator, class OutputIterator> |
| 1445 | constexpr OutputIterator // constexpr in C++20 | 1452 | constexpr OutputIterator // constexpr since C++20 |
| 1446 | reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result); | 1453 | reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result); |
| 1447 | 1454 | ||
| 1448 | template <class ForwardIterator> | 1455 | template <class ForwardIterator> |
| 1449 | constexpr ForwardIterator // constexpr in C++20 | 1456 | constexpr ForwardIterator // constexpr since C++20 |
| 1450 | rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last); | 1457 | rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last); |
| 1451 | 1458 | ||
| 1452 | template <class ForwardIterator, class OutputIterator> | 1459 | template <class ForwardIterator, class OutputIterator> |
| 1453 | constexpr OutputIterator // constexpr in C++20 | 1460 | constexpr OutputIterator // constexpr since C++20 |
| 1454 | rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result); | 1461 | rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result); |
| 1455 | 1462 | ||
| 1456 | template <class RandomAccessIterator> | 1463 | template <class RandomAccessIterator> |
| ... | @@ -1483,254 +1490,254 @@ template<class ForwardIterator> | ... | @@ -1483,254 +1490,254 @@ template<class ForwardIterator> |
| 1483 | typename iterator_traits<ForwardIterator>::difference_type n); // C++20 | 1490 | typename iterator_traits<ForwardIterator>::difference_type n); // C++20 |
| 1484 | 1491 | ||
| 1485 | template <class InputIterator, class Predicate> | 1492 | template <class InputIterator, class Predicate> |
| 1486 | constexpr bool // constexpr in C++20 | 1493 | constexpr bool // constexpr since C++20 |
| 1487 | is_partitioned(InputIterator first, InputIterator last, Predicate pred); | 1494 | is_partitioned(InputIterator first, InputIterator last, Predicate pred); |
| 1488 | 1495 | ||
| 1489 | template <class ForwardIterator, class Predicate> | 1496 | template <class ForwardIterator, class Predicate> |
| 1490 | constexpr ForwardIterator // constexpr in C++20 | 1497 | constexpr ForwardIterator // constexpr since C++20 |
| 1491 | partition(ForwardIterator first, ForwardIterator last, Predicate pred); | 1498 | partition(ForwardIterator first, ForwardIterator last, Predicate pred); |
| 1492 | 1499 | ||
| 1493 | template <class InputIterator, class OutputIterator1, | 1500 | template <class InputIterator, class OutputIterator1, |
| 1494 | class OutputIterator2, class Predicate> | 1501 | class OutputIterator2, class Predicate> |
| 1495 | constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20 | 1502 | constexpr pair<OutputIterator1, OutputIterator2> // constexpr since C++20 |
| 1496 | partition_copy(InputIterator first, InputIterator last, | 1503 | partition_copy(InputIterator first, InputIterator last, |
| 1497 | OutputIterator1 out_true, OutputIterator2 out_false, | 1504 | OutputIterator1 out_true, OutputIterator2 out_false, |
| 1498 | Predicate pred); | 1505 | Predicate pred); |
| 1499 | 1506 | ||
| 1500 | template <class ForwardIterator, class Predicate> | 1507 | template <class ForwardIterator, class Predicate> |
| 1501 | ForwardIterator | 1508 | constexpr ForwardIterator // constexpr since C++26 |
| 1502 | stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred); | 1509 | stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred); |
| 1503 | 1510 | ||
| 1504 | template<class ForwardIterator, class Predicate> | 1511 | template<class ForwardIterator, class Predicate> |
| 1505 | constexpr ForwardIterator // constexpr in C++20 | 1512 | constexpr ForwardIterator // constexpr since C++20 |
| 1506 | partition_point(ForwardIterator first, ForwardIterator last, Predicate pred); | 1513 | partition_point(ForwardIterator first, ForwardIterator last, Predicate pred); |
| 1507 | 1514 | ||
| 1508 | template <class ForwardIterator> | 1515 | template <class ForwardIterator> |
| 1509 | constexpr bool // constexpr in C++20 | 1516 | constexpr bool // constexpr since C++20 |
| 1510 | is_sorted(ForwardIterator first, ForwardIterator last); | 1517 | is_sorted(ForwardIterator first, ForwardIterator last); |
| 1511 | 1518 | ||
| 1512 | template <class ForwardIterator, class Compare> | 1519 | template <class ForwardIterator, class Compare> |
| 1513 | constexpr bool // constexpr in C++20 | 1520 | constexpr bool // constexpr since C++20 |
| 1514 | is_sorted(ForwardIterator first, ForwardIterator last, Compare comp); | 1521 | is_sorted(ForwardIterator first, ForwardIterator last, Compare comp); |
| 1515 | 1522 | ||
| 1516 | template<class ForwardIterator> | 1523 | template<class ForwardIterator> |
| 1517 | constexpr ForwardIterator // constexpr in C++20 | 1524 | constexpr ForwardIterator // constexpr since C++20 |
| 1518 | is_sorted_until(ForwardIterator first, ForwardIterator last); | 1525 | is_sorted_until(ForwardIterator first, ForwardIterator last); |
| 1519 | 1526 | ||
| 1520 | template <class ForwardIterator, class Compare> | 1527 | template <class ForwardIterator, class Compare> |
| 1521 | constexpr ForwardIterator // constexpr in C++20 | 1528 | constexpr ForwardIterator // constexpr since C++20 |
| 1522 | is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp); | 1529 | is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp); |
| 1523 | 1530 | ||
| 1524 | template <class RandomAccessIterator> | 1531 | template <class RandomAccessIterator> |
| 1525 | constexpr void // constexpr in C++20 | 1532 | constexpr void // constexpr since C++20 |
| 1526 | sort(RandomAccessIterator first, RandomAccessIterator last); | 1533 | sort(RandomAccessIterator first, RandomAccessIterator last); |
| 1527 | 1534 | ||
| 1528 | template <class RandomAccessIterator, class Compare> | 1535 | template <class RandomAccessIterator, class Compare> |
| 1529 | constexpr void // constexpr in C++20 | 1536 | constexpr void // constexpr since C++20 |
| 1530 | sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); | 1537 | sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1531 | 1538 | ||
| 1532 | template <class RandomAccessIterator> | 1539 | template <class RandomAccessIterator> |
| 1533 | constexpr void // constexpr in C++26 | 1540 | constexpr void // constexpr since C++26 |
| 1534 | stable_sort(RandomAccessIterator first, RandomAccessIterator last); | 1541 | stable_sort(RandomAccessIterator first, RandomAccessIterator last); |
| 1535 | 1542 | ||
| 1536 | template <class RandomAccessIterator, class Compare> | 1543 | template <class RandomAccessIterator, class Compare> |
| 1537 | constexpr void // constexpr in C++26 | 1544 | constexpr void // constexpr since C++26 |
| 1538 | stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); | 1545 | stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1539 | 1546 | ||
| 1540 | template <class RandomAccessIterator> | 1547 | template <class RandomAccessIterator> |
| 1541 | constexpr void // constexpr in C++20 | 1548 | constexpr void // constexpr since C++20 |
| 1542 | partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); | 1549 | partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); |
| 1543 | 1550 | ||
| 1544 | template <class RandomAccessIterator, class Compare> | 1551 | template <class RandomAccessIterator, class Compare> |
| 1545 | constexpr void // constexpr in C++20 | 1552 | constexpr void // constexpr since C++20 |
| 1546 | partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); | 1553 | partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); |
| 1547 | 1554 | ||
| 1548 | template <class InputIterator, class RandomAccessIterator> | 1555 | template <class InputIterator, class RandomAccessIterator> |
| 1549 | constexpr RandomAccessIterator // constexpr in C++20 | 1556 | constexpr RandomAccessIterator // constexpr since C++20 |
| 1550 | partial_sort_copy(InputIterator first, InputIterator last, | 1557 | partial_sort_copy(InputIterator first, InputIterator last, |
| 1551 | RandomAccessIterator result_first, RandomAccessIterator result_last); | 1558 | RandomAccessIterator result_first, RandomAccessIterator result_last); |
| 1552 | 1559 | ||
| 1553 | template <class InputIterator, class RandomAccessIterator, class Compare> | 1560 | template <class InputIterator, class RandomAccessIterator, class Compare> |
| 1554 | constexpr RandomAccessIterator // constexpr in C++20 | 1561 | constexpr RandomAccessIterator // constexpr since C++20 |
| 1555 | partial_sort_copy(InputIterator first, InputIterator last, | 1562 | partial_sort_copy(InputIterator first, InputIterator last, |
| 1556 | RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp); | 1563 | RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp); |
| 1557 | 1564 | ||
| 1558 | template <class RandomAccessIterator> | 1565 | template <class RandomAccessIterator> |
| 1559 | constexpr void // constexpr in C++20 | 1566 | constexpr void // constexpr since C++20 |
| 1560 | nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last); | 1567 | nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last); |
| 1561 | 1568 | ||
| 1562 | template <class RandomAccessIterator, class Compare> | 1569 | template <class RandomAccessIterator, class Compare> |
| 1563 | constexpr void // constexpr in C++20 | 1570 | constexpr void // constexpr since C++20 |
| 1564 | nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp); | 1571 | nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp); |
| 1565 | 1572 | ||
| 1566 | template <class ForwardIterator, class T> | 1573 | template <class ForwardIterator, class T> |
| 1567 | constexpr ForwardIterator // constexpr in C++20 | 1574 | constexpr ForwardIterator // constexpr since C++20 |
| 1568 | lower_bound(ForwardIterator first, ForwardIterator last, const T& value); | 1575 | lower_bound(ForwardIterator first, ForwardIterator last, const T& value); |
| 1569 | 1576 | ||
| 1570 | template <class ForwardIterator, class T, class Compare> | 1577 | template <class ForwardIterator, class T, class Compare> |
| 1571 | constexpr ForwardIterator // constexpr in C++20 | 1578 | constexpr ForwardIterator // constexpr since C++20 |
| 1572 | lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); | 1579 | lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); |
| 1573 | 1580 | ||
| 1574 | template <class ForwardIterator, class T> | 1581 | template <class ForwardIterator, class T> |
| 1575 | constexpr ForwardIterator // constexpr in C++20 | 1582 | constexpr ForwardIterator // constexpr since C++20 |
| 1576 | upper_bound(ForwardIterator first, ForwardIterator last, const T& value); | 1583 | upper_bound(ForwardIterator first, ForwardIterator last, const T& value); |
| 1577 | 1584 | ||
| 1578 | template <class ForwardIterator, class T, class Compare> | 1585 | template <class ForwardIterator, class T, class Compare> |
| 1579 | constexpr ForwardIterator // constexpr in C++20 | 1586 | constexpr ForwardIterator // constexpr since C++20 |
| 1580 | upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); | 1587 | upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); |
| 1581 | 1588 | ||
| 1582 | template <class ForwardIterator, class T> | 1589 | template <class ForwardIterator, class T> |
| 1583 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20 | 1590 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++20 |
| 1584 | equal_range(ForwardIterator first, ForwardIterator last, const T& value); | 1591 | equal_range(ForwardIterator first, ForwardIterator last, const T& value); |
| 1585 | 1592 | ||
| 1586 | template <class ForwardIterator, class T, class Compare> | 1593 | template <class ForwardIterator, class T, class Compare> |
| 1587 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20 | 1594 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++20 |
| 1588 | equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); | 1595 | equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); |
| 1589 | 1596 | ||
| 1590 | template <class ForwardIterator, class T> | 1597 | template <class ForwardIterator, class T> |
| 1591 | constexpr bool // constexpr in C++20 | 1598 | constexpr bool // constexpr since C++20 |
| 1592 | binary_search(ForwardIterator first, ForwardIterator last, const T& value); | 1599 | binary_search(ForwardIterator first, ForwardIterator last, const T& value); |
| 1593 | 1600 | ||
| 1594 | template <class ForwardIterator, class T, class Compare> | 1601 | template <class ForwardIterator, class T, class Compare> |
| 1595 | constexpr bool // constexpr in C++20 | 1602 | constexpr bool // constexpr since C++20 |
| 1596 | binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); | 1603 | binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp); |
| 1597 | 1604 | ||
| 1598 | template <class InputIterator1, class InputIterator2, class OutputIterator> | 1605 | template <class InputIterator1, class InputIterator2, class OutputIterator> |
| 1599 | constexpr OutputIterator // constexpr in C++20 | 1606 | constexpr OutputIterator // constexpr since C++20 |
| 1600 | merge(InputIterator1 first1, InputIterator1 last1, | 1607 | merge(InputIterator1 first1, InputIterator1 last1, |
| 1601 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); | 1608 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); |
| 1602 | 1609 | ||
| 1603 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> | 1610 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> |
| 1604 | constexpr OutputIterator // constexpr in C++20 | 1611 | constexpr OutputIterator // constexpr since C++20 |
| 1605 | merge(InputIterator1 first1, InputIterator1 last1, | 1612 | merge(InputIterator1 first1, InputIterator1 last1, |
| 1606 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); | 1613 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); |
| 1607 | 1614 | ||
| 1608 | template <class BidirectionalIterator> | 1615 | template <class BidirectionalIterator> |
| 1609 | void | 1616 | constexpr void // constexpr since C++26 |
| 1610 | inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last); | 1617 | inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last); |
| 1611 | 1618 | ||
| 1612 | template <class BidirectionalIterator, class Compare> | 1619 | template <class BidirectionalIterator, class Compare> |
| 1613 | void | 1620 | constexpr void // constexpr since C++26 |
| 1614 | inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp); | 1621 | inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp); |
| 1615 | 1622 | ||
| 1616 | template <class InputIterator1, class InputIterator2> | 1623 | template <class InputIterator1, class InputIterator2> |
| 1617 | constexpr bool // constexpr in C++20 | 1624 | constexpr bool // constexpr since C++20 |
| 1618 | includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); | 1625 | includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); |
| 1619 | 1626 | ||
| 1620 | template <class InputIterator1, class InputIterator2, class Compare> | 1627 | template <class InputIterator1, class InputIterator2, class Compare> |
| 1621 | constexpr bool // constexpr in C++20 | 1628 | constexpr bool // constexpr since C++20 |
| 1622 | includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp); | 1629 | includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp); |
| 1623 | 1630 | ||
| 1624 | template <class InputIterator1, class InputIterator2, class OutputIterator> | 1631 | template <class InputIterator1, class InputIterator2, class OutputIterator> |
| 1625 | constexpr OutputIterator // constexpr in C++20 | 1632 | constexpr OutputIterator // constexpr since C++20 |
| 1626 | set_union(InputIterator1 first1, InputIterator1 last1, | 1633 | set_union(InputIterator1 first1, InputIterator1 last1, |
| 1627 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); | 1634 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); |
| 1628 | 1635 | ||
| 1629 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> | 1636 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> |
| 1630 | constexpr OutputIterator // constexpr in C++20 | 1637 | constexpr OutputIterator // constexpr since C++20 |
| 1631 | set_union(InputIterator1 first1, InputIterator1 last1, | 1638 | set_union(InputIterator1 first1, InputIterator1 last1, |
| 1632 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); | 1639 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); |
| 1633 | 1640 | ||
| 1634 | template <class InputIterator1, class InputIterator2, class OutputIterator> | 1641 | template <class InputIterator1, class InputIterator2, class OutputIterator> |
| 1635 | constexpr OutputIterator // constexpr in C++20 | 1642 | constexpr OutputIterator // constexpr since C++20 |
| 1636 | set_intersection(InputIterator1 first1, InputIterator1 last1, | 1643 | set_intersection(InputIterator1 first1, InputIterator1 last1, |
| 1637 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); | 1644 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); |
| 1638 | 1645 | ||
| 1639 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> | 1646 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> |
| 1640 | constexpr OutputIterator // constexpr in C++20 | 1647 | constexpr OutputIterator // constexpr since C++20 |
| 1641 | set_intersection(InputIterator1 first1, InputIterator1 last1, | 1648 | set_intersection(InputIterator1 first1, InputIterator1 last1, |
| 1642 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); | 1649 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); |
| 1643 | 1650 | ||
| 1644 | template <class InputIterator1, class InputIterator2, class OutputIterator> | 1651 | template <class InputIterator1, class InputIterator2, class OutputIterator> |
| 1645 | constexpr OutputIterator // constexpr in C++20 | 1652 | constexpr OutputIterator // constexpr since C++20 |
| 1646 | set_difference(InputIterator1 first1, InputIterator1 last1, | 1653 | set_difference(InputIterator1 first1, InputIterator1 last1, |
| 1647 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); | 1654 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); |
| 1648 | 1655 | ||
| 1649 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> | 1656 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> |
| 1650 | constexpr OutputIterator // constexpr in C++20 | 1657 | constexpr OutputIterator // constexpr since C++20 |
| 1651 | set_difference(InputIterator1 first1, InputIterator1 last1, | 1658 | set_difference(InputIterator1 first1, InputIterator1 last1, |
| 1652 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); | 1659 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); |
| 1653 | 1660 | ||
| 1654 | template <class InputIterator1, class InputIterator2, class OutputIterator> | 1661 | template <class InputIterator1, class InputIterator2, class OutputIterator> |
| 1655 | constexpr OutputIterator // constexpr in C++20 | 1662 | constexpr OutputIterator // constexpr since C++20 |
| 1656 | set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, | 1663 | set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, |
| 1657 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); | 1664 | InputIterator2 first2, InputIterator2 last2, OutputIterator result); |
| 1658 | 1665 | ||
| 1659 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> | 1666 | template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> |
| 1660 | constexpr OutputIterator // constexpr in C++20 | 1667 | constexpr OutputIterator // constexpr since C++20 |
| 1661 | set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, | 1668 | set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, |
| 1662 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); | 1669 | InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp); |
| 1663 | 1670 | ||
| 1664 | template <class RandomAccessIterator> | 1671 | template <class RandomAccessIterator> |
| 1665 | constexpr void // constexpr in C++20 | 1672 | constexpr void // constexpr since C++20 |
| 1666 | push_heap(RandomAccessIterator first, RandomAccessIterator last); | 1673 | push_heap(RandomAccessIterator first, RandomAccessIterator last); |
| 1667 | 1674 | ||
| 1668 | template <class RandomAccessIterator, class Compare> | 1675 | template <class RandomAccessIterator, class Compare> |
| 1669 | constexpr void // constexpr in C++20 | 1676 | constexpr void // constexpr since C++20 |
| 1670 | push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); | 1677 | push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1671 | 1678 | ||
| 1672 | template <class RandomAccessIterator> | 1679 | template <class RandomAccessIterator> |
| 1673 | constexpr void // constexpr in C++20 | 1680 | constexpr void // constexpr since C++20 |
| 1674 | pop_heap(RandomAccessIterator first, RandomAccessIterator last); | 1681 | pop_heap(RandomAccessIterator first, RandomAccessIterator last); |
| 1675 | 1682 | ||
| 1676 | template <class RandomAccessIterator, class Compare> | 1683 | template <class RandomAccessIterator, class Compare> |
| 1677 | constexpr void // constexpr in C++20 | 1684 | constexpr void // constexpr since C++20 |
| 1678 | pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); | 1685 | pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1679 | 1686 | ||
| 1680 | template <class RandomAccessIterator> | 1687 | template <class RandomAccessIterator> |
| 1681 | constexpr void // constexpr in C++20 | 1688 | constexpr void // constexpr since C++20 |
| 1682 | make_heap(RandomAccessIterator first, RandomAccessIterator last); | 1689 | make_heap(RandomAccessIterator first, RandomAccessIterator last); |
| 1683 | 1690 | ||
| 1684 | template <class RandomAccessIterator, class Compare> | 1691 | template <class RandomAccessIterator, class Compare> |
| 1685 | constexpr void // constexpr in C++20 | 1692 | constexpr void // constexpr since C++20 |
| 1686 | make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); | 1693 | make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1687 | 1694 | ||
| 1688 | template <class RandomAccessIterator> | 1695 | template <class RandomAccessIterator> |
| 1689 | constexpr void // constexpr in C++20 | 1696 | constexpr void // constexpr since C++20 |
| 1690 | sort_heap(RandomAccessIterator first, RandomAccessIterator last); | 1697 | sort_heap(RandomAccessIterator first, RandomAccessIterator last); |
| 1691 | 1698 | ||
| 1692 | template <class RandomAccessIterator, class Compare> | 1699 | template <class RandomAccessIterator, class Compare> |
| 1693 | constexpr void // constexpr in C++20 | 1700 | constexpr void // constexpr since C++20 |
| 1694 | sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); | 1701 | sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1695 | 1702 | ||
| 1696 | template <class RandomAccessIterator> | 1703 | template <class RandomAccessIterator> |
| 1697 | constexpr bool // constexpr in C++20 | 1704 | constexpr bool // constexpr since C++20 |
| 1698 | is_heap(RandomAccessIterator first, RandomAccessiterator last); | 1705 | is_heap(RandomAccessIterator first, RandomAccessiterator last); |
| 1699 | 1706 | ||
| 1700 | template <class RandomAccessIterator, class Compare> | 1707 | template <class RandomAccessIterator, class Compare> |
| 1701 | constexpr bool // constexpr in C++20 | 1708 | constexpr bool // constexpr since C++20 |
| 1702 | is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp); | 1709 | is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp); |
| 1703 | 1710 | ||
| 1704 | template <class RandomAccessIterator> | 1711 | template <class RandomAccessIterator> |
| 1705 | constexpr RandomAccessIterator // constexpr in C++20 | 1712 | constexpr RandomAccessIterator // constexpr since C++20 |
| 1706 | is_heap_until(RandomAccessIterator first, RandomAccessiterator last); | 1713 | is_heap_until(RandomAccessIterator first, RandomAccessiterator last); |
| 1707 | 1714 | ||
| 1708 | template <class RandomAccessIterator, class Compare> | 1715 | template <class RandomAccessIterator, class Compare> |
| 1709 | constexpr RandomAccessIterator // constexpr in C++20 | 1716 | constexpr RandomAccessIterator // constexpr since C++20 |
| 1710 | is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp); | 1717 | is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp); |
| 1711 | 1718 | ||
| 1712 | template <class ForwardIterator> | 1719 | template <class ForwardIterator> |
| 1713 | constexpr ForwardIterator // constexpr in C++14 | 1720 | constexpr ForwardIterator // constexpr since C++14 |
| 1714 | min_element(ForwardIterator first, ForwardIterator last); | 1721 | min_element(ForwardIterator first, ForwardIterator last); |
| 1715 | 1722 | ||
| 1716 | template <class ForwardIterator, class Compare> | 1723 | template <class ForwardIterator, class Compare> |
| 1717 | constexpr ForwardIterator // constexpr in C++14 | 1724 | constexpr ForwardIterator // constexpr since C++14 |
| 1718 | min_element(ForwardIterator first, ForwardIterator last, Compare comp); | 1725 | min_element(ForwardIterator first, ForwardIterator last, Compare comp); |
| 1719 | 1726 | ||
| 1720 | template <class T> | 1727 | template <class T> |
| 1721 | constexpr const T& // constexpr in C++14 | 1728 | constexpr const T& // constexpr since C++14 |
| 1722 | min(const T& a, const T& b); | 1729 | min(const T& a, const T& b); |
| 1723 | 1730 | ||
| 1724 | template <class T, class Compare> | 1731 | template <class T, class Compare> |
| 1725 | constexpr const T& // constexpr in C++14 | 1732 | constexpr const T& // constexpr since C++14 |
| 1726 | min(const T& a, const T& b, Compare comp); | 1733 | min(const T& a, const T& b, Compare comp); |
| 1727 | 1734 | ||
| 1728 | template<class T> | 1735 | template<class T> |
| 1729 | constexpr T // constexpr in C++14 | 1736 | constexpr T // constexpr since C++14 |
| 1730 | min(initializer_list<T> t); | 1737 | min(initializer_list<T> t); |
| 1731 | 1738 | ||
| 1732 | template<class T, class Compare> | 1739 | template<class T, class Compare> |
| 1733 | constexpr T // constexpr in C++14 | 1740 | constexpr T // constexpr since C++14 |
| 1734 | min(initializer_list<T> t, Compare comp); | 1741 | min(initializer_list<T> t, Compare comp); |
| 1735 | 1742 | ||
| 1736 | template<class T> | 1743 | template<class T> |
| ... | @@ -1740,59 +1747,59 @@ template<class T, class Compare> | ... | @@ -1740,59 +1747,59 @@ template<class T, class Compare> |
| 1740 | constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17 | 1747 | constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17 |
| 1741 | 1748 | ||
| 1742 | template <class ForwardIterator> | 1749 | template <class ForwardIterator> |
| 1743 | constexpr ForwardIterator // constexpr in C++14 | 1750 | constexpr ForwardIterator // constexpr since C++14 |
| 1744 | max_element(ForwardIterator first, ForwardIterator last); | 1751 | max_element(ForwardIterator first, ForwardIterator last); |
| 1745 | 1752 | ||
| 1746 | template <class ForwardIterator, class Compare> | 1753 | template <class ForwardIterator, class Compare> |
| 1747 | constexpr ForwardIterator // constexpr in C++14 | 1754 | constexpr ForwardIterator // constexpr since C++14 |
| 1748 | max_element(ForwardIterator first, ForwardIterator last, Compare comp); | 1755 | max_element(ForwardIterator first, ForwardIterator last, Compare comp); |
| 1749 | 1756 | ||
| 1750 | template <class T> | 1757 | template <class T> |
| 1751 | constexpr const T& // constexpr in C++14 | 1758 | constexpr const T& // constexpr since C++14 |
| 1752 | max(const T& a, const T& b); | 1759 | max(const T& a, const T& b); |
| 1753 | 1760 | ||
| 1754 | template <class T, class Compare> | 1761 | template <class T, class Compare> |
| 1755 | constexpr const T& // constexpr in C++14 | 1762 | constexpr const T& // constexpr since C++14 |
| 1756 | max(const T& a, const T& b, Compare comp); | 1763 | max(const T& a, const T& b, Compare comp); |
| 1757 | 1764 | ||
| 1758 | template<class T> | 1765 | template<class T> |
| 1759 | constexpr T // constexpr in C++14 | 1766 | constexpr T // constexpr since C++14 |
| 1760 | max(initializer_list<T> t); | 1767 | max(initializer_list<T> t); |
| 1761 | 1768 | ||
| 1762 | template<class T, class Compare> | 1769 | template<class T, class Compare> |
| 1763 | constexpr T // constexpr in C++14 | 1770 | constexpr T // constexpr since C++14 |
| 1764 | max(initializer_list<T> t, Compare comp); | 1771 | max(initializer_list<T> t, Compare comp); |
| 1765 | 1772 | ||
| 1766 | template<class ForwardIterator> | 1773 | template<class ForwardIterator> |
| 1767 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14 | 1774 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++14 |
| 1768 | minmax_element(ForwardIterator first, ForwardIterator last); | 1775 | minmax_element(ForwardIterator first, ForwardIterator last); |
| 1769 | 1776 | ||
| 1770 | template<class ForwardIterator, class Compare> | 1777 | template<class ForwardIterator, class Compare> |
| 1771 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14 | 1778 | constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++14 |
| 1772 | minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); | 1779 | minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); |
| 1773 | 1780 | ||
| 1774 | template<class T> | 1781 | template<class T> |
| 1775 | constexpr pair<const T&, const T&> // constexpr in C++14 | 1782 | constexpr pair<const T&, const T&> // constexpr since C++14 |
| 1776 | minmax(const T& a, const T& b); | 1783 | minmax(const T& a, const T& b); |
| 1777 | 1784 | ||
| 1778 | template<class T, class Compare> | 1785 | template<class T, class Compare> |
| 1779 | constexpr pair<const T&, const T&> // constexpr in C++14 | 1786 | constexpr pair<const T&, const T&> // constexpr since C++14 |
| 1780 | minmax(const T& a, const T& b, Compare comp); | 1787 | minmax(const T& a, const T& b, Compare comp); |
| 1781 | 1788 | ||
| 1782 | template<class T> | 1789 | template<class T> |
| 1783 | constexpr pair<T, T> // constexpr in C++14 | 1790 | constexpr pair<T, T> // constexpr since C++14 |
| 1784 | minmax(initializer_list<T> t); | 1791 | minmax(initializer_list<T> t); |
| 1785 | 1792 | ||
| 1786 | template<class T, class Compare> | 1793 | template<class T, class Compare> |
| 1787 | constexpr pair<T, T> // constexpr in C++14 | 1794 | constexpr pair<T, T> // constexpr since C++14 |
| 1788 | minmax(initializer_list<T> t, Compare comp); | 1795 | minmax(initializer_list<T> t, Compare comp); |
| 1789 | 1796 | ||
| 1790 | template <class InputIterator1, class InputIterator2> | 1797 | template <class InputIterator1, class InputIterator2> |
| 1791 | constexpr bool // constexpr in C++20 | 1798 | constexpr bool // constexpr since C++20 |
| 1792 | lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); | 1799 | lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2); |
| 1793 | 1800 | ||
| 1794 | template <class InputIterator1, class InputIterator2, class Compare> | 1801 | template <class InputIterator1, class InputIterator2, class Compare> |
| 1795 | constexpr bool // constexpr in C++20 | 1802 | constexpr bool // constexpr since C++20 |
| 1796 | lexicographical_compare(InputIterator1 first1, InputIterator1 last1, | 1803 | lexicographical_compare(InputIterator1 first1, InputIterator1 last1, |
| 1797 | InputIterator2 first2, InputIterator2 last2, Compare comp); | 1804 | InputIterator2 first2, InputIterator2 last2, Compare comp); |
| 1798 | 1805 | ||
| ... | @@ -1809,19 +1816,19 @@ template<class InputIterator1, class InputIterator2> | ... | @@ -1809,19 +1816,19 @@ template<class InputIterator1, class InputIterator2> |
| 1809 | InputIterator2 first2, InputIterator2 last2); // since C++20 | 1816 | InputIterator2 first2, InputIterator2 last2); // since C++20 |
| 1810 | 1817 | ||
| 1811 | template <class BidirectionalIterator> | 1818 | template <class BidirectionalIterator> |
| 1812 | constexpr bool // constexpr in C++20 | 1819 | constexpr bool // constexpr since C++20 |
| 1813 | next_permutation(BidirectionalIterator first, BidirectionalIterator last); | 1820 | next_permutation(BidirectionalIterator first, BidirectionalIterator last); |
| 1814 | 1821 | ||
| 1815 | template <class BidirectionalIterator, class Compare> | 1822 | template <class BidirectionalIterator, class Compare> |
| 1816 | constexpr bool // constexpr in C++20 | 1823 | constexpr bool // constexpr since C++20 |
| 1817 | next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); | 1824 | next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); |
| 1818 | 1825 | ||
| 1819 | template <class BidirectionalIterator> | 1826 | template <class BidirectionalIterator> |
| 1820 | constexpr bool // constexpr in C++20 | 1827 | constexpr bool // constexpr since C++20 |
| 1821 | prev_permutation(BidirectionalIterator first, BidirectionalIterator last); | 1828 | prev_permutation(BidirectionalIterator first, BidirectionalIterator last); |
| 1822 | 1829 | ||
| 1823 | template <class BidirectionalIterator, class Compare> | 1830 | template <class BidirectionalIterator, class Compare> |
| 1824 | constexpr bool // constexpr in C++20 | 1831 | constexpr bool // constexpr since C++20 |
| 1825 | prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); | 1832 | prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); |
| 1826 | } // std | 1833 | } // std |
| 1827 | 1834 | ||
| ... | @@ -1932,6 +1939,7 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1932,6 +1939,7 @@ template <class BidirectionalIterator, class Compare> |
| 1932 | # include <__algorithm/in_out_result.h> | 1939 | # include <__algorithm/in_out_result.h> |
| 1933 | # include <__algorithm/lexicographical_compare_three_way.h> | 1940 | # include <__algorithm/lexicographical_compare_three_way.h> |
| 1934 | # include <__algorithm/min_max_result.h> | 1941 | # include <__algorithm/min_max_result.h> |
| 1942 | # include <__algorithm/out_value_result.h> | ||
| 1935 | # include <__algorithm/ranges_adjacent_find.h> | 1943 | # include <__algorithm/ranges_adjacent_find.h> |
| 1936 | # include <__algorithm/ranges_all_of.h> | 1944 | # include <__algorithm/ranges_all_of.h> |
| 1937 | # include <__algorithm/ranges_any_of.h> | 1945 | # include <__algorithm/ranges_any_of.h> |
| ... | @@ -2053,6 +2061,7 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -2053,6 +2061,7 @@ template <class BidirectionalIterator, class Compare> |
| 2053 | # include <cstring> | 2061 | # include <cstring> |
| 2054 | # include <iterator> | 2062 | # include <iterator> |
| 2055 | # include <memory> | 2063 | # include <memory> |
| 2064 | # include <optional> | ||
| 2056 | # include <stdexcept> | 2065 | # include <stdexcept> |
| 2057 | # include <type_traits> | 2066 | # include <type_traits> |
| 2058 | # include <utility> | 2067 | # include <utility> |
lib/libcxx/include/any+16-16| ... | @@ -81,7 +81,7 @@ namespace std { | ... | @@ -81,7 +81,7 @@ namespace std { |
| 81 | */ | 81 | */ |
| 82 | 82 | ||
| 83 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 83 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 84 | # include <__cxx03/any> | 84 | # include <__cxx03/__config> |
| 85 | #else | 85 | #else |
| 86 | # include <__config> | 86 | # include <__config> |
| 87 | # include <__memory/allocator.h> | 87 | # include <__memory/allocator.h> |
| ... | @@ -119,18 +119,18 @@ namespace std { | ... | @@ -119,18 +119,18 @@ namespace std { |
| 119 | _LIBCPP_PUSH_MACROS | 119 | _LIBCPP_PUSH_MACROS |
| 120 | # include <__undef_macros> | 120 | # include <__undef_macros> |
| 121 | 121 | ||
| 122 | namespace std { | 122 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 123 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast { | 123 | class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast { |
| 124 | public: | 124 | public: |
| 125 | const char* what() const _NOEXCEPT override; | 125 | const char* what() const _NOEXCEPT override; |
| 126 | }; | 126 | }; |
| 127 | } // namespace std | 127 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 128 | 128 | ||
| 129 | _LIBCPP_BEGIN_NAMESPACE_STD | 129 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 130 | 130 | ||
| 131 | # if _LIBCPP_STD_VER >= 17 | 131 | # if _LIBCPP_STD_VER >= 17 |
| 132 | 132 | ||
| 133 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { | 133 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_any_cast() { |
| 134 | # if _LIBCPP_HAS_EXCEPTIONS | 134 | # if _LIBCPP_HAS_EXCEPTIONS |
| 135 | throw bad_any_cast(); | 135 | throw bad_any_cast(); |
| 136 | # else | 136 | # else |
| ... | @@ -139,7 +139,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -139,7 +139,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | // Forward declarations | 141 | // Forward declarations |
| 142 | class _LIBCPP_TEMPLATE_VIS 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; |
| ... | @@ -166,7 +166,7 @@ template <class _Tp> | ... | @@ -166,7 +166,7 @@ template <class _Tp> |
| 166 | struct _LargeHandler; | 166 | struct _LargeHandler; |
| 167 | 167 | ||
| 168 | template <class _Tp> | 168 | template <class _Tp> |
| 169 | struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { | 169 | struct __unique_typeinfo { |
| 170 | static constexpr int __id = 0; | 170 | static constexpr int __id = 0; |
| 171 | }; | 171 | }; |
| 172 | 172 | ||
| ... | @@ -189,7 +189,7 @@ using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _Sma | ... | @@ -189,7 +189,7 @@ using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _Sma |
| 189 | 189 | ||
| 190 | } // namespace __any_imp | 190 | } // namespace __any_imp |
| 191 | 191 | ||
| 192 | class _LIBCPP_TEMPLATE_VIS any { | 192 | class any { |
| 193 | public: | 193 | public: |
| 194 | // construct/destruct | 194 | // construct/destruct |
| 195 | _LIBCPP_HIDE_FROM_ABI constexpr any() _NOEXCEPT : __h_(nullptr) {} | 195 | _LIBCPP_HIDE_FROM_ABI constexpr any() _NOEXCEPT : __h_(nullptr) {} |
| ... | @@ -316,7 +316,7 @@ private: | ... | @@ -316,7 +316,7 @@ private: |
| 316 | 316 | ||
| 317 | namespace __any_imp { | 317 | namespace __any_imp { |
| 318 | template <class _Tp> | 318 | template <class _Tp> |
| 319 | struct _LIBCPP_TEMPLATE_VIS _SmallHandler { | 319 | struct _SmallHandler { |
| 320 | _LIBCPP_HIDE_FROM_ABI static void* | 320 | _LIBCPP_HIDE_FROM_ABI static void* |
| 321 | __handle(_Action __act, any const* __this, any* __other, type_info const* __info, const void* __fallback_info) { | 321 | __handle(_Action __act, any const* __this, any* __other, type_info const* __info, const void* __fallback_info) { |
| 322 | switch (__act) { | 322 | switch (__act) { |
| ... | @@ -383,7 +383,7 @@ private: | ... | @@ -383,7 +383,7 @@ private: |
| 383 | }; | 383 | }; |
| 384 | 384 | ||
| 385 | template <class _Tp> | 385 | template <class _Tp> |
| 386 | struct _LIBCPP_TEMPLATE_VIS _LargeHandler { | 386 | struct _LargeHandler { |
| 387 | _LIBCPP_HIDE_FROM_ABI static void* | 387 | _LIBCPP_HIDE_FROM_ABI static void* |
| 388 | __handle(_Action __act, any const* __this, any* __other, type_info const* __info, void const* __fallback_info) { | 388 | __handle(_Action __act, any const* __this, any* __other, type_info const* __info, void const* __fallback_info) { |
| 389 | switch (__act) { | 389 | switch (__act) { |
| ... | @@ -519,38 +519,38 @@ inline _LIBCPP_HIDE_FROM_ABI any make_any(initializer_list<_Up> __il, _Args&&... | ... | @@ -519,38 +519,38 @@ inline _LIBCPP_HIDE_FROM_ABI any make_any(initializer_list<_Up> __il, _Args&&... |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | template <class _ValueType> | 521 | template <class _ValueType> |
| 522 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any const& __v) { | 522 | inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any const& __v) { |
| 523 | using _RawValueType = __remove_cvref_t<_ValueType>; | 523 | using _RawValueType = __remove_cvref_t<_ValueType>; |
| 524 | static_assert(is_constructible<_ValueType, _RawValueType const&>::value, | 524 | static_assert(is_constructible<_ValueType, _RawValueType const&>::value, |
| 525 | "ValueType is required to be a const lvalue reference " | 525 | "ValueType is required to be a const lvalue reference " |
| 526 | "or a CopyConstructible type"); | 526 | "or a CopyConstructible type"); |
| 527 | auto __tmp = std::any_cast<add_const_t<_RawValueType>>(&__v); | 527 | auto __tmp = std::any_cast<add_const_t<_RawValueType>>(&__v); |
| 528 | if (__tmp == nullptr) | 528 | if (__tmp == nullptr) |
| 529 | __throw_bad_any_cast(); | 529 | std::__throw_bad_any_cast(); |
| 530 | return static_cast<_ValueType>(*__tmp); | 530 | return static_cast<_ValueType>(*__tmp); |
| 531 | } | 531 | } |
| 532 | 532 | ||
| 533 | template <class _ValueType> | 533 | template <class _ValueType> |
| 534 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any& __v) { | 534 | inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any& __v) { |
| 535 | using _RawValueType = __remove_cvref_t<_ValueType>; | 535 | using _RawValueType = __remove_cvref_t<_ValueType>; |
| 536 | static_assert(is_constructible<_ValueType, _RawValueType&>::value, | 536 | static_assert(is_constructible<_ValueType, _RawValueType&>::value, |
| 537 | "ValueType is required to be an lvalue reference " | 537 | "ValueType is required to be an lvalue reference " |
| 538 | "or a CopyConstructible type"); | 538 | "or a CopyConstructible type"); |
| 539 | auto __tmp = std::any_cast<_RawValueType>(&__v); | 539 | auto __tmp = std::any_cast<_RawValueType>(&__v); |
| 540 | if (__tmp == nullptr) | 540 | if (__tmp == nullptr) |
| 541 | __throw_bad_any_cast(); | 541 | std::__throw_bad_any_cast(); |
| 542 | return static_cast<_ValueType>(*__tmp); | 542 | return static_cast<_ValueType>(*__tmp); |
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | template <class _ValueType> | 545 | template <class _ValueType> |
| 546 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any&& __v) { | 546 | inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any&& __v) { |
| 547 | using _RawValueType = __remove_cvref_t<_ValueType>; | 547 | using _RawValueType = __remove_cvref_t<_ValueType>; |
| 548 | static_assert(is_constructible<_ValueType, _RawValueType>::value, | 548 | static_assert(is_constructible<_ValueType, _RawValueType>::value, |
| 549 | "ValueType is required to be an rvalue reference " | 549 | "ValueType is required to be an rvalue reference " |
| 550 | "or a CopyConstructible type"); | 550 | "or a CopyConstructible type"); |
| 551 | auto __tmp = std::any_cast<_RawValueType>(&__v); | 551 | auto __tmp = std::any_cast<_RawValueType>(&__v); |
| 552 | if (__tmp == nullptr) | 552 | if (__tmp == nullptr) |
| 553 | __throw_bad_any_cast(); | 553 | std::__throw_bad_any_cast(); |
| 554 | return static_cast<_ValueType>(std::move(*__tmp)); | 554 | return static_cast<_ValueType>(std::move(*__tmp)); |
| 555 | } | 555 | } |
| 556 | 556 |
lib/libcxx/include/array+12-9| ... | @@ -134,6 +134,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce | ... | @@ -134,6 +134,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce |
| 134 | # include <__type_traits/is_const.h> | 134 | # include <__type_traits/is_const.h> |
| 135 | # include <__type_traits/is_constructible.h> | 135 | # include <__type_traits/is_constructible.h> |
| 136 | # include <__type_traits/is_nothrow_constructible.h> | 136 | # include <__type_traits/is_nothrow_constructible.h> |
| 137 | # include <__type_traits/is_replaceable.h> | ||
| 137 | # include <__type_traits/is_same.h> | 138 | # include <__type_traits/is_same.h> |
| 138 | # include <__type_traits/is_swappable.h> | 139 | # include <__type_traits/is_swappable.h> |
| 139 | # include <__type_traits/is_trivially_relocatable.h> | 140 | # include <__type_traits/is_trivially_relocatable.h> |
| ... | @@ -172,9 +173,10 @@ _LIBCPP_PUSH_MACROS | ... | @@ -172,9 +173,10 @@ _LIBCPP_PUSH_MACROS |
| 172 | _LIBCPP_BEGIN_NAMESPACE_STD | 173 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 173 | 174 | ||
| 174 | template <class _Tp, size_t _Size> | 175 | template <class _Tp, size_t _Size> |
| 175 | struct _LIBCPP_TEMPLATE_VIS array { | 176 | struct array { |
| 176 | using __trivially_relocatable _LIBCPP_NODEBUG = | 177 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 177 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; | 178 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; |
| 179 | using __replaceable _LIBCPP_NODEBUG = __conditional_t<__is_replaceable_v<_Tp>, array, void>; | ||
| 178 | 180 | ||
| 179 | // types: | 181 | // types: |
| 180 | using __self _LIBCPP_NODEBUG = array; | 182 | using __self _LIBCPP_NODEBUG = array; |
| ... | @@ -276,13 +278,13 @@ struct _LIBCPP_TEMPLATE_VIS array { | ... | @@ -276,13 +278,13 @@ struct _LIBCPP_TEMPLATE_VIS array { |
| 276 | 278 | ||
| 277 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) { | 279 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) { |
| 278 | if (__n >= _Size) | 280 | if (__n >= _Size) |
| 279 | __throw_out_of_range("array::at"); | 281 | std::__throw_out_of_range("array::at"); |
| 280 | return __elems_[__n]; | 282 | return __elems_[__n]; |
| 281 | } | 283 | } |
| 282 | 284 | ||
| 283 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const { | 285 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const { |
| 284 | if (__n >= _Size) | 286 | if (__n >= _Size) |
| 285 | __throw_out_of_range("array::at"); | 287 | std::__throw_out_of_range("array::at"); |
| 286 | return __elems_[__n]; | 288 | return __elems_[__n]; |
| 287 | } | 289 | } |
| 288 | 290 | ||
| ... | @@ -298,7 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS array { | ... | @@ -298,7 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS array { |
| 298 | }; | 300 | }; |
| 299 | 301 | ||
| 300 | template <class _Tp> | 302 | template <class _Tp> |
| 301 | struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { | 303 | struct array<_Tp, 0> { |
| 302 | // types: | 304 | // types: |
| 303 | using __self _LIBCPP_NODEBUG = array; | 305 | using __self _LIBCPP_NODEBUG = array; |
| 304 | using value_type = _Tp; | 306 | using value_type = _Tp; |
| ... | @@ -407,12 +409,12 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { | ... | @@ -407,12 +409,12 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { |
| 407 | } | 409 | } |
| 408 | 410 | ||
| 409 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) { | 411 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) { |
| 410 | __throw_out_of_range("array<T, 0>::at"); | 412 | std::__throw_out_of_range("array<T, 0>::at"); |
| 411 | __libcpp_unreachable(); | 413 | __libcpp_unreachable(); |
| 412 | } | 414 | } |
| 413 | 415 | ||
| 414 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const { | 416 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const { |
| 415 | __throw_out_of_range("array<T, 0>::at"); | 417 | std::__throw_out_of_range("array<T, 0>::at"); |
| 416 | __libcpp_unreachable(); | 418 | __libcpp_unreachable(); |
| 417 | } | 419 | } |
| 418 | 420 | ||
| ... | @@ -492,12 +494,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, | ... | @@ -492,12 +494,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, |
| 492 | } | 494 | } |
| 493 | 495 | ||
| 494 | template <class _Tp, size_t _Size> | 496 | template <class _Tp, size_t _Size> |
| 495 | struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {}; | 497 | struct tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {}; |
| 496 | 498 | ||
| 497 | template <size_t _Ip, class _Tp, size_t _Size> | 499 | template <size_t _Ip, class _Tp, size_t _Size> |
| 498 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > { | 500 | struct tuple_element<_Ip, array<_Tp, _Size> > { |
| 499 | static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)"); | 501 | static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)"); |
| 500 | using type = _Tp; | 502 | using type _LIBCPP_NODEBUG = _Tp; |
| 501 | }; | 503 | }; |
| 502 | 504 | ||
| 503 | template <size_t _Ip, class _Tp, size_t _Size> | 505 | template <size_t _Ip, class _Tp, size_t _Size> |
| ... | @@ -566,6 +568,7 @@ _LIBCPP_POP_MACROS | ... | @@ -566,6 +568,7 @@ _LIBCPP_POP_MACROS |
| 566 | # include <cstdlib> | 568 | # include <cstdlib> |
| 567 | # include <iterator> | 569 | # include <iterator> |
| 568 | # include <new> | 570 | # include <new> |
| 571 | # include <optional> | ||
| 569 | # include <type_traits> | 572 | # include <type_traits> |
| 570 | # include <utility> | 573 | # include <utility> |
| 571 | # endif | 574 | # endif |
lib/libcxx/include/barrier+1-1| ... | @@ -46,7 +46,7 @@ namespace std | ... | @@ -46,7 +46,7 @@ namespace std |
| 46 | */ | 46 | */ |
| 47 | 47 | ||
| 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 49 | # include <__cxx03/barrier> | 49 | # include <__cxx03/__config> |
| 50 | #else | 50 | #else |
| 51 | # include <__config> | 51 | # include <__config> |
| 52 | 52 |
lib/libcxx/include/bit+1-1| ... | @@ -62,7 +62,7 @@ namespace std { | ... | @@ -62,7 +62,7 @@ namespace std { |
| 62 | */ | 62 | */ |
| 63 | 63 | ||
| 64 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 64 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 65 | # include <__cxx03/bit> | 65 | # include <__cxx03/__config> |
| 66 | #else | 66 | #else |
| 67 | # include <__config> | 67 | # include <__config> |
| 68 | 68 |
lib/libcxx/include/bitset+183-199| ... | @@ -129,18 +129,29 @@ template <size_t N> struct hash<std::bitset<N>>; | ... | @@ -129,18 +129,29 @@ template <size_t N> struct hash<std::bitset<N>>; |
| 129 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 129 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 130 | # include <__cxx03/bitset> | 130 | # include <__cxx03/bitset> |
| 131 | #else | 131 | #else |
| 132 | # include <__algorithm/copy.h> | ||
| 133 | # include <__algorithm/copy_backward.h> | ||
| 132 | # include <__algorithm/count.h> | 134 | # include <__algorithm/count.h> |
| 135 | # include <__algorithm/equal.h> | ||
| 133 | # include <__algorithm/fill.h> | 136 | # include <__algorithm/fill.h> |
| 134 | # include <__algorithm/fill_n.h> | 137 | # include <__algorithm/fill_n.h> |
| 135 | # include <__algorithm/find.h> | 138 | # include <__algorithm/find.h> |
| 139 | # include <__algorithm/min.h> | ||
| 136 | # include <__assert> | 140 | # include <__assert> |
| 141 | # include <__bit/countr.h> | ||
| 142 | # include <__bit/invert_if.h> | ||
| 137 | # include <__bit_reference> | 143 | # include <__bit_reference> |
| 138 | # include <__config> | 144 | # include <__config> |
| 139 | # include <__cstddef/ptrdiff_t.h> | 145 | # include <__cstddef/ptrdiff_t.h> |
| 140 | # include <__cstddef/size_t.h> | 146 | # include <__cstddef/size_t.h> |
| 141 | # include <__functional/hash.h> | 147 | # include <__functional/hash.h> |
| 148 | # include <__functional/identity.h> | ||
| 142 | # include <__functional/unary_function.h> | 149 | # include <__functional/unary_function.h> |
| 150 | # include <__tuple/tuple_indices.h> | ||
| 151 | # include <__type_traits/enable_if.h> | ||
| 152 | # include <__type_traits/integral_constant.h> | ||
| 143 | # include <__type_traits/is_char_like_type.h> | 153 | # include <__type_traits/is_char_like_type.h> |
| 154 | # include <__utility/integer_sequence.h> | ||
| 144 | # include <climits> | 155 | # include <climits> |
| 145 | # include <stdexcept> | 156 | # include <stdexcept> |
| 146 | # include <string_view> | 157 | # include <string_view> |
| ... | @@ -214,28 +225,98 @@ protected: | ... | @@ -214,28 +225,98 @@ protected: |
| 214 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT; | 225 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT; |
| 215 | 226 | ||
| 216 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT; | 227 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT; |
| 228 | |||
| 217 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { | 229 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { |
| 218 | return to_ulong(integral_constant < bool, _Size< sizeof(unsigned long) * CHAR_BIT>()); | 230 | if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long) * CHAR_BIT) { |
| 231 | if (auto __e = __make_iter(_Size); std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true) != __e) | ||
| 232 | std::__throw_overflow_error("__bitset<_N_words, _Size>::to_ulong overflow error"); | ||
| 233 | } | ||
| 234 | |||
| 235 | static_assert(sizeof(__storage_type) >= sizeof(unsigned long), | ||
| 236 | "libc++ only supports platforms where sizeof(size_t) >= sizeof(unsigned long), such as 32-bit and " | ||
| 237 | "64-bit platforms. If you're interested in supporting a platform where that is not the case, please " | ||
| 238 | "contact the libc++ developers."); | ||
| 239 | return static_cast<unsigned long>(__first_[0]); | ||
| 219 | } | 240 | } |
| 241 | |||
| 220 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { | 242 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { |
| 221 | return to_ullong(integral_constant < bool, _Size< sizeof(unsigned long long) * CHAR_BIT>()); | 243 | // Check for overflow if _Size does not fit in unsigned long long |
| 244 | if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long long) * CHAR_BIT) { | ||
| 245 | if (auto __e = __make_iter(_Size); | ||
| 246 | std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true) != __e) | ||
| 247 | std::__throw_overflow_error("__bitset<_N_words, _Size>::to_ullong overflow error"); | ||
| 248 | } | ||
| 249 | |||
| 250 | // At this point, the effective bitset size (excluding leading zeros) fits in unsigned long long | ||
| 251 | |||
| 252 | if _LIBCPP_CONSTEXPR (sizeof(__storage_type) >= sizeof(unsigned long long)) { | ||
| 253 | // If __storage_type is at least as large as unsigned long long, the result spans only one word | ||
| 254 | return static_cast<unsigned long long>(__first_[0]); | ||
| 255 | } else { | ||
| 256 | // Otherwise, the result spans multiple words which are concatenated | ||
| 257 | const size_t __ull_words = (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1; | ||
| 258 | const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words; | ||
| 259 | unsigned long long __r = static_cast<unsigned long long>(__first_[0]); | ||
| 260 | for (size_t __i = 1; __i < __n_words; ++__i) | ||
| 261 | __r |= static_cast<unsigned long long>(__first_[__i]) << (__bits_per_word * __i); | ||
| 262 | return __r; | ||
| 263 | } | ||
| 222 | } | 264 | } |
| 223 | 265 | ||
| 224 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT; | 266 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return !__scan_bits(__bit_not()); } |
| 225 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT; | 267 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { |
| 268 | return __scan_bits(std::__identity()); | ||
| 269 | } | ||
| 226 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT; | 270 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT; |
| 227 | 271 | ||
| 272 | template <bool _Sparse, class _CharT, class _Traits, class _Allocator> | ||
| 273 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> | ||
| 274 | __to_string(_CharT __zero, _CharT __one) const { | ||
| 275 | basic_string<_CharT, _Traits, _Allocator> __r(_Size, _Sparse ? __zero : __one); | ||
| 276 | for (size_t __i = 0, __bits = 0; __i < _N_words; ++__i, __bits += __bits_per_word) { | ||
| 277 | __storage_type __word = std::__invert_if<!_Sparse>(__first_[__i]); | ||
| 278 | if (__i == _N_words - 1 && _Size - __bits < __bits_per_word) | ||
| 279 | __word &= (__storage_type(1) << (_Size - __bits)) - 1; | ||
| 280 | for (; __word; __word &= (__word - 1)) | ||
| 281 | __r[_Size - 1 - (__bits + std::__countr_zero(__word))] = _Sparse ? __one : __zero; | ||
| 282 | } | ||
| 283 | |||
| 284 | return __r; | ||
| 285 | } | ||
| 286 | |||
| 228 | private: | 287 | private: |
| 288 | struct __bit_not { | ||
| 289 | template <class _Tp> | ||
| 290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp operator()(const _Tp& __x) const _NOEXCEPT { | ||
| 291 | return ~__x; | ||
| 292 | } | ||
| 293 | }; | ||
| 294 | |||
| 295 | template <typename _Proj> | ||
| 296 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __scan_bits(_Proj __proj) const _NOEXCEPT { | ||
| 297 | size_t __n = _Size; | ||
| 298 | __const_storage_pointer __p = __first_; | ||
| 299 | // do middle whole words | ||
| 300 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | ||
| 301 | if (__proj(*__p)) | ||
| 302 | return true; | ||
| 303 | // do last partial word | ||
| 304 | if (__n > 0) { | ||
| 305 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 306 | if (__proj(*__p) & __m) | ||
| 307 | return true; | ||
| 308 | } | ||
| 309 | return false; | ||
| 310 | } | ||
| 311 | |||
| 229 | # ifdef _LIBCPP_CXX03_LANG | 312 | # ifdef _LIBCPP_CXX03_LANG |
| 230 | void __init(unsigned long long __v, false_type) _NOEXCEPT; | 313 | void __init(unsigned long long __v, false_type) _NOEXCEPT; |
| 231 | _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT; | 314 | _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT; |
| 315 | # else | ||
| 316 | template <size_t... _Indices> | ||
| 317 | _LIBCPP_HIDE_FROM_ABI constexpr __bitset(unsigned long long __v, std::__tuple_indices<_Indices...>) _NOEXCEPT | ||
| 318 | : __first_{static_cast<__storage_type>(__v >> (_Indices * __bits_per_word))...} {} | ||
| 232 | # endif // _LIBCPP_CXX03_LANG | 319 | # endif // _LIBCPP_CXX03_LANG |
| 233 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const; | ||
| 234 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const; | ||
| 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const; | ||
| 236 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type) const; | ||
| 237 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, false_type) const; | ||
| 238 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, true_type) const; | ||
| 239 | }; | 320 | }; |
| 240 | 321 | ||
| 241 | template <size_t _N_words, size_t _Size> | 322 | template <size_t _N_words, size_t _Size> |
| ... | @@ -253,26 +334,16 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT | ... | @@ -253,26 +334,16 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT |
| 253 | 334 | ||
| 254 | template <size_t _N_words, size_t _Size> | 335 | template <size_t _N_words, size_t _Size> |
| 255 | void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT { | 336 | void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT { |
| 256 | __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)]; | 337 | const size_t __n_words = std::min((sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1, _N_words); |
| 257 | size_t __sz = _Size; | 338 | for (size_t __i = 0; __i < __n_words; ++__i, __v >>= __bits_per_word) |
| 258 | for (size_t __i = 0; __i < sizeof(__t) / sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word) | 339 | __first_[__i] = static_cast<__storage_type>(__v); |
| 259 | if (__sz < __bits_per_word) | 340 | std::fill(__first_ + __n_words, __first_ + _N_words, __storage_type(0)); |
| 260 | __t[__i] = static_cast<__storage_type>(__v) & (1ULL << __sz) - 1; | ||
| 261 | else | ||
| 262 | __t[__i] = static_cast<__storage_type>(__v); | ||
| 263 | |||
| 264 | std::copy(__t, __t + sizeof(__t) / sizeof(__t[0]), __first_); | ||
| 265 | std::fill( | ||
| 266 | __first_ + sizeof(__t) / sizeof(__t[0]), __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0)); | ||
| 267 | } | 341 | } |
| 268 | 342 | ||
| 269 | template <size_t _N_words, size_t _Size> | 343 | template <size_t _N_words, size_t _Size> |
| 270 | inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT { | 344 | inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT { |
| 271 | __first_[0] = __v; | 345 | __first_[0] = __v; |
| 272 | if (_Size < __bits_per_word) | 346 | std::fill(__first_ + 1, __first_ + _N_words, __storage_type(0)); |
| 273 | __first_[0] &= (1ULL << _Size) - 1; | ||
| 274 | |||
| 275 | std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0)); | ||
| 276 | } | 347 | } |
| 277 | 348 | ||
| 278 | # endif // _LIBCPP_CXX03_LANG | 349 | # endif // _LIBCPP_CXX03_LANG |
| ... | @@ -280,21 +351,15 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon | ... | @@ -280,21 +351,15 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon |
| 280 | template <size_t _N_words, size_t _Size> | 351 | template <size_t _N_words, size_t _Size> |
| 281 | inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT | 352 | inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT |
| 282 | # ifndef _LIBCPP_CXX03_LANG | 353 | # ifndef _LIBCPP_CXX03_LANG |
| 283 | # if __SIZEOF_SIZE_T__ == 8 | 354 | : __bitset(__v, |
| 284 | : __first_{__v} | 355 | std::__make_indices_imp< (_N_words < (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1) |
| 285 | # elif __SIZEOF_SIZE_T__ == 4 | 356 | ? _N_words |
| 286 | : __first_{static_cast<__storage_type>(__v), | 357 | : (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1, |
| 287 | _Size >= 2 * __bits_per_word | 358 | 0>{}) |
| 288 | ? static_cast<__storage_type>(__v >> __bits_per_word) | ||
| 289 | : static_cast<__storage_type>((__v >> __bits_per_word) & | ||
| 290 | (__storage_type(1) << (_Size - __bits_per_word)) - 1)} | ||
| 291 | # else | ||
| 292 | # error This constructor has not been ported to this platform | ||
| 293 | # endif | ||
| 294 | # endif | 359 | # endif |
| 295 | { | 360 | { |
| 296 | # ifdef _LIBCPP_CXX03_LANG | 361 | # ifdef _LIBCPP_CXX03_LANG |
| 297 | __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>()); | 362 | __init(__v, _BoolConstant<sizeof(unsigned long long) <= sizeof(__storage_type)>()); |
| 298 | # endif | 363 | # endif |
| 299 | } | 364 | } |
| 300 | 365 | ||
| ... | @@ -327,98 +392,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz | ... | @@ -327,98 +392,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz |
| 327 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | 392 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) |
| 328 | *__p = ~*__p; | 393 | *__p = ~*__p; |
| 329 | // do last partial word | 394 | // do last partial word |
| 330 | if (__n > 0) { | 395 | // Ensure trailing padding bits are zeroed as part of the ABI for consistent hashing behavior. std::hash<bitset> |
| 331 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | 396 | // assumes trailing bits are zeroed; otherwise, identical bitsets could hash differently. |
| 332 | __storage_type __b = *__p & __m; | 397 | if (__n > 0) |
| 333 | *__p &= ~__m; | 398 | *__p ^= (__storage_type(1) << __n) - 1; |
| 334 | *__p |= ~__b & __m; | ||
| 335 | } | ||
| 336 | } | ||
| 337 | |||
| 338 | template <size_t _N_words, size_t _Size> | ||
| 339 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long | ||
| 340 | __bitset<_N_words, _Size>::to_ulong(false_type) const { | ||
| 341 | __const_iterator __e = __make_iter(_Size); | ||
| 342 | __const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); | ||
| 343 | if (__i != __e) | ||
| 344 | __throw_overflow_error("bitset to_ulong overflow error"); | ||
| 345 | |||
| 346 | return __first_[0]; | ||
| 347 | } | ||
| 348 | |||
| 349 | template <size_t _N_words, size_t _Size> | ||
| 350 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long | ||
| 351 | __bitset<_N_words, _Size>::to_ulong(true_type) const { | ||
| 352 | return __first_[0]; | ||
| 353 | } | ||
| 354 | |||
| 355 | template <size_t _N_words, size_t _Size> | ||
| 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long | ||
| 357 | __bitset<_N_words, _Size>::to_ullong(false_type) const { | ||
| 358 | __const_iterator __e = __make_iter(_Size); | ||
| 359 | __const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); | ||
| 360 | if (__i != __e) | ||
| 361 | __throw_overflow_error("bitset to_ullong overflow error"); | ||
| 362 | |||
| 363 | return to_ullong(true_type()); | ||
| 364 | } | ||
| 365 | |||
| 366 | template <size_t _N_words, size_t _Size> | ||
| 367 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long | ||
| 368 | __bitset<_N_words, _Size>::to_ullong(true_type) const { | ||
| 369 | return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>()); | ||
| 370 | } | ||
| 371 | |||
| 372 | template <size_t _N_words, size_t _Size> | ||
| 373 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long | ||
| 374 | __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const { | ||
| 375 | return __first_[0]; | ||
| 376 | } | ||
| 377 | |||
| 378 | template <size_t _N_words, size_t _Size> | ||
| 379 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long | ||
| 380 | __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const { | ||
| 381 | unsigned long long __r = __first_[0]; | ||
| 382 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 383 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow") | ||
| 384 | for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i) | ||
| 385 | __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT); | ||
| 386 | _LIBCPP_DIAGNOSTIC_POP | ||
| 387 | return __r; | ||
| 388 | } | ||
| 389 | |||
| 390 | template <size_t _N_words, size_t _Size> | ||
| 391 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT { | ||
| 392 | // do middle whole words | ||
| 393 | size_t __n = _Size; | ||
| 394 | __const_storage_pointer __p = __first_; | ||
| 395 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | ||
| 396 | if (~*__p) | ||
| 397 | return false; | ||
| 398 | // do last partial word | ||
| 399 | if (__n > 0) { | ||
| 400 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 401 | if (~*__p & __m) | ||
| 402 | return false; | ||
| 403 | } | ||
| 404 | return true; | ||
| 405 | } | ||
| 406 | |||
| 407 | template <size_t _N_words, size_t _Size> | ||
| 408 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT { | ||
| 409 | // do middle whole words | ||
| 410 | size_t __n = _Size; | ||
| 411 | __const_storage_pointer __p = __first_; | ||
| 412 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | ||
| 413 | if (*__p) | ||
| 414 | return true; | ||
| 415 | // do last partial word | ||
| 416 | if (__n > 0) { | ||
| 417 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | ||
| 418 | if (*__p & __m) | ||
| 419 | return true; | ||
| 420 | } | ||
| 421 | return false; | ||
| 422 | } | 399 | } |
| 423 | 400 | ||
| 424 | template <size_t _N_words, size_t _Size> | 401 | template <size_t _N_words, size_t _Size> |
| ... | @@ -463,10 +440,14 @@ protected: | ... | @@ -463,10 +440,14 @@ protected: |
| 463 | return __const_reference(&__first_, __storage_type(1) << __pos); | 440 | return __const_reference(&__first_, __storage_type(1) << __pos); |
| 464 | } | 441 | } |
| 465 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT { | 442 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT { |
| 466 | return __iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | 443 | // Allow the == case to accommodate the past-the-end iterator. |
| 444 | _LIBCPP_ASSERT_INTERNAL(__pos <= __bits_per_word, "Out of bounds access in the single-word bitset implementation."); | ||
| 445 | return __pos != __bits_per_word ? __iterator(&__first_, __pos) : __iterator(&__first_ + 1, 0); | ||
| 467 | } | 446 | } |
| 468 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT { | 447 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT { |
| 469 | return __const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | 448 | // Allow the == case to accommodate the past-the-end iterator. |
| 449 | _LIBCPP_ASSERT_INTERNAL(__pos <= __bits_per_word, "Out of bounds access in the single-word bitset implementation."); | ||
| 450 | return __pos != __bits_per_word ? __const_iterator(&__first_, __pos) : __const_iterator(&__first_ + 1, 0); | ||
| 470 | } | 451 | } |
| 471 | 452 | ||
| 472 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT; | 453 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT; |
| ... | @@ -475,8 +456,39 @@ protected: | ... | @@ -475,8 +456,39 @@ protected: |
| 475 | 456 | ||
| 476 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT; | 457 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT; |
| 477 | 458 | ||
| 478 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const; | 459 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { |
| 479 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const; | 460 | if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long) * CHAR_BIT) { |
| 461 | if (auto __e = __make_iter(_Size); std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true) != __e) | ||
| 462 | __throw_overflow_error("__bitset<1, _Size>::to_ulong overflow error"); | ||
| 463 | } | ||
| 464 | return static_cast<unsigned long>(__first_); | ||
| 465 | } | ||
| 466 | |||
| 467 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { | ||
| 468 | // If _Size exceeds the size of unsigned long long, check for overflow | ||
| 469 | if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long long) * CHAR_BIT) { | ||
| 470 | if (auto __e = __make_iter(_Size); | ||
| 471 | std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true) != __e) | ||
| 472 | __throw_overflow_error("__bitset<1, _Size>::to_ullong overflow error"); | ||
| 473 | } | ||
| 474 | |||
| 475 | // If _Size fits or no overflow, directly cast to unsigned long long | ||
| 476 | return static_cast<unsigned long long>(__first_); | ||
| 477 | } | ||
| 478 | |||
| 479 | template <bool _Sparse, class _CharT, class _Traits, class _Allocator> | ||
| 480 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> | ||
| 481 | __to_string(_CharT __zero, _CharT __one) const { | ||
| 482 | basic_string<_CharT, _Traits, _Allocator> __r(_Size, _Sparse ? __zero : __one); | ||
| 483 | __storage_type __word = std::__invert_if<!_Sparse>(__first_); | ||
| 484 | if (_Size < __bits_per_word) | ||
| 485 | __word &= (__storage_type(1) << _Size) - 1; | ||
| 486 | for (; __word; __word &= (__word - 1)) { | ||
| 487 | size_t __pos = std::__countr_zero(__word); | ||
| 488 | __r[_Size - 1 - __pos] = _Sparse ? __one : __zero; | ||
| 489 | } | ||
| 490 | return __r; | ||
| 491 | } | ||
| 480 | 492 | ||
| 481 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT; | 493 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT; |
| 482 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT; | 494 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT; |
| ... | @@ -489,8 +501,10 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0) | ... | @@ -489,8 +501,10 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0) |
| 489 | 501 | ||
| 490 | template <size_t _Size> | 502 | template <size_t _Size> |
| 491 | inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT | 503 | inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT |
| 492 | : __first_(_Size == __bits_per_word ? static_cast<__storage_type>(__v) | 504 | // TODO: We must refer to __bits_per_word in order to work around an issue with the GDB pretty-printers. |
| 493 | : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1)) {} | 505 | // Without it, the pretty-printers complain about a missing __bits_per_word member. This needs to |
| 506 | // be investigated further. | ||
| 507 | : __first_(_Size == __bits_per_word ? static_cast<__storage_type>(__v) : static_cast<__storage_type>(__v)) {} | ||
| 494 | 508 | ||
| 495 | template <size_t _Size> | 509 | template <size_t _Size> |
| 496 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void | 510 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void |
| ... | @@ -512,19 +526,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { | ... | @@ -512,19 +526,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { |
| 512 | 526 | ||
| 513 | template <size_t _Size> | 527 | template <size_t _Size> |
| 514 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Size>::flip() _NOEXCEPT { | 528 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Size>::flip() _NOEXCEPT { |
| 515 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); | 529 | __first_ ^= ~__storage_type(0) >> (__bits_per_word - _Size); |
| 516 | __first_ = ~__first_; | ||
| 517 | __first_ &= __m; | ||
| 518 | } | ||
| 519 | |||
| 520 | template <size_t _Size> | ||
| 521 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1, _Size>::to_ulong() const { | ||
| 522 | return __first_; | ||
| 523 | } | ||
| 524 | |||
| 525 | template <size_t _Size> | ||
| 526 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __bitset<1, _Size>::to_ullong() const { | ||
| 527 | return __first_; | ||
| 528 | } | 530 | } |
| 529 | 531 | ||
| 530 | template <size_t _Size> | 532 | template <size_t _Size> |
| ... | @@ -591,6 +593,12 @@ protected: | ... | @@ -591,6 +593,12 @@ protected: |
| 591 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return 0; } | 593 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return 0; } |
| 592 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { return 0; } | 594 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { return 0; } |
| 593 | 595 | ||
| 596 | template <bool _Sparse, class _CharT, class _Traits, class _Allocator> | ||
| 597 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> | ||
| 598 | __to_string(_CharT, _CharT) const { | ||
| 599 | return basic_string<_CharT, _Traits, _Allocator>(); | ||
| 600 | } | ||
| 601 | |||
| 594 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return true; } | 602 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return true; } |
| 595 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return false; } | 603 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return false; } |
| 596 | 604 | ||
| ... | @@ -602,37 +610,32 @@ inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT {} | ... | @@ -602,37 +610,32 @@ inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT {} |
| 602 | inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT {} | 610 | inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT {} |
| 603 | 611 | ||
| 604 | template <size_t _Size> | 612 | template <size_t _Size> |
| 605 | class _LIBCPP_TEMPLATE_VIS bitset; | 613 | class bitset; |
| 606 | template <size_t _Size> | 614 | template <size_t _Size> |
| 607 | struct hash<bitset<_Size> >; | 615 | struct hash<bitset<_Size> >; |
| 608 | 616 | ||
| 609 | template <size_t _Size> | 617 | template <size_t _Size> |
| 610 | class _LIBCPP_TEMPLATE_VIS bitset | 618 | class bitset : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> { |
| 611 | : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> { | ||
| 612 | public: | 619 | public: |
| 613 | static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1; | 620 | static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1; |
| 614 | typedef __bitset<__n_words, _Size> __base; | 621 | typedef __bitset<__n_words, _Size> __base; |
| 615 | |||
| 616 | public: | ||
| 617 | typedef typename __base::reference reference; | 622 | typedef typename __base::reference reference; |
| 618 | typedef typename __base::__const_reference __const_reference; | 623 | typedef typename __base::__const_reference __const_reference; |
| 619 | 624 | ||
| 620 | // 23.3.5.1 constructors: | 625 | // 23.3.5.1 constructors: |
| 621 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} | 626 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} |
| 622 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : __base(__v) {} | 627 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT |
| 628 | : __base(sizeof(unsigned long long) * CHAR_BIT <= _Size ? __v : __v & ((1ULL << _Size) - 1)) {} | ||
| 623 | template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0> | 629 | template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0> |
| 624 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( | 630 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( |
| 625 | const _CharT* __str, | 631 | const _CharT* __str, |
| 626 | # if _LIBCPP_STD_VER >= 26 | 632 | size_t __n = basic_string<_CharT>::npos, |
| 627 | typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos, | ||
| 628 | # else | ||
| 629 | typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, | ||
| 630 | # endif | ||
| 631 | _CharT __zero = _CharT('0'), | 633 | _CharT __zero = _CharT('0'), |
| 632 | _CharT __one = _CharT('1')) { | 634 | _CharT __one = _CharT('1')) { |
| 633 | 635 | if (__n == basic_string<_CharT>::npos) | |
| 634 | size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str)); | 636 | __init_from_string_view(basic_string_view<_CharT>(__str), __zero, __one); |
| 635 | __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one); | 637 | else |
| 638 | __init_from_string_view(basic_string_view<_CharT>(__str, __n), __zero, __one); | ||
| 636 | } | 639 | } |
| 637 | # if _LIBCPP_STD_VER >= 26 | 640 | # if _LIBCPP_STD_VER >= 26 |
| 638 | template <class _CharT, class _Traits> | 641 | template <class _CharT, class _Traits> |
| ... | @@ -643,7 +646,7 @@ public: | ... | @@ -643,7 +646,7 @@ public: |
| 643 | _CharT __zero = _CharT('0'), | 646 | _CharT __zero = _CharT('0'), |
| 644 | _CharT __one = _CharT('1')) { | 647 | _CharT __one = _CharT('1')) { |
| 645 | if (__pos > __str.size()) | 648 | if (__pos > __str.size()) |
| 646 | __throw_out_of_range("bitset string pos out of range"); | 649 | std::__throw_out_of_range("bitset string pos out of range"); |
| 647 | 650 | ||
| 648 | size_t __rlen = std::min(__n, __str.size() - __pos); | 651 | size_t __rlen = std::min(__n, __str.size() - __pos); |
| 649 | __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one); | 652 | __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one); |
| ... | @@ -694,8 +697,10 @@ public: | ... | @@ -694,8 +697,10 @@ public: |
| 694 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); | 697 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); |
| 695 | return __base::__make_ref(__p); | 698 | return __base::__make_ref(__p); |
| 696 | } | 699 | } |
| 697 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const; | 700 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return __base::to_ulong(); } |
| 698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const; | 701 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { |
| 702 | return __base::to_ullong(); | ||
| 703 | } | ||
| 699 | template <class _CharT, class _Traits, class _Allocator> | 704 | template <class _CharT, class _Traits, class _Allocator> |
| 700 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> | 705 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> |
| 701 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; | 706 | to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; |
| ... | @@ -714,8 +719,8 @@ public: | ... | @@ -714,8 +719,8 @@ public: |
| 714 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT; | 719 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT; |
| 715 | # endif | 720 | # endif |
| 716 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const; | 721 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const; |
| 717 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT; | 722 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return __base::all(); } |
| 718 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT; | 723 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return __base::any(); } |
| 719 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); } | 724 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); } |
| 720 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT; | 725 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT; |
| 721 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT; | 726 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT; |
| ... | @@ -734,7 +739,6 @@ private: | ... | @@ -734,7 +739,6 @@ private: |
| 734 | _CharT __c = __str[__mp - 1 - __i]; | 739 | _CharT __c = __str[__mp - 1 - __i]; |
| 735 | (*this)[__i] = _Traits::eq(__c, __one); | 740 | (*this)[__i] = _Traits::eq(__c, __one); |
| 736 | } | 741 | } |
| 737 | std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false); | ||
| 738 | } | 742 | } |
| 739 | 743 | ||
| 740 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); } | 744 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); } |
| ... | @@ -788,7 +792,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset | ... | @@ -788,7 +792,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset |
| 788 | template <size_t _Size> | 792 | template <size_t _Size> |
| 789 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set(size_t __pos, bool __val) { | 793 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set(size_t __pos, bool __val) { |
| 790 | if (__pos >= _Size) | 794 | if (__pos >= _Size) |
| 791 | __throw_out_of_range("bitset set argument out of range"); | 795 | std::__throw_out_of_range("bitset set argument out of range"); |
| 792 | 796 | ||
| 793 | (*this)[__pos] = __val; | 797 | (*this)[__pos] = __val; |
| 794 | return *this; | 798 | return *this; |
| ... | @@ -803,7 +807,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset | ... | @@ -803,7 +807,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset |
| 803 | template <size_t _Size> | 807 | template <size_t _Size> |
| 804 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset(size_t __pos) { | 808 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset(size_t __pos) { |
| 805 | if (__pos >= _Size) | 809 | if (__pos >= _Size) |
| 806 | __throw_out_of_range("bitset reset argument out of range"); | 810 | std::__throw_out_of_range("bitset reset argument out of range"); |
| 807 | 811 | ||
| 808 | (*this)[__pos] = false; | 812 | (*this)[__pos] = false; |
| 809 | return *this; | 813 | return *this; |
| ... | @@ -825,33 +829,22 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset | ... | @@ -825,33 +829,22 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset |
| 825 | template <size_t _Size> | 829 | template <size_t _Size> |
| 826 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip(size_t __pos) { | 830 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip(size_t __pos) { |
| 827 | if (__pos >= _Size) | 831 | if (__pos >= _Size) |
| 828 | __throw_out_of_range("bitset flip argument out of range"); | 832 | std::__throw_out_of_range("bitset flip argument out of range"); |
| 829 | 833 | ||
| 830 | reference __r = __base::__make_ref(__pos); | 834 | reference __r = __base::__make_ref(__pos); |
| 831 | __r = ~__r; | 835 | __r = ~__r; |
| 832 | return *this; | 836 | return *this; |
| 833 | } | 837 | } |
| 834 | 838 | ||
| 835 | template <size_t _Size> | ||
| 836 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const { | ||
| 837 | return __base::to_ulong(); | ||
| 838 | } | ||
| 839 | |||
| 840 | template <size_t _Size> | ||
| 841 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const { | ||
| 842 | return __base::to_ullong(); | ||
| 843 | } | ||
| 844 | |||
| 845 | template <size_t _Size> | 839 | template <size_t _Size> |
| 846 | template <class _CharT, class _Traits, class _Allocator> | 840 | template <class _CharT, class _Traits, class _Allocator> |
| 847 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> | 841 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator> |
| 848 | bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { | 842 | bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { |
| 849 | basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero); | 843 | bool __sparse = size_t(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true)) < _Size / 2; |
| 850 | for (size_t __i = 0; __i != _Size; ++__i) { | 844 | if (__sparse) |
| 851 | if ((*this)[__i]) | 845 | return __base::template __to_string<true, _CharT, _Traits, _Allocator>(__zero, __one); |
| 852 | __r[_Size - 1 - __i] = __one; | 846 | else |
| 853 | } | 847 | return __base::template __to_string<false, _CharT, _Traits, _Allocator>(__zero, __one); |
| 854 | return __r; | ||
| 855 | } | 848 | } |
| 856 | 849 | ||
| 857 | template <size_t _Size> | 850 | template <size_t _Size> |
| ... | @@ -897,21 +890,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) | ... | @@ -897,21 +890,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) |
| 897 | template <size_t _Size> | 890 | template <size_t _Size> |
| 898 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const { | 891 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const { |
| 899 | if (__pos >= _Size) | 892 | if (__pos >= _Size) |
| 900 | __throw_out_of_range("bitset test argument out of range"); | 893 | std::__throw_out_of_range("bitset test argument out of range"); |
| 901 | 894 | ||
| 902 | return (*this)[__pos]; | 895 | return (*this)[__pos]; |
| 903 | } | 896 | } |
| 904 | 897 | ||
| 905 | template <size_t _Size> | ||
| 906 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT { | ||
| 907 | return __base::all(); | ||
| 908 | } | ||
| 909 | |||
| 910 | template <size_t _Size> | ||
| 911 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT { | ||
| 912 | return __base::any(); | ||
| 913 | } | ||
| 914 | |||
| 915 | template <size_t _Size> | 898 | template <size_t _Size> |
| 916 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> | 899 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> |
| 917 | bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT { | 900 | bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT { |
| ... | @@ -953,7 +936,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { | ... | @@ -953,7 +936,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT { |
| 953 | } | 936 | } |
| 954 | 937 | ||
| 955 | template <size_t _Size> | 938 | template <size_t _Size> |
| 956 | struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> { | 939 | struct hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> { |
| 957 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { return __bs.__hash_code(); } | 940 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { return __bs.__hash_code(); } |
| 958 | }; | 941 | }; |
| 959 | 942 | ||
| ... | @@ -972,6 +955,7 @@ _LIBCPP_POP_MACROS | ... | @@ -972,6 +955,7 @@ _LIBCPP_POP_MACROS |
| 972 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 955 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 973 | # include <concepts> | 956 | # include <concepts> |
| 974 | # include <cstdlib> | 957 | # include <cstdlib> |
| 958 | # include <optional> | ||
| 975 | # include <type_traits> | 959 | # include <type_traits> |
| 976 | # endif | 960 | # endif |
| 977 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 961 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/charconv+1-1| ... | @@ -76,7 +76,7 @@ namespace std { | ... | @@ -76,7 +76,7 @@ namespace std { |
| 76 | */ | 76 | */ |
| 77 | 77 | ||
| 78 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 78 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 79 | # include <__cxx03/charconv> | 79 | # include <__cxx03/__config> |
| 80 | #else | 80 | #else |
| 81 | # include <__config> | 81 | # include <__config> |
| 82 | 82 |
lib/libcxx/include/chrono+88-22| ... | @@ -132,6 +132,11 @@ public: | ... | @@ -132,6 +132,11 @@ public: |
| 132 | 132 | ||
| 133 | // arithmetic | 133 | // arithmetic |
| 134 | 134 | ||
| 135 | constexpr time_point& operator++(); // C++20 | ||
| 136 | constexpr time_point operator++(int); // C++20 | ||
| 137 | constexpr time_point& operator--(); // C++20 | ||
| 138 | constexpr time_point operator--(int); // C++20 | ||
| 139 | |||
| 135 | time_point& operator+=(const duration& d); // constexpr in C++17 | 140 | time_point& operator+=(const duration& d); // constexpr in C++17 |
| 136 | time_point& operator-=(const duration& d); // constexpr in C++17 | 141 | time_point& operator-=(const duration& d); // constexpr in C++17 |
| 137 | 142 | ||
| ... | @@ -335,6 +340,61 @@ struct leap_second_info { // C++20 | ... | @@ -335,6 +340,61 @@ struct leap_second_info { // C++20 |
| 335 | template<class Duration> // C++20 | 340 | template<class Duration> // C++20 |
| 336 | leap_second_info get_leap_second_info(const utc_time<Duration>& ut); | 341 | leap_second_info get_leap_second_info(const utc_time<Duration>& ut); |
| 337 | 342 | ||
| 343 | |||
| 344 | // [time.clock.tai], class tai_clock | ||
| 345 | class tai_clock { // C++20 | ||
| 346 | public: | ||
| 347 | using rep = a signed arithmetic type; | ||
| 348 | using period = ratio<unspecified, unspecified>; | ||
| 349 | using duration = chrono::duration<rep, period>; | ||
| 350 | using time_point = chrono::time_point<tai_clock>; | ||
| 351 | static constexpr bool is_steady = unspecified; | ||
| 352 | |||
| 353 | static time_point now(); | ||
| 354 | |||
| 355 | template<class Duration> | ||
| 356 | static utc_time<common_type_t<Duration, seconds>> | ||
| 357 | to_utc(const tai_time<Duration>& t); | ||
| 358 | template<class Duration> | ||
| 359 | static tai_time<common_type_t<Duration, seconds>> | ||
| 360 | from_utc(const utc_time<Duration>& t); | ||
| 361 | }; | ||
| 362 | |||
| 363 | template<class Duration> | ||
| 364 | using tai_time = time_point<tai_clock, Duration>; // C++20 | ||
| 365 | using tai_seconds = tai_time<seconds>; // C++20 | ||
| 366 | |||
| 367 | template<class charT, class traits, class Duration> // C++20 | ||
| 368 | basic_ostream<charT, traits>& | ||
| 369 | operator<<(basic_ostream<charT, traits>& os, const tai_time<Duration>& t); | ||
| 370 | |||
| 371 | // [time.clock.gps], class gps_clock | ||
| 372 | class gps_clock { // C++20 | ||
| 373 | public: | ||
| 374 | using rep = a signed arithmetic type; | ||
| 375 | using period = ratio<unspecified, unspecified>; | ||
| 376 | using duration = chrono::duration<rep, period>; | ||
| 377 | using time_point = chrono::time_point<gps_clock>; | ||
| 378 | static constexpr bool is_steady = unspecified; | ||
| 379 | |||
| 380 | static time_point now(); | ||
| 381 | |||
| 382 | template<class Duration> | ||
| 383 | static utc_time<common_type_t<Duration, seconds>> | ||
| 384 | to_utc(const gps_time<Duration>& t); | ||
| 385 | template<class Duration> | ||
| 386 | static gps_time<common_type_t<Duration, seconds>> | ||
| 387 | from_utc(const utc_time<Duration>& t); | ||
| 388 | }; | ||
| 389 | |||
| 390 | template<class Duration> | ||
| 391 | using gps_time = time_point<gps_clock, Duration>; // C++20 | ||
| 392 | using gps_seconds = gps_time<seconds>; // C++20 | ||
| 393 | |||
| 394 | template<class charT, class traits, class Duration> // C++20 | ||
| 395 | basic_ostream<charT, traits>& | ||
| 396 | operator<<(basic_ostream<charT, traits>& os, const gps_time<Duration>& t); | ||
| 397 | |||
| 338 | class file_clock // C++20 | 398 | class file_clock // C++20 |
| 339 | { | 399 | { |
| 340 | public: | 400 | public: |
| ... | @@ -374,7 +434,7 @@ public: | ... | @@ -374,7 +434,7 @@ public: |
| 374 | 434 | ||
| 375 | typedef steady_clock high_resolution_clock; | 435 | typedef steady_clock high_resolution_clock; |
| 376 | 436 | ||
| 377 | // 25.7.8, local time // C++20 | 437 | // [time.clock.local] local time // C++20 |
| 378 | struct local_t {}; | 438 | struct local_t {}; |
| 379 | template<class Duration> | 439 | template<class Duration> |
| 380 | using local_time = time_point<local_t, Duration>; | 440 | using local_time = time_point<local_t, Duration>; |
| ... | @@ -385,10 +445,10 @@ template<class charT, class traits, class Duration> // C++20 | ... | @@ -385,10 +445,10 @@ template<class charT, class traits, class Duration> // C++20 |
| 385 | basic_ostream<charT, traits>& | 445 | basic_ostream<charT, traits>& |
| 386 | operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp); | 446 | operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp); |
| 387 | 447 | ||
| 388 | // 25.8.2, class last_spec // C++20 | 448 | // [time.cal.last] class last_spec // C++20 |
| 389 | struct last_spec; | 449 | struct last_spec; |
| 390 | 450 | ||
| 391 | // 25.8.3, class day // C++20 | 451 | // [time.cal.day] class day // C++20 |
| 392 | 452 | ||
| 393 | class day; | 453 | class day; |
| 394 | constexpr bool operator==(const day& x, const day& y) noexcept; | 454 | constexpr bool operator==(const day& x, const day& y) noexcept; |
| ... | @@ -401,7 +461,7 @@ template<class charT, class traits> | ... | @@ -401,7 +461,7 @@ template<class charT, class traits> |
| 401 | basic_ostream<charT, traits>& | 461 | basic_ostream<charT, traits>& |
| 402 | operator<<(basic_ostream<charT, traits>& os, const day& d); | 462 | operator<<(basic_ostream<charT, traits>& os, const day& d); |
| 403 | 463 | ||
| 404 | // 25.8.4, class month // C++20 | 464 | // [time.cal.month] class month // C++20 |
| 405 | class month; | 465 | class month; |
| 406 | constexpr bool operator==(const month& x, const month& y) noexcept; | 466 | constexpr bool operator==(const month& x, const month& y) noexcept; |
| 407 | constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept; | 467 | constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept; |
| ... | @@ -414,7 +474,7 @@ template<class charT, class traits> | ... | @@ -414,7 +474,7 @@ template<class charT, class traits> |
| 414 | basic_ostream<charT, traits>& | 474 | basic_ostream<charT, traits>& |
| 415 | operator<<(basic_ostream<charT, traits>& os, const month& m); | 475 | operator<<(basic_ostream<charT, traits>& os, const month& m); |
| 416 | 476 | ||
| 417 | // 25.8.5, class year // C++20 | 477 | // [time.cal.year] class year // C++20 |
| 418 | class year; | 478 | class year; |
| 419 | constexpr bool operator==(const year& x, const year& y) noexcept; | 479 | constexpr bool operator==(const year& x, const year& y) noexcept; |
| 420 | constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept; | 480 | constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept; |
| ... | @@ -427,7 +487,7 @@ template<class charT, class traits> | ... | @@ -427,7 +487,7 @@ template<class charT, class traits> |
| 427 | basic_ostream<charT, traits>& | 487 | basic_ostream<charT, traits>& |
| 428 | operator<<(basic_ostream<charT, traits>& os, const year& y); | 488 | operator<<(basic_ostream<charT, traits>& os, const year& y); |
| 429 | 489 | ||
| 430 | // 25.8.6, class weekday // C++20 | 490 | // [time.cal.wd] class weekday // C++20 |
| 431 | class weekday; | 491 | class weekday; |
| 432 | 492 | ||
| 433 | constexpr bool operator==(const weekday& x, const weekday& y) noexcept; | 493 | constexpr bool operator==(const weekday& x, const weekday& y) noexcept; |
| ... | @@ -439,7 +499,7 @@ template<class charT, class traits> | ... | @@ -439,7 +499,7 @@ template<class charT, class traits> |
| 439 | basic_ostream<charT, traits>& | 499 | basic_ostream<charT, traits>& |
| 440 | operator<<(basic_ostream<charT, traits>& os, const weekday& wd); | 500 | operator<<(basic_ostream<charT, traits>& os, const weekday& wd); |
| 441 | 501 | ||
| 442 | // 25.8.7, class weekday_indexed // C++20 | 502 | // [time.cal.wdidx] class weekday_indexed // C++20 |
| 443 | 503 | ||
| 444 | class weekday_indexed; | 504 | class weekday_indexed; |
| 445 | constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; | 505 | constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; |
| ... | @@ -448,7 +508,7 @@ template<class charT, class traits> | ... | @@ -448,7 +508,7 @@ template<class charT, class traits> |
| 448 | basic_ostream<charT, traits>& | 508 | basic_ostream<charT, traits>& |
| 449 | operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi); | 509 | operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi); |
| 450 | 510 | ||
| 451 | // 25.8.8, class weekday_last // C++20 | 511 | // [time.cal.wdlast] class weekday_last // C++20 |
| 452 | class weekday_last; | 512 | class weekday_last; |
| 453 | 513 | ||
| 454 | constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; | 514 | constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; |
| ... | @@ -457,7 +517,7 @@ template<class charT, class traits> | ... | @@ -457,7 +517,7 @@ template<class charT, class traits> |
| 457 | basic_ostream<charT, traits>& | 517 | basic_ostream<charT, traits>& |
| 458 | operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl); | 518 | operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl); |
| 459 | 519 | ||
| 460 | // 25.8.9, class month_day // C++20 | 520 | // [time.cal.md] class month_day // C++20 |
| 461 | class month_day; | 521 | class month_day; |
| 462 | 522 | ||
| 463 | constexpr bool operator==(const month_day& x, const month_day& y) noexcept; | 523 | constexpr bool operator==(const month_day& x, const month_day& y) noexcept; |
| ... | @@ -467,7 +527,7 @@ template<class charT, class traits> | ... | @@ -467,7 +527,7 @@ template<class charT, class traits> |
| 467 | basic_ostream<charT, traits>& | 527 | basic_ostream<charT, traits>& |
| 468 | operator<<(basic_ostream<charT, traits>& os, const month_day& md); | 528 | operator<<(basic_ostream<charT, traits>& os, const month_day& md); |
| 469 | 529 | ||
| 470 | // 25.8.10, class month_day_last // C++20 | 530 | // [time.cal.mdlast] class month_day_last // C++20 |
| 471 | class month_day_last; | 531 | class month_day_last; |
| 472 | 532 | ||
| 473 | constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; | 533 | constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; |
| ... | @@ -477,7 +537,7 @@ template<class charT, class traits> | ... | @@ -477,7 +537,7 @@ template<class charT, class traits> |
| 477 | basic_ostream<charT, traits>& | 537 | basic_ostream<charT, traits>& |
| 478 | operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl); | 538 | operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl); |
| 479 | 539 | ||
| 480 | // 25.8.11, class month_weekday // C++20 | 540 | // [time.cal.mwd] class month_weekday // C++20 |
| 481 | class month_weekday; | 541 | class month_weekday; |
| 482 | 542 | ||
| 483 | constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; | 543 | constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; |
| ... | @@ -486,7 +546,7 @@ template<class charT, class traits> | ... | @@ -486,7 +546,7 @@ template<class charT, class traits> |
| 486 | basic_ostream<charT, traits>& | 546 | basic_ostream<charT, traits>& |
| 487 | operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd); | 547 | operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd); |
| 488 | 548 | ||
| 489 | // 25.8.12, class month_weekday_last // C++20 | 549 | // [time.cal.mwdlast] class month_weekday_last // C++20 |
| 490 | class month_weekday_last; | 550 | class month_weekday_last; |
| 491 | 551 | ||
| 492 | constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; | 552 | constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; |
| ... | @@ -496,7 +556,7 @@ template<class charT, class traits> | ... | @@ -496,7 +556,7 @@ template<class charT, class traits> |
| 496 | operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl); | 556 | operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl); |
| 497 | 557 | ||
| 498 | 558 | ||
| 499 | // 25.8.13, class year_month // C++20 | 559 | // [time.cal.ym] class year_month // C++20 |
| 500 | class year_month; | 560 | class year_month; |
| 501 | 561 | ||
| 502 | constexpr bool operator==(const year_month& x, const year_month& y) noexcept; | 562 | constexpr bool operator==(const year_month& x, const year_month& y) noexcept; |
| ... | @@ -514,7 +574,7 @@ template<class charT, class traits> | ... | @@ -514,7 +574,7 @@ template<class charT, class traits> |
| 514 | basic_ostream<charT, traits>& | 574 | basic_ostream<charT, traits>& |
| 515 | operator<<(basic_ostream<charT, traits>& os, const year_month& ym); | 575 | operator<<(basic_ostream<charT, traits>& os, const year_month& ym); |
| 516 | 576 | ||
| 517 | // 25.8.14, class year_month_day class // C++20 | 577 | // [time.cal.ymd] class year_month_day class // C++20 |
| 518 | year_month_day; | 578 | year_month_day; |
| 519 | 579 | ||
| 520 | constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; | 580 | constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; |
| ... | @@ -531,7 +591,7 @@ template<class charT, class traits> | ... | @@ -531,7 +591,7 @@ template<class charT, class traits> |
| 531 | basic_ostream<charT, traits>& | 591 | basic_ostream<charT, traits>& |
| 532 | operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd); | 592 | operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd); |
| 533 | 593 | ||
| 534 | // 25.8.15, class year_month_day_last // C++20 | 594 | // [time.cal.ymdlast] class year_month_day_last // C++20 |
| 535 | class year_month_day_last; | 595 | class year_month_day_last; |
| 536 | 596 | ||
| 537 | constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept; | 597 | constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept; |
| ... | @@ -554,7 +614,7 @@ template<class charT, class traits> | ... | @@ -554,7 +614,7 @@ template<class charT, class traits> |
| 554 | basic_ostream<charT, traits>& | 614 | basic_ostream<charT, traits>& |
| 555 | operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl); | 615 | operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl); |
| 556 | 616 | ||
| 557 | // 25.8.16, class year_month_weekday // C++20 | 617 | // [time.cal.ymwd] class year_month_weekday // C++20 |
| 558 | class year_month_weekday; | 618 | class year_month_weekday; |
| 559 | 619 | ||
| 560 | constexpr bool operator==(const year_month_weekday& x, | 620 | constexpr bool operator==(const year_month_weekday& x, |
| ... | @@ -577,7 +637,7 @@ template<class charT, class traits> | ... | @@ -577,7 +637,7 @@ template<class charT, class traits> |
| 577 | basic_ostream<charT, traits>& | 637 | basic_ostream<charT, traits>& |
| 578 | operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd); | 638 | operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd); |
| 579 | 639 | ||
| 580 | // 25.8.17, class year_month_weekday_last // C++20 | 640 | // [time.cal.ymwdlast] class year_month_weekday_last // C++20 |
| 581 | class year_month_weekday_last; | 641 | class year_month_weekday_last; |
| 582 | 642 | ||
| 583 | constexpr bool operator==(const year_month_weekday_last& x, | 643 | constexpr bool operator==(const year_month_weekday_last& x, |
| ... | @@ -599,7 +659,7 @@ template<class charT, class traits> | ... | @@ -599,7 +659,7 @@ template<class charT, class traits> |
| 599 | basic_ostream<charT, traits>& | 659 | basic_ostream<charT, traits>& |
| 600 | operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl); | 660 | operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl); |
| 601 | 661 | ||
| 602 | // 25.8.18, civil calendar conventional syntax operators // C++20 | 662 | // [time.cal.operators] civil calendar conventional syntax operators // C++20 |
| 603 | constexpr year_month | 663 | constexpr year_month |
| 604 | operator/(const year& y, const month& m) noexcept; | 664 | operator/(const year& y, const month& m) noexcept; |
| 605 | constexpr year_month | 665 | constexpr year_month |
| ... | @@ -790,7 +850,7 @@ template<class charT, class traits> | ... | @@ -790,7 +850,7 @@ template<class charT, class traits> |
| 790 | basic_ostream<charT, traits>& | 850 | basic_ostream<charT, traits>& |
| 791 | operator<<(basic_ostream<charT, traits>& os, const local_info& li); | 851 | operator<<(basic_ostream<charT, traits>& os, const local_info& li); |
| 792 | 852 | ||
| 793 | // 25.10.5, class time_zone // C++20 | 853 | // [time.zone.timezone] class time_zone // C++20 |
| 794 | enum class choose {earliest, latest}; | 854 | enum class choose {earliest, latest}; |
| 795 | class time_zone { | 855 | class time_zone { |
| 796 | time_zone(time_zone&&) = default; | 856 | time_zone(time_zone&&) = default; |
| ... | @@ -894,16 +954,20 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); | ... | @@ -894,16 +954,20 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); |
| 894 | } // chrono | 954 | } // chrono |
| 895 | 955 | ||
| 896 | namespace std { | 956 | namespace std { |
| 957 | template<class Rep, class Period, class charT> | ||
| 958 | struct formatter<chrono::duration<Rep, Period>, charT>; // C++20 | ||
| 897 | template<class Duration, class charT> | 959 | template<class Duration, class charT> |
| 898 | struct formatter<chrono::sys_time<Duration>, charT>; // C++20 | 960 | struct formatter<chrono::sys_time<Duration>, charT>; // C++20 |
| 899 | template<class Duration, class charT> | 961 | template<class Duration, class charT> |
| 900 | struct formatter<chrono::utc_time<Duration>, charT>; // C++20 | 962 | struct formatter<chrono::utc_time<Duration>, charT>; // C++20 |
| 901 | template<class Duration, class charT> | 963 | template<class Duration, class charT> |
| 902 | struct formatter<chrono::filetime<Duration>, charT>; // C++20 | 964 | struct formatter<chrono::tai_time<Duration>, charT>; // C++20 |
| 965 | template<class Duration, class charT> | ||
| 966 | struct formatter<chrono::gps_time<Duration>, charT>; // C++20 | ||
| 967 | template<class Duration, class charT> | ||
| 968 | struct formatter<chrono::file_time<Duration>, charT>; // C++20 | ||
| 903 | template<class Duration, class charT> | 969 | template<class Duration, class charT> |
| 904 | struct formatter<chrono::local_time<Duration>, charT>; // C++20 | 970 | struct formatter<chrono::local_time<Duration>, charT>; // C++20 |
| 905 | template<class Rep, class Period, class charT> | ||
| 906 | struct formatter<chrono::duration<Rep, Period>, charT>; // C++20 | ||
| 907 | template<class charT> struct formatter<chrono::day, charT>; // C++20 | 971 | template<class charT> struct formatter<chrono::day, charT>; // C++20 |
| 908 | template<class charT> struct formatter<chrono::month, charT>; // C++20 | 972 | template<class charT> struct formatter<chrono::month, charT>; // C++20 |
| 909 | template<class charT> struct formatter<chrono::year, charT>; // C++20 | 973 | template<class charT> struct formatter<chrono::year, charT>; // C++20 |
| ... | @@ -1013,7 +1077,9 @@ constexpr chrono::year operator ""y(unsigned lo | ... | @@ -1013,7 +1077,9 @@ constexpr chrono::year operator ""y(unsigned lo |
| 1013 | # endif | 1077 | # endif |
| 1014 | 1078 | ||
| 1015 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | 1079 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION |
| 1080 | # include <__chrono/gps_clock.h> | ||
| 1016 | # include <__chrono/leap_second.h> | 1081 | # include <__chrono/leap_second.h> |
| 1082 | # include <__chrono/tai_clock.h> | ||
| 1017 | # include <__chrono/time_zone.h> | 1083 | # include <__chrono/time_zone.h> |
| 1018 | # include <__chrono/time_zone_link.h> | 1084 | # include <__chrono/time_zone_link.h> |
| 1019 | # include <__chrono/tzdb.h> | 1085 | # include <__chrono/tzdb.h> |
lib/libcxx/include/cmath+3-5| ... | @@ -599,11 +599,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr long double lerp(long double __a, long do | ... | @@ -599,11 +599,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr long double lerp(long double __a, long do |
| 599 | } | 599 | } |
| 600 | 600 | ||
| 601 | template <class _A1, class _A2, class _A3> | 601 | template <class _A1, class _A2, class _A3> |
| 602 | inline _LIBCPP_HIDE_FROM_ABI constexpr | 602 | requires(is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>) |
| 603 | typename enable_if_t< is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, | 603 | _LIBCPP_HIDE_FROM_ABI inline constexpr __promote_t<_A1, _A2, _A3> lerp(_A1 __a, _A2 __b, _A3 __t) noexcept { |
| 604 | __promote<_A1, _A2, _A3> >::type | 604 | using __result_type = __promote_t<_A1, _A2, _A3>; |
| 605 | lerp(_A1 __a, _A2 __b, _A3 __t) noexcept { | ||
| 606 | typedef typename __promote<_A1, _A2, _A3>::type __result_type; | ||
| 607 | static_assert(!( | 605 | static_assert(!( |
| 608 | _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value)); | 606 | _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value)); |
| 609 | return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t); | 607 | return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t); |
lib/libcxx/include/codecvt+22-17| ... | @@ -58,14 +58,17 @@ class codecvt_utf8_utf16 | ... | @@ -58,14 +58,17 @@ class codecvt_utf8_utf16 |
| 58 | # include <__cxx03/codecvt> | 58 | # include <__cxx03/codecvt> |
| 59 | #else | 59 | #else |
| 60 | # include <__config> | 60 | # include <__config> |
| 61 | # include <__locale> | ||
| 62 | # include <version> | ||
| 63 | 61 | ||
| 64 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 62 | # if _LIBCPP_HAS_LOCALIZATION |
| 65 | # pragma GCC system_header | 63 | |
| 66 | # endif | 64 | # include <__locale> |
| 65 | # include <version> | ||
| 67 | 66 | ||
| 68 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) | 67 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 68 | # pragma GCC system_header | ||
| 69 | # endif | ||
| 70 | |||
| 71 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) | ||
| 69 | 72 | ||
| 70 | _LIBCPP_BEGIN_NAMESPACE_STD | 73 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 71 | 74 | ||
| ... | @@ -76,7 +79,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea | ... | @@ -76,7 +79,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea |
| 76 | template <class _Elem> | 79 | template <class _Elem> |
| 77 | class __codecvt_utf8; | 80 | class __codecvt_utf8; |
| 78 | 81 | ||
| 79 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 82 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 80 | template <> | 83 | template <> |
| 81 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { | 84 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { |
| 82 | unsigned long __maxcode_; | 85 | unsigned long __maxcode_; |
| ... | @@ -115,7 +118,7 @@ protected: | ... | @@ -115,7 +118,7 @@ protected: |
| 115 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; | 118 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; |
| 116 | int do_max_length() const _NOEXCEPT override; | 119 | int do_max_length() const _NOEXCEPT override; |
| 117 | }; | 120 | }; |
| 118 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 121 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 119 | 122 | ||
| 120 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 123 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 121 | template <> | 124 | template <> |
| ... | @@ -193,7 +196,7 @@ protected: | ... | @@ -193,7 +196,7 @@ protected: |
| 193 | 196 | ||
| 194 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 197 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 195 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> | 198 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> |
| 196 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 : public __codecvt_utf8<_Elem> { | 199 | class _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 : public __codecvt_utf8<_Elem> { |
| 197 | public: | 200 | public: |
| 198 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8(size_t __refs = 0) : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {} | 201 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8(size_t __refs = 0) : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {} |
| 199 | 202 | ||
| ... | @@ -206,7 +209,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP | ... | @@ -206,7 +209,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 206 | template <class _Elem, bool _LittleEndian> | 209 | template <class _Elem, bool _LittleEndian> |
| 207 | class __codecvt_utf16; | 210 | class __codecvt_utf16; |
| 208 | 211 | ||
| 209 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 212 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 210 | template <> | 213 | template <> |
| 211 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> { | 214 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> { |
| 212 | unsigned long __maxcode_; | 215 | unsigned long __maxcode_; |
| ... | @@ -284,7 +287,7 @@ protected: | ... | @@ -284,7 +287,7 @@ protected: |
| 284 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; | 287 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; |
| 285 | int do_max_length() const _NOEXCEPT override; | 288 | int do_max_length() const _NOEXCEPT override; |
| 286 | }; | 289 | }; |
| 287 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 290 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 288 | 291 | ||
| 289 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 292 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 290 | template <> | 293 | template <> |
| ... | @@ -436,8 +439,7 @@ protected: | ... | @@ -436,8 +439,7 @@ protected: |
| 436 | 439 | ||
| 437 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 440 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 438 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> | 441 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> |
| 439 | class _LIBCPP_TEMPLATE_VIS | 442 | class _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { |
| 440 | _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { | ||
| 441 | public: | 443 | public: |
| 442 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0) | 444 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0) |
| 443 | : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} | 445 | : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} |
| ... | @@ -451,7 +453,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP | ... | @@ -451,7 +453,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 451 | template <class _Elem> | 453 | template <class _Elem> |
| 452 | class __codecvt_utf8_utf16; | 454 | class __codecvt_utf8_utf16; |
| 453 | 455 | ||
| 454 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 456 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 455 | template <> | 457 | template <> |
| 456 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { | 458 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { |
| 457 | unsigned long __maxcode_; | 459 | unsigned long __maxcode_; |
| ... | @@ -490,7 +492,7 @@ protected: | ... | @@ -490,7 +492,7 @@ protected: |
| 490 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; | 492 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; |
| 491 | int do_max_length() const _NOEXCEPT override; | 493 | int do_max_length() const _NOEXCEPT override; |
| 492 | }; | 494 | }; |
| 493 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 495 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 494 | 496 | ||
| 495 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 497 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 496 | template <> | 498 | template <> |
| ... | @@ -568,7 +570,7 @@ protected: | ... | @@ -568,7 +570,7 @@ protected: |
| 568 | 570 | ||
| 569 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | 571 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 570 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> | 572 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> |
| 571 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> { | 573 | class _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> { |
| 572 | public: | 574 | public: |
| 573 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8_utf16(size_t __refs = 0) | 575 | _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8_utf16(size_t __refs = 0) |
| 574 | : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {} | 576 | : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {} |
| ... | @@ -579,7 +581,9 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP | ... | @@ -579,7 +581,9 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 579 | 581 | ||
| 580 | _LIBCPP_END_NAMESPACE_STD | 582 | _LIBCPP_END_NAMESPACE_STD |
| 581 | 583 | ||
| 582 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) | 584 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) |
| 585 | |||
| 586 | # endif // _LIBCPP_HAS_LOCALIZATION | ||
| 583 | 587 | ||
| 584 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 588 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 585 | # include <atomic> | 589 | # include <atomic> |
| ... | @@ -592,6 +596,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -592,6 +596,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 592 | # include <limits> | 596 | # include <limits> |
| 593 | # include <mutex> | 597 | # include <mutex> |
| 594 | # include <new> | 598 | # include <new> |
| 599 | # include <optional> | ||
| 595 | # include <stdexcept> | 600 | # include <stdexcept> |
| 596 | # include <type_traits> | 601 | # include <type_traits> |
| 597 | # include <typeinfo> | 602 | # include <typeinfo> |
lib/libcxx/include/compare+1-1| ... | @@ -141,7 +141,7 @@ namespace std { | ... | @@ -141,7 +141,7 @@ namespace std { |
| 141 | */ | 141 | */ |
| 142 | 142 | ||
| 143 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 143 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 144 | # include <__cxx03/compare> | 144 | # include <__cxx03/__config> |
| 145 | #else | 145 | #else |
| 146 | # include <__config> | 146 | # include <__config> |
| 147 | 147 |
lib/libcxx/include/complex+15-15| ... | @@ -260,6 +260,7 @@ template<class T> complex<T> tanh (const complex<T>&); | ... | @@ -260,6 +260,7 @@ template<class T> complex<T> tanh (const complex<T>&); |
| 260 | # include <__cxx03/complex> | 260 | # include <__cxx03/complex> |
| 261 | #else | 261 | #else |
| 262 | # include <__config> | 262 | # include <__config> |
| 263 | # include <__cstddef/size_t.h> | ||
| 263 | # include <__fwd/complex.h> | 264 | # include <__fwd/complex.h> |
| 264 | # include <__fwd/tuple.h> | 265 | # include <__fwd/tuple.h> |
| 265 | # include <__tuple/tuple_element.h> | 266 | # include <__tuple/tuple_element.h> |
| ... | @@ -283,7 +284,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -283,7 +284,7 @@ _LIBCPP_PUSH_MACROS |
| 283 | _LIBCPP_BEGIN_NAMESPACE_STD | 284 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 284 | 285 | ||
| 285 | template <class _Tp> | 286 | template <class _Tp> |
| 286 | class _LIBCPP_TEMPLATE_VIS complex; | 287 | class complex; |
| 287 | 288 | ||
| 288 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> | 289 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> |
| 289 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | 290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| ... | @@ -302,7 +303,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> | ... | @@ -302,7 +303,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> |
| 302 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); | 303 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); |
| 303 | 304 | ||
| 304 | template <class _Tp> | 305 | template <class _Tp> |
| 305 | class _LIBCPP_TEMPLATE_VIS complex { | 306 | class complex { |
| 306 | public: | 307 | public: |
| 307 | typedef _Tp value_type; | 308 | typedef _Tp value_type; |
| 308 | 309 | ||
| ... | @@ -393,9 +394,9 @@ public: | ... | @@ -393,9 +394,9 @@ public: |
| 393 | }; | 394 | }; |
| 394 | 395 | ||
| 395 | template <> | 396 | template <> |
| 396 | class _LIBCPP_TEMPLATE_VIS complex<double>; | 397 | class complex<double>; |
| 397 | template <> | 398 | template <> |
| 398 | class _LIBCPP_TEMPLATE_VIS complex<long double>; | 399 | class complex<long double>; |
| 399 | 400 | ||
| 400 | struct __from_builtin_tag {}; | 401 | struct __from_builtin_tag {}; |
| 401 | 402 | ||
| ... | @@ -415,7 +416,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re | ... | @@ -415,7 +416,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re |
| 415 | } | 416 | } |
| 416 | 417 | ||
| 417 | template <> | 418 | template <> |
| 418 | class _LIBCPP_TEMPLATE_VIS complex<float> { | 419 | class complex<float> { |
| 419 | float __re_; | 420 | float __re_; |
| 420 | float __im_; | 421 | float __im_; |
| 421 | 422 | ||
| ... | @@ -512,7 +513,7 @@ public: | ... | @@ -512,7 +513,7 @@ public: |
| 512 | }; | 513 | }; |
| 513 | 514 | ||
| 514 | template <> | 515 | template <> |
| 515 | class _LIBCPP_TEMPLATE_VIS complex<double> { | 516 | class complex<double> { |
| 516 | double __re_; | 517 | double __re_; |
| 517 | double __im_; | 518 | double __im_; |
| 518 | 519 | ||
| ... | @@ -612,7 +613,7 @@ public: | ... | @@ -612,7 +613,7 @@ public: |
| 612 | }; | 613 | }; |
| 613 | 614 | ||
| 614 | template <> | 615 | template <> |
| 615 | class _LIBCPP_TEMPLATE_VIS complex<long double> { | 616 | class complex<long double> { |
| 616 | long double __re_; | 617 | long double __re_; |
| 617 | long double __im_; | 618 | long double __im_; |
| 618 | 619 | ||
| ... | @@ -1101,21 +1102,20 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const com | ... | @@ -1101,21 +1102,20 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const com |
| 1101 | } | 1102 | } |
| 1102 | 1103 | ||
| 1103 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0> | 1104 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0> |
| 1104 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> | 1105 | inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const complex<_Tp>& __x, const complex<_Up>& __y) { |
| 1105 | pow(const complex<_Tp>& __x, const complex<_Up>& __y) { | 1106 | typedef complex<__promote_t<_Tp, _Up> > result_type; |
| 1106 | typedef complex<typename __promote<_Tp, _Up>::type> result_type; | ||
| 1107 | return std::pow(result_type(__x), result_type(__y)); | 1107 | return std::pow(result_type(__x), result_type(__y)); |
| 1108 | } | 1108 | } |
| 1109 | 1109 | ||
| 1110 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0> | 1110 | 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<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) { | 1111 | inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const complex<_Tp>& __x, const _Up& __y) { |
| 1112 | typedef complex<typename __promote<_Tp, _Up>::type> result_type; | 1112 | typedef complex<__promote_t<_Tp, _Up> > result_type; |
| 1113 | return std::pow(result_type(__x), result_type(__y)); | 1113 | return std::pow(result_type(__x), result_type(__y)); |
| 1114 | } | 1114 | } |
| 1115 | 1115 | ||
| 1116 | template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0> | 1116 | 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<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) { | 1117 | inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const _Tp& __x, const complex<_Up>& __y) { |
| 1118 | typedef complex<typename __promote<_Tp, _Up>::type> result_type; | 1118 | typedef complex<__promote_t<_Tp, _Up> > result_type; |
| 1119 | return std::pow(result_type(__x), result_type(__y)); | 1119 | return std::pow(result_type(__x), result_type(__y)); |
| 1120 | } | 1120 | } |
| 1121 | 1121 | ||
| ... | @@ -1394,7 +1394,7 @@ struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {}; | ... | @@ -1394,7 +1394,7 @@ struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {}; |
| 1394 | template <size_t _Ip, class _Tp> | 1394 | template <size_t _Ip, class _Tp> |
| 1395 | struct tuple_element<_Ip, complex<_Tp>> { | 1395 | struct tuple_element<_Ip, complex<_Tp>> { |
| 1396 | static_assert(_Ip < 2, "Index value is out of range."); | 1396 | static_assert(_Ip < 2, "Index value is out of range."); |
| 1397 | using type = _Tp; | 1397 | using type _LIBCPP_NODEBUG = _Tp; |
| 1398 | }; | 1398 | }; |
| 1399 | 1399 | ||
| 1400 | template <size_t _Ip, class _Xp> | 1400 | template <size_t _Ip, class _Xp> |
lib/libcxx/include/concepts+1-1| ... | @@ -130,7 +130,7 @@ namespace std { | ... | @@ -130,7 +130,7 @@ namespace std { |
| 130 | */ | 130 | */ |
| 131 | 131 | ||
| 132 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 132 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 133 | # include <__cxx03/concepts> | 133 | # include <__cxx03/__config> |
| 134 | #else | 134 | #else |
| 135 | # include <__config> | 135 | # include <__config> |
| 136 | 136 |
lib/libcxx/include/condition_variable+31-36| ... | @@ -147,6 +147,21 @@ _LIBCPP_PUSH_MACROS | ... | @@ -147,6 +147,21 @@ _LIBCPP_PUSH_MACROS |
| 147 | 147 | ||
| 148 | _LIBCPP_BEGIN_NAMESPACE_STD | 148 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 149 | 149 | ||
| 150 | template <class _Lock> | ||
| 151 | struct __unlock_guard { | ||
| 152 | _Lock& __lock_; | ||
| 153 | |||
| 154 | _LIBCPP_HIDE_FROM_ABI __unlock_guard(_Lock& __lock) : __lock_(__lock) { __lock_.unlock(); } | ||
| 155 | |||
| 156 | _LIBCPP_HIDE_FROM_ABI ~__unlock_guard() _NOEXCEPT // turns exception to std::terminate | ||
| 157 | { | ||
| 158 | __lock_.lock(); | ||
| 159 | } | ||
| 160 | |||
| 161 | __unlock_guard(const __unlock_guard&) = delete; | ||
| 162 | __unlock_guard& operator=(const __unlock_guard&) = delete; | ||
| 163 | }; | ||
| 164 | |||
| 150 | class _LIBCPP_EXPORTED_FROM_ABI condition_variable_any { | 165 | class _LIBCPP_EXPORTED_FROM_ABI condition_variable_any { |
| 151 | condition_variable __cv_; | 166 | condition_variable __cv_; |
| 152 | shared_ptr<mutex> __mut_; | 167 | shared_ptr<mutex> __mut_; |
| ... | @@ -158,13 +173,25 @@ public: | ... | @@ -158,13 +173,25 @@ public: |
| 158 | _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT; | 173 | _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT; |
| 159 | 174 | ||
| 160 | template <class _Lock> | 175 | template <class _Lock> |
| 161 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS void wait(_Lock& __lock); | 176 | _LIBCPP_HIDE_FROM_ABI void wait(_Lock& __lock) { |
| 177 | shared_ptr<mutex> __mut = __mut_; | ||
| 178 | unique_lock<mutex> __lk(*__mut); | ||
| 179 | __unlock_guard<_Lock> __unlock(__lock); | ||
| 180 | lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t()); | ||
| 181 | __cv_.wait(__lk); | ||
| 182 | } // __mut_.unlock(), __lock.lock() | ||
| 183 | |||
| 162 | template <class _Lock, class _Predicate> | 184 | template <class _Lock, class _Predicate> |
| 163 | _LIBCPP_HIDE_FROM_ABI void wait(_Lock& __lock, _Predicate __pred); | 185 | _LIBCPP_HIDE_FROM_ABI void wait(_Lock& __lock, _Predicate __pred); |
| 164 | 186 | ||
| 165 | template <class _Lock, class _Clock, class _Duration> | 187 | template <class _Lock, class _Clock, class _Duration> |
| 166 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS cv_status | 188 | _LIBCPP_HIDE_FROM_ABI cv_status wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t) { |
| 167 | wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t); | 189 | shared_ptr<mutex> __mut = __mut_; |
| 190 | unique_lock<mutex> __lk(*__mut); | ||
| 191 | __unlock_guard<_Lock> __unlock(__lock); | ||
| 192 | lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t()); | ||
| 193 | return __cv_.wait_until(__lk, __t); | ||
| 194 | } // __mut_.unlock(), __lock.lock() | ||
| 168 | 195 | ||
| 169 | template <class _Lock, class _Clock, class _Duration, class _Predicate> | 196 | template <class _Lock, class _Clock, class _Duration, class _Predicate> |
| 170 | bool _LIBCPP_HIDE_FROM_ABI | 197 | bool _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -204,45 +231,12 @@ inline void condition_variable_any::notify_all() _NOEXCEPT { | ... | @@ -204,45 +231,12 @@ inline void condition_variable_any::notify_all() _NOEXCEPT { |
| 204 | __cv_.notify_all(); | 231 | __cv_.notify_all(); |
| 205 | } | 232 | } |
| 206 | 233 | ||
| 207 | template <class _Lock> | ||
| 208 | struct __unlock_guard { | ||
| 209 | _Lock& __lock_; | ||
| 210 | |||
| 211 | _LIBCPP_HIDE_FROM_ABI __unlock_guard(_Lock& __lock) : __lock_(__lock) { __lock_.unlock(); } | ||
| 212 | |||
| 213 | _LIBCPP_HIDE_FROM_ABI ~__unlock_guard() _NOEXCEPT // turns exception to std::terminate | ||
| 214 | { | ||
| 215 | __lock_.lock(); | ||
| 216 | } | ||
| 217 | |||
| 218 | __unlock_guard(const __unlock_guard&) = delete; | ||
| 219 | __unlock_guard& operator=(const __unlock_guard&) = delete; | ||
| 220 | }; | ||
| 221 | |||
| 222 | template <class _Lock> | ||
| 223 | void condition_variable_any::wait(_Lock& __lock) { | ||
| 224 | shared_ptr<mutex> __mut = __mut_; | ||
| 225 | unique_lock<mutex> __lk(*__mut); | ||
| 226 | __unlock_guard<_Lock> __unlock(__lock); | ||
| 227 | lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t()); | ||
| 228 | __cv_.wait(__lk); | ||
| 229 | } // __mut_.unlock(), __lock.lock() | ||
| 230 | |||
| 231 | template <class _Lock, class _Predicate> | 234 | template <class _Lock, class _Predicate> |
| 232 | inline void condition_variable_any::wait(_Lock& __lock, _Predicate __pred) { | 235 | inline void condition_variable_any::wait(_Lock& __lock, _Predicate __pred) { |
| 233 | while (!__pred()) | 236 | while (!__pred()) |
| 234 | wait(__lock); | 237 | wait(__lock); |
| 235 | } | 238 | } |
| 236 | 239 | ||
| 237 | template <class _Lock, class _Clock, class _Duration> | ||
| 238 | cv_status condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t) { | ||
| 239 | shared_ptr<mutex> __mut = __mut_; | ||
| 240 | unique_lock<mutex> __lk(*__mut); | ||
| 241 | __unlock_guard<_Lock> __unlock(__lock); | ||
| 242 | lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t()); | ||
| 243 | return __cv_.wait_until(__lk, __t); | ||
| 244 | } // __mut_.unlock(), __lock.lock() | ||
| 245 | |||
| 246 | template <class _Lock, class _Clock, class _Duration, class _Predicate> | 240 | template <class _Lock, class _Clock, class _Duration, class _Predicate> |
| 247 | inline bool | 241 | inline bool |
| 248 | condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) { | 242 | condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) { |
| ... | @@ -363,6 +357,7 @@ _LIBCPP_POP_MACROS | ... | @@ -363,6 +357,7 @@ _LIBCPP_POP_MACROS |
| 363 | # include <initializer_list> | 357 | # include <initializer_list> |
| 364 | # include <iosfwd> | 358 | # include <iosfwd> |
| 365 | # include <new> | 359 | # include <new> |
| 360 | # include <optional> | ||
| 366 | # include <stdexcept> | 361 | # include <stdexcept> |
| 367 | # include <system_error> | 362 | # include <system_error> |
| 368 | # include <type_traits> | 363 | # include <type_traits> |
lib/libcxx/include/coroutine+1-1| ... | @@ -39,7 +39,7 @@ struct suspend_always; | ... | @@ -39,7 +39,7 @@ struct suspend_always; |
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 41 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 42 | # include <__cxx03/coroutine> | 42 | # include <__cxx03/__config> |
| 43 | #else | 43 | #else |
| 44 | # include <__config> | 44 | # include <__config> |
| 45 | 45 |
lib/libcxx/include/cwchar+2-1| ... | @@ -107,6 +107,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, | ... | @@ -107,6 +107,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 107 | #else | 107 | #else |
| 108 | # include <__config> | 108 | # include <__config> |
| 109 | # include <__cstddef/size_t.h> | 109 | # include <__cstddef/size_t.h> |
| 110 | # include <__memory/addressof.h> | ||
| 110 | # include <__type_traits/copy_cv.h> | 111 | # include <__type_traits/copy_cv.h> |
| 111 | # include <__type_traits/is_constant_evaluated.h> | 112 | # include <__type_traits/is_constant_evaluated.h> |
| 112 | # include <__type_traits/is_equality_comparable.h> | 113 | # include <__type_traits/is_equality_comparable.h> |
| ... | @@ -237,7 +238,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp | ... | @@ -237,7 +238,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp |
| 237 | # if __has_builtin(__builtin_wmemchr) | 238 | # if __has_builtin(__builtin_wmemchr) |
| 238 | if (!__libcpp_is_constant_evaluated()) { | 239 | if (!__libcpp_is_constant_evaluated()) { |
| 239 | wchar_t __value_buffer = 0; | 240 | wchar_t __value_buffer = 0; |
| 240 | __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t)); | 241 | __builtin_memcpy(&__value_buffer, std::addressof(__value), sizeof(wchar_t)); |
| 241 | return reinterpret_cast<_Tp*>( | 242 | return reinterpret_cast<_Tp*>( |
| 242 | __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count)); | 243 | __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count)); |
| 243 | } | 244 | } |
lib/libcxx/include/deque+35-26| ... | @@ -59,9 +59,9 @@ public: | ... | @@ -59,9 +59,9 @@ public: |
| 59 | 59 | ||
| 60 | deque& operator=(const deque& c); | 60 | deque& operator=(const deque& c); |
| 61 | deque& operator=(deque&& c) | 61 | deque& operator=(deque&& c) |
| 62 | noexcept( | 62 | noexcept((allocator_traits<allocator_type>::propagate_on_container_move_assignment::value && |
| 63 | allocator_type::propagate_on_container_move_assignment::value && | 63 | is_nothrow_move_assignable<allocator_type>::value) || |
| 64 | is_nothrow_move_assignable<allocator_type>::value); | 64 | allocator_traits<allocator_type>::is_always_equal::value); |
| 65 | deque& operator=(initializer_list<value_type> il); | 65 | deque& operator=(initializer_list<value_type> il); |
| 66 | 66 | ||
| 67 | template <class InputIterator> | 67 | template <class InputIterator> |
| ... | @@ -230,6 +230,7 @@ template <class T, class Allocator, class Predicate> | ... | @@ -230,6 +230,7 @@ template <class T, class Allocator, class Predicate> |
| 230 | # include <__type_traits/is_convertible.h> | 230 | # include <__type_traits/is_convertible.h> |
| 231 | # include <__type_traits/is_nothrow_assignable.h> | 231 | # include <__type_traits/is_nothrow_assignable.h> |
| 232 | # include <__type_traits/is_nothrow_constructible.h> | 232 | # include <__type_traits/is_nothrow_constructible.h> |
| 233 | # include <__type_traits/is_replaceable.h> | ||
| 233 | # include <__type_traits/is_same.h> | 234 | # include <__type_traits/is_same.h> |
| 234 | # include <__type_traits/is_swappable.h> | 235 | # include <__type_traits/is_swappable.h> |
| 235 | # include <__type_traits/is_trivially_relocatable.h> | 236 | # include <__type_traits/is_trivially_relocatable.h> |
| ... | @@ -283,7 +284,7 @@ template <class _ValueType, | ... | @@ -283,7 +284,7 @@ template <class _ValueType, |
| 283 | __deque_block_size<_ValueType, _DiffType>::value | 284 | __deque_block_size<_ValueType, _DiffType>::value |
| 284 | # endif | 285 | # endif |
| 285 | > | 286 | > |
| 286 | class _LIBCPP_TEMPLATE_VIS __deque_iterator { | 287 | class __deque_iterator { |
| 287 | typedef _MapPointer __map_iterator; | 288 | typedef _MapPointer __map_iterator; |
| 288 | 289 | ||
| 289 | public: | 290 | public: |
| ... | @@ -444,9 +445,9 @@ private: | ... | @@ -444,9 +445,9 @@ private: |
| 444 | __ptr_(__p) {} | 445 | __ptr_(__p) {} |
| 445 | 446 | ||
| 446 | template <class _Tp, class _Ap> | 447 | template <class _Tp, class _Ap> |
| 447 | friend class _LIBCPP_TEMPLATE_VIS deque; | 448 | friend class deque; |
| 448 | template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp> | 449 | template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp> |
| 449 | friend class _LIBCPP_TEMPLATE_VIS __deque_iterator; | 450 | friend class __deque_iterator; |
| 450 | 451 | ||
| 451 | template <class> | 452 | template <class> |
| 452 | friend struct __segmented_iterator_traits; | 453 | friend struct __segmented_iterator_traits; |
| ... | @@ -486,7 +487,7 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, | ... | @@ -486,7 +487,7 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, |
| 486 | __deque_block_size<_ValueType, _DiffType>::value; | 487 | __deque_block_size<_ValueType, _DiffType>::value; |
| 487 | 488 | ||
| 488 | template <class _Tp, class _Allocator /*= allocator<_Tp>*/> | 489 | template <class _Tp, class _Allocator /*= allocator<_Tp>*/> |
| 489 | class _LIBCPP_TEMPLATE_VIS deque { | 490 | class deque { |
| 490 | public: | 491 | public: |
| 491 | // types: | 492 | // types: |
| 492 | 493 | ||
| ... | @@ -530,6 +531,10 @@ public: | ... | @@ -530,6 +531,10 @@ public: |
| 530 | __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | 531 | __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 531 | deque, | 532 | deque, |
| 532 | void>; | 533 | void>; |
| 534 | using __replaceable _LIBCPP_NODEBUG = | ||
| 535 | __conditional_t<__is_replaceable_v<__map> && __container_allocator_is_replaceable<__alloc_traits>::value, | ||
| 536 | deque, | ||
| 537 | void>; | ||
| 533 | 538 | ||
| 534 | static_assert(is_nothrow_default_constructible<allocator_type>::value == | 539 | static_assert(is_nothrow_default_constructible<allocator_type>::value == |
| 535 | is_nothrow_default_constructible<__pointer_allocator>::value, | 540 | is_nothrow_default_constructible<__pointer_allocator>::value, |
| ... | @@ -674,9 +679,10 @@ public: | ... | @@ -674,9 +679,10 @@ public: |
| 674 | 679 | ||
| 675 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value); | 680 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value); |
| 676 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c, const __type_identity_t<allocator_type>& __a); | 681 | _LIBCPP_HIDE_FROM_ABI deque(deque&& __c, const __type_identity_t<allocator_type>& __a); |
| 677 | _LIBCPP_HIDE_FROM_ABI deque& | 682 | _LIBCPP_HIDE_FROM_ABI deque& operator=(deque&& __c) noexcept( |
| 678 | operator=(deque&& __c) noexcept(__alloc_traits::propagate_on_container_move_assignment::value && | 683 | (__alloc_traits::propagate_on_container_move_assignment::value && |
| 679 | is_nothrow_move_assignable<allocator_type>::value); | 684 | is_nothrow_move_assignable<allocator_type>::value) || |
| 685 | __alloc_traits::is_always_equal::value); | ||
| 680 | 686 | ||
| 681 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } | 687 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } |
| 682 | # endif // _LIBCPP_CXX03_LANG | 688 | # endif // _LIBCPP_CXX03_LANG |
| ... | @@ -924,7 +930,7 @@ private: | ... | @@ -924,7 +930,7 @@ private: |
| 924 | (void)__end; | 930 | (void)__end; |
| 925 | (void)__annotation_type; | 931 | (void)__annotation_type; |
| 926 | (void)__place; | 932 | (void)__place; |
| 927 | # if _LIBCPP_HAS_ASAN | 933 | # if __has_feature(address_sanitizer) |
| 928 | // __beg - index of the first item to annotate | 934 | // __beg - index of the first item to annotate |
| 929 | // __end - index behind the last item to annotate (so last item + 1) | 935 | // __end - index behind the last item to annotate (so last item + 1) |
| 930 | // __annotation_type - __asan_unposion or __asan_poison | 936 | // __annotation_type - __asan_unposion or __asan_poison |
| ... | @@ -1017,23 +1023,23 @@ private: | ... | @@ -1017,23 +1023,23 @@ private: |
| 1017 | std::__annotate_double_ended_contiguous_container<_Allocator>( | 1023 | std::__annotate_double_ended_contiguous_container<_Allocator>( |
| 1018 | __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end); | 1024 | __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end); |
| 1019 | } | 1025 | } |
| 1020 | # endif // _LIBCPP_HAS_ASAN | 1026 | # endif // __has_feature(address_sanitizer) |
| 1021 | } | 1027 | } |
| 1022 | 1028 | ||
| 1023 | _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { | 1029 | _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| 1024 | (void)__current_size; | 1030 | (void)__current_size; |
| 1025 | # if _LIBCPP_HAS_ASAN | 1031 | # if __has_feature(address_sanitizer) |
| 1026 | if (__current_size == 0) | 1032 | if (__current_size == 0) |
| 1027 | __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved); | 1033 | __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved); |
| 1028 | else { | 1034 | else { |
| 1029 | __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved); | 1035 | __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved); |
| 1030 | __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved); | 1036 | __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved); |
| 1031 | } | 1037 | } |
| 1032 | # endif // _LIBCPP_HAS_ASAN | 1038 | # endif // __has_feature(address_sanitizer) |
| 1033 | } | 1039 | } |
| 1034 | 1040 | ||
| 1035 | _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { | 1041 | _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { |
| 1036 | # if _LIBCPP_HAS_ASAN | 1042 | # if __has_feature(address_sanitizer) |
| 1037 | if (empty()) { | 1043 | if (empty()) { |
| 1038 | for (size_t __i = 0; __i < __map_.size(); ++__i) { | 1044 | for (size_t __i = 0; __i < __map_.size(); ++__i) { |
| 1039 | __annotate_whole_block(__i, __asan_unposion); | 1045 | __annotate_whole_block(__i, __asan_unposion); |
| ... | @@ -1042,19 +1048,19 @@ private: | ... | @@ -1042,19 +1048,19 @@ private: |
| 1042 | __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved); | 1048 | __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved); |
| 1043 | __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved); | 1049 | __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved); |
| 1044 | } | 1050 | } |
| 1045 | # endif // _LIBCPP_HAS_ASAN | 1051 | # endif // __has_feature(address_sanitizer) |
| 1046 | } | 1052 | } |
| 1047 | 1053 | ||
| 1048 | _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT { | 1054 | _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT { |
| 1049 | (void)__n; | 1055 | (void)__n; |
| 1050 | # if _LIBCPP_HAS_ASAN | 1056 | # if __has_feature(address_sanitizer) |
| 1051 | __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved); | 1057 | __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved); |
| 1052 | # endif | 1058 | # endif |
| 1053 | } | 1059 | } |
| 1054 | 1060 | ||
| 1055 | _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT { | 1061 | _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT { |
| 1056 | (void)__n; | 1062 | (void)__n; |
| 1057 | # if _LIBCPP_HAS_ASAN | 1063 | # if __has_feature(address_sanitizer) |
| 1058 | __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved); | 1064 | __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved); |
| 1059 | # endif | 1065 | # endif |
| 1060 | } | 1066 | } |
| ... | @@ -1062,7 +1068,7 @@ private: | ... | @@ -1062,7 +1068,7 @@ private: |
| 1062 | _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT { | 1068 | _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT { |
| 1063 | (void)__old_size; | 1069 | (void)__old_size; |
| 1064 | (void)__old_start; | 1070 | (void)__old_start; |
| 1065 | # if _LIBCPP_HAS_ASAN | 1071 | # if __has_feature(address_sanitizer) |
| 1066 | __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved); | 1072 | __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved); |
| 1067 | # endif | 1073 | # endif |
| 1068 | } | 1074 | } |
| ... | @@ -1070,7 +1076,7 @@ private: | ... | @@ -1070,7 +1076,7 @@ private: |
| 1070 | _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT { | 1076 | _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT { |
| 1071 | (void)__old_size; | 1077 | (void)__old_size; |
| 1072 | (void)__old_start; | 1078 | (void)__old_start; |
| 1073 | # if _LIBCPP_HAS_ASAN | 1079 | # if __has_feature(address_sanitizer) |
| 1074 | __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved); | 1080 | __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved); |
| 1075 | # endif | 1081 | # endif |
| 1076 | } | 1082 | } |
| ... | @@ -1083,7 +1089,7 @@ private: | ... | @@ -1083,7 +1089,7 @@ private: |
| 1083 | __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT { | 1089 | __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT { |
| 1084 | (void)__block_index; | 1090 | (void)__block_index; |
| 1085 | (void)__annotation_type; | 1091 | (void)__annotation_type; |
| 1086 | # if _LIBCPP_HAS_ASAN | 1092 | # if __has_feature(address_sanitizer) |
| 1087 | __map_const_iterator __block_it = __map_.begin() + __block_index; | 1093 | __map_const_iterator __block_it = __map_.begin() + __block_index; |
| 1088 | const void* __block_start = std::__to_address(*__block_it); | 1094 | const void* __block_start = std::__to_address(*__block_it); |
| 1089 | const void* __block_end = std::__to_address(*__block_it + __block_size); | 1095 | const void* __block_end = std::__to_address(*__block_it + __block_size); |
| ... | @@ -1096,7 +1102,7 @@ private: | ... | @@ -1096,7 +1102,7 @@ private: |
| 1096 | } | 1102 | } |
| 1097 | # endif | 1103 | # endif |
| 1098 | } | 1104 | } |
| 1099 | # if _LIBCPP_HAS_ASAN | 1105 | # if __has_feature(address_sanitizer) |
| 1100 | 1106 | ||
| 1101 | public: | 1107 | public: |
| 1102 | _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT { | 1108 | _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT { |
| ... | @@ -1158,7 +1164,7 @@ public: | ... | @@ -1158,7 +1164,7 @@ public: |
| 1158 | } | 1164 | } |
| 1159 | 1165 | ||
| 1160 | private: | 1166 | private: |
| 1161 | # endif // _LIBCPP_HAS_ASAN | 1167 | # endif // __has_feature(address_sanitizer) |
| 1162 | _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) { | 1168 | _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) { |
| 1163 | if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) { | 1169 | if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) { |
| 1164 | __annotate_whole_block(0, __asan_unposion); | 1170 | __annotate_whole_block(0, __asan_unposion); |
| ... | @@ -1379,8 +1385,9 @@ inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<alloca | ... | @@ -1379,8 +1385,9 @@ inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<alloca |
| 1379 | 1385 | ||
| 1380 | template <class _Tp, class _Allocator> | 1386 | template <class _Tp, class _Allocator> |
| 1381 | inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) noexcept( | 1387 | inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) noexcept( |
| 1382 | __alloc_traits::propagate_on_container_move_assignment::value && | 1388 | (__alloc_traits::propagate_on_container_move_assignment::value && |
| 1383 | is_nothrow_move_assignable<allocator_type>::value) { | 1389 | is_nothrow_move_assignable<allocator_type>::value) || |
| 1390 | __alloc_traits::is_always_equal::value) { | ||
| 1384 | __move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | 1391 | __move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); |
| 1385 | return *this; | 1392 | return *this; |
| 1386 | } | 1393 | } |
| ... | @@ -2623,7 +2630,9 @@ struct __container_traits<deque<_Tp, _Allocator> > { | ... | @@ -2623,7 +2630,9 @@ struct __container_traits<deque<_Tp, _Allocator> > { |
| 2623 | // either end, there are no effects. Otherwise, if an exception is thrown by the move constructor of a | 2630 | // either end, there are no effects. Otherwise, if an exception is thrown by the move constructor of a |
| 2624 | // non-Cpp17CopyInsertable T, the effects are unspecified. | 2631 | // non-Cpp17CopyInsertable T, the effects are unspecified. |
| 2625 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | 2632 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = |
| 2626 | _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value; | 2633 | is_nothrow_move_constructible<_Tp>::value || __is_cpp17_copy_insertable_v<_Allocator>; |
| 2634 | |||
| 2635 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 2627 | }; | 2636 | }; |
| 2628 | 2637 | ||
| 2629 | _LIBCPP_END_NAMESPACE_STD | 2638 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/execution+1-1| ... | @@ -33,7 +33,7 @@ namespace std { | ... | @@ -33,7 +33,7 @@ namespace std { |
| 33 | */ | 33 | */ |
| 34 | 34 | ||
| 35 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 35 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 36 | # include <__cxx03/execution> | 36 | # include <__cxx03/__config> |
| 37 | #else | 37 | #else |
| 38 | # include <__config> | 38 | # include <__config> |
| 39 | # include <__type_traits/is_execution_policy.h> | 39 | # include <__type_traits/is_execution_policy.h> |
lib/libcxx/include/expected+1-1| ... | @@ -39,7 +39,7 @@ namespace std { | ... | @@ -39,7 +39,7 @@ namespace std { |
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 41 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 42 | # include <__cxx03/expected> | 42 | # include <__cxx03/__config> |
| 43 | #else | 43 | #else |
| 44 | # include <__config> | 44 | # include <__config> |
| 45 | 45 |
lib/libcxx/include/experimental/__simd/declaration.h+1-1| ... | @@ -49,7 +49,7 @@ using native = __vec_ext<_LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>; | ... | @@ -49,7 +49,7 @@ using native = __vec_ext<_LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>; |
| 49 | // TODO: make this platform dependent | 49 | // TODO: make this platform dependent |
| 50 | template <class _Tp, size_t _Np, class... _Abis> | 50 | template <class _Tp, size_t _Np, class... _Abis> |
| 51 | struct deduce { | 51 | struct deduce { |
| 52 | using type = fixed_size<_Np>; | 52 | using type _LIBCPP_NODEBUG = fixed_size<_Np>; |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | // TODO: make this platform dependent | 55 | // TODO: make this platform dependent |
lib/libcxx/include/experimental/__simd/utility.h+1-1| ... | @@ -58,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() { | ... | @@ -58,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() { |
| 58 | 58 | ||
| 59 | template <class _Tp> | 59 | template <class _Tp> |
| 60 | _LIBCPP_HIDE_FROM_ABI auto constexpr __set_all_bits(bool __v) { | 60 | _LIBCPP_HIDE_FROM_ABI auto constexpr __set_all_bits(bool __v) { |
| 61 | return __v ? (numeric_limits<decltype(__choose_mask_type<_Tp>())>::max()) : 0; | 61 | return __v ? (numeric_limits<decltype(experimental::__choose_mask_type<_Tp>())>::max()) : 0; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | template <class _From, class _To, class = void> | 64 | template <class _From, class _To, class = void> |
lib/libcxx/include/experimental/iterator+7-1| ... | @@ -53,7 +53,7 @@ namespace std { | ... | @@ -53,7 +53,7 @@ namespace std { |
| 53 | */ | 53 | */ |
| 54 | 54 | ||
| 55 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 55 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 56 | # include <__cxx03/experimental/iterator> | 56 | # include <__cxx03/__config> |
| 57 | #else | 57 | #else |
| 58 | # include <__config> | 58 | # include <__config> |
| 59 | # include <__memory/addressof.h> | 59 | # include <__memory/addressof.h> |
| ... | @@ -127,8 +127,14 @@ _LIBCPP_POP_MACROS | ... | @@ -127,8 +127,14 @@ _LIBCPP_POP_MACROS |
| 127 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 127 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 128 | # include <cstddef> | 128 | # include <cstddef> |
| 129 | # include <iosfwd> | 129 | # include <iosfwd> |
| 130 | # include <optional> | ||
| 130 | # include <type_traits> | 131 | # include <type_traits> |
| 131 | # endif | 132 | # endif |
| 133 | |||
| 134 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | ||
| 135 | # include <locale> | ||
| 136 | # endif | ||
| 137 | |||
| 132 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 138 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 133 | 139 | ||
| 134 | #endif // _LIBCPP_EXPERIMENTAL_ITERATOR | 140 | #endif // _LIBCPP_EXPERIMENTAL_ITERATOR |
lib/libcxx/include/experimental/memory+2-2| ... | @@ -50,15 +50,15 @@ public: | ... | @@ -50,15 +50,15 @@ public: |
| 50 | */ | 50 | */ |
| 51 | 51 | ||
| 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 53 | # include <__cxx03/experimental/memory> | 53 | # include <__cxx03/__config> |
| 54 | #else | 54 | #else |
| 55 | # include <__config> | 55 | # include <__config> |
| 56 | # include <__cstddef/nullptr_t.h> | 56 | # include <__cstddef/nullptr_t.h> |
| 57 | # include <__cstddef/size_t.h> | 57 | # include <__cstddef/size_t.h> |
| 58 | # include <__functional/hash.h> | 58 | # include <__functional/hash.h> |
| 59 | # include <__functional/operations.h> | 59 | # include <__functional/operations.h> |
| 60 | # include <__type_traits/add_lvalue_reference.h> | ||
| 61 | # include <__type_traits/add_pointer.h> | 60 | # include <__type_traits/add_pointer.h> |
| 61 | # include <__type_traits/add_reference.h> | ||
| 62 | # include <__type_traits/common_type.h> | 62 | # include <__type_traits/common_type.h> |
| 63 | # include <__type_traits/enable_if.h> | 63 | # include <__type_traits/enable_if.h> |
| 64 | # include <__type_traits/is_convertible.h> | 64 | # include <__type_traits/is_convertible.h> |
lib/libcxx/include/experimental/propagate_const+1-1| ... | @@ -108,7 +108,7 @@ | ... | @@ -108,7 +108,7 @@ |
| 108 | */ | 108 | */ |
| 109 | 109 | ||
| 110 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 110 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 111 | # include <__cxx03/experimental/propagate_const> | 111 | # include <__cxx03/__config> |
| 112 | #else | 112 | #else |
| 113 | # include <__config> | 113 | # include <__config> |
| 114 | # include <__cstddef/nullptr_t.h> | 114 | # include <__cstddef/nullptr_t.h> |
lib/libcxx/include/experimental/simd+1-1| ... | @@ -76,7 +76,7 @@ inline namespace parallelism_v2 { | ... | @@ -76,7 +76,7 @@ inline namespace parallelism_v2 { |
| 76 | #endif | 76 | #endif |
| 77 | 77 | ||
| 78 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 78 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 79 | # include <__cxx03/experimental/simd> | 79 | # include <__cxx03/__config> |
| 80 | #else | 80 | #else |
| 81 | # include <__config> | 81 | # include <__config> |
| 82 | # include <experimental/__simd/aligned_tag.h> | 82 | # include <experimental/__simd/aligned_tag.h> |
lib/libcxx/include/experimental/type_traits+5-5| ... | @@ -69,7 +69,7 @@ inline namespace fundamentals_v1 { | ... | @@ -69,7 +69,7 @@ inline namespace fundamentals_v1 { |
| 69 | */ | 69 | */ |
| 70 | 70 | ||
| 71 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 71 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 72 | # include <__cxx03/experimental/type_traits> | 72 | # include <__cxx03/__config> |
| 73 | #else | 73 | #else |
| 74 | # include <__config> | 74 | # include <__config> |
| 75 | 75 | ||
| ... | @@ -87,16 +87,16 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS | ... | @@ -87,16 +87,16 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 87 | // 3.3.2, Other type transformations | 87 | // 3.3.2, Other type transformations |
| 88 | /* | 88 | /* |
| 89 | template <class> | 89 | template <class> |
| 90 | class _LIBCPP_TEMPLATE_VIS raw_invocation_type; | 90 | class raw_invocation_type; |
| 91 | 91 | ||
| 92 | template <class _Fn, class ..._Args> | 92 | template <class _Fn, class ..._Args> |
| 93 | class _LIBCPP_TEMPLATE_VIS raw_invocation_type<_Fn(_Args...)>; | 93 | class raw_invocation_type<_Fn(_Args...)>; |
| 94 | 94 | ||
| 95 | template <class> | 95 | template <class> |
| 96 | class _LIBCPP_TEMPLATE_VIS invokation_type; | 96 | class invokation_type; |
| 97 | 97 | ||
| 98 | template <class _Fn, class ..._Args> | 98 | template <class _Fn, class ..._Args> |
| 99 | class _LIBCPP_TEMPLATE_VIS invokation_type<_Fn(_Args...)>; | 99 | class invokation_type<_Fn(_Args...)>; |
| 100 | 100 | ||
| 101 | template <class _Tp> | 101 | template <class _Tp> |
| 102 | using invokation_type_t = typename invokation_type<_Tp>::type; | 102 | using invokation_type_t = typename invokation_type<_Tp>::type; |
lib/libcxx/include/experimental/utility+1-1| ... | @@ -42,7 +42,7 @@ inline namespace fundamentals_v1 { | ... | @@ -42,7 +42,7 @@ inline namespace fundamentals_v1 { |
| 42 | 42 | ||
| 43 | _LIBCPP_BEGIN_NAMESPACE_LFTS | 43 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 44 | 44 | ||
| 45 | struct _LIBCPP_TEMPLATE_VIS erased_type {}; | 45 | struct erased_type {}; |
| 46 | 46 | ||
| 47 | _LIBCPP_END_NAMESPACE_LFTS | 47 | _LIBCPP_END_NAMESPACE_LFTS |
| 48 | 48 |
lib/libcxx/include/ext/__hash+12-12| ... | @@ -20,64 +20,64 @@ | ... | @@ -20,64 +20,64 @@ |
| 20 | namespace __gnu_cxx { | 20 | namespace __gnu_cxx { |
| 21 | 21 | ||
| 22 | template <typename _Tp> | 22 | template <typename _Tp> |
| 23 | struct _LIBCPP_TEMPLATE_VIS hash {}; | 23 | struct hash {}; |
| 24 | 24 | ||
| 25 | template <> | 25 | template <> |
| 26 | struct _LIBCPP_TEMPLATE_VIS hash<const char*> : public std::__unary_function<const char*, size_t> { | 26 | struct hash<const char*> : public std::__unary_function<const char*, size_t> { |
| 27 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const char* __c) const _NOEXCEPT { | 27 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const char* __c) const _NOEXCEPT { |
| 28 | return std::__do_string_hash(__c, __c + strlen(__c)); | 28 | return std::__do_string_hash(__c, __c + strlen(__c)); |
| 29 | } | 29 | } |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | template <> | 32 | template <> |
| 33 | struct _LIBCPP_TEMPLATE_VIS hash<char*> : public std::__unary_function<char*, size_t> { | 33 | struct hash<char*> : public std::__unary_function<char*, size_t> { |
| 34 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char* __c) const _NOEXCEPT { | 34 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char* __c) const _NOEXCEPT { |
| 35 | return std::__do_string_hash<const char*>(__c, __c + strlen(__c)); | 35 | return std::__do_string_hash<const char*>(__c, __c + strlen(__c)); |
| 36 | } | 36 | } |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | template <> | 39 | template <> |
| 40 | struct _LIBCPP_TEMPLATE_VIS hash<char> : public std::__unary_function<char, size_t> { | 40 | struct hash<char> : public std::__unary_function<char, size_t> { |
| 41 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char __c) const _NOEXCEPT { return __c; } | 41 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char __c) const _NOEXCEPT { return __c; } |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | template <> | 44 | template <> |
| 45 | struct _LIBCPP_TEMPLATE_VIS hash<signed char> : public std::__unary_function<signed char, size_t> { | 45 | struct hash<signed char> : public std::__unary_function<signed char, size_t> { |
| 46 | _LIBCPP_HIDE_FROM_ABI size_t operator()(signed char __c) const _NOEXCEPT { return __c; } | 46 | _LIBCPP_HIDE_FROM_ABI size_t operator()(signed char __c) const _NOEXCEPT { return __c; } |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | template <> | 49 | template <> |
| 50 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public std::__unary_function<unsigned char, size_t> { | 50 | struct hash<unsigned char> : public std::__unary_function<unsigned char, size_t> { |
| 51 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __c) const _NOEXCEPT { return __c; } | 51 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __c) const _NOEXCEPT { return __c; } |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | template <> | 54 | template <> |
| 55 | struct _LIBCPP_TEMPLATE_VIS hash<short> : public std::__unary_function<short, size_t> { | 55 | struct hash<short> : public std::__unary_function<short, size_t> { |
| 56 | _LIBCPP_HIDE_FROM_ABI size_t operator()(short __c) const _NOEXCEPT { return __c; } | 56 | _LIBCPP_HIDE_FROM_ABI size_t operator()(short __c) const _NOEXCEPT { return __c; } |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | template <> | 59 | template <> |
| 60 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> : public std::__unary_function<unsigned short, size_t> { | 60 | struct hash<unsigned short> : public std::__unary_function<unsigned short, size_t> { |
| 61 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned short __c) const _NOEXCEPT { return __c; } | 61 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned short __c) const _NOEXCEPT { return __c; } |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| 64 | template <> | 64 | template <> |
| 65 | struct _LIBCPP_TEMPLATE_VIS hash<int> : public std::__unary_function<int, size_t> { | 65 | struct hash<int> : public std::__unary_function<int, size_t> { |
| 66 | _LIBCPP_HIDE_FROM_ABI size_t operator()(int __c) const _NOEXCEPT { return __c; } | 66 | _LIBCPP_HIDE_FROM_ABI size_t operator()(int __c) const _NOEXCEPT { return __c; } |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
| 69 | template <> | 69 | template <> |
| 70 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> : public std::__unary_function<unsigned int, size_t> { | 70 | struct hash<unsigned int> : public std::__unary_function<unsigned int, size_t> { |
| 71 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned int __c) const _NOEXCEPT { return __c; } | 71 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned int __c) const _NOEXCEPT { return __c; } |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| 74 | template <> | 74 | template <> |
| 75 | struct _LIBCPP_TEMPLATE_VIS hash<long> : public std::__unary_function<long, size_t> { | 75 | struct hash<long> : public std::__unary_function<long, size_t> { |
| 76 | _LIBCPP_HIDE_FROM_ABI size_t operator()(long __c) const _NOEXCEPT { return __c; } | 76 | _LIBCPP_HIDE_FROM_ABI size_t operator()(long __c) const _NOEXCEPT { return __c; } |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | template <> | 79 | template <> |
| 80 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public std::__unary_function<unsigned long, size_t> { | 80 | struct hash<unsigned long> : public std::__unary_function<unsigned long, size_t> { |
| 81 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __c) const _NOEXCEPT { return __c; } | 81 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __c) const _NOEXCEPT { return __c; } |
| 82 | }; | 82 | }; |
| 83 | } // namespace __gnu_cxx | 83 | } // namespace __gnu_cxx |
lib/libcxx/include/ext/hash_map+17-17| ... | @@ -338,7 +338,7 @@ public: | ... | @@ -338,7 +338,7 @@ public: |
| 338 | }; | 338 | }; |
| 339 | 339 | ||
| 340 | template <class _HashIterator> | 340 | template <class _HashIterator> |
| 341 | class _LIBCPP_TEMPLATE_VIS __hash_map_iterator { | 341 | class __hash_map_iterator { |
| 342 | _HashIterator __i_; | 342 | _HashIterator __i_; |
| 343 | 343 | ||
| 344 | typedef const typename _HashIterator::value_type::first_type key_type; | 344 | typedef const typename _HashIterator::value_type::first_type key_type; |
| ... | @@ -376,19 +376,19 @@ public: | ... | @@ -376,19 +376,19 @@ public: |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | template <class, class, class, class, class> | 378 | template <class, class, class, class, class> |
| 379 | friend class _LIBCPP_TEMPLATE_VIS hash_map; | 379 | friend class hash_map; |
| 380 | template <class, class, class, class, class> | 380 | template <class, class, class, class, class> |
| 381 | friend class _LIBCPP_TEMPLATE_VIS hash_multimap; | 381 | friend class hash_multimap; |
| 382 | template <class> | 382 | template <class> |
| 383 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; | 383 | friend class __hash_const_iterator; |
| 384 | template <class> | 384 | template <class> |
| 385 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; | 385 | friend class __hash_const_local_iterator; |
| 386 | template <class> | 386 | template <class> |
| 387 | friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; | 387 | friend class __hash_map_const_iterator; |
| 388 | }; | 388 | }; |
| 389 | 389 | ||
| 390 | template <class _HashIterator> | 390 | template <class _HashIterator> |
| 391 | class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator { | 391 | class __hash_map_const_iterator { |
| 392 | _HashIterator __i_; | 392 | _HashIterator __i_; |
| 393 | 393 | ||
| 394 | typedef const typename _HashIterator::value_type::first_type key_type; | 394 | typedef const typename _HashIterator::value_type::first_type key_type; |
| ... | @@ -430,13 +430,13 @@ public: | ... | @@ -430,13 +430,13 @@ public: |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | template <class, class, class, class, class> | 432 | template <class, class, class, class, class> |
| 433 | friend class _LIBCPP_TEMPLATE_VIS hash_map; | 433 | friend class hash_map; |
| 434 | template <class, class, class, class, class> | 434 | template <class, class, class, class, class> |
| 435 | friend class _LIBCPP_TEMPLATE_VIS hash_multimap; | 435 | friend class hash_multimap; |
| 436 | template <class> | 436 | template <class> |
| 437 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; | 437 | friend class __hash_const_iterator; |
| 438 | template <class> | 438 | template <class> |
| 439 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; | 439 | friend class __hash_const_local_iterator; |
| 440 | }; | 440 | }; |
| 441 | 441 | ||
| 442 | template <class _Key, | 442 | template <class _Key, |
| ... | @@ -444,7 +444,7 @@ template <class _Key, | ... | @@ -444,7 +444,7 @@ template <class _Key, |
| 444 | class _Hash = hash<_Key>, | 444 | class _Hash = hash<_Key>, |
| 445 | class _Pred = std::equal_to<_Key>, | 445 | class _Pred = std::equal_to<_Key>, |
| 446 | class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > | 446 | class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > |
| 447 | class _LIBCPP_TEMPLATE_VIS hash_map { | 447 | class hash_map { |
| 448 | public: | 448 | public: |
| 449 | // types | 449 | // types |
| 450 | typedef _Key key_type; | 450 | typedef _Key key_type; |
| ... | @@ -520,7 +520,7 @@ public: | ... | @@ -520,7 +520,7 @@ public: |
| 520 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } | 520 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } |
| 521 | 521 | ||
| 522 | _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) { | 522 | _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) { |
| 523 | return __table_.__insert_unique(__x); | 523 | return __table_.__emplace_unique(__x); |
| 524 | } | 524 | } |
| 525 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } | 525 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } |
| 526 | template <class _InputIterator> | 526 | template <class _InputIterator> |
| ... | @@ -625,7 +625,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -625,7 +625,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 625 | template <class _InputIterator> | 625 | template <class _InputIterator> |
| 626 | inline void hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 626 | inline void hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 627 | for (; __first != __last; ++__first) | 627 | for (; __first != __last; ++__first) |
| 628 | __table_.__insert_unique(*__first); | 628 | __table_.__emplace_unique(*__first); |
| 629 | } | 629 | } |
| 630 | 630 | ||
| 631 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 631 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -670,7 +670,7 @@ template <class _Key, | ... | @@ -670,7 +670,7 @@ template <class _Key, |
| 670 | class _Hash = hash<_Key>, | 670 | class _Hash = hash<_Key>, |
| 671 | class _Pred = std::equal_to<_Key>, | 671 | class _Pred = std::equal_to<_Key>, |
| 672 | class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > | 672 | class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > |
| 673 | class _LIBCPP_TEMPLATE_VIS hash_multimap { | 673 | class hash_multimap { |
| 674 | public: | 674 | public: |
| 675 | // types | 675 | // types |
| 676 | typedef _Key key_type; | 676 | typedef _Key key_type; |
| ... | @@ -744,7 +744,7 @@ public: | ... | @@ -744,7 +744,7 @@ public: |
| 744 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); } | 744 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); } |
| 745 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } | 745 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } |
| 746 | 746 | ||
| 747 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); } | 747 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); } |
| 748 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); } | 748 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); } |
| 749 | template <class _InputIterator> | 749 | template <class _InputIterator> |
| 750 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); | 750 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); |
| ... | @@ -831,7 +831,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -831,7 +831,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 831 | template <class _InputIterator> | 831 | template <class _InputIterator> |
| 832 | inline void hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 832 | inline void hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 833 | for (; __first != __last; ++__first) | 833 | for (; __first != __last; ++__first) |
| 834 | __table_.__insert_multi(*__first); | 834 | __table_.__emplace_multi(*__first); |
| 835 | } | 835 | } |
| 836 | 836 | ||
| 837 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 837 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
lib/libcxx/include/ext/hash_set+6-6| ... | @@ -219,7 +219,7 @@ template <class _Value, | ... | @@ -219,7 +219,7 @@ template <class _Value, |
| 219 | class _Hash = hash<_Value>, | 219 | class _Hash = hash<_Value>, |
| 220 | class _Pred = std::equal_to<_Value>, | 220 | class _Pred = std::equal_to<_Value>, |
| 221 | class _Alloc = std::allocator<_Value> > | 221 | class _Alloc = std::allocator<_Value> > |
| 222 | class _LIBCPP_TEMPLATE_VIS hash_set { | 222 | class hash_set { |
| 223 | public: | 223 | public: |
| 224 | // types | 224 | // types |
| 225 | typedef _Value key_type; | 225 | typedef _Value key_type; |
| ... | @@ -279,7 +279,7 @@ public: | ... | @@ -279,7 +279,7 @@ public: |
| 279 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } | 279 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } |
| 280 | 280 | ||
| 281 | _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) { | 281 | _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) { |
| 282 | return __table_.__insert_unique(__x); | 282 | return __table_.__emplace_unique(__x); |
| 283 | } | 283 | } |
| 284 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } | 284 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } |
| 285 | template <class _InputIterator> | 285 | template <class _InputIterator> |
| ... | @@ -365,7 +365,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> | ... | @@ -365,7 +365,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 365 | template <class _InputIterator> | 365 | template <class _InputIterator> |
| 366 | inline void hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 366 | inline void hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 367 | for (; __first != __last; ++__first) | 367 | for (; __first != __last; ++__first) |
| 368 | __table_.__insert_unique(*__first); | 368 | __table_.__emplace_unique(*__first); |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 371 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -398,7 +398,7 @@ template <class _Value, | ... | @@ -398,7 +398,7 @@ template <class _Value, |
| 398 | class _Hash = hash<_Value>, | 398 | class _Hash = hash<_Value>, |
| 399 | class _Pred = std::equal_to<_Value>, | 399 | class _Pred = std::equal_to<_Value>, |
| 400 | class _Alloc = std::allocator<_Value> > | 400 | class _Alloc = std::allocator<_Value> > |
| 401 | class _LIBCPP_TEMPLATE_VIS hash_multiset { | 401 | class hash_multiset { |
| 402 | public: | 402 | public: |
| 403 | // types | 403 | // types |
| 404 | typedef _Value key_type; | 404 | typedef _Value key_type; |
| ... | @@ -458,7 +458,7 @@ public: | ... | @@ -458,7 +458,7 @@ public: |
| 458 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); } | 458 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); } |
| 459 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } | 459 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); } |
| 460 | 460 | ||
| 461 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); } | 461 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); } |
| 462 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); } | 462 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); } |
| 463 | template <class _InputIterator> | 463 | template <class _InputIterator> |
| 464 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); | 464 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); |
| ... | @@ -543,7 +543,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> | ... | @@ -543,7 +543,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 543 | template <class _InputIterator> | 543 | template <class _InputIterator> |
| 544 | inline void hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 544 | inline void hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 545 | for (; __first != __last; ++__first) | 545 | for (; __first != __last; ++__first) |
| 546 | __table_.__insert_multi(*__first); | 546 | __table_.__emplace_multi(*__first); |
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 549 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
lib/libcxx/include/filesystem+1-1| ... | @@ -534,7 +534,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct | ... | @@ -534,7 +534,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct |
| 534 | */ | 534 | */ |
| 535 | 535 | ||
| 536 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 536 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 537 | # include <__cxx03/filesystem> | 537 | # include <__cxx03/__config> |
| 538 | #else | 538 | #else |
| 539 | # include <__config> | 539 | # include <__config> |
| 540 | 540 |
lib/libcxx/include/flat_map+9| ... | @@ -72,6 +72,15 @@ namespace std { | ... | @@ -72,6 +72,15 @@ namespace std { |
| 72 | # include <version> | 72 | # include <version> |
| 73 | 73 | ||
| 74 | // standard required includes | 74 | // standard required includes |
| 75 | |||
| 76 | // [iterator.range] | ||
| 77 | # include <__iterator/access.h> | ||
| 78 | # include <__iterator/data.h> | ||
| 79 | # include <__iterator/empty.h> | ||
| 80 | # include <__iterator/reverse_access.h> | ||
| 81 | # include <__iterator/size.h> | ||
| 82 | |||
| 83 | // [flat.map.syn] | ||
| 75 | # include <compare> | 84 | # include <compare> |
| 76 | # include <initializer_list> | 85 | # include <initializer_list> |
| 77 | 86 |
lib/libcxx/include/flat_set created+85| ... | @@ -0,0 +1,85 @@ | ||
| 1 | // -*- C++ -*- | ||
| 2 | //===----------------------------------------------------------------------===// | ||
| 3 | // | ||
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 5 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 7 | // | ||
| 8 | //===----------------------------------------------------------------------===// | ||
| 9 | |||
| 10 | #ifndef _LIBCPP_FLAT_SET | ||
| 11 | #define _LIBCPP_FLAT_SET | ||
| 12 | |||
| 13 | /* | ||
| 14 | Header <flat_set> synopsis | ||
| 15 | |||
| 16 | #include <compare> // see [compare.syn] | ||
| 17 | #include <initializer_list> // see [initializer.list.syn] | ||
| 18 | |||
| 19 | namespace std { | ||
| 20 | // [flat.set], class template flat_set | ||
| 21 | template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>> | ||
| 22 | class flat_set; | ||
| 23 | |||
| 24 | struct sorted_unique_t { explicit sorted_unique_t() = default; }; | ||
| 25 | inline constexpr sorted_unique_t sorted_unique{}; | ||
| 26 | |||
| 27 | template<class Key, class Compare, class KeyContainer, class Allocator> | ||
| 28 | struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>; | ||
| 29 | |||
| 30 | // [flat.set.erasure], erasure for flat_set | ||
| 31 | template<class Key, class Compare, class KeyContainer, class Predicate> | ||
| 32 | typename flat_set<Key, Compare, KeyContainer>::size_type | ||
| 33 | erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred); | ||
| 34 | |||
| 35 | // [flat.multiset], class template flat_multiset | ||
| 36 | template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>> | ||
| 37 | class flat_multiset; | ||
| 38 | |||
| 39 | struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; }; | ||
| 40 | inline constexpr sorted_equivalent_t sorted_equivalent{}; | ||
| 41 | |||
| 42 | template<class Key, class Compare, class KeyContainer, class Allocator> | ||
| 43 | struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>; | ||
| 44 | |||
| 45 | // [flat.multiset.erasure], erasure for flat_multiset | ||
| 46 | template<class Key, class Compare, class KeyContainer, class Predicate> | ||
| 47 | typename flat_multiset<Key, Compare, KeyContainer>::size_type | ||
| 48 | erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred); | ||
| 49 | } | ||
| 50 | */ | ||
| 51 | |||
| 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 53 | # include <__cxx03/__config> | ||
| 54 | #else | ||
| 55 | # include <__config> | ||
| 56 | |||
| 57 | # if _LIBCPP_STD_VER >= 23 | ||
| 58 | # include <__flat_map/sorted_equivalent.h> | ||
| 59 | # include <__flat_map/sorted_unique.h> | ||
| 60 | # include <__flat_set/flat_multiset.h> | ||
| 61 | # include <__flat_set/flat_set.h> | ||
| 62 | # endif | ||
| 63 | |||
| 64 | // for feature-test macros | ||
| 65 | # include <version> | ||
| 66 | |||
| 67 | // standard required includes | ||
| 68 | |||
| 69 | // [iterator.range] | ||
| 70 | # include <__iterator/access.h> | ||
| 71 | # include <__iterator/data.h> | ||
| 72 | # include <__iterator/empty.h> | ||
| 73 | # include <__iterator/reverse_access.h> | ||
| 74 | # include <__iterator/size.h> | ||
| 75 | |||
| 76 | // [flat.set.syn] | ||
| 77 | # include <compare> | ||
| 78 | # include <initializer_list> | ||
| 79 | |||
| 80 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 81 | # pragma GCC system_header | ||
| 82 | # endif | ||
| 83 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 84 | |||
| 85 | #endif // _LIBCPP_FLAT_SET | ||
lib/libcxx/include/format+1-1| ... | @@ -192,7 +192,7 @@ namespace std { | ... | @@ -192,7 +192,7 @@ namespace std { |
| 192 | */ | 192 | */ |
| 193 | 193 | ||
| 194 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 194 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 195 | # include <__cxx03/format> | 195 | # include <__cxx03/__config> |
| 196 | #else | 196 | #else |
| 197 | # include <__config> | 197 | # include <__config> |
| 198 | 198 |
lib/libcxx/include/forward_list+325-284| ... | @@ -58,9 +58,9 @@ public: | ... | @@ -58,9 +58,9 @@ public: |
| 58 | 58 | ||
| 59 | forward_list& operator=(const forward_list& x); | 59 | forward_list& operator=(const forward_list& x); |
| 60 | forward_list& operator=(forward_list&& x) | 60 | forward_list& operator=(forward_list&& x) |
| 61 | noexcept( | 61 | noexcept((__node_traits::propagate_on_container_move_assignment::value && |
| 62 | allocator_type::propagate_on_container_move_assignment::value && | 62 | is_nothrow_move_assignable<allocator_type>::value) || |
| 63 | is_nothrow_move_assignable<allocator_type>::value); | 63 | allocator_traits<allocator_type>::is_always_equal::value); |
| 64 | forward_list& operator=(initializer_list<value_type> il); | 64 | forward_list& operator=(initializer_list<value_type> il); |
| 65 | 65 | ||
| 66 | template <class InputIterator> | 66 | template <class InputIterator> |
| ... | @@ -233,6 +233,7 @@ template <class T, class Allocator, class Predicate> | ... | @@ -233,6 +233,7 @@ template <class T, class Allocator, class Predicate> |
| 233 | # include <__type_traits/is_pointer.h> | 233 | # include <__type_traits/is_pointer.h> |
| 234 | # include <__type_traits/is_same.h> | 234 | # include <__type_traits/is_same.h> |
| 235 | # include <__type_traits/is_swappable.h> | 235 | # include <__type_traits/is_swappable.h> |
| 236 | # include <__type_traits/remove_cv.h> | ||
| 236 | # include <__type_traits/type_identity.h> | 237 | # include <__type_traits/type_identity.h> |
| 237 | # include <__utility/forward.h> | 238 | # include <__utility/forward.h> |
| 238 | # include <__utility/move.h> | 239 | # include <__utility/move.h> |
| ... | @@ -282,7 +283,6 @@ struct __forward_node_traits { | ... | @@ -282,7 +283,6 @@ struct __forward_node_traits { |
| 282 | typedef _NodePtr __node_pointer; | 283 | typedef _NodePtr __node_pointer; |
| 283 | typedef __forward_begin_node<_NodePtr> __begin_node; | 284 | typedef __forward_begin_node<_NodePtr> __begin_node; |
| 284 | typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; | 285 | typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; |
| 285 | typedef __rebind_pointer_t<_NodePtr, void> __void_pointer; | ||
| 286 | 286 | ||
| 287 | // TODO(LLVM 22): Remove this check | 287 | // TODO(LLVM 22): Remove this check |
| 288 | # ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | 288 | # ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB |
| ... | @@ -294,11 +294,6 @@ struct __forward_node_traits { | ... | @@ -294,11 +294,6 @@ struct __forward_node_traits { |
| 294 | "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define " | 294 | "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define " |
| 295 | "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); | 295 | "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); |
| 296 | # endif | 296 | # endif |
| 297 | |||
| 298 | _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; } | ||
| 299 | _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) { | ||
| 300 | return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p)); | ||
| 301 | } | ||
| 302 | }; | 297 | }; |
| 303 | 298 | ||
| 304 | template <class _NodePtr> | 299 | template <class _NodePtr> |
| ... | @@ -308,12 +303,8 @@ struct __forward_begin_node { | ... | @@ -308,12 +303,8 @@ struct __forward_begin_node { |
| 308 | 303 | ||
| 309 | pointer __next_; | 304 | pointer __next_; |
| 310 | 305 | ||
| 311 | _LIBCPP_HIDE_FROM_ABI __forward_begin_node() : __next_(nullptr) {} | 306 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_begin_node() : __next_(nullptr) {} |
| 312 | _LIBCPP_HIDE_FROM_ABI explicit __forward_begin_node(pointer __n) : __next_(__n) {} | 307 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_begin_node(pointer __n) : __next_(__n) {} |
| 313 | |||
| 314 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __next_as_begin() const { | ||
| 315 | return static_cast<__begin_node_pointer>(__next_); | ||
| 316 | } | ||
| 317 | }; | 308 | }; |
| 318 | 309 | ||
| 319 | template <class _Tp, class _VoidPtr> | 310 | template <class _Tp, class _VoidPtr> |
| ... | @@ -336,7 +327,7 @@ private: | ... | @@ -336,7 +327,7 @@ private: |
| 336 | }; | 327 | }; |
| 337 | 328 | ||
| 338 | public: | 329 | public: |
| 339 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } | 330 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } |
| 340 | # else | 331 | # else |
| 341 | 332 | ||
| 342 | private: | 333 | private: |
| ... | @@ -346,43 +337,38 @@ public: | ... | @@ -346,43 +337,38 @@ public: |
| 346 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); } | 337 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); } |
| 347 | # endif | 338 | # endif |
| 348 | 339 | ||
| 349 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {} | 340 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {} |
| 350 | _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {} | 341 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {} |
| 351 | }; | 342 | }; |
| 352 | 343 | ||
| 353 | template <class _Tp, class _Alloc = allocator<_Tp> > | 344 | template <class _Tp, class _Alloc = allocator<_Tp> > |
| 354 | class _LIBCPP_TEMPLATE_VIS forward_list; | 345 | class forward_list; |
| 355 | template <class _NodeConstPtr> | 346 | template <class _NodeConstPtr> |
| 356 | class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator; | 347 | class __forward_list_const_iterator; |
| 357 | 348 | ||
| 358 | template <class _NodePtr> | 349 | template <class _NodePtr> |
| 359 | class _LIBCPP_TEMPLATE_VIS __forward_list_iterator { | 350 | class __forward_list_iterator { |
| 360 | typedef __forward_node_traits<_NodePtr> __traits; | 351 | typedef __forward_node_traits<_NodePtr> __traits; |
| 352 | typedef typename __traits::__node_type __node_type; | ||
| 353 | typedef typename __traits::__begin_node __begin_node_type; | ||
| 361 | typedef typename __traits::__node_pointer __node_pointer; | 354 | typedef typename __traits::__node_pointer __node_pointer; |
| 362 | typedef typename __traits::__begin_node_pointer __begin_node_pointer; | 355 | typedef typename __traits::__begin_node_pointer __begin_node_pointer; |
| 363 | typedef typename __traits::__void_pointer __void_pointer; | ||
| 364 | 356 | ||
| 365 | __begin_node_pointer __ptr_; | 357 | __begin_node_pointer __ptr_; |
| 366 | 358 | ||
| 367 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const { | 359 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(nullptr_t) _NOEXCEPT |
| 368 | return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_)); | 360 | : __ptr_(nullptr) {} |
| 369 | } | ||
| 370 | _LIBCPP_HIDE_FROM_ABI __node_pointer __get_unsafe_node_pointer() const { | ||
| 371 | return static_cast<__node_pointer>(static_cast<__void_pointer>(__ptr_)); | ||
| 372 | } | ||
| 373 | |||
| 374 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {} | ||
| 375 | 361 | ||
| 376 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT | 362 | _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 377 | : __ptr_(__traits::__as_iter_node(__p)) {} | 363 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT : __ptr_(__p) {} |
| 378 | 364 | ||
| 379 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT | 365 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT |
| 380 | : __ptr_(__traits::__as_iter_node(__p)) {} | 366 | : __ptr_(std::__static_fancy_pointer_cast<__begin_node_pointer>(__p)) {} |
| 381 | 367 | ||
| 382 | template <class, class> | 368 | template <class, class> |
| 383 | friend class _LIBCPP_TEMPLATE_VIS forward_list; | 369 | friend class forward_list; |
| 384 | template <class> | 370 | template <class> |
| 385 | friend class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator; | 371 | friend class __forward_list_const_iterator; |
| 386 | 372 | ||
| 387 | public: | 373 | public: |
| 388 | typedef forward_iterator_tag iterator_category; | 374 | typedef forward_iterator_tag iterator_category; |
| ... | @@ -391,58 +377,57 @@ public: | ... | @@ -391,58 +377,57 @@ public: |
| 391 | typedef typename pointer_traits<__node_pointer>::difference_type difference_type; | 377 | typedef typename pointer_traits<__node_pointer>::difference_type difference_type; |
| 392 | typedef __rebind_pointer_t<__node_pointer, value_type> pointer; | 378 | typedef __rebind_pointer_t<__node_pointer, value_type> pointer; |
| 393 | 379 | ||
| 394 | _LIBCPP_HIDE_FROM_ABI __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {} | 380 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {} |
| 395 | 381 | ||
| 396 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_unsafe_node_pointer()->__get_value(); } | 382 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 397 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 383 | return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value(); |
| 398 | return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__get_value()); | 384 | } |
| 385 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | ||
| 386 | return pointer_traits<pointer>::pointer_to(std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value()); | ||
| 399 | } | 387 | } |
| 400 | 388 | ||
| 401 | _LIBCPP_HIDE_FROM_ABI __forward_list_iterator& operator++() { | 389 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator& operator++() { |
| 402 | __ptr_ = __traits::__as_iter_node(__ptr_->__next_); | 390 | __ptr_ = std::__static_fancy_pointer_cast<__begin_node_pointer>(__ptr_->__next_); |
| 403 | return *this; | 391 | return *this; |
| 404 | } | 392 | } |
| 405 | _LIBCPP_HIDE_FROM_ABI __forward_list_iterator operator++(int) { | 393 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator operator++(int) { |
| 406 | __forward_list_iterator __t(*this); | 394 | __forward_list_iterator __t(*this); |
| 407 | ++(*this); | 395 | ++(*this); |
| 408 | return __t; | 396 | return __t; |
| 409 | } | 397 | } |
| 410 | 398 | ||
| 411 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __forward_list_iterator& __x, const __forward_list_iterator& __y) { | 399 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 400 | operator==(const __forward_list_iterator& __x, const __forward_list_iterator& __y) { | ||
| 412 | return __x.__ptr_ == __y.__ptr_; | 401 | return __x.__ptr_ == __y.__ptr_; |
| 413 | } | 402 | } |
| 414 | friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __forward_list_iterator& __x, const __forward_list_iterator& __y) { | 403 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 404 | operator!=(const __forward_list_iterator& __x, const __forward_list_iterator& __y) { | ||
| 415 | return !(__x == __y); | 405 | return !(__x == __y); |
| 416 | } | 406 | } |
| 417 | }; | 407 | }; |
| 418 | 408 | ||
| 419 | template <class _NodeConstPtr> | 409 | template <class _NodeConstPtr> |
| 420 | class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator { | 410 | class __forward_list_const_iterator { |
| 421 | static_assert(!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value, ""); | 411 | static_assert(!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value, ""); |
| 422 | typedef _NodeConstPtr _NodePtr; | 412 | typedef _NodeConstPtr _NodePtr; |
| 423 | 413 | ||
| 424 | typedef __forward_node_traits<_NodePtr> __traits; | 414 | typedef __forward_node_traits<_NodePtr> __traits; |
| 425 | typedef typename __traits::__node_type __node_type; | 415 | typedef typename __traits::__node_type __node_type; |
| 416 | typedef typename __traits::__begin_node __begin_node_type; | ||
| 426 | typedef typename __traits::__node_pointer __node_pointer; | 417 | typedef typename __traits::__node_pointer __node_pointer; |
| 427 | typedef typename __traits::__begin_node_pointer __begin_node_pointer; | 418 | typedef typename __traits::__begin_node_pointer __begin_node_pointer; |
| 428 | typedef typename __traits::__void_pointer __void_pointer; | ||
| 429 | 419 | ||
| 430 | __begin_node_pointer __ptr_; | 420 | __begin_node_pointer __ptr_; |
| 431 | 421 | ||
| 432 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const { | 422 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT |
| 433 | return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_)); | 423 | : __ptr_(nullptr) {} |
| 434 | } | ||
| 435 | _LIBCPP_HIDE_FROM_ABI __node_pointer __get_unsafe_node_pointer() const { | ||
| 436 | return static_cast<__node_pointer>(static_cast<__void_pointer>(__ptr_)); | ||
| 437 | } | ||
| 438 | |||
| 439 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {} | ||
| 440 | 424 | ||
| 441 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT | 425 | _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 442 | : __ptr_(__traits::__as_iter_node(__p)) {} | 426 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT : __ptr_(__p) {} |
| 443 | 427 | ||
| 428 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 444 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT | 429 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT |
| 445 | : __ptr_(__traits::__as_iter_node(__p)) {} | 430 | : __ptr_(std::__static_fancy_pointer_cast<__begin_node_pointer>(__p)) {} |
| 446 | 431 | ||
| 447 | template <class, class> | 432 | template <class, class> |
| 448 | friend class forward_list; | 433 | friend class forward_list; |
| ... | @@ -454,30 +439,32 @@ public: | ... | @@ -454,30 +439,32 @@ public: |
| 454 | typedef typename pointer_traits<__node_pointer>::difference_type difference_type; | 439 | typedef typename pointer_traits<__node_pointer>::difference_type difference_type; |
| 455 | typedef __rebind_pointer_t<__node_pointer, const value_type> pointer; | 440 | typedef __rebind_pointer_t<__node_pointer, const value_type> pointer; |
| 456 | 441 | ||
| 457 | _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} | 442 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} |
| 458 | _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator(__forward_list_iterator<__node_pointer> __p) _NOEXCEPT | 443 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 459 | : __ptr_(__p.__ptr_) {} | 444 | __forward_list_const_iterator(__forward_list_iterator<__node_pointer> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} |
| 460 | 445 | ||
| 461 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_unsafe_node_pointer()->__get_value(); } | 446 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 462 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 447 | return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value(); |
| 463 | return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__get_value()); | 448 | } |
| 449 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | ||
| 450 | return pointer_traits<pointer>::pointer_to(std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value()); | ||
| 464 | } | 451 | } |
| 465 | 452 | ||
| 466 | _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator& operator++() { | 453 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator& operator++() { |
| 467 | __ptr_ = __traits::__as_iter_node(__ptr_->__next_); | 454 | __ptr_ = std::__static_fancy_pointer_cast<__begin_node_pointer>(__ptr_->__next_); |
| 468 | return *this; | 455 | return *this; |
| 469 | } | 456 | } |
| 470 | _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator operator++(int) { | 457 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator operator++(int) { |
| 471 | __forward_list_const_iterator __t(*this); | 458 | __forward_list_const_iterator __t(*this); |
| 472 | ++(*this); | 459 | ++(*this); |
| 473 | return __t; | 460 | return __t; |
| 474 | } | 461 | } |
| 475 | 462 | ||
| 476 | friend _LIBCPP_HIDE_FROM_ABI bool | 463 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 477 | operator==(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) { | 464 | operator==(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) { |
| 478 | return __x.__ptr_ == __y.__ptr_; | 465 | return __x.__ptr_ == __y.__ptr_; |
| 479 | } | 466 | } |
| 480 | friend _LIBCPP_HIDE_FROM_ABI bool | 467 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 481 | operator!=(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) { | 468 | operator!=(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) { |
| 482 | return !(__x == __y); | 469 | return !(__x == __y); |
| 483 | } | 470 | } |
| ... | @@ -501,48 +488,53 @@ protected: | ... | @@ -501,48 +488,53 @@ protected: |
| 501 | 488 | ||
| 502 | _LIBCPP_COMPRESSED_PAIR(__begin_node, __before_begin_, __node_allocator, __alloc_); | 489 | _LIBCPP_COMPRESSED_PAIR(__begin_node, __before_begin_, __node_allocator, __alloc_); |
| 503 | 490 | ||
| 504 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT { | 491 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT { |
| 505 | return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_); | 492 | return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_); |
| 506 | } | 493 | } |
| 507 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT { | 494 | |
| 508 | return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_)); | 495 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT { |
| 496 | return pointer_traits<__begin_node_pointer>::pointer_to( | ||
| 497 | *const_cast<__begin_node*>(std::addressof(__before_begin_))); | ||
| 509 | } | 498 | } |
| 510 | 499 | ||
| 511 | typedef __forward_list_iterator<__node_pointer> iterator; | 500 | typedef __forward_list_iterator<__node_pointer> iterator; |
| 512 | typedef __forward_list_const_iterator<__node_pointer> const_iterator; | 501 | typedef __forward_list_const_iterator<__node_pointer> const_iterator; |
| 513 | 502 | ||
| 514 | _LIBCPP_HIDE_FROM_ABI __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) | 503 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_base() |
| 504 | _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) | ||
| 515 | : __before_begin_(__begin_node()) {} | 505 | : __before_begin_(__begin_node()) {} |
| 516 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a) | 506 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a) |
| 517 | : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {} | 507 | : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {} |
| 518 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a) | 508 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a) |
| 519 | : __before_begin_(__begin_node()), __alloc_(__a) {} | 509 | : __before_begin_(__begin_node()), __alloc_(__a) {} |
| 520 | 510 | ||
| 521 | public: | 511 | public: |
| 522 | # ifndef _LIBCPP_CXX03_LANG | 512 | # ifndef _LIBCPP_CXX03_LANG |
| 523 | _LIBCPP_HIDE_FROM_ABI | 513 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 524 | __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value); | 514 | __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value); |
| 525 | _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a); | 515 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 516 | __forward_list_base(__forward_list_base&& __x, const allocator_type& __a); | ||
| 526 | # endif // _LIBCPP_CXX03_LANG | 517 | # endif // _LIBCPP_CXX03_LANG |
| 527 | 518 | ||
| 528 | __forward_list_base(const __forward_list_base&) = delete; | 519 | __forward_list_base(const __forward_list_base&) = delete; |
| 529 | __forward_list_base& operator=(const __forward_list_base&) = delete; | 520 | __forward_list_base& operator=(const __forward_list_base&) = delete; |
| 530 | 521 | ||
| 531 | _LIBCPP_HIDE_FROM_ABI ~__forward_list_base(); | 522 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__forward_list_base(); |
| 532 | 523 | ||
| 533 | protected: | 524 | protected: |
| 534 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x) { | 525 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x) { |
| 535 | __copy_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); | 526 | __copy_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>()); |
| 536 | } | 527 | } |
| 537 | 528 | ||
| 538 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x) | 529 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x) |
| 539 | _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || | 530 | _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value || |
| 540 | is_nothrow_move_assignable<__node_allocator>::value) { | 531 | is_nothrow_move_assignable<__node_allocator>::value) { |
| 541 | __move_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); | 532 | __move_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); |
| 542 | } | 533 | } |
| 543 | 534 | ||
| 544 | template <class... _Args> | 535 | template <class... _Args> |
| 545 | _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__node_pointer __next, _Args&&... __args) { | 536 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer |
| 537 | __create_node(__node_pointer __next, _Args&&... __args) { | ||
| 546 | __allocation_guard<__node_allocator> __guard(__alloc_, 1); | 538 | __allocation_guard<__node_allocator> __guard(__alloc_, 1); |
| 547 | // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value | 539 | // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value |
| 548 | // held inside the node, since we need to use the allocator's construct() method for that. | 540 | // held inside the node, since we need to use the allocator's construct() method for that. |
| ... | @@ -557,7 +549,7 @@ protected: | ... | @@ -557,7 +549,7 @@ protected: |
| 557 | return __guard.__release_ptr(); | 549 | return __guard.__release_ptr(); |
| 558 | } | 550 | } |
| 559 | 551 | ||
| 560 | _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { | 552 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { |
| 561 | // For the same reason as above, we use the allocator's destroy() method for the value_type, | 553 | // For the same reason as above, we use the allocator's destroy() method for the value_type, |
| 562 | // but not for the node itself. | 554 | // but not for the node itself. |
| 563 | __node_traits::destroy(__alloc_, std::addressof(__node->__get_value())); | 555 | __node_traits::destroy(__alloc_, std::addressof(__node->__get_value())); |
| ... | @@ -566,7 +558,7 @@ protected: | ... | @@ -566,7 +558,7 @@ protected: |
| 566 | } | 558 | } |
| 567 | 559 | ||
| 568 | public: | 560 | public: |
| 569 | _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x) | 561 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x) |
| 570 | # if _LIBCPP_STD_VER >= 14 | 562 | # if _LIBCPP_STD_VER >= 14 |
| 571 | _NOEXCEPT; | 563 | _NOEXCEPT; |
| 572 | # else | 564 | # else |
| ... | @@ -574,18 +566,21 @@ public: | ... | @@ -574,18 +566,21 @@ public: |
| 574 | # endif | 566 | # endif |
| 575 | 567 | ||
| 576 | protected: | 568 | protected: |
| 577 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; | 569 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; |
| 578 | 570 | ||
| 579 | private: | 571 | private: |
| 580 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) {} | 572 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) { |
| 581 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x, true_type) { | 573 | } |
| 574 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void | ||
| 575 | __copy_assign_alloc(const __forward_list_base& __x, true_type) { | ||
| 582 | if (__alloc_ != __x.__alloc_) | 576 | if (__alloc_ != __x.__alloc_) |
| 583 | clear(); | 577 | clear(); |
| 584 | __alloc_ = __x.__alloc_; | 578 | __alloc_ = __x.__alloc_; |
| 585 | } | 579 | } |
| 586 | 580 | ||
| 587 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {} | 581 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void |
| 588 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type) | 582 | __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {} |
| 583 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type) | ||
| 589 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) { | 584 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) { |
| 590 | __alloc_ = std::move(__x.__alloc_); | 585 | __alloc_ = std::move(__x.__alloc_); |
| 591 | } | 586 | } |
| ... | @@ -594,14 +589,15 @@ private: | ... | @@ -594,14 +589,15 @@ private: |
| 594 | # ifndef _LIBCPP_CXX03_LANG | 589 | # ifndef _LIBCPP_CXX03_LANG |
| 595 | 590 | ||
| 596 | template <class _Tp, class _Alloc> | 591 | template <class _Tp, class _Alloc> |
| 597 | inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept( | 592 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline __forward_list_base<_Tp, _Alloc>::__forward_list_base( |
| 598 | is_nothrow_move_constructible<__node_allocator>::value) | 593 | __forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value) |
| 599 | : __before_begin_(std::move(__x.__before_begin_)), __alloc_(std::move(__x.__alloc_)) { | 594 | : __before_begin_(std::move(__x.__before_begin_)), __alloc_(std::move(__x.__alloc_)) { |
| 600 | __x.__before_begin()->__next_ = nullptr; | 595 | __x.__before_begin()->__next_ = nullptr; |
| 601 | } | 596 | } |
| 602 | 597 | ||
| 603 | template <class _Tp, class _Alloc> | 598 | template <class _Tp, class _Alloc> |
| 604 | inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a) | 599 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline __forward_list_base<_Tp, _Alloc>::__forward_list_base( |
| 600 | __forward_list_base&& __x, const allocator_type& __a) | ||
| 605 | : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) { | 601 | : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) { |
| 606 | if (__alloc_ == __x.__alloc_) { | 602 | if (__alloc_ == __x.__alloc_) { |
| 607 | __before_begin()->__next_ = __x.__before_begin()->__next_; | 603 | __before_begin()->__next_ = __x.__before_begin()->__next_; |
| ... | @@ -612,12 +608,12 @@ inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base | ... | @@ -612,12 +608,12 @@ inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base |
| 612 | # endif // _LIBCPP_CXX03_LANG | 608 | # endif // _LIBCPP_CXX03_LANG |
| 613 | 609 | ||
| 614 | template <class _Tp, class _Alloc> | 610 | template <class _Tp, class _Alloc> |
| 615 | __forward_list_base<_Tp, _Alloc>::~__forward_list_base() { | 611 | _LIBCPP_CONSTEXPR_SINCE_CXX26 __forward_list_base<_Tp, _Alloc>::~__forward_list_base() { |
| 616 | clear(); | 612 | clear(); |
| 617 | } | 613 | } |
| 618 | 614 | ||
| 619 | template <class _Tp, class _Alloc> | 615 | template <class _Tp, class _Alloc> |
| 620 | inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) | 616 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) |
| 621 | # if _LIBCPP_STD_VER >= 14 | 617 | # if _LIBCPP_STD_VER >= 14 |
| 622 | _NOEXCEPT | 618 | _NOEXCEPT |
| 623 | # else | 619 | # else |
| ... | @@ -630,7 +626,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) | ... | @@ -630,7 +626,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) |
| 630 | } | 626 | } |
| 631 | 627 | ||
| 632 | template <class _Tp, class _Alloc> | 628 | template <class _Tp, class _Alloc> |
| 633 | void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT { | 629 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT { |
| 634 | for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;) { | 630 | for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;) { |
| 635 | __node_pointer __next = __p->__next_; | 631 | __node_pointer __next = __p->__next_; |
| 636 | __delete_node(__p); | 632 | __delete_node(__p); |
| ... | @@ -640,7 +636,7 @@ void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT { | ... | @@ -640,7 +636,7 @@ void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT { |
| 640 | } | 636 | } |
| 641 | 637 | ||
| 642 | template <class _Tp, class _Alloc /*= allocator<_Tp>*/> | 638 | template <class _Tp, class _Alloc /*= allocator<_Tp>*/> |
| 643 | class _LIBCPP_TEMPLATE_VIS forward_list : private __forward_list_base<_Tp, _Alloc> { | 639 | class forward_list : private __forward_list_base<_Tp, _Alloc> { |
| 644 | typedef __forward_list_base<_Tp, _Alloc> __base; | 640 | typedef __forward_list_base<_Tp, _Alloc> __base; |
| 645 | typedef typename __base::__node_allocator __node_allocator; | 641 | typedef typename __base::__node_allocator __node_allocator; |
| 646 | typedef typename __base::__node_type __node_type; | 642 | typedef typename __base::__node_type __node_type; |
| ... | @@ -675,104 +671,123 @@ public: | ... | @@ -675,104 +671,123 @@ public: |
| 675 | typedef void __remove_return_type; | 671 | typedef void __remove_return_type; |
| 676 | # endif | 672 | # endif |
| 677 | 673 | ||
| 678 | _LIBCPP_HIDE_FROM_ABI forward_list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) { | 674 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list() |
| 679 | } // = default; | 675 | _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} // = default; |
| 680 | _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a); | 676 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a); |
| 681 | _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n); | 677 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n); |
| 682 | # if _LIBCPP_STD_VER >= 14 | 678 | # if _LIBCPP_STD_VER >= 14 |
| 683 | _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a); | 679 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a); |
| 684 | # endif | 680 | # endif |
| 685 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); | 681 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); |
| 686 | 682 | ||
| 687 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 683 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 688 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : __base(__a) { | 684 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 685 | forward_list(size_type __n, const value_type& __v, const allocator_type& __a) | ||
| 686 | : __base(__a) { | ||
| 689 | insert_after(cbefore_begin(), __n, __v); | 687 | insert_after(cbefore_begin(), __n, __v); |
| 690 | } | 688 | } |
| 691 | 689 | ||
| 692 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> | 690 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 693 | _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l); | 691 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l); |
| 694 | 692 | ||
| 695 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> | 693 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 696 | _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a); | 694 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 695 | forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a); | ||
| 697 | 696 | ||
| 698 | # if _LIBCPP_STD_VER >= 23 | 697 | # if _LIBCPP_STD_VER >= 23 |
| 699 | template <_ContainerCompatibleRange<_Tp> _Range> | 698 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 700 | _LIBCPP_HIDE_FROM_ABI forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) | 699 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 700 | forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) | ||
| 701 | : __base(__a) { | 701 | : __base(__a) { |
| 702 | prepend_range(std::forward<_Range>(__range)); | 702 | prepend_range(std::forward<_Range>(__range)); |
| 703 | } | 703 | } |
| 704 | # endif | 704 | # endif |
| 705 | 705 | ||
| 706 | _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x); | 706 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x); |
| 707 | _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a); | 707 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 708 | forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a); | ||
| 708 | 709 | ||
| 709 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x); | 710 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x); |
| 710 | 711 | ||
| 711 | # ifndef _LIBCPP_CXX03_LANG | 712 | # ifndef _LIBCPP_CXX03_LANG |
| 712 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<__base>::value) | 713 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 714 | forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<__base>::value) | ||
| 713 | : __base(std::move(__x)) {} | 715 | : __base(std::move(__x)) {} |
| 714 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a); | 716 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 717 | forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a); | ||
| 715 | 718 | ||
| 716 | _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il); | 719 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il); |
| 717 | _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il, const allocator_type& __a); | 720 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 721 | forward_list(initializer_list<value_type> __il, const allocator_type& __a); | ||
| 718 | 722 | ||
| 719 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept( | 723 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept( |
| 720 | __node_traits::propagate_on_container_move_assignment::value && | 724 | (__node_traits::propagate_on_container_move_assignment::value && |
| 721 | is_nothrow_move_assignable<allocator_type>::value); | 725 | is_nothrow_move_assignable<allocator_type>::value) || |
| 726 | allocator_traits<allocator_type>::is_always_equal::value); | ||
| 722 | 727 | ||
| 723 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il); | 728 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il); |
| 724 | 729 | ||
| 725 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il); | 730 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il); |
| 726 | # endif // _LIBCPP_CXX03_LANG | 731 | # endif // _LIBCPP_CXX03_LANG |
| 727 | 732 | ||
| 728 | // ~forward_list() = default; | 733 | // ~forward_list() = default; |
| 729 | 734 | ||
| 730 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> | 735 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 731 | void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l); | 736 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l); |
| 732 | 737 | ||
| 733 | # if _LIBCPP_STD_VER >= 23 | 738 | # if _LIBCPP_STD_VER >= 23 |
| 734 | template <_ContainerCompatibleRange<_Tp> _Range> | 739 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 735 | _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { | 740 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { |
| 736 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | 741 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| 737 | } | 742 | } |
| 738 | # endif | 743 | # endif |
| 739 | 744 | ||
| 740 | _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); | 745 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); |
| 741 | 746 | ||
| 742 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(this->__alloc_); } | 747 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 748 | return allocator_type(this->__alloc_); | ||
| 749 | } | ||
| 743 | 750 | ||
| 744 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__base::__before_begin()->__next_); } | 751 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { |
| 745 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { | 752 | return iterator(__base::__before_begin()->__next_); |
| 753 | } | ||
| 754 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { | ||
| 746 | return const_iterator(__base::__before_begin()->__next_); | 755 | return const_iterator(__base::__before_begin()->__next_); |
| 747 | } | 756 | } |
| 748 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); } | 757 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); } |
| 749 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(nullptr); } | 758 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { |
| 759 | return const_iterator(nullptr); | ||
| 760 | } | ||
| 750 | 761 | ||
| 751 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { | 762 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { |
| 752 | return const_iterator(__base::__before_begin()->__next_); | 763 | return const_iterator(__base::__before_begin()->__next_); |
| 753 | } | 764 | } |
| 754 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return const_iterator(nullptr); } | 765 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { |
| 766 | return const_iterator(nullptr); | ||
| 767 | } | ||
| 755 | 768 | ||
| 756 | _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { return iterator(__base::__before_begin()); } | 769 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { |
| 757 | _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT { | 770 | return iterator(__base::__before_begin()); |
| 771 | } | ||
| 772 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT { | ||
| 758 | return const_iterator(__base::__before_begin()); | 773 | return const_iterator(__base::__before_begin()); |
| 759 | } | 774 | } |
| 760 | _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT { | 775 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT { |
| 761 | return const_iterator(__base::__before_begin()); | 776 | return const_iterator(__base::__before_begin()); |
| 762 | } | 777 | } |
| 763 | 778 | ||
| 764 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | 779 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { |
| 765 | return __base::__before_begin()->__next_ == nullptr; | 780 | return __base::__before_begin()->__next_ == nullptr; |
| 766 | } | 781 | } |
| 767 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 782 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 768 | return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); | 783 | return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); |
| 769 | } | 784 | } |
| 770 | 785 | ||
| 771 | _LIBCPP_HIDE_FROM_ABI reference front() { | 786 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() { |
| 772 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); | 787 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); |
| 773 | return __base::__before_begin()->__next_->__get_value(); | 788 | return __base::__before_begin()->__next_->__get_value(); |
| 774 | } | 789 | } |
| 775 | _LIBCPP_HIDE_FROM_ABI const_reference front() const { | 790 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const { |
| 776 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); | 791 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); |
| 777 | return __base::__before_begin()->__next_->__get_value(); | 792 | return __base::__before_begin()->__next_->__get_value(); |
| 778 | } | 793 | } |
| ... | @@ -780,52 +795,59 @@ public: | ... | @@ -780,52 +795,59 @@ public: |
| 780 | # ifndef _LIBCPP_CXX03_LANG | 795 | # ifndef _LIBCPP_CXX03_LANG |
| 781 | # if _LIBCPP_STD_VER >= 17 | 796 | # if _LIBCPP_STD_VER >= 17 |
| 782 | template <class... _Args> | 797 | template <class... _Args> |
| 783 | _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); | 798 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); |
| 784 | # else | 799 | # else |
| 785 | template <class... _Args> | 800 | template <class... _Args> |
| 786 | _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); | 801 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); |
| 787 | # endif | 802 | # endif |
| 788 | _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); | 803 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); |
| 789 | # endif // _LIBCPP_CXX03_LANG | 804 | # endif // _LIBCPP_CXX03_LANG |
| 790 | _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); | 805 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); |
| 791 | 806 | ||
| 792 | # if _LIBCPP_STD_VER >= 23 | 807 | # if _LIBCPP_STD_VER >= 23 |
| 793 | template <_ContainerCompatibleRange<_Tp> _Range> | 808 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 794 | _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { | 809 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { |
| 795 | insert_range_after(cbefore_begin(), std::forward<_Range>(__range)); | 810 | insert_range_after(cbefore_begin(), std::forward<_Range>(__range)); |
| 796 | } | 811 | } |
| 797 | # endif | 812 | # endif |
| 798 | 813 | ||
| 799 | _LIBCPP_HIDE_FROM_ABI void pop_front(); | 814 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_front(); |
| 800 | 815 | ||
| 801 | # ifndef _LIBCPP_CXX03_LANG | 816 | # ifndef _LIBCPP_CXX03_LANG |
| 802 | template <class... _Args> | 817 | template <class... _Args> |
| 803 | _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args); | 818 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args); |
| 804 | 819 | ||
| 805 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, value_type&& __v); | 820 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, value_type&& __v); |
| 806 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, initializer_list<value_type> __il) { | 821 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 822 | insert_after(const_iterator __p, initializer_list<value_type> __il) { | ||
| 807 | return insert_after(__p, __il.begin(), __il.end()); | 823 | return insert_after(__p, __il.begin(), __il.end()); |
| 808 | } | 824 | } |
| 809 | # endif // _LIBCPP_CXX03_LANG | 825 | # endif // _LIBCPP_CXX03_LANG |
| 810 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v); | 826 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v); |
| 811 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v); | 827 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 828 | insert_after(const_iterator __p, size_type __n, const value_type& __v) { | ||
| 829 | return __insert_after(__p, __n, __v); | ||
| 830 | } | ||
| 812 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> | 831 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 813 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l); | 832 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 833 | insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l); | ||
| 814 | 834 | ||
| 815 | # if _LIBCPP_STD_VER >= 23 | 835 | # if _LIBCPP_STD_VER >= 23 |
| 816 | template <_ContainerCompatibleRange<_Tp> _Range> | 836 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 817 | _LIBCPP_HIDE_FROM_ABI iterator insert_range_after(const_iterator __position, _Range&& __range) { | 837 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 838 | insert_range_after(const_iterator __position, _Range&& __range) { | ||
| 818 | return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); | 839 | return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); |
| 819 | } | 840 | } |
| 820 | # endif | 841 | # endif |
| 821 | 842 | ||
| 822 | template <class _InputIterator, class _Sentinel> | 843 | template <class _InputIterator, class _Sentinel> |
| 823 | _LIBCPP_HIDE_FROM_ABI iterator __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l); | 844 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 845 | __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l); | ||
| 824 | 846 | ||
| 825 | _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __p); | 847 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __p); |
| 826 | _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l); | 848 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l); |
| 827 | 849 | ||
| 828 | _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x) | 850 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x) |
| 829 | # if _LIBCPP_STD_VER >= 14 | 851 | # if _LIBCPP_STD_VER >= 14 |
| 830 | _NOEXCEPT | 852 | _NOEXCEPT |
| 831 | # else | 853 | # else |
| ... | @@ -835,55 +857,63 @@ public: | ... | @@ -835,55 +857,63 @@ public: |
| 835 | __base::swap(__x); | 857 | __base::swap(__x); |
| 836 | } | 858 | } |
| 837 | 859 | ||
| 838 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); | 860 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); |
| 839 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v); | 861 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v); |
| 840 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); } | 862 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); } |
| 841 | 863 | ||
| 842 | _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x); | 864 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x); |
| 843 | _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i); | 865 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void |
| 844 | _LIBCPP_HIDE_FROM_ABI void | 866 | splice_after(const_iterator __p, forward_list&& __x, const_iterator __i); |
| 867 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void | ||
| 845 | splice_after(const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l); | 868 | splice_after(const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l); |
| 846 | _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x); | 869 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x); |
| 847 | _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x, const_iterator __i); | 870 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void |
| 848 | _LIBCPP_HIDE_FROM_ABI void | 871 | splice_after(const_iterator __p, forward_list& __x, const_iterator __i); |
| 872 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void | ||
| 849 | splice_after(const_iterator __p, forward_list& __x, const_iterator __f, const_iterator __l); | 873 | splice_after(const_iterator __p, forward_list& __x, const_iterator __f, const_iterator __l); |
| 850 | _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __v); | 874 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __v); |
| 851 | template <class _Predicate> | 875 | template <class _Predicate> |
| 852 | _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Predicate __pred); | 876 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Predicate __pred); |
| 853 | _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); } | 877 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); } |
| 854 | template <class _BinaryPredicate> | 878 | template <class _BinaryPredicate> |
| 855 | _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred); | 879 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred); |
| 856 | # ifndef _LIBCPP_CXX03_LANG | 880 | # ifndef _LIBCPP_CXX03_LANG |
| 857 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); } | 881 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); } |
| 858 | template <class _Compare> | 882 | template <class _Compare> |
| 859 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) { | 883 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) { |
| 860 | merge(__x, std::move(__comp)); | 884 | merge(__x, std::move(__comp)); |
| 861 | } | 885 | } |
| 862 | # endif // _LIBCPP_CXX03_LANG | 886 | # endif // _LIBCPP_CXX03_LANG |
| 863 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); } | 887 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); } |
| 864 | template <class _Compare> | 888 | template <class _Compare> |
| 865 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp); | 889 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp); |
| 866 | _LIBCPP_HIDE_FROM_ABI void sort() { sort(__less<>()); } | 890 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort() { sort(__less<>()); } |
| 867 | template <class _Compare> | 891 | template <class _Compare> |
| 868 | _LIBCPP_HIDE_FROM_ABI void sort(_Compare __comp); | 892 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort(_Compare __comp); |
| 869 | _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT; | 893 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT; |
| 870 | 894 | ||
| 871 | private: | 895 | private: |
| 872 | # ifndef _LIBCPP_CXX03_LANG | 896 | # ifndef _LIBCPP_CXX03_LANG |
| 873 | _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type) | 897 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type) |
| 874 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | 898 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); |
| 875 | _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type); | 899 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type); |
| 876 | # endif // _LIBCPP_CXX03_LANG | 900 | # endif // _LIBCPP_CXX03_LANG |
| 877 | 901 | ||
| 878 | template <class _Iter, class _Sent> | 902 | template <class _Iter, class _Sent> |
| 879 | _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l); | 903 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l); |
| 904 | |||
| 905 | template <class... _Args> | ||
| 906 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator | ||
| 907 | __insert_after(const_iterator __p, size_type __n, _Args&&... __args); | ||
| 880 | 908 | ||
| 881 | template <class _Compare> | 909 | template <class _Compare> |
| 882 | static _LIBCPP_HIDE_FROM_ABI __node_pointer __merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp); | 910 | _LIBCPP_CONSTEXPR_SINCE_CXX26 static _LIBCPP_HIDE_FROM_ABI __node_pointer |
| 911 | __merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp); | ||
| 883 | 912 | ||
| 884 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI | 913 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI |
| 885 | template <class _Compare> | 914 | template <class _Compare> |
| 886 | static _LIBCPP_HIDDEN __node_pointer __sort(__node_pointer __f, difference_type __sz, _Compare& __comp); | 915 | _LIBCPP_CONSTEXPR_SINCE_CXX26 static _LIBCPP_HIDDEN __node_pointer |
| 916 | __sort(__node_pointer __f, difference_type __sz, _Compare& __comp); | ||
| 887 | }; | 917 | }; |
| 888 | 918 | ||
| 889 | # if _LIBCPP_STD_VER >= 17 | 919 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -908,12 +938,13 @@ forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges:: | ... | @@ -908,12 +938,13 @@ forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges:: |
| 908 | # endif | 938 | # endif |
| 909 | 939 | ||
| 910 | template <class _Tp, class _Alloc> | 940 | template <class _Tp, class _Alloc> |
| 911 | inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : __base(__a) {} | 941 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : __base(__a) {} |
| 912 | 942 | ||
| 913 | template <class _Tp, class _Alloc> | 943 | template <class _Tp, class _Alloc> |
| 914 | forward_list<_Tp, _Alloc>::forward_list(size_type __n) { | 944 | _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n) { |
| 915 | if (__n > 0) { | 945 | if (__n > 0) { |
| 916 | for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { | 946 | for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; |
| 947 | --__n, __p = std::__static_fancy_pointer_cast<__begin_node_pointer>(__p->__next_)) { | ||
| 917 | __p->__next_ = this->__create_node(/* next = */ nullptr); | 948 | __p->__next_ = this->__create_node(/* next = */ nullptr); |
| 918 | } | 949 | } |
| 919 | } | 950 | } |
| ... | @@ -921,9 +952,11 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) { | ... | @@ -921,9 +952,11 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) { |
| 921 | 952 | ||
| 922 | # if _LIBCPP_STD_VER >= 14 | 953 | # if _LIBCPP_STD_VER >= 14 |
| 923 | template <class _Tp, class _Alloc> | 954 | template <class _Tp, class _Alloc> |
| 924 | forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) : __base(__base_alloc) { | 955 | _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) |
| 956 | : __base(__base_alloc) { | ||
| 925 | if (__n > 0) { | 957 | if (__n > 0) { |
| 926 | for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { | 958 | for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; |
| 959 | --__n, __p = std::__static_fancy_pointer_cast<__begin_node_pointer>(__p->__next_)) { | ||
| 927 | __p->__next_ = this->__create_node(/* next = */ nullptr); | 960 | __p->__next_ = this->__create_node(/* next = */ nullptr); |
| 928 | } | 961 | } |
| 929 | } | 962 | } |
| ... | @@ -931,37 +964,39 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __b | ... | @@ -931,37 +964,39 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __b |
| 931 | # endif | 964 | # endif |
| 932 | 965 | ||
| 933 | template <class _Tp, class _Alloc> | 966 | template <class _Tp, class _Alloc> |
| 934 | forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { | 967 | _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { |
| 935 | insert_after(cbefore_begin(), __n, __v); | 968 | insert_after(cbefore_begin(), __n, __v); |
| 936 | } | 969 | } |
| 937 | 970 | ||
| 938 | template <class _Tp, class _Alloc> | 971 | template <class _Tp, class _Alloc> |
| 939 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > | 972 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| 940 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l) { | 973 | _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l) { |
| 941 | insert_after(cbefore_begin(), __f, __l); | 974 | insert_after(cbefore_begin(), __f, __l); |
| 942 | } | 975 | } |
| 943 | 976 | ||
| 944 | template <class _Tp, class _Alloc> | 977 | template <class _Tp, class _Alloc> |
| 945 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > | 978 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| 979 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 946 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a) | 980 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 947 | : __base(__a) { | 981 | : __base(__a) { |
| 948 | insert_after(cbefore_begin(), __f, __l); | 982 | insert_after(cbefore_begin(), __f, __l); |
| 949 | } | 983 | } |
| 950 | 984 | ||
| 951 | template <class _Tp, class _Alloc> | 985 | template <class _Tp, class _Alloc> |
| 952 | forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x) | 986 | _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x) |
| 953 | : __base(__node_traits::select_on_container_copy_construction(__x.__alloc_)) { | 987 | : __base(__node_traits::select_on_container_copy_construction(__x.__alloc_)) { |
| 954 | insert_after(cbefore_begin(), __x.begin(), __x.end()); | 988 | insert_after(cbefore_begin(), __x.begin(), __x.end()); |
| 955 | } | 989 | } |
| 956 | 990 | ||
| 957 | template <class _Tp, class _Alloc> | 991 | template <class _Tp, class _Alloc> |
| 992 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 958 | forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a) | 993 | forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a) |
| 959 | : __base(__a) { | 994 | : __base(__a) { |
| 960 | insert_after(cbefore_begin(), __x.begin(), __x.end()); | 995 | insert_after(cbefore_begin(), __x.begin(), __x.end()); |
| 961 | } | 996 | } |
| 962 | 997 | ||
| 963 | template <class _Tp, class _Alloc> | 998 | template <class _Tp, class _Alloc> |
| 964 | forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) { | 999 | _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) { |
| 965 | if (this != std::addressof(__x)) { | 1000 | if (this != std::addressof(__x)) { |
| 966 | __base::__copy_assign_alloc(__x); | 1001 | __base::__copy_assign_alloc(__x); |
| 967 | assign(__x.begin(), __x.end()); | 1002 | assign(__x.begin(), __x.end()); |
| ... | @@ -971,6 +1006,7 @@ forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_li | ... | @@ -971,6 +1006,7 @@ forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_li |
| 971 | 1006 | ||
| 972 | # ifndef _LIBCPP_CXX03_LANG | 1007 | # ifndef _LIBCPP_CXX03_LANG |
| 973 | template <class _Tp, class _Alloc> | 1008 | template <class _Tp, class _Alloc> |
| 1009 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 974 | forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a) | 1010 | forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a) |
| 975 | : __base(std::move(__x), __a) { | 1011 | : __base(std::move(__x), __a) { |
| 976 | if (this->__alloc_ != __x.__alloc_) { | 1012 | if (this->__alloc_ != __x.__alloc_) { |
| ... | @@ -980,17 +1016,19 @@ forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identit | ... | @@ -980,17 +1016,19 @@ forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identit |
| 980 | } | 1016 | } |
| 981 | 1017 | ||
| 982 | template <class _Tp, class _Alloc> | 1018 | template <class _Tp, class _Alloc> |
| 983 | forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il) { | 1019 | _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il) { |
| 984 | insert_after(cbefore_begin(), __il.begin(), __il.end()); | 1020 | insert_after(cbefore_begin(), __il.begin(), __il.end()); |
| 985 | } | 1021 | } |
| 986 | 1022 | ||
| 987 | template <class _Tp, class _Alloc> | 1023 | template <class _Tp, class _Alloc> |
| 988 | forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) { | 1024 | _LIBCPP_CONSTEXPR_SINCE_CXX26 |
| 1025 | forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a) | ||
| 1026 | : __base(__a) { | ||
| 989 | insert_after(cbefore_begin(), __il.begin(), __il.end()); | 1027 | insert_after(cbefore_begin(), __il.begin(), __il.end()); |
| 990 | } | 1028 | } |
| 991 | 1029 | ||
| 992 | template <class _Tp, class _Alloc> | 1030 | template <class _Tp, class _Alloc> |
| 993 | void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type) | 1031 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type) |
| 994 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | 1032 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { |
| 995 | clear(); | 1033 | clear(); |
| 996 | __base::__move_assign_alloc(__x); | 1034 | __base::__move_assign_alloc(__x); |
| ... | @@ -999,7 +1037,7 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type) | ... | @@ -999,7 +1037,7 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type) |
| 999 | } | 1037 | } |
| 1000 | 1038 | ||
| 1001 | template <class _Tp, class _Alloc> | 1039 | template <class _Tp, class _Alloc> |
| 1002 | void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) { | 1040 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) { |
| 1003 | if (this->__alloc_ == __x.__alloc_) | 1041 | if (this->__alloc_ == __x.__alloc_) |
| 1004 | __move_assign(__x, true_type()); | 1042 | __move_assign(__x, true_type()); |
| 1005 | else { | 1043 | else { |
| ... | @@ -1009,14 +1047,18 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) { | ... | @@ -1009,14 +1047,18 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) { |
| 1009 | } | 1047 | } |
| 1010 | 1048 | ||
| 1011 | template <class _Tp, class _Alloc> | 1049 | template <class _Tp, class _Alloc> |
| 1012 | inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(forward_list&& __x) _NOEXCEPT_( | 1050 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline forward_list<_Tp, _Alloc>& |
| 1013 | __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<allocator_type>::value) { | 1051 | forward_list<_Tp, _Alloc>::operator=(forward_list&& __x) noexcept( |
| 1052 | (__node_traits::propagate_on_container_move_assignment::value && | ||
| 1053 | is_nothrow_move_assignable<allocator_type>::value) || | ||
| 1054 | allocator_traits<allocator_type>::is_always_equal::value) { | ||
| 1014 | __move_assign(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); | 1055 | __move_assign(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>()); |
| 1015 | return *this; | 1056 | return *this; |
| 1016 | } | 1057 | } |
| 1017 | 1058 | ||
| 1018 | template <class _Tp, class _Alloc> | 1059 | template <class _Tp, class _Alloc> |
| 1019 | inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il) { | 1060 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline forward_list<_Tp, _Alloc>& |
| 1061 | forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il) { | ||
| 1020 | assign(__il.begin(), __il.end()); | 1062 | assign(__il.begin(), __il.end()); |
| 1021 | return *this; | 1063 | return *this; |
| 1022 | } | 1064 | } |
| ... | @@ -1025,13 +1067,14 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ | ... | @@ -1025,13 +1067,14 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ |
| 1025 | 1067 | ||
| 1026 | template <class _Tp, class _Alloc> | 1068 | template <class _Tp, class _Alloc> |
| 1027 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > | 1069 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| 1028 | void forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) { | 1070 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) { |
| 1029 | __assign_with_sentinel(__f, __l); | 1071 | __assign_with_sentinel(__f, __l); |
| 1030 | } | 1072 | } |
| 1031 | 1073 | ||
| 1032 | template <class _Tp, class _Alloc> | 1074 | template <class _Tp, class _Alloc> |
| 1033 | template <class _Iter, class _Sent> | 1075 | template <class _Iter, class _Sent> |
| 1034 | _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::__assign_with_sentinel(_Iter __f, _Sent __l) { | 1076 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void |
| 1077 | forward_list<_Tp, _Alloc>::__assign_with_sentinel(_Iter __f, _Sent __l) { | ||
| 1035 | iterator __i = before_begin(); | 1078 | iterator __i = before_begin(); |
| 1036 | iterator __j = std::next(__i); | 1079 | iterator __j = std::next(__i); |
| 1037 | iterator __e = end(); | 1080 | iterator __e = end(); |
| ... | @@ -1044,7 +1087,7 @@ _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::__assign_with_sentinel(_It | ... | @@ -1044,7 +1087,7 @@ _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::__assign_with_sentinel(_It |
| 1044 | } | 1087 | } |
| 1045 | 1088 | ||
| 1046 | template <class _Tp, class _Alloc> | 1089 | template <class _Tp, class _Alloc> |
| 1047 | void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) { | 1090 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) { |
| 1048 | iterator __i = before_begin(); | 1091 | iterator __i = before_begin(); |
| 1049 | iterator __j = std::next(__i); | 1092 | iterator __j = std::next(__i); |
| 1050 | iterator __e = end(); | 1093 | iterator __e = end(); |
| ... | @@ -1059,18 +1102,19 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) { | ... | @@ -1059,18 +1102,19 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) { |
| 1059 | # ifndef _LIBCPP_CXX03_LANG | 1102 | # ifndef _LIBCPP_CXX03_LANG |
| 1060 | 1103 | ||
| 1061 | template <class _Tp, class _Alloc> | 1104 | template <class _Tp, class _Alloc> |
| 1062 | inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) { | 1105 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) { |
| 1063 | assign(__il.begin(), __il.end()); | 1106 | assign(__il.begin(), __il.end()); |
| 1064 | } | 1107 | } |
| 1065 | 1108 | ||
| 1066 | template <class _Tp, class _Alloc> | 1109 | template <class _Tp, class _Alloc> |
| 1067 | template <class... _Args> | 1110 | template <class... _Args> |
| 1111 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 1068 | # if _LIBCPP_STD_VER >= 17 | 1112 | # if _LIBCPP_STD_VER >= 17 |
| 1069 | typename forward_list<_Tp, _Alloc>::reference | 1113 | typename forward_list<_Tp, _Alloc>::reference |
| 1070 | # else | 1114 | # else |
| 1071 | void | 1115 | void |
| 1072 | # endif | 1116 | # endif |
| 1073 | forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { | 1117 | forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { |
| 1074 | __base::__before_begin()->__next_ = | 1118 | __base::__before_begin()->__next_ = |
| 1075 | this->__create_node(/* next = */ __base::__before_begin()->__next_, std::forward<_Args>(__args)...); | 1119 | this->__create_node(/* next = */ __base::__before_begin()->__next_, std::forward<_Args>(__args)...); |
| 1076 | # if _LIBCPP_STD_VER >= 17 | 1120 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -1079,7 +1123,7 @@ forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { | ... | @@ -1079,7 +1123,7 @@ forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { |
| 1079 | } | 1123 | } |
| 1080 | 1124 | ||
| 1081 | template <class _Tp, class _Alloc> | 1125 | template <class _Tp, class _Alloc> |
| 1082 | void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { | 1126 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { |
| 1083 | __base::__before_begin()->__next_ = | 1127 | __base::__before_begin()->__next_ = |
| 1084 | this->__create_node(/* next = */ __base::__before_begin()->__next_, std::move(__v)); | 1128 | this->__create_node(/* next = */ __base::__before_begin()->__next_, std::move(__v)); |
| 1085 | } | 1129 | } |
| ... | @@ -1087,12 +1131,12 @@ void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { | ... | @@ -1087,12 +1131,12 @@ void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { |
| 1087 | # endif // _LIBCPP_CXX03_LANG | 1131 | # endif // _LIBCPP_CXX03_LANG |
| 1088 | 1132 | ||
| 1089 | template <class _Tp, class _Alloc> | 1133 | template <class _Tp, class _Alloc> |
| 1090 | void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) { | 1134 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) { |
| 1091 | __base::__before_begin()->__next_ = this->__create_node(/* next = */ __base::__before_begin()->__next_, __v); | 1135 | __base::__before_begin()->__next_ = this->__create_node(/* next = */ __base::__before_begin()->__next_, __v); |
| 1092 | } | 1136 | } |
| 1093 | 1137 | ||
| 1094 | template <class _Tp, class _Alloc> | 1138 | template <class _Tp, class _Alloc> |
| 1095 | void forward_list<_Tp, _Alloc>::pop_front() { | 1139 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::pop_front() { |
| 1096 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::pop_front called on an empty list"); | 1140 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::pop_front called on an empty list"); |
| 1097 | __node_pointer __p = __base::__before_begin()->__next_; | 1141 | __node_pointer __p = __base::__before_begin()->__next_; |
| 1098 | __base::__before_begin()->__next_ = __p->__next_; | 1142 | __base::__before_begin()->__next_ = __p->__next_; |
| ... | @@ -1103,17 +1147,17 @@ void forward_list<_Tp, _Alloc>::pop_front() { | ... | @@ -1103,17 +1147,17 @@ void forward_list<_Tp, _Alloc>::pop_front() { |
| 1103 | 1147 | ||
| 1104 | template <class _Tp, class _Alloc> | 1148 | template <class _Tp, class _Alloc> |
| 1105 | template <class... _Args> | 1149 | template <class... _Args> |
| 1106 | typename forward_list<_Tp, _Alloc>::iterator | 1150 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator |
| 1107 | forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args) { | 1151 | forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args) { |
| 1108 | __begin_node_pointer const __r = __p.__get_begin(); | 1152 | __begin_node_pointer const __r = __p.__ptr_; |
| 1109 | __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::forward<_Args>(__args)...); | 1153 | __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::forward<_Args>(__args)...); |
| 1110 | return iterator(__r->__next_); | 1154 | return iterator(__r->__next_); |
| 1111 | } | 1155 | } |
| 1112 | 1156 | ||
| 1113 | template <class _Tp, class _Alloc> | 1157 | template <class _Tp, class _Alloc> |
| 1114 | typename forward_list<_Tp, _Alloc>::iterator | 1158 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator |
| 1115 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { | 1159 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { |
| 1116 | __begin_node_pointer const __r = __p.__get_begin(); | 1160 | __begin_node_pointer const __r = __p.__ptr_; |
| 1117 | __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::move(__v)); | 1161 | __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::move(__v)); |
| 1118 | return iterator(__r->__next_); | 1162 | return iterator(__r->__next_); |
| 1119 | } | 1163 | } |
| ... | @@ -1121,25 +1165,26 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { | ... | @@ -1121,25 +1165,26 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { |
| 1121 | # endif // _LIBCPP_CXX03_LANG | 1165 | # endif // _LIBCPP_CXX03_LANG |
| 1122 | 1166 | ||
| 1123 | template <class _Tp, class _Alloc> | 1167 | template <class _Tp, class _Alloc> |
| 1124 | typename forward_list<_Tp, _Alloc>::iterator | 1168 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator |
| 1125 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v) { | 1169 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v) { |
| 1126 | __begin_node_pointer const __r = __p.__get_begin(); | 1170 | __begin_node_pointer const __r = __p.__ptr_; |
| 1127 | __r->__next_ = this->__create_node(/* next = */ __r->__next_, __v); | 1171 | __r->__next_ = this->__create_node(/* next = */ __r->__next_, __v); |
| 1128 | return iterator(__r->__next_); | 1172 | return iterator(__r->__next_); |
| 1129 | } | 1173 | } |
| 1130 | 1174 | ||
| 1131 | template <class _Tp, class _Alloc> | 1175 | template <class _Tp, class _Alloc> |
| 1132 | typename forward_list<_Tp, _Alloc>::iterator | 1176 | template <class... _Args> |
| 1133 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const value_type& __v) { | 1177 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator |
| 1134 | __begin_node_pointer __r = __p.__get_begin(); | 1178 | forward_list<_Tp, _Alloc>::__insert_after(const_iterator __p, size_type __n, _Args&&... __args) { |
| 1179 | __begin_node_pointer __r = __p.__ptr_; | ||
| 1135 | if (__n > 0) { | 1180 | if (__n > 0) { |
| 1136 | __node_pointer __first = this->__create_node(/* next = */ nullptr, __v); | 1181 | __node_pointer __first = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1137 | __node_pointer __last = __first; | 1182 | __node_pointer __last = __first; |
| 1138 | # if _LIBCPP_HAS_EXCEPTIONS | 1183 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1139 | try { | 1184 | try { |
| 1140 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1185 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 1141 | for (--__n; __n != 0; --__n, __last = __last->__next_) { | 1186 | for (--__n; __n != 0; --__n, __last = __last->__next_) { |
| 1142 | __last->__next_ = this->__create_node(/* next = */ nullptr, __v); | 1187 | __last->__next_ = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1143 | } | 1188 | } |
| 1144 | # if _LIBCPP_HAS_EXCEPTIONS | 1189 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1145 | } catch (...) { | 1190 | } catch (...) { |
| ... | @@ -1153,23 +1198,23 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const | ... | @@ -1153,23 +1198,23 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const |
| 1153 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1198 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 1154 | __last->__next_ = __r->__next_; | 1199 | __last->__next_ = __r->__next_; |
| 1155 | __r->__next_ = __first; | 1200 | __r->__next_ = __first; |
| 1156 | __r = static_cast<__begin_node_pointer>(__last); | 1201 | __r = std::__static_fancy_pointer_cast<__begin_node_pointer>(__last); |
| 1157 | } | 1202 | } |
| 1158 | return iterator(__r); | 1203 | return iterator(__r); |
| 1159 | } | 1204 | } |
| 1160 | 1205 | ||
| 1161 | template <class _Tp, class _Alloc> | 1206 | template <class _Tp, class _Alloc> |
| 1162 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > | 1207 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| 1163 | typename forward_list<_Tp, _Alloc>::iterator | 1208 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator |
| 1164 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l) { | 1209 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l) { |
| 1165 | return __insert_after_with_sentinel(__p, std::move(__f), std::move(__l)); | 1210 | return __insert_after_with_sentinel(__p, std::move(__f), std::move(__l)); |
| 1166 | } | 1211 | } |
| 1167 | 1212 | ||
| 1168 | template <class _Tp, class _Alloc> | 1213 | template <class _Tp, class _Alloc> |
| 1169 | template <class _InputIterator, class _Sentinel> | 1214 | template <class _InputIterator, class _Sentinel> |
| 1170 | _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Alloc>::iterator | 1215 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Alloc>::iterator |
| 1171 | forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l) { | 1216 | forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l) { |
| 1172 | __begin_node_pointer __r = __p.__get_begin(); | 1217 | __begin_node_pointer __r = __p.__ptr_; |
| 1173 | 1218 | ||
| 1174 | if (__f != __l) { | 1219 | if (__f != __l) { |
| 1175 | __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f); | 1220 | __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f); |
| ... | @@ -1194,15 +1239,16 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp | ... | @@ -1194,15 +1239,16 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp |
| 1194 | 1239 | ||
| 1195 | __last->__next_ = __r->__next_; | 1240 | __last->__next_ = __r->__next_; |
| 1196 | __r->__next_ = __first; | 1241 | __r->__next_ = __first; |
| 1197 | __r = static_cast<__begin_node_pointer>(__last); | 1242 | __r = std::__static_fancy_pointer_cast<__begin_node_pointer>(__last); |
| 1198 | } | 1243 | } |
| 1199 | 1244 | ||
| 1200 | return iterator(__r); | 1245 | return iterator(__r); |
| 1201 | } | 1246 | } |
| 1202 | 1247 | ||
| 1203 | template <class _Tp, class _Alloc> | 1248 | template <class _Tp, class _Alloc> |
| 1204 | typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_after(const_iterator __f) { | 1249 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator |
| 1205 | __begin_node_pointer __p = __f.__get_begin(); | 1250 | forward_list<_Tp, _Alloc>::erase_after(const_iterator __f) { |
| 1251 | __begin_node_pointer __p = __f.__ptr_; | ||
| 1206 | __node_pointer __n = __p->__next_; | 1252 | __node_pointer __n = __p->__next_; |
| 1207 | __p->__next_ = __n->__next_; | 1253 | __p->__next_ = __n->__next_; |
| 1208 | this->__delete_node(__n); | 1254 | this->__delete_node(__n); |
| ... | @@ -1210,11 +1256,11 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_af | ... | @@ -1210,11 +1256,11 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_af |
| 1210 | } | 1256 | } |
| 1211 | 1257 | ||
| 1212 | template <class _Tp, class _Alloc> | 1258 | template <class _Tp, class _Alloc> |
| 1213 | typename forward_list<_Tp, _Alloc>::iterator | 1259 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator |
| 1214 | forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) { | 1260 | forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) { |
| 1215 | __node_pointer __e = __l.__get_unsafe_node_pointer(); | 1261 | __node_pointer __e = std::__static_fancy_pointer_cast<__node_pointer>(__l.__ptr_); |
| 1216 | if (__f != __l) { | 1262 | if (__f != __l) { |
| 1217 | __begin_node_pointer __bp = __f.__get_begin(); | 1263 | __begin_node_pointer __bp = __f.__ptr_; |
| 1218 | 1264 | ||
| 1219 | __node_pointer __n = __bp->__next_; | 1265 | __node_pointer __n = __bp->__next_; |
| 1220 | if (__n != __e) { | 1266 | if (__n != __e) { |
| ... | @@ -1230,7 +1276,7 @@ forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) { | ... | @@ -1230,7 +1276,7 @@ forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) { |
| 1230 | } | 1276 | } |
| 1231 | 1277 | ||
| 1232 | template <class _Tp, class _Alloc> | 1278 | template <class _Tp, class _Alloc> |
| 1233 | void forward_list<_Tp, _Alloc>::resize(size_type __n) { | 1279 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::resize(size_type __n) { |
| 1234 | size_type __sz = 0; | 1280 | size_type __sz = 0; |
| 1235 | iterator __p = before_begin(); | 1281 | iterator __p = before_begin(); |
| 1236 | iterator __i = begin(); | 1282 | iterator __i = begin(); |
| ... | @@ -1239,18 +1285,12 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n) { | ... | @@ -1239,18 +1285,12 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n) { |
| 1239 | ; | 1285 | ; |
| 1240 | if (__i != __e) | 1286 | if (__i != __e) |
| 1241 | erase_after(__p, __e); | 1287 | erase_after(__p, __e); |
| 1242 | else { | 1288 | else |
| 1243 | __n -= __sz; | 1289 | __insert_after(__p, __n - __sz); |
| 1244 | if (__n > 0) { | ||
| 1245 | for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n, __ptr = __ptr->__next_as_begin()) { | ||
| 1246 | __ptr->__next_ = this->__create_node(/* next = */ nullptr); | ||
| 1247 | } | ||
| 1248 | } | ||
| 1249 | } | ||
| 1250 | } | 1290 | } |
| 1251 | 1291 | ||
| 1252 | template <class _Tp, class _Alloc> | 1292 | template <class _Tp, class _Alloc> |
| 1253 | void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) { | 1293 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) { |
| 1254 | size_type __sz = 0; | 1294 | size_type __sz = 0; |
| 1255 | iterator __p = before_begin(); | 1295 | iterator __p = before_begin(); |
| 1256 | iterator __i = begin(); | 1296 | iterator __i = begin(); |
| ... | @@ -1259,79 +1299,76 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) { | ... | @@ -1259,79 +1299,76 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) { |
| 1259 | ; | 1299 | ; |
| 1260 | if (__i != __e) | 1300 | if (__i != __e) |
| 1261 | erase_after(__p, __e); | 1301 | erase_after(__p, __e); |
| 1262 | else { | 1302 | else |
| 1263 | __n -= __sz; | 1303 | __insert_after(__p, __n - __sz, __v); |
| 1264 | if (__n > 0) { | ||
| 1265 | for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n, __ptr = __ptr->__next_as_begin()) { | ||
| 1266 | __ptr->__next_ = this->__create_node(/* next = */ nullptr, __v); | ||
| 1267 | } | ||
| 1268 | } | ||
| 1269 | } | ||
| 1270 | } | 1304 | } |
| 1271 | 1305 | ||
| 1272 | template <class _Tp, class _Alloc> | 1306 | template <class _Tp, class _Alloc> |
| 1273 | void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& __x) { | 1307 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& __x) { |
| 1274 | if (!__x.empty()) { | 1308 | if (!__x.empty()) { |
| 1275 | if (__p.__get_begin()->__next_ != nullptr) { | 1309 | if (__p.__ptr_->__next_ != nullptr) { |
| 1276 | const_iterator __lm1 = __x.before_begin(); | 1310 | const_iterator __lm1 = __x.before_begin(); |
| 1277 | while (__lm1.__get_begin()->__next_ != nullptr) | 1311 | while (__lm1.__ptr_->__next_ != nullptr) |
| 1278 | ++__lm1; | 1312 | ++__lm1; |
| 1279 | __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_; | 1313 | __lm1.__ptr_->__next_ = __p.__ptr_->__next_; |
| 1280 | } | 1314 | } |
| 1281 | __p.__get_begin()->__next_ = __x.__before_begin()->__next_; | 1315 | __p.__ptr_->__next_ = __x.__before_begin()->__next_; |
| 1282 | __x.__before_begin()->__next_ = nullptr; | 1316 | __x.__before_begin()->__next_ = nullptr; |
| 1283 | } | 1317 | } |
| 1284 | } | 1318 | } |
| 1285 | 1319 | ||
| 1286 | template <class _Tp, class _Alloc> | 1320 | template <class _Tp, class _Alloc> |
| 1287 | void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& /*__other*/, const_iterator __i) { | 1321 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 1322 | forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& /*__other*/, const_iterator __i) { | ||
| 1288 | const_iterator __lm1 = std::next(__i); | 1323 | const_iterator __lm1 = std::next(__i); |
| 1289 | if (__p != __i && __p != __lm1) { | 1324 | if (__p != __i && __p != __lm1) { |
| 1290 | __i.__get_begin()->__next_ = __lm1.__get_begin()->__next_; | 1325 | __i.__ptr_->__next_ = __lm1.__ptr_->__next_; |
| 1291 | __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_; | 1326 | __lm1.__ptr_->__next_ = __p.__ptr_->__next_; |
| 1292 | __p.__get_begin()->__next_ = __lm1.__get_unsafe_node_pointer(); | 1327 | __p.__ptr_->__next_ = std::__static_fancy_pointer_cast<__node_pointer>(__lm1.__ptr_); |
| 1293 | } | 1328 | } |
| 1294 | } | 1329 | } |
| 1295 | 1330 | ||
| 1296 | template <class _Tp, class _Alloc> | 1331 | template <class _Tp, class _Alloc> |
| 1297 | void forward_list<_Tp, _Alloc>::splice_after( | 1332 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::splice_after( |
| 1298 | const_iterator __p, forward_list& /*__other*/, const_iterator __f, const_iterator __l) { | 1333 | const_iterator __p, forward_list& /*__other*/, const_iterator __f, const_iterator __l) { |
| 1299 | if (__f != __l && __p != __f) { | 1334 | if (__f != __l && __p != __f) { |
| 1300 | const_iterator __lm1 = __f; | 1335 | const_iterator __lm1 = __f; |
| 1301 | while (__lm1.__get_begin()->__next_ != __l.__get_begin()) | 1336 | while (__lm1.__ptr_->__next_ != __l.__ptr_) |
| 1302 | ++__lm1; | 1337 | ++__lm1; |
| 1303 | if (__f != __lm1) { | 1338 | if (__f != __lm1) { |
| 1304 | __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_; | 1339 | __lm1.__ptr_->__next_ = __p.__ptr_->__next_; |
| 1305 | __p.__get_begin()->__next_ = __f.__get_begin()->__next_; | 1340 | __p.__ptr_->__next_ = __f.__ptr_->__next_; |
| 1306 | __f.__get_begin()->__next_ = __l.__get_unsafe_node_pointer(); | 1341 | __f.__ptr_->__next_ = std::__static_fancy_pointer_cast<__node_pointer>(__l.__ptr_); |
| 1307 | } | 1342 | } |
| 1308 | } | 1343 | } |
| 1309 | } | 1344 | } |
| 1310 | 1345 | ||
| 1311 | template <class _Tp, class _Alloc> | 1346 | template <class _Tp, class _Alloc> |
| 1312 | inline _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x) { | 1347 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void |
| 1348 | forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x) { | ||
| 1313 | splice_after(__p, __x); | 1349 | splice_after(__p, __x); |
| 1314 | } | 1350 | } |
| 1315 | 1351 | ||
| 1316 | template <class _Tp, class _Alloc> | 1352 | template <class _Tp, class _Alloc> |
| 1317 | inline _LIBCPP_HIDE_FROM_ABI void | 1353 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void |
| 1318 | forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x, const_iterator __i) { | 1354 | forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x, const_iterator __i) { |
| 1319 | splice_after(__p, __x, __i); | 1355 | splice_after(__p, __x, __i); |
| 1320 | } | 1356 | } |
| 1321 | 1357 | ||
| 1322 | template <class _Tp, class _Alloc> | 1358 | template <class _Tp, class _Alloc> |
| 1323 | inline _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::splice_after( | 1359 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::splice_after( |
| 1324 | const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l) { | 1360 | const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l) { |
| 1325 | splice_after(__p, __x, __f, __l); | 1361 | splice_after(__p, __x, __f, __l); |
| 1326 | } | 1362 | } |
| 1327 | 1363 | ||
| 1328 | template <class _Tp, class _Alloc> | 1364 | template <class _Tp, class _Alloc> |
| 1329 | typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Alloc>::remove(const value_type& __v) { | 1365 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__remove_return_type |
| 1366 | forward_list<_Tp, _Alloc>::remove(const value_type& __v) { | ||
| 1330 | forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing | 1367 | forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing |
| 1331 | typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0; | 1368 | typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0; |
| 1332 | const iterator __e = end(); | 1369 | const iterator __e = end(); |
| 1333 | for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;) { | 1370 | for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;) { |
| 1334 | if (__i.__get_begin()->__next_->__get_value() == __v) { | 1371 | if (__i.__ptr_->__next_->__get_value() == __v) { |
| 1335 | ++__count_removed; | 1372 | ++__count_removed; |
| 1336 | iterator __j = std::next(__i, 2); | 1373 | iterator __j = std::next(__i, 2); |
| 1337 | for (; __j != __e && *__j == __v; ++__j) | 1374 | for (; __j != __e && *__j == __v; ++__j) |
| ... | @@ -1349,12 +1386,13 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo | ... | @@ -1349,12 +1386,13 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo |
| 1349 | 1386 | ||
| 1350 | template <class _Tp, class _Alloc> | 1387 | template <class _Tp, class _Alloc> |
| 1351 | template <class _Predicate> | 1388 | template <class _Predicate> |
| 1352 | typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred) { | 1389 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__remove_return_type |
| 1390 | forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred) { | ||
| 1353 | forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing | 1391 | forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing |
| 1354 | typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0; | 1392 | typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0; |
| 1355 | const iterator __e = end(); | 1393 | const iterator __e = end(); |
| 1356 | for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;) { | 1394 | for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;) { |
| 1357 | if (__pred(__i.__get_begin()->__next_->__get_value())) { | 1395 | if (__pred(__i.__ptr_->__next_->__get_value())) { |
| 1358 | ++__count_removed; | 1396 | ++__count_removed; |
| 1359 | iterator __j = std::next(__i, 2); | 1397 | iterator __j = std::next(__i, 2); |
| 1360 | for (; __j != __e && __pred(*__j); ++__j) | 1398 | for (; __j != __e && __pred(*__j); ++__j) |
| ... | @@ -1372,7 +1410,7 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo | ... | @@ -1372,7 +1410,7 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo |
| 1372 | 1410 | ||
| 1373 | template <class _Tp, class _Alloc> | 1411 | template <class _Tp, class _Alloc> |
| 1374 | template <class _BinaryPredicate> | 1412 | template <class _BinaryPredicate> |
| 1375 | typename forward_list<_Tp, _Alloc>::__remove_return_type | 1413 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__remove_return_type |
| 1376 | forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) { | 1414 | forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) { |
| 1377 | forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing | 1415 | forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing |
| 1378 | typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0; | 1416 | typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0; |
| ... | @@ -1380,7 +1418,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) { | ... | @@ -1380,7 +1418,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) { |
| 1380 | iterator __j = std::next(__i); | 1418 | iterator __j = std::next(__i); |
| 1381 | for (; __j != __e && __binary_pred(*__i, *__j); ++__j) | 1419 | for (; __j != __e && __binary_pred(*__i, *__j); ++__j) |
| 1382 | ++__count_removed; | 1420 | ++__count_removed; |
| 1383 | if (__i.__get_begin()->__next_ != __j.__get_unsafe_node_pointer()) | 1421 | if (__i.__ptr_->__next_ != std::__static_fancy_pointer_cast<__node_pointer>(__j.__ptr_)) |
| 1384 | __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j); | 1422 | __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j); |
| 1385 | __i = __j; | 1423 | __i = __j; |
| 1386 | } | 1424 | } |
| ... | @@ -1390,7 +1428,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) { | ... | @@ -1390,7 +1428,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) { |
| 1390 | 1428 | ||
| 1391 | template <class _Tp, class _Alloc> | 1429 | template <class _Tp, class _Alloc> |
| 1392 | template <class _Compare> | 1430 | template <class _Compare> |
| 1393 | void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) { | 1431 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) { |
| 1394 | if (this != std::addressof(__x)) { | 1432 | if (this != std::addressof(__x)) { |
| 1395 | __base::__before_begin()->__next_ = | 1433 | __base::__before_begin()->__next_ = |
| 1396 | __merge(__base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp); | 1434 | __merge(__base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp); |
| ... | @@ -1400,7 +1438,7 @@ void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) { | ... | @@ -1400,7 +1438,7 @@ void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) { |
| 1400 | 1438 | ||
| 1401 | template <class _Tp, class _Alloc> | 1439 | template <class _Tp, class _Alloc> |
| 1402 | template <class _Compare> | 1440 | template <class _Compare> |
| 1403 | typename forward_list<_Tp, _Alloc>::__node_pointer | 1441 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__node_pointer |
| 1404 | forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp) { | 1442 | forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp) { |
| 1405 | if (__f1 == nullptr) | 1443 | if (__f1 == nullptr) |
| 1406 | return __f2; | 1444 | return __f2; |
| ... | @@ -1437,13 +1475,13 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Co | ... | @@ -1437,13 +1475,13 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Co |
| 1437 | 1475 | ||
| 1438 | template <class _Tp, class _Alloc> | 1476 | template <class _Tp, class _Alloc> |
| 1439 | template <class _Compare> | 1477 | template <class _Compare> |
| 1440 | inline void forward_list<_Tp, _Alloc>::sort(_Compare __comp) { | 1478 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void forward_list<_Tp, _Alloc>::sort(_Compare __comp) { |
| 1441 | __base::__before_begin()->__next_ = __sort(__base::__before_begin()->__next_, std::distance(begin(), end()), __comp); | 1479 | __base::__before_begin()->__next_ = __sort(__base::__before_begin()->__next_, std::distance(begin(), end()), __comp); |
| 1442 | } | 1480 | } |
| 1443 | 1481 | ||
| 1444 | template <class _Tp, class _Alloc> | 1482 | template <class _Tp, class _Alloc> |
| 1445 | template <class _Compare> | 1483 | template <class _Compare> |
| 1446 | typename forward_list<_Tp, _Alloc>::__node_pointer | 1484 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__node_pointer |
| 1447 | forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Compare& __comp) { | 1485 | forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Compare& __comp) { |
| 1448 | switch (__sz) { | 1486 | switch (__sz) { |
| 1449 | case 0: | 1487 | case 0: |
| ... | @@ -1460,14 +1498,14 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Co | ... | @@ -1460,14 +1498,14 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Co |
| 1460 | } | 1498 | } |
| 1461 | difference_type __sz1 = __sz / 2; | 1499 | difference_type __sz1 = __sz / 2; |
| 1462 | difference_type __sz2 = __sz - __sz1; | 1500 | difference_type __sz2 = __sz - __sz1; |
| 1463 | __node_pointer __t = std::next(iterator(__f1), __sz1 - 1).__get_unsafe_node_pointer(); | 1501 | __node_pointer __t = std::__static_fancy_pointer_cast<__node_pointer>(std::next(iterator(__f1), __sz1 - 1).__ptr_); |
| 1464 | __node_pointer __f2 = __t->__next_; | 1502 | __node_pointer __f2 = __t->__next_; |
| 1465 | __t->__next_ = nullptr; | 1503 | __t->__next_ = nullptr; |
| 1466 | return __merge(__sort(__f1, __sz1, __comp), __sort(__f2, __sz2, __comp), __comp); | 1504 | return __merge(__sort(__f1, __sz1, __comp), __sort(__f2, __sz2, __comp), __comp); |
| 1467 | } | 1505 | } |
| 1468 | 1506 | ||
| 1469 | template <class _Tp, class _Alloc> | 1507 | template <class _Tp, class _Alloc> |
| 1470 | void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT { | 1508 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT { |
| 1471 | __node_pointer __p = __base::__before_begin()->__next_; | 1509 | __node_pointer __p = __base::__before_begin()->__next_; |
| 1472 | if (__p != nullptr) { | 1510 | if (__p != nullptr) { |
| 1473 | __node_pointer __f = __p->__next_; | 1511 | __node_pointer __f = __p->__next_; |
| ... | @@ -1483,7 +1521,8 @@ void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT { | ... | @@ -1483,7 +1521,8 @@ void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT { |
| 1483 | } | 1521 | } |
| 1484 | 1522 | ||
| 1485 | template <class _Tp, class _Alloc> | 1523 | template <class _Tp, class _Alloc> |
| 1486 | _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { | 1524 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 1525 | operator==(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { | ||
| 1487 | typedef forward_list<_Tp, _Alloc> _Cp; | 1526 | typedef forward_list<_Tp, _Alloc> _Cp; |
| 1488 | typedef typename _Cp::const_iterator _Ip; | 1527 | typedef typename _Cp::const_iterator _Ip; |
| 1489 | _Ip __ix = __x.begin(); | 1528 | _Ip __ix = __x.begin(); |
| ... | @@ -1499,31 +1538,31 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons | ... | @@ -1499,31 +1538,31 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons |
| 1499 | # if _LIBCPP_STD_VER <= 17 | 1538 | # if _LIBCPP_STD_VER <= 17 |
| 1500 | 1539 | ||
| 1501 | template <class _Tp, class _Alloc> | 1540 | template <class _Tp, class _Alloc> |
| 1502 | inline _LIBCPP_HIDE_FROM_ABI bool | 1541 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1503 | operator!=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { | 1542 | operator!=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { |
| 1504 | return !(__x == __y); | 1543 | return !(__x == __y); |
| 1505 | } | 1544 | } |
| 1506 | 1545 | ||
| 1507 | template <class _Tp, class _Alloc> | 1546 | template <class _Tp, class _Alloc> |
| 1508 | inline _LIBCPP_HIDE_FROM_ABI bool | 1547 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1509 | operator<(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { | 1548 | operator<(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { |
| 1510 | return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); | 1549 | return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
| 1511 | } | 1550 | } |
| 1512 | 1551 | ||
| 1513 | template <class _Tp, class _Alloc> | 1552 | template <class _Tp, class _Alloc> |
| 1514 | inline _LIBCPP_HIDE_FROM_ABI bool | 1553 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1515 | operator>(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { | 1554 | operator>(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { |
| 1516 | return __y < __x; | 1555 | return __y < __x; |
| 1517 | } | 1556 | } |
| 1518 | 1557 | ||
| 1519 | template <class _Tp, class _Alloc> | 1558 | template <class _Tp, class _Alloc> |
| 1520 | inline _LIBCPP_HIDE_FROM_ABI bool | 1559 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1521 | operator>=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { | 1560 | operator>=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { |
| 1522 | return !(__x < __y); | 1561 | return !(__x < __y); |
| 1523 | } | 1562 | } |
| 1524 | 1563 | ||
| 1525 | template <class _Tp, class _Alloc> | 1564 | template <class _Tp, class _Alloc> |
| 1526 | inline _LIBCPP_HIDE_FROM_ABI bool | 1565 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1527 | operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { | 1566 | operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) { |
| 1528 | return !(__y < __x); | 1567 | return !(__y < __x); |
| 1529 | } | 1568 | } |
| ... | @@ -1531,7 +1570,7 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc> | ... | @@ -1531,7 +1570,7 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc> |
| 1531 | # else // #if _LIBCPP_STD_VER <= 17 | 1570 | # else // #if _LIBCPP_STD_VER <= 17 |
| 1532 | 1571 | ||
| 1533 | template <class _Tp, class _Allocator> | 1572 | template <class _Tp, class _Allocator> |
| 1534 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> | 1573 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| 1535 | operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) { | 1574 | operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) { |
| 1536 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 1575 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1537 | } | 1576 | } |
| ... | @@ -1539,22 +1578,22 @@ operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _A | ... | @@ -1539,22 +1578,22 @@ operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _A |
| 1539 | # endif // #if _LIBCPP_STD_VER <= 17 | 1578 | # endif // #if _LIBCPP_STD_VER <= 17 |
| 1540 | 1579 | ||
| 1541 | template <class _Tp, class _Alloc> | 1580 | template <class _Tp, class _Alloc> |
| 1542 | inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) | 1581 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void |
| 1543 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 1582 | swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 1544 | __x.swap(__y); | 1583 | __x.swap(__y); |
| 1545 | } | 1584 | } |
| 1546 | 1585 | ||
| 1547 | # if _LIBCPP_STD_VER >= 20 | 1586 | # if _LIBCPP_STD_VER >= 20 |
| 1548 | template <class _Tp, class _Allocator, class _Predicate> | 1587 | template <class _Tp, class _Allocator, class _Predicate> |
| 1549 | inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type | 1588 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type |
| 1550 | erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) { | 1589 | erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 1551 | return __c.remove_if(__pred); | 1590 | return __c.remove_if(__pred); |
| 1552 | } | 1591 | } |
| 1553 | 1592 | ||
| 1554 | template <class _Tp, class _Allocator, class _Up> | 1593 | template <class _Tp, class _Allocator, class _Up> |
| 1555 | inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type | 1594 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type |
| 1556 | erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) { | 1595 | erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) { |
| 1557 | return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); | 1596 | return std::erase_if(__c, [&](const auto& __elem) -> bool { return __elem == __v; }); |
| 1558 | } | 1597 | } |
| 1559 | # endif | 1598 | # endif |
| 1560 | 1599 | ||
| ... | @@ -1567,6 +1606,8 @@ struct __container_traits<forward_list<_Tp, _Allocator> > { | ... | @@ -1567,6 +1606,8 @@ struct __container_traits<forward_list<_Tp, _Allocator> > { |
| 1567 | // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that | 1606 | // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that |
| 1568 | // function has no effects. | 1607 | // function has no effects. |
| 1569 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | 1608 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; |
| 1609 | |||
| 1610 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 1570 | }; | 1611 | }; |
| 1571 | 1612 | ||
| 1572 | _LIBCPP_END_NAMESPACE_STD | 1613 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/fstream+93-73| ... | @@ -189,35 +189,36 @@ typedef basic_fstream<wchar_t> wfstream; | ... | @@ -189,35 +189,36 @@ typedef basic_fstream<wchar_t> wfstream; |
| 189 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 189 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 190 | # include <__cxx03/fstream> | 190 | # include <__cxx03/fstream> |
| 191 | #else | 191 | #else |
| 192 | # include <__algorithm/max.h> | ||
| 193 | # include <__assert> | ||
| 194 | # include <__config> | 192 | # include <__config> |
| 195 | # include <__filesystem/path.h> | ||
| 196 | # include <__fwd/fstream.h> | ||
| 197 | # include <__locale> | ||
| 198 | # include <__memory/addressof.h> | ||
| 199 | # include <__memory/unique_ptr.h> | ||
| 200 | # include <__ostream/basic_ostream.h> | ||
| 201 | # include <__type_traits/enable_if.h> | ||
| 202 | # include <__type_traits/is_same.h> | ||
| 203 | # include <__utility/move.h> | ||
| 204 | # include <__utility/swap.h> | ||
| 205 | # include <__utility/unreachable.h> | ||
| 206 | # include <cstdio> | ||
| 207 | # include <istream> | ||
| 208 | # include <streambuf> | ||
| 209 | # include <typeinfo> | ||
| 210 | # include <version> | ||
| 211 | |||
| 212 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 213 | # pragma GCC system_header | ||
| 214 | # endif | ||
| 215 | |||
| 216 | _LIBCPP_PUSH_MACROS | ||
| 217 | # include <__undef_macros> | ||
| 218 | 193 | ||
| 219 | # if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | 194 | # if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION |
| 220 | 195 | ||
| 196 | # include <__algorithm/max.h> | ||
| 197 | # include <__assert> | ||
| 198 | # include <__filesystem/path.h> | ||
| 199 | # include <__fwd/fstream.h> | ||
| 200 | # include <__locale> | ||
| 201 | # include <__memory/addressof.h> | ||
| 202 | # include <__memory/unique_ptr.h> | ||
| 203 | # include <__ostream/basic_ostream.h> | ||
| 204 | # include <__type_traits/enable_if.h> | ||
| 205 | # include <__type_traits/is_same.h> | ||
| 206 | # include <__utility/move.h> | ||
| 207 | # include <__utility/swap.h> | ||
| 208 | # include <__utility/unreachable.h> | ||
| 209 | # include <cstdio> | ||
| 210 | # include <istream> | ||
| 211 | # include <streambuf> | ||
| 212 | # include <typeinfo> | ||
| 213 | # include <version> | ||
| 214 | |||
| 215 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 216 | # pragma GCC system_header | ||
| 217 | # endif | ||
| 218 | |||
| 219 | _LIBCPP_PUSH_MACROS | ||
| 220 | # include <__undef_macros> | ||
| 221 | |||
| 221 | _LIBCPP_BEGIN_NAMESPACE_STD | 222 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 222 | 223 | ||
| 223 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) | 224 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) |
| ... | @@ -225,7 +226,7 @@ _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) no | ... | @@ -225,7 +226,7 @@ _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) no |
| 225 | # endif | 226 | # endif |
| 226 | 227 | ||
| 227 | template <class _CharT, class _Traits> | 228 | template <class _CharT, class _Traits> |
| 228 | class _LIBCPP_TEMPLATE_VIS basic_filebuf : public basic_streambuf<_CharT, _Traits> { | 229 | class basic_filebuf : public basic_streambuf<_CharT, _Traits> { |
| 229 | public: | 230 | public: |
| 230 | typedef _CharT char_type; | 231 | typedef _CharT char_type; |
| 231 | typedef _Traits traits_type; | 232 | typedef _Traits traits_type; |
| ... | @@ -420,7 +421,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf() | ... | @@ -420,7 +421,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf() |
| 420 | __owns_ib_(false), | 421 | __owns_ib_(false), |
| 421 | __always_noconv_(false) { | 422 | __always_noconv_(false) { |
| 422 | if (std::has_facet<codecvt<char_type, char, state_type> >(this->getloc())) { | 423 | if (std::has_facet<codecvt<char_type, char, state_type> >(this->getloc())) { |
| 423 | __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(this->getloc()); | 424 | __cv_ = std::addressof(std::use_facet<codecvt<char_type, char, state_type> >(this->getloc())); |
| 424 | __always_noconv_ = __cv_->always_noconv(); | 425 | __always_noconv_ = __cv_->always_noconv(); |
| 425 | } | 426 | } |
| 426 | setbuf(nullptr, 4096); | 427 | setbuf(nullptr, 4096); |
| ... | @@ -695,7 +696,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* | ... | @@ -695,7 +696,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* |
| 695 | if (!__mdstr) | 696 | if (!__mdstr) |
| 696 | return nullptr; | 697 | return nullptr; |
| 697 | 698 | ||
| 698 | return __do_open(fopen(__s, __mdstr), __mode); | 699 | return __do_open(std::fopen(__s, __mdstr), __mode); |
| 699 | } | 700 | } |
| 700 | 701 | ||
| 701 | template <class _CharT, class _Traits> | 702 | template <class _CharT, class _Traits> |
| ... | @@ -753,14 +754,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -753,14 +754,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 753 | bool __initial = __read_mode(); | 754 | bool __initial = __read_mode(); |
| 754 | char_type __1buf; | 755 | char_type __1buf; |
| 755 | if (this->gptr() == nullptr) | 756 | if (this->gptr() == nullptr) |
| 756 | this->setg(&__1buf, &__1buf + 1, &__1buf + 1); | 757 | this->setg(std::addressof(__1buf), std::addressof(__1buf) + 1, std::addressof(__1buf) + 1); |
| 757 | const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4); | 758 | const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4); |
| 758 | int_type __c = traits_type::eof(); | 759 | int_type __c = traits_type::eof(); |
| 759 | if (this->gptr() == this->egptr()) { | 760 | if (this->gptr() == this->egptr()) { |
| 760 | std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); | 761 | std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); |
| 761 | if (__always_noconv_) { | 762 | if (__always_noconv_) { |
| 762 | size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz); | 763 | size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz); |
| 763 | __nmemb = ::fread(this->eback() + __unget_sz, 1, __nmemb, __file_); | 764 | __nmemb = std::fread(this->eback() + __unget_sz, 1, __nmemb, __file_); |
| 764 | if (__nmemb != 0) { | 765 | if (__nmemb != 0) { |
| 765 | this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb); | 766 | this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb); |
| 766 | __c = traits_type::to_int_type(*this->gptr()); | 767 | __c = traits_type::to_int_type(*this->gptr()); |
| ... | @@ -777,10 +778,10 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -777,10 +778,10 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 777 | std::min(static_cast<size_t>(__ibs_ - __unget_sz), static_cast<size_t>(__extbufend_ - __extbufnext_)); | 778 | std::min(static_cast<size_t>(__ibs_ - __unget_sz), static_cast<size_t>(__extbufend_ - __extbufnext_)); |
| 778 | codecvt_base::result __r; | 779 | codecvt_base::result __r; |
| 779 | __st_last_ = __st_; | 780 | __st_last_ = __st_; |
| 780 | size_t __nr = fread((void*)const_cast<char*>(__extbufnext_), 1, __nmemb, __file_); | 781 | size_t __nr = std::fread((void*)const_cast<char*>(__extbufnext_), 1, __nmemb, __file_); |
| 781 | if (__nr != 0) { | 782 | if (__nr != 0) { |
| 782 | if (!__cv_) | 783 | if (!__cv_) |
| 783 | __throw_bad_cast(); | 784 | std::__throw_bad_cast(); |
| 784 | 785 | ||
| 785 | __extbufend_ = __extbufnext_ + __nr; | 786 | __extbufend_ = __extbufnext_ + __nr; |
| 786 | char_type* __inext; | 787 | char_type* __inext; |
| ... | @@ -797,7 +798,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -797,7 +798,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 797 | } | 798 | } |
| 798 | } else | 799 | } else |
| 799 | __c = traits_type::to_int_type(*this->gptr()); | 800 | __c = traits_type::to_int_type(*this->gptr()); |
| 800 | if (this->eback() == &__1buf) | 801 | if (this->eback() == std::addressof(__1buf)) |
| 801 | this->setg(nullptr, nullptr, nullptr); | 802 | this->setg(nullptr, nullptr, nullptr); |
| 802 | return __c; | 803 | return __c; |
| 803 | } | 804 | } |
| ... | @@ -828,44 +829,63 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> | ... | @@ -828,44 +829,63 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits> |
| 828 | char_type* __epb_save = this->epptr(); | 829 | char_type* __epb_save = this->epptr(); |
| 829 | if (!traits_type::eq_int_type(__c, traits_type::eof())) { | 830 | if (!traits_type::eq_int_type(__c, traits_type::eof())) { |
| 830 | if (this->pptr() == nullptr) | 831 | if (this->pptr() == nullptr) |
| 831 | this->setp(&__1buf, &__1buf + 1); | 832 | this->setp(std::addressof(__1buf), std::addressof(__1buf) + 1); |
| 832 | *this->pptr() = traits_type::to_char_type(__c); | 833 | *this->pptr() = traits_type::to_char_type(__c); |
| 833 | this->pbump(1); | 834 | this->pbump(1); |
| 834 | } | 835 | } |
| 835 | if (this->pptr() != this->pbase()) { | 836 | |
| 836 | if (__always_noconv_) { | 837 | // There is nothing to write, early return |
| 837 | size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase()); | 838 | if (this->pptr() == this->pbase()) { |
| 838 | if (std::fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb) | 839 | return traits_type::not_eof(__c); |
| 840 | } | ||
| 841 | |||
| 842 | if (__always_noconv_) { | ||
| 843 | size_t __n = static_cast<size_t>(this->pptr() - this->pbase()); | ||
| 844 | if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n) | ||
| 845 | return traits_type::eof(); | ||
| 846 | } else { | ||
| 847 | if (!__cv_) | ||
| 848 | std::__throw_bad_cast(); | ||
| 849 | |||
| 850 | // See [filebuf.virtuals] | ||
| 851 | char_type* __b = this->pbase(); | ||
| 852 | char_type* __p = this->pptr(); | ||
| 853 | const char_type* __end; | ||
| 854 | char* __extbuf_end = __extbuf_; | ||
| 855 | do { | ||
| 856 | codecvt_base::result __r = __cv_->out(__st_, __b, __p, __end, __extbuf_, __extbuf_ + __ebs_, __extbuf_end); | ||
| 857 | if (__end == __b) | ||
| 839 | return traits_type::eof(); | 858 | return traits_type::eof(); |
| 840 | } else { | ||
| 841 | char* __extbe = __extbuf_; | ||
| 842 | codecvt_base::result __r; | ||
| 843 | do { | ||
| 844 | if (!__cv_) | ||
| 845 | __throw_bad_cast(); | ||
| 846 | 859 | ||
| 847 | const char_type* __e; | 860 | // No conversion needed: output characters directly to the file, done. |
| 848 | __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe); | 861 | if (__r == codecvt_base::noconv) { |
| 849 | if (__e == this->pbase()) | 862 | size_t __n = static_cast<size_t>(__p - __b); |
| 863 | if (std::fwrite(__b, 1, __n, __file_) != __n) | ||
| 850 | return traits_type::eof(); | 864 | return traits_type::eof(); |
| 851 | if (__r == codecvt_base::noconv) { | 865 | break; |
| 852 | size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase()); | 866 | |
| 853 | if (std::fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb) | 867 | // Conversion successful: output the converted characters to the file, done. |
| 854 | return traits_type::eof(); | 868 | } else if (__r == codecvt_base::ok) { |
| 855 | } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) { | 869 | size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_); |
| 856 | size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_); | 870 | if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) |
| 857 | if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb) | ||
| 858 | return traits_type::eof(); | ||
| 859 | if (__r == codecvt_base::partial) { | ||
| 860 | this->setp(const_cast<char_type*>(__e), this->pptr()); | ||
| 861 | this->__pbump(this->epptr() - this->pbase()); | ||
| 862 | } | ||
| 863 | } else | ||
| 864 | return traits_type::eof(); | 871 | return traits_type::eof(); |
| 865 | } while (__r == codecvt_base::partial); | 872 | break; |
| 866 | } | 873 | |
| 867 | this->setp(__pb_save, __epb_save); | 874 | // Conversion partially successful: output converted characters to the file and repeat with the |
| 875 | // remaining characters. | ||
| 876 | } else if (__r == codecvt_base::partial) { | ||
| 877 | size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_); | ||
| 878 | if (std::fwrite(__extbuf_, 1, __n, __file_) != __n) | ||
| 879 | return traits_type::eof(); | ||
| 880 | __b = const_cast<char_type*>(__end); | ||
| 881 | continue; | ||
| 882 | |||
| 883 | } else { | ||
| 884 | return traits_type::eof(); | ||
| 885 | } | ||
| 886 | } while (true); | ||
| 868 | } | 887 | } |
| 888 | this->setp(__pb_save, __epb_save); | ||
| 869 | return traits_type::not_eof(__c); | 889 | return traits_type::not_eof(__c); |
| 870 | } | 890 | } |
| 871 | 891 | ||
| ... | @@ -913,7 +933,7 @@ template <class _CharT, class _Traits> | ... | @@ -913,7 +933,7 @@ template <class _CharT, class _Traits> |
| 913 | typename basic_filebuf<_CharT, _Traits>::pos_type | 933 | typename basic_filebuf<_CharT, _Traits>::pos_type |
| 914 | basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode) { | 934 | basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode) { |
| 915 | if (!__cv_) | 935 | if (!__cv_) |
| 916 | __throw_bad_cast(); | 936 | std::__throw_bad_cast(); |
| 917 | 937 | ||
| 918 | int __width = __cv_->encoding(); | 938 | int __width = __cv_->encoding(); |
| 919 | if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync()) | 939 | if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync()) |
| ... | @@ -978,7 +998,7 @@ int basic_filebuf<_CharT, _Traits>::sync() { | ... | @@ -978,7 +998,7 @@ int basic_filebuf<_CharT, _Traits>::sync() { |
| 978 | if (__file_ == nullptr) | 998 | if (__file_ == nullptr) |
| 979 | return 0; | 999 | return 0; |
| 980 | if (!__cv_) | 1000 | if (!__cv_) |
| 981 | __throw_bad_cast(); | 1001 | std::__throw_bad_cast(); |
| 982 | 1002 | ||
| 983 | if (__cm_ & ios_base::out) { | 1003 | if (__cm_ & ios_base::out) { |
| 984 | if (this->pptr() != this->pbase()) | 1004 | if (this->pptr() != this->pbase()) |
| ... | @@ -989,12 +1009,12 @@ int basic_filebuf<_CharT, _Traits>::sync() { | ... | @@ -989,12 +1009,12 @@ int basic_filebuf<_CharT, _Traits>::sync() { |
| 989 | char* __extbe; | 1009 | char* __extbe; |
| 990 | __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe); | 1010 | __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe); |
| 991 | size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_); | 1011 | size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_); |
| 992 | if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb) | 1012 | if (std::fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb) |
| 993 | return -1; | 1013 | return -1; |
| 994 | } while (__r == codecvt_base::partial); | 1014 | } while (__r == codecvt_base::partial); |
| 995 | if (__r == codecvt_base::error) | 1015 | if (__r == codecvt_base::error) |
| 996 | return -1; | 1016 | return -1; |
| 997 | if (fflush(__file_)) | 1017 | if (std::fflush(__file_)) |
| 998 | return -1; | 1018 | return -1; |
| 999 | } else if (__cm_ & ios_base::in) { | 1019 | } else if (__cm_ & ios_base::in) { |
| 1000 | off_type __c; | 1020 | off_type __c; |
| ... | @@ -1029,7 +1049,7 @@ int basic_filebuf<_CharT, _Traits>::sync() { | ... | @@ -1029,7 +1049,7 @@ int basic_filebuf<_CharT, _Traits>::sync() { |
| 1029 | template <class _CharT, class _Traits> | 1049 | template <class _CharT, class _Traits> |
| 1030 | void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) { | 1050 | void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) { |
| 1031 | sync(); | 1051 | sync(); |
| 1032 | __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(__loc); | 1052 | __cv_ = std::addressof(std::use_facet<codecvt<char_type, char, state_type> >(__loc)); |
| 1033 | bool __old_anc = __always_noconv_; | 1053 | bool __old_anc = __always_noconv_; |
| 1034 | __always_noconv_ = __cv_->always_noconv(); | 1054 | __always_noconv_ = __cv_->always_noconv(); |
| 1035 | if (__old_anc != __always_noconv_) { | 1055 | if (__old_anc != __always_noconv_) { |
| ... | @@ -1095,7 +1115,7 @@ void basic_filebuf<_CharT, _Traits>::__write_mode() { | ... | @@ -1095,7 +1115,7 @@ void basic_filebuf<_CharT, _Traits>::__write_mode() { |
| 1095 | // basic_ifstream | 1115 | // basic_ifstream |
| 1096 | 1116 | ||
| 1097 | template <class _CharT, class _Traits> | 1117 | template <class _CharT, class _Traits> |
| 1098 | class _LIBCPP_TEMPLATE_VIS basic_ifstream : public basic_istream<_CharT, _Traits> { | 1118 | class basic_ifstream : public basic_istream<_CharT, _Traits> { |
| 1099 | public: | 1119 | public: |
| 1100 | typedef _CharT char_type; | 1120 | typedef _CharT char_type; |
| 1101 | typedef _Traits traits_type; | 1121 | typedef _Traits traits_type; |
| ... | @@ -1251,7 +1271,7 @@ inline void basic_ifstream<_CharT, _Traits>::close() { | ... | @@ -1251,7 +1271,7 @@ inline void basic_ifstream<_CharT, _Traits>::close() { |
| 1251 | // basic_ofstream | 1271 | // basic_ofstream |
| 1252 | 1272 | ||
| 1253 | template <class _CharT, class _Traits> | 1273 | template <class _CharT, class _Traits> |
| 1254 | class _LIBCPP_TEMPLATE_VIS basic_ofstream : public basic_ostream<_CharT, _Traits> { | 1274 | class basic_ofstream : public basic_ostream<_CharT, _Traits> { |
| 1255 | public: | 1275 | public: |
| 1256 | typedef _CharT char_type; | 1276 | typedef _CharT char_type; |
| 1257 | typedef _Traits traits_type; | 1277 | typedef _Traits traits_type; |
| ... | @@ -1410,7 +1430,7 @@ inline void basic_ofstream<_CharT, _Traits>::close() { | ... | @@ -1410,7 +1430,7 @@ inline void basic_ofstream<_CharT, _Traits>::close() { |
| 1410 | // basic_fstream | 1430 | // basic_fstream |
| 1411 | 1431 | ||
| 1412 | template <class _CharT, class _Traits> | 1432 | template <class _CharT, class _Traits> |
| 1413 | class _LIBCPP_TEMPLATE_VIS basic_fstream : public basic_iostream<_CharT, _Traits> { | 1433 | class basic_fstream : public basic_iostream<_CharT, _Traits> { |
| 1414 | public: | 1434 | public: |
| 1415 | typedef _CharT char_type; | 1435 | typedef _CharT char_type; |
| 1416 | typedef _Traits traits_type; | 1436 | typedef _Traits traits_type; |
| ... | @@ -1570,10 +1590,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>; | ... | @@ -1570,10 +1590,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>; |
| 1570 | 1590 | ||
| 1571 | _LIBCPP_END_NAMESPACE_STD | 1591 | _LIBCPP_END_NAMESPACE_STD |
| 1572 | 1592 | ||
| 1573 | # endif // _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | ||
| 1574 | |||
| 1575 | _LIBCPP_POP_MACROS | 1593 | _LIBCPP_POP_MACROS |
| 1576 | 1594 | ||
| 1595 | # endif // _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | ||
| 1596 | |||
| 1577 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 1597 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 1578 | # include <atomic> | 1598 | # include <atomic> |
| 1579 | # include <concepts> | 1599 | # include <concepts> |
lib/libcxx/include/functional+5| ... | @@ -565,6 +565,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited | ... | @@ -565,6 +565,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 565 | # include <__functional/bind_front.h> | 565 | # include <__functional/bind_front.h> |
| 566 | # include <__functional/identity.h> | 566 | # include <__functional/identity.h> |
| 567 | # include <__functional/ranges_operations.h> | 567 | # include <__functional/ranges_operations.h> |
| 568 | # include <__type_traits/common_reference.h> | ||
| 568 | # include <__type_traits/unwrap_ref.h> | 569 | # include <__type_traits/unwrap_ref.h> |
| 569 | # endif | 570 | # endif |
| 570 | 571 | ||
| ... | @@ -599,6 +600,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited | ... | @@ -599,6 +600,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 599 | # include <utility> | 600 | # include <utility> |
| 600 | # include <vector> | 601 | # include <vector> |
| 601 | # endif | 602 | # endif |
| 603 | |||
| 604 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 23 | ||
| 605 | # include <__vector/vector.h> | ||
| 606 | # endif | ||
| 602 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 607 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 603 | 608 | ||
| 604 | #endif // _LIBCPP_FUNCTIONAL | 609 | #endif // _LIBCPP_FUNCTIONAL |
lib/libcxx/include/future+80-85| ... | @@ -322,8 +322,6 @@ template <class R, class... ArgTypes> | ... | @@ -322,8 +322,6 @@ template <class R, class... ArgTypes> |
| 322 | class packaged_task<R(ArgTypes...)> | 322 | class packaged_task<R(ArgTypes...)> |
| 323 | { | 323 | { |
| 324 | public: | 324 | public: |
| 325 | typedef R result_type; // extension | ||
| 326 | |||
| 327 | // construction and destruction | 325 | // construction and destruction |
| 328 | packaged_task() noexcept; | 326 | packaged_task() noexcept; |
| 329 | template <class F> | 327 | template <class F> |
| ... | @@ -393,7 +391,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; | ... | @@ -393,7 +391,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; |
| 393 | # include <__system_error/error_code.h> | 391 | # include <__system_error/error_code.h> |
| 394 | # include <__system_error/error_condition.h> | 392 | # include <__system_error/error_condition.h> |
| 395 | # include <__thread/thread.h> | 393 | # include <__thread/thread.h> |
| 396 | # include <__type_traits/add_lvalue_reference.h> | 394 | # include <__type_traits/add_reference.h> |
| 397 | # include <__type_traits/aligned_storage.h> | 395 | # include <__type_traits/aligned_storage.h> |
| 398 | # include <__type_traits/conditional.h> | 396 | # include <__type_traits/conditional.h> |
| 399 | # include <__type_traits/decay.h> | 397 | # include <__type_traits/decay.h> |
| ... | @@ -427,11 +425,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(future_errc){ | ... | @@ -427,11 +425,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(future_errc){ |
| 427 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) | 425 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) |
| 428 | 426 | ||
| 429 | template <> | 427 | template <> |
| 430 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {}; | 428 | struct is_error_code_enum<future_errc> : public true_type {}; |
| 431 | 429 | ||
| 432 | # ifdef _LIBCPP_CXX03_LANG | 430 | # ifdef _LIBCPP_CXX03_LANG |
| 433 | template <> | 431 | template <> |
| 434 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {}; | 432 | struct is_error_code_enum<future_errc::__lx> : public true_type {}; |
| 435 | # endif | 433 | # endif |
| 436 | 434 | ||
| 437 | // enum class launch | 435 | // enum class launch |
| ... | @@ -440,7 +438,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) | ... | @@ -440,7 +438,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) |
| 440 | 438 | ||
| 441 | # ifndef _LIBCPP_CXX03_LANG | 439 | # ifndef _LIBCPP_CXX03_LANG |
| 442 | 440 | ||
| 443 | typedef underlying_type<launch>::type __launch_underlying_type; | 441 | using __launch_underlying_type _LIBCPP_NODEBUG = __underlying_type_t<launch>; |
| 444 | 442 | ||
| 445 | inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator&(launch __x, launch __y) { | 443 | inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator&(launch __x, launch __y) { |
| 446 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y)); | 444 | return static_cast<launch>(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y)); |
| ... | @@ -541,7 +539,7 @@ public: | ... | @@ -541,7 +539,7 @@ public: |
| 541 | lock_guard<mutex> __lk(__mut_); | 539 | lock_guard<mutex> __lk(__mut_); |
| 542 | bool __has_future_attached = (__state_ & __future_attached) != 0; | 540 | bool __has_future_attached = (__state_ & __future_attached) != 0; |
| 543 | if (__has_future_attached) | 541 | if (__has_future_attached) |
| 544 | __throw_future_error(future_errc::future_already_retrieved); | 542 | std::__throw_future_error(future_errc::future_already_retrieved); |
| 545 | this->__add_shared(); | 543 | this->__add_shared(); |
| 546 | __state_ |= __future_attached; | 544 | __state_ |= __future_attached; |
| 547 | } | 545 | } |
| ... | @@ -563,24 +561,20 @@ public: | ... | @@ -563,24 +561,20 @@ public: |
| 563 | template <class _Rep, class _Period> | 561 | template <class _Rep, class _Period> |
| 564 | future_status _LIBCPP_HIDE_FROM_ABI wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const; | 562 | future_status _LIBCPP_HIDE_FROM_ABI wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const; |
| 565 | template <class _Clock, class _Duration> | 563 | template <class _Clock, class _Duration> |
| 566 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS future_status | 564 | _LIBCPP_HIDE_FROM_ABI future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const { |
| 567 | wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const; | 565 | unique_lock<mutex> __lk(__mut_); |
| 566 | if (__state_ & deferred) | ||
| 567 | return future_status::deferred; | ||
| 568 | while (!(__state_ & ready) && _Clock::now() < __abs_time) | ||
| 569 | __cv_.wait_until(__lk, __abs_time); | ||
| 570 | if (__state_ & ready) | ||
| 571 | return future_status::ready; | ||
| 572 | return future_status::timeout; | ||
| 573 | } | ||
| 568 | 574 | ||
| 569 | virtual void __execute(); | 575 | virtual void __execute(); |
| 570 | }; | 576 | }; |
| 571 | 577 | ||
| 572 | template <class _Clock, class _Duration> | ||
| 573 | future_status __assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const { | ||
| 574 | unique_lock<mutex> __lk(__mut_); | ||
| 575 | if (__state_ & deferred) | ||
| 576 | return future_status::deferred; | ||
| 577 | while (!(__state_ & ready) && _Clock::now() < __abs_time) | ||
| 578 | __cv_.wait_until(__lk, __abs_time); | ||
| 579 | if (__state_ & ready) | ||
| 580 | return future_status::ready; | ||
| 581 | return future_status::timeout; | ||
| 582 | } | ||
| 583 | |||
| 584 | template <class _Rep, class _Period> | 578 | template <class _Rep, class _Period> |
| 585 | inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const { | 579 | inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const { |
| 586 | return wait_until(chrono::steady_clock::now() + __rel_time); | 580 | return wait_until(chrono::steady_clock::now() + __rel_time); |
| ... | @@ -612,7 +606,7 @@ public: | ... | @@ -612,7 +606,7 @@ public: |
| 612 | template <class _Rp> | 606 | template <class _Rp> |
| 613 | void __assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT { | 607 | void __assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT { |
| 614 | if (this->__state_ & base::__constructed) | 608 | if (this->__state_ & base::__constructed) |
| 615 | reinterpret_cast<_Rp*>(&__value_)->~_Rp(); | 609 | reinterpret_cast<_Rp*>(std::addressof(__value_))->~_Rp(); |
| 616 | delete this; | 610 | delete this; |
| 617 | } | 611 | } |
| 618 | 612 | ||
| ... | @@ -621,8 +615,8 @@ template <class _Arg> | ... | @@ -621,8 +615,8 @@ template <class _Arg> |
| 621 | void __assoc_state<_Rp>::set_value(_Arg&& __arg) { | 615 | void __assoc_state<_Rp>::set_value(_Arg&& __arg) { |
| 622 | unique_lock<mutex> __lk(this->__mut_); | 616 | unique_lock<mutex> __lk(this->__mut_); |
| 623 | if (this->__has_value()) | 617 | if (this->__has_value()) |
| 624 | __throw_future_error(future_errc::promise_already_satisfied); | 618 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 625 | ::new ((void*)&__value_) _Rp(std::forward<_Arg>(__arg)); | 619 | ::new ((void*)std::addressof(__value_)) _Rp(std::forward<_Arg>(__arg)); |
| 626 | this->__state_ |= base::__constructed | base::ready; | 620 | this->__state_ |= base::__constructed | base::ready; |
| 627 | __cv_.notify_all(); | 621 | __cv_.notify_all(); |
| 628 | } | 622 | } |
| ... | @@ -632,8 +626,8 @@ template <class _Arg> | ... | @@ -632,8 +626,8 @@ template <class _Arg> |
| 632 | void __assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg) { | 626 | void __assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg) { |
| 633 | unique_lock<mutex> __lk(this->__mut_); | 627 | unique_lock<mutex> __lk(this->__mut_); |
| 634 | if (this->__has_value()) | 628 | if (this->__has_value()) |
| 635 | __throw_future_error(future_errc::promise_already_satisfied); | 629 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 636 | ::new ((void*)&__value_) _Rp(std::forward<_Arg>(__arg)); | 630 | ::new ((void*)std::addressof(__value_)) _Rp(std::forward<_Arg>(__arg)); |
| 637 | this->__state_ |= base::__constructed; | 631 | this->__state_ |= base::__constructed; |
| 638 | __thread_local_data()->__make_ready_at_thread_exit(this); | 632 | __thread_local_data()->__make_ready_at_thread_exit(this); |
| 639 | } | 633 | } |
| ... | @@ -644,7 +638,7 @@ _Rp __assoc_state<_Rp>::move() { | ... | @@ -644,7 +638,7 @@ _Rp __assoc_state<_Rp>::move() { |
| 644 | this->__sub_wait(__lk); | 638 | this->__sub_wait(__lk); |
| 645 | if (this->__exception_ != nullptr) | 639 | if (this->__exception_ != nullptr) |
| 646 | std::rethrow_exception(this->__exception_); | 640 | std::rethrow_exception(this->__exception_); |
| 647 | return std::move(*reinterpret_cast<_Rp*>(&__value_)); | 641 | return std::move(*reinterpret_cast<_Rp*>(std::addressof(__value_))); |
| 648 | } | 642 | } |
| 649 | 643 | ||
| 650 | template <class _Rp> | 644 | template <class _Rp> |
| ... | @@ -653,7 +647,7 @@ _Rp& __assoc_state<_Rp>::copy() { | ... | @@ -653,7 +647,7 @@ _Rp& __assoc_state<_Rp>::copy() { |
| 653 | this->__sub_wait(__lk); | 647 | this->__sub_wait(__lk); |
| 654 | if (this->__exception_ != nullptr) | 648 | if (this->__exception_ != nullptr) |
| 655 | std::rethrow_exception(this->__exception_); | 649 | std::rethrow_exception(this->__exception_); |
| 656 | return *reinterpret_cast<_Rp*>(&__value_); | 650 | return *reinterpret_cast<_Rp*>(std::addressof(__value_)); |
| 657 | } | 651 | } |
| 658 | 652 | ||
| 659 | template <class _Rp> | 653 | template <class _Rp> |
| ... | @@ -682,7 +676,7 @@ template <class _Rp> | ... | @@ -682,7 +676,7 @@ template <class _Rp> |
| 682 | void __assoc_state<_Rp&>::set_value(_Rp& __arg) { | 676 | void __assoc_state<_Rp&>::set_value(_Rp& __arg) { |
| 683 | unique_lock<mutex> __lk(this->__mut_); | 677 | unique_lock<mutex> __lk(this->__mut_); |
| 684 | if (this->__has_value()) | 678 | if (this->__has_value()) |
| 685 | __throw_future_error(future_errc::promise_already_satisfied); | 679 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 686 | __value_ = std::addressof(__arg); | 680 | __value_ = std::addressof(__arg); |
| 687 | this->__state_ |= base::__constructed | base::ready; | 681 | this->__state_ |= base::__constructed | base::ready; |
| 688 | __cv_.notify_all(); | 682 | __cv_.notify_all(); |
| ... | @@ -692,7 +686,7 @@ template <class _Rp> | ... | @@ -692,7 +686,7 @@ template <class _Rp> |
| 692 | void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) { | 686 | void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) { |
| 693 | unique_lock<mutex> __lk(this->__mut_); | 687 | unique_lock<mutex> __lk(this->__mut_); |
| 694 | if (this->__has_value()) | 688 | if (this->__has_value()) |
| 695 | __throw_future_error(future_errc::promise_already_satisfied); | 689 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 696 | __value_ = std::addressof(__arg); | 690 | __value_ = std::addressof(__arg); |
| 697 | this->__state_ |= base::__constructed; | 691 | this->__state_ |= base::__constructed; |
| 698 | __thread_local_data()->__make_ready_at_thread_exit(this); | 692 | __thread_local_data()->__make_ready_at_thread_exit(this); |
| ... | @@ -907,14 +901,14 @@ void __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT { | ... | @@ -907,14 +901,14 @@ void __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT { |
| 907 | } | 901 | } |
| 908 | 902 | ||
| 909 | template <class _Rp> | 903 | template <class _Rp> |
| 910 | class _LIBCPP_TEMPLATE_VIS promise; | 904 | class promise; |
| 911 | template <class _Rp> | 905 | template <class _Rp> |
| 912 | class _LIBCPP_TEMPLATE_VIS shared_future; | 906 | class shared_future; |
| 913 | 907 | ||
| 914 | // future | 908 | // future |
| 915 | 909 | ||
| 916 | template <class _Rp> | 910 | template <class _Rp> |
| 917 | class _LIBCPP_TEMPLATE_VIS future; | 911 | class future; |
| 918 | 912 | ||
| 919 | template <class _Rp, class _Fp> | 913 | template <class _Rp, class _Fp> |
| 920 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f); | 914 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f); |
| ... | @@ -923,7 +917,7 @@ template <class _Rp, class _Fp> | ... | @@ -923,7 +917,7 @@ template <class _Rp, class _Fp> |
| 923 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f); | 917 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f); |
| 924 | 918 | ||
| 925 | template <class _Rp> | 919 | template <class _Rp> |
| 926 | class _LIBCPP_TEMPLATE_VIS future { | 920 | class future { |
| 927 | __assoc_state<_Rp>* __state_; | 921 | __assoc_state<_Rp>* __state_; |
| 928 | 922 | ||
| 929 | explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp>* __state); | 923 | explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp>* __state); |
| ... | @@ -994,7 +988,7 @@ _Rp future<_Rp>::get() { | ... | @@ -994,7 +988,7 @@ _Rp future<_Rp>::get() { |
| 994 | } | 988 | } |
| 995 | 989 | ||
| 996 | template <class _Rp> | 990 | template <class _Rp> |
| 997 | class _LIBCPP_TEMPLATE_VIS future<_Rp&> { | 991 | class future<_Rp&> { |
| 998 | __assoc_state<_Rp&>* __state_; | 992 | __assoc_state<_Rp&>* __state_; |
| 999 | 993 | ||
| 1000 | explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp&>* __state); | 994 | explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp&>* __state); |
| ... | @@ -1119,7 +1113,7 @@ template <class _Callable> | ... | @@ -1119,7 +1113,7 @@ template <class _Callable> |
| 1119 | class packaged_task; | 1113 | class packaged_task; |
| 1120 | 1114 | ||
| 1121 | template <class _Rp> | 1115 | template <class _Rp> |
| 1122 | class _LIBCPP_TEMPLATE_VIS promise { | 1116 | class promise { |
| 1123 | __assoc_state<_Rp>* __state_; | 1117 | __assoc_state<_Rp>* __state_; |
| 1124 | 1118 | ||
| 1125 | _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} | 1119 | _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} |
| ... | @@ -1185,21 +1179,21 @@ promise<_Rp>::~promise() { | ... | @@ -1185,21 +1179,21 @@ promise<_Rp>::~promise() { |
| 1185 | template <class _Rp> | 1179 | template <class _Rp> |
| 1186 | future<_Rp> promise<_Rp>::get_future() { | 1180 | future<_Rp> promise<_Rp>::get_future() { |
| 1187 | if (__state_ == nullptr) | 1181 | if (__state_ == nullptr) |
| 1188 | __throw_future_error(future_errc::no_state); | 1182 | std::__throw_future_error(future_errc::no_state); |
| 1189 | return future<_Rp>(__state_); | 1183 | return future<_Rp>(__state_); |
| 1190 | } | 1184 | } |
| 1191 | 1185 | ||
| 1192 | template <class _Rp> | 1186 | template <class _Rp> |
| 1193 | void promise<_Rp>::set_value(const _Rp& __r) { | 1187 | void promise<_Rp>::set_value(const _Rp& __r) { |
| 1194 | if (__state_ == nullptr) | 1188 | if (__state_ == nullptr) |
| 1195 | __throw_future_error(future_errc::no_state); | 1189 | std::__throw_future_error(future_errc::no_state); |
| 1196 | __state_->set_value(__r); | 1190 | __state_->set_value(__r); |
| 1197 | } | 1191 | } |
| 1198 | 1192 | ||
| 1199 | template <class _Rp> | 1193 | template <class _Rp> |
| 1200 | void promise<_Rp>::set_value(_Rp&& __r) { | 1194 | void promise<_Rp>::set_value(_Rp&& __r) { |
| 1201 | if (__state_ == nullptr) | 1195 | if (__state_ == nullptr) |
| 1202 | __throw_future_error(future_errc::no_state); | 1196 | std::__throw_future_error(future_errc::no_state); |
| 1203 | __state_->set_value(std::move(__r)); | 1197 | __state_->set_value(std::move(__r)); |
| 1204 | } | 1198 | } |
| 1205 | 1199 | ||
| ... | @@ -1207,21 +1201,21 @@ template <class _Rp> | ... | @@ -1207,21 +1201,21 @@ template <class _Rp> |
| 1207 | void promise<_Rp>::set_exception(exception_ptr __p) { | 1201 | void promise<_Rp>::set_exception(exception_ptr __p) { |
| 1208 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr"); | 1202 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr"); |
| 1209 | if (__state_ == nullptr) | 1203 | if (__state_ == nullptr) |
| 1210 | __throw_future_error(future_errc::no_state); | 1204 | std::__throw_future_error(future_errc::no_state); |
| 1211 | __state_->set_exception(__p); | 1205 | __state_->set_exception(__p); |
| 1212 | } | 1206 | } |
| 1213 | 1207 | ||
| 1214 | template <class _Rp> | 1208 | template <class _Rp> |
| 1215 | void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) { | 1209 | void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) { |
| 1216 | if (__state_ == nullptr) | 1210 | if (__state_ == nullptr) |
| 1217 | __throw_future_error(future_errc::no_state); | 1211 | std::__throw_future_error(future_errc::no_state); |
| 1218 | __state_->set_value_at_thread_exit(__r); | 1212 | __state_->set_value_at_thread_exit(__r); |
| 1219 | } | 1213 | } |
| 1220 | 1214 | ||
| 1221 | template <class _Rp> | 1215 | template <class _Rp> |
| 1222 | void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) { | 1216 | void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) { |
| 1223 | if (__state_ == nullptr) | 1217 | if (__state_ == nullptr) |
| 1224 | __throw_future_error(future_errc::no_state); | 1218 | std::__throw_future_error(future_errc::no_state); |
| 1225 | __state_->set_value_at_thread_exit(std::move(__r)); | 1219 | __state_->set_value_at_thread_exit(std::move(__r)); |
| 1226 | } | 1220 | } |
| 1227 | 1221 | ||
| ... | @@ -1229,14 +1223,14 @@ template <class _Rp> | ... | @@ -1229,14 +1223,14 @@ template <class _Rp> |
| 1229 | void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) { | 1223 | void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) { |
| 1230 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr"); | 1224 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr"); |
| 1231 | if (__state_ == nullptr) | 1225 | if (__state_ == nullptr) |
| 1232 | __throw_future_error(future_errc::no_state); | 1226 | std::__throw_future_error(future_errc::no_state); |
| 1233 | __state_->set_exception_at_thread_exit(__p); | 1227 | __state_->set_exception_at_thread_exit(__p); |
| 1234 | } | 1228 | } |
| 1235 | 1229 | ||
| 1236 | // promise<R&> | 1230 | // promise<R&> |
| 1237 | 1231 | ||
| 1238 | template <class _Rp> | 1232 | template <class _Rp> |
| 1239 | class _LIBCPP_TEMPLATE_VIS promise<_Rp&> { | 1233 | class promise<_Rp&> { |
| 1240 | __assoc_state<_Rp&>* __state_; | 1234 | __assoc_state<_Rp&>* __state_; |
| 1241 | 1235 | ||
| 1242 | _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} | 1236 | _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} |
| ... | @@ -1300,14 +1294,14 @@ promise<_Rp&>::~promise() { | ... | @@ -1300,14 +1294,14 @@ promise<_Rp&>::~promise() { |
| 1300 | template <class _Rp> | 1294 | template <class _Rp> |
| 1301 | future<_Rp&> promise<_Rp&>::get_future() { | 1295 | future<_Rp&> promise<_Rp&>::get_future() { |
| 1302 | if (__state_ == nullptr) | 1296 | if (__state_ == nullptr) |
| 1303 | __throw_future_error(future_errc::no_state); | 1297 | std::__throw_future_error(future_errc::no_state); |
| 1304 | return future<_Rp&>(__state_); | 1298 | return future<_Rp&>(__state_); |
| 1305 | } | 1299 | } |
| 1306 | 1300 | ||
| 1307 | template <class _Rp> | 1301 | template <class _Rp> |
| 1308 | void promise<_Rp&>::set_value(_Rp& __r) { | 1302 | void promise<_Rp&>::set_value(_Rp& __r) { |
| 1309 | if (__state_ == nullptr) | 1303 | if (__state_ == nullptr) |
| 1310 | __throw_future_error(future_errc::no_state); | 1304 | std::__throw_future_error(future_errc::no_state); |
| 1311 | __state_->set_value(__r); | 1305 | __state_->set_value(__r); |
| 1312 | } | 1306 | } |
| 1313 | 1307 | ||
| ... | @@ -1315,14 +1309,14 @@ template <class _Rp> | ... | @@ -1315,14 +1309,14 @@ template <class _Rp> |
| 1315 | void promise<_Rp&>::set_exception(exception_ptr __p) { | 1309 | void promise<_Rp&>::set_exception(exception_ptr __p) { |
| 1316 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr"); | 1310 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr"); |
| 1317 | if (__state_ == nullptr) | 1311 | if (__state_ == nullptr) |
| 1318 | __throw_future_error(future_errc::no_state); | 1312 | std::__throw_future_error(future_errc::no_state); |
| 1319 | __state_->set_exception(__p); | 1313 | __state_->set_exception(__p); |
| 1320 | } | 1314 | } |
| 1321 | 1315 | ||
| 1322 | template <class _Rp> | 1316 | template <class _Rp> |
| 1323 | void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) { | 1317 | void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) { |
| 1324 | if (__state_ == nullptr) | 1318 | if (__state_ == nullptr) |
| 1325 | __throw_future_error(future_errc::no_state); | 1319 | std::__throw_future_error(future_errc::no_state); |
| 1326 | __state_->set_value_at_thread_exit(__r); | 1320 | __state_->set_value_at_thread_exit(__r); |
| 1327 | } | 1321 | } |
| 1328 | 1322 | ||
| ... | @@ -1330,7 +1324,7 @@ template <class _Rp> | ... | @@ -1330,7 +1324,7 @@ template <class _Rp> |
| 1330 | void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) { | 1324 | void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) { |
| 1331 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr"); | 1325 | _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr"); |
| 1332 | if (__state_ == nullptr) | 1326 | if (__state_ == nullptr) |
| 1333 | __throw_future_error(future_errc::no_state); | 1327 | std::__throw_future_error(future_errc::no_state); |
| 1334 | __state_->set_exception_at_thread_exit(__p); | 1328 | __state_->set_exception_at_thread_exit(__p); |
| 1335 | } | 1329 | } |
| 1336 | 1330 | ||
| ... | @@ -1347,8 +1341,17 @@ class _LIBCPP_EXPORTED_FROM_ABI promise<void> { | ... | @@ -1347,8 +1341,17 @@ class _LIBCPP_EXPORTED_FROM_ABI promise<void> { |
| 1347 | 1341 | ||
| 1348 | public: | 1342 | public: |
| 1349 | promise(); | 1343 | promise(); |
| 1350 | template <class _Allocator> | 1344 | template <class _Alloc> |
| 1351 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS promise(allocator_arg_t, const _Allocator& __a); | 1345 | _LIBCPP_HIDE_FROM_ABI promise(allocator_arg_t, const _Alloc& __a0) { |
| 1346 | typedef __assoc_sub_state_alloc<_Alloc> _State; | ||
| 1347 | typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; | ||
| 1348 | typedef __allocator_destructor<_A2> _D2; | ||
| 1349 | _A2 __a(__a0); | ||
| 1350 | unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); | ||
| 1351 | ::new ((void*)std::addressof(*__hold.get())) _State(__a0); | ||
| 1352 | __state_ = std::addressof(*__hold.release()); | ||
| 1353 | } | ||
| 1354 | |||
| 1352 | _LIBCPP_HIDE_FROM_ABI promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) { __rhs.__state_ = nullptr; } | 1355 | _LIBCPP_HIDE_FROM_ABI promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) { __rhs.__state_ = nullptr; } |
| 1353 | promise(const promise& __rhs) = delete; | 1356 | promise(const promise& __rhs) = delete; |
| 1354 | ~promise(); | 1357 | ~promise(); |
| ... | @@ -1374,24 +1377,13 @@ public: | ... | @@ -1374,24 +1377,13 @@ public: |
| 1374 | void set_exception_at_thread_exit(exception_ptr __p); | 1377 | void set_exception_at_thread_exit(exception_ptr __p); |
| 1375 | }; | 1378 | }; |
| 1376 | 1379 | ||
| 1377 | template <class _Alloc> | ||
| 1378 | promise<void>::promise(allocator_arg_t, const _Alloc& __a0) { | ||
| 1379 | typedef __assoc_sub_state_alloc<_Alloc> _State; | ||
| 1380 | typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; | ||
| 1381 | typedef __allocator_destructor<_A2> _D2; | ||
| 1382 | _A2 __a(__a0); | ||
| 1383 | unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); | ||
| 1384 | ::new ((void*)std::addressof(*__hold.get())) _State(__a0); | ||
| 1385 | __state_ = std::addressof(*__hold.release()); | ||
| 1386 | } | ||
| 1387 | |||
| 1388 | template <class _Rp> | 1380 | template <class _Rp> |
| 1389 | inline _LIBCPP_HIDE_FROM_ABI void swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT { | 1381 | inline _LIBCPP_HIDE_FROM_ABI void swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT { |
| 1390 | __x.swap(__y); | 1382 | __x.swap(__y); |
| 1391 | } | 1383 | } |
| 1392 | 1384 | ||
| 1393 | template <class _Rp, class _Alloc> | 1385 | template <class _Rp, class _Alloc> |
| 1394 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc> : public true_type {}; | 1386 | struct uses_allocator<promise<_Rp>, _Alloc> : public true_type {}; |
| 1395 | 1387 | ||
| 1396 | // packaged_task | 1388 | // packaged_task |
| 1397 | 1389 | ||
| ... | @@ -1610,10 +1602,7 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... | ... | @@ -1610,10 +1602,7 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... |
| 1610 | } | 1602 | } |
| 1611 | 1603 | ||
| 1612 | template <class _Rp, class... _ArgTypes> | 1604 | template <class _Rp, class... _ArgTypes> |
| 1613 | class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)> { | 1605 | class packaged_task<_Rp(_ArgTypes...)> { |
| 1614 | public: | ||
| 1615 | using result_type _LIBCPP_DEPRECATED = _Rp; // extension | ||
| 1616 | |||
| 1617 | private: | 1606 | private: |
| 1618 | __packaged_task_function<_Rp(_ArgTypes...)> __f_; | 1607 | __packaged_task_function<_Rp(_ArgTypes...)> __f_; |
| 1619 | promise<_Rp> __p_; | 1608 | promise<_Rp> __p_; |
| ... | @@ -1665,9 +1654,9 @@ public: | ... | @@ -1665,9 +1654,9 @@ public: |
| 1665 | template <class _Rp, class... _ArgTypes> | 1654 | template <class _Rp, class... _ArgTypes> |
| 1666 | void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { | 1655 | void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1667 | if (__p_.__state_ == nullptr) | 1656 | if (__p_.__state_ == nullptr) |
| 1668 | __throw_future_error(future_errc::no_state); | 1657 | std::__throw_future_error(future_errc::no_state); |
| 1669 | if (__p_.__state_->__has_value()) | 1658 | if (__p_.__state_->__has_value()) |
| 1670 | __throw_future_error(future_errc::promise_already_satisfied); | 1659 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 1671 | # if _LIBCPP_HAS_EXCEPTIONS | 1660 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1672 | try { | 1661 | try { |
| 1673 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1662 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -1682,9 +1671,9 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { | ... | @@ -1682,9 +1671,9 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1682 | template <class _Rp, class... _ArgTypes> | 1671 | template <class _Rp, class... _ArgTypes> |
| 1683 | void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { | 1672 | void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { |
| 1684 | if (__p_.__state_ == nullptr) | 1673 | if (__p_.__state_ == nullptr) |
| 1685 | __throw_future_error(future_errc::no_state); | 1674 | std::__throw_future_error(future_errc::no_state); |
| 1686 | if (__p_.__state_->__has_value()) | 1675 | if (__p_.__state_->__has_value()) |
| 1687 | __throw_future_error(future_errc::promise_already_satisfied); | 1676 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 1688 | # if _LIBCPP_HAS_EXCEPTIONS | 1677 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1689 | try { | 1678 | try { |
| 1690 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1679 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -1699,15 +1688,12 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ | ... | @@ -1699,15 +1688,12 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ |
| 1699 | template <class _Rp, class... _ArgTypes> | 1688 | template <class _Rp, class... _ArgTypes> |
| 1700 | void packaged_task<_Rp(_ArgTypes...)>::reset() { | 1689 | void packaged_task<_Rp(_ArgTypes...)>::reset() { |
| 1701 | if (!valid()) | 1690 | if (!valid()) |
| 1702 | __throw_future_error(future_errc::no_state); | 1691 | std::__throw_future_error(future_errc::no_state); |
| 1703 | __p_ = promise<_Rp>(); | 1692 | __p_ = promise<_Rp>(); |
| 1704 | } | 1693 | } |
| 1705 | 1694 | ||
| 1706 | template <class... _ArgTypes> | 1695 | template <class... _ArgTypes> |
| 1707 | class _LIBCPP_TEMPLATE_VIS packaged_task<void(_ArgTypes...)> { | 1696 | class packaged_task<void(_ArgTypes...)> { |
| 1708 | public: | ||
| 1709 | using result_type _LIBCPP_DEPRECATED = void; // extension | ||
| 1710 | |||
| 1711 | private: | 1697 | private: |
| 1712 | __packaged_task_function<void(_ArgTypes...)> __f_; | 1698 | __packaged_task_function<void(_ArgTypes...)> __f_; |
| 1713 | promise<void> __p_; | 1699 | promise<void> __p_; |
| ... | @@ -1767,9 +1753,9 @@ packaged_task(_Fp) -> packaged_task<_Stripped>; | ... | @@ -1767,9 +1753,9 @@ packaged_task(_Fp) -> packaged_task<_Stripped>; |
| 1767 | template <class... _ArgTypes> | 1753 | template <class... _ArgTypes> |
| 1768 | void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { | 1754 | void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1769 | if (__p_.__state_ == nullptr) | 1755 | if (__p_.__state_ == nullptr) |
| 1770 | __throw_future_error(future_errc::no_state); | 1756 | std::__throw_future_error(future_errc::no_state); |
| 1771 | if (__p_.__state_->__has_value()) | 1757 | if (__p_.__state_->__has_value()) |
| 1772 | __throw_future_error(future_errc::promise_already_satisfied); | 1758 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 1773 | # if _LIBCPP_HAS_EXCEPTIONS | 1759 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1774 | try { | 1760 | try { |
| 1775 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1761 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -1785,9 +1771,9 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { | ... | @@ -1785,9 +1771,9 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1785 | template <class... _ArgTypes> | 1771 | template <class... _ArgTypes> |
| 1786 | void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { | 1772 | void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { |
| 1787 | if (__p_.__state_ == nullptr) | 1773 | if (__p_.__state_ == nullptr) |
| 1788 | __throw_future_error(future_errc::no_state); | 1774 | std::__throw_future_error(future_errc::no_state); |
| 1789 | if (__p_.__state_->__has_value()) | 1775 | if (__p_.__state_->__has_value()) |
| 1790 | __throw_future_error(future_errc::promise_already_satisfied); | 1776 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 1791 | # if _LIBCPP_HAS_EXCEPTIONS | 1777 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1792 | try { | 1778 | try { |
| 1793 | # endif // _LIBCPP_HAS_EXCEPTIONS | 1779 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| ... | @@ -1803,7 +1789,7 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _ | ... | @@ -1803,7 +1789,7 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _ |
| 1803 | template <class... _ArgTypes> | 1789 | template <class... _ArgTypes> |
| 1804 | void packaged_task<void(_ArgTypes...)>::reset() { | 1790 | void packaged_task<void(_ArgTypes...)>::reset() { |
| 1805 | if (!valid()) | 1791 | if (!valid()) |
| 1806 | __throw_future_error(future_errc::no_state); | 1792 | std::__throw_future_error(future_errc::no_state); |
| 1807 | __p_ = promise<void>(); | 1793 | __p_ = promise<void>(); |
| 1808 | } | 1794 | } |
| 1809 | 1795 | ||
| ... | @@ -1815,7 +1801,7 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __ | ... | @@ -1815,7 +1801,7 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __ |
| 1815 | 1801 | ||
| 1816 | # if _LIBCPP_STD_VER <= 14 | 1802 | # if _LIBCPP_STD_VER <= 14 |
| 1817 | template <class _Callable, class _Alloc> | 1803 | template <class _Callable, class _Alloc> |
| 1818 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {}; | 1804 | struct uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {}; |
| 1819 | # endif | 1805 | # endif |
| 1820 | 1806 | ||
| 1821 | template <class _Rp, class _Fp> | 1807 | template <class _Rp, class _Fp> |
| ... | @@ -1829,7 +1815,16 @@ template <class _Rp, class _Fp> | ... | @@ -1829,7 +1815,16 @@ template <class _Rp, class _Fp> |
| 1829 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { | 1815 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { |
| 1830 | unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h( | 1816 | unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h( |
| 1831 | new __async_assoc_state<_Rp, _Fp>(std::forward<_Fp>(__f))); | 1817 | new __async_assoc_state<_Rp, _Fp>(std::forward<_Fp>(__f))); |
| 1832 | std::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach(); | 1818 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1819 | try { | ||
| 1820 | # endif | ||
| 1821 | std::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach(); | ||
| 1822 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1823 | } catch (...) { | ||
| 1824 | __h->__make_ready(); | ||
| 1825 | throw; | ||
| 1826 | } | ||
| 1827 | # endif | ||
| 1833 | return future<_Rp>(__h.get()); | 1828 | return future<_Rp>(__h.get()); |
| 1834 | } | 1829 | } |
| 1835 | 1830 | ||
| ... | @@ -1899,7 +1894,7 @@ async(_Fp&& __f, _Args&&... __args) { | ... | @@ -1899,7 +1894,7 @@ async(_Fp&& __f, _Args&&... __args) { |
| 1899 | // shared_future | 1894 | // shared_future |
| 1900 | 1895 | ||
| 1901 | template <class _Rp> | 1896 | template <class _Rp> |
| 1902 | class _LIBCPP_TEMPLATE_VIS shared_future { | 1897 | class shared_future { |
| 1903 | __assoc_state<_Rp>* __state_; | 1898 | __assoc_state<_Rp>* __state_; |
| 1904 | 1899 | ||
| 1905 | public: | 1900 | public: |
| ... | @@ -1955,7 +1950,7 @@ shared_future<_Rp>& shared_future<_Rp>::operator=(const shared_future& __rhs) _N | ... | @@ -1955,7 +1950,7 @@ shared_future<_Rp>& shared_future<_Rp>::operator=(const shared_future& __rhs) _N |
| 1955 | } | 1950 | } |
| 1956 | 1951 | ||
| 1957 | template <class _Rp> | 1952 | template <class _Rp> |
| 1958 | class _LIBCPP_TEMPLATE_VIS shared_future<_Rp&> { | 1953 | class shared_future<_Rp&> { |
| 1959 | __assoc_state<_Rp&>* __state_; | 1954 | __assoc_state<_Rp&>* __state_; |
| 1960 | 1955 | ||
| 1961 | public: | 1956 | public: |
lib/libcxx/include/initializer_list+2-2| ... | @@ -43,7 +43,7 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in | ... | @@ -43,7 +43,7 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in |
| 43 | */ | 43 | */ |
| 44 | 44 | ||
| 45 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 45 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 46 | # include <__cxx03/initializer_list> | 46 | # include <__cxx03/__config> |
| 47 | #else | 47 | #else |
| 48 | # include <__config> | 48 | # include <__config> |
| 49 | # include <__cstddef/size_t.h> | 49 | # include <__cstddef/size_t.h> |
| ... | @@ -59,7 +59,7 @@ namespace std // purposefully not versioned | ... | @@ -59,7 +59,7 @@ namespace std // purposefully not versioned |
| 59 | # ifndef _LIBCPP_CXX03_LANG | 59 | # ifndef _LIBCPP_CXX03_LANG |
| 60 | 60 | ||
| 61 | template <class _Ep> | 61 | template <class _Ep> |
| 62 | class _LIBCPP_TEMPLATE_VIS initializer_list { | 62 | class _LIBCPP_NO_SPECIALIZATIONS initializer_list { |
| 63 | const _Ep* __begin_; | 63 | const _Ep* __begin_; |
| 64 | size_t __size_; | 64 | size_t __size_; |
| 65 | 65 |
lib/libcxx/include/iomanip+8-1| ... | @@ -49,10 +49,12 @@ template <class charT, class traits, class Allocator> | ... | @@ -49,10 +49,12 @@ template <class charT, class traits, class Allocator> |
| 49 | 49 | ||
| 50 | # if _LIBCPP_HAS_LOCALIZATION | 50 | # if _LIBCPP_HAS_LOCALIZATION |
| 51 | 51 | ||
| 52 | # include <__iterator/istreambuf_iterator.h> | ||
| 53 | # include <__locale_dir/money.h> | ||
| 54 | # include <__locale_dir/time.h> | ||
| 52 | # include <__ostream/put_character_sequence.h> | 55 | # include <__ostream/put_character_sequence.h> |
| 53 | # include <ios> | 56 | # include <ios> |
| 54 | # include <iosfwd> | 57 | # include <iosfwd> |
| 55 | # include <locale> | ||
| 56 | # include <version> | 58 | # include <version> |
| 57 | 59 | ||
| 58 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 60 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -564,6 +566,11 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -564,6 +566,11 @@ _LIBCPP_END_NAMESPACE_STD |
| 564 | # include <unordered_map> | 566 | # include <unordered_map> |
| 565 | # include <vector> | 567 | # include <vector> |
| 566 | # endif | 568 | # endif |
| 569 | |||
| 570 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | ||
| 571 | # include <locale> | ||
| 572 | # endif | ||
| 573 | |||
| 567 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 574 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 568 | 575 | ||
| 569 | #endif // _LIBCPP_IOMANIP | 576 | #endif // _LIBCPP_IOMANIP |
lib/libcxx/include/ios+9-8| ... | @@ -216,6 +216,11 @@ storage-class-specifier const error_category& iostream_category() noexcept; | ... | @@ -216,6 +216,11 @@ storage-class-specifier const error_category& iostream_category() noexcept; |
| 216 | #else | 216 | #else |
| 217 | # include <__config> | 217 | # include <__config> |
| 218 | 218 | ||
| 219 | // standard-mandated includes | ||
| 220 | |||
| 221 | // [ios.syn] | ||
| 222 | # include <iosfwd> | ||
| 223 | |||
| 219 | # if _LIBCPP_HAS_LOCALIZATION | 224 | # if _LIBCPP_HAS_LOCALIZATION |
| 220 | 225 | ||
| 221 | # include <__fwd/ios.h> | 226 | # include <__fwd/ios.h> |
| ... | @@ -230,11 +235,6 @@ storage-class-specifier const error_category& iostream_category() noexcept; | ... | @@ -230,11 +235,6 @@ storage-class-specifier const error_category& iostream_category() noexcept; |
| 230 | # include <__verbose_abort> | 235 | # include <__verbose_abort> |
| 231 | # include <version> | 236 | # include <version> |
| 232 | 237 | ||
| 233 | // standard-mandated includes | ||
| 234 | |||
| 235 | // [ios.syn] | ||
| 236 | # include <iosfwd> | ||
| 237 | |||
| 238 | # if _LIBCPP_HAS_ATOMIC_HEADER | 238 | # if _LIBCPP_HAS_ATOMIC_HEADER |
| 239 | # include <__atomic/atomic.h> // for __xindex_ | 239 | # include <__atomic/atomic.h> // for __xindex_ |
| 240 | # endif | 240 | # endif |
| ... | @@ -418,11 +418,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc){stream = 1}; | ... | @@ -418,11 +418,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc){stream = 1}; |
| 418 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) | 418 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) |
| 419 | 419 | ||
| 420 | template <> | 420 | template <> |
| 421 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {}; | 421 | struct is_error_code_enum<io_errc> : public true_type {}; |
| 422 | 422 | ||
| 423 | # ifdef _LIBCPP_CXX03_LANG | 423 | # ifdef _LIBCPP_CXX03_LANG |
| 424 | template <> | 424 | template <> |
| 425 | struct _LIBCPP_TEMPLATE_VIS 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 | _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; |
| ... | @@ -559,7 +559,7 @@ private: | ... | @@ -559,7 +559,7 @@ private: |
| 559 | }; | 559 | }; |
| 560 | 560 | ||
| 561 | template <class _CharT, class _Traits> | 561 | template <class _CharT, class _Traits> |
| 562 | class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base { | 562 | class basic_ios : public ios_base { |
| 563 | public: | 563 | public: |
| 564 | // types: | 564 | // types: |
| 565 | typedef _CharT char_type; | 565 | typedef _CharT char_type; |
| ... | @@ -887,6 +887,7 @@ _LIBCPP_POP_MACROS | ... | @@ -887,6 +887,7 @@ _LIBCPP_POP_MACROS |
| 887 | # include <limits> | 887 | # include <limits> |
| 888 | # include <mutex> | 888 | # include <mutex> |
| 889 | # include <new> | 889 | # include <new> |
| 890 | # include <optional> | ||
| 890 | # include <stdexcept> | 891 | # include <stdexcept> |
| 891 | # include <system_error> | 892 | # include <system_error> |
| 892 | # include <type_traits> | 893 | # include <type_traits> |
lib/libcxx/include/iosfwd+3-3| ... | @@ -127,12 +127,12 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 | ... | @@ -127,12 +127,12 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 |
| 127 | _LIBCPP_BEGIN_NAMESPACE_STD | 127 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 128 | 128 | ||
| 129 | template <class _CharT, class _Traits = char_traits<_CharT> > | 129 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 130 | class _LIBCPP_TEMPLATE_VIS istreambuf_iterator; | 130 | class istreambuf_iterator; |
| 131 | template <class _CharT, class _Traits = char_traits<_CharT> > | 131 | template <class _CharT, class _Traits = char_traits<_CharT> > |
| 132 | class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator; | 132 | class ostreambuf_iterator; |
| 133 | 133 | ||
| 134 | template <class _State> | 134 | template <class _State> |
| 135 | class _LIBCPP_TEMPLATE_VIS fpos; | 135 | class fpos; |
| 136 | typedef fpos<mbstate_t> streampos; | 136 | typedef fpos<mbstate_t> streampos; |
| 137 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 137 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 138 | typedef fpos<mbstate_t> wstreampos; | 138 | typedef fpos<mbstate_t> wstreampos; |
lib/libcxx/include/istream+65-33| ... | @@ -167,6 +167,7 @@ template <class Stream, class T> | ... | @@ -167,6 +167,7 @@ template <class Stream, class T> |
| 167 | 167 | ||
| 168 | # include <__fwd/istream.h> | 168 | # include <__fwd/istream.h> |
| 169 | # include <__iterator/istreambuf_iterator.h> | 169 | # include <__iterator/istreambuf_iterator.h> |
| 170 | # include <__locale_dir/num.h> | ||
| 170 | # include <__ostream/basic_ostream.h> | 171 | # include <__ostream/basic_ostream.h> |
| 171 | # include <__type_traits/conjunction.h> | 172 | # include <__type_traits/conjunction.h> |
| 172 | # include <__type_traits/enable_if.h> | 173 | # include <__type_traits/enable_if.h> |
| ... | @@ -176,7 +177,7 @@ template <class Stream, class T> | ... | @@ -176,7 +177,7 @@ template <class Stream, class T> |
| 176 | # include <__utility/forward.h> | 177 | # include <__utility/forward.h> |
| 177 | # include <bitset> | 178 | # include <bitset> |
| 178 | # include <ios> | 179 | # include <ios> |
| 179 | # include <locale> | 180 | # include <streambuf> |
| 180 | # include <version> | 181 | # include <version> |
| 181 | 182 | ||
| 182 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 183 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -189,7 +190,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -189,7 +190,7 @@ _LIBCPP_PUSH_MACROS |
| 189 | _LIBCPP_BEGIN_NAMESPACE_STD | 190 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 190 | 191 | ||
| 191 | template <class _CharT, class _Traits> | 192 | template <class _CharT, class _Traits> |
| 192 | class _LIBCPP_TEMPLATE_VIS basic_istream : virtual public basic_ios<_CharT, _Traits> { | 193 | class basic_istream : virtual public basic_ios<_CharT, _Traits> { |
| 193 | streamsize __gc_; | 194 | streamsize __gc_; |
| 194 | 195 | ||
| 195 | _LIBCPP_HIDE_FROM_ABI void __inc_gcount() { | 196 | _LIBCPP_HIDE_FROM_ABI void __inc_gcount() { |
| ... | @@ -228,7 +229,7 @@ public: | ... | @@ -228,7 +229,7 @@ public: |
| 228 | basic_istream& operator=(const basic_istream& __rhs) = delete; | 229 | basic_istream& operator=(const basic_istream& __rhs) = delete; |
| 229 | 230 | ||
| 230 | // 27.7.1.1.3 Prefix/suffix: | 231 | // 27.7.1.1.3 Prefix/suffix: |
| 231 | class _LIBCPP_TEMPLATE_VIS sentry; | 232 | class sentry; |
| 232 | 233 | ||
| 233 | // 27.7.1.2 Formatted input: | 234 | // 27.7.1.2 Formatted input: |
| 234 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)) { | 235 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)) { |
| ... | @@ -305,7 +306,7 @@ public: | ... | @@ -305,7 +306,7 @@ public: |
| 305 | }; | 306 | }; |
| 306 | 307 | ||
| 307 | template <class _CharT, class _Traits> | 308 | template <class _CharT, class _Traits> |
| 308 | class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry { | 309 | class basic_istream<_CharT, _Traits>::sentry { |
| 309 | bool __ok_; | 310 | bool __ok_; |
| 310 | 311 | ||
| 311 | public: | 312 | public: |
| ... | @@ -1167,9 +1168,7 @@ _LIBCPP_HIDE_FROM_ABI _Stream&& operator>>(_Stream&& __is, _Tp&& __x) { | ... | @@ -1167,9 +1168,7 @@ _LIBCPP_HIDE_FROM_ABI _Stream&& operator>>(_Stream&& __is, _Tp&& __x) { |
| 1167 | } | 1168 | } |
| 1168 | 1169 | ||
| 1169 | template <class _CharT, class _Traits> | 1170 | template <class _CharT, class _Traits> |
| 1170 | class _LIBCPP_TEMPLATE_VIS basic_iostream | 1171 | class basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { |
| 1171 | : public basic_istream<_CharT, _Traits>, | ||
| 1172 | public basic_ostream<_CharT, _Traits> { | ||
| 1173 | public: | 1172 | public: |
| 1174 | // types: | 1173 | // types: |
| 1175 | typedef _CharT char_type; | 1174 | typedef _CharT char_type; |
| ... | @@ -1265,41 +1264,70 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& | ... | @@ -1265,41 +1264,70 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| 1265 | getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) { | 1264 | getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) { |
| 1266 | ios_base::iostate __state = ios_base::goodbit; | 1265 | ios_base::iostate __state = ios_base::goodbit; |
| 1267 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); | 1266 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); |
| 1268 | if (__sen) { | 1267 | if (!__sen) |
| 1268 | return __is; | ||
| 1269 | # if _LIBCPP_HAS_EXCEPTIONS | 1269 | # if _LIBCPP_HAS_EXCEPTIONS |
| 1270 | try { | 1270 | try { |
| 1271 | # endif | 1271 | # endif |
| 1272 | __str.clear(); | 1272 | __str.clear(); |
| 1273 | streamsize __extr = 0; | 1273 | |
| 1274 | while (true) { | 1274 | auto& __buffer = *__is.rdbuf(); |
| 1275 | typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); | 1275 | |
| 1276 | if (_Traits::eq_int_type(__i, _Traits::eof())) { | 1276 | auto __next = __buffer.sgetc(); |
| 1277 | __state |= ios_base::eofbit; | 1277 | for (; !_Traits::eq_int_type(__next, _Traits::eof()); __next = __buffer.sgetc()) { |
| 1278 | break; | 1278 | const auto* __first = __buffer.gptr(); |
| 1279 | const auto* __last = __buffer.egptr(); | ||
| 1280 | _CharT __1buf; | ||
| 1281 | |||
| 1282 | if (__first == __last) { | ||
| 1283 | __1buf = __next; | ||
| 1284 | __first = std::addressof(__1buf); | ||
| 1285 | __last = std::addressof(__1buf) + 1; | ||
| 1286 | } | ||
| 1287 | |||
| 1288 | auto __bump_stream = [&](ptrdiff_t __diff) { | ||
| 1289 | if (__first == std::addressof(__1buf)) { | ||
| 1290 | _LIBCPP_ASSERT_INTERNAL(__diff == 0 || __diff == 1, "trying to bump stream further than buffer size"); | ||
| 1291 | if (__diff != 0) | ||
| 1292 | __buffer.sbumpc(); | ||
| 1293 | } else { | ||
| 1294 | __buffer.__gbump_ptrdiff(__diff); | ||
| 1279 | } | 1295 | } |
| 1280 | ++__extr; | 1296 | }; |
| 1281 | _CharT __ch = _Traits::to_char_type(__i); | 1297 | |
| 1282 | if (_Traits::eq(__ch, __dlm)) | 1298 | const auto* const __match = _Traits::find(__first, __last - __first, __dlm); |
| 1283 | break; | 1299 | if (__match) |
| 1284 | __str.push_back(__ch); | 1300 | __last = __match; |
| 1285 | if (__str.size() == __str.max_size()) { | 1301 | |
| 1286 | __state |= ios_base::failbit; | 1302 | if (auto __cap = __str.max_size() - __str.size(); __cap > static_cast<size_t>(__last - __first)) { |
| 1303 | __str.append(__first, __last); | ||
| 1304 | __bump_stream(__last - __first); | ||
| 1305 | |||
| 1306 | if (__match) { | ||
| 1307 | __bump_stream(1); // Remove the matched character | ||
| 1287 | break; | 1308 | break; |
| 1288 | } | 1309 | } |
| 1289 | } | 1310 | } else { |
| 1290 | if (__extr == 0) | 1311 | __str.append(__first, __cap); |
| 1312 | __bump_stream(__cap); | ||
| 1291 | __state |= ios_base::failbit; | 1313 | __state |= ios_base::failbit; |
| 1292 | # if _LIBCPP_HAS_EXCEPTIONS | 1314 | break; |
| 1293 | } catch (...) { | ||
| 1294 | __state |= ios_base::badbit; | ||
| 1295 | __is.__setstate_nothrow(__state); | ||
| 1296 | if (__is.exceptions() & ios_base::badbit) { | ||
| 1297 | throw; | ||
| 1298 | } | 1315 | } |
| 1299 | } | 1316 | } |
| 1300 | # endif | 1317 | |
| 1301 | __is.setstate(__state); | 1318 | if (_Traits::eq_int_type(__next, _Traits::eof())) |
| 1319 | __state |= ios_base::eofbit | (__str.empty() ? ios_base::failbit : ios_base::goodbit); | ||
| 1320 | |||
| 1321 | # if _LIBCPP_HAS_EXCEPTIONS | ||
| 1322 | } catch (...) { | ||
| 1323 | __state |= ios_base::badbit; | ||
| 1324 | __is.__setstate_nothrow(__state); | ||
| 1325 | if (__is.exceptions() & ios_base::badbit) { | ||
| 1326 | throw; | ||
| 1327 | } | ||
| 1302 | } | 1328 | } |
| 1329 | # endif | ||
| 1330 | __is.setstate(__state); | ||
| 1303 | return __is; | 1331 | return __is; |
| 1304 | } | 1332 | } |
| 1305 | 1333 | ||
| ... | @@ -1384,6 +1412,10 @@ _LIBCPP_POP_MACROS | ... | @@ -1384,6 +1412,10 @@ _LIBCPP_POP_MACROS |
| 1384 | # include <type_traits> | 1412 | # include <type_traits> |
| 1385 | # endif | 1413 | # endif |
| 1386 | 1414 | ||
| 1415 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | ||
| 1416 | # include <locale> | ||
| 1417 | # endif | ||
| 1418 | |||
| 1387 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 1419 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 1388 | 1420 | ||
| 1389 | #endif // _LIBCPP_ISTREAM | 1421 | #endif // _LIBCPP_ISTREAM |
lib/libcxx/include/iterator+1-1| ... | @@ -530,7 +530,7 @@ public: | ... | @@ -530,7 +530,7 @@ public: |
| 530 | istream_iterator(); // constexpr since C++11 | 530 | istream_iterator(); // constexpr since C++11 |
| 531 | constexpr istream_iterator(default_sentinel_t); // since C++20 | 531 | constexpr istream_iterator(default_sentinel_t); // since C++20 |
| 532 | istream_iterator(istream_type& s); | 532 | istream_iterator(istream_type& s); |
| 533 | istream_iterator(const istream_iterator& x); | 533 | constexpr istream_iterator(const istream_iterator& x) noexcept(see below); |
| 534 | ~istream_iterator(); | 534 | ~istream_iterator(); |
| 535 | 535 | ||
| 536 | const T& operator*() const; | 536 | const T& operator*() const; |
lib/libcxx/include/latch+1-1| ... | @@ -41,7 +41,7 @@ namespace std | ... | @@ -41,7 +41,7 @@ namespace std |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 43 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 44 | # include <__cxx03/latch> | 44 | # include <__cxx03/__config> |
| 45 | #else | 45 | #else |
| 46 | # include <__config> | 46 | # include <__config> |
| 47 | 47 |
lib/libcxx/include/limits+7-20| ... | @@ -108,7 +108,6 @@ template<> class numeric_limits<cv long double>; | ... | @@ -108,7 +108,6 @@ template<> class numeric_limits<cv long double>; |
| 108 | # include <__config> | 108 | # include <__config> |
| 109 | # include <__type_traits/is_arithmetic.h> | 109 | # include <__type_traits/is_arithmetic.h> |
| 110 | # include <__type_traits/is_signed.h> | 110 | # include <__type_traits/is_signed.h> |
| 111 | # include <__type_traits/remove_cv.h> | ||
| 112 | 111 | ||
| 113 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 112 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 114 | # pragma GCC system_header | 113 | # pragma GCC system_header |
| ... | @@ -178,16 +177,6 @@ protected: | ... | @@ -178,16 +177,6 @@ protected: |
| 178 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero; | 177 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero; |
| 179 | }; | 178 | }; |
| 180 | 179 | ||
| 181 | template <class _Tp, int __digits, bool _IsSigned> | ||
| 182 | struct __libcpp_compute_min { | ||
| 183 | static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits); | ||
| 184 | }; | ||
| 185 | |||
| 186 | template <class _Tp, int __digits> | ||
| 187 | struct __libcpp_compute_min<_Tp, __digits, false> { | ||
| 188 | static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0); | ||
| 189 | }; | ||
| 190 | |||
| 191 | template <class _Tp> | 180 | template <class _Tp> |
| 192 | class __libcpp_numeric_limits<_Tp, true> { | 181 | class __libcpp_numeric_limits<_Tp, true> { |
| 193 | protected: | 182 | protected: |
| ... | @@ -199,7 +188,7 @@ protected: | ... | @@ -199,7 +188,7 @@ protected: |
| 199 | static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed); | 188 | static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed); |
| 200 | static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10; | 189 | static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10; |
| 201 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; | 190 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; |
| 202 | static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value; | 191 | static _LIBCPP_CONSTEXPR const type __min = is_signed ? _Tp(_Tp(1) << digits) : 0; |
| 203 | static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0); | 192 | static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0); |
| 204 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | 193 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } |
| 205 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | 194 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } |
| ... | @@ -250,10 +239,8 @@ protected: | ... | @@ -250,10 +239,8 @@ protected: |
| 250 | static _LIBCPP_CONSTEXPR const int digits = 1; | 239 | static _LIBCPP_CONSTEXPR const int digits = 1; |
| 251 | static _LIBCPP_CONSTEXPR const int digits10 = 0; | 240 | static _LIBCPP_CONSTEXPR const int digits10 = 0; |
| 252 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; | 241 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; |
| 253 | static _LIBCPP_CONSTEXPR const type __min = false; | 242 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return false; } |
| 254 | static _LIBCPP_CONSTEXPR const type __max = true; | 243 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return true; } |
| 255 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | ||
| 256 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | ||
| 257 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } | 244 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } |
| 258 | 245 | ||
| 259 | static _LIBCPP_CONSTEXPR const bool is_integer = true; | 246 | static _LIBCPP_CONSTEXPR const bool is_integer = true; |
| ... | @@ -462,7 +449,7 @@ protected: | ... | @@ -462,7 +449,7 @@ protected: |
| 462 | }; | 449 | }; |
| 463 | 450 | ||
| 464 | template <class _Tp> | 451 | template <class _Tp> |
| 465 | class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> { | 452 | class numeric_limits : private __libcpp_numeric_limits<_Tp> { |
| 466 | typedef __libcpp_numeric_limits<_Tp> __base; | 453 | typedef __libcpp_numeric_limits<_Tp> __base; |
| 467 | typedef typename __base::type type; | 454 | typedef typename __base::type type; |
| 468 | 455 | ||
| ... | @@ -521,13 +508,13 @@ public: | ... | @@ -521,13 +508,13 @@ public: |
| 521 | }; | 508 | }; |
| 522 | 509 | ||
| 523 | template <class _Tp> | 510 | template <class _Tp> |
| 524 | class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {}; | 511 | class numeric_limits<const _Tp> : public numeric_limits<_Tp> {}; |
| 525 | 512 | ||
| 526 | template <class _Tp> | 513 | template <class _Tp> |
| 527 | class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {}; | 514 | class numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {}; |
| 528 | 515 | ||
| 529 | template <class _Tp> | 516 | template <class _Tp> |
| 530 | class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {}; | 517 | class numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {}; |
| 531 | 518 | ||
| 532 | _LIBCPP_END_NAMESPACE_STD | 519 | _LIBCPP_END_NAMESPACE_STD |
| 533 | 520 |
lib/libcxx/include/list+343-247| ... | @@ -60,9 +60,9 @@ public: | ... | @@ -60,9 +60,9 @@ public: |
| 60 | 60 | ||
| 61 | list& operator=(const list& x); | 61 | list& operator=(const list& x); |
| 62 | list& operator=(list&& x) | 62 | list& operator=(list&& x) |
| 63 | noexcept( | 63 | noexcept((__node_alloc_traits::propagate_on_container_move_assignment::value && |
| 64 | allocator_type::propagate_on_container_move_assignment::value && | 64 | is_nothrow_move_assignable<__node_allocator>::value) || |
| 65 | is_nothrow_move_assignable<allocator_type>::value); | 65 | allocator_traits<allocator_type>::is_always_equal::value); |
| 66 | list& operator=(initializer_list<value_type>); | 66 | list& operator=(initializer_list<value_type>); |
| 67 | template <class Iter> | 67 | template <class Iter> |
| 68 | void assign(Iter first, Iter last); | 68 | void assign(Iter first, Iter last); |
| ... | @@ -286,12 +286,6 @@ struct __list_node_pointer_traits { | ... | @@ -286,12 +286,6 @@ struct __list_node_pointer_traits { |
| 286 | "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the " | 286 | "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the " |
| 287 | "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); | 287 | "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); |
| 288 | # endif | 288 | # endif |
| 289 | |||
| 290 | static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; } | ||
| 291 | |||
| 292 | static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) { | ||
| 293 | return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p)); | ||
| 294 | } | ||
| 295 | }; | 289 | }; |
| 296 | 290 | ||
| 297 | template <class _Tp, class _VoidPtr> | 291 | template <class _Tp, class _VoidPtr> |
| ... | @@ -303,14 +297,20 @@ struct __list_node_base { | ... | @@ -303,14 +297,20 @@ struct __list_node_base { |
| 303 | __base_pointer __prev_; | 297 | __base_pointer __prev_; |
| 304 | __base_pointer __next_; | 298 | __base_pointer __next_; |
| 305 | 299 | ||
| 306 | _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {} | 300 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {} |
| 307 | 301 | ||
| 302 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 308 | _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next) | 303 | _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next) |
| 309 | : __prev_(__prev), __next_(__next) {} | 304 | : __prev_(__prev), __next_(__next) {} |
| 310 | 305 | ||
| 311 | _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); } | 306 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { |
| 307 | return pointer_traits<__base_pointer>::pointer_to(*this); | ||
| 308 | } | ||
| 312 | 309 | ||
| 313 | _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() { return static_cast<__node_pointer>(__self()); } | 310 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() { |
| 311 | return pointer_traits<__node_pointer>::pointer_to( | ||
| 312 | *static_cast<typename pointer_traits<__node_pointer>::element_type*>(this)); | ||
| 313 | } | ||
| 314 | }; | 314 | }; |
| 315 | 315 | ||
| 316 | template <class _Tp, class _VoidPtr> | 316 | template <class _Tp, class _VoidPtr> |
| ... | @@ -325,7 +325,7 @@ private: | ... | @@ -325,7 +325,7 @@ private: |
| 325 | }; | 325 | }; |
| 326 | 326 | ||
| 327 | public: | 327 | public: |
| 328 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } | 328 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } |
| 329 | # else | 329 | # else |
| 330 | 330 | ||
| 331 | private: | 331 | private: |
| ... | @@ -338,27 +338,32 @@ public: | ... | @@ -338,27 +338,32 @@ public: |
| 338 | typedef __list_node_base<_Tp, _VoidPtr> __base; | 338 | typedef __list_node_base<_Tp, _VoidPtr> __base; |
| 339 | typedef typename __base::__base_pointer __base_pointer; | 339 | typedef typename __base::__base_pointer __base_pointer; |
| 340 | 340 | ||
| 341 | _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) : __base(__prev, __next) {} | 341 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) |
| 342 | _LIBCPP_HIDE_FROM_ABI ~__list_node() {} | 342 | : __base(__prev, __next) {} |
| 343 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__list_node() {} | ||
| 343 | 344 | ||
| 344 | _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { return __base::__self(); } | 345 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { |
| 346 | return pointer_traits<__base_pointer>::pointer_to( | ||
| 347 | *static_cast<typename pointer_traits<__base_pointer>::element_type*>(std::addressof(*this))); | ||
| 348 | } | ||
| 345 | }; | 349 | }; |
| 346 | 350 | ||
| 347 | template <class _Tp, class _Alloc = allocator<_Tp> > | 351 | template <class _Tp, class _Alloc = allocator<_Tp> > |
| 348 | class _LIBCPP_TEMPLATE_VIS list; | 352 | class list; |
| 349 | template <class _Tp, class _Alloc> | 353 | template <class _Tp, class _Alloc> |
| 350 | class __list_imp; | 354 | class __list_imp; |
| 351 | template <class _Tp, class _VoidPtr> | 355 | template <class _Tp, class _VoidPtr> |
| 352 | class _LIBCPP_TEMPLATE_VIS __list_const_iterator; | 356 | class __list_const_iterator; |
| 353 | 357 | ||
| 354 | template <class _Tp, class _VoidPtr> | 358 | template <class _Tp, class _VoidPtr> |
| 355 | class _LIBCPP_TEMPLATE_VIS __list_iterator { | 359 | class __list_iterator { |
| 356 | typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; | 360 | typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; |
| 357 | typedef typename _NodeTraits::__base_pointer __base_pointer; | 361 | typedef typename _NodeTraits::__base_pointer __base_pointer; |
| 358 | 362 | ||
| 359 | __base_pointer __ptr_; | 363 | __base_pointer __ptr_; |
| 360 | 364 | ||
| 361 | _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {} | 365 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT |
| 366 | : __ptr_(__p) {} | ||
| 362 | 367 | ||
| 363 | template <class, class> | 368 | template <class, class> |
| 364 | friend class list; | 369 | friend class list; |
| ... | @@ -374,49 +379,54 @@ public: | ... | @@ -374,49 +379,54 @@ public: |
| 374 | typedef __rebind_pointer_t<_VoidPtr, value_type> pointer; | 379 | typedef __rebind_pointer_t<_VoidPtr, value_type> pointer; |
| 375 | typedef typename pointer_traits<pointer>::difference_type difference_type; | 380 | typedef typename pointer_traits<pointer>::difference_type difference_type; |
| 376 | 381 | ||
| 377 | _LIBCPP_HIDE_FROM_ABI __list_iterator() _NOEXCEPT : __ptr_(nullptr) {} | 382 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator() _NOEXCEPT : __ptr_(nullptr) {} |
| 378 | 383 | ||
| 379 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); } | 384 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 380 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 385 | return __ptr_->__as_node()->__get_value(); |
| 386 | } | ||
| 387 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | ||
| 381 | return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value()); | 388 | return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value()); |
| 382 | } | 389 | } |
| 383 | 390 | ||
| 384 | _LIBCPP_HIDE_FROM_ABI __list_iterator& operator++() { | 391 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator++() { |
| 385 | __ptr_ = __ptr_->__next_; | 392 | __ptr_ = __ptr_->__next_; |
| 386 | return *this; | 393 | return *this; |
| 387 | } | 394 | } |
| 388 | _LIBCPP_HIDE_FROM_ABI __list_iterator operator++(int) { | 395 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator operator++(int) { |
| 389 | __list_iterator __t(*this); | 396 | __list_iterator __t(*this); |
| 390 | ++(*this); | 397 | ++(*this); |
| 391 | return __t; | 398 | return __t; |
| 392 | } | 399 | } |
| 393 | 400 | ||
| 394 | _LIBCPP_HIDE_FROM_ABI __list_iterator& operator--() { | 401 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator--() { |
| 395 | __ptr_ = __ptr_->__prev_; | 402 | __ptr_ = __ptr_->__prev_; |
| 396 | return *this; | 403 | return *this; |
| 397 | } | 404 | } |
| 398 | _LIBCPP_HIDE_FROM_ABI __list_iterator operator--(int) { | 405 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator operator--(int) { |
| 399 | __list_iterator __t(*this); | 406 | __list_iterator __t(*this); |
| 400 | --(*this); | 407 | --(*this); |
| 401 | return __t; | 408 | return __t; |
| 402 | } | 409 | } |
| 403 | 410 | ||
| 404 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_iterator& __x, const __list_iterator& __y) { | 411 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 412 | operator==(const __list_iterator& __x, const __list_iterator& __y) { | ||
| 405 | return __x.__ptr_ == __y.__ptr_; | 413 | return __x.__ptr_ == __y.__ptr_; |
| 406 | } | 414 | } |
| 407 | friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_iterator& __x, const __list_iterator& __y) { | 415 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 416 | operator!=(const __list_iterator& __x, const __list_iterator& __y) { | ||
| 408 | return !(__x == __y); | 417 | return !(__x == __y); |
| 409 | } | 418 | } |
| 410 | }; | 419 | }; |
| 411 | 420 | ||
| 412 | template <class _Tp, class _VoidPtr> | 421 | template <class _Tp, class _VoidPtr> |
| 413 | class _LIBCPP_TEMPLATE_VIS __list_const_iterator { | 422 | class __list_const_iterator { |
| 414 | typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; | 423 | typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; |
| 415 | typedef typename _NodeTraits::__base_pointer __base_pointer; | 424 | typedef typename _NodeTraits::__base_pointer __base_pointer; |
| 416 | 425 | ||
| 417 | __base_pointer __ptr_; | 426 | __base_pointer __ptr_; |
| 418 | 427 | ||
| 419 | _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {} | 428 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT |
| 429 | : __ptr_(__p) {} | ||
| 420 | 430 | ||
| 421 | template <class, class> | 431 | template <class, class> |
| 422 | friend class list; | 432 | friend class list; |
| ... | @@ -430,39 +440,43 @@ public: | ... | @@ -430,39 +440,43 @@ public: |
| 430 | typedef __rebind_pointer_t<_VoidPtr, const value_type> pointer; | 440 | typedef __rebind_pointer_t<_VoidPtr, const value_type> pointer; |
| 431 | typedef typename pointer_traits<pointer>::difference_type difference_type; | 441 | typedef typename pointer_traits<pointer>::difference_type difference_type; |
| 432 | 442 | ||
| 433 | _LIBCPP_HIDE_FROM_ABI __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} | 443 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} |
| 434 | _LIBCPP_HIDE_FROM_ABI __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT | 444 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 435 | : __ptr_(__p.__ptr_) {} | 445 | __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT : __ptr_(__p.__ptr_) {} |
| 436 | 446 | ||
| 437 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); } | 447 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const { |
| 438 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | 448 | return __ptr_->__as_node()->__get_value(); |
| 449 | } | ||
| 450 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { | ||
| 439 | return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value()); | 451 | return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value()); |
| 440 | } | 452 | } |
| 441 | 453 | ||
| 442 | _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator++() { | 454 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator++() { |
| 443 | __ptr_ = __ptr_->__next_; | 455 | __ptr_ = __ptr_->__next_; |
| 444 | return *this; | 456 | return *this; |
| 445 | } | 457 | } |
| 446 | _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator++(int) { | 458 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator++(int) { |
| 447 | __list_const_iterator __t(*this); | 459 | __list_const_iterator __t(*this); |
| 448 | ++(*this); | 460 | ++(*this); |
| 449 | return __t; | 461 | return __t; |
| 450 | } | 462 | } |
| 451 | 463 | ||
| 452 | _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator--() { | 464 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator--() { |
| 453 | __ptr_ = __ptr_->__prev_; | 465 | __ptr_ = __ptr_->__prev_; |
| 454 | return *this; | 466 | return *this; |
| 455 | } | 467 | } |
| 456 | _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator--(int) { | 468 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator--(int) { |
| 457 | __list_const_iterator __t(*this); | 469 | __list_const_iterator __t(*this); |
| 458 | --(*this); | 470 | --(*this); |
| 459 | return __t; | 471 | return __t; |
| 460 | } | 472 | } |
| 461 | 473 | ||
| 462 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) { | 474 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 475 | operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) { | ||
| 463 | return __x.__ptr_ == __y.__ptr_; | 476 | return __x.__ptr_ == __y.__ptr_; |
| 464 | } | 477 | } |
| 465 | friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y) { | 478 | friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool |
| 479 | operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y) { | ||
| 466 | return !(__x == __y); | 480 | return !(__x == __y); |
| 467 | } | 481 | } |
| 468 | }; | 482 | }; |
| ... | @@ -503,43 +517,49 @@ protected: | ... | @@ -503,43 +517,49 @@ protected: |
| 503 | __node_base __end_; | 517 | __node_base __end_; |
| 504 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_); | 518 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_); |
| 505 | 519 | ||
| 506 | _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT { | 520 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT { |
| 507 | return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self()); | 521 | return pointer_traits<__base_pointer>::pointer_to(const_cast<__node_base&>(__end_)); |
| 508 | } | 522 | } |
| 509 | 523 | ||
| 510 | _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT { | 524 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT { |
| 511 | return __node_alloc_traits::max_size(__node_alloc_); | 525 | return __node_alloc_traits::max_size(__node_alloc_); |
| 512 | } | 526 | } |
| 513 | _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT; | 527 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static void |
| 528 | __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT; | ||
| 514 | 529 | ||
| 515 | _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value); | 530 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp() |
| 516 | _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a); | 531 | _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value); |
| 517 | _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a); | 532 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a); |
| 533 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a); | ||
| 518 | # ifndef _LIBCPP_CXX03_LANG | 534 | # ifndef _LIBCPP_CXX03_LANG |
| 519 | _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT; | 535 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT; |
| 520 | # endif | 536 | # endif |
| 521 | _LIBCPP_HIDE_FROM_ABI ~__list_imp(); | 537 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__list_imp(); |
| 522 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; | 538 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; |
| 523 | _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; } | 539 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; } |
| 524 | 540 | ||
| 525 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); } | 541 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); } |
| 526 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__end_.__next_); } | 542 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { |
| 527 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_as_link()); } | 543 | return const_iterator(__end_.__next_); |
| 528 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); } | 544 | } |
| 545 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_as_link()); } | ||
| 546 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { | ||
| 547 | return const_iterator(__end_as_link()); | ||
| 548 | } | ||
| 529 | 549 | ||
| 530 | _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c) | 550 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c) |
| 531 | # if _LIBCPP_STD_VER >= 14 | 551 | # if _LIBCPP_STD_VER >= 14 |
| 532 | _NOEXCEPT; | 552 | _NOEXCEPT; |
| 533 | # else | 553 | # else |
| 534 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); | 554 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 535 | # endif | 555 | # endif |
| 536 | 556 | ||
| 537 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) { | 557 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) { |
| 538 | __copy_assign_alloc( | 558 | __copy_assign_alloc( |
| 539 | __c, integral_constant<bool, __node_alloc_traits::propagate_on_container_copy_assignment::value>()); | 559 | __c, integral_constant<bool, __node_alloc_traits::propagate_on_container_copy_assignment::value>()); |
| 540 | } | 560 | } |
| 541 | 561 | ||
| 542 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c) | 562 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c) |
| 543 | _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_move_assignment::value || | 563 | _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_move_assignment::value || |
| 544 | is_nothrow_move_assignable<__node_allocator>::value) { | 564 | is_nothrow_move_assignable<__node_allocator>::value) { |
| 545 | __move_assign_alloc( | 565 | __move_assign_alloc( |
| ... | @@ -547,7 +567,8 @@ protected: | ... | @@ -547,7 +567,8 @@ protected: |
| 547 | } | 567 | } |
| 548 | 568 | ||
| 549 | template <class... _Args> | 569 | template <class... _Args> |
| 550 | _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) { | 570 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer |
| 571 | __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) { | ||
| 551 | __allocation_guard<__node_allocator> __guard(__node_alloc_, 1); | 572 | __allocation_guard<__node_allocator> __guard(__node_alloc_, 1); |
| 552 | // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value | 573 | // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value |
| 553 | // held inside the node, since we need to use the allocator's construct() method for that. | 574 | // held inside the node, since we need to use the allocator's construct() method for that. |
| ... | @@ -563,7 +584,7 @@ protected: | ... | @@ -563,7 +584,7 @@ protected: |
| 563 | return __guard.__release_ptr(); | 584 | return __guard.__release_ptr(); |
| 564 | } | 585 | } |
| 565 | 586 | ||
| 566 | _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { | 587 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { |
| 567 | // For the same reason as above, we use the allocator's destroy() method for the value_type, | 588 | // For the same reason as above, we use the allocator's destroy() method for the value_type, |
| 568 | // but not for the node itself. | 589 | // but not for the node itself. |
| 569 | __node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value())); | 590 | __node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value())); |
| ... | @@ -572,54 +593,57 @@ protected: | ... | @@ -572,54 +593,57 @@ protected: |
| 572 | } | 593 | } |
| 573 | 594 | ||
| 574 | private: | 595 | private: |
| 575 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) { | 596 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) { |
| 576 | if (__node_alloc_ != __c.__node_alloc_) | 597 | if (__node_alloc_ != __c.__node_alloc_) |
| 577 | clear(); | 598 | clear(); |
| 578 | __node_alloc_ = __c.__node_alloc_; | 599 | __node_alloc_ = __c.__node_alloc_; |
| 579 | } | 600 | } |
| 580 | 601 | ||
| 581 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {} | 602 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {} |
| 582 | 603 | ||
| 583 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type) | 604 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type) |
| 584 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) { | 605 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) { |
| 585 | __node_alloc_ = std::move(__c.__node_alloc_); | 606 | __node_alloc_ = std::move(__c.__node_alloc_); |
| 586 | } | 607 | } |
| 587 | 608 | ||
| 588 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {} | 609 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {} |
| 589 | }; | 610 | }; |
| 590 | 611 | ||
| 591 | // Unlink nodes [__f, __l] | 612 | // Unlink nodes [__f, __l] |
| 592 | template <class _Tp, class _Alloc> | 613 | template <class _Tp, class _Alloc> |
| 593 | inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT { | 614 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void |
| 615 | __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT { | ||
| 594 | __f->__prev_->__next_ = __l->__next_; | 616 | __f->__prev_->__next_ = __l->__next_; |
| 595 | __l->__next_->__prev_ = __f->__prev_; | 617 | __l->__next_->__prev_ = __f->__prev_; |
| 596 | } | 618 | } |
| 597 | 619 | ||
| 598 | template <class _Tp, class _Alloc> | 620 | template <class _Tp, class _Alloc> |
| 599 | inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) | 621 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp() |
| 622 | _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) | ||
| 600 | : __size_(0) {} | 623 | : __size_(0) {} |
| 601 | 624 | ||
| 602 | template <class _Tp, class _Alloc> | 625 | template <class _Tp, class _Alloc> |
| 603 | inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) | 626 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) |
| 604 | : __size_(0), __node_alloc_(__node_allocator(__a)) {} | 627 | : __size_(0), __node_alloc_(__node_allocator(__a)) {} |
| 605 | 628 | ||
| 606 | template <class _Tp, class _Alloc> | 629 | template <class _Tp, class _Alloc> |
| 607 | inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {} | 630 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) |
| 631 | : __size_(0), __node_alloc_(__a) {} | ||
| 608 | 632 | ||
| 609 | # ifndef _LIBCPP_CXX03_LANG | 633 | # ifndef _LIBCPP_CXX03_LANG |
| 610 | template <class _Tp, class _Alloc> | 634 | template <class _Tp, class _Alloc> |
| 611 | inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT | 635 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT |
| 612 | : __size_(0), | 636 | : __size_(0), |
| 613 | __node_alloc_(std::move(__a)) {} | 637 | __node_alloc_(std::move(__a)) {} |
| 614 | # endif | 638 | # endif |
| 615 | 639 | ||
| 616 | template <class _Tp, class _Alloc> | 640 | template <class _Tp, class _Alloc> |
| 617 | __list_imp<_Tp, _Alloc>::~__list_imp() { | 641 | _LIBCPP_CONSTEXPR_SINCE_CXX26 __list_imp<_Tp, _Alloc>::~__list_imp() { |
| 618 | clear(); | 642 | clear(); |
| 619 | } | 643 | } |
| 620 | 644 | ||
| 621 | template <class _Tp, class _Alloc> | 645 | template <class _Tp, class _Alloc> |
| 622 | void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { | 646 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { |
| 623 | if (!empty()) { | 647 | if (!empty()) { |
| 624 | __base_pointer __f = __end_.__next_; | 648 | __base_pointer __f = __end_.__next_; |
| 625 | __base_pointer __l = __end_as_link(); | 649 | __base_pointer __l = __end_as_link(); |
| ... | @@ -634,7 +658,7 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { | ... | @@ -634,7 +658,7 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { |
| 634 | } | 658 | } |
| 635 | 659 | ||
| 636 | template <class _Tp, class _Alloc> | 660 | template <class _Tp, class _Alloc> |
| 637 | void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) | 661 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) |
| 638 | # if _LIBCPP_STD_VER >= 14 | 662 | # if _LIBCPP_STD_VER >= 14 |
| 639 | _NOEXCEPT | 663 | _NOEXCEPT |
| 640 | # else | 664 | # else |
| ... | @@ -660,7 +684,7 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) | ... | @@ -660,7 +684,7 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) |
| 660 | } | 684 | } |
| 661 | 685 | ||
| 662 | template <class _Tp, class _Alloc /*= allocator<_Tp>*/> | 686 | template <class _Tp, class _Alloc /*= allocator<_Tp>*/> |
| 663 | class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> { | 687 | class list : private __list_imp<_Tp, _Alloc> { |
| 664 | typedef __list_imp<_Tp, _Alloc> __base; | 688 | typedef __list_imp<_Tp, _Alloc> __base; |
| 665 | typedef typename __base::__node_type __node_type; | 689 | typedef typename __base::__node_type __node_type; |
| 666 | typedef typename __base::__node_allocator __node_allocator; | 690 | typedef typename __base::__node_allocator __node_allocator; |
| ... | @@ -692,169 +716,204 @@ public: | ... | @@ -692,169 +716,204 @@ public: |
| 692 | typedef void __remove_return_type; | 716 | typedef void __remove_return_type; |
| 693 | # endif | 717 | # endif |
| 694 | 718 | ||
| 695 | _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} | 719 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list() |
| 696 | _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {} | 720 | _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} |
| 697 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n); | 721 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {} |
| 722 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n); | ||
| 698 | # if _LIBCPP_STD_VER >= 14 | 723 | # if _LIBCPP_STD_VER >= 14 |
| 699 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); | 724 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); |
| 700 | # endif | 725 | # endif |
| 701 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); | 726 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); |
| 702 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 727 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 703 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) { | 728 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 729 | list(size_type __n, const value_type& __x, const allocator_type& __a) | ||
| 730 | : __base(__a) { | ||
| 704 | for (; __n > 0; --__n) | 731 | for (; __n > 0; --__n) |
| 705 | push_back(__x); | 732 | push_back(__x); |
| 706 | } | 733 | } |
| 707 | 734 | ||
| 708 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> | 735 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 709 | _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l); | 736 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l); |
| 710 | 737 | ||
| 711 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> | 738 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 712 | _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a); | 739 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a); |
| 713 | 740 | ||
| 714 | # if _LIBCPP_STD_VER >= 23 | 741 | # if _LIBCPP_STD_VER >= 23 |
| 715 | template <_ContainerCompatibleRange<_Tp> _Range> | 742 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 716 | _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) | 743 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 744 | list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) | ||
| 717 | : __base(__a) { | 745 | : __base(__a) { |
| 718 | prepend_range(std::forward<_Range>(__range)); | 746 | prepend_range(std::forward<_Range>(__range)); |
| 719 | } | 747 | } |
| 720 | # endif | 748 | # endif |
| 721 | 749 | ||
| 722 | _LIBCPP_HIDE_FROM_ABI list(const list& __c); | 750 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(const list& __c); |
| 723 | _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t<allocator_type>& __a); | 751 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 724 | _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c); | 752 | list(const list& __c, const __type_identity_t<allocator_type>& __a); |
| 753 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c); | ||
| 725 | # ifndef _LIBCPP_CXX03_LANG | 754 | # ifndef _LIBCPP_CXX03_LANG |
| 726 | _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il); | 755 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il); |
| 727 | _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il, const allocator_type& __a); | 756 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 728 | 757 | list(initializer_list<value_type> __il, const allocator_type& __a); | |
| 729 | _LIBCPP_HIDE_FROM_ABI list(list&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value); | 758 | |
| 730 | _LIBCPP_HIDE_FROM_ABI list(list&& __c, const __type_identity_t<allocator_type>& __a); | 759 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(list&& __c) |
| 731 | _LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c) | 760 | _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value); |
| 732 | _NOEXCEPT_(__node_alloc_traits::propagate_on_container_move_assignment::value&& | 761 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(list&& __c, const __type_identity_t<allocator_type>& __a); |
| 733 | is_nothrow_move_assignable<__node_allocator>::value); | 762 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c) noexcept( |
| 734 | 763 | (__node_alloc_traits::propagate_on_container_move_assignment::value && | |
| 735 | _LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) { | 764 | is_nothrow_move_assignable<__node_allocator>::value) || |
| 765 | allocator_traits<allocator_type>::is_always_equal::value); | ||
| 766 | |||
| 767 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) { | ||
| 736 | assign(__il.begin(), __il.end()); | 768 | assign(__il.begin(), __il.end()); |
| 737 | return *this; | 769 | return *this; |
| 738 | } | 770 | } |
| 739 | 771 | ||
| 740 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } | 772 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { |
| 773 | assign(__il.begin(), __il.end()); | ||
| 774 | } | ||
| 741 | # endif // _LIBCPP_CXX03_LANG | 775 | # endif // _LIBCPP_CXX03_LANG |
| 742 | 776 | ||
| 743 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> | 777 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 744 | _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l); | 778 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l); |
| 745 | 779 | ||
| 746 | # if _LIBCPP_STD_VER >= 23 | 780 | # if _LIBCPP_STD_VER >= 23 |
| 747 | template <_ContainerCompatibleRange<_Tp> _Range> | 781 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 748 | _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { | 782 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { |
| 749 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | 783 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| 750 | } | 784 | } |
| 751 | # endif | 785 | # endif |
| 752 | 786 | ||
| 753 | _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x); | 787 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x); |
| 754 | 788 | ||
| 755 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; | 789 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; |
| 756 | 790 | ||
| 757 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; } | 791 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; } |
| 758 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __base::empty(); } | 792 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { |
| 759 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | 793 | return __base::empty(); |
| 794 | } | ||
| 795 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | ||
| 760 | return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max()); | 796 | return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max()); |
| 761 | } | 797 | } |
| 762 | 798 | ||
| 763 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); } | 799 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); } |
| 764 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); } | 800 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); } |
| 765 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); } | 801 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); } |
| 766 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); } | 802 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); } |
| 767 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __base::begin(); } | 803 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { |
| 768 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); } | 804 | return __base::begin(); |
| 805 | } | ||
| 806 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); } | ||
| 769 | 807 | ||
| 770 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } | 808 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { |
| 771 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 809 | return reverse_iterator(end()); |
| 772 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } | 810 | } |
| 773 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 811 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { |
| 774 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } | 812 | return const_reverse_iterator(end()); |
| 775 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(begin()); } | 813 | } |
| 814 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { | ||
| 815 | return reverse_iterator(begin()); | ||
| 816 | } | ||
| 817 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | ||
| 818 | return const_reverse_iterator(begin()); | ||
| 819 | } | ||
| 820 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { | ||
| 821 | return const_reverse_iterator(end()); | ||
| 822 | } | ||
| 823 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { | ||
| 824 | return const_reverse_iterator(begin()); | ||
| 825 | } | ||
| 776 | 826 | ||
| 777 | _LIBCPP_HIDE_FROM_ABI reference front() { | 827 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() { |
| 778 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); | 828 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); |
| 779 | return __base::__end_.__next_->__as_node()->__get_value(); | 829 | return __base::__end_.__next_->__as_node()->__get_value(); |
| 780 | } | 830 | } |
| 781 | _LIBCPP_HIDE_FROM_ABI const_reference front() const { | 831 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const { |
| 782 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); | 832 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); |
| 783 | return __base::__end_.__next_->__as_node()->__get_value(); | 833 | return __base::__end_.__next_->__as_node()->__get_value(); |
| 784 | } | 834 | } |
| 785 | _LIBCPP_HIDE_FROM_ABI reference back() { | 835 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference back() { |
| 786 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); | 836 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); |
| 787 | return __base::__end_.__prev_->__as_node()->__get_value(); | 837 | return __base::__end_.__prev_->__as_node()->__get_value(); |
| 788 | } | 838 | } |
| 789 | _LIBCPP_HIDE_FROM_ABI const_reference back() const { | 839 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference back() const { |
| 790 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); | 840 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); |
| 791 | return __base::__end_.__prev_->__as_node()->__get_value(); | 841 | return __base::__end_.__prev_->__as_node()->__get_value(); |
| 792 | } | 842 | } |
| 793 | 843 | ||
| 794 | # ifndef _LIBCPP_CXX03_LANG | 844 | # ifndef _LIBCPP_CXX03_LANG |
| 795 | _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x); | 845 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x); |
| 796 | _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); | 846 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); |
| 797 | 847 | ||
| 798 | # if _LIBCPP_STD_VER >= 23 | 848 | # if _LIBCPP_STD_VER >= 23 |
| 799 | template <_ContainerCompatibleRange<_Tp> _Range> | 849 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 800 | _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { | 850 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { |
| 801 | insert_range(begin(), std::forward<_Range>(__range)); | 851 | insert_range(begin(), std::forward<_Range>(__range)); |
| 802 | } | 852 | } |
| 803 | 853 | ||
| 804 | template <_ContainerCompatibleRange<_Tp> _Range> | 854 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 805 | _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { | 855 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { |
| 806 | insert_range(end(), std::forward<_Range>(__range)); | 856 | insert_range(end(), std::forward<_Range>(__range)); |
| 807 | } | 857 | } |
| 808 | # endif | 858 | # endif |
| 809 | 859 | ||
| 810 | template <class... _Args> | 860 | template <class... _Args> |
| 861 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 811 | # if _LIBCPP_STD_VER >= 17 | 862 | # if _LIBCPP_STD_VER >= 17 |
| 812 | _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); | 863 | _LIBCPP_HIDE_FROM_ABI reference |
| 864 | emplace_front(_Args&&... __args); | ||
| 813 | # else | 865 | # else |
| 814 | _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); | 866 | _LIBCPP_HIDE_FROM_ABI void |
| 867 | emplace_front(_Args&&... __args); | ||
| 815 | # endif | 868 | # endif |
| 816 | template <class... _Args> | 869 | template <class... _Args> |
| 870 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 817 | # if _LIBCPP_STD_VER >= 17 | 871 | # if _LIBCPP_STD_VER >= 17 |
| 818 | _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args); | 872 | _LIBCPP_HIDE_FROM_ABI reference |
| 873 | emplace_back(_Args&&... __args); | ||
| 819 | # else | 874 | # else |
| 820 | _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); | 875 | _LIBCPP_HIDE_FROM_ABI void |
| 876 | emplace_back(_Args&&... __args); | ||
| 821 | # endif | 877 | # endif |
| 822 | template <class... _Args> | 878 | template <class... _Args> |
| 823 | _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args); | 879 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args); |
| 824 | 880 | ||
| 825 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x); | 881 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x); |
| 826 | 882 | ||
| 827 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) { | 883 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 884 | insert(const_iterator __p, initializer_list<value_type> __il) { | ||
| 828 | return insert(__p, __il.begin(), __il.end()); | 885 | return insert(__p, __il.begin(), __il.end()); |
| 829 | } | 886 | } |
| 830 | # endif // _LIBCPP_CXX03_LANG | 887 | # endif // _LIBCPP_CXX03_LANG |
| 831 | 888 | ||
| 832 | _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x); | 889 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x); |
| 833 | _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x); | 890 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x); |
| 834 | 891 | ||
| 835 | # ifndef _LIBCPP_CXX03_LANG | 892 | # ifndef _LIBCPP_CXX03_LANG |
| 836 | template <class _Arg> | 893 | template <class _Arg> |
| 837 | _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) { | 894 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) { |
| 838 | emplace_back(std::forward<_Arg>(__arg)); | 895 | emplace_back(std::forward<_Arg>(__arg)); |
| 839 | } | 896 | } |
| 840 | # else | 897 | # else |
| 841 | _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); } | 898 | _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); } |
| 842 | # endif | 899 | # endif |
| 843 | 900 | ||
| 844 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x); | 901 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x); |
| 845 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x); | 902 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 903 | insert(const_iterator __p, size_type __n, const value_type& __x); | ||
| 846 | 904 | ||
| 847 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> | 905 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 848 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l); | 906 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l); |
| 849 | 907 | ||
| 850 | # if _LIBCPP_STD_VER >= 23 | 908 | # if _LIBCPP_STD_VER >= 23 |
| 851 | template <_ContainerCompatibleRange<_Tp> _Range> | 909 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 852 | _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) { | 910 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 911 | insert_range(const_iterator __position, _Range&& __range) { | ||
| 853 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); | 912 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); |
| 854 | } | 913 | } |
| 855 | # endif | 914 | # endif |
| 856 | 915 | ||
| 857 | _LIBCPP_HIDE_FROM_ABI void swap(list& __c) | 916 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(list& __c) |
| 858 | # if _LIBCPP_STD_VER >= 14 | 917 | # if _LIBCPP_STD_VER >= 14 |
| 859 | _NOEXCEPT | 918 | _NOEXCEPT |
| 860 | # else | 919 | # else |
| ... | @@ -863,72 +922,80 @@ public: | ... | @@ -863,72 +922,80 @@ public: |
| 863 | { | 922 | { |
| 864 | __base::swap(__c); | 923 | __base::swap(__c); |
| 865 | } | 924 | } |
| 866 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); } | 925 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); } |
| 867 | 926 | ||
| 868 | _LIBCPP_HIDE_FROM_ABI void pop_front(); | 927 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_front(); |
| 869 | _LIBCPP_HIDE_FROM_ABI void pop_back(); | 928 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_back(); |
| 870 | 929 | ||
| 871 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p); | 930 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p); |
| 872 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l); | 931 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l); |
| 873 | 932 | ||
| 874 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); | 933 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); |
| 875 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x); | 934 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x); |
| 876 | 935 | ||
| 877 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c); | 936 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c); |
| 878 | # ifndef _LIBCPP_CXX03_LANG | 937 | # ifndef _LIBCPP_CXX03_LANG |
| 879 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); } | 938 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); } |
| 880 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); } | 939 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { |
| 881 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) { | 940 | splice(__p, __c, __i); |
| 941 | } | ||
| 942 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void | ||
| 943 | splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) { | ||
| 882 | splice(__p, __c, __f, __l); | 944 | splice(__p, __c, __f, __l); |
| 883 | } | 945 | } |
| 884 | # endif | 946 | # endif |
| 885 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i); | 947 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i); |
| 886 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l); | 948 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void |
| 949 | splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l); | ||
| 887 | 950 | ||
| 888 | _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __x); | 951 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __x); |
| 889 | template <class _Pred> | 952 | template <class _Pred> |
| 890 | _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Pred __pred); | 953 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Pred __pred); |
| 891 | _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); } | 954 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); } |
| 892 | template <class _BinaryPred> | 955 | template <class _BinaryPred> |
| 893 | _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred); | 956 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred); |
| 894 | _LIBCPP_HIDE_FROM_ABI void merge(list& __c); | 957 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list& __c); |
| 895 | # ifndef _LIBCPP_CXX03_LANG | 958 | # ifndef _LIBCPP_CXX03_LANG |
| 896 | _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); } | 959 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); } |
| 897 | 960 | ||
| 898 | template <class _Comp> | 961 | template <class _Comp> |
| 899 | _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) { | 962 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) { |
| 900 | merge(__c, __comp); | 963 | merge(__c, __comp); |
| 901 | } | 964 | } |
| 902 | # endif | 965 | # endif |
| 903 | template <class _Comp> | 966 | template <class _Comp> |
| 904 | _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp); | 967 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp); |
| 905 | 968 | ||
| 906 | _LIBCPP_HIDE_FROM_ABI void sort(); | 969 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort(); |
| 907 | template <class _Comp> | 970 | template <class _Comp> |
| 908 | _LIBCPP_HIDE_FROM_ABI void sort(_Comp __comp); | 971 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort(_Comp __comp); |
| 909 | 972 | ||
| 910 | _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT; | 973 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT; |
| 911 | 974 | ||
| 912 | _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | 975 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; |
| 913 | 976 | ||
| 914 | private: | 977 | private: |
| 915 | template <class _Iterator, class _Sentinel> | 978 | template <class _Iterator, class _Sentinel> |
| 916 | _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __f, _Sentinel __l); | 979 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __f, _Sentinel __l); |
| 917 | 980 | ||
| 918 | template <class _Iterator, class _Sentinel> | 981 | template <class _Iterator, class _Sentinel> |
| 919 | _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l); | 982 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator |
| 920 | 983 | __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l); | |
| 921 | _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l); | 984 | |
| 922 | _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__base_pointer __f, __base_pointer __l); | 985 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static void |
| 923 | _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l); | 986 | __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l); |
| 924 | _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n); | 987 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void |
| 988 | __link_nodes_at_front(__base_pointer __f, __base_pointer __l); | ||
| 989 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l); | ||
| 990 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n); | ||
| 925 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI | 991 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI |
| 926 | template <class _Comp> | 992 | template <class _Comp> |
| 927 | _LIBCPP_HIDDEN static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp); | 993 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDDEN static iterator |
| 994 | __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp); | ||
| 928 | 995 | ||
| 929 | _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, true_type) | 996 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, true_type) |
| 930 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value); | 997 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value); |
| 931 | _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type); | 998 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type); |
| 932 | }; | 999 | }; |
| 933 | 1000 | ||
| 934 | # if _LIBCPP_STD_VER >= 17 | 1001 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -954,7 +1021,8 @@ list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_R | ... | @@ -954,7 +1021,8 @@ list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_R |
| 954 | 1021 | ||
| 955 | // Link in nodes [__f, __l] just prior to __p | 1022 | // Link in nodes [__f, __l] just prior to __p |
| 956 | template <class _Tp, class _Alloc> | 1023 | template <class _Tp, class _Alloc> |
| 957 | inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) { | 1024 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void |
| 1025 | list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) { | ||
| 958 | __p->__prev_->__next_ = __f; | 1026 | __p->__prev_->__next_ = __f; |
| 959 | __f->__prev_ = __p->__prev_; | 1027 | __f->__prev_ = __p->__prev_; |
| 960 | __p->__prev_ = __l; | 1028 | __p->__prev_ = __l; |
| ... | @@ -963,7 +1031,8 @@ inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer _ | ... | @@ -963,7 +1031,8 @@ inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer _ |
| 963 | 1031 | ||
| 964 | // Link in nodes [__f, __l] at the front of the list | 1032 | // Link in nodes [__f, __l] at the front of the list |
| 965 | template <class _Tp, class _Alloc> | 1033 | template <class _Tp, class _Alloc> |
| 966 | inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) { | 1034 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void |
| 1035 | list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) { | ||
| 967 | __f->__prev_ = __base::__end_as_link(); | 1036 | __f->__prev_ = __base::__end_as_link(); |
| 968 | __l->__next_ = __base::__end_.__next_; | 1037 | __l->__next_ = __base::__end_.__next_; |
| 969 | __l->__next_->__prev_ = __l; | 1038 | __l->__next_->__prev_ = __l; |
| ... | @@ -972,7 +1041,8 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_ | ... | @@ -972,7 +1041,8 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_ |
| 972 | 1041 | ||
| 973 | // Link in nodes [__f, __l] at the back of the list | 1042 | // Link in nodes [__f, __l] at the back of the list |
| 974 | template <class _Tp, class _Alloc> | 1043 | template <class _Tp, class _Alloc> |
| 975 | inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) { | 1044 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void |
| 1045 | list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) { | ||
| 976 | __l->__next_ = __base::__end_as_link(); | 1046 | __l->__next_ = __base::__end_as_link(); |
| 977 | __f->__prev_ = __base::__end_.__prev_; | 1047 | __f->__prev_ = __base::__end_.__prev_; |
| 978 | __f->__prev_->__next_ = __f; | 1048 | __f->__prev_->__next_ = __f; |
| ... | @@ -980,12 +1050,12 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_p | ... | @@ -980,12 +1050,12 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_p |
| 980 | } | 1050 | } |
| 981 | 1051 | ||
| 982 | template <class _Tp, class _Alloc> | 1052 | template <class _Tp, class _Alloc> |
| 983 | inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) { | 1053 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) { |
| 984 | return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n); | 1054 | return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n); |
| 985 | } | 1055 | } |
| 986 | 1056 | ||
| 987 | template <class _Tp, class _Alloc> | 1057 | template <class _Tp, class _Alloc> |
| 988 | list<_Tp, _Alloc>::list(size_type __n) { | 1058 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n) { |
| 989 | for (; __n > 0; --__n) | 1059 | for (; __n > 0; --__n) |
| 990 | # ifndef _LIBCPP_CXX03_LANG | 1060 | # ifndef _LIBCPP_CXX03_LANG |
| 991 | emplace_back(); | 1061 | emplace_back(); |
| ... | @@ -996,41 +1066,43 @@ list<_Tp, _Alloc>::list(size_type __n) { | ... | @@ -996,41 +1066,43 @@ list<_Tp, _Alloc>::list(size_type __n) { |
| 996 | 1066 | ||
| 997 | # if _LIBCPP_STD_VER >= 14 | 1067 | # if _LIBCPP_STD_VER >= 14 |
| 998 | template <class _Tp, class _Alloc> | 1068 | template <class _Tp, class _Alloc> |
| 999 | list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) { | 1069 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) { |
| 1000 | for (; __n > 0; --__n) | 1070 | for (; __n > 0; --__n) |
| 1001 | emplace_back(); | 1071 | emplace_back(); |
| 1002 | } | 1072 | } |
| 1003 | # endif | 1073 | # endif |
| 1004 | 1074 | ||
| 1005 | template <class _Tp, class _Alloc> | 1075 | template <class _Tp, class _Alloc> |
| 1006 | list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { | 1076 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { |
| 1007 | for (; __n > 0; --__n) | 1077 | for (; __n > 0; --__n) |
| 1008 | push_back(__x); | 1078 | push_back(__x); |
| 1009 | } | 1079 | } |
| 1010 | 1080 | ||
| 1011 | template <class _Tp, class _Alloc> | 1081 | template <class _Tp, class _Alloc> |
| 1012 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > | 1082 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1013 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) { | 1083 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) { |
| 1014 | for (; __f != __l; ++__f) | 1084 | for (; __f != __l; ++__f) |
| 1015 | __emplace_back(*__f); | 1085 | __emplace_back(*__f); |
| 1016 | } | 1086 | } |
| 1017 | 1087 | ||
| 1018 | template <class _Tp, class _Alloc> | 1088 | template <class _Tp, class _Alloc> |
| 1019 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > | 1089 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1020 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : __base(__a) { | 1090 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) |
| 1091 | : __base(__a) { | ||
| 1021 | for (; __f != __l; ++__f) | 1092 | for (; __f != __l; ++__f) |
| 1022 | __emplace_back(*__f); | 1093 | __emplace_back(*__f); |
| 1023 | } | 1094 | } |
| 1024 | 1095 | ||
| 1025 | template <class _Tp, class _Alloc> | 1096 | template <class _Tp, class _Alloc> |
| 1026 | list<_Tp, _Alloc>::list(const list& __c) | 1097 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(const list& __c) |
| 1027 | : __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) { | 1098 | : __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) { |
| 1028 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) | 1099 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) |
| 1029 | push_back(*__i); | 1100 | push_back(*__i); |
| 1030 | } | 1101 | } |
| 1031 | 1102 | ||
| 1032 | template <class _Tp, class _Alloc> | 1103 | template <class _Tp, class _Alloc> |
| 1033 | list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) { | 1104 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) |
| 1105 | : __base(__a) { | ||
| 1034 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) | 1106 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) |
| 1035 | push_back(*__i); | 1107 | push_back(*__i); |
| 1036 | } | 1108 | } |
| ... | @@ -1038,25 +1110,28 @@ list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type> | ... | @@ -1038,25 +1110,28 @@ list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type> |
| 1038 | # ifndef _LIBCPP_CXX03_LANG | 1110 | # ifndef _LIBCPP_CXX03_LANG |
| 1039 | 1111 | ||
| 1040 | template <class _Tp, class _Alloc> | 1112 | template <class _Tp, class _Alloc> |
| 1041 | list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) { | 1113 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) |
| 1114 | : __base(__a) { | ||
| 1042 | for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i) | 1115 | for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i) |
| 1043 | push_back(*__i); | 1116 | push_back(*__i); |
| 1044 | } | 1117 | } |
| 1045 | 1118 | ||
| 1046 | template <class _Tp, class _Alloc> | 1119 | template <class _Tp, class _Alloc> |
| 1047 | list<_Tp, _Alloc>::list(initializer_list<value_type> __il) { | 1120 | _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(initializer_list<value_type> __il) { |
| 1048 | for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i) | 1121 | for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i) |
| 1049 | push_back(*__i); | 1122 | push_back(*__i); |
| 1050 | } | 1123 | } |
| 1051 | 1124 | ||
| 1052 | template <class _Tp, class _Alloc> | 1125 | template <class _Tp, class _Alloc> |
| 1053 | inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value) | 1126 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>::list(list&& __c) noexcept( |
| 1127 | is_nothrow_move_constructible<__node_allocator>::value) | ||
| 1054 | : __base(std::move(__c.__node_alloc_)) { | 1128 | : __base(std::move(__c.__node_alloc_)) { |
| 1055 | splice(end(), __c); | 1129 | splice(end(), __c); |
| 1056 | } | 1130 | } |
| 1057 | 1131 | ||
| 1058 | template <class _Tp, class _Alloc> | 1132 | template <class _Tp, class _Alloc> |
| 1059 | inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) { | 1133 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) |
| 1134 | : __base(__a) { | ||
| 1060 | if (__a == __c.get_allocator()) | 1135 | if (__a == __c.get_allocator()) |
| 1061 | splice(end(), __c); | 1136 | splice(end(), __c); |
| 1062 | else { | 1137 | else { |
| ... | @@ -1066,15 +1141,16 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ | ... | @@ -1066,15 +1141,16 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ |
| 1066 | } | 1141 | } |
| 1067 | 1142 | ||
| 1068 | template <class _Tp, class _Alloc> | 1143 | template <class _Tp, class _Alloc> |
| 1069 | inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept( | 1144 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept( |
| 1070 | __node_alloc_traits::propagate_on_container_move_assignment::value && | 1145 | (__node_alloc_traits::propagate_on_container_move_assignment::value && |
| 1071 | is_nothrow_move_assignable<__node_allocator>::value) { | 1146 | is_nothrow_move_assignable<__node_allocator>::value) || |
| 1147 | allocator_traits<allocator_type>::is_always_equal::value) { | ||
| 1072 | __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>()); | 1148 | __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>()); |
| 1073 | return *this; | 1149 | return *this; |
| 1074 | } | 1150 | } |
| 1075 | 1151 | ||
| 1076 | template <class _Tp, class _Alloc> | 1152 | template <class _Tp, class _Alloc> |
| 1077 | void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) { | 1153 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) { |
| 1078 | if (this->__node_alloc_ != __c.__node_alloc_) { | 1154 | if (this->__node_alloc_ != __c.__node_alloc_) { |
| 1079 | typedef move_iterator<iterator> _Ip; | 1155 | typedef move_iterator<iterator> _Ip; |
| 1080 | assign(_Ip(__c.begin()), _Ip(__c.end())); | 1156 | assign(_Ip(__c.begin()), _Ip(__c.end())); |
| ... | @@ -1083,8 +1159,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) { | ... | @@ -1083,8 +1159,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) { |
| 1083 | } | 1159 | } |
| 1084 | 1160 | ||
| 1085 | template <class _Tp, class _Alloc> | 1161 | template <class _Tp, class _Alloc> |
| 1086 | void list<_Tp, _Alloc>::__move_assign(list& __c, | 1162 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 1087 | true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) { | 1163 | list<_Tp, _Alloc>::__move_assign(list& __c, true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) { |
| 1088 | clear(); | 1164 | clear(); |
| 1089 | __base::__move_assign_alloc(__c); | 1165 | __base::__move_assign_alloc(__c); |
| 1090 | splice(end(), __c); | 1166 | splice(end(), __c); |
| ... | @@ -1093,7 +1169,7 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, | ... | @@ -1093,7 +1169,7 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, |
| 1093 | # endif // _LIBCPP_CXX03_LANG | 1169 | # endif // _LIBCPP_CXX03_LANG |
| 1094 | 1170 | ||
| 1095 | template <class _Tp, class _Alloc> | 1171 | template <class _Tp, class _Alloc> |
| 1096 | inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { | 1172 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { |
| 1097 | if (this != std::addressof(__c)) { | 1173 | if (this != std::addressof(__c)) { |
| 1098 | __base::__copy_assign_alloc(__c); | 1174 | __base::__copy_assign_alloc(__c); |
| 1099 | assign(__c.begin(), __c.end()); | 1175 | assign(__c.begin(), __c.end()); |
| ... | @@ -1103,13 +1179,14 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { | ... | @@ -1103,13 +1179,14 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { |
| 1103 | 1179 | ||
| 1104 | template <class _Tp, class _Alloc> | 1180 | template <class _Tp, class _Alloc> |
| 1105 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > | 1181 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1106 | void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) { | 1182 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) { |
| 1107 | __assign_with_sentinel(__f, __l); | 1183 | __assign_with_sentinel(__f, __l); |
| 1108 | } | 1184 | } |
| 1109 | 1185 | ||
| 1110 | template <class _Tp, class _Alloc> | 1186 | template <class _Tp, class _Alloc> |
| 1111 | template <class _Iterator, class _Sentinel> | 1187 | template <class _Iterator, class _Sentinel> |
| 1112 | _LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator __f, _Sentinel __l) { | 1188 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void |
| 1189 | list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator __f, _Sentinel __l) { | ||
| 1113 | iterator __i = begin(); | 1190 | iterator __i = begin(); |
| 1114 | iterator __e = end(); | 1191 | iterator __e = end(); |
| 1115 | for (; __f != __l && __i != __e; ++__f, (void)++__i) | 1192 | for (; __f != __l && __i != __e; ++__f, (void)++__i) |
| ... | @@ -1121,7 +1198,7 @@ _LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator _ | ... | @@ -1121,7 +1198,7 @@ _LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator _ |
| 1121 | } | 1198 | } |
| 1122 | 1199 | ||
| 1123 | template <class _Tp, class _Alloc> | 1200 | template <class _Tp, class _Alloc> |
| 1124 | void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) { | 1201 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) { |
| 1125 | iterator __i = begin(); | 1202 | iterator __i = begin(); |
| 1126 | iterator __e = end(); | 1203 | iterator __e = end(); |
| 1127 | for (; __n > 0 && __i != __e; --__n, (void)++__i) | 1204 | for (; __n > 0 && __i != __e; --__n, (void)++__i) |
| ... | @@ -1133,12 +1210,13 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) { | ... | @@ -1133,12 +1210,13 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) { |
| 1133 | } | 1210 | } |
| 1134 | 1211 | ||
| 1135 | template <class _Tp, class _Alloc> | 1212 | template <class _Tp, class _Alloc> |
| 1136 | inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT { | 1213 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT { |
| 1137 | return allocator_type(this->__node_alloc_); | 1214 | return allocator_type(this->__node_alloc_); |
| 1138 | } | 1215 | } |
| 1139 | 1216 | ||
| 1140 | template <class _Tp, class _Alloc> | 1217 | template <class _Tp, class _Alloc> |
| 1141 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) { | 1218 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator |
| 1219 | list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) { | ||
| 1142 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); | 1220 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); |
| 1143 | __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link()); | 1221 | __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link()); |
| 1144 | ++this->__size_; | 1222 | ++this->__size_; |
| ... | @@ -1146,7 +1224,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __ | ... | @@ -1146,7 +1224,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __ |
| 1146 | } | 1224 | } |
| 1147 | 1225 | ||
| 1148 | template <class _Tp, class _Alloc> | 1226 | template <class _Tp, class _Alloc> |
| 1149 | typename list<_Tp, _Alloc>::iterator | 1227 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator |
| 1150 | list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) { | 1228 | list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) { |
| 1151 | iterator __r(__p.__ptr_); | 1229 | iterator __r(__p.__ptr_); |
| 1152 | if (__n > 0) { | 1230 | if (__n > 0) { |
| ... | @@ -1182,13 +1260,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ | ... | @@ -1182,13 +1260,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1182 | 1260 | ||
| 1183 | template <class _Tp, class _Alloc> | 1261 | template <class _Tp, class _Alloc> |
| 1184 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > | 1262 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1185 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) { | 1263 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator |
| 1264 | list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) { | ||
| 1186 | return __insert_with_sentinel(__p, __f, __l); | 1265 | return __insert_with_sentinel(__p, __f, __l); |
| 1187 | } | 1266 | } |
| 1188 | 1267 | ||
| 1189 | template <class _Tp, class _Alloc> | 1268 | template <class _Tp, class _Alloc> |
| 1190 | template <class _Iterator, class _Sentinel> | 1269 | template <class _Iterator, class _Sentinel> |
| 1191 | _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Alloc>::iterator | 1270 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Alloc>::iterator |
| 1192 | list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) { | 1271 | list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) { |
| 1193 | iterator __r(__p.__ptr_); | 1272 | iterator __r(__p.__ptr_); |
| 1194 | if (__f != __l) { | 1273 | if (__f != __l) { |
| ... | @@ -1223,7 +1302,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se | ... | @@ -1223,7 +1302,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se |
| 1223 | } | 1302 | } |
| 1224 | 1303 | ||
| 1225 | template <class _Tp, class _Alloc> | 1304 | template <class _Tp, class _Alloc> |
| 1226 | void list<_Tp, _Alloc>::push_front(const value_type& __x) { | 1305 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_front(const value_type& __x) { |
| 1227 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); | 1306 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); |
| 1228 | __base_pointer __nl = __node->__as_link(); | 1307 | __base_pointer __nl = __node->__as_link(); |
| 1229 | __link_nodes_at_front(__nl, __nl); | 1308 | __link_nodes_at_front(__nl, __nl); |
| ... | @@ -1231,7 +1310,7 @@ void list<_Tp, _Alloc>::push_front(const value_type& __x) { | ... | @@ -1231,7 +1310,7 @@ void list<_Tp, _Alloc>::push_front(const value_type& __x) { |
| 1231 | } | 1310 | } |
| 1232 | 1311 | ||
| 1233 | template <class _Tp, class _Alloc> | 1312 | template <class _Tp, class _Alloc> |
| 1234 | void list<_Tp, _Alloc>::push_back(const value_type& __x) { | 1313 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_back(const value_type& __x) { |
| 1235 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); | 1314 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); |
| 1236 | __base_pointer __nl = __node->__as_link(); | 1315 | __base_pointer __nl = __node->__as_link(); |
| 1237 | __link_nodes_at_back(__nl, __nl); | 1316 | __link_nodes_at_back(__nl, __nl); |
| ... | @@ -1241,7 +1320,7 @@ void list<_Tp, _Alloc>::push_back(const value_type& __x) { | ... | @@ -1241,7 +1320,7 @@ void list<_Tp, _Alloc>::push_back(const value_type& __x) { |
| 1241 | # ifndef _LIBCPP_CXX03_LANG | 1320 | # ifndef _LIBCPP_CXX03_LANG |
| 1242 | 1321 | ||
| 1243 | template <class _Tp, class _Alloc> | 1322 | template <class _Tp, class _Alloc> |
| 1244 | void list<_Tp, _Alloc>::push_front(value_type&& __x) { | 1323 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_front(value_type&& __x) { |
| 1245 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); | 1324 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); |
| 1246 | __base_pointer __nl = __node->__as_link(); | 1325 | __base_pointer __nl = __node->__as_link(); |
| 1247 | __link_nodes_at_front(__nl, __nl); | 1326 | __link_nodes_at_front(__nl, __nl); |
| ... | @@ -1249,7 +1328,7 @@ void list<_Tp, _Alloc>::push_front(value_type&& __x) { | ... | @@ -1249,7 +1328,7 @@ void list<_Tp, _Alloc>::push_front(value_type&& __x) { |
| 1249 | } | 1328 | } |
| 1250 | 1329 | ||
| 1251 | template <class _Tp, class _Alloc> | 1330 | template <class _Tp, class _Alloc> |
| 1252 | void list<_Tp, _Alloc>::push_back(value_type&& __x) { | 1331 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_back(value_type&& __x) { |
| 1253 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); | 1332 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); |
| 1254 | __base_pointer __nl = __node->__as_link(); | 1333 | __base_pointer __nl = __node->__as_link(); |
| 1255 | __link_nodes_at_back(__nl, __nl); | 1334 | __link_nodes_at_back(__nl, __nl); |
| ... | @@ -1258,12 +1337,13 @@ void list<_Tp, _Alloc>::push_back(value_type&& __x) { | ... | @@ -1258,12 +1337,13 @@ void list<_Tp, _Alloc>::push_back(value_type&& __x) { |
| 1258 | 1337 | ||
| 1259 | template <class _Tp, class _Alloc> | 1338 | template <class _Tp, class _Alloc> |
| 1260 | template <class... _Args> | 1339 | template <class... _Args> |
| 1340 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 1261 | # if _LIBCPP_STD_VER >= 17 | 1341 | # if _LIBCPP_STD_VER >= 17 |
| 1262 | typename list<_Tp, _Alloc>::reference | 1342 | typename list<_Tp, _Alloc>::reference |
| 1263 | # else | 1343 | # else |
| 1264 | void | 1344 | void |
| 1265 | # endif | 1345 | # endif |
| 1266 | list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { | 1346 | list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { |
| 1267 | __node_pointer __node = | 1347 | __node_pointer __node = |
| 1268 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); | 1348 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1269 | __base_pointer __nl = __node->__as_link(); | 1349 | __base_pointer __nl = __node->__as_link(); |
| ... | @@ -1276,12 +1356,13 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { | ... | @@ -1276,12 +1356,13 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { |
| 1276 | 1356 | ||
| 1277 | template <class _Tp, class _Alloc> | 1357 | template <class _Tp, class _Alloc> |
| 1278 | template <class... _Args> | 1358 | template <class... _Args> |
| 1359 | _LIBCPP_CONSTEXPR_SINCE_CXX26 | ||
| 1279 | # if _LIBCPP_STD_VER >= 17 | 1360 | # if _LIBCPP_STD_VER >= 17 |
| 1280 | typename list<_Tp, _Alloc>::reference | 1361 | typename list<_Tp, _Alloc>::reference |
| 1281 | # else | 1362 | # else |
| 1282 | void | 1363 | void |
| 1283 | # endif | 1364 | # endif |
| 1284 | list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { | 1365 | list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { |
| 1285 | __node_pointer __node = | 1366 | __node_pointer __node = |
| 1286 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); | 1367 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1287 | __base_pointer __nl = __node->__as_link(); | 1368 | __base_pointer __nl = __node->__as_link(); |
| ... | @@ -1294,7 +1375,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { | ... | @@ -1294,7 +1375,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { |
| 1294 | 1375 | ||
| 1295 | template <class _Tp, class _Alloc> | 1376 | template <class _Tp, class _Alloc> |
| 1296 | template <class... _Args> | 1377 | template <class... _Args> |
| 1297 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) { | 1378 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator |
| 1379 | list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) { | ||
| 1298 | __node_pointer __node = | 1380 | __node_pointer __node = |
| 1299 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); | 1381 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1300 | __base_pointer __nl = __node->__as_link(); | 1382 | __base_pointer __nl = __node->__as_link(); |
| ... | @@ -1304,7 +1386,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator _ | ... | @@ -1304,7 +1386,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator _ |
| 1304 | } | 1386 | } |
| 1305 | 1387 | ||
| 1306 | template <class _Tp, class _Alloc> | 1388 | template <class _Tp, class _Alloc> |
| 1307 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) { | 1389 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator |
| 1390 | list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) { | ||
| 1308 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); | 1391 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); |
| 1309 | __base_pointer __nl = __node->__as_link(); | 1392 | __base_pointer __nl = __node->__as_link(); |
| 1310 | __link_nodes(__p.__ptr_, __nl, __nl); | 1393 | __link_nodes(__p.__ptr_, __nl, __nl); |
| ... | @@ -1315,7 +1398,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __ | ... | @@ -1315,7 +1398,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __ |
| 1315 | # endif // _LIBCPP_CXX03_LANG | 1398 | # endif // _LIBCPP_CXX03_LANG |
| 1316 | 1399 | ||
| 1317 | template <class _Tp, class _Alloc> | 1400 | template <class _Tp, class _Alloc> |
| 1318 | void list<_Tp, _Alloc>::pop_front() { | 1401 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::pop_front() { |
| 1319 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list"); | 1402 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list"); |
| 1320 | __base_pointer __n = __base::__end_.__next_; | 1403 | __base_pointer __n = __base::__end_.__next_; |
| 1321 | __base::__unlink_nodes(__n, __n); | 1404 | __base::__unlink_nodes(__n, __n); |
| ... | @@ -1324,7 +1407,7 @@ void list<_Tp, _Alloc>::pop_front() { | ... | @@ -1324,7 +1407,7 @@ void list<_Tp, _Alloc>::pop_front() { |
| 1324 | } | 1407 | } |
| 1325 | 1408 | ||
| 1326 | template <class _Tp, class _Alloc> | 1409 | template <class _Tp, class _Alloc> |
| 1327 | void list<_Tp, _Alloc>::pop_back() { | 1410 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::pop_back() { |
| 1328 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list"); | 1411 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list"); |
| 1329 | __base_pointer __n = __base::__end_.__prev_; | 1412 | __base_pointer __n = __base::__end_.__prev_; |
| 1330 | __base::__unlink_nodes(__n, __n); | 1413 | __base::__unlink_nodes(__n, __n); |
| ... | @@ -1333,7 +1416,7 @@ void list<_Tp, _Alloc>::pop_back() { | ... | @@ -1333,7 +1416,7 @@ void list<_Tp, _Alloc>::pop_back() { |
| 1333 | } | 1416 | } |
| 1334 | 1417 | ||
| 1335 | template <class _Tp, class _Alloc> | 1418 | template <class _Tp, class _Alloc> |
| 1336 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) { | 1419 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) { |
| 1337 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator"); | 1420 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator"); |
| 1338 | __base_pointer __n = __p.__ptr_; | 1421 | __base_pointer __n = __p.__ptr_; |
| 1339 | __base_pointer __r = __n->__next_; | 1422 | __base_pointer __r = __n->__next_; |
| ... | @@ -1344,7 +1427,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p | ... | @@ -1344,7 +1427,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p |
| 1344 | } | 1427 | } |
| 1345 | 1428 | ||
| 1346 | template <class _Tp, class _Alloc> | 1429 | template <class _Tp, class _Alloc> |
| 1347 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) { | 1430 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator |
| 1431 | list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) { | ||
| 1348 | if (__f != __l) { | 1432 | if (__f != __l) { |
| 1349 | __base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); | 1433 | __base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); |
| 1350 | while (__f != __l) { | 1434 | while (__f != __l) { |
| ... | @@ -1358,7 +1442,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f | ... | @@ -1358,7 +1442,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f |
| 1358 | } | 1442 | } |
| 1359 | 1443 | ||
| 1360 | template <class _Tp, class _Alloc> | 1444 | template <class _Tp, class _Alloc> |
| 1361 | void list<_Tp, _Alloc>::resize(size_type __n) { | 1445 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n) { |
| 1362 | if (__n < this->__size_) | 1446 | if (__n < this->__size_) |
| 1363 | erase(__iterator(__n), end()); | 1447 | erase(__iterator(__n), end()); |
| 1364 | else if (__n > this->__size_) { | 1448 | else if (__n > this->__size_) { |
| ... | @@ -1393,7 +1477,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) { | ... | @@ -1393,7 +1477,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) { |
| 1393 | } | 1477 | } |
| 1394 | 1478 | ||
| 1395 | template <class _Tp, class _Alloc> | 1479 | template <class _Tp, class _Alloc> |
| 1396 | void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { | 1480 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { |
| 1397 | if (__n < this->__size_) | 1481 | if (__n < this->__size_) |
| 1398 | erase(__iterator(__n), end()); | 1482 | erase(__iterator(__n), end()); |
| 1399 | else if (__n > this->__size_) { | 1483 | else if (__n > this->__size_) { |
| ... | @@ -1429,7 +1513,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { | ... | @@ -1429,7 +1513,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { |
| 1429 | } | 1513 | } |
| 1430 | 1514 | ||
| 1431 | template <class _Tp, class _Alloc> | 1515 | template <class _Tp, class _Alloc> |
| 1432 | void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { | 1516 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { |
| 1433 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | 1517 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( |
| 1434 | this != std::addressof(__c), "list::splice(iterator, list) called with this == &list"); | 1518 | this != std::addressof(__c), "list::splice(iterator, list) called with this == &list"); |
| 1435 | if (!__c.empty()) { | 1519 | if (!__c.empty()) { |
| ... | @@ -1443,7 +1527,7 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { | ... | @@ -1443,7 +1527,7 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { |
| 1443 | } | 1527 | } |
| 1444 | 1528 | ||
| 1445 | template <class _Tp, class _Alloc> | 1529 | template <class _Tp, class _Alloc> |
| 1446 | void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) { | 1530 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) { |
| 1447 | if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) { | 1531 | if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) { |
| 1448 | __base_pointer __f = __i.__ptr_; | 1532 | __base_pointer __f = __i.__ptr_; |
| 1449 | __base::__unlink_nodes(__f, __f); | 1533 | __base::__unlink_nodes(__f, __f); |
| ... | @@ -1454,7 +1538,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i | ... | @@ -1454,7 +1538,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i |
| 1454 | } | 1538 | } |
| 1455 | 1539 | ||
| 1456 | template <class _Tp, class _Alloc> | 1540 | template <class _Tp, class _Alloc> |
| 1457 | void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) { | 1541 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void |
| 1542 | list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) { | ||
| 1458 | if (__f != __l) { | 1543 | if (__f != __l) { |
| 1459 | __base_pointer __first = __f.__ptr_; | 1544 | __base_pointer __first = __f.__ptr_; |
| 1460 | --__l; | 1545 | --__l; |
| ... | @@ -1470,7 +1555,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f | ... | @@ -1470,7 +1555,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f |
| 1470 | } | 1555 | } |
| 1471 | 1556 | ||
| 1472 | template <class _Tp, class _Alloc> | 1557 | template <class _Tp, class _Alloc> |
| 1473 | typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const value_type& __x) { | 1558 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type |
| 1559 | list<_Tp, _Alloc>::remove(const value_type& __x) { | ||
| 1474 | list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing | 1560 | list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing |
| 1475 | for (const_iterator __i = begin(), __e = end(); __i != __e;) { | 1561 | for (const_iterator __i = begin(), __e = end(); __i != __e;) { |
| 1476 | if (*__i == __x) { | 1562 | if (*__i == __x) { |
| ... | @@ -1490,7 +1576,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const | ... | @@ -1490,7 +1576,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const |
| 1490 | 1576 | ||
| 1491 | template <class _Tp, class _Alloc> | 1577 | template <class _Tp, class _Alloc> |
| 1492 | template <class _Pred> | 1578 | template <class _Pred> |
| 1493 | typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_Pred __pred) { | 1579 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type |
| 1580 | list<_Tp, _Alloc>::remove_if(_Pred __pred) { | ||
| 1494 | list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing | 1581 | list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing |
| 1495 | for (iterator __i = begin(), __e = end(); __i != __e;) { | 1582 | for (iterator __i = begin(), __e = end(); __i != __e;) { |
| 1496 | if (__pred(*__i)) { | 1583 | if (__pred(*__i)) { |
| ... | @@ -1510,7 +1597,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_P | ... | @@ -1510,7 +1597,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_P |
| 1510 | 1597 | ||
| 1511 | template <class _Tp, class _Alloc> | 1598 | template <class _Tp, class _Alloc> |
| 1512 | template <class _BinaryPred> | 1599 | template <class _BinaryPred> |
| 1513 | typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred) { | 1600 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type |
| 1601 | list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred) { | ||
| 1514 | list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing | 1602 | list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing |
| 1515 | for (iterator __i = begin(), __e = end(); __i != __e;) { | 1603 | for (iterator __i = begin(), __e = end(); __i != __e;) { |
| 1516 | iterator __j = std::next(__i); | 1604 | iterator __j = std::next(__i); |
| ... | @@ -1526,13 +1614,13 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_Bina | ... | @@ -1526,13 +1614,13 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_Bina |
| 1526 | } | 1614 | } |
| 1527 | 1615 | ||
| 1528 | template <class _Tp, class _Alloc> | 1616 | template <class _Tp, class _Alloc> |
| 1529 | inline void list<_Tp, _Alloc>::merge(list& __c) { | 1617 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::merge(list& __c) { |
| 1530 | merge(__c, __less<>()); | 1618 | merge(__c, __less<>()); |
| 1531 | } | 1619 | } |
| 1532 | 1620 | ||
| 1533 | template <class _Tp, class _Alloc> | 1621 | template <class _Tp, class _Alloc> |
| 1534 | template <class _Comp> | 1622 | template <class _Comp> |
| 1535 | void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { | 1623 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { |
| 1536 | if (this != std::addressof(__c)) { | 1624 | if (this != std::addressof(__c)) { |
| 1537 | iterator __f1 = begin(); | 1625 | iterator __f1 = begin(); |
| 1538 | iterator __e1 = end(); | 1626 | iterator __e1 = end(); |
| ... | @@ -1561,19 +1649,19 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { | ... | @@ -1561,19 +1649,19 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { |
| 1561 | } | 1649 | } |
| 1562 | 1650 | ||
| 1563 | template <class _Tp, class _Alloc> | 1651 | template <class _Tp, class _Alloc> |
| 1564 | inline void list<_Tp, _Alloc>::sort() { | 1652 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::sort() { |
| 1565 | sort(__less<>()); | 1653 | sort(__less<>()); |
| 1566 | } | 1654 | } |
| 1567 | 1655 | ||
| 1568 | template <class _Tp, class _Alloc> | 1656 | template <class _Tp, class _Alloc> |
| 1569 | template <class _Comp> | 1657 | template <class _Comp> |
| 1570 | inline void list<_Tp, _Alloc>::sort(_Comp __comp) { | 1658 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::sort(_Comp __comp) { |
| 1571 | __sort(begin(), end(), this->__size_, __comp); | 1659 | __sort(begin(), end(), this->__size_, __comp); |
| 1572 | } | 1660 | } |
| 1573 | 1661 | ||
| 1574 | template <class _Tp, class _Alloc> | 1662 | template <class _Tp, class _Alloc> |
| 1575 | template <class _Comp> | 1663 | template <class _Comp> |
| 1576 | typename list<_Tp, _Alloc>::iterator | 1664 | _LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator |
| 1577 | list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp) { | 1665 | list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp) { |
| 1578 | switch (__n) { | 1666 | switch (__n) { |
| 1579 | case 0: | 1667 | case 0: |
| ... | @@ -1627,7 +1715,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ | ... | @@ -1627,7 +1715,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ |
| 1627 | } | 1715 | } |
| 1628 | 1716 | ||
| 1629 | template <class _Tp, class _Alloc> | 1717 | template <class _Tp, class _Alloc> |
| 1630 | void list<_Tp, _Alloc>::reverse() _NOEXCEPT { | 1718 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::reverse() _NOEXCEPT { |
| 1631 | if (this->__size_ > 1) { | 1719 | if (this->__size_ > 1) { |
| 1632 | iterator __e = end(); | 1720 | iterator __e = end(); |
| 1633 | for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) { | 1721 | for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) { |
| ... | @@ -1639,46 +1727,52 @@ void list<_Tp, _Alloc>::reverse() _NOEXCEPT { | ... | @@ -1639,46 +1727,52 @@ void list<_Tp, _Alloc>::reverse() _NOEXCEPT { |
| 1639 | } | 1727 | } |
| 1640 | 1728 | ||
| 1641 | template <class _Tp, class _Alloc> | 1729 | template <class _Tp, class _Alloc> |
| 1642 | bool list<_Tp, _Alloc>::__invariants() const { | 1730 | _LIBCPP_CONSTEXPR_SINCE_CXX26 bool list<_Tp, _Alloc>::__invariants() const { |
| 1643 | return size() == std::distance(begin(), end()); | 1731 | return size() == std::distance(begin(), end()); |
| 1644 | } | 1732 | } |
| 1645 | 1733 | ||
| 1646 | template <class _Tp, class _Alloc> | 1734 | template <class _Tp, class _Alloc> |
| 1647 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | 1735 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1736 | operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | ||
| 1648 | return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); | 1737 | return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
| 1649 | } | 1738 | } |
| 1650 | 1739 | ||
| 1651 | # if _LIBCPP_STD_VER <= 17 | 1740 | # if _LIBCPP_STD_VER <= 17 |
| 1652 | 1741 | ||
| 1653 | template <class _Tp, class _Alloc> | 1742 | template <class _Tp, class _Alloc> |
| 1654 | inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | 1743 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1744 | operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | ||
| 1655 | return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); | 1745 | return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
| 1656 | } | 1746 | } |
| 1657 | 1747 | ||
| 1658 | template <class _Tp, class _Alloc> | 1748 | template <class _Tp, class _Alloc> |
| 1659 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | 1749 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1750 | operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | ||
| 1660 | return !(__x == __y); | 1751 | return !(__x == __y); |
| 1661 | } | 1752 | } |
| 1662 | 1753 | ||
| 1663 | template <class _Tp, class _Alloc> | 1754 | template <class _Tp, class _Alloc> |
| 1664 | inline _LIBCPP_HIDE_FROM_ABI bool operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | 1755 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1756 | operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | ||
| 1665 | return __y < __x; | 1757 | return __y < __x; |
| 1666 | } | 1758 | } |
| 1667 | 1759 | ||
| 1668 | template <class _Tp, class _Alloc> | 1760 | template <class _Tp, class _Alloc> |
| 1669 | inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | 1761 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1762 | operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | ||
| 1670 | return !(__x < __y); | 1763 | return !(__x < __y); |
| 1671 | } | 1764 | } |
| 1672 | 1765 | ||
| 1673 | template <class _Tp, class _Alloc> | 1766 | template <class _Tp, class _Alloc> |
| 1674 | inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | 1767 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool |
| 1768 | operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { | ||
| 1675 | return !(__y < __x); | 1769 | return !(__y < __x); |
| 1676 | } | 1770 | } |
| 1677 | 1771 | ||
| 1678 | # else // _LIBCPP_STD_VER <= 17 | 1772 | # else // _LIBCPP_STD_VER <= 17 |
| 1679 | 1773 | ||
| 1680 | template <class _Tp, class _Allocator> | 1774 | template <class _Tp, class _Allocator> |
| 1681 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> | 1775 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| 1682 | operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) { | 1776 | operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) { |
| 1683 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 1777 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1684 | } | 1778 | } |
| ... | @@ -1686,22 +1780,22 @@ operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) | ... | @@ -1686,22 +1780,22 @@ operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) |
| 1686 | # endif // _LIBCPP_STD_VER <= 17 | 1780 | # endif // _LIBCPP_STD_VER <= 17 |
| 1687 | 1781 | ||
| 1688 | template <class _Tp, class _Alloc> | 1782 | template <class _Tp, class _Alloc> |
| 1689 | inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) | 1783 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) |
| 1690 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 1784 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 1691 | __x.swap(__y); | 1785 | __x.swap(__y); |
| 1692 | } | 1786 | } |
| 1693 | 1787 | ||
| 1694 | # if _LIBCPP_STD_VER >= 20 | 1788 | # if _LIBCPP_STD_VER >= 20 |
| 1695 | template <class _Tp, class _Allocator, class _Predicate> | 1789 | template <class _Tp, class _Allocator, class _Predicate> |
| 1696 | inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type | 1790 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type |
| 1697 | erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) { | 1791 | erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 1698 | return __c.remove_if(__pred); | 1792 | return __c.remove_if(__pred); |
| 1699 | } | 1793 | } |
| 1700 | 1794 | ||
| 1701 | template <class _Tp, class _Allocator, class _Up> | 1795 | template <class _Tp, class _Allocator, class _Up> |
| 1702 | inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type | 1796 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type |
| 1703 | erase(list<_Tp, _Allocator>& __c, const _Up& __v) { | 1797 | erase(list<_Tp, _Allocator>& __c, const _Up& __v) { |
| 1704 | return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); | 1798 | return std::erase_if(__c, [&](const auto& __elem) -> bool { return __elem == __v; }); |
| 1705 | } | 1799 | } |
| 1706 | 1800 | ||
| 1707 | template <> | 1801 | template <> |
| ... | @@ -1722,6 +1816,8 @@ struct __container_traits<list<_Tp, _Allocator> > { | ... | @@ -1722,6 +1816,8 @@ struct __container_traits<list<_Tp, _Allocator> > { |
| 1722 | // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that | 1816 | // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that |
| 1723 | // function has no effects. | 1817 | // function has no effects. |
| 1724 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | 1818 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; |
| 1819 | |||
| 1820 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 1725 | }; | 1821 | }; |
| 1726 | 1822 | ||
| 1727 | _LIBCPP_END_NAMESPACE_STD | 1823 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/locale+7-3487| ... | @@ -194,3501 +194,20 @@ template <class charT> class messages_byname; | ... | @@ -194,3501 +194,20 @@ template <class charT> class messages_byname; |
| 194 | 194 | ||
| 195 | # if _LIBCPP_HAS_LOCALIZATION | 195 | # if _LIBCPP_HAS_LOCALIZATION |
| 196 | 196 | ||
| 197 | # include <__algorithm/copy.h> | ||
| 198 | # include <__algorithm/equal.h> | ||
| 199 | # include <__algorithm/find.h> | ||
| 200 | # include <__algorithm/max.h> | ||
| 201 | # include <__algorithm/reverse.h> | ||
| 202 | # include <__algorithm/unwrap_iter.h> | ||
| 203 | # include <__assert> | ||
| 204 | # include <__iterator/access.h> | ||
| 205 | # include <__iterator/back_insert_iterator.h> | ||
| 206 | # include <__iterator/istreambuf_iterator.h> | ||
| 207 | # include <__iterator/ostreambuf_iterator.h> | ||
| 208 | # include <__locale> | 197 | # include <__locale> |
| 209 | # include <__locale_dir/pad_and_output.h> | 198 | # include <__locale_dir/messages.h> |
| 210 | # include <__memory/unique_ptr.h> | 199 | # include <__locale_dir/money.h> |
| 211 | # include <__new/exceptions.h> | 200 | # include <__locale_dir/num.h> |
| 212 | # include <__type_traits/make_unsigned.h> | 201 | # include <__locale_dir/time.h> |
| 213 | # include <cerrno> | 202 | # include <__locale_dir/wbuffer_convert.h> |
| 214 | # include <cstdio> | 203 | # include <__locale_dir/wstring_convert.h> |
| 215 | # include <cstdlib> | ||
| 216 | # include <ctime> | ||
| 217 | # include <ios> | 204 | # include <ios> |
| 218 | # include <limits> | ||
| 219 | # include <streambuf> | ||
| 220 | # include <version> | 205 | # include <version> |
| 221 | 206 | ||
| 222 | // TODO: Properly qualify calls now that the locale base API defines functions instead of macros | ||
| 223 | // NOLINTBEGIN(libcpp-robust-against-adl) | ||
| 224 | |||
| 225 | # if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) | ||
| 226 | // Most unix variants have catopen. These are the specific ones that don't. | ||
| 227 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) | ||
| 228 | # define _LIBCPP_HAS_CATOPEN 1 | ||
| 229 | # include <nl_types.h> | ||
| 230 | # else | ||
| 231 | # define _LIBCPP_HAS_CATOPEN 0 | ||
| 232 | # endif | ||
| 233 | # else | ||
| 234 | # define _LIBCPP_HAS_CATOPEN 0 | ||
| 235 | # endif | ||
| 236 | |||
| 237 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 207 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 238 | # pragma GCC system_header | 208 | # pragma GCC system_header |
| 239 | # endif | 209 | # endif |
| 240 | 210 | ||
| 241 | _LIBCPP_PUSH_MACROS | ||
| 242 | # include <__undef_macros> | ||
| 243 | |||
| 244 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 245 | |||
| 246 | # if defined(__APPLE__) || defined(__FreeBSD__) | ||
| 247 | # define _LIBCPP_GET_C_LOCALE 0 | ||
| 248 | # elif defined(__NetBSD__) | ||
| 249 | # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE | ||
| 250 | # else | ||
| 251 | # define _LIBCPP_GET_C_LOCALE __cloc() | ||
| 252 | // Get the C locale object | ||
| 253 | _LIBCPP_EXPORTED_FROM_ABI __locale::__locale_t __cloc(); | ||
| 254 | # define __cloc_defined | ||
| 255 | # endif | ||
| 256 | |||
| 257 | // __scan_keyword | ||
| 258 | // Scans [__b, __e) until a match is found in the basic_strings range | ||
| 259 | // [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke). | ||
| 260 | // __b will be incremented (visibly), consuming CharT until a match is found | ||
| 261 | // or proved to not exist. A keyword may be "", in which will match anything. | ||
| 262 | // If one keyword is a prefix of another, and the next CharT in the input | ||
| 263 | // might match another keyword, the algorithm will attempt to find the longest | ||
| 264 | // matching keyword. If the longer matching keyword ends up not matching, then | ||
| 265 | // no keyword match is found. If no keyword match is found, __ke is returned | ||
| 266 | // and failbit is set in __err. | ||
| 267 | // Else an iterator pointing to the matching keyword is found. If more than | ||
| 268 | // one keyword matches, an iterator to the first matching keyword is returned. | ||
| 269 | // If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false, | ||
| 270 | // __ct is used to force to lower case before comparing characters. | ||
| 271 | // Examples: | ||
| 272 | // Keywords: "a", "abb" | ||
| 273 | // If the input is "a", the first keyword matches and eofbit is set. | ||
| 274 | // If the input is "abc", no match is found and "ab" are consumed. | ||
| 275 | template <class _InputIterator, class _ForwardIterator, class _Ctype> | ||
| 276 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator __scan_keyword( | ||
| 277 | _InputIterator& __b, | ||
| 278 | _InputIterator __e, | ||
| 279 | _ForwardIterator __kb, | ||
| 280 | _ForwardIterator __ke, | ||
| 281 | const _Ctype& __ct, | ||
| 282 | ios_base::iostate& __err, | ||
| 283 | bool __case_sensitive = true) { | ||
| 284 | typedef typename iterator_traits<_InputIterator>::value_type _CharT; | ||
| 285 | size_t __nkw = static_cast<size_t>(std::distance(__kb, __ke)); | ||
| 286 | const unsigned char __doesnt_match = '\0'; | ||
| 287 | const unsigned char __might_match = '\1'; | ||
| 288 | const unsigned char __does_match = '\2'; | ||
| 289 | unsigned char __statbuf[100]; | ||
| 290 | unsigned char* __status = __statbuf; | ||
| 291 | unique_ptr<unsigned char, void (*)(void*)> __stat_hold(nullptr, free); | ||
| 292 | if (__nkw > sizeof(__statbuf)) { | ||
| 293 | __status = (unsigned char*)malloc(__nkw); | ||
| 294 | if (__status == nullptr) | ||
| 295 | __throw_bad_alloc(); | ||
| 296 | __stat_hold.reset(__status); | ||
| 297 | } | ||
| 298 | size_t __n_might_match = __nkw; // At this point, any keyword might match | ||
| 299 | size_t __n_does_match = 0; // but none of them definitely do | ||
| 300 | // Initialize all statuses to __might_match, except for "" keywords are __does_match | ||
| 301 | unsigned char* __st = __status; | ||
| 302 | for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) { | ||
| 303 | if (!__ky->empty()) | ||
| 304 | *__st = __might_match; | ||
| 305 | else { | ||
| 306 | *__st = __does_match; | ||
| 307 | --__n_might_match; | ||
| 308 | ++__n_does_match; | ||
| 309 | } | ||
| 310 | } | ||
| 311 | // While there might be a match, test keywords against the next CharT | ||
| 312 | for (size_t __indx = 0; __b != __e && __n_might_match > 0; ++__indx) { | ||
| 313 | // Peek at the next CharT but don't consume it | ||
| 314 | _CharT __c = *__b; | ||
| 315 | if (!__case_sensitive) | ||
| 316 | __c = __ct.toupper(__c); | ||
| 317 | bool __consume = false; | ||
| 318 | // For each keyword which might match, see if the __indx character is __c | ||
| 319 | // If a match if found, consume __c | ||
| 320 | // If a match is found, and that is the last character in the keyword, | ||
| 321 | // then that keyword matches. | ||
| 322 | // If the keyword doesn't match this character, then change the keyword | ||
| 323 | // to doesn't match | ||
| 324 | __st = __status; | ||
| 325 | for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) { | ||
| 326 | if (*__st == __might_match) { | ||
| 327 | _CharT __kc = (*__ky)[__indx]; | ||
| 328 | if (!__case_sensitive) | ||
| 329 | __kc = __ct.toupper(__kc); | ||
| 330 | if (__c == __kc) { | ||
| 331 | __consume = true; | ||
| 332 | if (__ky->size() == __indx + 1) { | ||
| 333 | *__st = __does_match; | ||
| 334 | --__n_might_match; | ||
| 335 | ++__n_does_match; | ||
| 336 | } | ||
| 337 | } else { | ||
| 338 | *__st = __doesnt_match; | ||
| 339 | --__n_might_match; | ||
| 340 | } | ||
| 341 | } | ||
| 342 | } | ||
| 343 | // consume if we matched a character | ||
| 344 | if (__consume) { | ||
| 345 | ++__b; | ||
| 346 | // If we consumed a character and there might be a matched keyword that | ||
| 347 | // was marked matched on a previous iteration, then such keywords | ||
| 348 | // which are now marked as not matching. | ||
| 349 | if (__n_might_match + __n_does_match > 1) { | ||
| 350 | __st = __status; | ||
| 351 | for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) { | ||
| 352 | if (*__st == __does_match && __ky->size() != __indx + 1) { | ||
| 353 | *__st = __doesnt_match; | ||
| 354 | --__n_does_match; | ||
| 355 | } | ||
| 356 | } | ||
| 357 | } | ||
| 358 | } | ||
| 359 | } | ||
| 360 | // We've exited the loop because we hit eof and/or we have no more "might matches". | ||
| 361 | if (__b == __e) | ||
| 362 | __err |= ios_base::eofbit; | ||
| 363 | // Return the first matching result | ||
| 364 | for (__st = __status; __kb != __ke; ++__kb, (void)++__st) | ||
| 365 | if (*__st == __does_match) | ||
| 366 | break; | ||
| 367 | if (__kb == __ke) | ||
| 368 | __err |= ios_base::failbit; | ||
| 369 | return __kb; | ||
| 370 | } | ||
| 371 | |||
| 372 | struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base { | ||
| 373 | static const int __num_get_buf_sz = 40; | ||
| 374 | |||
| 375 | static int __get_base(ios_base&); | ||
| 376 | static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN" | ||
| 377 | // count of leading characters in __src used for parsing integers ("012..X+-") | ||
| 378 | static const size_t __int_chr_cnt = 26; | ||
| 379 | // count of leading characters in __src used for parsing floating-point values ("012..-pP") | ||
| 380 | static const size_t __fp_chr_cnt = 28; | ||
| 381 | }; | ||
| 382 | |||
| 383 | _LIBCPP_EXPORTED_FROM_ABI void | ||
| 384 | __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err); | ||
| 385 | |||
| 386 | template <class _CharT> | ||
| 387 | struct __num_get : protected __num_get_base { | ||
| 388 | static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep); | ||
| 389 | |||
| 390 | static int __stage2_float_loop( | ||
| 391 | _CharT __ct, | ||
| 392 | bool& __in_units, | ||
| 393 | char& __exp, | ||
| 394 | char* __a, | ||
| 395 | char*& __a_end, | ||
| 396 | _CharT __decimal_point, | ||
| 397 | _CharT __thousands_sep, | ||
| 398 | const string& __grouping, | ||
| 399 | unsigned* __g, | ||
| 400 | unsigned*& __g_end, | ||
| 401 | unsigned& __dc, | ||
| 402 | _CharT* __atoms); | ||
| 403 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | ||
| 404 | static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); | ||
| 405 | static int __stage2_int_loop( | ||
| 406 | _CharT __ct, | ||
| 407 | int __base, | ||
| 408 | char* __a, | ||
| 409 | char*& __a_end, | ||
| 410 | unsigned& __dc, | ||
| 411 | _CharT __thousands_sep, | ||
| 412 | const string& __grouping, | ||
| 413 | unsigned* __g, | ||
| 414 | unsigned*& __g_end, | ||
| 415 | _CharT* __atoms); | ||
| 416 | |||
| 417 | # else | ||
| 418 | static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { | ||
| 419 | locale __loc = __iob.getloc(); | ||
| 420 | const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); | ||
| 421 | __thousands_sep = __np.thousands_sep(); | ||
| 422 | return __np.grouping(); | ||
| 423 | } | ||
| 424 | |||
| 425 | const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const { return __do_widen_p(__iob, __atoms); } | ||
| 426 | |||
| 427 | static int __stage2_int_loop( | ||
| 428 | _CharT __ct, | ||
| 429 | int __base, | ||
| 430 | char* __a, | ||
| 431 | char*& __a_end, | ||
| 432 | unsigned& __dc, | ||
| 433 | _CharT __thousands_sep, | ||
| 434 | const string& __grouping, | ||
| 435 | unsigned* __g, | ||
| 436 | unsigned*& __g_end, | ||
| 437 | const _CharT* __atoms); | ||
| 438 | |||
| 439 | private: | ||
| 440 | template <typename _Tp> | ||
| 441 | const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const { | ||
| 442 | locale __loc = __iob.getloc(); | ||
| 443 | use_facet<ctype<_Tp> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms); | ||
| 444 | return __atoms; | ||
| 445 | } | ||
| 446 | |||
| 447 | const char* __do_widen_p(ios_base& __iob, char* __atoms) const { | ||
| 448 | (void)__iob; | ||
| 449 | (void)__atoms; | ||
| 450 | return __src; | ||
| 451 | } | ||
| 452 | # endif | ||
| 453 | }; | ||
| 454 | |||
| 455 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | ||
| 456 | template <class _CharT> | ||
| 457 | string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { | ||
| 458 | locale __loc = __iob.getloc(); | ||
| 459 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms); | ||
| 460 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 461 | __thousands_sep = __np.thousands_sep(); | ||
| 462 | return __np.grouping(); | ||
| 463 | } | ||
| 464 | # endif | ||
| 465 | |||
| 466 | template <class _CharT> | ||
| 467 | string __num_get<_CharT>::__stage2_float_prep( | ||
| 468 | ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) { | ||
| 469 | locale __loc = __iob.getloc(); | ||
| 470 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __fp_chr_cnt, __atoms); | ||
| 471 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 472 | __decimal_point = __np.decimal_point(); | ||
| 473 | __thousands_sep = __np.thousands_sep(); | ||
| 474 | return __np.grouping(); | ||
| 475 | } | ||
| 476 | |||
| 477 | template <class _CharT> | ||
| 478 | int | ||
| 479 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | ||
| 480 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, | ||
| 481 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, | ||
| 482 | unsigned* __g, unsigned*& __g_end, _CharT* __atoms) | ||
| 483 | # else | ||
| 484 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, | ||
| 485 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, | ||
| 486 | unsigned* __g, unsigned*& __g_end, const _CharT* __atoms) | ||
| 487 | |||
| 488 | # endif | ||
| 489 | { | ||
| 490 | if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { | ||
| 491 | *__a_end++ = __ct == __atoms[24] ? '+' : '-'; | ||
| 492 | __dc = 0; | ||
| 493 | return 0; | ||
| 494 | } | ||
| 495 | if (__grouping.size() != 0 && __ct == __thousands_sep) { | ||
| 496 | if (__g_end - __g < __num_get_buf_sz) { | ||
| 497 | *__g_end++ = __dc; | ||
| 498 | __dc = 0; | ||
| 499 | } | ||
| 500 | return 0; | ||
| 501 | } | ||
| 502 | ptrdiff_t __f = std::find(__atoms, __atoms + __int_chr_cnt, __ct) - __atoms; | ||
| 503 | if (__f >= 24) | ||
| 504 | return -1; | ||
| 505 | switch (__base) { | ||
| 506 | case 8: | ||
| 507 | case 10: | ||
| 508 | if (__f >= __base) | ||
| 509 | return -1; | ||
| 510 | break; | ||
| 511 | case 16: | ||
| 512 | if (__f < 22) | ||
| 513 | break; | ||
| 514 | if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0') { | ||
| 515 | __dc = 0; | ||
| 516 | *__a_end++ = __src[__f]; | ||
| 517 | return 0; | ||
| 518 | } | ||
| 519 | return -1; | ||
| 520 | } | ||
| 521 | *__a_end++ = __src[__f]; | ||
| 522 | ++__dc; | ||
| 523 | return 0; | ||
| 524 | } | ||
| 525 | |||
| 526 | template <class _CharT> | ||
| 527 | int __num_get<_CharT>::__stage2_float_loop( | ||
| 528 | _CharT __ct, | ||
| 529 | bool& __in_units, | ||
| 530 | char& __exp, | ||
| 531 | char* __a, | ||
| 532 | char*& __a_end, | ||
| 533 | _CharT __decimal_point, | ||
| 534 | _CharT __thousands_sep, | ||
| 535 | const string& __grouping, | ||
| 536 | unsigned* __g, | ||
| 537 | unsigned*& __g_end, | ||
| 538 | unsigned& __dc, | ||
| 539 | _CharT* __atoms) { | ||
| 540 | if (__ct == __decimal_point) { | ||
| 541 | if (!__in_units) | ||
| 542 | return -1; | ||
| 543 | __in_units = false; | ||
| 544 | *__a_end++ = '.'; | ||
| 545 | if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz) | ||
| 546 | *__g_end++ = __dc; | ||
| 547 | return 0; | ||
| 548 | } | ||
| 549 | if (__ct == __thousands_sep && __grouping.size() != 0) { | ||
| 550 | if (!__in_units) | ||
| 551 | return -1; | ||
| 552 | if (__g_end - __g < __num_get_buf_sz) { | ||
| 553 | *__g_end++ = __dc; | ||
| 554 | __dc = 0; | ||
| 555 | } | ||
| 556 | return 0; | ||
| 557 | } | ||
| 558 | ptrdiff_t __f = std::find(__atoms, __atoms + __num_get_base::__fp_chr_cnt, __ct) - __atoms; | ||
| 559 | if (__f >= static_cast<ptrdiff_t>(__num_get_base::__fp_chr_cnt)) | ||
| 560 | return -1; | ||
| 561 | char __x = __src[__f]; | ||
| 562 | if (__x == '-' || __x == '+') { | ||
| 563 | if (__a_end == __a || (std::toupper(__a_end[-1]) == std::toupper(__exp))) { | ||
| 564 | *__a_end++ = __x; | ||
| 565 | return 0; | ||
| 566 | } | ||
| 567 | return -1; | ||
| 568 | } | ||
| 569 | if (__x == 'x' || __x == 'X') | ||
| 570 | __exp = 'P'; | ||
| 571 | else if (std::toupper(__x) == __exp) { | ||
| 572 | __exp = std::tolower(__exp); | ||
| 573 | if (__in_units) { | ||
| 574 | __in_units = false; | ||
| 575 | if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz) | ||
| 576 | *__g_end++ = __dc; | ||
| 577 | } | ||
| 578 | } | ||
| 579 | *__a_end++ = __x; | ||
| 580 | if (__f >= 22) | ||
| 581 | return 0; | ||
| 582 | ++__dc; | ||
| 583 | return 0; | ||
| 584 | } | ||
| 585 | |||
| 586 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>; | ||
| 587 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 588 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>; | ||
| 589 | # endif | ||
| 590 | |||
| 591 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | ||
| 592 | class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> { | ||
| 593 | public: | ||
| 594 | typedef _CharT char_type; | ||
| 595 | typedef _InputIterator iter_type; | ||
| 596 | |||
| 597 | _LIBCPP_HIDE_FROM_ABI explicit num_get(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 598 | |||
| 599 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 600 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const { | ||
| 601 | return do_get(__b, __e, __iob, __err, __v); | ||
| 602 | } | ||
| 603 | |||
| 604 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 605 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { | ||
| 606 | return do_get(__b, __e, __iob, __err, __v); | ||
| 607 | } | ||
| 608 | |||
| 609 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 610 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { | ||
| 611 | return do_get(__b, __e, __iob, __err, __v); | ||
| 612 | } | ||
| 613 | |||
| 614 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 615 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { | ||
| 616 | return do_get(__b, __e, __iob, __err, __v); | ||
| 617 | } | ||
| 618 | |||
| 619 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 620 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { | ||
| 621 | return do_get(__b, __e, __iob, __err, __v); | ||
| 622 | } | ||
| 623 | |||
| 624 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 625 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { | ||
| 626 | return do_get(__b, __e, __iob, __err, __v); | ||
| 627 | } | ||
| 628 | |||
| 629 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 630 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { | ||
| 631 | return do_get(__b, __e, __iob, __err, __v); | ||
| 632 | } | ||
| 633 | |||
| 634 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 635 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { | ||
| 636 | return do_get(__b, __e, __iob, __err, __v); | ||
| 637 | } | ||
| 638 | |||
| 639 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 640 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const { | ||
| 641 | return do_get(__b, __e, __iob, __err, __v); | ||
| 642 | } | ||
| 643 | |||
| 644 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 645 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 646 | return do_get(__b, __e, __iob, __err, __v); | ||
| 647 | } | ||
| 648 | |||
| 649 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 650 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { | ||
| 651 | return do_get(__b, __e, __iob, __err, __v); | ||
| 652 | } | ||
| 653 | |||
| 654 | static locale::id id; | ||
| 655 | |||
| 656 | protected: | ||
| 657 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_get() override {} | ||
| 658 | |||
| 659 | template <class _Fp> | ||
| 660 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type | ||
| 661 | __do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const; | ||
| 662 | |||
| 663 | template <class _Signed> | ||
| 664 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type | ||
| 665 | __do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const; | ||
| 666 | |||
| 667 | template <class _Unsigned> | ||
| 668 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type | ||
| 669 | __do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const; | ||
| 670 | |||
| 671 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; | ||
| 672 | |||
| 673 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { | ||
| 674 | return this->__do_get_signed(__b, __e, __iob, __err, __v); | ||
| 675 | } | ||
| 676 | |||
| 677 | virtual iter_type | ||
| 678 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { | ||
| 679 | return this->__do_get_signed(__b, __e, __iob, __err, __v); | ||
| 680 | } | ||
| 681 | |||
| 682 | virtual iter_type | ||
| 683 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { | ||
| 684 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 685 | } | ||
| 686 | |||
| 687 | virtual iter_type | ||
| 688 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { | ||
| 689 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 690 | } | ||
| 691 | |||
| 692 | virtual iter_type | ||
| 693 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { | ||
| 694 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 695 | } | ||
| 696 | |||
| 697 | virtual iter_type | ||
| 698 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { | ||
| 699 | return this->__do_get_unsigned(__b, __e, __iob, __err, __v); | ||
| 700 | } | ||
| 701 | |||
| 702 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { | ||
| 703 | return this->__do_get_floating_point(__b, __e, __iob, __err, __v); | ||
| 704 | } | ||
| 705 | |||
| 706 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const { | ||
| 707 | return this->__do_get_floating_point(__b, __e, __iob, __err, __v); | ||
| 708 | } | ||
| 709 | |||
| 710 | virtual iter_type | ||
| 711 | do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 712 | return this->__do_get_floating_point(__b, __e, __iob, __err, __v); | ||
| 713 | } | ||
| 714 | |||
| 715 | virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const; | ||
| 716 | }; | ||
| 717 | |||
| 718 | template <class _CharT, class _InputIterator> | ||
| 719 | locale::id num_get<_CharT, _InputIterator>::id; | ||
| 720 | |||
| 721 | template <class _Tp> | ||
| 722 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 723 | __num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) { | ||
| 724 | if (__a != __a_end) { | ||
| 725 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; | ||
| 726 | errno = 0; | ||
| 727 | char* __p2; | ||
| 728 | long long __ll = __locale::__strtoll(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | ||
| 729 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; | ||
| 730 | if (__current_errno == 0) | ||
| 731 | errno = __save_errno; | ||
| 732 | if (__p2 != __a_end) { | ||
| 733 | __err = ios_base::failbit; | ||
| 734 | return 0; | ||
| 735 | } else if (__current_errno == ERANGE || __ll < numeric_limits<_Tp>::min() || numeric_limits<_Tp>::max() < __ll) { | ||
| 736 | __err = ios_base::failbit; | ||
| 737 | if (__ll > 0) | ||
| 738 | return numeric_limits<_Tp>::max(); | ||
| 739 | else | ||
| 740 | return numeric_limits<_Tp>::min(); | ||
| 741 | } | ||
| 742 | return static_cast<_Tp>(__ll); | ||
| 743 | } | ||
| 744 | __err = ios_base::failbit; | ||
| 745 | return 0; | ||
| 746 | } | ||
| 747 | |||
| 748 | template <class _Tp> | ||
| 749 | _LIBCPP_HIDE_FROM_ABI _Tp | ||
| 750 | __num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) { | ||
| 751 | if (__a != __a_end) { | ||
| 752 | const bool __negate = *__a == '-'; | ||
| 753 | if (__negate && ++__a == __a_end) { | ||
| 754 | __err = ios_base::failbit; | ||
| 755 | return 0; | ||
| 756 | } | ||
| 757 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; | ||
| 758 | errno = 0; | ||
| 759 | char* __p2; | ||
| 760 | unsigned long long __ll = __locale::__strtoull(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | ||
| 761 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; | ||
| 762 | if (__current_errno == 0) | ||
| 763 | errno = __save_errno; | ||
| 764 | if (__p2 != __a_end) { | ||
| 765 | __err = ios_base::failbit; | ||
| 766 | return 0; | ||
| 767 | } else if (__current_errno == ERANGE || numeric_limits<_Tp>::max() < __ll) { | ||
| 768 | __err = ios_base::failbit; | ||
| 769 | return numeric_limits<_Tp>::max(); | ||
| 770 | } | ||
| 771 | _Tp __res = static_cast<_Tp>(__ll); | ||
| 772 | if (__negate) | ||
| 773 | __res = -__res; | ||
| 774 | return __res; | ||
| 775 | } | ||
| 776 | __err = ios_base::failbit; | ||
| 777 | return 0; | ||
| 778 | } | ||
| 779 | |||
| 780 | template <class _Tp> | ||
| 781 | _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2); | ||
| 782 | |||
| 783 | template <> | ||
| 784 | inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) { | ||
| 785 | return __locale::__strtof(__a, __p2, _LIBCPP_GET_C_LOCALE); | ||
| 786 | } | ||
| 787 | |||
| 788 | template <> | ||
| 789 | inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) { | ||
| 790 | return __locale::__strtod(__a, __p2, _LIBCPP_GET_C_LOCALE); | ||
| 791 | } | ||
| 792 | |||
| 793 | template <> | ||
| 794 | inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) { | ||
| 795 | return __locale::__strtold(__a, __p2, _LIBCPP_GET_C_LOCALE); | ||
| 796 | } | ||
| 797 | |||
| 798 | template <class _Tp> | ||
| 799 | _LIBCPP_HIDE_FROM_ABI _Tp __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) { | ||
| 800 | if (__a != __a_end) { | ||
| 801 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; | ||
| 802 | errno = 0; | ||
| 803 | char* __p2; | ||
| 804 | _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2); | ||
| 805 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; | ||
| 806 | if (__current_errno == 0) | ||
| 807 | errno = __save_errno; | ||
| 808 | if (__p2 != __a_end) { | ||
| 809 | __err = ios_base::failbit; | ||
| 810 | return 0; | ||
| 811 | } else if (__current_errno == ERANGE) | ||
| 812 | __err = ios_base::failbit; | ||
| 813 | return __ld; | ||
| 814 | } | ||
| 815 | __err = ios_base::failbit; | ||
| 816 | return 0; | ||
| 817 | } | ||
| 818 | |||
| 819 | template <class _CharT, class _InputIterator> | ||
| 820 | _InputIterator num_get<_CharT, _InputIterator>::do_get( | ||
| 821 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const { | ||
| 822 | if ((__iob.flags() & ios_base::boolalpha) == 0) { | ||
| 823 | long __lv = -1; | ||
| 824 | __b = do_get(__b, __e, __iob, __err, __lv); | ||
| 825 | switch (__lv) { | ||
| 826 | case 0: | ||
| 827 | __v = false; | ||
| 828 | break; | ||
| 829 | case 1: | ||
| 830 | __v = true; | ||
| 831 | break; | ||
| 832 | default: | ||
| 833 | __v = true; | ||
| 834 | __err = ios_base::failbit; | ||
| 835 | break; | ||
| 836 | } | ||
| 837 | return __b; | ||
| 838 | } | ||
| 839 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__iob.getloc()); | ||
| 840 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__iob.getloc()); | ||
| 841 | typedef typename numpunct<_CharT>::string_type string_type; | ||
| 842 | const string_type __names[2] = {__np.truename(), __np.falsename()}; | ||
| 843 | const string_type* __i = std::__scan_keyword(__b, __e, __names, __names + 2, __ct, __err); | ||
| 844 | __v = __i == __names; | ||
| 845 | return __b; | ||
| 846 | } | ||
| 847 | |||
| 848 | // signed | ||
| 849 | |||
| 850 | template <class _CharT, class _InputIterator> | ||
| 851 | template <class _Signed> | ||
| 852 | _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed( | ||
| 853 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const { | ||
| 854 | // Stage 1 | ||
| 855 | int __base = this->__get_base(__iob); | ||
| 856 | // Stage 2 | ||
| 857 | char_type __thousands_sep; | ||
| 858 | const int __atoms_size = __num_get_base::__int_chr_cnt; | ||
| 859 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | ||
| 860 | char_type __atoms1[__atoms_size]; | ||
| 861 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | ||
| 862 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | ||
| 863 | # else | ||
| 864 | char_type __atoms[__atoms_size]; | ||
| 865 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); | ||
| 866 | # endif | ||
| 867 | string __buf; | ||
| 868 | __buf.resize(__buf.capacity()); | ||
| 869 | char* __a = &__buf[0]; | ||
| 870 | char* __a_end = __a; | ||
| 871 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 872 | unsigned* __g_end = __g; | ||
| 873 | unsigned __dc = 0; | ||
| 874 | for (; __b != __e; ++__b) { | ||
| 875 | if (__a_end == __a + __buf.size()) { | ||
| 876 | size_t __tmp = __buf.size(); | ||
| 877 | __buf.resize(2 * __buf.size()); | ||
| 878 | __buf.resize(__buf.capacity()); | ||
| 879 | __a = &__buf[0]; | ||
| 880 | __a_end = __a + __tmp; | ||
| 881 | } | ||
| 882 | if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) | ||
| 883 | break; | ||
| 884 | } | ||
| 885 | if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz) | ||
| 886 | *__g_end++ = __dc; | ||
| 887 | // Stage 3 | ||
| 888 | __v = std::__num_get_signed_integral<_Signed>(__a, __a_end, __err, __base); | ||
| 889 | // Digit grouping checked | ||
| 890 | __check_grouping(__grouping, __g, __g_end, __err); | ||
| 891 | // EOF checked | ||
| 892 | if (__b == __e) | ||
| 893 | __err |= ios_base::eofbit; | ||
| 894 | return __b; | ||
| 895 | } | ||
| 896 | |||
| 897 | // unsigned | ||
| 898 | |||
| 899 | template <class _CharT, class _InputIterator> | ||
| 900 | template <class _Unsigned> | ||
| 901 | _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned( | ||
| 902 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const { | ||
| 903 | // Stage 1 | ||
| 904 | int __base = this->__get_base(__iob); | ||
| 905 | // Stage 2 | ||
| 906 | char_type __thousands_sep; | ||
| 907 | const int __atoms_size = __num_get_base::__int_chr_cnt; | ||
| 908 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | ||
| 909 | char_type __atoms1[__atoms_size]; | ||
| 910 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); | ||
| 911 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); | ||
| 912 | # else | ||
| 913 | char_type __atoms[__atoms_size]; | ||
| 914 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); | ||
| 915 | # endif | ||
| 916 | string __buf; | ||
| 917 | __buf.resize(__buf.capacity()); | ||
| 918 | char* __a = &__buf[0]; | ||
| 919 | char* __a_end = __a; | ||
| 920 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 921 | unsigned* __g_end = __g; | ||
| 922 | unsigned __dc = 0; | ||
| 923 | for (; __b != __e; ++__b) { | ||
| 924 | if (__a_end == __a + __buf.size()) { | ||
| 925 | size_t __tmp = __buf.size(); | ||
| 926 | __buf.resize(2 * __buf.size()); | ||
| 927 | __buf.resize(__buf.capacity()); | ||
| 928 | __a = &__buf[0]; | ||
| 929 | __a_end = __a + __tmp; | ||
| 930 | } | ||
| 931 | if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) | ||
| 932 | break; | ||
| 933 | } | ||
| 934 | if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz) | ||
| 935 | *__g_end++ = __dc; | ||
| 936 | // Stage 3 | ||
| 937 | __v = std::__num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base); | ||
| 938 | // Digit grouping checked | ||
| 939 | __check_grouping(__grouping, __g, __g_end, __err); | ||
| 940 | // EOF checked | ||
| 941 | if (__b == __e) | ||
| 942 | __err |= ios_base::eofbit; | ||
| 943 | return __b; | ||
| 944 | } | ||
| 945 | |||
| 946 | // floating point | ||
| 947 | |||
| 948 | template <class _CharT, class _InputIterator> | ||
| 949 | template <class _Fp> | ||
| 950 | _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point( | ||
| 951 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const { | ||
| 952 | // Stage 1, nothing to do | ||
| 953 | // Stage 2 | ||
| 954 | char_type __atoms[__num_get_base::__fp_chr_cnt]; | ||
| 955 | char_type __decimal_point; | ||
| 956 | char_type __thousands_sep; | ||
| 957 | string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep); | ||
| 958 | string __buf; | ||
| 959 | __buf.resize(__buf.capacity()); | ||
| 960 | char* __a = &__buf[0]; | ||
| 961 | char* __a_end = __a; | ||
| 962 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 963 | unsigned* __g_end = __g; | ||
| 964 | unsigned __dc = 0; | ||
| 965 | bool __in_units = true; | ||
| 966 | char __exp = 'E'; | ||
| 967 | bool __is_leading_parsed = false; | ||
| 968 | for (; __b != __e; ++__b) { | ||
| 969 | if (__a_end == __a + __buf.size()) { | ||
| 970 | size_t __tmp = __buf.size(); | ||
| 971 | __buf.resize(2 * __buf.size()); | ||
| 972 | __buf.resize(__buf.capacity()); | ||
| 973 | __a = &__buf[0]; | ||
| 974 | __a_end = __a + __tmp; | ||
| 975 | } | ||
| 976 | if (this->__stage2_float_loop( | ||
| 977 | *__b, | ||
| 978 | __in_units, | ||
| 979 | __exp, | ||
| 980 | __a, | ||
| 981 | __a_end, | ||
| 982 | __decimal_point, | ||
| 983 | __thousands_sep, | ||
| 984 | __grouping, | ||
| 985 | __g, | ||
| 986 | __g_end, | ||
| 987 | __dc, | ||
| 988 | __atoms)) | ||
| 989 | break; | ||
| 990 | |||
| 991 | // the leading character excluding the sign must be a decimal digit | ||
| 992 | if (!__is_leading_parsed) { | ||
| 993 | if (__a_end - __a >= 1 && __a[0] != '-' && __a[0] != '+') { | ||
| 994 | if (('0' <= __a[0] && __a[0] <= '9') || __a[0] == '.') | ||
| 995 | __is_leading_parsed = true; | ||
| 996 | else | ||
| 997 | break; | ||
| 998 | } else if (__a_end - __a >= 2 && (__a[0] == '-' || __a[0] == '+')) { | ||
| 999 | if (('0' <= __a[1] && __a[1] <= '9') || __a[1] == '.') | ||
| 1000 | __is_leading_parsed = true; | ||
| 1001 | else | ||
| 1002 | break; | ||
| 1003 | } | ||
| 1004 | } | ||
| 1005 | } | ||
| 1006 | if (__grouping.size() != 0 && __in_units && __g_end - __g < __num_get_base::__num_get_buf_sz) | ||
| 1007 | *__g_end++ = __dc; | ||
| 1008 | // Stage 3 | ||
| 1009 | __v = std::__num_get_float<_Fp>(__a, __a_end, __err); | ||
| 1010 | // Digit grouping checked | ||
| 1011 | __check_grouping(__grouping, __g, __g_end, __err); | ||
| 1012 | // EOF checked | ||
| 1013 | if (__b == __e) | ||
| 1014 | __err |= ios_base::eofbit; | ||
| 1015 | return __b; | ||
| 1016 | } | ||
| 1017 | |||
| 1018 | template <class _CharT, class _InputIterator> | ||
| 1019 | _InputIterator num_get<_CharT, _InputIterator>::do_get( | ||
| 1020 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { | ||
| 1021 | // Stage 1 | ||
| 1022 | int __base = 16; | ||
| 1023 | // Stage 2 | ||
| 1024 | char_type __atoms[__num_get_base::__int_chr_cnt]; | ||
| 1025 | char_type __thousands_sep = char_type(); | ||
| 1026 | string __grouping; | ||
| 1027 | std::use_facet<ctype<_CharT> >(__iob.getloc()) | ||
| 1028 | .widen(__num_get_base::__src, __num_get_base::__src + __num_get_base::__int_chr_cnt, __atoms); | ||
| 1029 | string __buf; | ||
| 1030 | __buf.resize(__buf.capacity()); | ||
| 1031 | char* __a = &__buf[0]; | ||
| 1032 | char* __a_end = __a; | ||
| 1033 | unsigned __g[__num_get_base::__num_get_buf_sz]; | ||
| 1034 | unsigned* __g_end = __g; | ||
| 1035 | unsigned __dc = 0; | ||
| 1036 | for (; __b != __e; ++__b) { | ||
| 1037 | if (__a_end == __a + __buf.size()) { | ||
| 1038 | size_t __tmp = __buf.size(); | ||
| 1039 | __buf.resize(2 * __buf.size()); | ||
| 1040 | __buf.resize(__buf.capacity()); | ||
| 1041 | __a = &__buf[0]; | ||
| 1042 | __a_end = __a + __tmp; | ||
| 1043 | } | ||
| 1044 | if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) | ||
| 1045 | break; | ||
| 1046 | } | ||
| 1047 | // Stage 3 | ||
| 1048 | __buf.resize(__a_end - __a); | ||
| 1049 | if (__locale::__sscanf(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) | ||
| 1050 | __err = ios_base::failbit; | ||
| 1051 | // EOF checked | ||
| 1052 | if (__b == __e) | ||
| 1053 | __err |= ios_base::eofbit; | ||
| 1054 | return __b; | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; | ||
| 1058 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 1059 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>; | ||
| 1060 | # endif | ||
| 1061 | |||
| 1062 | struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base { | ||
| 1063 | protected: | ||
| 1064 | static void __format_int(char* __fmt, const char* __len, bool __signd, ios_base::fmtflags __flags); | ||
| 1065 | static bool __format_float(char* __fmt, const char* __len, ios_base::fmtflags __flags); | ||
| 1066 | static char* __identify_padding(char* __nb, char* __ne, const ios_base& __iob); | ||
| 1067 | }; | ||
| 1068 | |||
| 1069 | template <class _CharT> | ||
| 1070 | struct __num_put : protected __num_put_base { | ||
| 1071 | static void __widen_and_group_int( | ||
| 1072 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc); | ||
| 1073 | static void __widen_and_group_float( | ||
| 1074 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc); | ||
| 1075 | }; | ||
| 1076 | |||
| 1077 | template <class _CharT> | ||
| 1078 | void __num_put<_CharT>::__widen_and_group_int( | ||
| 1079 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { | ||
| 1080 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc); | ||
| 1081 | const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 1082 | string __grouping = __npt.grouping(); | ||
| 1083 | if (__grouping.empty()) { | ||
| 1084 | __ct.widen(__nb, __ne, __ob); | ||
| 1085 | __oe = __ob + (__ne - __nb); | ||
| 1086 | } else { | ||
| 1087 | __oe = __ob; | ||
| 1088 | char* __nf = __nb; | ||
| 1089 | if (*__nf == '-' || *__nf == '+') | ||
| 1090 | *__oe++ = __ct.widen(*__nf++); | ||
| 1091 | if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) { | ||
| 1092 | *__oe++ = __ct.widen(*__nf++); | ||
| 1093 | *__oe++ = __ct.widen(*__nf++); | ||
| 1094 | } | ||
| 1095 | std::reverse(__nf, __ne); | ||
| 1096 | _CharT __thousands_sep = __npt.thousands_sep(); | ||
| 1097 | unsigned __dc = 0; | ||
| 1098 | unsigned __dg = 0; | ||
| 1099 | for (char* __p = __nf; __p < __ne; ++__p) { | ||
| 1100 | if (static_cast<unsigned>(__grouping[__dg]) > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) { | ||
| 1101 | *__oe++ = __thousands_sep; | ||
| 1102 | __dc = 0; | ||
| 1103 | if (__dg < __grouping.size() - 1) | ||
| 1104 | ++__dg; | ||
| 1105 | } | ||
| 1106 | *__oe++ = __ct.widen(*__p); | ||
| 1107 | ++__dc; | ||
| 1108 | } | ||
| 1109 | std::reverse(__ob + (__nf - __nb), __oe); | ||
| 1110 | } | ||
| 1111 | if (__np == __ne) | ||
| 1112 | __op = __oe; | ||
| 1113 | else | ||
| 1114 | __op = __ob + (__np - __nb); | ||
| 1115 | } | ||
| 1116 | |||
| 1117 | template <class _CharT> | ||
| 1118 | void __num_put<_CharT>::__widen_and_group_float( | ||
| 1119 | char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { | ||
| 1120 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc); | ||
| 1121 | const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 1122 | string __grouping = __npt.grouping(); | ||
| 1123 | __oe = __ob; | ||
| 1124 | char* __nf = __nb; | ||
| 1125 | if (*__nf == '-' || *__nf == '+') | ||
| 1126 | *__oe++ = __ct.widen(*__nf++); | ||
| 1127 | char* __ns; | ||
| 1128 | if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) { | ||
| 1129 | *__oe++ = __ct.widen(*__nf++); | ||
| 1130 | *__oe++ = __ct.widen(*__nf++); | ||
| 1131 | for (__ns = __nf; __ns < __ne; ++__ns) | ||
| 1132 | if (!__locale::__isxdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | ||
| 1133 | break; | ||
| 1134 | } else { | ||
| 1135 | for (__ns = __nf; __ns < __ne; ++__ns) | ||
| 1136 | if (!__locale::__isdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | ||
| 1137 | break; | ||
| 1138 | } | ||
| 1139 | if (__grouping.empty()) { | ||
| 1140 | __ct.widen(__nf, __ns, __oe); | ||
| 1141 | __oe += __ns - __nf; | ||
| 1142 | } else { | ||
| 1143 | std::reverse(__nf, __ns); | ||
| 1144 | _CharT __thousands_sep = __npt.thousands_sep(); | ||
| 1145 | unsigned __dc = 0; | ||
| 1146 | unsigned __dg = 0; | ||
| 1147 | for (char* __p = __nf; __p < __ns; ++__p) { | ||
| 1148 | if (__grouping[__dg] > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) { | ||
| 1149 | *__oe++ = __thousands_sep; | ||
| 1150 | __dc = 0; | ||
| 1151 | if (__dg < __grouping.size() - 1) | ||
| 1152 | ++__dg; | ||
| 1153 | } | ||
| 1154 | *__oe++ = __ct.widen(*__p); | ||
| 1155 | ++__dc; | ||
| 1156 | } | ||
| 1157 | std::reverse(__ob + (__nf - __nb), __oe); | ||
| 1158 | } | ||
| 1159 | for (__nf = __ns; __nf < __ne; ++__nf) { | ||
| 1160 | if (*__nf == '.') { | ||
| 1161 | *__oe++ = __npt.decimal_point(); | ||
| 1162 | ++__nf; | ||
| 1163 | break; | ||
| 1164 | } else | ||
| 1165 | *__oe++ = __ct.widen(*__nf); | ||
| 1166 | } | ||
| 1167 | __ct.widen(__nf, __ne, __oe); | ||
| 1168 | __oe += __ne - __nf; | ||
| 1169 | if (__np == __ne) | ||
| 1170 | __op = __oe; | ||
| 1171 | else | ||
| 1172 | __op = __ob + (__np - __nb); | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>; | ||
| 1176 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 1177 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>; | ||
| 1178 | # endif | ||
| 1179 | |||
| 1180 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 1181 | class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> { | ||
| 1182 | public: | ||
| 1183 | typedef _CharT char_type; | ||
| 1184 | typedef _OutputIterator iter_type; | ||
| 1185 | |||
| 1186 | _LIBCPP_HIDE_FROM_ABI explicit num_put(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 1187 | |||
| 1188 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const { | ||
| 1189 | return do_put(__s, __iob, __fl, __v); | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const { | ||
| 1193 | return do_put(__s, __iob, __fl, __v); | ||
| 1194 | } | ||
| 1195 | |||
| 1196 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const { | ||
| 1197 | return do_put(__s, __iob, __fl, __v); | ||
| 1198 | } | ||
| 1199 | |||
| 1200 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const { | ||
| 1201 | return do_put(__s, __iob, __fl, __v); | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const { | ||
| 1205 | return do_put(__s, __iob, __fl, __v); | ||
| 1206 | } | ||
| 1207 | |||
| 1208 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const { | ||
| 1209 | return do_put(__s, __iob, __fl, __v); | ||
| 1210 | } | ||
| 1211 | |||
| 1212 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const { | ||
| 1213 | return do_put(__s, __iob, __fl, __v); | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const { | ||
| 1217 | return do_put(__s, __iob, __fl, __v); | ||
| 1218 | } | ||
| 1219 | |||
| 1220 | static locale::id id; | ||
| 1221 | |||
| 1222 | protected: | ||
| 1223 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_put() override {} | ||
| 1224 | |||
| 1225 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const; | ||
| 1226 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const; | ||
| 1227 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const; | ||
| 1228 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long) const; | ||
| 1229 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long) const; | ||
| 1230 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const; | ||
| 1231 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const; | ||
| 1232 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const; | ||
| 1233 | |||
| 1234 | template <class _Integral> | ||
| 1235 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator | ||
| 1236 | __do_put_integral(iter_type __s, ios_base& __iob, char_type __fl, _Integral __v, char const* __len) const; | ||
| 1237 | |||
| 1238 | template <class _Float> | ||
| 1239 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator | ||
| 1240 | __do_put_floating_point(iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const; | ||
| 1241 | }; | ||
| 1242 | |||
| 1243 | template <class _CharT, class _OutputIterator> | ||
| 1244 | locale::id num_put<_CharT, _OutputIterator>::id; | ||
| 1245 | |||
| 1246 | template <class _CharT, class _OutputIterator> | ||
| 1247 | _OutputIterator | ||
| 1248 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const { | ||
| 1249 | if ((__iob.flags() & ios_base::boolalpha) == 0) | ||
| 1250 | return do_put(__s, __iob, __fl, (unsigned long)__v); | ||
| 1251 | const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc()); | ||
| 1252 | typedef typename numpunct<char_type>::string_type string_type; | ||
| 1253 | string_type __nm = __v ? __np.truename() : __np.falsename(); | ||
| 1254 | for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s) | ||
| 1255 | *__s = *__i; | ||
| 1256 | return __s; | ||
| 1257 | } | ||
| 1258 | |||
| 1259 | template <class _CharT, class _OutputIterator> | ||
| 1260 | template <class _Integral> | ||
| 1261 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_integral( | ||
| 1262 | iter_type __s, ios_base& __iob, char_type __fl, _Integral __v, char const* __len) const { | ||
| 1263 | // Stage 1 - Get number in narrow char | ||
| 1264 | char __fmt[8] = {'%', 0}; | ||
| 1265 | this->__format_int(__fmt + 1, __len, is_signed<_Integral>::value, __iob.flags()); | ||
| 1266 | // Worst case is octal, with showbase enabled. Note that octal is always | ||
| 1267 | // printed as an unsigned value. | ||
| 1268 | using _Unsigned = typename make_unsigned<_Integral>::type; | ||
| 1269 | _LIBCPP_CONSTEXPR const unsigned __nbuf = | ||
| 1270 | (numeric_limits<_Unsigned>::digits / 3) // 1 char per 3 bits | ||
| 1271 | + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up | ||
| 1272 | + 2; // base prefix + terminating null character | ||
| 1273 | char __nar[__nbuf]; | ||
| 1274 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 1275 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | ||
| 1276 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | ||
| 1277 | int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); | ||
| 1278 | _LIBCPP_DIAGNOSTIC_POP | ||
| 1279 | char* __ne = __nar + __nc; | ||
| 1280 | char* __np = this->__identify_padding(__nar, __ne, __iob); | ||
| 1281 | // Stage 2 - Widen __nar while adding thousands separators | ||
| 1282 | char_type __o[2 * (__nbuf - 1) - 1]; | ||
| 1283 | char_type* __op; // pad here | ||
| 1284 | char_type* __oe; // end of output | ||
| 1285 | this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); | ||
| 1286 | // [__o, __oe) contains thousands_sep'd wide number | ||
| 1287 | // Stage 3 & 4 | ||
| 1288 | return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl); | ||
| 1289 | } | ||
| 1290 | |||
| 1291 | template <class _CharT, class _OutputIterator> | ||
| 1292 | _OutputIterator | ||
| 1293 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const { | ||
| 1294 | return this->__do_put_integral(__s, __iob, __fl, __v, "l"); | ||
| 1295 | } | ||
| 1296 | |||
| 1297 | template <class _CharT, class _OutputIterator> | ||
| 1298 | _OutputIterator | ||
| 1299 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const { | ||
| 1300 | return this->__do_put_integral(__s, __iob, __fl, __v, "ll"); | ||
| 1301 | } | ||
| 1302 | |||
| 1303 | template <class _CharT, class _OutputIterator> | ||
| 1304 | _OutputIterator | ||
| 1305 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const { | ||
| 1306 | return this->__do_put_integral(__s, __iob, __fl, __v, "l"); | ||
| 1307 | } | ||
| 1308 | |||
| 1309 | template <class _CharT, class _OutputIterator> | ||
| 1310 | _OutputIterator | ||
| 1311 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const { | ||
| 1312 | return this->__do_put_integral(__s, __iob, __fl, __v, "ll"); | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | template <class _CharT, class _OutputIterator> | ||
| 1316 | template <class _Float> | ||
| 1317 | _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_floating_point( | ||
| 1318 | iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const { | ||
| 1319 | // Stage 1 - Get number in narrow char | ||
| 1320 | char __fmt[8] = {'%', 0}; | ||
| 1321 | bool __specify_precision = this->__format_float(__fmt + 1, __len, __iob.flags()); | ||
| 1322 | const unsigned __nbuf = 30; | ||
| 1323 | char __nar[__nbuf]; | ||
| 1324 | char* __nb = __nar; | ||
| 1325 | int __nc; | ||
| 1326 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 1327 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | ||
| 1328 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | ||
| 1329 | if (__specify_precision) | ||
| 1330 | __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | ||
| 1331 | else | ||
| 1332 | __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); | ||
| 1333 | unique_ptr<char, void (*)(void*)> __nbh(nullptr, free); | ||
| 1334 | if (__nc > static_cast<int>(__nbuf - 1)) { | ||
| 1335 | if (__specify_precision) | ||
| 1336 | __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | ||
| 1337 | else | ||
| 1338 | __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); | ||
| 1339 | if (__nc == -1) | ||
| 1340 | __throw_bad_alloc(); | ||
| 1341 | __nbh.reset(__nb); | ||
| 1342 | } | ||
| 1343 | _LIBCPP_DIAGNOSTIC_POP | ||
| 1344 | char* __ne = __nb + __nc; | ||
| 1345 | char* __np = this->__identify_padding(__nb, __ne, __iob); | ||
| 1346 | // Stage 2 - Widen __nar while adding thousands separators | ||
| 1347 | char_type __o[2 * (__nbuf - 1) - 1]; | ||
| 1348 | char_type* __ob = __o; | ||
| 1349 | unique_ptr<char_type, void (*)(void*)> __obh(0, free); | ||
| 1350 | if (__nb != __nar) { | ||
| 1351 | __ob = (char_type*)malloc(2 * static_cast<size_t>(__nc) * sizeof(char_type)); | ||
| 1352 | if (__ob == 0) | ||
| 1353 | __throw_bad_alloc(); | ||
| 1354 | __obh.reset(__ob); | ||
| 1355 | } | ||
| 1356 | char_type* __op; // pad here | ||
| 1357 | char_type* __oe; // end of output | ||
| 1358 | this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc()); | ||
| 1359 | // [__o, __oe) contains thousands_sep'd wide number | ||
| 1360 | // Stage 3 & 4 | ||
| 1361 | __s = std::__pad_and_output(__s, __ob, __op, __oe, __iob, __fl); | ||
| 1362 | return __s; | ||
| 1363 | } | ||
| 1364 | |||
| 1365 | template <class _CharT, class _OutputIterator> | ||
| 1366 | _OutputIterator | ||
| 1367 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const { | ||
| 1368 | return this->__do_put_floating_point(__s, __iob, __fl, __v, ""); | ||
| 1369 | } | ||
| 1370 | |||
| 1371 | template <class _CharT, class _OutputIterator> | ||
| 1372 | _OutputIterator | ||
| 1373 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const { | ||
| 1374 | return this->__do_put_floating_point(__s, __iob, __fl, __v, "L"); | ||
| 1375 | } | ||
| 1376 | |||
| 1377 | template <class _CharT, class _OutputIterator> | ||
| 1378 | _OutputIterator | ||
| 1379 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const { | ||
| 1380 | // Stage 1 - Get pointer in narrow char | ||
| 1381 | const unsigned __nbuf = 20; | ||
| 1382 | char __nar[__nbuf]; | ||
| 1383 | int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v); | ||
| 1384 | char* __ne = __nar + __nc; | ||
| 1385 | char* __np = this->__identify_padding(__nar, __ne, __iob); | ||
| 1386 | // Stage 2 - Widen __nar | ||
| 1387 | char_type __o[2 * (__nbuf - 1) - 1]; | ||
| 1388 | char_type* __op; // pad here | ||
| 1389 | char_type* __oe; // end of output | ||
| 1390 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 1391 | __ct.widen(__nar, __ne, __o); | ||
| 1392 | __oe = __o + (__ne - __nar); | ||
| 1393 | if (__np == __ne) | ||
| 1394 | __op = __oe; | ||
| 1395 | else | ||
| 1396 | __op = __o + (__np - __nar); | ||
| 1397 | // [__o, __oe) contains wide number | ||
| 1398 | // Stage 3 & 4 | ||
| 1399 | return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl); | ||
| 1400 | } | ||
| 1401 | |||
| 1402 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>; | ||
| 1403 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 1404 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>; | ||
| 1405 | # endif | ||
| 1406 | |||
| 1407 | template <class _CharT, class _InputIterator> | ||
| 1408 | _LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits( | ||
| 1409 | _InputIterator& __b, _InputIterator __e, ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n) { | ||
| 1410 | // Precondition: __n >= 1 | ||
| 1411 | if (__b == __e) { | ||
| 1412 | __err |= ios_base::eofbit | ios_base::failbit; | ||
| 1413 | return 0; | ||
| 1414 | } | ||
| 1415 | // get first digit | ||
| 1416 | _CharT __c = *__b; | ||
| 1417 | if (!__ct.is(ctype_base::digit, __c)) { | ||
| 1418 | __err |= ios_base::failbit; | ||
| 1419 | return 0; | ||
| 1420 | } | ||
| 1421 | int __r = __ct.narrow(__c, 0) - '0'; | ||
| 1422 | for (++__b, (void)--__n; __b != __e && __n > 0; ++__b, (void)--__n) { | ||
| 1423 | // get next digit | ||
| 1424 | __c = *__b; | ||
| 1425 | if (!__ct.is(ctype_base::digit, __c)) | ||
| 1426 | return __r; | ||
| 1427 | __r = __r * 10 + __ct.narrow(__c, 0) - '0'; | ||
| 1428 | } | ||
| 1429 | if (__b == __e) | ||
| 1430 | __err |= ios_base::eofbit; | ||
| 1431 | return __r; | ||
| 1432 | } | ||
| 1433 | |||
| 1434 | class _LIBCPP_EXPORTED_FROM_ABI time_base { | ||
| 1435 | public: | ||
| 1436 | enum dateorder { no_order, dmy, mdy, ymd, ydm }; | ||
| 1437 | }; | ||
| 1438 | |||
| 1439 | template <class _CharT> | ||
| 1440 | class _LIBCPP_TEMPLATE_VIS __time_get_c_storage { | ||
| 1441 | protected: | ||
| 1442 | typedef basic_string<_CharT> string_type; | ||
| 1443 | |||
| 1444 | virtual const string_type* __weeks() const; | ||
| 1445 | virtual const string_type* __months() const; | ||
| 1446 | virtual const string_type* __am_pm() const; | ||
| 1447 | virtual const string_type& __c() const; | ||
| 1448 | virtual const string_type& __r() const; | ||
| 1449 | virtual const string_type& __x() const; | ||
| 1450 | virtual const string_type& __X() const; | ||
| 1451 | |||
| 1452 | _LIBCPP_HIDE_FROM_ABI ~__time_get_c_storage() {} | ||
| 1453 | }; | ||
| 1454 | |||
| 1455 | template <> | ||
| 1456 | _LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__weeks() const; | ||
| 1457 | template <> | ||
| 1458 | _LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__months() const; | ||
| 1459 | template <> | ||
| 1460 | _LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__am_pm() const; | ||
| 1461 | template <> | ||
| 1462 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__c() const; | ||
| 1463 | template <> | ||
| 1464 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__r() const; | ||
| 1465 | template <> | ||
| 1466 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const; | ||
| 1467 | template <> | ||
| 1468 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const; | ||
| 1469 | |||
| 1470 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 1471 | template <> | ||
| 1472 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const; | ||
| 1473 | template <> | ||
| 1474 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__months() const; | ||
| 1475 | template <> | ||
| 1476 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__am_pm() const; | ||
| 1477 | template <> | ||
| 1478 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__c() const; | ||
| 1479 | template <> | ||
| 1480 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__r() const; | ||
| 1481 | template <> | ||
| 1482 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const; | ||
| 1483 | template <> | ||
| 1484 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const; | ||
| 1485 | # endif | ||
| 1486 | |||
| 1487 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | ||
| 1488 | class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { | ||
| 1489 | public: | ||
| 1490 | typedef _CharT char_type; | ||
| 1491 | typedef _InputIterator iter_type; | ||
| 1492 | typedef time_base::dateorder dateorder; | ||
| 1493 | typedef basic_string<char_type> string_type; | ||
| 1494 | |||
| 1495 | _LIBCPP_HIDE_FROM_ABI explicit time_get(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 1496 | |||
| 1497 | _LIBCPP_HIDE_FROM_ABI dateorder date_order() const { return this->do_date_order(); } | ||
| 1498 | |||
| 1499 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 1500 | get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1501 | return do_get_time(__b, __e, __iob, __err, __tm); | ||
| 1502 | } | ||
| 1503 | |||
| 1504 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 1505 | get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1506 | return do_get_date(__b, __e, __iob, __err, __tm); | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 1510 | get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1511 | return do_get_weekday(__b, __e, __iob, __err, __tm); | ||
| 1512 | } | ||
| 1513 | |||
| 1514 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 1515 | get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1516 | return do_get_monthname(__b, __e, __iob, __err, __tm); | ||
| 1517 | } | ||
| 1518 | |||
| 1519 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 1520 | get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1521 | return do_get_year(__b, __e, __iob, __err, __tm); | ||
| 1522 | } | ||
| 1523 | |||
| 1524 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 1525 | get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod = 0) | ||
| 1526 | const { | ||
| 1527 | return do_get(__b, __e, __iob, __err, __tm, __fmt, __mod); | ||
| 1528 | } | ||
| 1529 | |||
| 1530 | iter_type | ||
| 1531 | get(iter_type __b, | ||
| 1532 | iter_type __e, | ||
| 1533 | ios_base& __iob, | ||
| 1534 | ios_base::iostate& __err, | ||
| 1535 | tm* __tm, | ||
| 1536 | const char_type* __fmtb, | ||
| 1537 | const char_type* __fmte) const; | ||
| 1538 | |||
| 1539 | static locale::id id; | ||
| 1540 | |||
| 1541 | protected: | ||
| 1542 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get() override {} | ||
| 1543 | |||
| 1544 | virtual dateorder do_date_order() const; | ||
| 1545 | virtual iter_type | ||
| 1546 | do_get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 1547 | virtual iter_type | ||
| 1548 | do_get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 1549 | virtual iter_type | ||
| 1550 | do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 1551 | virtual iter_type | ||
| 1552 | do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 1553 | virtual iter_type | ||
| 1554 | do_get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; | ||
| 1555 | virtual iter_type do_get( | ||
| 1556 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod) const; | ||
| 1557 | |||
| 1558 | private: | ||
| 1559 | void __get_white_space(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1560 | void __get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1561 | |||
| 1562 | void __get_weekdayname( | ||
| 1563 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1564 | void __get_monthname( | ||
| 1565 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1566 | void __get_day(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1567 | void | ||
| 1568 | __get_month(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1569 | void | ||
| 1570 | __get_year(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1571 | void | ||
| 1572 | __get_year4(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1573 | void | ||
| 1574 | __get_hour(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1575 | void | ||
| 1576 | __get_12_hour(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1577 | void | ||
| 1578 | __get_am_pm(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1579 | void | ||
| 1580 | __get_minute(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1581 | void | ||
| 1582 | __get_second(int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1583 | void | ||
| 1584 | __get_weekday(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1585 | void __get_day_year_num( | ||
| 1586 | int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const; | ||
| 1587 | }; | ||
| 1588 | |||
| 1589 | template <class _CharT, class _InputIterator> | ||
| 1590 | locale::id time_get<_CharT, _InputIterator>::id; | ||
| 1591 | |||
| 1592 | // time_get primitives | ||
| 1593 | |||
| 1594 | template <class _CharT, class _InputIterator> | ||
| 1595 | void time_get<_CharT, _InputIterator>::__get_weekdayname( | ||
| 1596 | int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1597 | // Note: ignoring case comes from the POSIX strptime spec | ||
| 1598 | const string_type* __wk = this->__weeks(); | ||
| 1599 | ptrdiff_t __i = std::__scan_keyword(__b, __e, __wk, __wk + 14, __ct, __err, false) - __wk; | ||
| 1600 | if (__i < 14) | ||
| 1601 | __w = __i % 7; | ||
| 1602 | } | ||
| 1603 | |||
| 1604 | template <class _CharT, class _InputIterator> | ||
| 1605 | void time_get<_CharT, _InputIterator>::__get_monthname( | ||
| 1606 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1607 | // Note: ignoring case comes from the POSIX strptime spec | ||
| 1608 | const string_type* __month = this->__months(); | ||
| 1609 | ptrdiff_t __i = std::__scan_keyword(__b, __e, __month, __month + 24, __ct, __err, false) - __month; | ||
| 1610 | if (__i < 24) | ||
| 1611 | __m = __i % 12; | ||
| 1612 | } | ||
| 1613 | |||
| 1614 | template <class _CharT, class _InputIterator> | ||
| 1615 | void time_get<_CharT, _InputIterator>::__get_day( | ||
| 1616 | int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1617 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 1618 | if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31) | ||
| 1619 | __d = __t; | ||
| 1620 | else | ||
| 1621 | __err |= ios_base::failbit; | ||
| 1622 | } | ||
| 1623 | |||
| 1624 | template <class _CharT, class _InputIterator> | ||
| 1625 | void time_get<_CharT, _InputIterator>::__get_month( | ||
| 1626 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1627 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1; | ||
| 1628 | if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11) | ||
| 1629 | __m = __t; | ||
| 1630 | else | ||
| 1631 | __err |= ios_base::failbit; | ||
| 1632 | } | ||
| 1633 | |||
| 1634 | template <class _CharT, class _InputIterator> | ||
| 1635 | void time_get<_CharT, _InputIterator>::__get_year( | ||
| 1636 | int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1637 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4); | ||
| 1638 | if (!(__err & ios_base::failbit)) { | ||
| 1639 | if (__t < 69) | ||
| 1640 | __t += 2000; | ||
| 1641 | else if (69 <= __t && __t <= 99) | ||
| 1642 | __t += 1900; | ||
| 1643 | __y = __t - 1900; | ||
| 1644 | } | ||
| 1645 | } | ||
| 1646 | |||
| 1647 | template <class _CharT, class _InputIterator> | ||
| 1648 | void time_get<_CharT, _InputIterator>::__get_year4( | ||
| 1649 | int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1650 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4); | ||
| 1651 | if (!(__err & ios_base::failbit)) | ||
| 1652 | __y = __t - 1900; | ||
| 1653 | } | ||
| 1654 | |||
| 1655 | template <class _CharT, class _InputIterator> | ||
| 1656 | void time_get<_CharT, _InputIterator>::__get_hour( | ||
| 1657 | int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1658 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 1659 | if (!(__err & ios_base::failbit) && __t <= 23) | ||
| 1660 | __h = __t; | ||
| 1661 | else | ||
| 1662 | __err |= ios_base::failbit; | ||
| 1663 | } | ||
| 1664 | |||
| 1665 | template <class _CharT, class _InputIterator> | ||
| 1666 | void time_get<_CharT, _InputIterator>::__get_12_hour( | ||
| 1667 | int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1668 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 1669 | if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12) | ||
| 1670 | __h = __t; | ||
| 1671 | else | ||
| 1672 | __err |= ios_base::failbit; | ||
| 1673 | } | ||
| 1674 | |||
| 1675 | template <class _CharT, class _InputIterator> | ||
| 1676 | void time_get<_CharT, _InputIterator>::__get_minute( | ||
| 1677 | int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1678 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 1679 | if (!(__err & ios_base::failbit) && __t <= 59) | ||
| 1680 | __m = __t; | ||
| 1681 | else | ||
| 1682 | __err |= ios_base::failbit; | ||
| 1683 | } | ||
| 1684 | |||
| 1685 | template <class _CharT, class _InputIterator> | ||
| 1686 | void time_get<_CharT, _InputIterator>::__get_second( | ||
| 1687 | int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1688 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2); | ||
| 1689 | if (!(__err & ios_base::failbit) && __t <= 60) | ||
| 1690 | __s = __t; | ||
| 1691 | else | ||
| 1692 | __err |= ios_base::failbit; | ||
| 1693 | } | ||
| 1694 | |||
| 1695 | template <class _CharT, class _InputIterator> | ||
| 1696 | void time_get<_CharT, _InputIterator>::__get_weekday( | ||
| 1697 | int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1698 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 1); | ||
| 1699 | if (!(__err & ios_base::failbit) && __t <= 6) | ||
| 1700 | __w = __t; | ||
| 1701 | else | ||
| 1702 | __err |= ios_base::failbit; | ||
| 1703 | } | ||
| 1704 | |||
| 1705 | template <class _CharT, class _InputIterator> | ||
| 1706 | void time_get<_CharT, _InputIterator>::__get_day_year_num( | ||
| 1707 | int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1708 | int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 3); | ||
| 1709 | if (!(__err & ios_base::failbit) && __t <= 365) | ||
| 1710 | __d = __t; | ||
| 1711 | else | ||
| 1712 | __err |= ios_base::failbit; | ||
| 1713 | } | ||
| 1714 | |||
| 1715 | template <class _CharT, class _InputIterator> | ||
| 1716 | void time_get<_CharT, _InputIterator>::__get_white_space( | ||
| 1717 | iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1718 | for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b) | ||
| 1719 | ; | ||
| 1720 | if (__b == __e) | ||
| 1721 | __err |= ios_base::eofbit; | ||
| 1722 | } | ||
| 1723 | |||
| 1724 | template <class _CharT, class _InputIterator> | ||
| 1725 | void time_get<_CharT, _InputIterator>::__get_am_pm( | ||
| 1726 | int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1727 | const string_type* __ap = this->__am_pm(); | ||
| 1728 | if (__ap[0].size() + __ap[1].size() == 0) { | ||
| 1729 | __err |= ios_base::failbit; | ||
| 1730 | return; | ||
| 1731 | } | ||
| 1732 | ptrdiff_t __i = std::__scan_keyword(__b, __e, __ap, __ap + 2, __ct, __err, false) - __ap; | ||
| 1733 | if (__i == 0 && __h == 12) | ||
| 1734 | __h = 0; | ||
| 1735 | else if (__i == 1 && __h < 12) | ||
| 1736 | __h += 12; | ||
| 1737 | } | ||
| 1738 | |||
| 1739 | template <class _CharT, class _InputIterator> | ||
| 1740 | void time_get<_CharT, _InputIterator>::__get_percent( | ||
| 1741 | iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const { | ||
| 1742 | if (__b == __e) { | ||
| 1743 | __err |= ios_base::eofbit | ios_base::failbit; | ||
| 1744 | return; | ||
| 1745 | } | ||
| 1746 | if (__ct.narrow(*__b, 0) != '%') | ||
| 1747 | __err |= ios_base::failbit; | ||
| 1748 | else if (++__b == __e) | ||
| 1749 | __err |= ios_base::eofbit; | ||
| 1750 | } | ||
| 1751 | |||
| 1752 | // time_get end primitives | ||
| 1753 | |||
| 1754 | template <class _CharT, class _InputIterator> | ||
| 1755 | _InputIterator time_get<_CharT, _InputIterator>::get( | ||
| 1756 | iter_type __b, | ||
| 1757 | iter_type __e, | ||
| 1758 | ios_base& __iob, | ||
| 1759 | ios_base::iostate& __err, | ||
| 1760 | tm* __tm, | ||
| 1761 | const char_type* __fmtb, | ||
| 1762 | const char_type* __fmte) const { | ||
| 1763 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 1764 | __err = ios_base::goodbit; | ||
| 1765 | while (__fmtb != __fmte && __err == ios_base::goodbit) { | ||
| 1766 | if (__b == __e) { | ||
| 1767 | __err = ios_base::failbit; | ||
| 1768 | break; | ||
| 1769 | } | ||
| 1770 | if (__ct.narrow(*__fmtb, 0) == '%') { | ||
| 1771 | if (++__fmtb == __fmte) { | ||
| 1772 | __err = ios_base::failbit; | ||
| 1773 | break; | ||
| 1774 | } | ||
| 1775 | char __cmd = __ct.narrow(*__fmtb, 0); | ||
| 1776 | char __opt = '\0'; | ||
| 1777 | if (__cmd == 'E' || __cmd == '0') { | ||
| 1778 | if (++__fmtb == __fmte) { | ||
| 1779 | __err = ios_base::failbit; | ||
| 1780 | break; | ||
| 1781 | } | ||
| 1782 | __opt = __cmd; | ||
| 1783 | __cmd = __ct.narrow(*__fmtb, 0); | ||
| 1784 | } | ||
| 1785 | __b = do_get(__b, __e, __iob, __err, __tm, __cmd, __opt); | ||
| 1786 | ++__fmtb; | ||
| 1787 | } else if (__ct.is(ctype_base::space, *__fmtb)) { | ||
| 1788 | for (++__fmtb; __fmtb != __fmte && __ct.is(ctype_base::space, *__fmtb); ++__fmtb) | ||
| 1789 | ; | ||
| 1790 | for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b) | ||
| 1791 | ; | ||
| 1792 | } else if (__ct.toupper(*__b) == __ct.toupper(*__fmtb)) { | ||
| 1793 | ++__b; | ||
| 1794 | ++__fmtb; | ||
| 1795 | } else | ||
| 1796 | __err = ios_base::failbit; | ||
| 1797 | } | ||
| 1798 | if (__b == __e) | ||
| 1799 | __err |= ios_base::eofbit; | ||
| 1800 | return __b; | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | template <class _CharT, class _InputIterator> | ||
| 1804 | typename time_get<_CharT, _InputIterator>::dateorder time_get<_CharT, _InputIterator>::do_date_order() const { | ||
| 1805 | return mdy; | ||
| 1806 | } | ||
| 1807 | |||
| 1808 | template <class _CharT, class _InputIterator> | ||
| 1809 | _InputIterator time_get<_CharT, _InputIterator>::do_get_time( | ||
| 1810 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1811 | const char_type __fmt[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'}; | ||
| 1812 | return get(__b, __e, __iob, __err, __tm, __fmt, __fmt + sizeof(__fmt) / sizeof(__fmt[0])); | ||
| 1813 | } | ||
| 1814 | |||
| 1815 | template <class _CharT, class _InputIterator> | ||
| 1816 | _InputIterator time_get<_CharT, _InputIterator>::do_get_date( | ||
| 1817 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1818 | const string_type& __fmt = this->__x(); | ||
| 1819 | return get(__b, __e, __iob, __err, __tm, __fmt.data(), __fmt.data() + __fmt.size()); | ||
| 1820 | } | ||
| 1821 | |||
| 1822 | template <class _CharT, class _InputIterator> | ||
| 1823 | _InputIterator time_get<_CharT, _InputIterator>::do_get_weekday( | ||
| 1824 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1825 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 1826 | __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct); | ||
| 1827 | return __b; | ||
| 1828 | } | ||
| 1829 | |||
| 1830 | template <class _CharT, class _InputIterator> | ||
| 1831 | _InputIterator time_get<_CharT, _InputIterator>::do_get_monthname( | ||
| 1832 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1833 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 1834 | __get_monthname(__tm->tm_mon, __b, __e, __err, __ct); | ||
| 1835 | return __b; | ||
| 1836 | } | ||
| 1837 | |||
| 1838 | template <class _CharT, class _InputIterator> | ||
| 1839 | _InputIterator time_get<_CharT, _InputIterator>::do_get_year( | ||
| 1840 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { | ||
| 1841 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 1842 | __get_year(__tm->tm_year, __b, __e, __err, __ct); | ||
| 1843 | return __b; | ||
| 1844 | } | ||
| 1845 | |||
| 1846 | template <class _CharT, class _InputIterator> | ||
| 1847 | _InputIterator time_get<_CharT, _InputIterator>::do_get( | ||
| 1848 | iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char) const { | ||
| 1849 | __err = ios_base::goodbit; | ||
| 1850 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 1851 | switch (__fmt) { | ||
| 1852 | case 'a': | ||
| 1853 | case 'A': | ||
| 1854 | __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct); | ||
| 1855 | break; | ||
| 1856 | case 'b': | ||
| 1857 | case 'B': | ||
| 1858 | case 'h': | ||
| 1859 | __get_monthname(__tm->tm_mon, __b, __e, __err, __ct); | ||
| 1860 | break; | ||
| 1861 | case 'c': { | ||
| 1862 | const string_type& __fm = this->__c(); | ||
| 1863 | __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size()); | ||
| 1864 | } break; | ||
| 1865 | case 'd': | ||
| 1866 | case 'e': | ||
| 1867 | __get_day(__tm->tm_mday, __b, __e, __err, __ct); | ||
| 1868 | break; | ||
| 1869 | case 'D': { | ||
| 1870 | const char_type __fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'}; | ||
| 1871 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 1872 | } break; | ||
| 1873 | case 'F': { | ||
| 1874 | const char_type __fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'}; | ||
| 1875 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 1876 | } break; | ||
| 1877 | case 'H': | ||
| 1878 | __get_hour(__tm->tm_hour, __b, __e, __err, __ct); | ||
| 1879 | break; | ||
| 1880 | case 'I': | ||
| 1881 | __get_12_hour(__tm->tm_hour, __b, __e, __err, __ct); | ||
| 1882 | break; | ||
| 1883 | case 'j': | ||
| 1884 | __get_day_year_num(__tm->tm_yday, __b, __e, __err, __ct); | ||
| 1885 | break; | ||
| 1886 | case 'm': | ||
| 1887 | __get_month(__tm->tm_mon, __b, __e, __err, __ct); | ||
| 1888 | break; | ||
| 1889 | case 'M': | ||
| 1890 | __get_minute(__tm->tm_min, __b, __e, __err, __ct); | ||
| 1891 | break; | ||
| 1892 | case 'n': | ||
| 1893 | case 't': | ||
| 1894 | __get_white_space(__b, __e, __err, __ct); | ||
| 1895 | break; | ||
| 1896 | case 'p': | ||
| 1897 | __get_am_pm(__tm->tm_hour, __b, __e, __err, __ct); | ||
| 1898 | break; | ||
| 1899 | case 'r': { | ||
| 1900 | const char_type __fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'}; | ||
| 1901 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 1902 | } break; | ||
| 1903 | case 'R': { | ||
| 1904 | const char_type __fm[] = {'%', 'H', ':', '%', 'M'}; | ||
| 1905 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 1906 | } break; | ||
| 1907 | case 'S': | ||
| 1908 | __get_second(__tm->tm_sec, __b, __e, __err, __ct); | ||
| 1909 | break; | ||
| 1910 | case 'T': { | ||
| 1911 | const char_type __fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'}; | ||
| 1912 | __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0])); | ||
| 1913 | } break; | ||
| 1914 | case 'w': | ||
| 1915 | __get_weekday(__tm->tm_wday, __b, __e, __err, __ct); | ||
| 1916 | break; | ||
| 1917 | case 'x': | ||
| 1918 | return do_get_date(__b, __e, __iob, __err, __tm); | ||
| 1919 | case 'X': { | ||
| 1920 | const string_type& __fm = this->__X(); | ||
| 1921 | __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size()); | ||
| 1922 | } break; | ||
| 1923 | case 'y': | ||
| 1924 | __get_year(__tm->tm_year, __b, __e, __err, __ct); | ||
| 1925 | break; | ||
| 1926 | case 'Y': | ||
| 1927 | __get_year4(__tm->tm_year, __b, __e, __err, __ct); | ||
| 1928 | break; | ||
| 1929 | case '%': | ||
| 1930 | __get_percent(__b, __e, __err, __ct); | ||
| 1931 | break; | ||
| 1932 | default: | ||
| 1933 | __err |= ios_base::failbit; | ||
| 1934 | } | ||
| 1935 | return __b; | ||
| 1936 | } | ||
| 1937 | |||
| 1938 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>; | ||
| 1939 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 1940 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>; | ||
| 1941 | # endif | ||
| 1942 | |||
| 1943 | class _LIBCPP_EXPORTED_FROM_ABI __time_get { | ||
| 1944 | protected: | ||
| 1945 | __locale::__locale_t __loc_; | ||
| 1946 | |||
| 1947 | __time_get(const char* __nm); | ||
| 1948 | __time_get(const string& __nm); | ||
| 1949 | ~__time_get(); | ||
| 1950 | }; | ||
| 1951 | |||
| 1952 | template <class _CharT> | ||
| 1953 | class _LIBCPP_TEMPLATE_VIS __time_get_storage : public __time_get { | ||
| 1954 | protected: | ||
| 1955 | typedef basic_string<_CharT> string_type; | ||
| 1956 | |||
| 1957 | string_type __weeks_[14]; | ||
| 1958 | string_type __months_[24]; | ||
| 1959 | string_type __am_pm_[2]; | ||
| 1960 | string_type __c_; | ||
| 1961 | string_type __r_; | ||
| 1962 | string_type __x_; | ||
| 1963 | string_type __X_; | ||
| 1964 | |||
| 1965 | explicit __time_get_storage(const char* __nm); | ||
| 1966 | explicit __time_get_storage(const string& __nm); | ||
| 1967 | |||
| 1968 | _LIBCPP_HIDE_FROM_ABI ~__time_get_storage() {} | ||
| 1969 | |||
| 1970 | time_base::dateorder __do_date_order() const; | ||
| 1971 | |||
| 1972 | private: | ||
| 1973 | void init(const ctype<_CharT>&); | ||
| 1974 | string_type __analyze(char __fmt, const ctype<_CharT>&); | ||
| 1975 | }; | ||
| 1976 | |||
| 1977 | # define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ | ||
| 1978 | template <> \ | ||
| 1979 | _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ | ||
| 1980 | template <> \ | ||
| 1981 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | ||
| 1982 | template <> \ | ||
| 1983 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | ||
| 1984 | template <> \ | ||
| 1985 | _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | ||
| 1986 | template <> \ | ||
| 1987 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ | ||
| 1988 | char, const ctype<_CharT>&); \ | ||
| 1989 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ | ||
| 1990 | const; \ | ||
| 1991 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | ||
| 1992 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | ||
| 1993 | extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | ||
| 1994 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ | ||
| 1995 | __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ | ||
| 1996 | /**/ | ||
| 1997 | |||
| 1998 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) | ||
| 1999 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2000 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t) | ||
| 2001 | # endif | ||
| 2002 | # undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION | ||
| 2003 | |||
| 2004 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | ||
| 2005 | class _LIBCPP_TEMPLATE_VIS time_get_byname | ||
| 2006 | : public time_get<_CharT, _InputIterator>, | ||
| 2007 | private __time_get_storage<_CharT> { | ||
| 2008 | public: | ||
| 2009 | typedef time_base::dateorder dateorder; | ||
| 2010 | typedef _InputIterator iter_type; | ||
| 2011 | typedef _CharT char_type; | ||
| 2012 | typedef basic_string<char_type> string_type; | ||
| 2013 | |||
| 2014 | _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const char* __nm, size_t __refs = 0) | ||
| 2015 | : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {} | ||
| 2016 | _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const string& __nm, size_t __refs = 0) | ||
| 2017 | : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {} | ||
| 2018 | |||
| 2019 | protected: | ||
| 2020 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get_byname() override {} | ||
| 2021 | |||
| 2022 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL dateorder do_date_order() const override { return this->__do_date_order(); } | ||
| 2023 | |||
| 2024 | private: | ||
| 2025 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __weeks() const override { return this->__weeks_; } | ||
| 2026 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __months() const override { return this->__months_; } | ||
| 2027 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __am_pm() const override { return this->__am_pm_; } | ||
| 2028 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __c() const override { return this->__c_; } | ||
| 2029 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __r() const override { return this->__r_; } | ||
| 2030 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __x() const override { return this->__x_; } | ||
| 2031 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __X() const override { return this->__X_; } | ||
| 2032 | }; | ||
| 2033 | |||
| 2034 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>; | ||
| 2035 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2036 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>; | ||
| 2037 | # endif | ||
| 2038 | |||
| 2039 | class _LIBCPP_EXPORTED_FROM_ABI __time_put { | ||
| 2040 | __locale::__locale_t __loc_; | ||
| 2041 | |||
| 2042 | protected: | ||
| 2043 | _LIBCPP_HIDE_FROM_ABI __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {} | ||
| 2044 | __time_put(const char* __nm); | ||
| 2045 | __time_put(const string& __nm); | ||
| 2046 | ~__time_put(); | ||
| 2047 | void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; | ||
| 2048 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2049 | void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; | ||
| 2050 | # endif | ||
| 2051 | }; | ||
| 2052 | |||
| 2053 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 2054 | class _LIBCPP_TEMPLATE_VIS time_put : public locale::facet, private __time_put { | ||
| 2055 | public: | ||
| 2056 | typedef _CharT char_type; | ||
| 2057 | typedef _OutputIterator iter_type; | ||
| 2058 | |||
| 2059 | _LIBCPP_HIDE_FROM_ABI explicit time_put(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 2060 | |||
| 2061 | iter_type | ||
| 2062 | put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe) | ||
| 2063 | const; | ||
| 2064 | |||
| 2065 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 2066 | put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, char __fmt, char __mod = 0) const { | ||
| 2067 | return do_put(__s, __iob, __fl, __tm, __fmt, __mod); | ||
| 2068 | } | ||
| 2069 | |||
| 2070 | static locale::id id; | ||
| 2071 | |||
| 2072 | protected: | ||
| 2073 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put() override {} | ||
| 2074 | virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const; | ||
| 2075 | |||
| 2076 | _LIBCPP_HIDE_FROM_ABI explicit time_put(const char* __nm, size_t __refs) : locale::facet(__refs), __time_put(__nm) {} | ||
| 2077 | _LIBCPP_HIDE_FROM_ABI explicit time_put(const string& __nm, size_t __refs) | ||
| 2078 | : locale::facet(__refs), __time_put(__nm) {} | ||
| 2079 | }; | ||
| 2080 | |||
| 2081 | template <class _CharT, class _OutputIterator> | ||
| 2082 | locale::id time_put<_CharT, _OutputIterator>::id; | ||
| 2083 | |||
| 2084 | template <class _CharT, class _OutputIterator> | ||
| 2085 | _OutputIterator time_put<_CharT, _OutputIterator>::put( | ||
| 2086 | iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe) | ||
| 2087 | const { | ||
| 2088 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc()); | ||
| 2089 | for (; __pb != __pe; ++__pb) { | ||
| 2090 | if (__ct.narrow(*__pb, 0) == '%') { | ||
| 2091 | if (++__pb == __pe) { | ||
| 2092 | *__s++ = __pb[-1]; | ||
| 2093 | break; | ||
| 2094 | } | ||
| 2095 | char __mod = 0; | ||
| 2096 | char __fmt = __ct.narrow(*__pb, 0); | ||
| 2097 | if (__fmt == 'E' || __fmt == 'O') { | ||
| 2098 | if (++__pb == __pe) { | ||
| 2099 | *__s++ = __pb[-2]; | ||
| 2100 | *__s++ = __pb[-1]; | ||
| 2101 | break; | ||
| 2102 | } | ||
| 2103 | __mod = __fmt; | ||
| 2104 | __fmt = __ct.narrow(*__pb, 0); | ||
| 2105 | } | ||
| 2106 | __s = do_put(__s, __iob, __fl, __tm, __fmt, __mod); | ||
| 2107 | } else | ||
| 2108 | *__s++ = *__pb; | ||
| 2109 | } | ||
| 2110 | return __s; | ||
| 2111 | } | ||
| 2112 | |||
| 2113 | template <class _CharT, class _OutputIterator> | ||
| 2114 | _OutputIterator time_put<_CharT, _OutputIterator>::do_put( | ||
| 2115 | iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const { | ||
| 2116 | char_type __nar[100]; | ||
| 2117 | char_type* __nb = __nar; | ||
| 2118 | char_type* __ne = __nb + 100; | ||
| 2119 | __do_put(__nb, __ne, __tm, __fmt, __mod); | ||
| 2120 | return std::copy(__nb, __ne, __s); | ||
| 2121 | } | ||
| 2122 | |||
| 2123 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>; | ||
| 2124 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2125 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>; | ||
| 2126 | # endif | ||
| 2127 | |||
| 2128 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 2129 | class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> { | ||
| 2130 | public: | ||
| 2131 | _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const char* __nm, size_t __refs = 0) | ||
| 2132 | : time_put<_CharT, _OutputIterator>(__nm, __refs) {} | ||
| 2133 | |||
| 2134 | _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const string& __nm, size_t __refs = 0) | ||
| 2135 | : time_put<_CharT, _OutputIterator>(__nm, __refs) {} | ||
| 2136 | |||
| 2137 | protected: | ||
| 2138 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put_byname() override {} | ||
| 2139 | }; | ||
| 2140 | |||
| 2141 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>; | ||
| 2142 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2143 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>; | ||
| 2144 | # endif | ||
| 2145 | |||
| 2146 | // money_base | ||
| 2147 | |||
| 2148 | class _LIBCPP_EXPORTED_FROM_ABI money_base { | ||
| 2149 | public: | ||
| 2150 | enum part { none, space, symbol, sign, value }; | ||
| 2151 | struct pattern { | ||
| 2152 | char field[4]; | ||
| 2153 | }; | ||
| 2154 | |||
| 2155 | _LIBCPP_HIDE_FROM_ABI money_base() {} | ||
| 2156 | }; | ||
| 2157 | |||
| 2158 | // moneypunct | ||
| 2159 | |||
| 2160 | template <class _CharT, bool _International = false> | ||
| 2161 | class _LIBCPP_TEMPLATE_VIS moneypunct : public locale::facet, public money_base { | ||
| 2162 | public: | ||
| 2163 | typedef _CharT char_type; | ||
| 2164 | typedef basic_string<char_type> string_type; | ||
| 2165 | |||
| 2166 | _LIBCPP_HIDE_FROM_ABI explicit moneypunct(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 2167 | |||
| 2168 | _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); } | ||
| 2169 | _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); } | ||
| 2170 | _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); } | ||
| 2171 | _LIBCPP_HIDE_FROM_ABI string_type curr_symbol() const { return do_curr_symbol(); } | ||
| 2172 | _LIBCPP_HIDE_FROM_ABI string_type positive_sign() const { return do_positive_sign(); } | ||
| 2173 | _LIBCPP_HIDE_FROM_ABI string_type negative_sign() const { return do_negative_sign(); } | ||
| 2174 | _LIBCPP_HIDE_FROM_ABI int frac_digits() const { return do_frac_digits(); } | ||
| 2175 | _LIBCPP_HIDE_FROM_ABI pattern pos_format() const { return do_pos_format(); } | ||
| 2176 | _LIBCPP_HIDE_FROM_ABI pattern neg_format() const { return do_neg_format(); } | ||
| 2177 | |||
| 2178 | static locale::id id; | ||
| 2179 | static const bool intl = _International; | ||
| 2180 | |||
| 2181 | protected: | ||
| 2182 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct() override {} | ||
| 2183 | |||
| 2184 | virtual char_type do_decimal_point() const { return numeric_limits<char_type>::max(); } | ||
| 2185 | virtual char_type do_thousands_sep() const { return numeric_limits<char_type>::max(); } | ||
| 2186 | virtual string do_grouping() const { return string(); } | ||
| 2187 | virtual string_type do_curr_symbol() const { return string_type(); } | ||
| 2188 | virtual string_type do_positive_sign() const { return string_type(); } | ||
| 2189 | virtual string_type do_negative_sign() const { return string_type(1, '-'); } | ||
| 2190 | virtual int do_frac_digits() const { return 0; } | ||
| 2191 | virtual pattern do_pos_format() const { | ||
| 2192 | pattern __p = {{symbol, sign, none, value}}; | ||
| 2193 | return __p; | ||
| 2194 | } | ||
| 2195 | virtual pattern do_neg_format() const { | ||
| 2196 | pattern __p = {{symbol, sign, none, value}}; | ||
| 2197 | return __p; | ||
| 2198 | } | ||
| 2199 | }; | ||
| 2200 | |||
| 2201 | template <class _CharT, bool _International> | ||
| 2202 | locale::id moneypunct<_CharT, _International>::id; | ||
| 2203 | |||
| 2204 | template <class _CharT, bool _International> | ||
| 2205 | const bool moneypunct<_CharT, _International>::intl; | ||
| 2206 | |||
| 2207 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>; | ||
| 2208 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>; | ||
| 2209 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2210 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>; | ||
| 2211 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>; | ||
| 2212 | # endif | ||
| 2213 | |||
| 2214 | // moneypunct_byname | ||
| 2215 | |||
| 2216 | template <class _CharT, bool _International = false> | ||
| 2217 | class _LIBCPP_TEMPLATE_VIS moneypunct_byname : public moneypunct<_CharT, _International> { | ||
| 2218 | public: | ||
| 2219 | typedef money_base::pattern pattern; | ||
| 2220 | typedef _CharT char_type; | ||
| 2221 | typedef basic_string<char_type> string_type; | ||
| 2222 | |||
| 2223 | _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const char* __nm, size_t __refs = 0) | ||
| 2224 | : moneypunct<_CharT, _International>(__refs) { | ||
| 2225 | init(__nm); | ||
| 2226 | } | ||
| 2227 | |||
| 2228 | _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const string& __nm, size_t __refs = 0) | ||
| 2229 | : moneypunct<_CharT, _International>(__refs) { | ||
| 2230 | init(__nm.c_str()); | ||
| 2231 | } | ||
| 2232 | |||
| 2233 | protected: | ||
| 2234 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct_byname() override {} | ||
| 2235 | |||
| 2236 | char_type do_decimal_point() const override { return __decimal_point_; } | ||
| 2237 | char_type do_thousands_sep() const override { return __thousands_sep_; } | ||
| 2238 | string do_grouping() const override { return __grouping_; } | ||
| 2239 | string_type do_curr_symbol() const override { return __curr_symbol_; } | ||
| 2240 | string_type do_positive_sign() const override { return __positive_sign_; } | ||
| 2241 | string_type do_negative_sign() const override { return __negative_sign_; } | ||
| 2242 | int do_frac_digits() const override { return __frac_digits_; } | ||
| 2243 | pattern do_pos_format() const override { return __pos_format_; } | ||
| 2244 | pattern do_neg_format() const override { return __neg_format_; } | ||
| 2245 | |||
| 2246 | private: | ||
| 2247 | char_type __decimal_point_; | ||
| 2248 | char_type __thousands_sep_; | ||
| 2249 | string __grouping_; | ||
| 2250 | string_type __curr_symbol_; | ||
| 2251 | string_type __positive_sign_; | ||
| 2252 | string_type __negative_sign_; | ||
| 2253 | int __frac_digits_; | ||
| 2254 | pattern __pos_format_; | ||
| 2255 | pattern __neg_format_; | ||
| 2256 | |||
| 2257 | void init(const char*); | ||
| 2258 | }; | ||
| 2259 | |||
| 2260 | template <> | ||
| 2261 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, false>::init(const char*); | ||
| 2262 | template <> | ||
| 2263 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*); | ||
| 2264 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>; | ||
| 2265 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>; | ||
| 2266 | |||
| 2267 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2268 | template <> | ||
| 2269 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*); | ||
| 2270 | template <> | ||
| 2271 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*); | ||
| 2272 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>; | ||
| 2273 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>; | ||
| 2274 | # endif | ||
| 2275 | |||
| 2276 | // money_get | ||
| 2277 | |||
| 2278 | template <class _CharT> | ||
| 2279 | class __money_get { | ||
| 2280 | protected: | ||
| 2281 | typedef _CharT char_type; | ||
| 2282 | typedef basic_string<char_type> string_type; | ||
| 2283 | |||
| 2284 | _LIBCPP_HIDE_FROM_ABI __money_get() {} | ||
| 2285 | |||
| 2286 | static void __gather_info( | ||
| 2287 | bool __intl, | ||
| 2288 | const locale& __loc, | ||
| 2289 | money_base::pattern& __pat, | ||
| 2290 | char_type& __dp, | ||
| 2291 | char_type& __ts, | ||
| 2292 | string& __grp, | ||
| 2293 | string_type& __sym, | ||
| 2294 | string_type& __psn, | ||
| 2295 | string_type& __nsn, | ||
| 2296 | int& __fd); | ||
| 2297 | }; | ||
| 2298 | |||
| 2299 | template <class _CharT> | ||
| 2300 | void __money_get<_CharT>::__gather_info( | ||
| 2301 | bool __intl, | ||
| 2302 | const locale& __loc, | ||
| 2303 | money_base::pattern& __pat, | ||
| 2304 | char_type& __dp, | ||
| 2305 | char_type& __ts, | ||
| 2306 | string& __grp, | ||
| 2307 | string_type& __sym, | ||
| 2308 | string_type& __psn, | ||
| 2309 | string_type& __nsn, | ||
| 2310 | int& __fd) { | ||
| 2311 | if (__intl) { | ||
| 2312 | const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc); | ||
| 2313 | __pat = __mp.neg_format(); | ||
| 2314 | __nsn = __mp.negative_sign(); | ||
| 2315 | __psn = __mp.positive_sign(); | ||
| 2316 | __dp = __mp.decimal_point(); | ||
| 2317 | __ts = __mp.thousands_sep(); | ||
| 2318 | __grp = __mp.grouping(); | ||
| 2319 | __sym = __mp.curr_symbol(); | ||
| 2320 | __fd = __mp.frac_digits(); | ||
| 2321 | } else { | ||
| 2322 | const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc); | ||
| 2323 | __pat = __mp.neg_format(); | ||
| 2324 | __nsn = __mp.negative_sign(); | ||
| 2325 | __psn = __mp.positive_sign(); | ||
| 2326 | __dp = __mp.decimal_point(); | ||
| 2327 | __ts = __mp.thousands_sep(); | ||
| 2328 | __grp = __mp.grouping(); | ||
| 2329 | __sym = __mp.curr_symbol(); | ||
| 2330 | __fd = __mp.frac_digits(); | ||
| 2331 | } | ||
| 2332 | } | ||
| 2333 | |||
| 2334 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>; | ||
| 2335 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2336 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>; | ||
| 2337 | # endif | ||
| 2338 | |||
| 2339 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > | ||
| 2340 | class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> { | ||
| 2341 | public: | ||
| 2342 | typedef _CharT char_type; | ||
| 2343 | typedef _InputIterator iter_type; | ||
| 2344 | typedef basic_string<char_type> string_type; | ||
| 2345 | |||
| 2346 | _LIBCPP_HIDE_FROM_ABI explicit money_get(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 2347 | |||
| 2348 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 2349 | get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 2350 | return do_get(__b, __e, __intl, __iob, __err, __v); | ||
| 2351 | } | ||
| 2352 | |||
| 2353 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 2354 | get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const { | ||
| 2355 | return do_get(__b, __e, __intl, __iob, __err, __v); | ||
| 2356 | } | ||
| 2357 | |||
| 2358 | static locale::id id; | ||
| 2359 | |||
| 2360 | protected: | ||
| 2361 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_get() override {} | ||
| 2362 | |||
| 2363 | virtual iter_type | ||
| 2364 | do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const; | ||
| 2365 | virtual iter_type | ||
| 2366 | do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const; | ||
| 2367 | |||
| 2368 | private: | ||
| 2369 | static bool __do_get( | ||
| 2370 | iter_type& __b, | ||
| 2371 | iter_type __e, | ||
| 2372 | bool __intl, | ||
| 2373 | const locale& __loc, | ||
| 2374 | ios_base::fmtflags __flags, | ||
| 2375 | ios_base::iostate& __err, | ||
| 2376 | bool& __neg, | ||
| 2377 | const ctype<char_type>& __ct, | ||
| 2378 | unique_ptr<char_type, void (*)(void*)>& __wb, | ||
| 2379 | char_type*& __wn, | ||
| 2380 | char_type* __we); | ||
| 2381 | }; | ||
| 2382 | |||
| 2383 | template <class _CharT, class _InputIterator> | ||
| 2384 | locale::id money_get<_CharT, _InputIterator>::id; | ||
| 2385 | |||
| 2386 | _LIBCPP_EXPORTED_FROM_ABI void __do_nothing(void*); | ||
| 2387 | |||
| 2388 | template <class _Tp> | ||
| 2389 | _LIBCPP_HIDE_FROM_ABI void __double_or_nothing(unique_ptr<_Tp, void (*)(void*)>& __b, _Tp*& __n, _Tp*& __e) { | ||
| 2390 | bool __owns = __b.get_deleter() != __do_nothing; | ||
| 2391 | size_t __cur_cap = static_cast<size_t>(__e - __b.get()) * sizeof(_Tp); | ||
| 2392 | size_t __new_cap = __cur_cap < numeric_limits<size_t>::max() / 2 ? 2 * __cur_cap : numeric_limits<size_t>::max(); | ||
| 2393 | if (__new_cap == 0) | ||
| 2394 | __new_cap = sizeof(_Tp); | ||
| 2395 | size_t __n_off = static_cast<size_t>(__n - __b.get()); | ||
| 2396 | _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap); | ||
| 2397 | if (__t == 0) | ||
| 2398 | __throw_bad_alloc(); | ||
| 2399 | if (__owns) | ||
| 2400 | __b.release(); | ||
| 2401 | __b = unique_ptr<_Tp, void (*)(void*)>(__t, free); | ||
| 2402 | __new_cap /= sizeof(_Tp); | ||
| 2403 | __n = __b.get() + __n_off; | ||
| 2404 | __e = __b.get() + __new_cap; | ||
| 2405 | } | ||
| 2406 | |||
| 2407 | // true == success | ||
| 2408 | template <class _CharT, class _InputIterator> | ||
| 2409 | bool money_get<_CharT, _InputIterator>::__do_get( | ||
| 2410 | iter_type& __b, | ||
| 2411 | iter_type __e, | ||
| 2412 | bool __intl, | ||
| 2413 | const locale& __loc, | ||
| 2414 | ios_base::fmtflags __flags, | ||
| 2415 | ios_base::iostate& __err, | ||
| 2416 | bool& __neg, | ||
| 2417 | const ctype<char_type>& __ct, | ||
| 2418 | unique_ptr<char_type, void (*)(void*)>& __wb, | ||
| 2419 | char_type*& __wn, | ||
| 2420 | char_type* __we) { | ||
| 2421 | if (__b == __e) { | ||
| 2422 | __err |= ios_base::failbit; | ||
| 2423 | return false; | ||
| 2424 | } | ||
| 2425 | const unsigned __bz = 100; | ||
| 2426 | unsigned __gbuf[__bz]; | ||
| 2427 | unique_ptr<unsigned, void (*)(void*)> __gb(__gbuf, __do_nothing); | ||
| 2428 | unsigned* __gn = __gb.get(); | ||
| 2429 | unsigned* __ge = __gn + __bz; | ||
| 2430 | money_base::pattern __pat; | ||
| 2431 | char_type __dp; | ||
| 2432 | char_type __ts; | ||
| 2433 | string __grp; | ||
| 2434 | string_type __sym; | ||
| 2435 | string_type __psn; | ||
| 2436 | string_type __nsn; | ||
| 2437 | // Capture the spaces read into money_base::{space,none} so they | ||
| 2438 | // can be compared to initial spaces in __sym. | ||
| 2439 | string_type __spaces; | ||
| 2440 | int __fd; | ||
| 2441 | __money_get<_CharT>::__gather_info(__intl, __loc, __pat, __dp, __ts, __grp, __sym, __psn, __nsn, __fd); | ||
| 2442 | const string_type* __trailing_sign = 0; | ||
| 2443 | __wn = __wb.get(); | ||
| 2444 | for (unsigned __p = 0; __p < 4 && __b != __e; ++__p) { | ||
| 2445 | switch (__pat.field[__p]) { | ||
| 2446 | case money_base::space: | ||
| 2447 | if (__p != 3) { | ||
| 2448 | if (__ct.is(ctype_base::space, *__b)) | ||
| 2449 | __spaces.push_back(*__b++); | ||
| 2450 | else { | ||
| 2451 | __err |= ios_base::failbit; | ||
| 2452 | return false; | ||
| 2453 | } | ||
| 2454 | } | ||
| 2455 | _LIBCPP_FALLTHROUGH(); | ||
| 2456 | case money_base::none: | ||
| 2457 | if (__p != 3) { | ||
| 2458 | while (__b != __e && __ct.is(ctype_base::space, *__b)) | ||
| 2459 | __spaces.push_back(*__b++); | ||
| 2460 | } | ||
| 2461 | break; | ||
| 2462 | case money_base::sign: | ||
| 2463 | if (__psn.size() > 0 && *__b == __psn[0]) { | ||
| 2464 | ++__b; | ||
| 2465 | __neg = false; | ||
| 2466 | if (__psn.size() > 1) | ||
| 2467 | __trailing_sign = &__psn; | ||
| 2468 | break; | ||
| 2469 | } | ||
| 2470 | if (__nsn.size() > 0 && *__b == __nsn[0]) { | ||
| 2471 | ++__b; | ||
| 2472 | __neg = true; | ||
| 2473 | if (__nsn.size() > 1) | ||
| 2474 | __trailing_sign = &__nsn; | ||
| 2475 | break; | ||
| 2476 | } | ||
| 2477 | if (__psn.size() > 0 && __nsn.size() > 0) { // sign is required | ||
| 2478 | __err |= ios_base::failbit; | ||
| 2479 | return false; | ||
| 2480 | } | ||
| 2481 | if (__psn.size() == 0 && __nsn.size() == 0) | ||
| 2482 | // locale has no way of specifying a sign. Use the initial value of __neg as a default | ||
| 2483 | break; | ||
| 2484 | __neg = (__nsn.size() == 0); | ||
| 2485 | break; | ||
| 2486 | case money_base::symbol: { | ||
| 2487 | bool __more_needed = | ||
| 2488 | __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none)); | ||
| 2489 | bool __sb = (__flags & ios_base::showbase) != 0; | ||
| 2490 | if (__sb || __more_needed) { | ||
| 2491 | typename string_type::const_iterator __sym_space_end = __sym.begin(); | ||
| 2492 | if (__p > 0 && (__pat.field[__p - 1] == money_base::none || __pat.field[__p - 1] == money_base::space)) { | ||
| 2493 | // Match spaces we've already read against spaces at | ||
| 2494 | // the beginning of __sym. | ||
| 2495 | while (__sym_space_end != __sym.end() && __ct.is(ctype_base::space, *__sym_space_end)) | ||
| 2496 | ++__sym_space_end; | ||
| 2497 | const size_t __num_spaces = __sym_space_end - __sym.begin(); | ||
| 2498 | if (__num_spaces > __spaces.size() || | ||
| 2499 | !std::equal(__spaces.end() - __num_spaces, __spaces.end(), __sym.begin())) { | ||
| 2500 | // No match. Put __sym_space_end back at the | ||
| 2501 | // beginning of __sym, which will prevent a | ||
| 2502 | // match in the next loop. | ||
| 2503 | __sym_space_end = __sym.begin(); | ||
| 2504 | } | ||
| 2505 | } | ||
| 2506 | typename string_type::const_iterator __sym_curr_char = __sym_space_end; | ||
| 2507 | while (__sym_curr_char != __sym.end() && __b != __e && *__b == *__sym_curr_char) { | ||
| 2508 | ++__b; | ||
| 2509 | ++__sym_curr_char; | ||
| 2510 | } | ||
| 2511 | if (__sb && __sym_curr_char != __sym.end()) { | ||
| 2512 | __err |= ios_base::failbit; | ||
| 2513 | return false; | ||
| 2514 | } | ||
| 2515 | } | ||
| 2516 | } break; | ||
| 2517 | case money_base::value: { | ||
| 2518 | unsigned __ng = 0; | ||
| 2519 | for (; __b != __e; ++__b) { | ||
| 2520 | char_type __c = *__b; | ||
| 2521 | if (__ct.is(ctype_base::digit, __c)) { | ||
| 2522 | if (__wn == __we) | ||
| 2523 | std::__double_or_nothing(__wb, __wn, __we); | ||
| 2524 | *__wn++ = __c; | ||
| 2525 | ++__ng; | ||
| 2526 | } else if (__grp.size() > 0 && __ng > 0 && __c == __ts) { | ||
| 2527 | if (__gn == __ge) | ||
| 2528 | std::__double_or_nothing(__gb, __gn, __ge); | ||
| 2529 | *__gn++ = __ng; | ||
| 2530 | __ng = 0; | ||
| 2531 | } else | ||
| 2532 | break; | ||
| 2533 | } | ||
| 2534 | if (__gb.get() != __gn && __ng > 0) { | ||
| 2535 | if (__gn == __ge) | ||
| 2536 | std::__double_or_nothing(__gb, __gn, __ge); | ||
| 2537 | *__gn++ = __ng; | ||
| 2538 | } | ||
| 2539 | if (__fd > 0) { | ||
| 2540 | if (__b == __e || *__b != __dp) { | ||
| 2541 | __err |= ios_base::failbit; | ||
| 2542 | return false; | ||
| 2543 | } | ||
| 2544 | for (++__b; __fd > 0; --__fd, ++__b) { | ||
| 2545 | if (__b == __e || !__ct.is(ctype_base::digit, *__b)) { | ||
| 2546 | __err |= ios_base::failbit; | ||
| 2547 | return false; | ||
| 2548 | } | ||
| 2549 | if (__wn == __we) | ||
| 2550 | std::__double_or_nothing(__wb, __wn, __we); | ||
| 2551 | *__wn++ = *__b; | ||
| 2552 | } | ||
| 2553 | } | ||
| 2554 | if (__wn == __wb.get()) { | ||
| 2555 | __err |= ios_base::failbit; | ||
| 2556 | return false; | ||
| 2557 | } | ||
| 2558 | } break; | ||
| 2559 | } | ||
| 2560 | } | ||
| 2561 | if (__trailing_sign) { | ||
| 2562 | for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b) { | ||
| 2563 | if (__b == __e || *__b != (*__trailing_sign)[__i]) { | ||
| 2564 | __err |= ios_base::failbit; | ||
| 2565 | return false; | ||
| 2566 | } | ||
| 2567 | } | ||
| 2568 | } | ||
| 2569 | if (__gb.get() != __gn) { | ||
| 2570 | ios_base::iostate __et = ios_base::goodbit; | ||
| 2571 | __check_grouping(__grp, __gb.get(), __gn, __et); | ||
| 2572 | if (__et) { | ||
| 2573 | __err |= ios_base::failbit; | ||
| 2574 | return false; | ||
| 2575 | } | ||
| 2576 | } | ||
| 2577 | return true; | ||
| 2578 | } | ||
| 2579 | |||
| 2580 | template <class _CharT, class _InputIterator> | ||
| 2581 | _InputIterator money_get<_CharT, _InputIterator>::do_get( | ||
| 2582 | iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { | ||
| 2583 | const int __bz = 100; | ||
| 2584 | char_type __wbuf[__bz]; | ||
| 2585 | unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing); | ||
| 2586 | char_type* __wn; | ||
| 2587 | char_type* __we = __wbuf + __bz; | ||
| 2588 | locale __loc = __iob.getloc(); | ||
| 2589 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 2590 | bool __neg = false; | ||
| 2591 | if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) { | ||
| 2592 | const char __src[] = "0123456789"; | ||
| 2593 | char_type __atoms[sizeof(__src) - 1]; | ||
| 2594 | __ct.widen(__src, __src + (sizeof(__src) - 1), __atoms); | ||
| 2595 | char __nbuf[__bz]; | ||
| 2596 | char* __nc = __nbuf; | ||
| 2597 | unique_ptr<char, void (*)(void*)> __h(nullptr, free); | ||
| 2598 | if (__wn - __wb.get() > __bz - 2) { | ||
| 2599 | __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2))); | ||
| 2600 | if (__h.get() == nullptr) | ||
| 2601 | __throw_bad_alloc(); | ||
| 2602 | __nc = __h.get(); | ||
| 2603 | } | ||
| 2604 | if (__neg) | ||
| 2605 | *__nc++ = '-'; | ||
| 2606 | for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc) | ||
| 2607 | *__nc = __src[std::find(__atoms, std::end(__atoms), *__w) - __atoms]; | ||
| 2608 | *__nc = char(); | ||
| 2609 | if (sscanf(__nbuf, "%Lf", &__v) != 1) | ||
| 2610 | __throw_runtime_error("money_get error"); | ||
| 2611 | } | ||
| 2612 | if (__b == __e) | ||
| 2613 | __err |= ios_base::eofbit; | ||
| 2614 | return __b; | ||
| 2615 | } | ||
| 2616 | |||
| 2617 | template <class _CharT, class _InputIterator> | ||
| 2618 | _InputIterator money_get<_CharT, _InputIterator>::do_get( | ||
| 2619 | iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const { | ||
| 2620 | const int __bz = 100; | ||
| 2621 | char_type __wbuf[__bz]; | ||
| 2622 | unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing); | ||
| 2623 | char_type* __wn; | ||
| 2624 | char_type* __we = __wbuf + __bz; | ||
| 2625 | locale __loc = __iob.getloc(); | ||
| 2626 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 2627 | bool __neg = false; | ||
| 2628 | if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) { | ||
| 2629 | __v.clear(); | ||
| 2630 | if (__neg) | ||
| 2631 | __v.push_back(__ct.widen('-')); | ||
| 2632 | char_type __z = __ct.widen('0'); | ||
| 2633 | char_type* __w; | ||
| 2634 | for (__w = __wb.get(); __w < __wn - 1; ++__w) | ||
| 2635 | if (*__w != __z) | ||
| 2636 | break; | ||
| 2637 | __v.append(__w, __wn); | ||
| 2638 | } | ||
| 2639 | if (__b == __e) | ||
| 2640 | __err |= ios_base::eofbit; | ||
| 2641 | return __b; | ||
| 2642 | } | ||
| 2643 | |||
| 2644 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>; | ||
| 2645 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2646 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>; | ||
| 2647 | # endif | ||
| 2648 | |||
| 2649 | // money_put | ||
| 2650 | |||
| 2651 | template <class _CharT> | ||
| 2652 | class __money_put { | ||
| 2653 | protected: | ||
| 2654 | typedef _CharT char_type; | ||
| 2655 | typedef basic_string<char_type> string_type; | ||
| 2656 | |||
| 2657 | _LIBCPP_HIDE_FROM_ABI __money_put() {} | ||
| 2658 | |||
| 2659 | static void __gather_info( | ||
| 2660 | bool __intl, | ||
| 2661 | bool __neg, | ||
| 2662 | const locale& __loc, | ||
| 2663 | money_base::pattern& __pat, | ||
| 2664 | char_type& __dp, | ||
| 2665 | char_type& __ts, | ||
| 2666 | string& __grp, | ||
| 2667 | string_type& __sym, | ||
| 2668 | string_type& __sn, | ||
| 2669 | int& __fd); | ||
| 2670 | static void __format( | ||
| 2671 | char_type* __mb, | ||
| 2672 | char_type*& __mi, | ||
| 2673 | char_type*& __me, | ||
| 2674 | ios_base::fmtflags __flags, | ||
| 2675 | const char_type* __db, | ||
| 2676 | const char_type* __de, | ||
| 2677 | const ctype<char_type>& __ct, | ||
| 2678 | bool __neg, | ||
| 2679 | const money_base::pattern& __pat, | ||
| 2680 | char_type __dp, | ||
| 2681 | char_type __ts, | ||
| 2682 | const string& __grp, | ||
| 2683 | const string_type& __sym, | ||
| 2684 | const string_type& __sn, | ||
| 2685 | int __fd); | ||
| 2686 | }; | ||
| 2687 | |||
| 2688 | template <class _CharT> | ||
| 2689 | void __money_put<_CharT>::__gather_info( | ||
| 2690 | bool __intl, | ||
| 2691 | bool __neg, | ||
| 2692 | const locale& __loc, | ||
| 2693 | money_base::pattern& __pat, | ||
| 2694 | char_type& __dp, | ||
| 2695 | char_type& __ts, | ||
| 2696 | string& __grp, | ||
| 2697 | string_type& __sym, | ||
| 2698 | string_type& __sn, | ||
| 2699 | int& __fd) { | ||
| 2700 | if (__intl) { | ||
| 2701 | const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc); | ||
| 2702 | if (__neg) { | ||
| 2703 | __pat = __mp.neg_format(); | ||
| 2704 | __sn = __mp.negative_sign(); | ||
| 2705 | } else { | ||
| 2706 | __pat = __mp.pos_format(); | ||
| 2707 | __sn = __mp.positive_sign(); | ||
| 2708 | } | ||
| 2709 | __dp = __mp.decimal_point(); | ||
| 2710 | __ts = __mp.thousands_sep(); | ||
| 2711 | __grp = __mp.grouping(); | ||
| 2712 | __sym = __mp.curr_symbol(); | ||
| 2713 | __fd = __mp.frac_digits(); | ||
| 2714 | } else { | ||
| 2715 | const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc); | ||
| 2716 | if (__neg) { | ||
| 2717 | __pat = __mp.neg_format(); | ||
| 2718 | __sn = __mp.negative_sign(); | ||
| 2719 | } else { | ||
| 2720 | __pat = __mp.pos_format(); | ||
| 2721 | __sn = __mp.positive_sign(); | ||
| 2722 | } | ||
| 2723 | __dp = __mp.decimal_point(); | ||
| 2724 | __ts = __mp.thousands_sep(); | ||
| 2725 | __grp = __mp.grouping(); | ||
| 2726 | __sym = __mp.curr_symbol(); | ||
| 2727 | __fd = __mp.frac_digits(); | ||
| 2728 | } | ||
| 2729 | } | ||
| 2730 | |||
| 2731 | template <class _CharT> | ||
| 2732 | void __money_put<_CharT>::__format( | ||
| 2733 | char_type* __mb, | ||
| 2734 | char_type*& __mi, | ||
| 2735 | char_type*& __me, | ||
| 2736 | ios_base::fmtflags __flags, | ||
| 2737 | const char_type* __db, | ||
| 2738 | const char_type* __de, | ||
| 2739 | const ctype<char_type>& __ct, | ||
| 2740 | bool __neg, | ||
| 2741 | const money_base::pattern& __pat, | ||
| 2742 | char_type __dp, | ||
| 2743 | char_type __ts, | ||
| 2744 | const string& __grp, | ||
| 2745 | const string_type& __sym, | ||
| 2746 | const string_type& __sn, | ||
| 2747 | int __fd) { | ||
| 2748 | __me = __mb; | ||
| 2749 | for (char __p : __pat.field) { | ||
| 2750 | switch (__p) { | ||
| 2751 | case money_base::none: | ||
| 2752 | __mi = __me; | ||
| 2753 | break; | ||
| 2754 | case money_base::space: | ||
| 2755 | __mi = __me; | ||
| 2756 | *__me++ = __ct.widen(' '); | ||
| 2757 | break; | ||
| 2758 | case money_base::sign: | ||
| 2759 | if (!__sn.empty()) | ||
| 2760 | *__me++ = __sn[0]; | ||
| 2761 | break; | ||
| 2762 | case money_base::symbol: | ||
| 2763 | if (!__sym.empty() && (__flags & ios_base::showbase)) | ||
| 2764 | __me = std::copy(__sym.begin(), __sym.end(), __me); | ||
| 2765 | break; | ||
| 2766 | case money_base::value: { | ||
| 2767 | // remember start of value so we can reverse it | ||
| 2768 | char_type* __t = __me; | ||
| 2769 | // find beginning of digits | ||
| 2770 | if (__neg) | ||
| 2771 | ++__db; | ||
| 2772 | // find end of digits | ||
| 2773 | const char_type* __d; | ||
| 2774 | for (__d = __db; __d < __de; ++__d) | ||
| 2775 | if (!__ct.is(ctype_base::digit, *__d)) | ||
| 2776 | break; | ||
| 2777 | // print fractional part | ||
| 2778 | if (__fd > 0) { | ||
| 2779 | int __f; | ||
| 2780 | for (__f = __fd; __d > __db && __f > 0; --__f) | ||
| 2781 | *__me++ = *--__d; | ||
| 2782 | char_type __z = __f > 0 ? __ct.widen('0') : char_type(); | ||
| 2783 | for (; __f > 0; --__f) | ||
| 2784 | *__me++ = __z; | ||
| 2785 | *__me++ = __dp; | ||
| 2786 | } | ||
| 2787 | // print units part | ||
| 2788 | if (__d == __db) { | ||
| 2789 | *__me++ = __ct.widen('0'); | ||
| 2790 | } else { | ||
| 2791 | unsigned __ng = 0; | ||
| 2792 | unsigned __ig = 0; | ||
| 2793 | unsigned __gl = __grp.empty() ? numeric_limits<unsigned>::max() : static_cast<unsigned>(__grp[__ig]); | ||
| 2794 | while (__d != __db) { | ||
| 2795 | if (__ng == __gl) { | ||
| 2796 | *__me++ = __ts; | ||
| 2797 | __ng = 0; | ||
| 2798 | if (++__ig < __grp.size()) | ||
| 2799 | __gl = __grp[__ig] == numeric_limits<char>::max() | ||
| 2800 | ? numeric_limits<unsigned>::max() | ||
| 2801 | : static_cast<unsigned>(__grp[__ig]); | ||
| 2802 | } | ||
| 2803 | *__me++ = *--__d; | ||
| 2804 | ++__ng; | ||
| 2805 | } | ||
| 2806 | } | ||
| 2807 | // reverse it | ||
| 2808 | std::reverse(__t, __me); | ||
| 2809 | } break; | ||
| 2810 | } | ||
| 2811 | } | ||
| 2812 | // print rest of sign, if any | ||
| 2813 | if (__sn.size() > 1) | ||
| 2814 | __me = std::copy(__sn.begin() + 1, __sn.end(), __me); | ||
| 2815 | // set alignment | ||
| 2816 | if ((__flags & ios_base::adjustfield) == ios_base::left) | ||
| 2817 | __mi = __me; | ||
| 2818 | else if ((__flags & ios_base::adjustfield) != ios_base::internal) | ||
| 2819 | __mi = __mb; | ||
| 2820 | } | ||
| 2821 | |||
| 2822 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>; | ||
| 2823 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2824 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>; | ||
| 2825 | # endif | ||
| 2826 | |||
| 2827 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > | ||
| 2828 | class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> { | ||
| 2829 | public: | ||
| 2830 | typedef _CharT char_type; | ||
| 2831 | typedef _OutputIterator iter_type; | ||
| 2832 | typedef basic_string<char_type> string_type; | ||
| 2833 | |||
| 2834 | _LIBCPP_HIDE_FROM_ABI explicit money_put(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 2835 | |||
| 2836 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 2837 | put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const { | ||
| 2838 | return do_put(__s, __intl, __iob, __fl, __units); | ||
| 2839 | } | ||
| 2840 | |||
| 2841 | _LIBCPP_HIDE_FROM_ABI iter_type | ||
| 2842 | put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const { | ||
| 2843 | return do_put(__s, __intl, __iob, __fl, __digits); | ||
| 2844 | } | ||
| 2845 | |||
| 2846 | static locale::id id; | ||
| 2847 | |||
| 2848 | protected: | ||
| 2849 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_put() override {} | ||
| 2850 | |||
| 2851 | virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const; | ||
| 2852 | virtual iter_type | ||
| 2853 | do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const; | ||
| 2854 | }; | ||
| 2855 | |||
| 2856 | template <class _CharT, class _OutputIterator> | ||
| 2857 | locale::id money_put<_CharT, _OutputIterator>::id; | ||
| 2858 | |||
| 2859 | template <class _CharT, class _OutputIterator> | ||
| 2860 | _OutputIterator money_put<_CharT, _OutputIterator>::do_put( | ||
| 2861 | iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const { | ||
| 2862 | // convert to char | ||
| 2863 | const size_t __bs = 100; | ||
| 2864 | char __buf[__bs]; | ||
| 2865 | char* __bb = __buf; | ||
| 2866 | char_type __digits[__bs]; | ||
| 2867 | char_type* __db = __digits; | ||
| 2868 | int __n = snprintf(__bb, __bs, "%.0Lf", __units); | ||
| 2869 | unique_ptr<char, void (*)(void*)> __hn(nullptr, free); | ||
| 2870 | unique_ptr<char_type, void (*)(void*)> __hd(0, free); | ||
| 2871 | // secure memory for digit storage | ||
| 2872 | if (static_cast<size_t>(__n) > __bs - 1) { | ||
| 2873 | __n = __locale::__asprintf(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units); | ||
| 2874 | if (__n == -1) | ||
| 2875 | __throw_bad_alloc(); | ||
| 2876 | __hn.reset(__bb); | ||
| 2877 | __hd.reset((char_type*)malloc(static_cast<size_t>(__n) * sizeof(char_type))); | ||
| 2878 | if (__hd == nullptr) | ||
| 2879 | __throw_bad_alloc(); | ||
| 2880 | __db = __hd.get(); | ||
| 2881 | } | ||
| 2882 | // gather info | ||
| 2883 | locale __loc = __iob.getloc(); | ||
| 2884 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 2885 | __ct.widen(__bb, __bb + __n, __db); | ||
| 2886 | bool __neg = __n > 0 && __bb[0] == '-'; | ||
| 2887 | money_base::pattern __pat; | ||
| 2888 | char_type __dp; | ||
| 2889 | char_type __ts; | ||
| 2890 | string __grp; | ||
| 2891 | string_type __sym; | ||
| 2892 | string_type __sn; | ||
| 2893 | int __fd; | ||
| 2894 | this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd); | ||
| 2895 | // secure memory for formatting | ||
| 2896 | char_type __mbuf[__bs]; | ||
| 2897 | char_type* __mb = __mbuf; | ||
| 2898 | unique_ptr<char_type, void (*)(void*)> __hw(0, free); | ||
| 2899 | size_t __exn = __n > __fd ? (static_cast<size_t>(__n) - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() + | ||
| 2900 | static_cast<size_t>(__fd) + 1 | ||
| 2901 | : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2; | ||
| 2902 | if (__exn > __bs) { | ||
| 2903 | __hw.reset((char_type*)malloc(__exn * sizeof(char_type))); | ||
| 2904 | __mb = __hw.get(); | ||
| 2905 | if (__mb == 0) | ||
| 2906 | __throw_bad_alloc(); | ||
| 2907 | } | ||
| 2908 | // format | ||
| 2909 | char_type* __mi; | ||
| 2910 | char_type* __me; | ||
| 2911 | this->__format( | ||
| 2912 | __mb, __mi, __me, __iob.flags(), __db, __db + __n, __ct, __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd); | ||
| 2913 | return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl); | ||
| 2914 | } | ||
| 2915 | |||
| 2916 | template <class _CharT, class _OutputIterator> | ||
| 2917 | _OutputIterator money_put<_CharT, _OutputIterator>::do_put( | ||
| 2918 | iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const { | ||
| 2919 | // gather info | ||
| 2920 | locale __loc = __iob.getloc(); | ||
| 2921 | const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc); | ||
| 2922 | bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-'); | ||
| 2923 | money_base::pattern __pat; | ||
| 2924 | char_type __dp; | ||
| 2925 | char_type __ts; | ||
| 2926 | string __grp; | ||
| 2927 | string_type __sym; | ||
| 2928 | string_type __sn; | ||
| 2929 | int __fd; | ||
| 2930 | this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd); | ||
| 2931 | // secure memory for formatting | ||
| 2932 | char_type __mbuf[100]; | ||
| 2933 | char_type* __mb = __mbuf; | ||
| 2934 | unique_ptr<char_type, void (*)(void*)> __h(0, free); | ||
| 2935 | size_t __exn = | ||
| 2936 | static_cast<int>(__digits.size()) > __fd | ||
| 2937 | ? (__digits.size() - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() + static_cast<size_t>(__fd) + | ||
| 2938 | 1 | ||
| 2939 | : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2; | ||
| 2940 | if (__exn > 100) { | ||
| 2941 | __h.reset((char_type*)malloc(__exn * sizeof(char_type))); | ||
| 2942 | __mb = __h.get(); | ||
| 2943 | if (__mb == 0) | ||
| 2944 | __throw_bad_alloc(); | ||
| 2945 | } | ||
| 2946 | // format | ||
| 2947 | char_type* __mi; | ||
| 2948 | char_type* __me; | ||
| 2949 | this->__format( | ||
| 2950 | __mb, | ||
| 2951 | __mi, | ||
| 2952 | __me, | ||
| 2953 | __iob.flags(), | ||
| 2954 | __digits.data(), | ||
| 2955 | __digits.data() + __digits.size(), | ||
| 2956 | __ct, | ||
| 2957 | __neg, | ||
| 2958 | __pat, | ||
| 2959 | __dp, | ||
| 2960 | __ts, | ||
| 2961 | __grp, | ||
| 2962 | __sym, | ||
| 2963 | __sn, | ||
| 2964 | __fd); | ||
| 2965 | return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl); | ||
| 2966 | } | ||
| 2967 | |||
| 2968 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>; | ||
| 2969 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 2970 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; | ||
| 2971 | # endif | ||
| 2972 | |||
| 2973 | // messages | ||
| 2974 | |||
| 2975 | class _LIBCPP_EXPORTED_FROM_ABI messages_base { | ||
| 2976 | public: | ||
| 2977 | typedef intptr_t catalog; | ||
| 2978 | |||
| 2979 | _LIBCPP_HIDE_FROM_ABI messages_base() {} | ||
| 2980 | }; | ||
| 2981 | |||
| 2982 | template <class _CharT> | ||
| 2983 | class _LIBCPP_TEMPLATE_VIS messages : public locale::facet, public messages_base { | ||
| 2984 | public: | ||
| 2985 | typedef _CharT char_type; | ||
| 2986 | typedef basic_string<_CharT> string_type; | ||
| 2987 | |||
| 2988 | _LIBCPP_HIDE_FROM_ABI explicit messages(size_t __refs = 0) : locale::facet(__refs) {} | ||
| 2989 | |||
| 2990 | _LIBCPP_HIDE_FROM_ABI catalog open(const basic_string<char>& __nm, const locale& __loc) const { | ||
| 2991 | return do_open(__nm, __loc); | ||
| 2992 | } | ||
| 2993 | |||
| 2994 | _LIBCPP_HIDE_FROM_ABI string_type get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { | ||
| 2995 | return do_get(__c, __set, __msgid, __dflt); | ||
| 2996 | } | ||
| 2997 | |||
| 2998 | _LIBCPP_HIDE_FROM_ABI void close(catalog __c) const { do_close(__c); } | ||
| 2999 | |||
| 3000 | static locale::id id; | ||
| 3001 | |||
| 3002 | protected: | ||
| 3003 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages() override {} | ||
| 3004 | |||
| 3005 | virtual catalog do_open(const basic_string<char>&, const locale&) const; | ||
| 3006 | virtual string_type do_get(catalog, int __set, int __msgid, const string_type& __dflt) const; | ||
| 3007 | virtual void do_close(catalog) const; | ||
| 3008 | }; | ||
| 3009 | |||
| 3010 | template <class _CharT> | ||
| 3011 | locale::id messages<_CharT>::id; | ||
| 3012 | |||
| 3013 | template <class _CharT> | ||
| 3014 | typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const { | ||
| 3015 | # if _LIBCPP_HAS_CATOPEN | ||
| 3016 | return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); | ||
| 3017 | # else // !_LIBCPP_HAS_CATOPEN | ||
| 3018 | (void)__nm; | ||
| 3019 | return -1; | ||
| 3020 | # endif // _LIBCPP_HAS_CATOPEN | ||
| 3021 | } | ||
| 3022 | |||
| 3023 | template <class _CharT> | ||
| 3024 | typename messages<_CharT>::string_type | ||
| 3025 | messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { | ||
| 3026 | # if _LIBCPP_HAS_CATOPEN | ||
| 3027 | string __ndflt; | ||
| 3028 | __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()( | ||
| 3029 | std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); | ||
| 3030 | nl_catd __cat = (nl_catd)__c; | ||
| 3031 | static_assert(sizeof(catalog) >= sizeof(nl_catd), "Unexpected nl_catd type"); | ||
| 3032 | char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str()); | ||
| 3033 | string_type __w; | ||
| 3034 | __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n)); | ||
| 3035 | return __w; | ||
| 3036 | # else // !_LIBCPP_HAS_CATOPEN | ||
| 3037 | (void)__c; | ||
| 3038 | (void)__set; | ||
| 3039 | (void)__msgid; | ||
| 3040 | return __dflt; | ||
| 3041 | # endif // _LIBCPP_HAS_CATOPEN | ||
| 3042 | } | ||
| 3043 | |||
| 3044 | template <class _CharT> | ||
| 3045 | void messages<_CharT>::do_close(catalog __c) const { | ||
| 3046 | # if _LIBCPP_HAS_CATOPEN | ||
| 3047 | catclose((nl_catd)__c); | ||
| 3048 | # else // !_LIBCPP_HAS_CATOPEN | ||
| 3049 | (void)__c; | ||
| 3050 | # endif // _LIBCPP_HAS_CATOPEN | ||
| 3051 | } | ||
| 3052 | |||
| 3053 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>; | ||
| 3054 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 3055 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>; | ||
| 3056 | # endif | ||
| 3057 | |||
| 3058 | template <class _CharT> | ||
| 3059 | class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> { | ||
| 3060 | public: | ||
| 3061 | typedef messages_base::catalog catalog; | ||
| 3062 | typedef basic_string<_CharT> string_type; | ||
| 3063 | |||
| 3064 | _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const char*, size_t __refs = 0) : messages<_CharT>(__refs) {} | ||
| 3065 | |||
| 3066 | _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const string&, size_t __refs = 0) : messages<_CharT>(__refs) {} | ||
| 3067 | |||
| 3068 | protected: | ||
| 3069 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages_byname() override {} | ||
| 3070 | }; | ||
| 3071 | |||
| 3072 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>; | ||
| 3073 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 3074 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; | ||
| 3075 | # endif | ||
| 3076 | |||
| 3077 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 3078 | |||
| 3079 | template <class _Codecvt, | ||
| 3080 | class _Elem = wchar_t, | ||
| 3081 | class _WideAlloc = allocator<_Elem>, | ||
| 3082 | class _ByteAlloc = allocator<char> > | ||
| 3083 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert { | ||
| 3084 | public: | ||
| 3085 | typedef basic_string<char, char_traits<char>, _ByteAlloc> byte_string; | ||
| 3086 | typedef basic_string<_Elem, char_traits<_Elem>, _WideAlloc> wide_string; | ||
| 3087 | typedef typename _Codecvt::state_type state_type; | ||
| 3088 | typedef typename wide_string::traits_type::int_type int_type; | ||
| 3089 | |||
| 3090 | private: | ||
| 3091 | byte_string __byte_err_string_; | ||
| 3092 | wide_string __wide_err_string_; | ||
| 3093 | _Codecvt* __cvtptr_; | ||
| 3094 | state_type __cvtstate_; | ||
| 3095 | size_t __cvtcount_; | ||
| 3096 | |||
| 3097 | public: | ||
| 3098 | # ifndef _LIBCPP_CXX03_LANG | ||
| 3099 | _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {} | ||
| 3100 | _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt); | ||
| 3101 | # else | ||
| 3102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt); | ||
| 3103 | # endif | ||
| 3104 | |||
| 3105 | _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state); | ||
| 3106 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI | ||
| 3107 | wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); | ||
| 3108 | # ifndef _LIBCPP_CXX03_LANG | ||
| 3109 | _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc); | ||
| 3110 | # endif | ||
| 3111 | _LIBCPP_HIDE_FROM_ABI ~wstring_convert(); | ||
| 3112 | |||
| 3113 | wstring_convert(const wstring_convert& __wc) = delete; | ||
| 3114 | wstring_convert& operator=(const wstring_convert& __wc) = delete; | ||
| 3115 | |||
| 3116 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); } | ||
| 3117 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) { | ||
| 3118 | return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr)); | ||
| 3119 | } | ||
| 3120 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const byte_string& __str) { | ||
| 3121 | return from_bytes(__str.data(), __str.data() + __str.size()); | ||
| 3122 | } | ||
| 3123 | _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __first, const char* __last); | ||
| 3124 | |||
| 3125 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) { return to_bytes(&__wchar, &__wchar + 1); } | ||
| 3126 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __wptr) { | ||
| 3127 | return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr)); | ||
| 3128 | } | ||
| 3129 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const wide_string& __wstr) { | ||
| 3130 | return to_bytes(__wstr.data(), __wstr.data() + __wstr.size()); | ||
| 3131 | } | ||
| 3132 | _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __first, const _Elem* __last); | ||
| 3133 | |||
| 3134 | _LIBCPP_HIDE_FROM_ABI size_t converted() const _NOEXCEPT { return __cvtcount_; } | ||
| 3135 | _LIBCPP_HIDE_FROM_ABI state_type state() const { return __cvtstate_; } | ||
| 3136 | }; | ||
| 3137 | |||
| 3138 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3139 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 3140 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt) | ||
| 3141 | : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) {} | ||
| 3142 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3143 | |||
| 3144 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 3145 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt, state_type __state) | ||
| 3146 | : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) {} | ||
| 3147 | |||
| 3148 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 3149 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert( | ||
| 3150 | const byte_string& __byte_err, const wide_string& __wide_err) | ||
| 3151 | : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err), __cvtstate_(), __cvtcount_(0) { | ||
| 3152 | __cvtptr_ = new _Codecvt; | ||
| 3153 | } | ||
| 3154 | |||
| 3155 | # ifndef _LIBCPP_CXX03_LANG | ||
| 3156 | |||
| 3157 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 3158 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc) | ||
| 3159 | : __byte_err_string_(std::move(__wc.__byte_err_string_)), | ||
| 3160 | __wide_err_string_(std::move(__wc.__wide_err_string_)), | ||
| 3161 | __cvtptr_(__wc.__cvtptr_), | ||
| 3162 | __cvtstate_(__wc.__cvtstate_), | ||
| 3163 | __cvtcount_(__wc.__cvtcount_) { | ||
| 3164 | __wc.__cvtptr_ = nullptr; | ||
| 3165 | } | ||
| 3166 | |||
| 3167 | # endif // _LIBCPP_CXX03_LANG | ||
| 3168 | |||
| 3169 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3170 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 3171 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::~wstring_convert() { | ||
| 3172 | delete __cvtptr_; | ||
| 3173 | } | ||
| 3174 | |||
| 3175 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 3176 | typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wide_string | ||
| 3177 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::from_bytes(const char* __frm, const char* __frm_end) { | ||
| 3178 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3179 | __cvtcount_ = 0; | ||
| 3180 | if (__cvtptr_ != nullptr) { | ||
| 3181 | wide_string __ws(2 * (__frm_end - __frm), _Elem()); | ||
| 3182 | if (__frm != __frm_end) | ||
| 3183 | __ws.resize(__ws.capacity()); | ||
| 3184 | codecvt_base::result __r = codecvt_base::ok; | ||
| 3185 | state_type __st = __cvtstate_; | ||
| 3186 | if (__frm != __frm_end) { | ||
| 3187 | _Elem* __to = &__ws[0]; | ||
| 3188 | _Elem* __to_end = __to + __ws.size(); | ||
| 3189 | const char* __frm_nxt; | ||
| 3190 | do { | ||
| 3191 | _Elem* __to_nxt; | ||
| 3192 | __r = __cvtptr_->in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); | ||
| 3193 | __cvtcount_ += __frm_nxt - __frm; | ||
| 3194 | if (__frm_nxt == __frm) { | ||
| 3195 | __r = codecvt_base::error; | ||
| 3196 | } else if (__r == codecvt_base::noconv) { | ||
| 3197 | __ws.resize(__to - &__ws[0]); | ||
| 3198 | // This only gets executed if _Elem is char | ||
| 3199 | __ws.append((const _Elem*)__frm, (const _Elem*)__frm_end); | ||
| 3200 | __frm = __frm_nxt; | ||
| 3201 | __r = codecvt_base::ok; | ||
| 3202 | } else if (__r == codecvt_base::ok) { | ||
| 3203 | __ws.resize(__to_nxt - &__ws[0]); | ||
| 3204 | __frm = __frm_nxt; | ||
| 3205 | } else if (__r == codecvt_base::partial) { | ||
| 3206 | ptrdiff_t __s = __to_nxt - &__ws[0]; | ||
| 3207 | __ws.resize(2 * __s); | ||
| 3208 | __to = &__ws[0] + __s; | ||
| 3209 | __to_end = &__ws[0] + __ws.size(); | ||
| 3210 | __frm = __frm_nxt; | ||
| 3211 | } | ||
| 3212 | } while (__r == codecvt_base::partial && __frm_nxt < __frm_end); | ||
| 3213 | } | ||
| 3214 | if (__r == codecvt_base::ok) | ||
| 3215 | return __ws; | ||
| 3216 | } | ||
| 3217 | |||
| 3218 | if (__wide_err_string_.empty()) | ||
| 3219 | __throw_range_error("wstring_convert: from_bytes error"); | ||
| 3220 | |||
| 3221 | return __wide_err_string_; | ||
| 3222 | } | ||
| 3223 | |||
| 3224 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> | ||
| 3225 | typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::byte_string | ||
| 3226 | wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem* __frm, const _Elem* __frm_end) { | ||
| 3227 | __cvtcount_ = 0; | ||
| 3228 | if (__cvtptr_ != nullptr) { | ||
| 3229 | byte_string __bs(2 * (__frm_end - __frm), char()); | ||
| 3230 | if (__frm != __frm_end) | ||
| 3231 | __bs.resize(__bs.capacity()); | ||
| 3232 | codecvt_base::result __r = codecvt_base::ok; | ||
| 3233 | state_type __st = __cvtstate_; | ||
| 3234 | if (__frm != __frm_end) { | ||
| 3235 | char* __to = &__bs[0]; | ||
| 3236 | char* __to_end = __to + __bs.size(); | ||
| 3237 | const _Elem* __frm_nxt; | ||
| 3238 | do { | ||
| 3239 | char* __to_nxt; | ||
| 3240 | __r = __cvtptr_->out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); | ||
| 3241 | __cvtcount_ += __frm_nxt - __frm; | ||
| 3242 | if (__frm_nxt == __frm) { | ||
| 3243 | __r = codecvt_base::error; | ||
| 3244 | } else if (__r == codecvt_base::noconv) { | ||
| 3245 | __bs.resize(__to - &__bs[0]); | ||
| 3246 | // This only gets executed if _Elem is char | ||
| 3247 | __bs.append((const char*)__frm, (const char*)__frm_end); | ||
| 3248 | __frm = __frm_nxt; | ||
| 3249 | __r = codecvt_base::ok; | ||
| 3250 | } else if (__r == codecvt_base::ok) { | ||
| 3251 | __bs.resize(__to_nxt - &__bs[0]); | ||
| 3252 | __frm = __frm_nxt; | ||
| 3253 | } else if (__r == codecvt_base::partial) { | ||
| 3254 | ptrdiff_t __s = __to_nxt - &__bs[0]; | ||
| 3255 | __bs.resize(2 * __s); | ||
| 3256 | __to = &__bs[0] + __s; | ||
| 3257 | __to_end = &__bs[0] + __bs.size(); | ||
| 3258 | __frm = __frm_nxt; | ||
| 3259 | } | ||
| 3260 | } while (__r == codecvt_base::partial && __frm_nxt < __frm_end); | ||
| 3261 | } | ||
| 3262 | if (__r == codecvt_base::ok) { | ||
| 3263 | size_t __s = __bs.size(); | ||
| 3264 | __bs.resize(__bs.capacity()); | ||
| 3265 | char* __to = &__bs[0] + __s; | ||
| 3266 | char* __to_end = __to + __bs.size(); | ||
| 3267 | do { | ||
| 3268 | char* __to_nxt; | ||
| 3269 | __r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt); | ||
| 3270 | if (__r == codecvt_base::noconv) { | ||
| 3271 | __bs.resize(__to - &__bs[0]); | ||
| 3272 | __r = codecvt_base::ok; | ||
| 3273 | } else if (__r == codecvt_base::ok) { | ||
| 3274 | __bs.resize(__to_nxt - &__bs[0]); | ||
| 3275 | } else if (__r == codecvt_base::partial) { | ||
| 3276 | ptrdiff_t __sp = __to_nxt - &__bs[0]; | ||
| 3277 | __bs.resize(2 * __sp); | ||
| 3278 | __to = &__bs[0] + __sp; | ||
| 3279 | __to_end = &__bs[0] + __bs.size(); | ||
| 3280 | } | ||
| 3281 | } while (__r == codecvt_base::partial); | ||
| 3282 | if (__r == codecvt_base::ok) | ||
| 3283 | return __bs; | ||
| 3284 | } | ||
| 3285 | } | ||
| 3286 | |||
| 3287 | if (__byte_err_string_.empty()) | ||
| 3288 | __throw_range_error("wstring_convert: to_bytes error"); | ||
| 3289 | |||
| 3290 | return __byte_err_string_; | ||
| 3291 | } | ||
| 3292 | |||
| 3293 | template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> > | ||
| 3294 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert : public basic_streambuf<_Elem, _Tr> { | ||
| 3295 | public: | ||
| 3296 | // types: | ||
| 3297 | typedef _Elem char_type; | ||
| 3298 | typedef _Tr traits_type; | ||
| 3299 | typedef typename traits_type::int_type int_type; | ||
| 3300 | typedef typename traits_type::pos_type pos_type; | ||
| 3301 | typedef typename traits_type::off_type off_type; | ||
| 3302 | typedef typename _Codecvt::state_type state_type; | ||
| 3303 | |||
| 3304 | private: | ||
| 3305 | char* __extbuf_; | ||
| 3306 | const char* __extbufnext_; | ||
| 3307 | const char* __extbufend_; | ||
| 3308 | char __extbuf_min_[8]; | ||
| 3309 | size_t __ebs_; | ||
| 3310 | char_type* __intbuf_; | ||
| 3311 | size_t __ibs_; | ||
| 3312 | streambuf* __bufptr_; | ||
| 3313 | _Codecvt* __cv_; | ||
| 3314 | state_type __st_; | ||
| 3315 | ios_base::openmode __cm_; | ||
| 3316 | bool __owns_eb_; | ||
| 3317 | bool __owns_ib_; | ||
| 3318 | bool __always_noconv_; | ||
| 3319 | |||
| 3320 | public: | ||
| 3321 | # ifndef _LIBCPP_CXX03_LANG | ||
| 3322 | _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {} | ||
| 3323 | explicit _LIBCPP_HIDE_FROM_ABI | ||
| 3324 | wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); | ||
| 3325 | # else | ||
| 3326 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI | ||
| 3327 | wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); | ||
| 3328 | # endif | ||
| 3329 | |||
| 3330 | _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert(); | ||
| 3331 | |||
| 3332 | _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf() const { return __bufptr_; } | ||
| 3333 | _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf(streambuf* __bytebuf) { | ||
| 3334 | streambuf* __r = __bufptr_; | ||
| 3335 | __bufptr_ = __bytebuf; | ||
| 3336 | return __r; | ||
| 3337 | } | ||
| 3338 | |||
| 3339 | wbuffer_convert(const wbuffer_convert&) = delete; | ||
| 3340 | wbuffer_convert& operator=(const wbuffer_convert&) = delete; | ||
| 3341 | |||
| 3342 | _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; } | ||
| 3343 | |||
| 3344 | protected: | ||
| 3345 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type underflow(); | ||
| 3346 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type pbackfail(int_type __c = traits_type::eof()); | ||
| 3347 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type overflow(int_type __c = traits_type::eof()); | ||
| 3348 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n); | ||
| 3349 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type | ||
| 3350 | seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch = ios_base::in | ios_base::out); | ||
| 3351 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type | ||
| 3352 | seekpos(pos_type __sp, ios_base::openmode __wch = ios_base::in | ios_base::out); | ||
| 3353 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int sync(); | ||
| 3354 | |||
| 3355 | private: | ||
| 3356 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool __read_mode(); | ||
| 3357 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __write_mode(); | ||
| 3358 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL wbuffer_convert* __close(); | ||
| 3359 | }; | ||
| 3360 | |||
| 3361 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3362 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3363 | wbuffer_convert<_Codecvt, _Elem, _Tr>::wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state) | ||
| 3364 | : __extbuf_(nullptr), | ||
| 3365 | __extbufnext_(nullptr), | ||
| 3366 | __extbufend_(nullptr), | ||
| 3367 | __ebs_(0), | ||
| 3368 | __intbuf_(0), | ||
| 3369 | __ibs_(0), | ||
| 3370 | __bufptr_(__bytebuf), | ||
| 3371 | __cv_(__pcvt), | ||
| 3372 | __st_(__state), | ||
| 3373 | __cm_(0), | ||
| 3374 | __owns_eb_(false), | ||
| 3375 | __owns_ib_(false), | ||
| 3376 | __always_noconv_(__cv_ ? __cv_->always_noconv() : false) { | ||
| 3377 | setbuf(0, 4096); | ||
| 3378 | } | ||
| 3379 | |||
| 3380 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3381 | wbuffer_convert<_Codecvt, _Elem, _Tr>::~wbuffer_convert() { | ||
| 3382 | __close(); | ||
| 3383 | delete __cv_; | ||
| 3384 | if (__owns_eb_) | ||
| 3385 | delete[] __extbuf_; | ||
| 3386 | if (__owns_ib_) | ||
| 3387 | delete[] __intbuf_; | ||
| 3388 | } | ||
| 3389 | |||
| 3390 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3391 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() { | ||
| 3392 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3393 | if (__cv_ == 0 || __bufptr_ == nullptr) | ||
| 3394 | return traits_type::eof(); | ||
| 3395 | bool __initial = __read_mode(); | ||
| 3396 | char_type __1buf; | ||
| 3397 | if (this->gptr() == 0) | ||
| 3398 | this->setg(&__1buf, &__1buf + 1, &__1buf + 1); | ||
| 3399 | const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4); | ||
| 3400 | int_type __c = traits_type::eof(); | ||
| 3401 | if (this->gptr() == this->egptr()) { | ||
| 3402 | std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); | ||
| 3403 | if (__always_noconv_) { | ||
| 3404 | streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz); | ||
| 3405 | __nmemb = __bufptr_->sgetn((char*)this->eback() + __unget_sz, __nmemb); | ||
| 3406 | if (__nmemb != 0) { | ||
| 3407 | this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb); | ||
| 3408 | __c = *this->gptr(); | ||
| 3409 | } | ||
| 3410 | } else { | ||
| 3411 | if (__extbufend_ != __extbufnext_) { | ||
| 3412 | _LIBCPP_ASSERT_NON_NULL(__extbufnext_ != nullptr, "underflow moving from nullptr"); | ||
| 3413 | _LIBCPP_ASSERT_NON_NULL(__extbuf_ != nullptr, "underflow moving into nullptr"); | ||
| 3414 | std::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); | ||
| 3415 | } | ||
| 3416 | __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); | ||
| 3417 | __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); | ||
| 3418 | streamsize __nmemb = std::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz), | ||
| 3419 | static_cast<streamsize>(__extbufend_ - __extbufnext_)); | ||
| 3420 | codecvt_base::result __r; | ||
| 3421 | // FIXME: Do we ever need to restore the state here? | ||
| 3422 | // state_type __svs = __st_; | ||
| 3423 | streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb); | ||
| 3424 | if (__nr != 0) { | ||
| 3425 | __extbufend_ = __extbufnext_ + __nr; | ||
| 3426 | char_type* __inext; | ||
| 3427 | __r = __cv_->in( | ||
| 3428 | __st_, __extbuf_, __extbufend_, __extbufnext_, this->eback() + __unget_sz, this->egptr(), __inext); | ||
| 3429 | if (__r == codecvt_base::noconv) { | ||
| 3430 | this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)const_cast<char*>(__extbufend_)); | ||
| 3431 | __c = *this->gptr(); | ||
| 3432 | } else if (__inext != this->eback() + __unget_sz) { | ||
| 3433 | this->setg(this->eback(), this->eback() + __unget_sz, __inext); | ||
| 3434 | __c = *this->gptr(); | ||
| 3435 | } | ||
| 3436 | } | ||
| 3437 | } | ||
| 3438 | } else | ||
| 3439 | __c = *this->gptr(); | ||
| 3440 | if (this->eback() == &__1buf) | ||
| 3441 | this->setg(0, 0, 0); | ||
| 3442 | return __c; | ||
| 3443 | } | ||
| 3444 | |||
| 3445 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3446 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3447 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type | ||
| 3448 | wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) { | ||
| 3449 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3450 | if (__cv_ != 0 && __bufptr_ && this->eback() < this->gptr()) { | ||
| 3451 | if (traits_type::eq_int_type(__c, traits_type::eof())) { | ||
| 3452 | this->gbump(-1); | ||
| 3453 | return traits_type::not_eof(__c); | ||
| 3454 | } | ||
| 3455 | if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) { | ||
| 3456 | this->gbump(-1); | ||
| 3457 | *this->gptr() = traits_type::to_char_type(__c); | ||
| 3458 | return __c; | ||
| 3459 | } | ||
| 3460 | } | ||
| 3461 | return traits_type::eof(); | ||
| 3462 | } | ||
| 3463 | |||
| 3464 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3465 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3466 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) { | ||
| 3467 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3468 | if (__cv_ == 0 || !__bufptr_) | ||
| 3469 | return traits_type::eof(); | ||
| 3470 | __write_mode(); | ||
| 3471 | char_type __1buf; | ||
| 3472 | char_type* __pb_save = this->pbase(); | ||
| 3473 | char_type* __epb_save = this->epptr(); | ||
| 3474 | if (!traits_type::eq_int_type(__c, traits_type::eof())) { | ||
| 3475 | if (this->pptr() == 0) | ||
| 3476 | this->setp(&__1buf, &__1buf + 1); | ||
| 3477 | *this->pptr() = traits_type::to_char_type(__c); | ||
| 3478 | this->pbump(1); | ||
| 3479 | } | ||
| 3480 | if (this->pptr() != this->pbase()) { | ||
| 3481 | if (__always_noconv_) { | ||
| 3482 | streamsize __nmemb = static_cast<streamsize>(this->pptr() - this->pbase()); | ||
| 3483 | if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb) | ||
| 3484 | return traits_type::eof(); | ||
| 3485 | } else { | ||
| 3486 | char* __extbe = __extbuf_; | ||
| 3487 | codecvt_base::result __r; | ||
| 3488 | do { | ||
| 3489 | const char_type* __e; | ||
| 3490 | __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe); | ||
| 3491 | if (__e == this->pbase()) | ||
| 3492 | return traits_type::eof(); | ||
| 3493 | if (__r == codecvt_base::noconv) { | ||
| 3494 | streamsize __nmemb = static_cast<size_t>(this->pptr() - this->pbase()); | ||
| 3495 | if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb) | ||
| 3496 | return traits_type::eof(); | ||
| 3497 | } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) { | ||
| 3498 | streamsize __nmemb = static_cast<size_t>(__extbe - __extbuf_); | ||
| 3499 | if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb) | ||
| 3500 | return traits_type::eof(); | ||
| 3501 | if (__r == codecvt_base::partial) { | ||
| 3502 | this->setp(const_cast<char_type*>(__e), this->pptr()); | ||
| 3503 | this->__pbump(this->epptr() - this->pbase()); | ||
| 3504 | } | ||
| 3505 | } else | ||
| 3506 | return traits_type::eof(); | ||
| 3507 | } while (__r == codecvt_base::partial); | ||
| 3508 | } | ||
| 3509 | this->setp(__pb_save, __epb_save); | ||
| 3510 | } | ||
| 3511 | return traits_type::not_eof(__c); | ||
| 3512 | } | ||
| 3513 | |||
| 3514 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3515 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3516 | basic_streambuf<_Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) { | ||
| 3517 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3518 | this->setg(0, 0, 0); | ||
| 3519 | this->setp(0, 0); | ||
| 3520 | if (__owns_eb_) | ||
| 3521 | delete[] __extbuf_; | ||
| 3522 | if (__owns_ib_) | ||
| 3523 | delete[] __intbuf_; | ||
| 3524 | __ebs_ = __n; | ||
| 3525 | if (__ebs_ > sizeof(__extbuf_min_)) { | ||
| 3526 | if (__always_noconv_ && __s) { | ||
| 3527 | __extbuf_ = (char*)__s; | ||
| 3528 | __owns_eb_ = false; | ||
| 3529 | } else { | ||
| 3530 | __extbuf_ = new char[__ebs_]; | ||
| 3531 | __owns_eb_ = true; | ||
| 3532 | } | ||
| 3533 | } else { | ||
| 3534 | __extbuf_ = __extbuf_min_; | ||
| 3535 | __ebs_ = sizeof(__extbuf_min_); | ||
| 3536 | __owns_eb_ = false; | ||
| 3537 | } | ||
| 3538 | if (!__always_noconv_) { | ||
| 3539 | __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_)); | ||
| 3540 | if (__s && __ibs_ >= sizeof(__extbuf_min_)) { | ||
| 3541 | __intbuf_ = __s; | ||
| 3542 | __owns_ib_ = false; | ||
| 3543 | } else { | ||
| 3544 | __intbuf_ = new char_type[__ibs_]; | ||
| 3545 | __owns_ib_ = true; | ||
| 3546 | } | ||
| 3547 | } else { | ||
| 3548 | __ibs_ = 0; | ||
| 3549 | __intbuf_ = 0; | ||
| 3550 | __owns_ib_ = false; | ||
| 3551 | } | ||
| 3552 | return this; | ||
| 3553 | } | ||
| 3554 | |||
| 3555 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3556 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3557 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type | ||
| 3558 | wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __om) { | ||
| 3559 | int __width = __cv_->encoding(); | ||
| 3560 | if (__cv_ == 0 || !__bufptr_ || (__width <= 0 && __off != 0) || sync()) | ||
| 3561 | return pos_type(off_type(-1)); | ||
| 3562 | // __width > 0 || __off == 0, now check __way | ||
| 3563 | if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end) | ||
| 3564 | return pos_type(off_type(-1)); | ||
| 3565 | pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om); | ||
| 3566 | __r.state(__st_); | ||
| 3567 | return __r; | ||
| 3568 | } | ||
| 3569 | |||
| 3570 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3571 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type | ||
| 3572 | wbuffer_convert<_Codecvt, _Elem, _Tr>::seekpos(pos_type __sp, ios_base::openmode __wch) { | ||
| 3573 | if (__cv_ == 0 || !__bufptr_ || sync()) | ||
| 3574 | return pos_type(off_type(-1)); | ||
| 3575 | if (__bufptr_->pubseekpos(__sp, __wch) == pos_type(off_type(-1))) | ||
| 3576 | return pos_type(off_type(-1)); | ||
| 3577 | return __sp; | ||
| 3578 | } | ||
| 3579 | |||
| 3580 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3581 | int wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() { | ||
| 3582 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3583 | if (__cv_ == 0 || !__bufptr_) | ||
| 3584 | return 0; | ||
| 3585 | if (__cm_ & ios_base::out) { | ||
| 3586 | if (this->pptr() != this->pbase()) | ||
| 3587 | if (overflow() == traits_type::eof()) | ||
| 3588 | return -1; | ||
| 3589 | codecvt_base::result __r; | ||
| 3590 | do { | ||
| 3591 | char* __extbe; | ||
| 3592 | __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe); | ||
| 3593 | streamsize __nmemb = static_cast<streamsize>(__extbe - __extbuf_); | ||
| 3594 | if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb) | ||
| 3595 | return -1; | ||
| 3596 | } while (__r == codecvt_base::partial); | ||
| 3597 | if (__r == codecvt_base::error) | ||
| 3598 | return -1; | ||
| 3599 | if (__bufptr_->pubsync()) | ||
| 3600 | return -1; | ||
| 3601 | } else if (__cm_ & ios_base::in) { | ||
| 3602 | off_type __c; | ||
| 3603 | if (__always_noconv_) | ||
| 3604 | __c = this->egptr() - this->gptr(); | ||
| 3605 | else { | ||
| 3606 | int __width = __cv_->encoding(); | ||
| 3607 | __c = __extbufend_ - __extbufnext_; | ||
| 3608 | if (__width > 0) | ||
| 3609 | __c += __width * (this->egptr() - this->gptr()); | ||
| 3610 | else { | ||
| 3611 | if (this->gptr() != this->egptr()) { | ||
| 3612 | std::reverse(this->gptr(), this->egptr()); | ||
| 3613 | codecvt_base::result __r; | ||
| 3614 | const char_type* __e = this->gptr(); | ||
| 3615 | char* __extbe; | ||
| 3616 | do { | ||
| 3617 | __r = __cv_->out(__st_, __e, this->egptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe); | ||
| 3618 | switch (__r) { | ||
| 3619 | case codecvt_base::noconv: | ||
| 3620 | __c += this->egptr() - this->gptr(); | ||
| 3621 | break; | ||
| 3622 | case codecvt_base::ok: | ||
| 3623 | case codecvt_base::partial: | ||
| 3624 | __c += __extbe - __extbuf_; | ||
| 3625 | break; | ||
| 3626 | default: | ||
| 3627 | return -1; | ||
| 3628 | } | ||
| 3629 | } while (__r == codecvt_base::partial); | ||
| 3630 | } | ||
| 3631 | } | ||
| 3632 | } | ||
| 3633 | if (__bufptr_->pubseekoff(-__c, ios_base::cur, __cm_) == pos_type(off_type(-1))) | ||
| 3634 | return -1; | ||
| 3635 | this->setg(0, 0, 0); | ||
| 3636 | __cm_ = 0; | ||
| 3637 | } | ||
| 3638 | return 0; | ||
| 3639 | } | ||
| 3640 | |||
| 3641 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
| 3642 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3643 | bool wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode() { | ||
| 3644 | if (!(__cm_ & ios_base::in)) { | ||
| 3645 | this->setp(0, 0); | ||
| 3646 | if (__always_noconv_) | ||
| 3647 | this->setg((char_type*)__extbuf_, (char_type*)__extbuf_ + __ebs_, (char_type*)__extbuf_ + __ebs_); | ||
| 3648 | else | ||
| 3649 | this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_); | ||
| 3650 | __cm_ = ios_base::in; | ||
| 3651 | return true; | ||
| 3652 | } | ||
| 3653 | return false; | ||
| 3654 | } | ||
| 3655 | |||
| 3656 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3657 | void wbuffer_convert<_Codecvt, _Elem, _Tr>::__write_mode() { | ||
| 3658 | if (!(__cm_ & ios_base::out)) { | ||
| 3659 | this->setg(0, 0, 0); | ||
| 3660 | if (__ebs_ > sizeof(__extbuf_min_)) { | ||
| 3661 | if (__always_noconv_) | ||
| 3662 | this->setp((char_type*)__extbuf_, (char_type*)__extbuf_ + (__ebs_ - 1)); | ||
| 3663 | else | ||
| 3664 | this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1)); | ||
| 3665 | } else | ||
| 3666 | this->setp(0, 0); | ||
| 3667 | __cm_ = ios_base::out; | ||
| 3668 | } | ||
| 3669 | } | ||
| 3670 | |||
| 3671 | template <class _Codecvt, class _Elem, class _Tr> | ||
| 3672 | wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() { | ||
| 3673 | wbuffer_convert* __rt = nullptr; | ||
| 3674 | if (__cv_ != nullptr && __bufptr_ != nullptr) { | ||
| 3675 | __rt = this; | ||
| 3676 | if ((__cm_ & ios_base::out) && sync()) | ||
| 3677 | __rt = nullptr; | ||
| 3678 | } | ||
| 3679 | return __rt; | ||
| 3680 | } | ||
| 3681 | |||
| 3682 | _LIBCPP_SUPPRESS_DEPRECATED_POP | ||
| 3683 | |||
| 3684 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | ||
| 3685 | |||
| 3686 | _LIBCPP_END_NAMESPACE_STD | ||
| 3687 | |||
| 3688 | _LIBCPP_POP_MACROS | ||
| 3689 | |||
| 3690 | // NOLINTEND(libcpp-robust-against-adl) | ||
| 3691 | |||
| 3692 | # endif // _LIBCPP_HAS_LOCALIZATION | 211 | # endif // _LIBCPP_HAS_LOCALIZATION |
| 3693 | 212 | ||
| 3694 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 213 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| ... | @@ -3697,6 +216,7 @@ _LIBCPP_POP_MACROS | ... | @@ -3697,6 +216,7 @@ _LIBCPP_POP_MACROS |
| 3697 | # include <cstdarg> | 216 | # include <cstdarg> |
| 3698 | # include <iterator> | 217 | # include <iterator> |
| 3699 | # include <mutex> | 218 | # include <mutex> |
| 219 | # include <optional> | ||
| 3700 | # include <stdexcept> | 220 | # include <stdexcept> |
| 3701 | # include <type_traits> | 221 | # include <type_traits> |
| 3702 | # include <typeinfo> | 222 | # include <typeinfo> |
lib/libcxx/include/map+94-232| ... | @@ -582,6 +582,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -582,6 +582,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 582 | # include <__functional/binary_function.h> | 582 | # include <__functional/binary_function.h> |
| 583 | # include <__functional/is_transparent.h> | 583 | # include <__functional/is_transparent.h> |
| 584 | # include <__functional/operations.h> | 584 | # include <__functional/operations.h> |
| 585 | # include <__fwd/map.h> | ||
| 585 | # include <__iterator/erase_if_container.h> | 586 | # include <__iterator/erase_if_container.h> |
| 586 | # include <__iterator/iterator_traits.h> | 587 | # include <__iterator/iterator_traits.h> |
| 587 | # include <__iterator/ranges_iterator_traits.h> | 588 | # include <__iterator/ranges_iterator_traits.h> |
| ... | @@ -592,7 +593,6 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -592,7 +593,6 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 592 | # include <__memory/pointer_traits.h> | 593 | # include <__memory/pointer_traits.h> |
| 593 | # include <__memory/unique_ptr.h> | 594 | # include <__memory/unique_ptr.h> |
| 594 | # include <__memory_resource/polymorphic_allocator.h> | 595 | # include <__memory_resource/polymorphic_allocator.h> |
| 595 | # include <__new/launder.h> | ||
| 596 | # include <__node_handle> | 596 | # include <__node_handle> |
| 597 | # include <__ranges/concepts.h> | 597 | # include <__ranges/concepts.h> |
| 598 | # include <__ranges/container_compatible_range.h> | 598 | # include <__ranges/container_compatible_range.h> |
| ... | @@ -644,13 +644,13 @@ public: | ... | @@ -644,13 +644,13 @@ public: |
| 644 | : _Compare(__c) {} | 644 | : _Compare(__c) {} |
| 645 | _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; } | 645 | _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; } |
| 646 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { | 646 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { |
| 647 | return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first); | 647 | return static_cast<const _Compare&>(*this)(__x.first, __y.first); |
| 648 | } | 648 | } |
| 649 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { | 649 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { |
| 650 | return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y); | 650 | return static_cast<const _Compare&>(*this)(__x.first, __y); |
| 651 | } | 651 | } |
| 652 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { | 652 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { |
| 653 | return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first); | 653 | return static_cast<const _Compare&>(*this)(__x, __y.first); |
| 654 | } | 654 | } |
| 655 | _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { | 655 | _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { |
| 656 | using std::swap; | 656 | using std::swap; |
| ... | @@ -660,12 +660,12 @@ public: | ... | @@ -660,12 +660,12 @@ public: |
| 660 | # if _LIBCPP_STD_VER >= 14 | 660 | # if _LIBCPP_STD_VER >= 14 |
| 661 | template <typename _K2> | 661 | template <typename _K2> |
| 662 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { | 662 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { |
| 663 | return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first); | 663 | return static_cast<const _Compare&>(*this)(__x, __y.first); |
| 664 | } | 664 | } |
| 665 | 665 | ||
| 666 | template <typename _K2> | 666 | template <typename _K2> |
| 667 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { | 667 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { |
| 668 | return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y); | 668 | return static_cast<const _Compare&>(*this)(__x.first, __y); |
| 669 | } | 669 | } |
| 670 | # endif | 670 | # endif |
| 671 | }; | 671 | }; |
| ... | @@ -681,15 +681,9 @@ public: | ... | @@ -681,15 +681,9 @@ public: |
| 681 | : __comp_(__c) {} | 681 | : __comp_(__c) {} |
| 682 | _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; } | 682 | _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; } |
| 683 | 683 | ||
| 684 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { | 684 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { return __comp_(__x.first, __y.first); } |
| 685 | return __comp_(__x.__get_value().first, __y.__get_value().first); | 685 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { return __comp_(__x.first, __y); } |
| 686 | } | 686 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { return __comp_(__x, __y.first); } |
| 687 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { | ||
| 688 | return __comp_(__x.__get_value().first, __y); | ||
| 689 | } | ||
| 690 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { | ||
| 691 | return __comp_(__x, __y.__get_value().first); | ||
| 692 | } | ||
| 693 | void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { | 687 | void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { |
| 694 | using std::swap; | 688 | using std::swap; |
| 695 | swap(__comp_, __y.__comp_); | 689 | swap(__comp_, __y.__comp_); |
| ... | @@ -698,12 +692,12 @@ public: | ... | @@ -698,12 +692,12 @@ public: |
| 698 | # if _LIBCPP_STD_VER >= 14 | 692 | # if _LIBCPP_STD_VER >= 14 |
| 699 | template <typename _K2> | 693 | template <typename _K2> |
| 700 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { | 694 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { |
| 701 | return __comp_(__x, __y.__get_value().first); | 695 | return __comp_(__x, __y.first); |
| 702 | } | 696 | } |
| 703 | 697 | ||
| 704 | template <typename _K2> | 698 | template <typename _K2> |
| 705 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { | 699 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { |
| 706 | return __comp_(__x.__get_value().first, __y); | 700 | return __comp_(__x.first, __y); |
| 707 | } | 701 | } |
| 708 | # endif | 702 | # endif |
| 709 | }; | 703 | }; |
| ... | @@ -748,135 +742,34 @@ public: | ... | @@ -748,135 +742,34 @@ public: |
| 748 | 742 | ||
| 749 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { | 743 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 750 | if (__second_constructed) | 744 | if (__second_constructed) |
| 751 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second)); | 745 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.second)); |
| 752 | if (__first_constructed) | 746 | if (__first_constructed) |
| 753 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().first)); | 747 | __alloc_traits::destroy(__na_, std::addressof(__p->__value_.first)); |
| 754 | if (__p) | 748 | if (__p) |
| 755 | __alloc_traits::deallocate(__na_, __p, 1); | 749 | __alloc_traits::deallocate(__na_, __p, 1); |
| 756 | } | 750 | } |
| 757 | }; | 751 | }; |
| 758 | 752 | ||
| 759 | template <class _Key, class _Tp, class _Compare, class _Allocator> | ||
| 760 | class map; | ||
| 761 | template <class _Key, class _Tp, class _Compare, class _Allocator> | ||
| 762 | class multimap; | ||
| 763 | template <class _TreeIterator> | ||
| 764 | class __map_const_iterator; | ||
| 765 | |||
| 766 | # ifndef _LIBCPP_CXX03_LANG | ||
| 767 | |||
| 768 | template <class _Key, class _Tp> | 753 | template <class _Key, class _Tp> |
| 769 | struct _LIBCPP_STANDALONE_DEBUG __value_type { | 754 | struct __value_type; |
| 770 | typedef _Key key_type; | ||
| 771 | typedef _Tp mapped_type; | ||
| 772 | typedef pair<const key_type, mapped_type> value_type; | ||
| 773 | typedef pair<key_type&, mapped_type&> __nc_ref_pair_type; | ||
| 774 | typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type; | ||
| 775 | |||
| 776 | private: | ||
| 777 | value_type __cc_; | ||
| 778 | |||
| 779 | public: | ||
| 780 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { | ||
| 781 | # if _LIBCPP_STD_VER >= 17 | ||
| 782 | return *std::launder(std::addressof(__cc_)); | ||
| 783 | # else | ||
| 784 | return __cc_; | ||
| 785 | # endif | ||
| 786 | } | ||
| 787 | |||
| 788 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { | ||
| 789 | # if _LIBCPP_STD_VER >= 17 | ||
| 790 | return *std::launder(std::addressof(__cc_)); | ||
| 791 | # else | ||
| 792 | return __cc_; | ||
| 793 | # endif | ||
| 794 | } | ||
| 795 | |||
| 796 | _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() { | ||
| 797 | value_type& __v = __get_value(); | ||
| 798 | return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second); | ||
| 799 | } | ||
| 800 | |||
| 801 | _LIBCPP_HIDE_FROM_ABI __nc_rref_pair_type __move() { | ||
| 802 | value_type& __v = __get_value(); | ||
| 803 | return __nc_rref_pair_type(std::move(const_cast<key_type&>(__v.first)), std::move(__v.second)); | ||
| 804 | } | ||
| 805 | |||
| 806 | _LIBCPP_HIDE_FROM_ABI __value_type& operator=(const __value_type& __v) { | ||
| 807 | __ref() = __v.__get_value(); | ||
| 808 | return *this; | ||
| 809 | } | ||
| 810 | |||
| 811 | _LIBCPP_HIDE_FROM_ABI __value_type& operator=(__value_type&& __v) { | ||
| 812 | __ref() = __v.__move(); | ||
| 813 | return *this; | ||
| 814 | } | ||
| 815 | |||
| 816 | template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0> | ||
| 817 | _LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) { | ||
| 818 | __ref() = std::forward<_ValueTp>(__v); | ||
| 819 | return *this; | ||
| 820 | } | ||
| 821 | |||
| 822 | __value_type() = delete; | ||
| 823 | ~__value_type() = delete; | ||
| 824 | __value_type(const __value_type&) = delete; | ||
| 825 | __value_type(__value_type&&) = delete; | ||
| 826 | }; | ||
| 827 | |||
| 828 | # else | ||
| 829 | |||
| 830 | template <class _Key, class _Tp> | ||
| 831 | struct __value_type { | ||
| 832 | typedef _Key key_type; | ||
| 833 | typedef _Tp mapped_type; | ||
| 834 | typedef pair<const key_type, mapped_type> value_type; | ||
| 835 | |||
| 836 | private: | ||
| 837 | value_type __cc_; | ||
| 838 | |||
| 839 | public: | ||
| 840 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } | ||
| 841 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } | ||
| 842 | |||
| 843 | __value_type() = delete; | ||
| 844 | __value_type(__value_type const&) = delete; | ||
| 845 | __value_type& operator=(__value_type const&) = delete; | ||
| 846 | ~__value_type() = delete; | ||
| 847 | }; | ||
| 848 | |||
| 849 | # endif // _LIBCPP_CXX03_LANG | ||
| 850 | |||
| 851 | template <class _Tp> | ||
| 852 | struct __extract_key_value_types; | ||
| 853 | |||
| 854 | template <class _Key, class _Tp> | ||
| 855 | struct __extract_key_value_types<__value_type<_Key, _Tp> > { | ||
| 856 | typedef _Key const __key_type; | ||
| 857 | typedef _Tp __mapped_type; | ||
| 858 | }; | ||
| 859 | 755 | ||
| 860 | template <class _TreeIterator> | 756 | template <class _TreeIterator> |
| 861 | class _LIBCPP_TEMPLATE_VIS __map_iterator { | 757 | class __map_iterator { |
| 862 | typedef typename _TreeIterator::_NodeTypes _NodeTypes; | ||
| 863 | typedef typename _TreeIterator::__pointer_traits __pointer_traits; | ||
| 864 | |||
| 865 | _TreeIterator __i_; | 758 | _TreeIterator __i_; |
| 866 | 759 | ||
| 867 | public: | 760 | public: |
| 868 | typedef bidirectional_iterator_tag iterator_category; | 761 | using iterator_category = bidirectional_iterator_tag; |
| 869 | typedef typename _NodeTypes::__map_value_type value_type; | 762 | using value_type = typename _TreeIterator::value_type; |
| 870 | typedef typename _TreeIterator::difference_type difference_type; | 763 | using difference_type = typename _TreeIterator::difference_type; |
| 871 | typedef value_type& reference; | 764 | using reference = value_type&; |
| 872 | typedef typename _NodeTypes::__map_value_type_pointer pointer; | 765 | using pointer = typename _TreeIterator::pointer; |
| 873 | 766 | ||
| 874 | _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {} | 767 | _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {} |
| 875 | 768 | ||
| 876 | _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} | 769 | _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} |
| 877 | 770 | ||
| 878 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } | 771 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; } |
| 879 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } | 772 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); } |
| 880 | 773 | ||
| 881 | _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() { | 774 | _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() { |
| 882 | ++__i_; | 775 | ++__i_; |
| ... | @@ -906,26 +799,23 @@ public: | ... | @@ -906,26 +799,23 @@ public: |
| 906 | } | 799 | } |
| 907 | 800 | ||
| 908 | template <class, class, class, class> | 801 | template <class, class, class, class> |
| 909 | friend class _LIBCPP_TEMPLATE_VIS map; | 802 | friend class map; |
| 910 | template <class, class, class, class> | 803 | template <class, class, class, class> |
| 911 | friend class _LIBCPP_TEMPLATE_VIS multimap; | 804 | friend class multimap; |
| 912 | template <class> | 805 | template <class> |
| 913 | friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; | 806 | friend class __map_const_iterator; |
| 914 | }; | 807 | }; |
| 915 | 808 | ||
| 916 | template <class _TreeIterator> | 809 | template <class _TreeIterator> |
| 917 | class _LIBCPP_TEMPLATE_VIS __map_const_iterator { | 810 | class __map_const_iterator { |
| 918 | typedef typename _TreeIterator::_NodeTypes _NodeTypes; | ||
| 919 | typedef typename _TreeIterator::__pointer_traits __pointer_traits; | ||
| 920 | |||
| 921 | _TreeIterator __i_; | 811 | _TreeIterator __i_; |
| 922 | 812 | ||
| 923 | public: | 813 | public: |
| 924 | typedef bidirectional_iterator_tag iterator_category; | 814 | using iterator_category = bidirectional_iterator_tag; |
| 925 | typedef typename _NodeTypes::__map_value_type value_type; | 815 | using value_type = typename _TreeIterator::value_type; |
| 926 | typedef typename _TreeIterator::difference_type difference_type; | 816 | using difference_type = typename _TreeIterator::difference_type; |
| 927 | typedef const value_type& reference; | 817 | using reference = const value_type&; |
| 928 | typedef typename _NodeTypes::__const_map_value_type_pointer pointer; | 818 | using pointer = typename _TreeIterator::pointer; |
| 929 | 819 | ||
| 930 | _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {} | 820 | _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {} |
| 931 | 821 | ||
| ... | @@ -933,8 +823,8 @@ public: | ... | @@ -933,8 +823,8 @@ public: |
| 933 | _LIBCPP_HIDE_FROM_ABI | 823 | _LIBCPP_HIDE_FROM_ABI |
| 934 | __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {} | 824 | __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {} |
| 935 | 825 | ||
| 936 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } | 826 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; } |
| 937 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } | 827 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); } |
| 938 | 828 | ||
| 939 | _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() { | 829 | _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() { |
| 940 | ++__i_; | 830 | ++__i_; |
| ... | @@ -964,15 +854,15 @@ public: | ... | @@ -964,15 +854,15 @@ public: |
| 964 | } | 854 | } |
| 965 | 855 | ||
| 966 | template <class, class, class, class> | 856 | template <class, class, class, class> |
| 967 | friend class _LIBCPP_TEMPLATE_VIS map; | 857 | friend class map; |
| 968 | template <class, class, class, class> | 858 | template <class, class, class, class> |
| 969 | friend class _LIBCPP_TEMPLATE_VIS multimap; | 859 | friend class multimap; |
| 970 | template <class, class, class> | 860 | template <class, class, class> |
| 971 | friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; | 861 | friend class __tree_const_iterator; |
| 972 | }; | 862 | }; |
| 973 | 863 | ||
| 974 | template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > | 864 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 975 | class _LIBCPP_TEMPLATE_VIS map { | 865 | class map { |
| 976 | public: | 866 | public: |
| 977 | // types: | 867 | // types: |
| 978 | typedef _Key key_type; | 868 | typedef _Key key_type; |
| ... | @@ -986,7 +876,7 @@ public: | ... | @@ -986,7 +876,7 @@ public: |
| 986 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | 876 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| 987 | "Allocator::value_type must be same type as value_type"); | 877 | "Allocator::value_type must be same type as value_type"); |
| 988 | 878 | ||
| 989 | class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { | 879 | class value_compare : public __binary_function<value_type, value_type, bool> { |
| 990 | friend class map; | 880 | friend class map; |
| 991 | 881 | ||
| 992 | protected: | 882 | protected: |
| ... | @@ -1002,9 +892,8 @@ public: | ... | @@ -1002,9 +892,8 @@ public: |
| 1002 | 892 | ||
| 1003 | private: | 893 | private: |
| 1004 | typedef std::__value_type<key_type, mapped_type> __value_type; | 894 | typedef std::__value_type<key_type, mapped_type> __value_type; |
| 1005 | typedef __map_value_compare<key_type, __value_type, key_compare> __vc; | 895 | typedef __map_value_compare<key_type, value_type, key_compare> __vc; |
| 1006 | typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; | 896 | typedef __tree<__value_type, __vc, allocator_type> __base; |
| 1007 | typedef __tree<__value_type, __vc, __allocator_type> __base; | ||
| 1008 | typedef typename __base::__node_traits __node_traits; | 897 | typedef typename __base::__node_traits __node_traits; |
| 1009 | typedef allocator_traits<allocator_type> __alloc_traits; | 898 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1010 | 899 | ||
| ... | @@ -1028,9 +917,9 @@ public: | ... | @@ -1028,9 +917,9 @@ public: |
| 1028 | # endif | 917 | # endif |
| 1029 | 918 | ||
| 1030 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> | 919 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1031 | friend class _LIBCPP_TEMPLATE_VIS map; | 920 | friend class map; |
| 1032 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> | 921 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1033 | friend class _LIBCPP_TEMPLATE_VIS multimap; | 922 | friend class multimap; |
| 1034 | 923 | ||
| 1035 | _LIBCPP_HIDE_FROM_ABI map() _NOEXCEPT_( | 924 | _LIBCPP_HIDE_FROM_ABI map() _NOEXCEPT_( |
| 1036 | is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&& | 925 | is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&& |
| ... | @@ -1083,31 +972,15 @@ public: | ... | @@ -1083,31 +972,15 @@ public: |
| 1083 | 972 | ||
| 1084 | _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); } | 973 | _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); } |
| 1085 | 974 | ||
| 1086 | _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) { | 975 | _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) = default; |
| 1087 | # ifndef _LIBCPP_CXX03_LANG | ||
| 1088 | __tree_ = __m.__tree_; | ||
| 1089 | # else | ||
| 1090 | if (this != std::addressof(__m)) { | ||
| 1091 | __tree_.clear(); | ||
| 1092 | __tree_.value_comp() = __m.__tree_.value_comp(); | ||
| 1093 | __tree_.__copy_assign_alloc(__m.__tree_); | ||
| 1094 | insert(__m.begin(), __m.end()); | ||
| 1095 | } | ||
| 1096 | # endif | ||
| 1097 | return *this; | ||
| 1098 | } | ||
| 1099 | 976 | ||
| 1100 | # ifndef _LIBCPP_CXX03_LANG | 977 | # ifndef _LIBCPP_CXX03_LANG |
| 1101 | 978 | ||
| 1102 | _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) | 979 | _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) = default; |
| 1103 | : __tree_(std::move(__m.__tree_)) {} | ||
| 1104 | 980 | ||
| 1105 | _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a); | 981 | _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a); |
| 1106 | 982 | ||
| 1107 | _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) { | 983 | _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) = default; |
| 1108 | __tree_ = std::move(__m.__tree_); | ||
| 1109 | return *this; | ||
| 1110 | } | ||
| 1111 | 984 | ||
| 1112 | _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 985 | _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 1113 | : __tree_(__vc(__comp)) { | 986 | : __tree_(__vc(__comp)) { |
| ... | @@ -1138,7 +1011,7 @@ public: | ... | @@ -1138,7 +1011,7 @@ public: |
| 1138 | insert(__m.begin(), __m.end()); | 1011 | insert(__m.begin(), __m.end()); |
| 1139 | } | 1012 | } |
| 1140 | 1013 | ||
| 1141 | _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } | 1014 | _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); } |
| 1142 | 1015 | ||
| 1143 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 1016 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 1144 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 1017 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| ... | @@ -1184,29 +1057,29 @@ public: | ... | @@ -1184,29 +1057,29 @@ public: |
| 1184 | 1057 | ||
| 1185 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1058 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1186 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) { | 1059 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) { |
| 1187 | return __tree_.__insert_unique(std::forward<_Pp>(__p)); | 1060 | return __tree_.__emplace_unique(std::forward<_Pp>(__p)); |
| 1188 | } | 1061 | } |
| 1189 | 1062 | ||
| 1190 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1063 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1191 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { | 1064 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { |
| 1192 | return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p)); | 1065 | return __tree_.__emplace_hint_unique(__pos.__i_, std::forward<_Pp>(__p)); |
| 1193 | } | 1066 | } |
| 1194 | 1067 | ||
| 1195 | # endif // _LIBCPP_CXX03_LANG | 1068 | # endif // _LIBCPP_CXX03_LANG |
| 1196 | 1069 | ||
| 1197 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); } | 1070 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); } |
| 1198 | 1071 | ||
| 1199 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { | 1072 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| 1200 | return __tree_.__insert_unique(__p.__i_, __v); | 1073 | return __tree_.__emplace_hint_unique(__p.__i_, __v); |
| 1201 | } | 1074 | } |
| 1202 | 1075 | ||
| 1203 | # ifndef _LIBCPP_CXX03_LANG | 1076 | # ifndef _LIBCPP_CXX03_LANG |
| 1204 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) { | 1077 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) { |
| 1205 | return __tree_.__insert_unique(std::move(__v)); | 1078 | return __tree_.__emplace_unique(std::move(__v)); |
| 1206 | } | 1079 | } |
| 1207 | 1080 | ||
| 1208 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { | 1081 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { |
| 1209 | return __tree_.__insert_unique(__p.__i_, std::move(__v)); | 1082 | return __tree_.__emplace_hint_unique(__p.__i_, std::move(__v)); |
| 1210 | } | 1083 | } |
| 1211 | 1084 | ||
| 1212 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 1085 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| ... | @@ -1297,7 +1170,7 @@ public: | ... | @@ -1297,7 +1170,7 @@ public: |
| 1297 | auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, __k, std::forward<_Vp>(__v)); | 1170 | auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, __k, std::forward<_Vp>(__v)); |
| 1298 | 1171 | ||
| 1299 | if (!__inserted) | 1172 | if (!__inserted) |
| 1300 | __r->__get_value().second = std::forward<_Vp>(__v); | 1173 | __r->second = std::forward<_Vp>(__v); |
| 1301 | 1174 | ||
| 1302 | return __r; | 1175 | return __r; |
| 1303 | } | 1176 | } |
| ... | @@ -1308,7 +1181,7 @@ public: | ... | @@ -1308,7 +1181,7 @@ public: |
| 1308 | __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, std::move(__k), std::forward<_Vp>(__v)); | 1181 | __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, std::move(__k), std::forward<_Vp>(__v)); |
| 1309 | 1182 | ||
| 1310 | if (!__inserted) | 1183 | if (!__inserted) |
| 1311 | __r->__get_value().second = std::forward<_Vp>(__v); | 1184 | __r->second = std::forward<_Vp>(__v); |
| 1312 | 1185 | ||
| 1313 | return __r; | 1186 | return __r; |
| 1314 | } | 1187 | } |
| ... | @@ -1513,8 +1386,9 @@ map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) | ... | @@ -1513,8 +1386,9 @@ map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) |
| 1513 | : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { | 1386 | : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { |
| 1514 | if (__a != __m.get_allocator()) { | 1387 | if (__a != __m.get_allocator()) { |
| 1515 | const_iterator __e = cend(); | 1388 | const_iterator __e = cend(); |
| 1516 | while (!__m.empty()) | 1389 | while (!__m.empty()) { |
| 1517 | __tree_.__insert_unique(__e.__i_, __m.__tree_.remove(__m.begin().__i_)->__value_.__move()); | 1390 | __tree_.__insert_unique_from_orphaned_node(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_)); |
| 1391 | } | ||
| 1518 | } | 1392 | } |
| 1519 | } | 1393 | } |
| 1520 | 1394 | ||
| ... | @@ -1522,8 +1396,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator> | ... | @@ -1522,8 +1396,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1522 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { | 1396 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { |
| 1523 | return __tree_ | 1397 | return __tree_ |
| 1524 | .__emplace_unique_key_args(__k, std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) | 1398 | .__emplace_unique_key_args(__k, std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) |
| 1525 | .first->__get_value() | 1399 | .first->second; |
| 1526 | .second; | ||
| 1527 | } | 1400 | } |
| 1528 | 1401 | ||
| 1529 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1402 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1533,8 +1406,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { | ... | @@ -1533,8 +1406,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { |
| 1533 | return __tree_ | 1406 | return __tree_ |
| 1534 | .__emplace_unique_key_args( | 1407 | .__emplace_unique_key_args( |
| 1535 | __k, std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) | 1408 | __k, std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) |
| 1536 | .first->__get_value() | 1409 | .first->second; |
| 1537 | .second; | ||
| 1538 | // NOLINTEND(bugprone-use-after-move) | 1410 | // NOLINTEND(bugprone-use-after-move) |
| 1539 | } | 1411 | } |
| 1540 | 1412 | ||
| ... | @@ -1545,9 +1417,9 @@ typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder | ... | @@ -1545,9 +1417,9 @@ typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder |
| 1545 | map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) { | 1417 | map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) { |
| 1546 | __node_allocator& __na = __tree_.__node_alloc(); | 1418 | __node_allocator& __na = __tree_.__node_alloc(); |
| 1547 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1419 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1548 | __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().first), __k); | 1420 | __node_traits::construct(__na, std::addressof(__h->__value_.first), __k); |
| 1549 | __h.get_deleter().__first_constructed = true; | 1421 | __h.get_deleter().__first_constructed = true; |
| 1550 | __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().second)); | 1422 | __node_traits::construct(__na, std::addressof(__h->__value_.second)); |
| 1551 | __h.get_deleter().__second_constructed = true; | 1423 | __h.get_deleter().__second_constructed = true; |
| 1552 | return __h; | 1424 | return __h; |
| 1553 | } | 1425 | } |
| ... | @@ -1562,7 +1434,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { | ... | @@ -1562,7 +1434,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { |
| 1562 | __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); | 1434 | __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
| 1563 | __r = __h.release(); | 1435 | __r = __h.release(); |
| 1564 | } | 1436 | } |
| 1565 | return __r->__value_.__get_value().second; | 1437 | return __r->__value_.second; |
| 1566 | } | 1438 | } |
| 1567 | 1439 | ||
| 1568 | # endif // _LIBCPP_CXX03_LANG | 1440 | # endif // _LIBCPP_CXX03_LANG |
| ... | @@ -1572,8 +1444,8 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { | ... | @@ -1572,8 +1444,8 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { |
| 1572 | __parent_pointer __parent; | 1444 | __parent_pointer __parent; |
| 1573 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); | 1445 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); |
| 1574 | if (__child == nullptr) | 1446 | if (__child == nullptr) |
| 1575 | __throw_out_of_range("map::at: key not found"); | 1447 | std::__throw_out_of_range("map::at: key not found"); |
| 1576 | return static_cast<__node_pointer>(__child)->__value_.__get_value().second; | 1448 | return static_cast<__node_pointer>(__child)->__value_.second; |
| 1577 | } | 1449 | } |
| 1578 | 1450 | ||
| 1579 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1451 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1581,8 +1453,8 @@ const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const { | ... | @@ -1581,8 +1453,8 @@ const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const { |
| 1581 | __parent_pointer __parent; | 1453 | __parent_pointer __parent; |
| 1582 | __node_base_pointer __child = __tree_.__find_equal(__parent, __k); | 1454 | __node_base_pointer __child = __tree_.__find_equal(__parent, __k); |
| 1583 | if (__child == nullptr) | 1455 | if (__child == nullptr) |
| 1584 | __throw_out_of_range("map::at: key not found"); | 1456 | std::__throw_out_of_range("map::at: key not found"); |
| 1585 | return static_cast<__node_pointer>(__child)->__value_.__get_value().second; | 1457 | return static_cast<__node_pointer>(__child)->__value_.second; |
| 1586 | } | 1458 | } |
| 1587 | 1459 | ||
| 1588 | template <class _Key, class _Tp, class _Compare, class _Allocator> | 1460 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| ... | @@ -1654,10 +1526,12 @@ struct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > { | ... | @@ -1654,10 +1526,12 @@ struct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > { |
| 1654 | // For associative containers, if an exception is thrown by any operation from within | 1526 | // For associative containers, if an exception is thrown by any operation from within |
| 1655 | // an insert or emplace function inserting a single element, the insertion has no effect. | 1527 | // an insert or emplace function inserting a single element, the insertion has no effect. |
| 1656 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | 1528 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; |
| 1529 | |||
| 1530 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 1657 | }; | 1531 | }; |
| 1658 | 1532 | ||
| 1659 | template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > | 1533 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1660 | class _LIBCPP_TEMPLATE_VIS multimap { | 1534 | class multimap { |
| 1661 | public: | 1535 | public: |
| 1662 | // types: | 1536 | // types: |
| 1663 | typedef _Key key_type; | 1537 | typedef _Key key_type; |
| ... | @@ -1672,7 +1546,7 @@ public: | ... | @@ -1672,7 +1546,7 @@ public: |
| 1672 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | 1546 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| 1673 | "Allocator::value_type must be same type as value_type"); | 1547 | "Allocator::value_type must be same type as value_type"); |
| 1674 | 1548 | ||
| 1675 | class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> { | 1549 | class value_compare : public __binary_function<value_type, value_type, bool> { |
| 1676 | friend class multimap; | 1550 | friend class multimap; |
| 1677 | 1551 | ||
| 1678 | protected: | 1552 | protected: |
| ... | @@ -1688,9 +1562,8 @@ public: | ... | @@ -1688,9 +1562,8 @@ public: |
| 1688 | 1562 | ||
| 1689 | private: | 1563 | private: |
| 1690 | typedef std::__value_type<key_type, mapped_type> __value_type; | 1564 | typedef std::__value_type<key_type, mapped_type> __value_type; |
| 1691 | typedef __map_value_compare<key_type, __value_type, key_compare> __vc; | 1565 | typedef __map_value_compare<key_type, value_type, key_compare> __vc; |
| 1692 | typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; | 1566 | typedef __tree<__value_type, __vc, allocator_type> __base; |
| 1693 | typedef __tree<__value_type, __vc, __allocator_type> __base; | ||
| 1694 | typedef typename __base::__node_traits __node_traits; | 1567 | typedef typename __base::__node_traits __node_traits; |
| 1695 | typedef allocator_traits<allocator_type> __alloc_traits; | 1568 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1696 | 1569 | ||
| ... | @@ -1711,9 +1584,9 @@ public: | ... | @@ -1711,9 +1584,9 @@ public: |
| 1711 | # endif | 1584 | # endif |
| 1712 | 1585 | ||
| 1713 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> | 1586 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1714 | friend class _LIBCPP_TEMPLATE_VIS map; | 1587 | friend class map; |
| 1715 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> | 1588 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1716 | friend class _LIBCPP_TEMPLATE_VIS multimap; | 1589 | friend class multimap; |
| 1717 | 1590 | ||
| 1718 | _LIBCPP_HIDE_FROM_ABI multimap() _NOEXCEPT_( | 1591 | _LIBCPP_HIDE_FROM_ABI multimap() _NOEXCEPT_( |
| 1719 | is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&& | 1592 | is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&& |
| ... | @@ -1770,31 +1643,16 @@ public: | ... | @@ -1770,31 +1643,16 @@ public: |
| 1770 | insert(__m.begin(), __m.end()); | 1643 | insert(__m.begin(), __m.end()); |
| 1771 | } | 1644 | } |
| 1772 | 1645 | ||
| 1773 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) { | 1646 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) = default; |
| 1774 | # ifndef _LIBCPP_CXX03_LANG | ||
| 1775 | __tree_ = __m.__tree_; | ||
| 1776 | # else | ||
| 1777 | if (this != std::addressof(__m)) { | ||
| 1778 | __tree_.clear(); | ||
| 1779 | __tree_.value_comp() = __m.__tree_.value_comp(); | ||
| 1780 | __tree_.__copy_assign_alloc(__m.__tree_); | ||
| 1781 | insert(__m.begin(), __m.end()); | ||
| 1782 | } | ||
| 1783 | # endif | ||
| 1784 | return *this; | ||
| 1785 | } | ||
| 1786 | 1647 | ||
| 1787 | # ifndef _LIBCPP_CXX03_LANG | 1648 | # ifndef _LIBCPP_CXX03_LANG |
| 1788 | 1649 | ||
| 1789 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value) | 1650 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value) = default; |
| 1790 | : __tree_(std::move(__m.__tree_)) {} | ||
| 1791 | 1651 | ||
| 1792 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a); | 1652 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a); |
| 1793 | 1653 | ||
| 1794 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) { | 1654 | _LIBCPP_HIDE_FROM_ABI multimap& |
| 1795 | __tree_ = std::move(__m.__tree_); | 1655 | operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) = default; |
| 1796 | return *this; | ||
| 1797 | } | ||
| 1798 | 1656 | ||
| 1799 | _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | 1657 | _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 1800 | : __tree_(__vc(__comp)) { | 1658 | : __tree_(__vc(__comp)) { |
| ... | @@ -1826,7 +1684,9 @@ public: | ... | @@ -1826,7 +1684,9 @@ public: |
| 1826 | insert(__m.begin(), __m.end()); | 1684 | insert(__m.begin(), __m.end()); |
| 1827 | } | 1685 | } |
| 1828 | 1686 | ||
| 1829 | _LIBCPP_HIDE_FROM_ABI ~multimap() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } | 1687 | _LIBCPP_HIDE_FROM_ABI ~multimap() { |
| 1688 | static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); | ||
| 1689 | } | ||
| 1830 | 1690 | ||
| 1831 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 1691 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 1832 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 1692 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| ... | @@ -1865,34 +1725,34 @@ public: | ... | @@ -1865,34 +1725,34 @@ public: |
| 1865 | 1725 | ||
| 1866 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1726 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1867 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) { | 1727 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) { |
| 1868 | return __tree_.__insert_multi(std::forward<_Pp>(__p)); | 1728 | return __tree_.__emplace_multi(std::forward<_Pp>(__p)); |
| 1869 | } | 1729 | } |
| 1870 | 1730 | ||
| 1871 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1731 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1872 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { | 1732 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { |
| 1873 | return __tree_.__insert_multi(__pos.__i_, std::forward<_Pp>(__p)); | 1733 | return __tree_.__emplace_hint_multi(__pos.__i_, std::forward<_Pp>(__p)); |
| 1874 | } | 1734 | } |
| 1875 | 1735 | ||
| 1876 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); } | 1736 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__emplace_multi(std::move(__v)); } |
| 1877 | 1737 | ||
| 1878 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { | 1738 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { |
| 1879 | return __tree_.__insert_multi(__p.__i_, std::move(__v)); | 1739 | return __tree_.__emplace_hint_multi(__p.__i_, std::move(__v)); |
| 1880 | } | 1740 | } |
| 1881 | 1741 | ||
| 1882 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 1742 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1883 | 1743 | ||
| 1884 | # endif // _LIBCPP_CXX03_LANG | 1744 | # endif // _LIBCPP_CXX03_LANG |
| 1885 | 1745 | ||
| 1886 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } | 1746 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__emplace_multi(__v); } |
| 1887 | 1747 | ||
| 1888 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { | 1748 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| 1889 | return __tree_.__insert_multi(__p.__i_, __v); | 1749 | return __tree_.__emplace_hint_multi(__p.__i_, __v); |
| 1890 | } | 1750 | } |
| 1891 | 1751 | ||
| 1892 | template <class _InputIterator> | 1752 | template <class _InputIterator> |
| 1893 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { | 1753 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { |
| 1894 | for (const_iterator __e = cend(); __f != __l; ++__f) | 1754 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1895 | __tree_.__insert_multi(__e.__i_, *__f); | 1755 | __tree_.__emplace_hint_multi(__e.__i_, *__f); |
| 1896 | } | 1756 | } |
| 1897 | 1757 | ||
| 1898 | # if _LIBCPP_STD_VER >= 23 | 1758 | # if _LIBCPP_STD_VER >= 23 |
| ... | @@ -1900,7 +1760,7 @@ public: | ... | @@ -1900,7 +1760,7 @@ public: |
| 1900 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1760 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1901 | const_iterator __end = cend(); | 1761 | const_iterator __end = cend(); |
| 1902 | for (auto&& __element : __range) { | 1762 | for (auto&& __element : __range) { |
| 1903 | __tree_.__insert_multi(__end.__i_, std::forward<decltype(__element)>(__element)); | 1763 | __tree_.__emplace_hint_multi(__end.__i_, std::forward<decltype(__element)>(__element)); |
| 1904 | } | 1764 | } |
| 1905 | } | 1765 | } |
| 1906 | # endif | 1766 | # endif |
| ... | @@ -2101,7 +1961,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca | ... | @@ -2101,7 +1961,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca |
| 2101 | if (__a != __m.get_allocator()) { | 1961 | if (__a != __m.get_allocator()) { |
| 2102 | const_iterator __e = cend(); | 1962 | const_iterator __e = cend(); |
| 2103 | while (!__m.empty()) | 1963 | while (!__m.empty()) |
| 2104 | __tree_.__insert_multi(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move())); | 1964 | __tree_.__insert_multi_from_orphaned_node(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_)); |
| 2105 | } | 1965 | } |
| 2106 | } | 1966 | } |
| 2107 | # endif | 1967 | # endif |
| ... | @@ -2176,6 +2036,8 @@ struct __container_traits<multimap<_Key, _Tp, _Compare, _Allocator> > { | ... | @@ -2176,6 +2036,8 @@ struct __container_traits<multimap<_Key, _Tp, _Compare, _Allocator> > { |
| 2176 | // For associative containers, if an exception is thrown by any operation from within | 2036 | // For associative containers, if an exception is thrown by any operation from within |
| 2177 | // an insert or emplace function inserting a single element, the insertion has no effect. | 2037 | // an insert or emplace function inserting a single element, the insertion has no effect. |
| 2178 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | 2038 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; |
| 2039 | |||
| 2040 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 2179 | }; | 2041 | }; |
| 2180 | 2042 | ||
| 2181 | _LIBCPP_END_NAMESPACE_STD | 2043 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/math.h+1-10| ... | @@ -378,9 +378,7 @@ extern "C++" { | ... | @@ -378,9 +378,7 @@ extern "C++" { |
| 378 | # include <__math/traits.h> | 378 | # include <__math/traits.h> |
| 379 | # include <__math/trigonometric_functions.h> | 379 | # include <__math/trigonometric_functions.h> |
| 380 | # include <__type_traits/enable_if.h> | 380 | # include <__type_traits/enable_if.h> |
| 381 | # include <__type_traits/is_floating_point.h> | ||
| 382 | # include <__type_traits/is_integral.h> | 381 | # include <__type_traits/is_integral.h> |
| 383 | # include <stdlib.h> | ||
| 384 | 382 | ||
| 385 | // fpclassify relies on implementation-defined constants, so we can't move it to a detail header | 383 | // fpclassify relies on implementation-defined constants, so we can't move it to a detail header |
| 386 | _LIBCPP_BEGIN_NAMESPACE_STD | 384 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | @@ -431,19 +429,12 @@ using std::__math::isnormal; | ... | @@ -431,19 +429,12 @@ using std::__math::isnormal; |
| 431 | using std::__math::isunordered; | 429 | using std::__math::isunordered; |
| 432 | # endif // _LIBCPP_MSVCRT | 430 | # endif // _LIBCPP_MSVCRT |
| 433 | 431 | ||
| 434 | // abs | ||
| 435 | // | ||
| 436 | // handled in stdlib.h | ||
| 437 | |||
| 438 | // div | ||
| 439 | // | ||
| 440 | // handled in stdlib.h | ||
| 441 | |||
| 442 | // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math | 432 | // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math |
| 443 | // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads | 433 | // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads |
| 444 | // templates. Functions are preferred over function templates during overload resolution, which means that our overload | 434 | // templates. Functions are preferred over function templates during overload resolution, which means that our overload |
| 445 | // will only be selected when the C library doesn't provide one. | 435 | // will only be selected when the C library doesn't provide one. |
| 446 | 436 | ||
| 437 | using std::__math::abs; | ||
| 447 | using std::__math::acos; | 438 | using std::__math::acos; |
| 448 | using std::__math::acosh; | 439 | using std::__math::acosh; |
| 449 | using std::__math::asin; | 440 | using std::__math::asin; |
lib/libcxx/include/mdspan+44-3| ... | @@ -33,10 +33,14 @@ namespace std { | ... | @@ -33,10 +33,14 @@ namespace std { |
| 33 | template<class ElementType> | 33 | template<class ElementType> |
| 34 | class default_accessor; | 34 | class default_accessor; |
| 35 | 35 | ||
| 36 | // [mdspan.accessor.aligned], class template aligned_accessor | ||
| 37 | template<class ElementType, size_t ByteAlignment> | ||
| 38 | class aligned_accessor; // since C++26 | ||
| 39 | |||
| 36 | // [mdspan.mdspan], class template mdspan | 40 | // [mdspan.mdspan], class template mdspan |
| 37 | template<class ElementType, class Extents, class LayoutPolicy = layout_right, | 41 | template<class ElementType, class Extents, class LayoutPolicy = layout_right, |
| 38 | class AccessorPolicy = default_accessor<ElementType>> | 42 | class AccessorPolicy = default_accessor<ElementType>> |
| 39 | class mdspan; // not implemented yet | 43 | class mdspan; |
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | // extents synopsis | 46 | // extents synopsis |
| ... | @@ -269,6 +273,38 @@ namespace std { | ... | @@ -269,6 +273,38 @@ namespace std { |
| 269 | }; | 273 | }; |
| 270 | } | 274 | } |
| 271 | 275 | ||
| 276 | // aligned_accessor synopsis | ||
| 277 | |||
| 278 | namespace std { | ||
| 279 | template<class ElementType, size_t ByteAlignment> | ||
| 280 | struct aligned_accessor { | ||
| 281 | using offset_policy = default_accessor<ElementType>; | ||
| 282 | using element_type = ElementType; | ||
| 283 | using reference = ElementType&; | ||
| 284 | using data_handle_type = ElementType*; | ||
| 285 | |||
| 286 | static constexpr size_t byte_alignment = ByteAlignment; | ||
| 287 | |||
| 288 | constexpr aligned_accessor() noexcept = default; | ||
| 289 | |||
| 290 | template<class OtherElementType, size_t OtherByteAlignment> | ||
| 291 | constexpr aligned_accessor( | ||
| 292 | aligned_accessor<OtherElementType, OtherByteAlignment>) noexcept; | ||
| 293 | |||
| 294 | template<class OtherElementType> | ||
| 295 | explicit constexpr aligned_accessor( | ||
| 296 | default_accessor<OtherElementType>) noexcept; | ||
| 297 | |||
| 298 | template<class OtherElementType> | ||
| 299 | constexpr operator default_accessor<OtherElementType>() const noexcept; | ||
| 300 | |||
| 301 | constexpr reference access(data_handle_type p, size_t i) const noexcept; | ||
| 302 | |||
| 303 | constexpr typename offset_policy::data_handle_type | ||
| 304 | offset(data_handle_type p, size_t i) const noexcept; | ||
| 305 | }; | ||
| 306 | } | ||
| 307 | |||
| 272 | // mdspan synopsis | 308 | // mdspan synopsis |
| 273 | 309 | ||
| 274 | namespace std { | 310 | namespace std { |
| ... | @@ -409,12 +445,17 @@ namespace std { | ... | @@ -409,12 +445,17 @@ namespace std { |
| 409 | #define _LIBCPP_MDSPAN | 445 | #define _LIBCPP_MDSPAN |
| 410 | 446 | ||
| 411 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 447 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 412 | # include <__cxx03/mdspan> | 448 | # include <__cxx03/__config> |
| 413 | #else | 449 | #else |
| 414 | # include <__config> | 450 | # include <__config> |
| 415 | 451 | ||
| 416 | # if _LIBCPP_STD_VER >= 23 | 452 | # if _LIBCPP_STD_VER >= 23 |
| 417 | # include <__fwd/mdspan.h> | 453 | # include <__fwd/mdspan.h> // TODO(boomanaiden154): This is currently a |
| 454 | // non-standard extension to include | ||
| 455 | // std::dynamic_extent tracked by LWG issue 4275. | ||
| 456 | // This comment should be deleted or the include | ||
| 457 | // deleted upon resolution. | ||
| 458 | # include <__fwd/span.h> | ||
| 418 | # include <__mdspan/default_accessor.h> | 459 | # include <__mdspan/default_accessor.h> |
| 419 | # include <__mdspan/extents.h> | 460 | # include <__mdspan/extents.h> |
| 420 | # include <__mdspan/layout_left.h> | 461 | # include <__mdspan/layout_left.h> |
lib/libcxx/include/memory+6| ... | @@ -912,6 +912,9 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); | ... | @@ -912,6 +912,9 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); |
| 912 | template<size_t N, class T> | 912 | template<size_t N, class T> |
| 913 | [[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20 | 913 | [[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20 |
| 914 | 914 | ||
| 915 | template<size_t Alignment, class T> | ||
| 916 | bool is_sufficiently_aligned(T* ptr); // since C++26 | ||
| 917 | |||
| 915 | // [out.ptr.t], class template out_ptr_t | 918 | // [out.ptr.t], class template out_ptr_t |
| 916 | template<class Smart, class Pointer, class... Args> | 919 | template<class Smart, class Pointer, class... Args> |
| 917 | class out_ptr_t; // since c++23 | 920 | class out_ptr_t; // since c++23 |
| ... | @@ -945,6 +948,7 @@ template<class Pointer = void, class Smart, class... Args> | ... | @@ -945,6 +948,7 @@ template<class Pointer = void, class Smart, class... Args> |
| 945 | # include <__memory/allocator_traits.h> | 948 | # include <__memory/allocator_traits.h> |
| 946 | # include <__memory/auto_ptr.h> | 949 | # include <__memory/auto_ptr.h> |
| 947 | # include <__memory/inout_ptr.h> | 950 | # include <__memory/inout_ptr.h> |
| 951 | # include <__memory/is_sufficiently_aligned.h> | ||
| 948 | # include <__memory/out_ptr.h> | 952 | # include <__memory/out_ptr.h> |
| 949 | # include <__memory/pointer_traits.h> | 953 | # include <__memory/pointer_traits.h> |
| 950 | # include <__memory/raw_storage_iterator.h> | 954 | # include <__memory/raw_storage_iterator.h> |
| ... | @@ -958,12 +962,14 @@ template<class Pointer = void, class Smart, class... Args> | ... | @@ -958,12 +962,14 @@ template<class Pointer = void, class Smart, class... Args> |
| 958 | 962 | ||
| 959 | # if _LIBCPP_STD_VER >= 17 | 963 | # if _LIBCPP_STD_VER >= 17 |
| 960 | # include <__memory/construct_at.h> | 964 | # include <__memory/construct_at.h> |
| 965 | # include <__memory/destroy.h> | ||
| 961 | # endif | 966 | # endif |
| 962 | 967 | ||
| 963 | # if _LIBCPP_STD_VER >= 20 | 968 | # if _LIBCPP_STD_VER >= 20 |
| 964 | # include <__memory/assume_aligned.h> | 969 | # include <__memory/assume_aligned.h> |
| 965 | # include <__memory/concepts.h> | 970 | # include <__memory/concepts.h> |
| 966 | # include <__memory/ranges_construct_at.h> | 971 | # include <__memory/ranges_construct_at.h> |
| 972 | # include <__memory/ranges_destroy.h> | ||
| 967 | # include <__memory/ranges_uninitialized_algorithms.h> | 973 | # include <__memory/ranges_uninitialized_algorithms.h> |
| 968 | # include <__memory/uses_allocator_construction.h> | 974 | # include <__memory/uses_allocator_construction.h> |
| 969 | # endif | 975 | # endif |
lib/libcxx/include/memory_resource+1-1| ... | @@ -50,7 +50,7 @@ namespace std::pmr { | ... | @@ -50,7 +50,7 @@ namespace std::pmr { |
| 50 | */ | 50 | */ |
| 51 | 51 | ||
| 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 53 | # include <__cxx03/memory_resource> | 53 | # include <__cxx03/__config> |
| 54 | #else | 54 | #else |
| 55 | # include <__config> | 55 | # include <__config> |
| 56 | 56 |
lib/libcxx/include/mutex+45-49| ... | @@ -256,26 +256,24 @@ public: | ... | @@ -256,26 +256,24 @@ public: |
| 256 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | 256 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { |
| 257 | return try_lock_until(chrono::steady_clock::now() + __d); | 257 | return try_lock_until(chrono::steady_clock::now() + __d); |
| 258 | } | 258 | } |
| 259 | |||
| 259 | template <class _Clock, class _Duration> | 260 | template <class _Clock, class _Duration> |
| 260 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool | 261 | _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { |
| 261 | try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); | 262 | using namespace chrono; |
| 263 | unique_lock<mutex> __lk(__m_); | ||
| 264 | bool __no_timeout = _Clock::now() < __t; | ||
| 265 | while (__no_timeout && __locked_) | ||
| 266 | __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout; | ||
| 267 | if (!__locked_) { | ||
| 268 | __locked_ = true; | ||
| 269 | return true; | ||
| 270 | } | ||
| 271 | return false; | ||
| 272 | } | ||
| 273 | |||
| 262 | void unlock() _NOEXCEPT; | 274 | void unlock() _NOEXCEPT; |
| 263 | }; | 275 | }; |
| 264 | 276 | ||
| 265 | template <class _Clock, class _Duration> | ||
| 266 | bool timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | ||
| 267 | using namespace chrono; | ||
| 268 | unique_lock<mutex> __lk(__m_); | ||
| 269 | bool __no_timeout = _Clock::now() < __t; | ||
| 270 | while (__no_timeout && __locked_) | ||
| 271 | __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout; | ||
| 272 | if (!__locked_) { | ||
| 273 | __locked_ = true; | ||
| 274 | return true; | ||
| 275 | } | ||
| 276 | return false; | ||
| 277 | } | ||
| 278 | |||
| 279 | class _LIBCPP_EXPORTED_FROM_ABI recursive_timed_mutex { | 277 | class _LIBCPP_EXPORTED_FROM_ABI recursive_timed_mutex { |
| 280 | mutex __m_; | 278 | mutex __m_; |
| 281 | condition_variable __cv_; | 279 | condition_variable __cv_; |
| ... | @@ -295,34 +293,32 @@ public: | ... | @@ -295,34 +293,32 @@ public: |
| 295 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | 293 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) { |
| 296 | return try_lock_until(chrono::steady_clock::now() + __d); | 294 | return try_lock_until(chrono::steady_clock::now() + __d); |
| 297 | } | 295 | } |
| 296 | |||
| 298 | template <class _Clock, class _Duration> | 297 | template <class _Clock, class _Duration> |
| 299 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool | 298 | _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { |
| 300 | try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); | 299 | using namespace chrono; |
| 300 | __thread_id __id = this_thread::get_id(); | ||
| 301 | unique_lock<mutex> __lk(__m_); | ||
| 302 | if (__id == __id_) { | ||
| 303 | if (__count_ == numeric_limits<size_t>::max()) | ||
| 304 | return false; | ||
| 305 | ++__count_; | ||
| 306 | return true; | ||
| 307 | } | ||
| 308 | bool __no_timeout = _Clock::now() < __t; | ||
| 309 | while (__no_timeout && __count_ != 0) | ||
| 310 | __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout; | ||
| 311 | if (__count_ == 0) { | ||
| 312 | __count_ = 1; | ||
| 313 | __id_ = __id; | ||
| 314 | return true; | ||
| 315 | } | ||
| 316 | return false; | ||
| 317 | } | ||
| 318 | |||
| 301 | void unlock() _NOEXCEPT; | 319 | void unlock() _NOEXCEPT; |
| 302 | }; | 320 | }; |
| 303 | 321 | ||
| 304 | template <class _Clock, class _Duration> | ||
| 305 | bool recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | ||
| 306 | using namespace chrono; | ||
| 307 | __thread_id __id = this_thread::get_id(); | ||
| 308 | unique_lock<mutex> __lk(__m_); | ||
| 309 | if (__id == __id_) { | ||
| 310 | if (__count_ == numeric_limits<size_t>::max()) | ||
| 311 | return false; | ||
| 312 | ++__count_; | ||
| 313 | return true; | ||
| 314 | } | ||
| 315 | bool __no_timeout = _Clock::now() < __t; | ||
| 316 | while (__no_timeout && __count_ != 0) | ||
| 317 | __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout; | ||
| 318 | if (__count_ == 0) { | ||
| 319 | __count_ = 1; | ||
| 320 | __id_ = __id; | ||
| 321 | return true; | ||
| 322 | } | ||
| 323 | return false; | ||
| 324 | } | ||
| 325 | |||
| 326 | template <class _L0, class _L1> | 322 | template <class _L0, class _L1> |
| 327 | _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { | 323 | _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { |
| 328 | unique_lock<_L0> __u0(__l0, try_to_lock_t()); | 324 | unique_lock<_L0> __u0(__l0, try_to_lock_t()); |
| ... | @@ -423,10 +419,10 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... | ... | @@ -423,10 +419,10 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... |
| 423 | 419 | ||
| 424 | # if _LIBCPP_STD_VER >= 17 | 420 | # if _LIBCPP_STD_VER >= 17 |
| 425 | template <class... _Mutexes> | 421 | template <class... _Mutexes> |
| 426 | class _LIBCPP_TEMPLATE_VIS scoped_lock; | 422 | class scoped_lock; |
| 427 | 423 | ||
| 428 | template <> | 424 | template <> |
| 429 | class _LIBCPP_TEMPLATE_VIS scoped_lock<> { | 425 | class scoped_lock<> { |
| 430 | public: | 426 | public: |
| 431 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock() {} | 427 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock() {} |
| 432 | ~scoped_lock() = default; | 428 | ~scoped_lock() = default; |
| ... | @@ -438,7 +434,7 @@ public: | ... | @@ -438,7 +434,7 @@ public: |
| 438 | }; | 434 | }; |
| 439 | 435 | ||
| 440 | template <class _Mutex> | 436 | template <class _Mutex> |
| 441 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) scoped_lock<_Mutex> { | 437 | class _LIBCPP_SCOPED_LOCKABLE scoped_lock<_Mutex> { |
| 442 | public: | 438 | public: |
| 443 | typedef _Mutex mutex_type; | 439 | typedef _Mutex mutex_type; |
| 444 | 440 | ||
| ... | @@ -446,16 +442,15 @@ private: | ... | @@ -446,16 +442,15 @@ private: |
| 446 | mutex_type& __m_; | 442 | mutex_type& __m_; |
| 447 | 443 | ||
| 448 | public: | 444 | public: |
| 449 | [[nodiscard]] | 445 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(mutex_type& __m) _LIBCPP_ACQUIRE_CAPABILITY(__m) |
| 450 | _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) | ||
| 451 | : __m_(__m) { | 446 | : __m_(__m) { |
| 452 | __m_.lock(); | 447 | __m_.lock(); |
| 453 | } | 448 | } |
| 454 | 449 | ||
| 455 | ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } | 450 | _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { __m_.unlock(); } |
| 456 | 451 | ||
| 457 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m) | 452 | [[nodiscard]] |
| 458 | _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) | 453 | _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m) _LIBCPP_REQUIRES_CAPABILITY(__m) |
| 459 | : __m_(__m) {} | 454 | : __m_(__m) {} |
| 460 | 455 | ||
| 461 | scoped_lock(scoped_lock const&) = delete; | 456 | scoped_lock(scoped_lock const&) = delete; |
| ... | @@ -463,7 +458,7 @@ public: | ... | @@ -463,7 +458,7 @@ public: |
| 463 | }; | 458 | }; |
| 464 | 459 | ||
| 465 | template <class... _MArgs> | 460 | template <class... _MArgs> |
| 466 | class _LIBCPP_TEMPLATE_VIS scoped_lock { | 461 | class scoped_lock { |
| 467 | static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required"); | 462 | static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required"); |
| 468 | typedef tuple<_MArgs&...> _MutexTuple; | 463 | typedef tuple<_MArgs&...> _MutexTuple; |
| 469 | 464 | ||
| ... | @@ -508,6 +503,7 @@ _LIBCPP_POP_MACROS | ... | @@ -508,6 +503,7 @@ _LIBCPP_POP_MACROS |
| 508 | # include <initializer_list> | 503 | # include <initializer_list> |
| 509 | # include <iosfwd> | 504 | # include <iosfwd> |
| 510 | # include <new> | 505 | # include <new> |
| 506 | # include <optional> | ||
| 511 | # include <stdexcept> | 507 | # include <stdexcept> |
| 512 | # include <system_error> | 508 | # include <system_error> |
| 513 | # include <type_traits> | 509 | # include <type_traits> |
lib/libcxx/include/numbers+1-1| ... | @@ -59,7 +59,7 @@ namespace std::numbers { | ... | @@ -59,7 +59,7 @@ namespace std::numbers { |
| 59 | */ | 59 | */ |
| 60 | 60 | ||
| 61 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 61 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 62 | # include <__cxx03/numbers> | 62 | # include <__cxx03/__config> |
| 63 | #else | 63 | #else |
| 64 | # include <__concepts/arithmetic.h> | 64 | # include <__concepts/arithmetic.h> |
| 65 | # include <__config> | 65 | # include <__config> |
lib/libcxx/include/numeric+1| ... | @@ -172,6 +172,7 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin | ... | @@ -172,6 +172,7 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin |
| 172 | # include <__numeric/gcd_lcm.h> | 172 | # include <__numeric/gcd_lcm.h> |
| 173 | # include <__numeric/inclusive_scan.h> | 173 | # include <__numeric/inclusive_scan.h> |
| 174 | # include <__numeric/pstl.h> | 174 | # include <__numeric/pstl.h> |
| 175 | # include <__numeric/ranges_iota.h> | ||
| 175 | # include <__numeric/reduce.h> | 176 | # include <__numeric/reduce.h> |
| 176 | # include <__numeric/transform_exclusive_scan.h> | 177 | # include <__numeric/transform_exclusive_scan.h> |
| 177 | # include <__numeric/transform_inclusive_scan.h> | 178 | # include <__numeric/transform_inclusive_scan.h> |
lib/libcxx/include/optional+154-144| ... | @@ -178,7 +178,7 @@ namespace std { | ... | @@ -178,7 +178,7 @@ namespace std { |
| 178 | */ | 178 | */ |
| 179 | 179 | ||
| 180 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 180 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 181 | # include <__cxx03/optional> | 181 | # include <__cxx03/__config> |
| 182 | #else | 182 | #else |
| 183 | # include <__assert> | 183 | # include <__assert> |
| 184 | # include <__compare/compare_three_way_result.h> | 184 | # include <__compare/compare_three_way_result.h> |
| ... | @@ -205,11 +205,13 @@ namespace std { | ... | @@ -205,11 +205,13 @@ namespace std { |
| 205 | # include <__type_traits/is_assignable.h> | 205 | # include <__type_traits/is_assignable.h> |
| 206 | # include <__type_traits/is_constructible.h> | 206 | # include <__type_traits/is_constructible.h> |
| 207 | # include <__type_traits/is_convertible.h> | 207 | # include <__type_traits/is_convertible.h> |
| 208 | # include <__type_traits/is_core_convertible.h> | ||
| 208 | # include <__type_traits/is_destructible.h> | 209 | # include <__type_traits/is_destructible.h> |
| 209 | # include <__type_traits/is_nothrow_assignable.h> | 210 | # include <__type_traits/is_nothrow_assignable.h> |
| 210 | # include <__type_traits/is_nothrow_constructible.h> | 211 | # include <__type_traits/is_nothrow_constructible.h> |
| 211 | # include <__type_traits/is_object.h> | 212 | # include <__type_traits/is_object.h> |
| 212 | # include <__type_traits/is_reference.h> | 213 | # include <__type_traits/is_reference.h> |
| 214 | # include <__type_traits/is_replaceable.h> | ||
| 213 | # include <__type_traits/is_same.h> | 215 | # include <__type_traits/is_same.h> |
| 214 | # include <__type_traits/is_scalar.h> | 216 | # include <__type_traits/is_scalar.h> |
| 215 | # include <__type_traits/is_swappable.h> | 217 | # include <__type_traits/is_swappable.h> |
| ... | @@ -246,7 +248,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -246,7 +248,7 @@ _LIBCPP_PUSH_MACROS |
| 246 | namespace std // purposefully not using versioning namespace | 248 | namespace std // purposefully not using versioning namespace |
| 247 | { | 249 | { |
| 248 | 250 | ||
| 249 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public exception { | 251 | class _LIBCPP_EXPORTED_FROM_ABI bad_optional_access : public exception { |
| 250 | public: | 252 | public: |
| 251 | _LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default; | 253 | _LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default; |
| 252 | _LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default; | 254 | _LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default; |
| ... | @@ -262,8 +264,7 @@ public: | ... | @@ -262,8 +264,7 @@ public: |
| 262 | 264 | ||
| 263 | _LIBCPP_BEGIN_NAMESPACE_STD | 265 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 264 | 266 | ||
| 265 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void | 267 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_optional_access() { |
| 266 | __throw_bad_optional_access() { | ||
| 267 | # if _LIBCPP_HAS_EXCEPTIONS | 268 | # if _LIBCPP_HAS_EXCEPTIONS |
| 268 | throw bad_optional_access(); | 269 | throw bad_optional_access(); |
| 269 | # else | 270 | # else |
| ... | @@ -590,6 +591,7 @@ public: | ... | @@ -590,6 +591,7 @@ public: |
| 590 | 591 | ||
| 591 | using __trivially_relocatable _LIBCPP_NODEBUG = | 592 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 592 | conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>; | 593 | conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>; |
| 594 | using __replaceable _LIBCPP_NODEBUG = conditional_t<__is_replaceable_v<_Tp>, optional, void>; | ||
| 593 | 595 | ||
| 594 | private: | 596 | private: |
| 595 | // Disable the reference extension using this static assert. | 597 | // Disable the reference extension using this static assert. |
| ... | @@ -672,44 +674,41 @@ public: | ... | @@ -672,44 +674,41 @@ public: |
| 672 | _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default; | 674 | _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default; |
| 673 | _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {} | 675 | _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {} |
| 674 | 676 | ||
| 675 | template < | 677 | template <class _InPlaceT, |
| 676 | class _InPlaceT, | 678 | class... _Args, |
| 677 | class... _Args, | 679 | enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>, is_constructible<value_type, _Args...>>::value, int> = 0> |
| 678 | class = enable_if_t< _And< _IsSame<_InPlaceT, in_place_t>, is_constructible<value_type, _Args...> >::value > > | ||
| 679 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args) | 680 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args) |
| 680 | : __base(in_place, std::forward<_Args>(__args)...) {} | 681 | : __base(in_place, std::forward<_Args>(__args)...) {} |
| 681 | 682 | ||
| 682 | template <class _Up, | 683 | template <class _Up, |
| 683 | class... _Args, | 684 | class... _Args, |
| 684 | class = enable_if_t< is_constructible_v<value_type, initializer_list<_Up>&, _Args...>> > | 685 | enable_if_t<is_constructible_v<value_type, initializer_list<_Up>&, _Args...>, int> = 0> |
| 685 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) | 686 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) |
| 686 | : __base(in_place, __il, std::forward<_Args>(__args)...) {} | 687 | : __base(in_place, __il, std::forward<_Args>(__args)...) {} |
| 687 | 688 | ||
| 688 | template <class _Up = value_type, | 689 | template <class _Up = value_type, |
| 689 | enable_if_t< _CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0> | 690 | enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0> |
| 690 | _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {} | 691 | _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {} |
| 691 | 692 | ||
| 692 | template <class _Up, enable_if_t< _CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0> | 693 | template <class _Up, enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0> |
| 693 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {} | 694 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {} |
| 694 | 695 | ||
| 695 | // LWG2756: conditionally explicit conversion from const optional<_Up>& | 696 | // LWG2756: conditionally explicit conversion from const optional<_Up>& |
| 696 | template <class _Up, | 697 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> |
| 697 | enable_if_t< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> | ||
| 698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) { | 698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) { |
| 699 | this->__construct_from(__v); | 699 | this->__construct_from(__v); |
| 700 | } | 700 | } |
| 701 | template <class _Up, | 701 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> |
| 702 | enable_if_t< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> | ||
| 703 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) { | 702 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) { |
| 704 | this->__construct_from(__v); | 703 | this->__construct_from(__v); |
| 705 | } | 704 | } |
| 706 | 705 | ||
| 707 | // LWG2756: conditionally explicit conversion from optional<_Up>&& | 706 | // LWG2756: conditionally explicit conversion from optional<_Up>&& |
| 708 | template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0> | 707 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0> |
| 709 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) { | 708 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) { |
| 710 | this->__construct_from(std::move(__v)); | 709 | this->__construct_from(std::move(__v)); |
| 711 | } | 710 | } |
| 712 | template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0> | 711 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0> |
| 713 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) { | 712 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) { |
| 714 | this->__construct_from(std::move(__v)); | 713 | this->__construct_from(std::move(__v)); |
| 715 | } | 714 | } |
| ... | @@ -718,7 +717,7 @@ public: | ... | @@ -718,7 +717,7 @@ public: |
| 718 | template <class _Tag, | 717 | template <class _Tag, |
| 719 | class _Fp, | 718 | class _Fp, |
| 720 | class... _Args, | 719 | class... _Args, |
| 721 | __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0> | 720 | enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0> |
| 722 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args) | 721 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args) |
| 723 | : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {} | 722 | : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {} |
| 724 | # endif | 723 | # endif |
| ... | @@ -732,12 +731,12 @@ public: | ... | @@ -732,12 +731,12 @@ public: |
| 732 | _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(optional&&) = default; | 731 | _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(optional&&) = default; |
| 733 | 732 | ||
| 734 | // LWG2756 | 733 | // LWG2756 |
| 735 | template < | 734 | template <class _Up = value_type, |
| 736 | class _Up = value_type, | 735 | enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Up>, optional>, |
| 737 | class = enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Up>, optional>, | 736 | _Or<_IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>>>, |
| 738 | _Or< _IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>> >, | 737 | is_constructible<value_type, _Up>, |
| 739 | is_constructible<value_type, _Up>, | 738 | is_assignable<value_type&, _Up>>::value, |
| 740 | is_assignable<value_type&, _Up> >::value> > | 739 | int> = 0> |
| 741 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) { | 740 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) { |
| 742 | if (this->has_value()) | 741 | if (this->has_value()) |
| 743 | this->__get() = std::forward<_Up>(__v); | 742 | this->__get() = std::forward<_Up>(__v); |
| ... | @@ -747,21 +746,20 @@ public: | ... | @@ -747,21 +746,20 @@ public: |
| 747 | } | 746 | } |
| 748 | 747 | ||
| 749 | // LWG2756 | 748 | // LWG2756 |
| 750 | template <class _Up, | 749 | template <class _Up, enable_if_t<_CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>(), int> = 0> |
| 751 | enable_if_t< _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>(), int> = 0> | ||
| 752 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(const optional<_Up>& __v) { | 750 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(const optional<_Up>& __v) { |
| 753 | this->__assign_from(__v); | 751 | this->__assign_from(__v); |
| 754 | return *this; | 752 | return *this; |
| 755 | } | 753 | } |
| 756 | 754 | ||
| 757 | // LWG2756 | 755 | // LWG2756 |
| 758 | template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_assign<_Up>(), int> = 0> | 756 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_assign<_Up>(), int> = 0> |
| 759 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(optional<_Up>&& __v) { | 757 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(optional<_Up>&& __v) { |
| 760 | this->__assign_from(std::move(__v)); | 758 | this->__assign_from(std::move(__v)); |
| 761 | return *this; | 759 | return *this; |
| 762 | } | 760 | } |
| 763 | 761 | ||
| 764 | template <class... _Args, class = enable_if_t< is_constructible_v<value_type, _Args...> > > | 762 | template <class... _Args, enable_if_t<is_constructible_v<value_type, _Args...>, int> = 0> |
| 765 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) { | 763 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) { |
| 766 | reset(); | 764 | reset(); |
| 767 | this->__construct(std::forward<_Args>(__args)...); | 765 | this->__construct(std::forward<_Args>(__args)...); |
| ... | @@ -770,7 +768,7 @@ public: | ... | @@ -770,7 +768,7 @@ public: |
| 770 | 768 | ||
| 771 | template <class _Up, | 769 | template <class _Up, |
| 772 | class... _Args, | 770 | class... _Args, |
| 773 | class = enable_if_t< is_constructible_v<value_type, initializer_list<_Up>&, _Args...> > > | 771 | enable_if_t<is_constructible_v<value_type, initializer_list<_Up>&, _Args...>, int> = 0> |
| 774 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { | 772 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { |
| 775 | reset(); | 773 | reset(); |
| 776 | this->__construct(__il, std::forward<_Args>(__args)...); | 774 | this->__construct(__il, std::forward<_Args>(__args)...); |
| ... | @@ -829,27 +827,27 @@ public: | ... | @@ -829,27 +827,27 @@ public: |
| 829 | using __base::__get; | 827 | using __base::__get; |
| 830 | using __base::has_value; | 828 | using __base::has_value; |
| 831 | 829 | ||
| 832 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const& value() const& { | 830 | _LIBCPP_HIDE_FROM_ABI constexpr value_type const& value() const& { |
| 833 | if (!this->has_value()) | 831 | if (!this->has_value()) |
| 834 | __throw_bad_optional_access(); | 832 | std::__throw_bad_optional_access(); |
| 835 | return this->__get(); | 833 | return this->__get(); |
| 836 | } | 834 | } |
| 837 | 835 | ||
| 838 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type& value() & { | 836 | _LIBCPP_HIDE_FROM_ABI constexpr value_type& value() & { |
| 839 | if (!this->has_value()) | 837 | if (!this->has_value()) |
| 840 | __throw_bad_optional_access(); | 838 | std::__throw_bad_optional_access(); |
| 841 | return this->__get(); | 839 | return this->__get(); |
| 842 | } | 840 | } |
| 843 | 841 | ||
| 844 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type&& value() && { | 842 | _LIBCPP_HIDE_FROM_ABI constexpr value_type&& value() && { |
| 845 | if (!this->has_value()) | 843 | if (!this->has_value()) |
| 846 | __throw_bad_optional_access(); | 844 | std::__throw_bad_optional_access(); |
| 847 | return std::move(this->__get()); | 845 | return std::move(this->__get()); |
| 848 | } | 846 | } |
| 849 | 847 | ||
| 850 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const&& value() const&& { | 848 | _LIBCPP_HIDE_FROM_ABI constexpr value_type const&& value() const&& { |
| 851 | if (!this->has_value()) | 849 | if (!this->has_value()) |
| 852 | __throw_bad_optional_access(); | 850 | std::__throw_bad_optional_access(); |
| 853 | return std::move(this->__get()); | 851 | return std::move(this->__get()); |
| 854 | } | 852 | } |
| 855 | 853 | ||
| ... | @@ -869,7 +867,7 @@ public: | ... | @@ -869,7 +867,7 @@ public: |
| 869 | 867 | ||
| 870 | # if _LIBCPP_STD_VER >= 23 | 868 | # if _LIBCPP_STD_VER >= 23 |
| 871 | template <class _Func> | 869 | template <class _Func> |
| 872 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & { | 870 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { |
| 873 | using _Up = invoke_result_t<_Func, value_type&>; | 871 | using _Up = invoke_result_t<_Func, value_type&>; |
| 874 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | 872 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| 875 | "Result of f(value()) must be a specialization of std::optional"); | 873 | "Result of f(value()) must be a specialization of std::optional"); |
| ... | @@ -879,7 +877,7 @@ public: | ... | @@ -879,7 +877,7 @@ public: |
| 879 | } | 877 | } |
| 880 | 878 | ||
| 881 | template <class _Func> | 879 | template <class _Func> |
| 882 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) const& { | 880 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { |
| 883 | using _Up = invoke_result_t<_Func, const value_type&>; | 881 | using _Up = invoke_result_t<_Func, const value_type&>; |
| 884 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | 882 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| 885 | "Result of f(value()) must be a specialization of std::optional"); | 883 | "Result of f(value()) must be a specialization of std::optional"); |
| ... | @@ -889,7 +887,7 @@ public: | ... | @@ -889,7 +887,7 @@ public: |
| 889 | } | 887 | } |
| 890 | 888 | ||
| 891 | template <class _Func> | 889 | template <class _Func> |
| 892 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) && { | 890 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { |
| 893 | using _Up = invoke_result_t<_Func, value_type&&>; | 891 | using _Up = invoke_result_t<_Func, value_type&&>; |
| 894 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | 892 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| 895 | "Result of f(std::move(value())) must be a specialization of std::optional"); | 893 | "Result of f(std::move(value())) must be a specialization of std::optional"); |
| ... | @@ -909,7 +907,7 @@ public: | ... | @@ -909,7 +907,7 @@ public: |
| 909 | } | 907 | } |
| 910 | 908 | ||
| 911 | template <class _Func> | 909 | template <class _Func> |
| 912 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) & { | 910 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & { |
| 913 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>; | 911 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>; |
| 914 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); | 912 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); |
| 915 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); | 913 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); |
| ... | @@ -921,7 +919,7 @@ public: | ... | @@ -921,7 +919,7 @@ public: |
| 921 | } | 919 | } |
| 922 | 920 | ||
| 923 | template <class _Func> | 921 | template <class _Func> |
| 924 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const& { | 922 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& { |
| 925 | using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>; | 923 | using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>; |
| 926 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); | 924 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); |
| 927 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); | 925 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t"); |
| ... | @@ -933,7 +931,7 @@ public: | ... | @@ -933,7 +931,7 @@ public: |
| 933 | } | 931 | } |
| 934 | 932 | ||
| 935 | template <class _Func> | 933 | template <class _Func> |
| 936 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) && { | 934 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && { |
| 937 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>; | 935 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>; |
| 938 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); | 936 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); |
| 939 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); | 937 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); |
| ... | @@ -945,7 +943,7 @@ public: | ... | @@ -945,7 +943,7 @@ public: |
| 945 | } | 943 | } |
| 946 | 944 | ||
| 947 | template <class _Func> | 945 | template <class _Func> |
| 948 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const&& { | 946 | _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& { |
| 949 | using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>; | 947 | using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>; |
| 950 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); | 948 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); |
| 951 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); | 949 | static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t"); |
| ... | @@ -982,17 +980,17 @@ public: | ... | @@ -982,17 +980,17 @@ public: |
| 982 | using __base::reset; | 980 | using __base::reset; |
| 983 | }; | 981 | }; |
| 984 | 982 | ||
| 985 | # if _LIBCPP_STD_VER >= 17 | ||
| 986 | template <class _Tp> | 983 | template <class _Tp> |
| 987 | optional(_Tp) -> optional<_Tp>; | 984 | optional(_Tp) -> optional<_Tp>; |
| 988 | # endif | ||
| 989 | 985 | ||
| 990 | // Comparisons between optionals | 986 | // [optional.relops] Relational operators |
| 991 | template <class _Tp, class _Up> | 987 | |
| 992 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 988 | template < |
| 993 | is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, | 989 | class _Tp, |
| 994 | bool > | 990 | class _Up, |
| 995 | operator==(const optional<_Tp>& __x, const optional<_Up>& __y) { | 991 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, |
| 992 | int> = 0> | ||
| 993 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const optional<_Up>& __y) { | ||
| 996 | if (static_cast<bool>(__x) != static_cast<bool>(__y)) | 994 | if (static_cast<bool>(__x) != static_cast<bool>(__y)) |
| 997 | return false; | 995 | return false; |
| 998 | if (!static_cast<bool>(__x)) | 996 | if (!static_cast<bool>(__x)) |
| ... | @@ -1000,11 +998,12 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y) { | ... | @@ -1000,11 +998,12 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1000 | return *__x == *__y; | 998 | return *__x == *__y; |
| 1001 | } | 999 | } |
| 1002 | 1000 | ||
| 1003 | template <class _Tp, class _Up> | 1001 | template < |
| 1004 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1002 | class _Tp, |
| 1005 | is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, | 1003 | class _Up, |
| 1006 | bool > | 1004 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, |
| 1007 | operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) { | 1005 | int> = 0> |
| 1006 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) { | ||
| 1008 | if (static_cast<bool>(__x) != static_cast<bool>(__y)) | 1007 | if (static_cast<bool>(__x) != static_cast<bool>(__y)) |
| 1009 | return true; | 1008 | return true; |
| 1010 | if (!static_cast<bool>(__x)) | 1009 | if (!static_cast<bool>(__x)) |
| ... | @@ -1012,11 +1011,11 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) { | ... | @@ -1012,11 +1011,11 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1012 | return *__x != *__y; | 1011 | return *__x != *__y; |
| 1013 | } | 1012 | } |
| 1014 | 1013 | ||
| 1015 | template <class _Tp, class _Up> | 1014 | template < class _Tp, |
| 1016 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1015 | class _Up, |
| 1017 | is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, | 1016 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, |
| 1018 | bool > | 1017 | int> = 0> |
| 1019 | operator<(const optional<_Tp>& __x, const optional<_Up>& __y) { | 1018 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1020 | if (!static_cast<bool>(__y)) | 1019 | if (!static_cast<bool>(__y)) |
| 1021 | return false; | 1020 | return false; |
| 1022 | if (!static_cast<bool>(__x)) | 1021 | if (!static_cast<bool>(__x)) |
| ... | @@ -1024,11 +1023,11 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y) { | ... | @@ -1024,11 +1023,11 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1024 | return *__x < *__y; | 1023 | return *__x < *__y; |
| 1025 | } | 1024 | } |
| 1026 | 1025 | ||
| 1027 | template <class _Tp, class _Up> | 1026 | template < class _Tp, |
| 1028 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1027 | class _Up, |
| 1029 | is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, | 1028 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, |
| 1030 | bool > | 1029 | int> = 0> |
| 1031 | operator>(const optional<_Tp>& __x, const optional<_Up>& __y) { | 1030 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1032 | if (!static_cast<bool>(__x)) | 1031 | if (!static_cast<bool>(__x)) |
| 1033 | return false; | 1032 | return false; |
| 1034 | if (!static_cast<bool>(__y)) | 1033 | if (!static_cast<bool>(__y)) |
| ... | @@ -1036,11 +1035,12 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y) { | ... | @@ -1036,11 +1035,12 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1036 | return *__x > *__y; | 1035 | return *__x > *__y; |
| 1037 | } | 1036 | } |
| 1038 | 1037 | ||
| 1039 | template <class _Tp, class _Up> | 1038 | template < |
| 1040 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1039 | class _Tp, |
| 1041 | is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, | 1040 | class _Up, |
| 1042 | bool > | 1041 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, |
| 1043 | operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) { | 1042 | int> = 0> |
| 1043 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) { | ||
| 1044 | if (!static_cast<bool>(__x)) | 1044 | if (!static_cast<bool>(__x)) |
| 1045 | return true; | 1045 | return true; |
| 1046 | if (!static_cast<bool>(__y)) | 1046 | if (!static_cast<bool>(__y)) |
| ... | @@ -1048,11 +1048,12 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) { | ... | @@ -1048,11 +1048,12 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1048 | return *__x <= *__y; | 1048 | return *__x <= *__y; |
| 1049 | } | 1049 | } |
| 1050 | 1050 | ||
| 1051 | template <class _Tp, class _Up> | 1051 | template < |
| 1052 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1052 | class _Tp, |
| 1053 | is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, | 1053 | class _Up, |
| 1054 | bool > | 1054 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, |
| 1055 | operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) { | 1055 | int> = 0> |
| 1056 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) { | ||
| 1056 | if (!static_cast<bool>(__y)) | 1057 | if (!static_cast<bool>(__y)) |
| 1057 | return true; | 1058 | return true; |
| 1058 | if (!static_cast<bool>(__x)) | 1059 | if (!static_cast<bool>(__x)) |
| ... | @@ -1072,7 +1073,8 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) { | ... | @@ -1072,7 +1073,8 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1072 | 1073 | ||
| 1073 | # endif // _LIBCPP_STD_VER >= 20 | 1074 | # endif // _LIBCPP_STD_VER >= 20 |
| 1074 | 1075 | ||
| 1075 | // Comparisons with nullopt | 1076 | // [optional.nullops] Comparison with nullopt |
| 1077 | |||
| 1076 | template <class _Tp> | 1078 | template <class _Tp> |
| 1077 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullopt_t) noexcept { | 1079 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullopt_t) noexcept { |
| 1078 | return !static_cast<bool>(__x); | 1080 | return !static_cast<bool>(__x); |
| ... | @@ -1144,100 +1146,109 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>& | ... | @@ -1144,100 +1146,109 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>& |
| 1144 | 1146 | ||
| 1145 | # endif // _LIBCPP_STD_VER <= 17 | 1147 | # endif // _LIBCPP_STD_VER <= 17 |
| 1146 | 1148 | ||
| 1147 | // Comparisons with T | 1149 | // [optional.comp.with.t] Comparison with T |
| 1148 | template <class _Tp, class _Up> | 1150 | |
| 1149 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1151 | template < |
| 1150 | is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, | 1152 | class _Tp, |
| 1151 | bool > | 1153 | class _Up, |
| 1152 | operator==(const optional<_Tp>& __x, const _Up& __v) { | 1154 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, |
| 1155 | int> = 0> | ||
| 1156 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const _Up& __v) { | ||
| 1153 | return static_cast<bool>(__x) ? *__x == __v : false; | 1157 | return static_cast<bool>(__x) ? *__x == __v : false; |
| 1154 | } | 1158 | } |
| 1155 | 1159 | ||
| 1156 | template <class _Tp, class _Up> | 1160 | template < |
| 1157 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1161 | class _Tp, |
| 1158 | is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, | 1162 | class _Up, |
| 1159 | bool > | 1163 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>, |
| 1160 | operator==(const _Tp& __v, const optional<_Up>& __x) { | 1164 | int> = 0> |
| 1165 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const _Tp& __v, const optional<_Up>& __x) { | ||
| 1161 | return static_cast<bool>(__x) ? __v == *__x : false; | 1166 | return static_cast<bool>(__x) ? __v == *__x : false; |
| 1162 | } | 1167 | } |
| 1163 | 1168 | ||
| 1164 | template <class _Tp, class _Up> | 1169 | template < |
| 1165 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1170 | class _Tp, |
| 1166 | is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, | 1171 | class _Up, |
| 1167 | bool > | 1172 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, |
| 1168 | operator!=(const optional<_Tp>& __x, const _Up& __v) { | 1173 | int> = 0> |
| 1174 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, const _Up& __v) { | ||
| 1169 | return static_cast<bool>(__x) ? *__x != __v : true; | 1175 | return static_cast<bool>(__x) ? *__x != __v : true; |
| 1170 | } | 1176 | } |
| 1171 | 1177 | ||
| 1172 | template <class _Tp, class _Up> | 1178 | template < |
| 1173 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1179 | class _Tp, |
| 1174 | is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, | 1180 | class _Up, |
| 1175 | bool > | 1181 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>, |
| 1176 | operator!=(const _Tp& __v, const optional<_Up>& __x) { | 1182 | int> = 0> |
| 1183 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const _Tp& __v, const optional<_Up>& __x) { | ||
| 1177 | return static_cast<bool>(__x) ? __v != *__x : true; | 1184 | return static_cast<bool>(__x) ? __v != *__x : true; |
| 1178 | } | 1185 | } |
| 1179 | 1186 | ||
| 1180 | template <class _Tp, class _Up> | 1187 | template < class _Tp, |
| 1181 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1188 | class _Up, |
| 1182 | is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, | 1189 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, |
| 1183 | bool > | 1190 | int> = 0> |
| 1184 | operator<(const optional<_Tp>& __x, const _Up& __v) { | 1191 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>& __x, const _Up& __v) { |
| 1185 | return static_cast<bool>(__x) ? *__x < __v : true; | 1192 | return static_cast<bool>(__x) ? *__x < __v : true; |
| 1186 | } | 1193 | } |
| 1187 | 1194 | ||
| 1188 | template <class _Tp, class _Up> | 1195 | template < class _Tp, |
| 1189 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1196 | class _Up, |
| 1190 | is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, | 1197 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>, |
| 1191 | bool > | 1198 | int> = 0> |
| 1192 | operator<(const _Tp& __v, const optional<_Up>& __x) { | 1199 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const _Tp& __v, const optional<_Up>& __x) { |
| 1193 | return static_cast<bool>(__x) ? __v < *__x : false; | 1200 | return static_cast<bool>(__x) ? __v < *__x : false; |
| 1194 | } | 1201 | } |
| 1195 | 1202 | ||
| 1196 | template <class _Tp, class _Up> | 1203 | template < |
| 1197 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1204 | class _Tp, |
| 1198 | is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, | 1205 | class _Up, |
| 1199 | bool > | 1206 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, |
| 1200 | operator<=(const optional<_Tp>& __x, const _Up& __v) { | 1207 | int> = 0> |
| 1208 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, const _Up& __v) { | ||
| 1201 | return static_cast<bool>(__x) ? *__x <= __v : true; | 1209 | return static_cast<bool>(__x) ? *__x <= __v : true; |
| 1202 | } | 1210 | } |
| 1203 | 1211 | ||
| 1204 | template <class _Tp, class _Up> | 1212 | template < |
| 1205 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1213 | class _Tp, |
| 1206 | is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, | 1214 | class _Up, |
| 1207 | bool > | 1215 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>, |
| 1208 | operator<=(const _Tp& __v, const optional<_Up>& __x) { | 1216 | int> = 0> |
| 1217 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const _Tp& __v, const optional<_Up>& __x) { | ||
| 1209 | return static_cast<bool>(__x) ? __v <= *__x : false; | 1218 | return static_cast<bool>(__x) ? __v <= *__x : false; |
| 1210 | } | 1219 | } |
| 1211 | 1220 | ||
| 1212 | template <class _Tp, class _Up> | 1221 | template < class _Tp, |
| 1213 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1222 | class _Up, |
| 1214 | is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, | 1223 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, |
| 1215 | bool > | 1224 | int> = 0> |
| 1216 | operator>(const optional<_Tp>& __x, const _Up& __v) { | 1225 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, const _Up& __v) { |
| 1217 | return static_cast<bool>(__x) ? *__x > __v : false; | 1226 | return static_cast<bool>(__x) ? *__x > __v : false; |
| 1218 | } | 1227 | } |
| 1219 | 1228 | ||
| 1220 | template <class _Tp, class _Up> | 1229 | template < class _Tp, |
| 1221 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1230 | class _Up, |
| 1222 | is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, | 1231 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>, |
| 1223 | bool > | 1232 | int> = 0> |
| 1224 | operator>(const _Tp& __v, const optional<_Up>& __x) { | 1233 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const _Tp& __v, const optional<_Up>& __x) { |
| 1225 | return static_cast<bool>(__x) ? __v > *__x : true; | 1234 | return static_cast<bool>(__x) ? __v > *__x : true; |
| 1226 | } | 1235 | } |
| 1227 | 1236 | ||
| 1228 | template <class _Tp, class _Up> | 1237 | template < |
| 1229 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1238 | class _Tp, |
| 1230 | is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, | 1239 | class _Up, |
| 1231 | bool > | 1240 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, |
| 1232 | operator>=(const optional<_Tp>& __x, const _Up& __v) { | 1241 | int> = 0> |
| 1242 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>& __x, const _Up& __v) { | ||
| 1233 | return static_cast<bool>(__x) ? *__x >= __v : false; | 1243 | return static_cast<bool>(__x) ? *__x >= __v : false; |
| 1234 | } | 1244 | } |
| 1235 | 1245 | ||
| 1236 | template <class _Tp, class _Up> | 1246 | template < |
| 1237 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t< | 1247 | class _Tp, |
| 1238 | is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, | 1248 | class _Up, |
| 1239 | bool > | 1249 | enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>, |
| 1240 | operator>=(const _Tp& __v, const optional<_Up>& __x) { | 1250 | int> = 0> |
| 1251 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const _Tp& __v, const optional<_Up>& __x) { | ||
| 1241 | return static_cast<bool>(__x) ? __v >= *__x : true; | 1252 | return static_cast<bool>(__x) ? __v >= *__x : true; |
| 1242 | } | 1253 | } |
| 1243 | 1254 | ||
| ... | @@ -1252,9 +1263,8 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { | ... | @@ -1252,9 +1263,8 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { |
| 1252 | 1263 | ||
| 1253 | # endif // _LIBCPP_STD_VER >= 20 | 1264 | # endif // _LIBCPP_STD_VER >= 20 |
| 1254 | 1265 | ||
| 1255 | template <class _Tp> | 1266 | template <class _Tp, enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, int> = 0> |
| 1256 | inline _LIBCPP_HIDE_FROM_ABI | 1267 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 1257 | _LIBCPP_CONSTEXPR_SINCE_CXX20 enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void > | ||
| 1258 | swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) { | 1268 | swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) { |
| 1259 | __x.swap(__y); | 1269 | __x.swap(__y); |
| 1260 | } | 1270 | } |
| ... | @@ -1275,7 +1285,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up | ... | @@ -1275,7 +1285,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up |
| 1275 | } | 1285 | } |
| 1276 | 1286 | ||
| 1277 | template <class _Tp> | 1287 | template <class _Tp> |
| 1278 | struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > { | 1288 | struct hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > { |
| 1279 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | 1289 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1280 | _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type; | 1290 | _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type; |
| 1281 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | 1291 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; |
lib/libcxx/include/ostream+5| ... | @@ -205,6 +205,11 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args); | ... | @@ -205,6 +205,11 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args); |
| 205 | # include <stdexcept> | 205 | # include <stdexcept> |
| 206 | # include <type_traits> | 206 | # include <type_traits> |
| 207 | # endif | 207 | # endif |
| 208 | |||
| 209 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | ||
| 210 | # include <locale> | ||
| 211 | # endif | ||
| 212 | |||
| 208 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 213 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 209 | 214 | ||
| 210 | #endif // _LIBCPP_OSTREAM | 215 | #endif // _LIBCPP_OSTREAM |
lib/libcxx/include/print+2-2| ... | @@ -34,7 +34,7 @@ namespace std { | ... | @@ -34,7 +34,7 @@ namespace std { |
| 34 | */ | 34 | */ |
| 35 | 35 | ||
| 36 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 36 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 37 | # include <__cxx03/print> | 37 | # include <__cxx03/__config> |
| 38 | #else | 38 | #else |
| 39 | # include <__assert> | 39 | # include <__assert> |
| 40 | # include <__concepts/same_as.h> | 40 | # include <__concepts/same_as.h> |
| ... | @@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __encode(_OutIt& __out_it, char32_t __value | ... | @@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __encode(_OutIt& __out_it, char32_t __value |
| 123 | _LIBCPP_ASSERT_UNCATEGORIZED(__is_scalar_value(__value), "an invalid unicode scalar value results in invalid UTF-16"); | 123 | _LIBCPP_ASSERT_UNCATEGORIZED(__is_scalar_value(__value), "an invalid unicode scalar value results in invalid UTF-16"); |
| 124 | 124 | ||
| 125 | if (__value < 0x10000) { | 125 | if (__value < 0x10000) { |
| 126 | *__out_it++ = __value; | 126 | *__out_it++ = static_cast<iter_value_t<_OutIt>>(__value); |
| 127 | return; | 127 | return; |
| 128 | } | 128 | } |
| 129 | 129 |
lib/libcxx/include/queue+88-69| ... | @@ -299,7 +299,7 @@ template <class _Tp, class _Container> | ... | @@ -299,7 +299,7 @@ template <class _Tp, class _Container> |
| 299 | _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); | 299 | _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); |
| 300 | 300 | ||
| 301 | template <class _Tp, class _Container /*= deque<_Tp>*/> | 301 | template <class _Tp, class _Container /*= deque<_Tp>*/> |
| 302 | class _LIBCPP_TEMPLATE_VIS queue { | 302 | class queue { |
| 303 | public: | 303 | public: |
| 304 | typedef _Container container_type; | 304 | typedef _Container container_type; |
| 305 | typedef typename container_type::value_type value_type; | 305 | typedef typename container_type::value_type value_type; |
| ... | @@ -428,6 +428,12 @@ public: | ... | @@ -428,6 +428,12 @@ public: |
| 428 | template <class _T1, class _OtherContainer> | 428 | template <class _T1, class _OtherContainer> |
| 429 | friend _LIBCPP_HIDE_FROM_ABI bool | 429 | friend _LIBCPP_HIDE_FROM_ABI bool |
| 430 | operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); | 430 | operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); |
| 431 | |||
| 432 | # if _LIBCPP_STD_VER >= 20 | ||
| 433 | template <class _T1, three_way_comparable _OtherContainer> | ||
| 434 | friend _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_OtherContainer> | ||
| 435 | operator<=>(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); | ||
| 436 | # endif | ||
| 431 | }; | 437 | }; |
| 432 | 438 | ||
| 433 | # if _LIBCPP_STD_VER >= 17 | 439 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -452,14 +458,12 @@ template <class _InputIterator, | ... | @@ -452,14 +458,12 @@ template <class _InputIterator, |
| 452 | class _Alloc, | 458 | class _Alloc, |
| 453 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, | 459 | __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, |
| 454 | __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> | 460 | __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 455 | queue(_InputIterator, | 461 | queue(_InputIterator, _InputIterator, _Alloc) |
| 456 | _InputIterator, | 462 | -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; |
| 457 | _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | ||
| 458 | 463 | ||
| 459 | 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<_Alloc>::value, int> = 0> |
| 460 | queue(from_range_t, | 465 | queue(from_range_t, _Range&&, _Alloc) |
| 461 | _Range&&, | 466 | -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; |
| 462 | _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; | ||
| 463 | # endif | 467 | # endif |
| 464 | 468 | ||
| 465 | template <class _Tp, class _Container> | 469 | template <class _Tp, class _Container> |
| ... | @@ -497,8 +501,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, | ... | @@ -497,8 +501,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, |
| 497 | template <class _Tp, three_way_comparable _Container> | 501 | template <class _Tp, three_way_comparable _Container> |
| 498 | _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> | 502 | _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> |
| 499 | operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { | 503 | operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| 500 | // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors | 504 | return __x.c <=> __y.c; |
| 501 | return __x.__get_container() <=> __y.__get_container(); | ||
| 502 | } | 505 | } |
| 503 | 506 | ||
| 504 | # endif | 507 | # endif |
| ... | @@ -510,11 +513,10 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _ | ... | @@ -510,11 +513,10 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _ |
| 510 | } | 513 | } |
| 511 | 514 | ||
| 512 | template <class _Tp, class _Container, class _Alloc> | 515 | template <class _Tp, class _Container, class _Alloc> |
| 513 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { | 516 | struct uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {}; |
| 514 | }; | ||
| 515 | 517 | ||
| 516 | template <class _Tp, class _Container, class _Compare> | 518 | template <class _Tp, class _Container, class _Compare> |
| 517 | class _LIBCPP_TEMPLATE_VIS priority_queue { | 519 | class priority_queue { |
| 518 | public: | 520 | public: |
| 519 | typedef _Container container_type; | 521 | typedef _Container container_type; |
| 520 | typedef _Compare value_compare; | 522 | typedef _Compare value_compare; |
| ... | @@ -529,24 +531,25 @@ protected: | ... | @@ -529,24 +531,25 @@ protected: |
| 529 | value_compare comp; | 531 | value_compare comp; |
| 530 | 532 | ||
| 531 | public: | 533 | public: |
| 532 | _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_( | 534 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_( |
| 533 | is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value) | 535 | is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value) |
| 534 | : c(), comp() {} | 536 | : c(), comp() {} |
| 535 | 537 | ||
| 536 | _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} | 538 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) |
| 539 | : c(__q.c), comp(__q.comp) {} | ||
| 537 | 540 | ||
| 538 | _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) { | 541 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) { |
| 539 | c = __q.c; | 542 | c = __q.c; |
| 540 | comp = __q.comp; | 543 | comp = __q.comp; |
| 541 | return *this; | 544 | return *this; |
| 542 | } | 545 | } |
| 543 | 546 | ||
| 544 | # ifndef _LIBCPP_CXX03_LANG | 547 | # ifndef _LIBCPP_CXX03_LANG |
| 545 | _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept( | 548 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept( |
| 546 | is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value) | 549 | is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value) |
| 547 | : c(std::move(__q.c)), comp(std::move(__q.comp)) {} | 550 | : c(std::move(__q.c)), comp(std::move(__q.comp)) {} |
| 548 | 551 | ||
| 549 | _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) noexcept( | 552 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) noexcept( |
| 550 | is_nothrow_move_assignable<container_type>::value && is_nothrow_move_assignable<value_compare>::value) { | 553 | is_nothrow_move_assignable<container_type>::value && is_nothrow_move_assignable<value_compare>::value) { |
| 551 | c = std::move(__q.c); | 554 | c = std::move(__q.c); |
| 552 | comp = std::move(__q.comp); | 555 | comp = std::move(__q.comp); |
| ... | @@ -554,50 +557,56 @@ public: | ... | @@ -554,50 +557,56 @@ public: |
| 554 | } | 557 | } |
| 555 | # endif // _LIBCPP_CXX03_LANG | 558 | # endif // _LIBCPP_CXX03_LANG |
| 556 | 559 | ||
| 557 | _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {} | 560 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) |
| 558 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c); | 561 | : c(), comp(__comp) {} |
| 562 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI | ||
| 563 | priority_queue(const value_compare& __comp, const container_type& __c); | ||
| 559 | # ifndef _LIBCPP_CXX03_LANG | 564 | # ifndef _LIBCPP_CXX03_LANG |
| 560 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); | 565 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); |
| 561 | # endif | 566 | # endif |
| 562 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> | 567 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 563 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); | 568 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 569 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); | ||
| 564 | 570 | ||
| 565 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> | 571 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 566 | _LIBCPP_HIDE_FROM_ABI | 572 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 567 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); | 573 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); |
| 568 | 574 | ||
| 569 | # ifndef _LIBCPP_CXX03_LANG | 575 | # ifndef _LIBCPP_CXX03_LANG |
| 570 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> | 576 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 571 | _LIBCPP_HIDE_FROM_ABI | 577 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 572 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); | 578 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); |
| 573 | # endif // _LIBCPP_CXX03_LANG | 579 | # endif // _LIBCPP_CXX03_LANG |
| 574 | 580 | ||
| 575 | # if _LIBCPP_STD_VER >= 23 | 581 | # if _LIBCPP_STD_VER >= 23 |
| 576 | template <_ContainerCompatibleRange<_Tp> _Range> | 582 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 577 | _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare()) | 583 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 584 | priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare()) | ||
| 578 | : c(from_range, std::forward<_Range>(__range)), comp(__comp) { | 585 | : c(from_range, std::forward<_Range>(__range)), comp(__comp) { |
| 579 | std::make_heap(c.begin(), c.end(), comp); | 586 | std::make_heap(c.begin(), c.end(), comp); |
| 580 | } | 587 | } |
| 581 | # endif | 588 | # endif |
| 582 | 589 | ||
| 583 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | 590 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 584 | _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a); | 591 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a); |
| 585 | 592 | ||
| 586 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | 593 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 587 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a); | 594 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a); |
| 588 | 595 | ||
| 589 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | 596 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 590 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a); | 597 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 598 | priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a); | ||
| 591 | 599 | ||
| 592 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | 600 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 593 | _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a); | 601 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a); |
| 594 | 602 | ||
| 595 | # ifndef _LIBCPP_CXX03_LANG | 603 | # ifndef _LIBCPP_CXX03_LANG |
| 596 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | 604 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 597 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a); | 605 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 606 | priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a); | ||
| 598 | 607 | ||
| 599 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> | 608 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 600 | _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a); | 609 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a); |
| 601 | # endif // _LIBCPP_CXX03_LANG | 610 | # endif // _LIBCPP_CXX03_LANG |
| 602 | 611 | ||
| 603 | template < | 612 | template < |
| ... | @@ -605,21 +614,22 @@ public: | ... | @@ -605,21 +614,22 @@ public: |
| 605 | class _Alloc, | 614 | class _Alloc, |
| 606 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | 615 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, |
| 607 | int> = 0> | 616 | int> = 0> |
| 608 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a); | 617 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a); |
| 609 | 618 | ||
| 610 | template < | 619 | template < |
| 611 | class _InputIter, | 620 | class _InputIter, |
| 612 | class _Alloc, | 621 | class _Alloc, |
| 613 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | 622 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, |
| 614 | int> = 0> | 623 | int> = 0> |
| 615 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a); | 624 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 625 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a); | ||
| 616 | 626 | ||
| 617 | template < | 627 | template < |
| 618 | class _InputIter, | 628 | class _InputIter, |
| 619 | class _Alloc, | 629 | class _Alloc, |
| 620 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | 630 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, |
| 621 | int> = 0> | 631 | int> = 0> |
| 622 | _LIBCPP_HIDE_FROM_ABI priority_queue( | 632 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue( |
| 623 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a); | 633 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a); |
| 624 | 634 | ||
| 625 | # ifndef _LIBCPP_CXX03_LANG | 635 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -628,7 +638,7 @@ public: | ... | @@ -628,7 +638,7 @@ public: |
| 628 | class _Alloc, | 638 | class _Alloc, |
| 629 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, | 639 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, |
| 630 | int> = 0> | 640 | int> = 0> |
| 631 | _LIBCPP_HIDE_FROM_ABI | 641 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 632 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a); | 642 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a); |
| 633 | # endif // _LIBCPP_CXX03_LANG | 643 | # endif // _LIBCPP_CXX03_LANG |
| 634 | 644 | ||
| ... | @@ -637,7 +647,8 @@ public: | ... | @@ -637,7 +647,8 @@ public: |
| 637 | template <_ContainerCompatibleRange<_Tp> _Range, | 647 | template <_ContainerCompatibleRange<_Tp> _Range, |
| 638 | class _Alloc, | 648 | class _Alloc, |
| 639 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> | 649 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> |
| 640 | _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a) | 650 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI |
| 651 | priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a) | ||
| 641 | : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) { | 652 | : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) { |
| 642 | std::make_heap(c.begin(), c.end(), comp); | 653 | std::make_heap(c.begin(), c.end(), comp); |
| 643 | } | 654 | } |
| ... | @@ -645,24 +656,24 @@ public: | ... | @@ -645,24 +656,24 @@ public: |
| 645 | template <_ContainerCompatibleRange<_Tp> _Range, | 656 | template <_ContainerCompatibleRange<_Tp> _Range, |
| 646 | class _Alloc, | 657 | class _Alloc, |
| 647 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> | 658 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> |
| 648 | _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a) | 659 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a) |
| 649 | : c(from_range, std::forward<_Range>(__range), __a), comp() { | 660 | : c(from_range, std::forward<_Range>(__range), __a), comp() { |
| 650 | std::make_heap(c.begin(), c.end(), comp); | 661 | std::make_heap(c.begin(), c.end(), comp); |
| 651 | } | 662 | } |
| 652 | 663 | ||
| 653 | # endif | 664 | # endif |
| 654 | 665 | ||
| 655 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | 666 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 656 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } | 667 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 657 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } | 668 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } |
| 658 | 669 | ||
| 659 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); | 670 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); |
| 660 | # ifndef _LIBCPP_CXX03_LANG | 671 | # ifndef _LIBCPP_CXX03_LANG |
| 661 | _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v); | 672 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v); |
| 662 | 673 | ||
| 663 | # if _LIBCPP_STD_VER >= 23 | 674 | # if _LIBCPP_STD_VER >= 23 |
| 664 | template <_ContainerCompatibleRange<_Tp> _Range> | 675 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 665 | _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { | 676 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { |
| 666 | if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { | 677 | if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { |
| 667 | c.append_range(std::forward<_Range>(__range)); | 678 | c.append_range(std::forward<_Range>(__range)); |
| 668 | } else { | 679 | } else { |
| ... | @@ -674,14 +685,16 @@ public: | ... | @@ -674,14 +685,16 @@ public: |
| 674 | # endif | 685 | # endif |
| 675 | 686 | ||
| 676 | template <class... _Args> | 687 | template <class... _Args> |
| 677 | _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args); | 688 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args); |
| 678 | # endif // _LIBCPP_CXX03_LANG | 689 | # endif // _LIBCPP_CXX03_LANG |
| 679 | _LIBCPP_HIDE_FROM_ABI void pop(); | 690 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop(); |
| 680 | 691 | ||
| 681 | _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) | 692 | _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) |
| 682 | _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>); | 693 | _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>); |
| 683 | 694 | ||
| 684 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | 695 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { |
| 696 | return c; | ||
| 697 | } | ||
| 685 | }; | 698 | }; |
| 686 | 699 | ||
| 687 | # if _LIBCPP_STD_VER >= 17 | 700 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -763,7 +776,8 @@ priority_queue(from_range_t, _Range&&, _Alloc) | ... | @@ -763,7 +776,8 @@ priority_queue(from_range_t, _Range&&, _Alloc) |
| 763 | # endif | 776 | # endif |
| 764 | 777 | ||
| 765 | template <class _Tp, class _Container, class _Compare> | 778 | template <class _Tp, class _Container, class _Compare> |
| 766 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c) | 779 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 780 | const _Compare& __comp, const container_type& __c) | ||
| 767 | : c(__c), comp(__comp) { | 781 | : c(__c), comp(__comp) { |
| 768 | std::make_heap(c.begin(), c.end(), comp); | 782 | std::make_heap(c.begin(), c.end(), comp); |
| 769 | } | 783 | } |
| ... | @@ -771,7 +785,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& | ... | @@ -771,7 +785,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& |
| 771 | # ifndef _LIBCPP_CXX03_LANG | 785 | # ifndef _LIBCPP_CXX03_LANG |
| 772 | 786 | ||
| 773 | template <class _Tp, class _Container, class _Compare> | 787 | template <class _Tp, class _Container, class _Compare> |
| 774 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c) | 788 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 789 | const value_compare& __comp, container_type&& __c) | ||
| 775 | : c(std::move(__c)), comp(__comp) { | 790 | : c(std::move(__c)), comp(__comp) { |
| 776 | std::make_heap(c.begin(), c.end(), comp); | 791 | std::make_heap(c.begin(), c.end(), comp); |
| 777 | } | 792 | } |
| ... | @@ -780,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com | ... | @@ -780,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com |
| 780 | 795 | ||
| 781 | template <class _Tp, class _Container, class _Compare> | 796 | template <class _Tp, class _Container, class _Compare> |
| 782 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > | 797 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 783 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 798 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 784 | _InputIter __f, _InputIter __l, const value_compare& __comp) | 799 | _InputIter __f, _InputIter __l, const value_compare& __comp) |
| 785 | : c(__f, __l), comp(__comp) { | 800 | : c(__f, __l), comp(__comp) { |
| 786 | std::make_heap(c.begin(), c.end(), comp); | 801 | std::make_heap(c.begin(), c.end(), comp); |
| ... | @@ -788,7 +803,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -788,7 +803,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 788 | 803 | ||
| 789 | template <class _Tp, class _Container, class _Compare> | 804 | template <class _Tp, class _Container, class _Compare> |
| 790 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > | 805 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 791 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 806 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 792 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c) | 807 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c) |
| 793 | : c(__c), comp(__comp) { | 808 | : c(__c), comp(__comp) { |
| 794 | c.insert(c.end(), __f, __l); | 809 | c.insert(c.end(), __f, __l); |
| ... | @@ -799,7 +814,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -799,7 +814,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 799 | 814 | ||
| 800 | template <class _Tp, class _Container, class _Compare> | 815 | template <class _Tp, class _Container, class _Compare> |
| 801 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > | 816 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 802 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 817 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 803 | _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c) | 818 | _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c) |
| 804 | : c(std::move(__c)), comp(__comp) { | 819 | : c(std::move(__c)), comp(__comp) { |
| 805 | c.insert(c.end(), __f, __l); | 820 | c.insert(c.end(), __f, __l); |
| ... | @@ -810,16 +825,18 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -810,16 +825,18 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 810 | 825 | ||
| 811 | template <class _Tp, class _Container, class _Compare> | 826 | template <class _Tp, class _Container, class _Compare> |
| 812 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > | 827 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 813 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {} | 828 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) |
| 829 | : c(__a) {} | ||
| 814 | 830 | ||
| 815 | template <class _Tp, class _Container, class _Compare> | 831 | template <class _Tp, class _Container, class _Compare> |
| 816 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > | 832 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 817 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a) | 833 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 834 | const value_compare& __comp, const _Alloc& __a) | ||
| 818 | : c(__a), comp(__comp) {} | 835 | : c(__a), comp(__comp) {} |
| 819 | 836 | ||
| 820 | template <class _Tp, class _Container, class _Compare> | 837 | template <class _Tp, class _Container, class _Compare> |
| 821 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > | 838 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 822 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 839 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 823 | const value_compare& __comp, const container_type& __c, const _Alloc& __a) | 840 | const value_compare& __comp, const container_type& __c, const _Alloc& __a) |
| 824 | : c(__c, __a), comp(__comp) { | 841 | : c(__c, __a), comp(__comp) { |
| 825 | std::make_heap(c.begin(), c.end(), comp); | 842 | std::make_heap(c.begin(), c.end(), comp); |
| ... | @@ -827,14 +844,15 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -827,14 +844,15 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 827 | 844 | ||
| 828 | template <class _Tp, class _Container, class _Compare> | 845 | template <class _Tp, class _Container, class _Compare> |
| 829 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > | 846 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 830 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a) | 847 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 848 | const priority_queue& __q, const _Alloc& __a) | ||
| 831 | : c(__q.c, __a), comp(__q.comp) {} | 849 | : c(__q.c, __a), comp(__q.comp) {} |
| 832 | 850 | ||
| 833 | # ifndef _LIBCPP_CXX03_LANG | 851 | # ifndef _LIBCPP_CXX03_LANG |
| 834 | 852 | ||
| 835 | template <class _Tp, class _Container, class _Compare> | 853 | template <class _Tp, class _Container, class _Compare> |
| 836 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > | 854 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 837 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 855 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 838 | const value_compare& __comp, container_type&& __c, const _Alloc& __a) | 856 | const value_compare& __comp, container_type&& __c, const _Alloc& __a) |
| 839 | : c(std::move(__c), __a), comp(__comp) { | 857 | : c(std::move(__c), __a), comp(__comp) { |
| 840 | std::make_heap(c.begin(), c.end(), comp); | 858 | std::make_heap(c.begin(), c.end(), comp); |
| ... | @@ -842,7 +860,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -842,7 +860,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 842 | 860 | ||
| 843 | template <class _Tp, class _Container, class _Compare> | 861 | template <class _Tp, class _Container, class _Compare> |
| 844 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > | 862 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 845 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a) | 863 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 864 | priority_queue&& __q, const _Alloc& __a) | ||
| 846 | : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {} | 865 | : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {} |
| 847 | 866 | ||
| 848 | # endif // _LIBCPP_CXX03_LANG | 867 | # endif // _LIBCPP_CXX03_LANG |
| ... | @@ -852,7 +871,8 @@ template < | ... | @@ -852,7 +871,8 @@ template < |
| 852 | class _InputIter, | 871 | class _InputIter, |
| 853 | class _Alloc, | 872 | class _Alloc, |
| 854 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | 873 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > |
| 855 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a) | 874 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 875 | _InputIter __f, _InputIter __l, const _Alloc& __a) | ||
| 856 | : c(__f, __l, __a), comp() { | 876 | : c(__f, __l, __a), comp() { |
| 857 | std::make_heap(c.begin(), c.end(), comp); | 877 | std::make_heap(c.begin(), c.end(), comp); |
| 858 | } | 878 | } |
| ... | @@ -862,7 +882,7 @@ template < | ... | @@ -862,7 +882,7 @@ template < |
| 862 | class _InputIter, | 882 | class _InputIter, |
| 863 | class _Alloc, | 883 | class _Alloc, |
| 864 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | 884 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > |
| 865 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 885 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 866 | _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a) | 886 | _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a) |
| 867 | : c(__f, __l, __a), comp(__comp) { | 887 | : c(__f, __l, __a), comp(__comp) { |
| 868 | std::make_heap(c.begin(), c.end(), comp); | 888 | std::make_heap(c.begin(), c.end(), comp); |
| ... | @@ -873,7 +893,7 @@ template < | ... | @@ -873,7 +893,7 @@ template < |
| 873 | class _InputIter, | 893 | class _InputIter, |
| 874 | class _Alloc, | 894 | class _Alloc, |
| 875 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | 895 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > |
| 876 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 896 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 877 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a) | 897 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a) |
| 878 | : c(__c, __a), comp(__comp) { | 898 | : c(__c, __a), comp(__comp) { |
| 879 | c.insert(c.end(), __f, __l); | 899 | c.insert(c.end(), __f, __l); |
| ... | @@ -886,7 +906,7 @@ template < | ... | @@ -886,7 +906,7 @@ template < |
| 886 | class _InputIter, | 906 | class _InputIter, |
| 887 | class _Alloc, | 907 | class _Alloc, |
| 888 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > | 908 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > |
| 889 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | 909 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 890 | _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a) | 910 | _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a) |
| 891 | : c(std::move(__c), __a), comp(__comp) { | 911 | : c(std::move(__c), __a), comp(__comp) { |
| 892 | c.insert(c.end(), __f, __l); | 912 | c.insert(c.end(), __f, __l); |
| ... | @@ -895,7 +915,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( | ... | @@ -895,7 +915,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 895 | # endif // _LIBCPP_CXX03_LANG | 915 | # endif // _LIBCPP_CXX03_LANG |
| 896 | 916 | ||
| 897 | template <class _Tp, class _Container, class _Compare> | 917 | template <class _Tp, class _Container, class _Compare> |
| 898 | inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) { | 918 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) { |
| 899 | c.push_back(__v); | 919 | c.push_back(__v); |
| 900 | std::push_heap(c.begin(), c.end(), comp); | 920 | std::push_heap(c.begin(), c.end(), comp); |
| 901 | } | 921 | } |
| ... | @@ -903,14 +923,14 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __ | ... | @@ -903,14 +923,14 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __ |
| 903 | # ifndef _LIBCPP_CXX03_LANG | 923 | # ifndef _LIBCPP_CXX03_LANG |
| 904 | 924 | ||
| 905 | template <class _Tp, class _Container, class _Compare> | 925 | template <class _Tp, class _Container, class _Compare> |
| 906 | inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) { | 926 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) { |
| 907 | c.push_back(std::move(__v)); | 927 | c.push_back(std::move(__v)); |
| 908 | std::push_heap(c.begin(), c.end(), comp); | 928 | std::push_heap(c.begin(), c.end(), comp); |
| 909 | } | 929 | } |
| 910 | 930 | ||
| 911 | template <class _Tp, class _Container, class _Compare> | 931 | template <class _Tp, class _Container, class _Compare> |
| 912 | template <class... _Args> | 932 | template <class... _Args> |
| 913 | inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) { | 933 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) { |
| 914 | c.emplace_back(std::forward<_Args>(__args)...); | 934 | c.emplace_back(std::forward<_Args>(__args)...); |
| 915 | std::push_heap(c.begin(), c.end(), comp); | 935 | std::push_heap(c.begin(), c.end(), comp); |
| 916 | } | 936 | } |
| ... | @@ -918,13 +938,13 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args | ... | @@ -918,13 +938,13 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args |
| 918 | # endif // _LIBCPP_CXX03_LANG | 938 | # endif // _LIBCPP_CXX03_LANG |
| 919 | 939 | ||
| 920 | template <class _Tp, class _Container, class _Compare> | 940 | template <class _Tp, class _Container, class _Compare> |
| 921 | inline void priority_queue<_Tp, _Container, _Compare>::pop() { | 941 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::pop() { |
| 922 | std::pop_heap(c.begin(), c.end(), comp); | 942 | std::pop_heap(c.begin(), c.end(), comp); |
| 923 | c.pop_back(); | 943 | c.pop_back(); |
| 924 | } | 944 | } |
| 925 | 945 | ||
| 926 | template <class _Tp, class _Container, class _Compare> | 946 | template <class _Tp, class _Container, class _Compare> |
| 927 | inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) | 947 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) |
| 928 | _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>) { | 948 | _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>) { |
| 929 | using std::swap; | 949 | using std::swap; |
| 930 | swap(c, __q.c); | 950 | swap(c, __q.c); |
| ... | @@ -935,15 +955,14 @@ template <class _Tp, | ... | @@ -935,15 +955,14 @@ template <class _Tp, |
| 935 | class _Container, | 955 | class _Container, |
| 936 | class _Compare, | 956 | class _Compare, |
| 937 | __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0> | 957 | __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0> |
| 938 | inline _LIBCPP_HIDE_FROM_ABI void | 958 | _LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void |
| 939 | swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) | 959 | swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) |
| 940 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | 960 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { |
| 941 | __x.swap(__y); | 961 | __x.swap(__y); |
| 942 | } | 962 | } |
| 943 | 963 | ||
| 944 | template <class _Tp, class _Container, class _Compare, class _Alloc> | 964 | template <class _Tp, class _Container, class _Compare, class _Alloc> |
| 945 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> | 965 | struct uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> : public uses_allocator<_Container, _Alloc> {}; |
| 946 | : public uses_allocator<_Container, _Alloc> {}; | ||
| 947 | 966 | ||
| 948 | _LIBCPP_END_NAMESPACE_STD | 967 | _LIBCPP_END_NAMESPACE_STD |
| 949 | 968 |
lib/libcxx/include/ranges+11-1| ... | @@ -285,6 +285,15 @@ namespace std::ranges { | ... | @@ -285,6 +285,15 @@ namespace std::ranges { |
| 285 | requires view<V> && input_range<range_reference_t<V>> | 285 | requires view<V> && input_range<range_reference_t<V>> |
| 286 | class join_view; | 286 | class join_view; |
| 287 | 287 | ||
| 288 | // [range.join.with], join with view | ||
| 289 | template<input_range V, forward_range Pattern> | ||
| 290 | requires view<V> && input_range<range_reference_t<V>> | ||
| 291 | && view<Pattern> | ||
| 292 | && concatable<range_reference_t<V>, Pattern> | ||
| 293 | class join_with_view; // since C++23 | ||
| 294 | |||
| 295 | namespace views { inline constexpr unspecified join_with = unspecified; } // since C++23 | ||
| 296 | |||
| 288 | // [range.lazy.split], lazy split view | 297 | // [range.lazy.split], lazy split view |
| 289 | template<class R> | 298 | template<class R> |
| 290 | concept tiny-range = see below; // exposition only | 299 | concept tiny-range = see below; // exposition only |
| ... | @@ -381,7 +390,7 @@ namespace std { | ... | @@ -381,7 +390,7 @@ namespace std { |
| 381 | */ | 390 | */ |
| 382 | 391 | ||
| 383 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 392 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 384 | # include <__cxx03/ranges> | 393 | # include <__cxx03/__config> |
| 385 | #else | 394 | #else |
| 386 | # include <__config> | 395 | # include <__config> |
| 387 | 396 | ||
| ... | @@ -427,6 +436,7 @@ namespace std { | ... | @@ -427,6 +436,7 @@ namespace std { |
| 427 | # include <__ranges/as_rvalue_view.h> | 436 | # include <__ranges/as_rvalue_view.h> |
| 428 | # include <__ranges/chunk_by_view.h> | 437 | # include <__ranges/chunk_by_view.h> |
| 429 | # include <__ranges/from_range.h> | 438 | # include <__ranges/from_range.h> |
| 439 | # include <__ranges/join_with_view.h> | ||
| 430 | # include <__ranges/repeat_view.h> | 440 | # include <__ranges/repeat_view.h> |
| 431 | # include <__ranges/to.h> | 441 | # include <__ranges/to.h> |
| 432 | # include <__ranges/zip_view.h> | 442 | # include <__ranges/zip_view.h> |
lib/libcxx/include/ratio+11-11| ... | @@ -229,7 +229,7 @@ public: | ... | @@ -229,7 +229,7 @@ public: |
| 229 | }; | 229 | }; |
| 230 | 230 | ||
| 231 | template <intmax_t _Num, intmax_t _Den = 1> | 231 | template <intmax_t _Num, intmax_t _Den = 1> |
| 232 | class _LIBCPP_TEMPLATE_VIS ratio { | 232 | class ratio { |
| 233 | static_assert(__static_abs<_Num> >= 0, "ratio numerator is out of range"); | 233 | static_assert(__static_abs<_Num> >= 0, "ratio numerator is out of range"); |
| 234 | static_assert(_Den != 0, "ratio divide by 0"); | 234 | static_assert(_Den != 0, "ratio divide by 0"); |
| 235 | static_assert(__static_abs<_Den> > 0, "ratio denominator is out of range"); | 235 | static_assert(__static_abs<_Den> > 0, "ratio denominator is out of range"); |
| ... | @@ -290,7 +290,7 @@ using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type; | ... | @@ -290,7 +290,7 @@ using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type; |
| 290 | # else // _LIBCPP_CXX03_LANG | 290 | # else // _LIBCPP_CXX03_LANG |
| 291 | 291 | ||
| 292 | template <class _R1, class _R2> | 292 | template <class _R1, class _R2> |
| 293 | struct _LIBCPP_TEMPLATE_VIS ratio_multiply : public __ratio_multiply<_R1, _R2>::type {}; | 293 | struct ratio_multiply : public __ratio_multiply<_R1, _R2>::type {}; |
| 294 | 294 | ||
| 295 | # endif // _LIBCPP_CXX03_LANG | 295 | # endif // _LIBCPP_CXX03_LANG |
| 296 | 296 | ||
| ... | @@ -316,7 +316,7 @@ using ratio_divide = typename __ratio_divide<_R1, _R2>::type; | ... | @@ -316,7 +316,7 @@ using ratio_divide = typename __ratio_divide<_R1, _R2>::type; |
| 316 | # else // _LIBCPP_CXX03_LANG | 316 | # else // _LIBCPP_CXX03_LANG |
| 317 | 317 | ||
| 318 | template <class _R1, class _R2> | 318 | template <class _R1, class _R2> |
| 319 | struct _LIBCPP_TEMPLATE_VIS ratio_divide : public __ratio_divide<_R1, _R2>::type {}; | 319 | struct ratio_divide : public __ratio_divide<_R1, _R2>::type {}; |
| 320 | 320 | ||
| 321 | # endif // _LIBCPP_CXX03_LANG | 321 | # endif // _LIBCPP_CXX03_LANG |
| 322 | 322 | ||
| ... | @@ -345,7 +345,7 @@ using ratio_add = typename __ratio_add<_R1, _R2>::type; | ... | @@ -345,7 +345,7 @@ using ratio_add = typename __ratio_add<_R1, _R2>::type; |
| 345 | # else // _LIBCPP_CXX03_LANG | 345 | # else // _LIBCPP_CXX03_LANG |
| 346 | 346 | ||
| 347 | template <class _R1, class _R2> | 347 | template <class _R1, class _R2> |
| 348 | struct _LIBCPP_TEMPLATE_VIS ratio_add : public __ratio_add<_R1, _R2>::type {}; | 348 | struct ratio_add : public __ratio_add<_R1, _R2>::type {}; |
| 349 | 349 | ||
| 350 | # endif // _LIBCPP_CXX03_LANG | 350 | # endif // _LIBCPP_CXX03_LANG |
| 351 | 351 | ||
| ... | @@ -374,20 +374,20 @@ using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; | ... | @@ -374,20 +374,20 @@ using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; |
| 374 | # else // _LIBCPP_CXX03_LANG | 374 | # else // _LIBCPP_CXX03_LANG |
| 375 | 375 | ||
| 376 | template <class _R1, class _R2> | 376 | template <class _R1, class _R2> |
| 377 | struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::type {}; | 377 | struct ratio_subtract : public __ratio_subtract<_R1, _R2>::type {}; |
| 378 | 378 | ||
| 379 | # endif // _LIBCPP_CXX03_LANG | 379 | # endif // _LIBCPP_CXX03_LANG |
| 380 | 380 | ||
| 381 | // ratio_equal | 381 | // ratio_equal |
| 382 | 382 | ||
| 383 | template <class _R1, class _R2> | 383 | template <class _R1, class _R2> |
| 384 | struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> { | 384 | struct ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> { |
| 385 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | 385 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); |
| 386 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | 386 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); |
| 387 | }; | 387 | }; |
| 388 | 388 | ||
| 389 | template <class _R1, class _R2> | 389 | template <class _R1, class _R2> |
| 390 | struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> { | 390 | struct ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> { |
| 391 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | 391 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); |
| 392 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | 392 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); |
| 393 | }; | 393 | }; |
| ... | @@ -441,25 +441,25 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> { | ... | @@ -441,25 +441,25 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> { |
| 441 | }; | 441 | }; |
| 442 | 442 | ||
| 443 | template <class _R1, class _R2> | 443 | template <class _R1, class _R2> |
| 444 | struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> { | 444 | struct ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> { |
| 445 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | 445 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); |
| 446 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | 446 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); |
| 447 | }; | 447 | }; |
| 448 | 448 | ||
| 449 | template <class _R1, class _R2> | 449 | template <class _R1, class _R2> |
| 450 | struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> { | 450 | struct ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> { |
| 451 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | 451 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); |
| 452 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | 452 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); |
| 453 | }; | 453 | }; |
| 454 | 454 | ||
| 455 | template <class _R1, class _R2> | 455 | template <class _R1, class _R2> |
| 456 | struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> { | 456 | struct ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> { |
| 457 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | 457 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); |
| 458 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | 458 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); |
| 459 | }; | 459 | }; |
| 460 | 460 | ||
| 461 | template <class _R1, class _R2> | 461 | template <class _R1, class _R2> |
| 462 | struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> { | 462 | struct ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> { |
| 463 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | 463 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); |
| 464 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | 464 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); |
| 465 | }; | 465 | }; |
lib/libcxx/include/regex+248-241| ... | @@ -792,26 +792,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | ... | @@ -792,26 +792,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 792 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 792 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 793 | # include <__cxx03/regex> | 793 | # include <__cxx03/regex> |
| 794 | #else | 794 | #else |
| 795 | # include <__algorithm/find.h> | ||
| 796 | # include <__algorithm/search.h> | ||
| 797 | # include <__assert> | ||
| 798 | # include <__config> | 795 | # include <__config> |
| 799 | # include <__iterator/back_insert_iterator.h> | ||
| 800 | # include <__iterator/default_sentinel.h> | ||
| 801 | # include <__iterator/wrap_iter.h> | ||
| 802 | # include <__locale> | ||
| 803 | # include <__memory/shared_ptr.h> | ||
| 804 | # include <__memory_resource/polymorphic_allocator.h> | ||
| 805 | # include <__type_traits/is_swappable.h> | ||
| 806 | # include <__utility/move.h> | ||
| 807 | # include <__utility/pair.h> | ||
| 808 | # include <__utility/swap.h> | ||
| 809 | # include <__verbose_abort> | ||
| 810 | # include <deque> | ||
| 811 | # include <stdexcept> | ||
| 812 | # include <string> | ||
| 813 | # include <vector> | ||
| 814 | # include <version> | ||
| 815 | 796 | ||
| 816 | // standard-mandated includes | 797 | // standard-mandated includes |
| 817 | 798 | ||
| ... | @@ -826,14 +807,37 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | ... | @@ -826,14 +807,37 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 826 | # include <compare> | 807 | # include <compare> |
| 827 | # include <initializer_list> | 808 | # include <initializer_list> |
| 828 | 809 | ||
| 829 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 810 | # if _LIBCPP_HAS_LOCALIZATION |
| 830 | # pragma GCC system_header | 811 | |
| 831 | # endif | 812 | # include <__algorithm/find.h> |
| 813 | # include <__algorithm/search.h> | ||
| 814 | # include <__assert> | ||
| 815 | # include <__iterator/back_insert_iterator.h> | ||
| 816 | # include <__iterator/default_sentinel.h> | ||
| 817 | # include <__iterator/wrap_iter.h> | ||
| 818 | # include <__locale> | ||
| 819 | # include <__memory/addressof.h> | ||
| 820 | # include <__memory/shared_ptr.h> | ||
| 821 | # include <__memory_resource/polymorphic_allocator.h> | ||
| 822 | # include <__type_traits/is_swappable.h> | ||
| 823 | # include <__utility/move.h> | ||
| 824 | # include <__utility/pair.h> | ||
| 825 | # include <__utility/swap.h> | ||
| 826 | # include <__verbose_abort> | ||
| 827 | # include <deque> | ||
| 828 | # include <stdexcept> | ||
| 829 | # include <string> | ||
| 830 | # include <vector> | ||
| 831 | # include <version> | ||
| 832 | |||
| 833 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 834 | # pragma GCC system_header | ||
| 835 | # endif | ||
| 832 | 836 | ||
| 833 | _LIBCPP_PUSH_MACROS | 837 | _LIBCPP_PUSH_MACROS |
| 834 | # include <__undef_macros> | 838 | # include <__undef_macros> |
| 835 | 839 | ||
| 836 | # define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 | 840 | # define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 |
| 837 | 841 | ||
| 838 | _LIBCPP_BEGIN_NAMESPACE_STD | 842 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 839 | 843 | ||
| ... | @@ -846,11 +850,11 @@ enum syntax_option_type { | ... | @@ -846,11 +850,11 @@ enum syntax_option_type { |
| 846 | nosubs = 1 << 1, | 850 | nosubs = 1 << 1, |
| 847 | optimize = 1 << 2, | 851 | optimize = 1 << 2, |
| 848 | collate = 1 << 3, | 852 | collate = 1 << 3, |
| 849 | # ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | 853 | # ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO |
| 850 | ECMAScript = 1 << 9, | 854 | ECMAScript = 1 << 9, |
| 851 | # else | 855 | # else |
| 852 | ECMAScript = 0, | 856 | ECMAScript = 0, |
| 853 | # endif | 857 | # endif |
| 854 | basic = 1 << 4, | 858 | basic = 1 << 4, |
| 855 | extended = 1 << 5, | 859 | extended = 1 << 5, |
| 856 | awk = 1 << 6, | 860 | awk = 1 << 6, |
| ... | @@ -861,11 +865,11 @@ enum syntax_option_type { | ... | @@ -861,11 +865,11 @@ enum syntax_option_type { |
| 861 | }; | 865 | }; |
| 862 | 866 | ||
| 863 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) { | 867 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) { |
| 864 | # ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | 868 | # ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO |
| 865 | return static_cast<syntax_option_type>(__g & 0x3F0); | 869 | return static_cast<syntax_option_type>(__g & 0x3F0); |
| 866 | # else | 870 | # else |
| 867 | return static_cast<syntax_option_type>(__g & 0x1F0); | 871 | return static_cast<syntax_option_type>(__g & 0x1F0); |
| 868 | # endif | 872 | # endif |
| 869 | } | 873 | } |
| 870 | 874 | ||
| 871 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) { | 875 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) { |
| ... | @@ -987,20 +991,20 @@ public: | ... | @@ -987,20 +991,20 @@ public: |
| 987 | 991 | ||
| 988 | template <regex_constants::error_type _Ev> | 992 | template <regex_constants::error_type _Ev> |
| 989 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { | 993 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { |
| 990 | # if _LIBCPP_HAS_EXCEPTIONS | 994 | # if _LIBCPP_HAS_EXCEPTIONS |
| 991 | throw regex_error(_Ev); | 995 | throw regex_error(_Ev); |
| 992 | # else | 996 | # else |
| 993 | _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode"); | 997 | _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode"); |
| 994 | # endif | 998 | # endif |
| 995 | } | 999 | } |
| 996 | 1000 | ||
| 997 | template <class _CharT> | 1001 | template <class _CharT> |
| 998 | struct _LIBCPP_TEMPLATE_VIS regex_traits { | 1002 | struct regex_traits { |
| 999 | public: | 1003 | public: |
| 1000 | typedef _CharT char_type; | 1004 | typedef _CharT char_type; |
| 1001 | typedef basic_string<char_type> string_type; | 1005 | typedef basic_string<char_type> string_type; |
| 1002 | typedef locale locale_type; | 1006 | typedef locale locale_type; |
| 1003 | # if defined(__BIONIC__) || defined(_NEWLIB_VERSION) | 1007 | # if defined(__BIONIC__) || defined(_NEWLIB_VERSION) |
| 1004 | // Originally bionic's ctype_base used its own ctype masks because the | 1008 | // Originally bionic's ctype_base used its own ctype masks because the |
| 1005 | // 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 |
| 1006 | // 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 |
| ... | @@ -1015,9 +1019,9 @@ public: | ... | @@ -1015,9 +1019,9 @@ public: |
| 1015 | // often used for space constrained environments, so it makes sense not to | 1019 | // often used for space constrained environments, so it makes sense not to |
| 1016 | // duplicate the ctype table. | 1020 | // duplicate the ctype table. |
| 1017 | typedef uint16_t char_class_type; | 1021 | typedef uint16_t char_class_type; |
| 1018 | # else | 1022 | # else |
| 1019 | typedef ctype_base::mask char_class_type; | 1023 | typedef ctype_base::mask char_class_type; |
| 1020 | # endif | 1024 | # endif |
| 1021 | 1025 | ||
| 1022 | static const char_class_type __regex_word = ctype_base::__regex_word; | 1026 | static const char_class_type __regex_word = ctype_base::__regex_word; |
| 1023 | 1027 | ||
| ... | @@ -1057,30 +1061,30 @@ private: | ... | @@ -1057,30 +1061,30 @@ private: |
| 1057 | 1061 | ||
| 1058 | template <class _ForwardIterator> | 1062 | template <class _ForwardIterator> |
| 1059 | string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; | 1063 | string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 1060 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1064 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1061 | template <class _ForwardIterator> | 1065 | template <class _ForwardIterator> |
| 1062 | string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 1066 | string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 1063 | # endif | 1067 | # endif |
| 1064 | template <class _ForwardIterator> | 1068 | template <class _ForwardIterator> |
| 1065 | string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; | 1069 | string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 1066 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1070 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1067 | template <class _ForwardIterator> | 1071 | template <class _ForwardIterator> |
| 1068 | string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 1072 | string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 1069 | # endif | 1073 | # endif |
| 1070 | template <class _ForwardIterator> | 1074 | template <class _ForwardIterator> |
| 1071 | char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const; | 1075 | char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const; |
| 1072 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1076 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1073 | template <class _ForwardIterator> | 1077 | template <class _ForwardIterator> |
| 1074 | char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; | 1078 | char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; |
| 1075 | # endif | 1079 | # endif |
| 1076 | 1080 | ||
| 1077 | static int __regex_traits_value(unsigned char __ch, int __radix); | 1081 | static int __regex_traits_value(unsigned char __ch, int __radix); |
| 1078 | _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const { | 1082 | _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const { |
| 1079 | return __regex_traits_value(static_cast<unsigned char>(__ch), __radix); | 1083 | return __regex_traits_value(static_cast<unsigned char>(__ch), __radix); |
| 1080 | } | 1084 | } |
| 1081 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1085 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1082 | _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const; | 1086 | _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const; |
| 1083 | # endif | 1087 | # endif |
| 1084 | }; | 1088 | }; |
| 1085 | 1089 | ||
| 1086 | template <class _CharT> | 1090 | template <class _CharT> |
| ... | @@ -1106,8 +1110,8 @@ regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) cons | ... | @@ -1106,8 +1110,8 @@ regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) cons |
| 1106 | 1110 | ||
| 1107 | template <class _CharT> | 1111 | template <class _CharT> |
| 1108 | void regex_traits<_CharT>::__init() { | 1112 | void regex_traits<_CharT>::__init() { |
| 1109 | __ct_ = &std::use_facet<ctype<char_type> >(__loc_); | 1113 | __ct_ = std::addressof(std::use_facet<ctype<char_type> >(__loc_)); |
| 1110 | __col_ = &std::use_facet<collate<char_type> >(__loc_); | 1114 | __col_ = std::addressof(std::use_facet<collate<char_type> >(__loc_)); |
| 1111 | } | 1115 | } |
| 1112 | 1116 | ||
| 1113 | template <class _CharT> | 1117 | template <class _CharT> |
| ... | @@ -1139,7 +1143,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator | ... | @@ -1139,7 +1143,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator |
| 1139 | return __d; | 1143 | return __d; |
| 1140 | } | 1144 | } |
| 1141 | 1145 | ||
| 1142 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1146 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1143 | template <class _CharT> | 1147 | template <class _CharT> |
| 1144 | template <class _ForwardIterator> | 1148 | template <class _ForwardIterator> |
| 1145 | typename regex_traits<_CharT>::string_type | 1149 | typename regex_traits<_CharT>::string_type |
| ... | @@ -1158,7 +1162,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator | ... | @@ -1158,7 +1162,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator |
| 1158 | } | 1162 | } |
| 1159 | return __d; | 1163 | return __d; |
| 1160 | } | 1164 | } |
| 1161 | # endif | 1165 | # endif |
| 1162 | 1166 | ||
| 1163 | // lookup_collatename is very FreeBSD-specific | 1167 | // lookup_collatename is very FreeBSD-specific |
| 1164 | 1168 | ||
| ... | @@ -1183,7 +1187,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato | ... | @@ -1183,7 +1187,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato |
| 1183 | return __r; | 1187 | return __r; |
| 1184 | } | 1188 | } |
| 1185 | 1189 | ||
| 1186 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1190 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1187 | template <class _CharT> | 1191 | template <class _CharT> |
| 1188 | template <class _ForwardIterator> | 1192 | template <class _ForwardIterator> |
| 1189 | typename regex_traits<_CharT>::string_type | 1193 | typename regex_traits<_CharT>::string_type |
| ... | @@ -1211,7 +1215,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato | ... | @@ -1211,7 +1215,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato |
| 1211 | } | 1215 | } |
| 1212 | return __r; | 1216 | return __r; |
| 1213 | } | 1217 | } |
| 1214 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 1218 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 1215 | 1219 | ||
| 1216 | // lookup_classname | 1220 | // lookup_classname |
| 1217 | 1221 | ||
| ... | @@ -1222,17 +1226,17 @@ template <class _ForwardIterator> | ... | @@ -1222,17 +1226,17 @@ template <class _ForwardIterator> |
| 1222 | typename regex_traits<_CharT>::char_class_type | 1226 | typename regex_traits<_CharT>::char_class_type |
| 1223 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const { | 1227 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const { |
| 1224 | string_type __s(__f, __l); | 1228 | string_type __s(__f, __l); |
| 1225 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 1229 | __ct_->tolower(std::addressof(__s[0]), std::addressof(__s[0]) + __s.size()); |
| 1226 | return std::__get_classname(__s.c_str(), __icase); | 1230 | return std::__get_classname(__s.c_str(), __icase); |
| 1227 | } | 1231 | } |
| 1228 | 1232 | ||
| 1229 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1233 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1230 | template <class _CharT> | 1234 | template <class _CharT> |
| 1231 | template <class _ForwardIterator> | 1235 | template <class _ForwardIterator> |
| 1232 | typename regex_traits<_CharT>::char_class_type | 1236 | typename regex_traits<_CharT>::char_class_type |
| 1233 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const { | 1237 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const { |
| 1234 | string_type __s(__f, __l); | 1238 | string_type __s(__f, __l); |
| 1235 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 1239 | __ct_->tolower(std::addressof(__s[0]), std::addressof(__s[0]) + __s.size()); |
| 1236 | string __n; | 1240 | string __n; |
| 1237 | __n.reserve(__s.size()); | 1241 | __n.reserve(__s.size()); |
| 1238 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); __i != __e; ++__i) { | 1242 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); __i != __e; ++__i) { |
| ... | @@ -1242,7 +1246,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator | ... | @@ -1242,7 +1246,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator |
| 1242 | } | 1246 | } |
| 1243 | return __get_classname(__n.c_str(), __icase); | 1247 | return __get_classname(__n.c_str(), __icase); |
| 1244 | } | 1248 | } |
| 1245 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 1249 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 1246 | 1250 | ||
| 1247 | template <class _CharT> | 1251 | template <class _CharT> |
| 1248 | bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { | 1252 | bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { |
| ... | @@ -1253,28 +1257,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { | ... | @@ -1253,28 +1257,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { |
| 1253 | 1257 | ||
| 1254 | inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) { | 1258 | inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) { |
| 1255 | return (__c & 0xF8u) == | 1259 | return (__c & 0xF8u) == |
| 1256 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | 1260 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) |
| 1257 | 0xF0; | 1261 | 0xF0; |
| 1258 | # else | 1262 | # else |
| 1259 | 0x30; | 1263 | 0x30; |
| 1260 | # endif | 1264 | # endif |
| 1261 | } | 1265 | } |
| 1262 | 1266 | ||
| 1263 | inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) { | 1267 | inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) { |
| 1264 | return (__c & 0xFEu) == | 1268 | return (__c & 0xFEu) == |
| 1265 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | 1269 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) |
| 1266 | 0xF8; | 1270 | 0xF8; |
| 1267 | # else | 1271 | # else |
| 1268 | 0x38; | 1272 | 0x38; |
| 1269 | # endif | 1273 | # endif |
| 1270 | } | 1274 | } |
| 1271 | 1275 | ||
| 1272 | inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) { | 1276 | inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) { |
| 1273 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | 1277 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) |
| 1274 | return __c & 0xBF; | 1278 | return __c & 0xBF; |
| 1275 | # else | 1279 | # else |
| 1276 | return __c | 0x20; | 1280 | return __c | 0x20; |
| 1277 | # endif | 1281 | # endif |
| 1278 | } | 1282 | } |
| 1279 | 1283 | ||
| 1280 | template <class _CharT> | 1284 | template <class _CharT> |
| ... | @@ -1293,21 +1297,21 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) | ... | @@ -1293,21 +1297,21 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) |
| 1293 | return -1; | 1297 | return -1; |
| 1294 | } | 1298 | } |
| 1295 | 1299 | ||
| 1296 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1300 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1297 | template <class _CharT> | 1301 | template <class _CharT> |
| 1298 | inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { | 1302 | inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { |
| 1299 | return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); | 1303 | return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); |
| 1300 | } | 1304 | } |
| 1301 | # endif | 1305 | # endif |
| 1302 | 1306 | ||
| 1303 | template <class _CharT> | 1307 | template <class _CharT> |
| 1304 | class __node; | 1308 | class __node; |
| 1305 | 1309 | ||
| 1306 | template <class _BidirectionalIterator> | 1310 | template <class _BidirectionalIterator> |
| 1307 | class _LIBCPP_TEMPLATE_VIS sub_match; | 1311 | class sub_match; |
| 1308 | 1312 | ||
| 1309 | template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > > | 1313 | template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > > |
| 1310 | class _LIBCPP_TEMPLATE_VIS match_results; | 1314 | class match_results; |
| 1311 | 1315 | ||
| 1312 | template <class _CharT> | 1316 | template <class _CharT> |
| 1313 | struct __state { | 1317 | struct __state { |
| ... | @@ -1681,7 +1685,7 @@ public: | ... | @@ -1681,7 +1685,7 @@ public: |
| 1681 | template <class _CharT> | 1685 | template <class _CharT> |
| 1682 | void __back_ref<_CharT>::__exec(__state& __s) const { | 1686 | void __back_ref<_CharT>::__exec(__state& __s) const { |
| 1683 | if (__mexp_ > __s.__sub_matches_.size()) | 1687 | if (__mexp_ > __s.__sub_matches_.size()) |
| 1684 | __throw_regex_error<regex_constants::error_backref>(); | 1688 | std::__throw_regex_error<regex_constants::error_backref>(); |
| 1685 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_ - 1]; | 1689 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_ - 1]; |
| 1686 | if (__sm.matched) { | 1690 | if (__sm.matched) { |
| 1687 | ptrdiff_t __len = __sm.second - __sm.first; | 1691 | ptrdiff_t __len = __sm.second - __sm.first; |
| ... | @@ -1941,10 +1945,10 @@ public: | ... | @@ -1941,10 +1945,10 @@ public: |
| 1941 | 1945 | ||
| 1942 | template <> | 1946 | template <> |
| 1943 | _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const; | 1947 | _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const; |
| 1944 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 1948 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 1945 | template <> | 1949 | template <> |
| 1946 | _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const; | 1950 | _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const; |
| 1947 | # endif | 1951 | # endif |
| 1948 | 1952 | ||
| 1949 | // __match_char | 1953 | // __match_char |
| 1950 | 1954 | ||
| ... | @@ -2117,7 +2121,7 @@ public: | ... | @@ -2117,7 +2121,7 @@ public: |
| 2117 | std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end()))); | 2121 | std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end()))); |
| 2118 | } else { | 2122 | } else { |
| 2119 | if (__b.size() != 1 || __e.size() != 1) | 2123 | if (__b.size() != 1 || __e.size() != 1) |
| 2120 | __throw_regex_error<regex_constants::error_range>(); | 2124 | std::__throw_regex_error<regex_constants::error_range>(); |
| 2121 | if (__icase_) { | 2125 | if (__icase_) { |
| 2122 | __b[0] = __traits_.translate_nocase(__b[0]); | 2126 | __b[0] = __traits_.translate_nocase(__b[0]); |
| 2123 | __e[0] = __traits_.translate_nocase(__e[0]); | 2127 | __e[0] = __traits_.translate_nocase(__e[0]); |
| ... | @@ -2157,7 +2161,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { | ... | @@ -2157,7 +2161,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { |
| 2157 | __ch2.first = __traits_.translate(__ch2.first); | 2161 | __ch2.first = __traits_.translate(__ch2.first); |
| 2158 | __ch2.second = __traits_.translate(__ch2.second); | 2162 | __ch2.second = __traits_.translate(__ch2.second); |
| 2159 | } | 2163 | } |
| 2160 | if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first + 2).empty()) { | 2164 | if (!__traits_.lookup_collatename(std::addressof(__ch2.first), std::addressof(__ch2.first) + 2).empty()) { |
| 2161 | // __ch2 is a digraph in this locale | 2165 | // __ch2 is a digraph in this locale |
| 2162 | ++__consumed; | 2166 | ++__consumed; |
| 2163 | for (size_t __i = 0; __i < __digraphs_.size(); ++__i) { | 2167 | for (size_t __i = 0; __i < __digraphs_.size(); ++__i) { |
| ... | @@ -2167,7 +2171,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { | ... | @@ -2167,7 +2171,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { |
| 2167 | } | 2171 | } |
| 2168 | } | 2172 | } |
| 2169 | if (__collate_ && !__ranges_.empty()) { | 2173 | if (__collate_ && !__ranges_.empty()) { |
| 2170 | string_type __s2 = __traits_.transform(&__ch2.first, &__ch2.first + 2); | 2174 | string_type __s2 = __traits_.transform(std::addressof(__ch2.first), std::addressof(__ch2.first) + 2); |
| 2171 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) { | 2175 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) { |
| 2172 | if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) { | 2176 | if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) { |
| 2173 | __found = true; | 2177 | __found = true; |
| ... | @@ -2176,7 +2180,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { | ... | @@ -2176,7 +2180,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { |
| 2176 | } | 2180 | } |
| 2177 | } | 2181 | } |
| 2178 | if (!__equivalences_.empty()) { | 2182 | if (!__equivalences_.empty()) { |
| 2179 | string_type __s2 = __traits_.transform_primary(&__ch2.first, &__ch2.first + 2); | 2183 | string_type __s2 = |
| 2184 | __traits_.transform_primary(std::addressof(__ch2.first), std::addressof(__ch2.first) + 2); | ||
| 2180 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) { | 2185 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) { |
| 2181 | if (__s2 == __equivalences_[__i]) { | 2186 | if (__s2 == __equivalences_[__i]) { |
| 2182 | __found = true; | 2187 | __found = true; |
| ... | @@ -2224,7 +2229,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { | ... | @@ -2224,7 +2229,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { |
| 2224 | } | 2229 | } |
| 2225 | } | 2230 | } |
| 2226 | if (!__ranges_.empty()) { | 2231 | if (!__ranges_.empty()) { |
| 2227 | string_type __s2 = __collate_ ? __traits_.transform(&__ch, &__ch + 1) : string_type(1, __ch); | 2232 | string_type __s2 = |
| 2233 | __collate_ ? __traits_.transform(std::addressof(__ch), std::addressof(__ch) + 1) : string_type(1, __ch); | ||
| 2228 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) { | 2234 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) { |
| 2229 | if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) { | 2235 | if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) { |
| 2230 | __found = true; | 2236 | __found = true; |
| ... | @@ -2233,7 +2239,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { | ... | @@ -2233,7 +2239,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const { |
| 2233 | } | 2239 | } |
| 2234 | } | 2240 | } |
| 2235 | if (!__equivalences_.empty()) { | 2241 | if (!__equivalences_.empty()) { |
| 2236 | string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1); | 2242 | string_type __s2 = __traits_.transform_primary(std::addressof(__ch), std::addressof(__ch) + 1); |
| 2237 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) { | 2243 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) { |
| 2238 | if (__s2 == __equivalences_[__i]) { | 2244 | if (__s2 == __equivalences_[__i]) { |
| 2239 | __found = true; | 2245 | __found = true; |
| ... | @@ -2262,16 +2268,15 @@ template <class _CharT, class _Traits> | ... | @@ -2262,16 +2268,15 @@ template <class _CharT, class _Traits> |
| 2262 | class __lookahead; | 2268 | class __lookahead; |
| 2263 | 2269 | ||
| 2264 | template <class _CharT, class _Traits = regex_traits<_CharT> > | 2270 | template <class _CharT, class _Traits = regex_traits<_CharT> > |
| 2265 | class _LIBCPP_TEMPLATE_VIS basic_regex; | 2271 | class basic_regex; |
| 2266 | 2272 | ||
| 2267 | typedef basic_regex<char> regex; | 2273 | typedef basic_regex<char> regex; |
| 2268 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 2274 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 2269 | typedef basic_regex<wchar_t> wregex; | 2275 | typedef basic_regex<wchar_t> wregex; |
| 2270 | # endif | 2276 | # endif |
| 2271 | 2277 | ||
| 2272 | template <class _CharT, class _Traits> | 2278 | template <class _CharT, class _Traits> |
| 2273 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(regex) | 2279 | class _LIBCPP_PREFERRED_NAME(regex) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wregex)) basic_regex { |
| 2274 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wregex)) basic_regex { | ||
| 2275 | public: | 2280 | public: |
| 2276 | // types: | 2281 | // types: |
| 2277 | typedef _CharT value_type; | 2282 | typedef _CharT value_type; |
| ... | @@ -2338,21 +2343,21 @@ public: | ... | @@ -2338,21 +2343,21 @@ public: |
| 2338 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { | 2343 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { |
| 2339 | __init(__first, __last); | 2344 | __init(__first, __last); |
| 2340 | } | 2345 | } |
| 2341 | # ifndef _LIBCPP_CXX03_LANG | 2346 | # ifndef _LIBCPP_CXX03_LANG |
| 2342 | _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) | 2347 | _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) |
| 2343 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { | 2348 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { |
| 2344 | __init(__il.begin(), __il.end()); | 2349 | __init(__il.begin(), __il.end()); |
| 2345 | } | 2350 | } |
| 2346 | # endif // _LIBCPP_CXX03_LANG | 2351 | # endif // _LIBCPP_CXX03_LANG |
| 2347 | 2352 | ||
| 2348 | // ~basic_regex() = default; | 2353 | // ~basic_regex() = default; |
| 2349 | 2354 | ||
| 2350 | // basic_regex& operator=(const basic_regex&) = default; | 2355 | // basic_regex& operator=(const basic_regex&) = default; |
| 2351 | // basic_regex& operator=(basic_regex&&) = default; | 2356 | // basic_regex& operator=(basic_regex&&) = default; |
| 2352 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); } | 2357 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); } |
| 2353 | # ifndef _LIBCPP_CXX03_LANG | 2358 | # ifndef _LIBCPP_CXX03_LANG |
| 2354 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list<value_type> __il) { return assign(__il); } | 2359 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list<value_type> __il) { return assign(__il); } |
| 2355 | # endif // _LIBCPP_CXX03_LANG | 2360 | # endif // _LIBCPP_CXX03_LANG |
| 2356 | template <class _ST, class _SA> | 2361 | template <class _ST, class _SA> |
| 2357 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) { | 2362 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) { |
| 2358 | return assign(__p); | 2363 | return assign(__p); |
| ... | @@ -2360,9 +2365,9 @@ public: | ... | @@ -2360,9 +2365,9 @@ public: |
| 2360 | 2365 | ||
| 2361 | // assign: | 2366 | // assign: |
| 2362 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; } | 2367 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; } |
| 2363 | # ifndef _LIBCPP_CXX03_LANG | 2368 | # ifndef _LIBCPP_CXX03_LANG |
| 2364 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); } | 2369 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); } |
| 2365 | # endif | 2370 | # endif |
| 2366 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) { | 2371 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) { |
| 2367 | return assign(__p, __p + __traits_.length(__p), __f); | 2372 | return assign(__p, __p + __traits_.length(__p), __f); |
| 2368 | } | 2373 | } |
| ... | @@ -2399,14 +2404,14 @@ public: | ... | @@ -2399,14 +2404,14 @@ public: |
| 2399 | return assign(basic_regex(__first, __last, __f)); | 2404 | return assign(basic_regex(__first, __last, __f)); |
| 2400 | } | 2405 | } |
| 2401 | 2406 | ||
| 2402 | # ifndef _LIBCPP_CXX03_LANG | 2407 | # ifndef _LIBCPP_CXX03_LANG |
| 2403 | 2408 | ||
| 2404 | _LIBCPP_HIDE_FROM_ABI basic_regex& | 2409 | _LIBCPP_HIDE_FROM_ABI basic_regex& |
| 2405 | assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) { | 2410 | assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) { |
| 2406 | return assign(__il.begin(), __il.end(), __f); | 2411 | return assign(__il.begin(), __il.end(), __f); |
| 2407 | } | 2412 | } |
| 2408 | 2413 | ||
| 2409 | # endif // _LIBCPP_CXX03_LANG | 2414 | # endif // _LIBCPP_CXX03_LANG |
| 2410 | 2415 | ||
| 2411 | // const operations: | 2416 | // const operations: |
| 2412 | _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; } | 2417 | _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; } |
| ... | @@ -2647,11 +2652,11 @@ private: | ... | @@ -2647,11 +2652,11 @@ private: |
| 2647 | friend class __lookahead; | 2652 | friend class __lookahead; |
| 2648 | }; | 2653 | }; |
| 2649 | 2654 | ||
| 2650 | # if _LIBCPP_STD_VER >= 17 | 2655 | # if _LIBCPP_STD_VER >= 17 |
| 2651 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | 2656 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> |
| 2652 | basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript) | 2657 | basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript) |
| 2653 | -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>; | 2658 | -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>; |
| 2654 | # endif | 2659 | # endif |
| 2655 | 2660 | ||
| 2656 | template <class _CharT, class _Traits> | 2661 | template <class _CharT, class _Traits> |
| 2657 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase; | 2662 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase; |
| ... | @@ -2743,7 +2748,7 @@ void basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIter | ... | @@ -2743,7 +2748,7 @@ void basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIter |
| 2743 | __flags_ |= regex_constants::ECMAScript; | 2748 | __flags_ |= regex_constants::ECMAScript; |
| 2744 | _ForwardIterator __temp = __parse(__first, __last); | 2749 | _ForwardIterator __temp = __parse(__first, __last); |
| 2745 | if (__temp != __last) | 2750 | if (__temp != __last) |
| 2746 | __throw_regex_error<regex_constants::__re_err_parse>(); | 2751 | std::__throw_regex_error<regex_constants::__re_err_parse>(); |
| 2747 | } | 2752 | } |
| 2748 | 2753 | ||
| 2749 | template <class _CharT, class _Traits> | 2754 | template <class _CharT, class _Traits> |
| ... | @@ -2773,7 +2778,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, | ... | @@ -2773,7 +2778,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, |
| 2773 | __first = __parse_egrep(__first, __last); | 2778 | __first = __parse_egrep(__first, __last); |
| 2774 | break; | 2779 | break; |
| 2775 | default: | 2780 | default: |
| 2776 | __throw_regex_error<regex_constants::__re_err_grammar>(); | 2781 | std::__throw_regex_error<regex_constants::__re_err_grammar>(); |
| 2777 | } | 2782 | } |
| 2778 | return __first; | 2783 | return __first; |
| 2779 | } | 2784 | } |
| ... | @@ -2798,7 +2803,7 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, _F | ... | @@ -2798,7 +2803,7 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, _F |
| 2798 | } | 2803 | } |
| 2799 | } | 2804 | } |
| 2800 | if (__first != __last) | 2805 | if (__first != __last) |
| 2801 | __throw_regex_error<regex_constants::__re_err_empty>(); | 2806 | std::__throw_regex_error<regex_constants::__re_err_empty>(); |
| 2802 | } | 2807 | } |
| 2803 | return __first; | 2808 | return __first; |
| 2804 | } | 2809 | } |
| ... | @@ -2810,13 +2815,13 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, | ... | @@ -2810,13 +2815,13 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, |
| 2810 | __owns_one_state<_CharT>* __sa = __end_; | 2815 | __owns_one_state<_CharT>* __sa = __end_; |
| 2811 | _ForwardIterator __temp = __parse_ERE_branch(__first, __last); | 2816 | _ForwardIterator __temp = __parse_ERE_branch(__first, __last); |
| 2812 | if (__temp == __first) | 2817 | if (__temp == __first) |
| 2813 | __throw_regex_error<regex_constants::__re_err_empty>(); | 2818 | std::__throw_regex_error<regex_constants::__re_err_empty>(); |
| 2814 | __first = __temp; | 2819 | __first = __temp; |
| 2815 | while (__first != __last && *__first == '|') { | 2820 | while (__first != __last && *__first == '|') { |
| 2816 | __owns_one_state<_CharT>* __sb = __end_; | 2821 | __owns_one_state<_CharT>* __sb = __end_; |
| 2817 | __temp = __parse_ERE_branch(++__first, __last); | 2822 | __temp = __parse_ERE_branch(++__first, __last); |
| 2818 | if (__temp == __first) | 2823 | if (__temp == __first) |
| 2819 | __throw_regex_error<regex_constants::__re_err_empty>(); | 2824 | std::__throw_regex_error<regex_constants::__re_err_empty>(); |
| 2820 | __push_alternation(__sa, __sb); | 2825 | __push_alternation(__sa, __sb); |
| 2821 | __first = __temp; | 2826 | __first = __temp; |
| 2822 | } | 2827 | } |
| ... | @@ -2828,7 +2833,7 @@ template <class _ForwardIterator> | ... | @@ -2828,7 +2833,7 @@ template <class _ForwardIterator> |
| 2828 | _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last) { | 2833 | _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last) { |
| 2829 | _ForwardIterator __temp = __parse_ERE_expression(__first, __last); | 2834 | _ForwardIterator __temp = __parse_ERE_expression(__first, __last); |
| 2830 | if (__temp == __first) | 2835 | if (__temp == __first) |
| 2831 | __throw_regex_error<regex_constants::__re_err_empty>(); | 2836 | std::__throw_regex_error<regex_constants::__re_err_empty>(); |
| 2832 | do { | 2837 | do { |
| 2833 | __first = __temp; | 2838 | __first = __temp; |
| 2834 | __temp = __parse_ERE_expression(__first, __last); | 2839 | __temp = __parse_ERE_expression(__first, __last); |
| ... | @@ -2859,7 +2864,7 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, _ | ... | @@ -2859,7 +2864,7 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, _ |
| 2859 | ++__open_count_; | 2864 | ++__open_count_; |
| 2860 | __temp = __parse_extended_reg_exp(++__temp, __last); | 2865 | __temp = __parse_extended_reg_exp(++__temp, __last); |
| 2861 | if (__temp == __last || *__temp != ')') | 2866 | if (__temp == __last || *__temp != ')') |
| 2862 | __throw_regex_error<regex_constants::error_paren>(); | 2867 | std::__throw_regex_error<regex_constants::error_paren>(); |
| 2863 | __push_end_marked_subexpression(__temp_count); | 2868 | __push_end_marked_subexpression(__temp_count); |
| 2864 | --__open_count_; | 2869 | --__open_count_; |
| 2865 | ++__temp; | 2870 | ++__temp; |
| ... | @@ -2911,7 +2916,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterat | ... | @@ -2911,7 +2916,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterat |
| 2911 | __first = __parse_RE_expression(__temp, __last); | 2916 | __first = __parse_RE_expression(__temp, __last); |
| 2912 | __temp = __parse_Back_close_paren(__first, __last); | 2917 | __temp = __parse_Back_close_paren(__first, __last); |
| 2913 | if (__temp == __first) | 2918 | if (__temp == __first) |
| 2914 | __throw_regex_error<regex_constants::error_paren>(); | 2919 | std::__throw_regex_error<regex_constants::error_paren>(); |
| 2915 | __push_end_marked_subexpression(__temp_count); | 2920 | __push_end_marked_subexpression(__temp_count); |
| 2916 | __first = __temp; | 2921 | __first = __temp; |
| 2917 | } else | 2922 | } else |
| ... | @@ -3154,14 +3159,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol( | ... | @@ -3154,14 +3159,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol( |
| 3154 | __first = __temp; | 3159 | __first = __temp; |
| 3155 | __temp = __parse_DUP_COUNT(__first, __last, __min); | 3160 | __temp = __parse_DUP_COUNT(__first, __last, __min); |
| 3156 | if (__temp == __first) | 3161 | if (__temp == __first) |
| 3157 | __throw_regex_error<regex_constants::error_badbrace>(); | 3162 | std::__throw_regex_error<regex_constants::error_badbrace>(); |
| 3158 | __first = __temp; | 3163 | __first = __temp; |
| 3159 | if (__first == __last) | 3164 | if (__first == __last) |
| 3160 | __throw_regex_error<regex_constants::error_brace>(); | 3165 | std::__throw_regex_error<regex_constants::error_brace>(); |
| 3161 | if (*__first != ',') { | 3166 | if (*__first != ',') { |
| 3162 | __temp = __parse_Back_close_brace(__first, __last); | 3167 | __temp = __parse_Back_close_brace(__first, __last); |
| 3163 | if (__temp == __first) | 3168 | if (__temp == __first) |
| 3164 | __throw_regex_error<regex_constants::error_brace>(); | 3169 | std::__throw_regex_error<regex_constants::error_brace>(); |
| 3165 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, true); | 3170 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, true); |
| 3166 | __first = __temp; | 3171 | __first = __temp; |
| 3167 | } else { | 3172 | } else { |
| ... | @@ -3170,12 +3175,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol( | ... | @@ -3170,12 +3175,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol( |
| 3170 | __first = __parse_DUP_COUNT(__first, __last, __max); | 3175 | __first = __parse_DUP_COUNT(__first, __last, __max); |
| 3171 | __temp = __parse_Back_close_brace(__first, __last); | 3176 | __temp = __parse_Back_close_brace(__first, __last); |
| 3172 | if (__temp == __first) | 3177 | if (__temp == __first) |
| 3173 | __throw_regex_error<regex_constants::error_brace>(); | 3178 | std::__throw_regex_error<regex_constants::error_brace>(); |
| 3174 | if (__max == -1) | 3179 | if (__max == -1) |
| 3175 | __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); | 3180 | __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); |
| 3176 | else { | 3181 | else { |
| 3177 | if (__max < __min) | 3182 | if (__max < __min) |
| 3178 | __throw_regex_error<regex_constants::error_badbrace>(); | 3183 | std::__throw_regex_error<regex_constants::error_badbrace>(); |
| 3179 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, true); | 3184 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, true); |
| 3180 | } | 3185 | } |
| 3181 | __first = __temp; | 3186 | __first = __temp; |
| ... | @@ -3225,10 +3230,10 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( | ... | @@ -3225,10 +3230,10 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( |
| 3225 | int __min; | 3230 | int __min; |
| 3226 | _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); | 3231 | _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); |
| 3227 | if (__temp == __first) | 3232 | if (__temp == __first) |
| 3228 | __throw_regex_error<regex_constants::error_badbrace>(); | 3233 | std::__throw_regex_error<regex_constants::error_badbrace>(); |
| 3229 | __first = __temp; | 3234 | __first = __temp; |
| 3230 | if (__first == __last) | 3235 | if (__first == __last) |
| 3231 | __throw_regex_error<regex_constants::error_brace>(); | 3236 | std::__throw_regex_error<regex_constants::error_brace>(); |
| 3232 | switch (*__first) { | 3237 | switch (*__first) { |
| 3233 | case '}': | 3238 | case '}': |
| 3234 | ++__first; | 3239 | ++__first; |
| ... | @@ -3241,7 +3246,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( | ... | @@ -3241,7 +3246,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( |
| 3241 | case ',': | 3246 | case ',': |
| 3242 | ++__first; | 3247 | ++__first; |
| 3243 | if (__first == __last) | 3248 | if (__first == __last) |
| 3244 | __throw_regex_error<regex_constants::error_badbrace>(); | 3249 | std::__throw_regex_error<regex_constants::error_badbrace>(); |
| 3245 | if (*__first == '}') { | 3250 | if (*__first == '}') { |
| 3246 | ++__first; | 3251 | ++__first; |
| 3247 | if (__grammar == ECMAScript && __first != __last && *__first == '?') { | 3252 | if (__grammar == ECMAScript && __first != __last && *__first == '?') { |
| ... | @@ -3253,13 +3258,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( | ... | @@ -3253,13 +3258,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( |
| 3253 | int __max = -1; | 3258 | int __max = -1; |
| 3254 | __temp = __parse_DUP_COUNT(__first, __last, __max); | 3259 | __temp = __parse_DUP_COUNT(__first, __last, __max); |
| 3255 | if (__temp == __first) | 3260 | if (__temp == __first) |
| 3256 | __throw_regex_error<regex_constants::error_brace>(); | 3261 | std::__throw_regex_error<regex_constants::error_brace>(); |
| 3257 | __first = __temp; | 3262 | __first = __temp; |
| 3258 | if (__first == __last || *__first != '}') | 3263 | if (__first == __last || *__first != '}') |
| 3259 | __throw_regex_error<regex_constants::error_brace>(); | 3264 | std::__throw_regex_error<regex_constants::error_brace>(); |
| 3260 | ++__first; | 3265 | ++__first; |
| 3261 | if (__max < __min) | 3266 | if (__max < __min) |
| 3262 | __throw_regex_error<regex_constants::error_badbrace>(); | 3267 | std::__throw_regex_error<regex_constants::error_badbrace>(); |
| 3263 | if (__grammar == ECMAScript && __first != __last && *__first == '?') { | 3268 | if (__grammar == ECMAScript && __first != __last && *__first == '?') { |
| 3264 | ++__first; | 3269 | ++__first; |
| 3265 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false); | 3270 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false); |
| ... | @@ -3268,7 +3273,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( | ... | @@ -3268,7 +3273,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol( |
| 3268 | } | 3273 | } |
| 3269 | break; | 3274 | break; |
| 3270 | default: | 3275 | default: |
| 3271 | __throw_regex_error<regex_constants::error_badbrace>(); | 3276 | std::__throw_regex_error<regex_constants::error_badbrace>(); |
| 3272 | } | 3277 | } |
| 3273 | } break; | 3278 | } break; |
| 3274 | } | 3279 | } |
| ... | @@ -3283,7 +3288,7 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs | ... | @@ -3283,7 +3288,7 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs |
| 3283 | if (__first != __last && *__first == '[') { | 3288 | if (__first != __last && *__first == '[') { |
| 3284 | ++__first; | 3289 | ++__first; |
| 3285 | if (__first == __last) | 3290 | if (__first == __last) |
| 3286 | __throw_regex_error<regex_constants::error_brack>(); | 3291 | std::__throw_regex_error<regex_constants::error_brack>(); |
| 3287 | bool __negate = false; | 3292 | bool __negate = false; |
| 3288 | if (*__first == '^') { | 3293 | if (*__first == '^') { |
| 3289 | ++__first; | 3294 | ++__first; |
| ... | @@ -3292,20 +3297,20 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs | ... | @@ -3292,20 +3297,20 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs |
| 3292 | __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); | 3297 | __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); |
| 3293 | // __ml owned by *this | 3298 | // __ml owned by *this |
| 3294 | if (__first == __last) | 3299 | if (__first == __last) |
| 3295 | __throw_regex_error<regex_constants::error_brack>(); | 3300 | std::__throw_regex_error<regex_constants::error_brack>(); |
| 3296 | if (__get_grammar(__flags_) != ECMAScript && *__first == ']') { | 3301 | if (__get_grammar(__flags_) != ECMAScript && *__first == ']') { |
| 3297 | __ml->__add_char(']'); | 3302 | __ml->__add_char(']'); |
| 3298 | ++__first; | 3303 | ++__first; |
| 3299 | } | 3304 | } |
| 3300 | __first = __parse_follow_list(__first, __last, __ml); | 3305 | __first = __parse_follow_list(__first, __last, __ml); |
| 3301 | if (__first == __last) | 3306 | if (__first == __last) |
| 3302 | __throw_regex_error<regex_constants::error_brack>(); | 3307 | std::__throw_regex_error<regex_constants::error_brack>(); |
| 3303 | if (*__first == '-') { | 3308 | if (*__first == '-') { |
| 3304 | __ml->__add_char('-'); | 3309 | __ml->__add_char('-'); |
| 3305 | ++__first; | 3310 | ++__first; |
| 3306 | } | 3311 | } |
| 3307 | if (__first == __last || *__first != ']') | 3312 | if (__first == __last || *__first != ']') |
| 3308 | __throw_regex_error<regex_constants::error_brack>(); | 3313 | std::__throw_regex_error<regex_constants::error_brack>(); |
| 3309 | ++__first; | 3314 | ++__first; |
| 3310 | } | 3315 | } |
| 3311 | return __first; | 3316 | return __first; |
| ... | @@ -3347,7 +3352,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term( | ... | @@ -3347,7 +3352,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term( |
| 3347 | if (__grammar == ECMAScript) | 3352 | if (__grammar == ECMAScript) |
| 3348 | __first = __parse_class_escape(++__first, __last, __start_range, __ml); | 3353 | __first = __parse_class_escape(++__first, __last, __start_range, __ml); |
| 3349 | else | 3354 | else |
| 3350 | __first = __parse_awk_escape(++__first, __last, &__start_range); | 3355 | __first = __parse_awk_escape(++__first, __last, std::addressof(__start_range)); |
| 3351 | } else { | 3356 | } else { |
| 3352 | __start_range = *__first; | 3357 | __start_range = *__first; |
| 3353 | ++__first; | 3358 | ++__first; |
| ... | @@ -3367,7 +3372,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term( | ... | @@ -3367,7 +3372,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term( |
| 3367 | if (__grammar == ECMAScript) | 3372 | if (__grammar == ECMAScript) |
| 3368 | __first = __parse_class_escape(++__first, __last, __end_range, __ml); | 3373 | __first = __parse_class_escape(++__first, __last, __end_range, __ml); |
| 3369 | else | 3374 | else |
| 3370 | __first = __parse_awk_escape(++__first, __last, &__end_range); | 3375 | __first = __parse_awk_escape(++__first, __last, std::addressof(__end_range)); |
| 3371 | } else { | 3376 | } else { |
| 3372 | __end_range = *__first; | 3377 | __end_range = *__first; |
| 3373 | ++__first; | 3378 | ++__first; |
| ... | @@ -3398,7 +3403,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape( | ... | @@ -3398,7 +3403,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape( |
| 3398 | basic_string<_CharT>& __str, | 3403 | basic_string<_CharT>& __str, |
| 3399 | __bracket_expression<_CharT, _Traits>* __ml) { | 3404 | __bracket_expression<_CharT, _Traits>* __ml) { |
| 3400 | if (__first == __last) | 3405 | if (__first == __last) |
| 3401 | __throw_regex_error<regex_constants::error_escape>(); | 3406 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3402 | switch (*__first) { | 3407 | switch (*__first) { |
| 3403 | case 0: | 3408 | case 0: |
| 3404 | __str = *__first; | 3409 | __str = *__first; |
| ... | @@ -3427,7 +3432,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape( | ... | @@ -3427,7 +3432,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape( |
| 3427 | __ml->__add_neg_char('_'); | 3432 | __ml->__add_neg_char('_'); |
| 3428 | return ++__first; | 3433 | return ++__first; |
| 3429 | } | 3434 | } |
| 3430 | __first = __parse_character_escape(__first, __last, &__str); | 3435 | __first = __parse_character_escape(__first, __last, std::addressof(__str)); |
| 3431 | return __first; | 3436 | return __first; |
| 3432 | } | 3437 | } |
| 3433 | 3438 | ||
| ... | @@ -3436,7 +3441,7 @@ template <class _ForwardIterator> | ... | @@ -3436,7 +3441,7 @@ template <class _ForwardIterator> |
| 3436 | _ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape( | 3441 | _ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape( |
| 3437 | _ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) { | 3442 | _ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) { |
| 3438 | if (__first == __last) | 3443 | if (__first == __last) |
| 3439 | __throw_regex_error<regex_constants::error_escape>(); | 3444 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3440 | switch (*__first) { | 3445 | switch (*__first) { |
| 3441 | case '\\': | 3446 | case '\\': |
| 3442 | case '"': | 3447 | case '"': |
| ... | @@ -3501,7 +3506,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape( | ... | @@ -3501,7 +3506,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape( |
| 3501 | else | 3506 | else |
| 3502 | __push_char(_CharT(__val)); | 3507 | __push_char(_CharT(__val)); |
| 3503 | } else | 3508 | } else |
| 3504 | __throw_regex_error<regex_constants::error_escape>(); | 3509 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3505 | return __first; | 3510 | return __first; |
| 3506 | } | 3511 | } |
| 3507 | 3512 | ||
| ... | @@ -3514,11 +3519,11 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class( | ... | @@ -3514,11 +3519,11 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class( |
| 3514 | value_type __equal_close[2] = {'=', ']'}; | 3519 | value_type __equal_close[2] = {'=', ']'}; |
| 3515 | _ForwardIterator __temp = std::search(__first, __last, __equal_close, __equal_close + 2); | 3520 | _ForwardIterator __temp = std::search(__first, __last, __equal_close, __equal_close + 2); |
| 3516 | if (__temp == __last) | 3521 | if (__temp == __last) |
| 3517 | __throw_regex_error<regex_constants::error_brack>(); | 3522 | std::__throw_regex_error<regex_constants::error_brack>(); |
| 3518 | // [__first, __temp) contains all text in [= ... =] | 3523 | // [__first, __temp) contains all text in [= ... =] |
| 3519 | string_type __collate_name = __traits_.lookup_collatename(__first, __temp); | 3524 | string_type __collate_name = __traits_.lookup_collatename(__first, __temp); |
| 3520 | if (__collate_name.empty()) | 3525 | if (__collate_name.empty()) |
| 3521 | __throw_regex_error<regex_constants::error_collate>(); | 3526 | std::__throw_regex_error<regex_constants::error_collate>(); |
| 3522 | string_type __equiv_name = __traits_.transform_primary(__collate_name.begin(), __collate_name.end()); | 3527 | string_type __equiv_name = __traits_.transform_primary(__collate_name.begin(), __collate_name.end()); |
| 3523 | if (!__equiv_name.empty()) | 3528 | if (!__equiv_name.empty()) |
| 3524 | __ml->__add_equivalence(__equiv_name); | 3529 | __ml->__add_equivalence(__equiv_name); |
| ... | @@ -3531,7 +3536,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class( | ... | @@ -3531,7 +3536,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class( |
| 3531 | __ml->__add_digraph(__collate_name[0], __collate_name[1]); | 3536 | __ml->__add_digraph(__collate_name[0], __collate_name[1]); |
| 3532 | break; | 3537 | break; |
| 3533 | default: | 3538 | default: |
| 3534 | __throw_regex_error<regex_constants::error_collate>(); | 3539 | std::__throw_regex_error<regex_constants::error_collate>(); |
| 3535 | } | 3540 | } |
| 3536 | } | 3541 | } |
| 3537 | __first = std::next(__temp, 2); | 3542 | __first = std::next(__temp, 2); |
| ... | @@ -3547,12 +3552,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_class( | ... | @@ -3547,12 +3552,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_class( |
| 3547 | value_type __colon_close[2] = {':', ']'}; | 3552 | value_type __colon_close[2] = {':', ']'}; |
| 3548 | _ForwardIterator __temp = std::search(__first, __last, __colon_close, __colon_close + 2); | 3553 | _ForwardIterator __temp = std::search(__first, __last, __colon_close, __colon_close + 2); |
| 3549 | if (__temp == __last) | 3554 | if (__temp == __last) |
| 3550 | __throw_regex_error<regex_constants::error_brack>(); | 3555 | std::__throw_regex_error<regex_constants::error_brack>(); |
| 3551 | // [__first, __temp) contains all text in [: ... :] | 3556 | // [__first, __temp) contains all text in [: ... :] |
| 3552 | typedef typename _Traits::char_class_type char_class_type; | 3557 | typedef typename _Traits::char_class_type char_class_type; |
| 3553 | char_class_type __class_type = __traits_.lookup_classname(__first, __temp, __flags_ & icase); | 3558 | char_class_type __class_type = __traits_.lookup_classname(__first, __temp, __flags_ & icase); |
| 3554 | if (__class_type == 0) | 3559 | if (__class_type == 0) |
| 3555 | __throw_regex_error<regex_constants::error_ctype>(); | 3560 | std::__throw_regex_error<regex_constants::error_ctype>(); |
| 3556 | __ml->__add_class(__class_type); | 3561 | __ml->__add_class(__class_type); |
| 3557 | __first = std::next(__temp, 2); | 3562 | __first = std::next(__temp, 2); |
| 3558 | return __first; | 3563 | return __first; |
| ... | @@ -3567,7 +3572,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol( | ... | @@ -3567,7 +3572,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol( |
| 3567 | value_type __dot_close[2] = {'.', ']'}; | 3572 | value_type __dot_close[2] = {'.', ']'}; |
| 3568 | _ForwardIterator __temp = std::search(__first, __last, __dot_close, __dot_close + 2); | 3573 | _ForwardIterator __temp = std::search(__first, __last, __dot_close, __dot_close + 2); |
| 3569 | if (__temp == __last) | 3574 | if (__temp == __last) |
| 3570 | __throw_regex_error<regex_constants::error_brack>(); | 3575 | std::__throw_regex_error<regex_constants::error_brack>(); |
| 3571 | // [__first, __temp) contains all text in [. ... .] | 3576 | // [__first, __temp) contains all text in [. ... .] |
| 3572 | __col_sym = __traits_.lookup_collatename(__first, __temp); | 3577 | __col_sym = __traits_.lookup_collatename(__first, __temp); |
| 3573 | switch (__col_sym.size()) { | 3578 | switch (__col_sym.size()) { |
| ... | @@ -3575,7 +3580,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol( | ... | @@ -3575,7 +3580,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol( |
| 3575 | case 2: | 3580 | case 2: |
| 3576 | break; | 3581 | break; |
| 3577 | default: | 3582 | default: |
| 3578 | __throw_regex_error<regex_constants::error_collate>(); | 3583 | std::__throw_regex_error<regex_constants::error_collate>(); |
| 3579 | } | 3584 | } |
| 3580 | __first = std::next(__temp, 2); | 3585 | __first = std::next(__temp, 2); |
| 3581 | return __first; | 3586 | return __first; |
| ... | @@ -3591,7 +3596,7 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, _Forwa | ... | @@ -3591,7 +3596,7 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, _Forwa |
| 3591 | __c = __val; | 3596 | __c = __val; |
| 3592 | for (++__first; __first != __last && (__val = __traits_.value(*__first, 10)) != -1; ++__first) { | 3597 | for (++__first; __first != __last && (__val = __traits_.value(*__first, 10)) != -1; ++__first) { |
| 3593 | if (__c >= numeric_limits<int>::max() / 10) | 3598 | if (__c >= numeric_limits<int>::max() / 10) |
| 3594 | __throw_regex_error<regex_constants::error_badbrace>(); | 3599 | std::__throw_regex_error<regex_constants::error_badbrace>(); |
| 3595 | __c *= 10; | 3600 | __c *= 10; |
| 3596 | __c += __val; | 3601 | __c += __val; |
| 3597 | } | 3602 | } |
| ... | @@ -3684,7 +3689,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato | ... | @@ -3684,7 +3689,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato |
| 3684 | __push_lookahead(std::move(__exp), false, __marked_count_); | 3689 | __push_lookahead(std::move(__exp), false, __marked_count_); |
| 3685 | __marked_count_ += __mexp; | 3690 | __marked_count_ += __mexp; |
| 3686 | if (__temp == __last || *__temp != ')') | 3691 | if (__temp == __last || *__temp != ')') |
| 3687 | __throw_regex_error<regex_constants::error_paren>(); | 3692 | std::__throw_regex_error<regex_constants::error_paren>(); |
| 3688 | __first = ++__temp; | 3693 | __first = ++__temp; |
| 3689 | } break; | 3694 | } break; |
| 3690 | case '!': { | 3695 | case '!': { |
| ... | @@ -3695,7 +3700,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato | ... | @@ -3695,7 +3700,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato |
| 3695 | __push_lookahead(std::move(__exp), true, __marked_count_); | 3700 | __push_lookahead(std::move(__exp), true, __marked_count_); |
| 3696 | __marked_count_ += __mexp; | 3701 | __marked_count_ += __mexp; |
| 3697 | if (__temp == __last || *__temp != ')') | 3702 | if (__temp == __last || *__temp != ')') |
| 3698 | __throw_regex_error<regex_constants::error_paren>(); | 3703 | std::__throw_regex_error<regex_constants::error_paren>(); |
| 3699 | __first = ++__temp; | 3704 | __first = ++__temp; |
| 3700 | } break; | 3705 | } break; |
| 3701 | } | 3706 | } |
| ... | @@ -3725,13 +3730,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f | ... | @@ -3725,13 +3730,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f |
| 3725 | case '(': { | 3730 | case '(': { |
| 3726 | ++__first; | 3731 | ++__first; |
| 3727 | if (__first == __last) | 3732 | if (__first == __last) |
| 3728 | __throw_regex_error<regex_constants::error_paren>(); | 3733 | std::__throw_regex_error<regex_constants::error_paren>(); |
| 3729 | _ForwardIterator __temp = std::next(__first); | 3734 | _ForwardIterator __temp = std::next(__first); |
| 3730 | if (__temp != __last && *__first == '?' && *__temp == ':') { | 3735 | if (__temp != __last && *__first == '?' && *__temp == ':') { |
| 3731 | ++__open_count_; | 3736 | ++__open_count_; |
| 3732 | __first = __parse_ecma_exp(++__temp, __last); | 3737 | __first = __parse_ecma_exp(++__temp, __last); |
| 3733 | if (__first == __last || *__first != ')') | 3738 | if (__first == __last || *__first != ')') |
| 3734 | __throw_regex_error<regex_constants::error_paren>(); | 3739 | std::__throw_regex_error<regex_constants::error_paren>(); |
| 3735 | --__open_count_; | 3740 | --__open_count_; |
| 3736 | ++__first; | 3741 | ++__first; |
| 3737 | } else { | 3742 | } else { |
| ... | @@ -3740,7 +3745,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f | ... | @@ -3740,7 +3745,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f |
| 3740 | ++__open_count_; | 3745 | ++__open_count_; |
| 3741 | __first = __parse_ecma_exp(__first, __last); | 3746 | __first = __parse_ecma_exp(__first, __last); |
| 3742 | if (__first == __last || *__first != ')') | 3747 | if (__first == __last || *__first != ')') |
| 3743 | __throw_regex_error<regex_constants::error_paren>(); | 3748 | std::__throw_regex_error<regex_constants::error_paren>(); |
| 3744 | __push_end_marked_subexpression(__temp_count); | 3749 | __push_end_marked_subexpression(__temp_count); |
| 3745 | --__open_count_; | 3750 | --__open_count_; |
| 3746 | ++__first; | 3751 | ++__first; |
| ... | @@ -3750,7 +3755,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f | ... | @@ -3750,7 +3755,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f |
| 3750 | case '+': | 3755 | case '+': |
| 3751 | case '?': | 3756 | case '?': |
| 3752 | case '{': | 3757 | case '{': |
| 3753 | __throw_regex_error<regex_constants::error_badrepeat>(); | 3758 | std::__throw_regex_error<regex_constants::error_badrepeat>(); |
| 3754 | break; | 3759 | break; |
| 3755 | default: | 3760 | default: |
| 3756 | __first = __parse_pattern_character(__first, __last); | 3761 | __first = __parse_pattern_character(__first, __last); |
| ... | @@ -3766,7 +3771,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardItera | ... | @@ -3766,7 +3771,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardItera |
| 3766 | if (__first != __last && *__first == '\\') { | 3771 | if (__first != __last && *__first == '\\') { |
| 3767 | _ForwardIterator __t1 = std::next(__first); | 3772 | _ForwardIterator __t1 = std::next(__first); |
| 3768 | if (__t1 == __last) | 3773 | if (__t1 == __last) |
| 3769 | __throw_regex_error<regex_constants::error_escape>(); | 3774 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3770 | 3775 | ||
| 3771 | _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last); | 3776 | _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last); |
| 3772 | if (__t2 != __t1) | 3777 | if (__t2 != __t1) |
| ... | @@ -3797,11 +3802,11 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, _ | ... | @@ -3797,11 +3802,11 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, _ |
| 3797 | unsigned __v = *__first - '0'; | 3802 | unsigned __v = *__first - '0'; |
| 3798 | for (++__first; __first != __last && '0' <= *__first && *__first <= '9'; ++__first) { | 3803 | for (++__first; __first != __last && '0' <= *__first && *__first <= '9'; ++__first) { |
| 3799 | if (__v >= numeric_limits<unsigned>::max() / 10) | 3804 | if (__v >= numeric_limits<unsigned>::max() / 10) |
| 3800 | __throw_regex_error<regex_constants::error_backref>(); | 3805 | std::__throw_regex_error<regex_constants::error_backref>(); |
| 3801 | __v = 10 * __v + *__first - '0'; | 3806 | __v = 10 * __v + *__first - '0'; |
| 3802 | } | 3807 | } |
| 3803 | if (__v == 0 || __v > mark_count()) | 3808 | if (__v == 0 || __v > mark_count()) |
| 3804 | __throw_regex_error<regex_constants::error_backref>(); | 3809 | std::__throw_regex_error<regex_constants::error_backref>(); |
| 3805 | __push_back_ref(__v); | 3810 | __push_back_ref(__v); |
| 3806 | } | 3811 | } |
| 3807 | } | 3812 | } |
| ... | @@ -3905,40 +3910,40 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape( | ... | @@ -3905,40 +3910,40 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape( |
| 3905 | __push_char(_CharT(*__t % 32)); | 3910 | __push_char(_CharT(*__t % 32)); |
| 3906 | __first = ++__t; | 3911 | __first = ++__t; |
| 3907 | } else | 3912 | } else |
| 3908 | __throw_regex_error<regex_constants::error_escape>(); | 3913 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3909 | } else | 3914 | } else |
| 3910 | __throw_regex_error<regex_constants::error_escape>(); | 3915 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3911 | break; | 3916 | break; |
| 3912 | case 'u': | 3917 | case 'u': |
| 3913 | ++__first; | 3918 | ++__first; |
| 3914 | if (__first == __last) | 3919 | if (__first == __last) |
| 3915 | __throw_regex_error<regex_constants::error_escape>(); | 3920 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3916 | __hd = __traits_.value(*__first, 16); | 3921 | __hd = __traits_.value(*__first, 16); |
| 3917 | if (__hd == -1) | 3922 | if (__hd == -1) |
| 3918 | __throw_regex_error<regex_constants::error_escape>(); | 3923 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3919 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 3924 | __sum = 16 * __sum + static_cast<unsigned>(__hd); |
| 3920 | ++__first; | 3925 | ++__first; |
| 3921 | if (__first == __last) | 3926 | if (__first == __last) |
| 3922 | __throw_regex_error<regex_constants::error_escape>(); | 3927 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3923 | __hd = __traits_.value(*__first, 16); | 3928 | __hd = __traits_.value(*__first, 16); |
| 3924 | if (__hd == -1) | 3929 | if (__hd == -1) |
| 3925 | __throw_regex_error<regex_constants::error_escape>(); | 3930 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3926 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 3931 | __sum = 16 * __sum + static_cast<unsigned>(__hd); |
| 3927 | _LIBCPP_FALLTHROUGH(); | 3932 | [[__fallthrough__]]; |
| 3928 | case 'x': | 3933 | case 'x': |
| 3929 | ++__first; | 3934 | ++__first; |
| 3930 | if (__first == __last) | 3935 | if (__first == __last) |
| 3931 | __throw_regex_error<regex_constants::error_escape>(); | 3936 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3932 | __hd = __traits_.value(*__first, 16); | 3937 | __hd = __traits_.value(*__first, 16); |
| 3933 | if (__hd == -1) | 3938 | if (__hd == -1) |
| 3934 | __throw_regex_error<regex_constants::error_escape>(); | 3939 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3935 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 3940 | __sum = 16 * __sum + static_cast<unsigned>(__hd); |
| 3936 | ++__first; | 3941 | ++__first; |
| 3937 | if (__first == __last) | 3942 | if (__first == __last) |
| 3938 | __throw_regex_error<regex_constants::error_escape>(); | 3943 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3939 | __hd = __traits_.value(*__first, 16); | 3944 | __hd = __traits_.value(*__first, 16); |
| 3940 | if (__hd == -1) | 3945 | if (__hd == -1) |
| 3941 | __throw_regex_error<regex_constants::error_escape>(); | 3946 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3942 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 3947 | __sum = 16 * __sum + static_cast<unsigned>(__hd); |
| 3943 | if (__str) | 3948 | if (__str) |
| 3944 | *__str = _CharT(__sum); | 3949 | *__str = _CharT(__sum); |
| ... | @@ -3954,14 +3959,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape( | ... | @@ -3954,14 +3959,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape( |
| 3954 | ++__first; | 3959 | ++__first; |
| 3955 | break; | 3960 | break; |
| 3956 | default: | 3961 | default: |
| 3957 | if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) { | 3962 | if (!__traits_.isctype(*__first, ctype_base::alnum)) { |
| 3958 | if (__str) | 3963 | if (__str) |
| 3959 | *__str = *__first; | 3964 | *__str = *__first; |
| 3960 | else | 3965 | else |
| 3961 | __push_char(*__first); | 3966 | __push_char(*__first); |
| 3962 | ++__first; | 3967 | ++__first; |
| 3963 | } else | 3968 | } else |
| 3964 | __throw_regex_error<regex_constants::error_escape>(); | 3969 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 3965 | break; | 3970 | break; |
| 3966 | } | 3971 | } |
| 3967 | } | 3972 | } |
| ... | @@ -4057,7 +4062,7 @@ bool basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c) { | ... | @@ -4057,7 +4062,7 @@ bool basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c) { |
| 4057 | unsigned __val = __traits_.value(__c, 10); | 4062 | unsigned __val = __traits_.value(__c, 10); |
| 4058 | if (__val >= 1 && __val <= 9) { | 4063 | if (__val >= 1 && __val <= 9) { |
| 4059 | if (__val > mark_count()) | 4064 | if (__val > mark_count()) |
| 4060 | __throw_regex_error<regex_constants::error_backref>(); | 4065 | std::__throw_regex_error<regex_constants::error_backref>(); |
| 4061 | __push_back_ref(__val); | 4066 | __push_back_ref(__val); |
| 4062 | return true; | 4067 | return true; |
| 4063 | } | 4068 | } |
| ... | @@ -4184,15 +4189,14 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo | ... | @@ -4184,15 +4189,14 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo |
| 4184 | 4189 | ||
| 4185 | typedef sub_match<const char*> csub_match; | 4190 | typedef sub_match<const char*> csub_match; |
| 4186 | typedef sub_match<string::const_iterator> ssub_match; | 4191 | typedef sub_match<string::const_iterator> ssub_match; |
| 4187 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 4192 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 4188 | typedef sub_match<const wchar_t*> wcsub_match; | 4193 | typedef sub_match<const wchar_t*> wcsub_match; |
| 4189 | typedef sub_match<wstring::const_iterator> wssub_match; | 4194 | typedef sub_match<wstring::const_iterator> wssub_match; |
| 4190 | # endif | 4195 | # endif |
| 4191 | 4196 | ||
| 4192 | template <class _BidirectionalIterator> | 4197 | template <class _BidirectionalIterator> |
| 4193 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(csub_match) | 4198 | class _LIBCPP_PREFERRED_NAME(csub_match) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcsub_match)) |
| 4194 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcsub_match)) _LIBCPP_PREFERRED_NAME(ssub_match) | 4199 | _LIBCPP_PREFERRED_NAME(ssub_match) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wssub_match)) sub_match |
| 4195 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wssub_match)) sub_match | ||
| 4196 | : public pair<_BidirectionalIterator, _BidirectionalIterator> { | 4200 | : public pair<_BidirectionalIterator, _BidirectionalIterator> { |
| 4197 | public: | 4201 | public: |
| 4198 | typedef _BidirectionalIterator iterator; | 4202 | typedef _BidirectionalIterator iterator; |
| ... | @@ -4227,7 +4231,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons | ... | @@ -4227,7 +4231,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons |
| 4227 | return __x.compare(__y) == 0; | 4231 | return __x.compare(__y) == 0; |
| 4228 | } | 4232 | } |
| 4229 | 4233 | ||
| 4230 | # if _LIBCPP_STD_VER >= 20 | 4234 | # if _LIBCPP_STD_VER >= 20 |
| 4231 | template <class _BiIter> | 4235 | template <class _BiIter> |
| 4232 | using __sub_match_cat _LIBCPP_NODEBUG = | 4236 | using __sub_match_cat _LIBCPP_NODEBUG = |
| 4233 | compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>; | 4237 | compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>; |
| ... | @@ -4236,7 +4240,7 @@ template <class _BiIter> | ... | @@ -4236,7 +4240,7 @@ template <class _BiIter> |
| 4236 | _LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { | 4240 | _LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { |
| 4237 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); | 4241 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); |
| 4238 | } | 4242 | } |
| 4239 | # else // _LIBCPP_STD_VER >= 20 | 4243 | # else // _LIBCPP_STD_VER >= 20 |
| 4240 | template <class _BiIter> | 4244 | template <class _BiIter> |
| 4241 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { | 4245 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { |
| 4242 | return !(__x == __y); | 4246 | return !(__x == __y); |
| ... | @@ -4303,7 +4307,7 @@ operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST | ... | @@ -4303,7 +4307,7 @@ operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST |
| 4303 | const sub_match<_BiIter>& __y) { | 4307 | const sub_match<_BiIter>& __y) { |
| 4304 | return !(__y < __x); | 4308 | return !(__y < __x); |
| 4305 | } | 4309 | } |
| 4306 | # endif // _LIBCPP_STD_VER >= 20 | 4310 | # endif // _LIBCPP_STD_VER >= 20 |
| 4307 | 4311 | ||
| 4308 | template <class _BiIter, class _ST, class _SA> | 4312 | template <class _BiIter, class _ST, class _SA> |
| 4309 | inline _LIBCPP_HIDE_FROM_ABI bool | 4313 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | @@ -4312,7 +4316,7 @@ operator==(const sub_match<_BiIter>& __x, | ... | @@ -4312,7 +4316,7 @@ operator==(const sub_match<_BiIter>& __x, |
| 4312 | return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0; | 4316 | return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0; |
| 4313 | } | 4317 | } |
| 4314 | 4318 | ||
| 4315 | # if _LIBCPP_STD_VER >= 20 | 4319 | # if _LIBCPP_STD_VER >= 20 |
| 4316 | template <class _BiIter, class _ST, class _SA> | 4320 | template <class _BiIter, class _ST, class _SA> |
| 4317 | _LIBCPP_HIDE_FROM_ABI auto | 4321 | _LIBCPP_HIDE_FROM_ABI auto |
| 4318 | operator<=>(const sub_match<_BiIter>& __x, | 4322 | operator<=>(const sub_match<_BiIter>& __x, |
| ... | @@ -4320,7 +4324,7 @@ operator<=>(const sub_match<_BiIter>& __x, | ... | @@ -4320,7 +4324,7 @@ operator<=>(const sub_match<_BiIter>& __x, |
| 4320 | return static_cast<__sub_match_cat<_BiIter>>( | 4324 | return static_cast<__sub_match_cat<_BiIter>>( |
| 4321 | __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0); | 4325 | __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0); |
| 4322 | } | 4326 | } |
| 4323 | # else // _LIBCPP_STD_VER >= 20 | 4327 | # else // _LIBCPP_STD_VER >= 20 |
| 4324 | template <class _BiIter, class _ST, class _SA> | 4328 | template <class _BiIter, class _ST, class _SA> |
| 4325 | inline _LIBCPP_HIDE_FROM_ABI bool | 4329 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 4326 | operator!=(const sub_match<_BiIter>& __x, | 4330 | operator!=(const sub_match<_BiIter>& __x, |
| ... | @@ -4391,7 +4395,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool | ... | @@ -4391,7 +4395,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool |
| 4391 | operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) { | 4395 | operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) { |
| 4392 | return !(__y < __x); | 4396 | return !(__y < __x); |
| 4393 | } | 4397 | } |
| 4394 | # endif // _LIBCPP_STD_VER >= 20 | 4398 | # endif // _LIBCPP_STD_VER >= 20 |
| 4395 | 4399 | ||
| 4396 | template <class _BiIter> | 4400 | template <class _BiIter> |
| 4397 | inline _LIBCPP_HIDE_FROM_ABI bool | 4401 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | @@ -4399,13 +4403,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val | ... | @@ -4399,13 +4403,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val |
| 4399 | return __x.compare(__y) == 0; | 4403 | return __x.compare(__y) == 0; |
| 4400 | } | 4404 | } |
| 4401 | 4405 | ||
| 4402 | # if _LIBCPP_STD_VER >= 20 | 4406 | # if _LIBCPP_STD_VER >= 20 |
| 4403 | template <class _BiIter> | 4407 | template <class _BiIter> |
| 4404 | _LIBCPP_HIDE_FROM_ABI auto | 4408 | _LIBCPP_HIDE_FROM_ABI auto |
| 4405 | operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { | 4409 | operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { |
| 4406 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); | 4410 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); |
| 4407 | } | 4411 | } |
| 4408 | # else // _LIBCPP_STD_VER >= 20 | 4412 | # else // _LIBCPP_STD_VER >= 20 |
| 4409 | template <class _BiIter> | 4413 | template <class _BiIter> |
| 4410 | inline _LIBCPP_HIDE_FROM_ABI bool | 4414 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 4411 | operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { | 4415 | operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { |
| ... | @@ -4473,7 +4477,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool | ... | @@ -4473,7 +4477,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool |
| 4473 | operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) { | 4477 | operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) { |
| 4474 | return !(__y < __x); | 4478 | return !(__y < __x); |
| 4475 | } | 4479 | } |
| 4476 | # endif // _LIBCPP_STD_VER >= 20 | 4480 | # endif // _LIBCPP_STD_VER >= 20 |
| 4477 | 4481 | ||
| 4478 | template <class _BiIter> | 4482 | template <class _BiIter> |
| 4479 | inline _LIBCPP_HIDE_FROM_ABI bool | 4483 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | @@ -4482,14 +4486,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val | ... | @@ -4482,14 +4486,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val |
| 4482 | return __x.compare(string_type(1, __y)) == 0; | 4486 | return __x.compare(string_type(1, __y)) == 0; |
| 4483 | } | 4487 | } |
| 4484 | 4488 | ||
| 4485 | # if _LIBCPP_STD_VER >= 20 | 4489 | # if _LIBCPP_STD_VER >= 20 |
| 4486 | template <class _BiIter> | 4490 | template <class _BiIter> |
| 4487 | _LIBCPP_HIDE_FROM_ABI auto | 4491 | _LIBCPP_HIDE_FROM_ABI auto |
| 4488 | operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { | 4492 | operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { |
| 4489 | using string_type = basic_string<typename iterator_traits<_BiIter>::value_type>; | 4493 | using string_type = basic_string<typename iterator_traits<_BiIter>::value_type>; |
| 4490 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0); | 4494 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0); |
| 4491 | } | 4495 | } |
| 4492 | # else // _LIBCPP_STD_VER >= 20 | 4496 | # else // _LIBCPP_STD_VER >= 20 |
| 4493 | template <class _BiIter> | 4497 | template <class _BiIter> |
| 4494 | inline _LIBCPP_HIDE_FROM_ABI bool | 4498 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 4495 | operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { | 4499 | operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { |
| ... | @@ -4520,7 +4524,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool | ... | @@ -4520,7 +4524,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool |
| 4520 | operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { | 4524 | operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { |
| 4521 | return !(__y < __x); | 4525 | return !(__y < __x); |
| 4522 | } | 4526 | } |
| 4523 | # endif // _LIBCPP_STD_VER >= 20 | 4527 | # endif // _LIBCPP_STD_VER >= 20 |
| 4524 | 4528 | ||
| 4525 | template <class _CharT, class _ST, class _BiIter> | 4529 | template <class _CharT, class _ST, class _BiIter> |
| 4526 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>& | 4530 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>& |
| ... | @@ -4530,13 +4534,13 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) { | ... | @@ -4530,13 +4534,13 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) { |
| 4530 | 4534 | ||
| 4531 | typedef match_results<const char*> cmatch; | 4535 | typedef match_results<const char*> cmatch; |
| 4532 | typedef match_results<string::const_iterator> smatch; | 4536 | typedef match_results<string::const_iterator> smatch; |
| 4533 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 4537 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 4534 | typedef match_results<const wchar_t*> wcmatch; | 4538 | typedef match_results<const wchar_t*> wcmatch; |
| 4535 | typedef match_results<wstring::const_iterator> wsmatch; | 4539 | typedef match_results<wstring::const_iterator> wsmatch; |
| 4536 | # endif | 4540 | # endif |
| 4537 | 4541 | ||
| 4538 | template <class _BidirectionalIterator, class _Allocator> | 4542 | template <class _BidirectionalIterator, class _Allocator> |
| 4539 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch)) | 4543 | class _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch)) |
| 4540 | _LIBCPP_PREFERRED_NAME(smatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsmatch)) match_results { | 4544 | _LIBCPP_PREFERRED_NAME(smatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsmatch)) match_results { |
| 4541 | public: | 4545 | public: |
| 4542 | typedef _Allocator allocator_type; | 4546 | typedef _Allocator allocator_type; |
| ... | @@ -4563,12 +4567,12 @@ public: | ... | @@ -4563,12 +4567,12 @@ public: |
| 4563 | typedef basic_string<char_type> string_type; | 4567 | typedef basic_string<char_type> string_type; |
| 4564 | 4568 | ||
| 4565 | // construct/copy/destroy: | 4569 | // construct/copy/destroy: |
| 4566 | # ifndef _LIBCPP_CXX03_LANG | 4570 | # ifndef _LIBCPP_CXX03_LANG |
| 4567 | match_results() : match_results(allocator_type()) {} | 4571 | match_results() : match_results(allocator_type()) {} |
| 4568 | explicit match_results(const allocator_type& __a); | 4572 | explicit match_results(const allocator_type& __a); |
| 4569 | # else | 4573 | # else |
| 4570 | explicit match_results(const allocator_type& __a = allocator_type()); | 4574 | explicit match_results(const allocator_type& __a = allocator_type()); |
| 4571 | # endif | 4575 | # endif |
| 4572 | 4576 | ||
| 4573 | // match_results(const match_results&) = default; | 4577 | // match_results(const match_results&) = default; |
| 4574 | // match_results& operator=(const match_results&) = default; | 4578 | // match_results& operator=(const match_results&) = default; |
| ... | @@ -4778,7 +4782,7 @@ _OutputIter match_results<_BidirectionalIterator, _Allocator>::format( | ... | @@ -4778,7 +4782,7 @@ _OutputIter match_results<_BidirectionalIterator, _Allocator>::format( |
| 4778 | if (__fmt_first + 1 != __fmt_last && '0' <= __fmt_first[1] && __fmt_first[1] <= '9') { | 4782 | if (__fmt_first + 1 != __fmt_last && '0' <= __fmt_first[1] && __fmt_first[1] <= '9') { |
| 4779 | ++__fmt_first; | 4783 | ++__fmt_first; |
| 4780 | if (__idx >= numeric_limits<size_t>::max() / 10) | 4784 | if (__idx >= numeric_limits<size_t>::max() / 10) |
| 4781 | __throw_regex_error<regex_constants::error_escape>(); | 4785 | std::__throw_regex_error<regex_constants::error_escape>(); |
| 4782 | __idx = 10 * __idx + *__fmt_first - '0'; | 4786 | __idx = 10 * __idx + *__fmt_first - '0'; |
| 4783 | } | 4787 | } |
| 4784 | __output_iter = std::copy((*this)[__idx].first, (*this)[__idx].second, __output_iter); | 4788 | __output_iter = std::copy((*this)[__idx].first, (*this)[__idx].second, __output_iter); |
| ... | @@ -4818,13 +4822,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator | ... | @@ -4818,13 +4822,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator |
| 4818 | return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_; | 4822 | return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_; |
| 4819 | } | 4823 | } |
| 4820 | 4824 | ||
| 4821 | # if _LIBCPP_STD_VER < 20 | 4825 | # if _LIBCPP_STD_VER < 20 |
| 4822 | template <class _BidirectionalIterator, class _Allocator> | 4826 | template <class _BidirectionalIterator, class _Allocator> |
| 4823 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x, | 4827 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x, |
| 4824 | const match_results<_BidirectionalIterator, _Allocator>& __y) { | 4828 | const match_results<_BidirectionalIterator, _Allocator>& __y) { |
| 4825 | return !(__x == __y); | 4829 | return !(__x == __y); |
| 4826 | } | 4830 | } |
| 4827 | # endif | 4831 | # endif |
| 4828 | 4832 | ||
| 4829 | template <class _BidirectionalIterator, class _Allocator> | 4833 | template <class _BidirectionalIterator, class _Allocator> |
| 4830 | inline _LIBCPP_HIDE_FROM_ABI void | 4834 | inline _LIBCPP_HIDE_FROM_ABI void |
| ... | @@ -4865,7 +4869,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma( | ... | @@ -4865,7 +4869,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma( |
| 4865 | do { | 4869 | do { |
| 4866 | ++__counter; | 4870 | ++__counter; |
| 4867 | if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) | 4871 | if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) |
| 4868 | __throw_regex_error<regex_constants::error_complexity>(); | 4872 | std::__throw_regex_error<regex_constants::error_complexity>(); |
| 4869 | __state& __s = __states.back(); | 4873 | __state& __s = __states.back(); |
| 4870 | if (__s.__node_) | 4874 | if (__s.__node_) |
| 4871 | __s.__node_->__exec(__s); | 4875 | __s.__node_->__exec(__s); |
| ... | @@ -4899,7 +4903,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma( | ... | @@ -4899,7 +4903,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma( |
| 4899 | __states.pop_back(); | 4903 | __states.pop_back(); |
| 4900 | break; | 4904 | break; |
| 4901 | default: | 4905 | default: |
| 4902 | __throw_regex_error<regex_constants::__re_err_unknown>(); | 4906 | std::__throw_regex_error<regex_constants::__re_err_unknown>(); |
| 4903 | break; | 4907 | break; |
| 4904 | } | 4908 | } |
| 4905 | } while (!__states.empty()); | 4909 | } while (!__states.empty()); |
| ... | @@ -4935,7 +4939,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( | ... | @@ -4935,7 +4939,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( |
| 4935 | do { | 4939 | do { |
| 4936 | ++__counter; | 4940 | ++__counter; |
| 4937 | if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) | 4941 | if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) |
| 4938 | __throw_regex_error<regex_constants::error_complexity>(); | 4942 | std::__throw_regex_error<regex_constants::error_complexity>(); |
| 4939 | __state& __s = __states.back(); | 4943 | __state& __s = __states.back(); |
| 4940 | if (__s.__node_) | 4944 | if (__s.__node_) |
| 4941 | __s.__node_->__exec(__s); | 4945 | __s.__node_->__exec(__s); |
| ... | @@ -4976,7 +4980,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( | ... | @@ -4976,7 +4980,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( |
| 4976 | __states.pop_back(); | 4980 | __states.pop_back(); |
| 4977 | break; | 4981 | break; |
| 4978 | default: | 4982 | default: |
| 4979 | __throw_regex_error<regex_constants::__re_err_unknown>(); | 4983 | std::__throw_regex_error<regex_constants::__re_err_unknown>(); |
| 4980 | break; | 4984 | break; |
| 4981 | } | 4985 | } |
| 4982 | } while (!__states.empty()); | 4986 | } while (!__states.empty()); |
| ... | @@ -5025,7 +5029,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( | ... | @@ -5025,7 +5029,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( |
| 5025 | do { | 5029 | do { |
| 5026 | ++__counter; | 5030 | ++__counter; |
| 5027 | if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) | 5031 | if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) |
| 5028 | __throw_regex_error<regex_constants::error_complexity>(); | 5032 | std::__throw_regex_error<regex_constants::error_complexity>(); |
| 5029 | __state& __s = __states.back(); | 5033 | __state& __s = __states.back(); |
| 5030 | if (__s.__node_) | 5034 | if (__s.__node_) |
| 5031 | __s.__node_->__exec(__s); | 5035 | __s.__node_->__exec(__s); |
| ... | @@ -5063,7 +5067,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( | ... | @@ -5063,7 +5067,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( |
| 5063 | __states.pop_back(); | 5067 | __states.pop_back(); |
| 5064 | break; | 5068 | break; |
| 5065 | default: | 5069 | default: |
| 5066 | __throw_regex_error<regex_constants::__re_err_unknown>(); | 5070 | std::__throw_regex_error<regex_constants::__re_err_unknown>(); |
| 5067 | break; | 5071 | break; |
| 5068 | } | 5072 | } |
| 5069 | } while (!__states.empty()); | 5073 | } while (!__states.empty()); |
| ... | @@ -5236,13 +5240,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s, | ... | @@ -5236,13 +5240,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s, |
| 5236 | return __r; | 5240 | return __r; |
| 5237 | } | 5241 | } |
| 5238 | 5242 | ||
| 5239 | # if _LIBCPP_STD_VER >= 14 | 5243 | # if _LIBCPP_STD_VER >= 14 |
| 5240 | template <class _ST, class _SA, class _Ap, class _Cp, class _Tp> | 5244 | template <class _ST, class _SA, class _Ap, class _Cp, class _Tp> |
| 5241 | bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s, | 5245 | bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s, |
| 5242 | match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&, | 5246 | match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&, |
| 5243 | const basic_regex<_Cp, _Tp>& __e, | 5247 | const basic_regex<_Cp, _Tp>& __e, |
| 5244 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; | 5248 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; |
| 5245 | # endif | 5249 | # endif |
| 5246 | 5250 | ||
| 5247 | // regex_match | 5251 | // regex_match |
| 5248 | 5252 | ||
| ... | @@ -5291,14 +5295,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, | ... | @@ -5291,14 +5295,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, |
| 5291 | return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags); | 5295 | return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags); |
| 5292 | } | 5296 | } |
| 5293 | 5297 | ||
| 5294 | # if _LIBCPP_STD_VER >= 14 | 5298 | # if _LIBCPP_STD_VER >= 14 |
| 5295 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> | 5299 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> |
| 5296 | inline _LIBCPP_HIDE_FROM_ABI bool | 5300 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 5297 | regex_match(const basic_string<_CharT, _ST, _SA>&& __s, | 5301 | regex_match(const basic_string<_CharT, _ST, _SA>&& __s, |
| 5298 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, | 5302 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, |
| 5299 | const basic_regex<_CharT, _Traits>& __e, | 5303 | const basic_regex<_CharT, _Traits>& __e, |
| 5300 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; | 5304 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; |
| 5301 | # endif | 5305 | # endif |
| 5302 | 5306 | ||
| 5303 | template <class _CharT, class _Traits> | 5307 | template <class _CharT, class _Traits> |
| 5304 | inline _LIBCPP_HIDE_FROM_ABI bool | 5308 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | @@ -5321,18 +5325,18 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, | ... | @@ -5321,18 +5325,18 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, |
| 5321 | template <class _BidirectionalIterator, | 5325 | template <class _BidirectionalIterator, |
| 5322 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, | 5326 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, |
| 5323 | class _Traits = regex_traits<_CharT> > | 5327 | class _Traits = regex_traits<_CharT> > |
| 5324 | class _LIBCPP_TEMPLATE_VIS regex_iterator; | 5328 | class regex_iterator; |
| 5325 | 5329 | ||
| 5326 | typedef regex_iterator<const char*> cregex_iterator; | 5330 | typedef regex_iterator<const char*> cregex_iterator; |
| 5327 | typedef regex_iterator<string::const_iterator> sregex_iterator; | 5331 | typedef regex_iterator<string::const_iterator> sregex_iterator; |
| 5328 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 5332 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 5329 | typedef regex_iterator<const wchar_t*> wcregex_iterator; | 5333 | typedef regex_iterator<const wchar_t*> wcregex_iterator; |
| 5330 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; | 5334 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; |
| 5331 | # endif | 5335 | # endif |
| 5332 | 5336 | ||
| 5333 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 5337 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5334 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_iterator) | 5338 | class _LIBCPP_PREFERRED_NAME(cregex_iterator) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator)) |
| 5335 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator)) _LIBCPP_PREFERRED_NAME(sregex_iterator) | 5339 | _LIBCPP_PREFERRED_NAME(sregex_iterator) |
| 5336 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) regex_iterator { | 5340 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) regex_iterator { |
| 5337 | public: | 5341 | public: |
| 5338 | typedef basic_regex<_CharT, _Traits> regex_type; | 5342 | typedef basic_regex<_CharT, _Traits> regex_type; |
| ... | @@ -5341,9 +5345,9 @@ public: | ... | @@ -5341,9 +5345,9 @@ public: |
| 5341 | typedef const value_type* pointer; | 5345 | typedef const value_type* pointer; |
| 5342 | typedef const value_type& reference; | 5346 | typedef const value_type& reference; |
| 5343 | typedef forward_iterator_tag iterator_category; | 5347 | typedef forward_iterator_tag iterator_category; |
| 5344 | # if _LIBCPP_STD_VER >= 20 | 5348 | # if _LIBCPP_STD_VER >= 20 |
| 5345 | typedef input_iterator_tag iterator_concept; | 5349 | typedef input_iterator_tag iterator_concept; |
| 5346 | # endif | 5350 | # endif |
| 5347 | 5351 | ||
| 5348 | private: | 5352 | private: |
| 5349 | _BidirectionalIterator __begin_; | 5353 | _BidirectionalIterator __begin_; |
| ... | @@ -5358,20 +5362,20 @@ public: | ... | @@ -5358,20 +5362,20 @@ public: |
| 5358 | _BidirectionalIterator __b, | 5362 | _BidirectionalIterator __b, |
| 5359 | const regex_type& __re, | 5363 | const regex_type& __re, |
| 5360 | regex_constants::match_flag_type __m = regex_constants::match_default); | 5364 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5361 | # if _LIBCPP_STD_VER >= 14 | 5365 | # if _LIBCPP_STD_VER >= 14 |
| 5362 | regex_iterator(_BidirectionalIterator __a, | 5366 | regex_iterator(_BidirectionalIterator __a, |
| 5363 | _BidirectionalIterator __b, | 5367 | _BidirectionalIterator __b, |
| 5364 | const regex_type&& __re, | 5368 | const regex_type&& __re, |
| 5365 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; | 5369 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5366 | # endif | 5370 | # endif |
| 5367 | 5371 | ||
| 5368 | _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const; | 5372 | _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const; |
| 5369 | # if _LIBCPP_STD_VER >= 20 | 5373 | # if _LIBCPP_STD_VER >= 20 |
| 5370 | _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); } | 5374 | _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); } |
| 5371 | # endif | 5375 | # endif |
| 5372 | # if _LIBCPP_STD_VER < 20 | 5376 | # if _LIBCPP_STD_VER < 20 |
| 5373 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); } | 5377 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); } |
| 5374 | # endif | 5378 | # endif |
| 5375 | 5379 | ||
| 5376 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; } | 5380 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; } |
| 5377 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); } | 5381 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); } |
| ... | @@ -5451,17 +5455,17 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { | ... | @@ -5451,17 +5455,17 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { |
| 5451 | template <class _BidirectionalIterator, | 5455 | template <class _BidirectionalIterator, |
| 5452 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, | 5456 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, |
| 5453 | class _Traits = regex_traits<_CharT> > | 5457 | class _Traits = regex_traits<_CharT> > |
| 5454 | class _LIBCPP_TEMPLATE_VIS regex_token_iterator; | 5458 | class regex_token_iterator; |
| 5455 | 5459 | ||
| 5456 | typedef regex_token_iterator<const char*> cregex_token_iterator; | 5460 | typedef regex_token_iterator<const char*> cregex_token_iterator; |
| 5457 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; | 5461 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; |
| 5458 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 5462 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 5459 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; | 5463 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; |
| 5460 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | 5464 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 5461 | # endif | 5465 | # endif |
| 5462 | 5466 | ||
| 5463 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 5467 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5464 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_token_iterator) | 5468 | class _LIBCPP_PREFERRED_NAME(cregex_token_iterator) |
| 5465 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_token_iterator)) | 5469 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_token_iterator)) |
| 5466 | _LIBCPP_PREFERRED_NAME(sregex_token_iterator) | 5470 | _LIBCPP_PREFERRED_NAME(sregex_token_iterator) |
| 5467 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_token_iterator)) regex_token_iterator { | 5471 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_token_iterator)) regex_token_iterator { |
| ... | @@ -5472,9 +5476,9 @@ public: | ... | @@ -5472,9 +5476,9 @@ public: |
| 5472 | typedef const value_type* pointer; | 5476 | typedef const value_type* pointer; |
| 5473 | typedef const value_type& reference; | 5477 | typedef const value_type& reference; |
| 5474 | typedef forward_iterator_tag iterator_category; | 5478 | typedef forward_iterator_tag iterator_category; |
| 5475 | # if _LIBCPP_STD_VER >= 20 | 5479 | # if _LIBCPP_STD_VER >= 20 |
| 5476 | typedef input_iterator_tag iterator_concept; | 5480 | typedef input_iterator_tag iterator_concept; |
| 5477 | # endif | 5481 | # endif |
| 5478 | 5482 | ||
| 5479 | private: | 5483 | private: |
| 5480 | typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position; | 5484 | typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position; |
| ... | @@ -5492,67 +5496,67 @@ public: | ... | @@ -5492,67 +5496,67 @@ public: |
| 5492 | const regex_type& __re, | 5496 | const regex_type& __re, |
| 5493 | int __submatch = 0, | 5497 | int __submatch = 0, |
| 5494 | regex_constants::match_flag_type __m = regex_constants::match_default); | 5498 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5495 | # if _LIBCPP_STD_VER >= 14 | 5499 | # if _LIBCPP_STD_VER >= 14 |
| 5496 | regex_token_iterator(_BidirectionalIterator __a, | 5500 | regex_token_iterator(_BidirectionalIterator __a, |
| 5497 | _BidirectionalIterator __b, | 5501 | _BidirectionalIterator __b, |
| 5498 | const regex_type&& __re, | 5502 | const regex_type&& __re, |
| 5499 | int __submatch = 0, | 5503 | int __submatch = 0, |
| 5500 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; | 5504 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5501 | # endif | 5505 | # endif |
| 5502 | 5506 | ||
| 5503 | regex_token_iterator(_BidirectionalIterator __a, | 5507 | regex_token_iterator(_BidirectionalIterator __a, |
| 5504 | _BidirectionalIterator __b, | 5508 | _BidirectionalIterator __b, |
| 5505 | const regex_type& __re, | 5509 | const regex_type& __re, |
| 5506 | const vector<int>& __submatches, | 5510 | const vector<int>& __submatches, |
| 5507 | regex_constants::match_flag_type __m = regex_constants::match_default); | 5511 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5508 | # if _LIBCPP_STD_VER >= 14 | 5512 | # if _LIBCPP_STD_VER >= 14 |
| 5509 | regex_token_iterator(_BidirectionalIterator __a, | 5513 | regex_token_iterator(_BidirectionalIterator __a, |
| 5510 | _BidirectionalIterator __b, | 5514 | _BidirectionalIterator __b, |
| 5511 | const regex_type&& __re, | 5515 | const regex_type&& __re, |
| 5512 | const vector<int>& __submatches, | 5516 | const vector<int>& __submatches, |
| 5513 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; | 5517 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5514 | # endif | 5518 | # endif |
| 5515 | 5519 | ||
| 5516 | # ifndef _LIBCPP_CXX03_LANG | 5520 | # ifndef _LIBCPP_CXX03_LANG |
| 5517 | regex_token_iterator(_BidirectionalIterator __a, | 5521 | regex_token_iterator(_BidirectionalIterator __a, |
| 5518 | _BidirectionalIterator __b, | 5522 | _BidirectionalIterator __b, |
| 5519 | const regex_type& __re, | 5523 | const regex_type& __re, |
| 5520 | initializer_list<int> __submatches, | 5524 | initializer_list<int> __submatches, |
| 5521 | regex_constants::match_flag_type __m = regex_constants::match_default); | 5525 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5522 | 5526 | ||
| 5523 | # if _LIBCPP_STD_VER >= 14 | 5527 | # if _LIBCPP_STD_VER >= 14 |
| 5524 | regex_token_iterator(_BidirectionalIterator __a, | 5528 | regex_token_iterator(_BidirectionalIterator __a, |
| 5525 | _BidirectionalIterator __b, | 5529 | _BidirectionalIterator __b, |
| 5526 | const regex_type&& __re, | 5530 | const regex_type&& __re, |
| 5527 | initializer_list<int> __submatches, | 5531 | initializer_list<int> __submatches, |
| 5528 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; | 5532 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5529 | # endif | 5533 | # endif |
| 5530 | # endif // _LIBCPP_CXX03_LANG | 5534 | # endif // _LIBCPP_CXX03_LANG |
| 5531 | template <size_t _Np> | 5535 | template <size_t _Np> |
| 5532 | regex_token_iterator(_BidirectionalIterator __a, | 5536 | regex_token_iterator(_BidirectionalIterator __a, |
| 5533 | _BidirectionalIterator __b, | 5537 | _BidirectionalIterator __b, |
| 5534 | const regex_type& __re, | 5538 | const regex_type& __re, |
| 5535 | const int (&__submatches)[_Np], | 5539 | const int (&__submatches)[_Np], |
| 5536 | regex_constants::match_flag_type __m = regex_constants::match_default); | 5540 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5537 | # if _LIBCPP_STD_VER >= 14 | 5541 | # if _LIBCPP_STD_VER >= 14 |
| 5538 | template <size_t _Np> | 5542 | template <size_t _Np> |
| 5539 | regex_token_iterator(_BidirectionalIterator __a, | 5543 | regex_token_iterator(_BidirectionalIterator __a, |
| 5540 | _BidirectionalIterator __b, | 5544 | _BidirectionalIterator __b, |
| 5541 | const regex_type&& __re, | 5545 | const regex_type&& __re, |
| 5542 | const int (&__submatches)[_Np], | 5546 | const int (&__submatches)[_Np], |
| 5543 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; | 5547 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5544 | # endif | 5548 | # endif |
| 5545 | 5549 | ||
| 5546 | regex_token_iterator(const regex_token_iterator&); | 5550 | regex_token_iterator(const regex_token_iterator&); |
| 5547 | regex_token_iterator& operator=(const regex_token_iterator&); | 5551 | regex_token_iterator& operator=(const regex_token_iterator&); |
| 5548 | 5552 | ||
| 5549 | _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const; | 5553 | _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const; |
| 5550 | # if _LIBCPP_STD_VER >= 20 | 5554 | # if _LIBCPP_STD_VER >= 20 |
| 5551 | _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); } | 5555 | _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); } |
| 5552 | # endif | 5556 | # endif |
| 5553 | # if _LIBCPP_STD_VER < 20 | 5557 | # if _LIBCPP_STD_VER < 20 |
| 5554 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); } | 5558 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); } |
| 5555 | # endif | 5559 | # endif |
| 5556 | 5560 | ||
| 5557 | _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; } | 5561 | _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; } |
| 5558 | _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; } | 5562 | _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; } |
| ... | @@ -5568,9 +5572,9 @@ private: | ... | @@ -5568,9 +5572,9 @@ private: |
| 5568 | void __init(_BidirectionalIterator __a, _BidirectionalIterator __b); | 5572 | void __init(_BidirectionalIterator __a, _BidirectionalIterator __b); |
| 5569 | void __establish_result() { | 5573 | void __establish_result() { |
| 5570 | if (__subs_[__n_] == -1) | 5574 | if (__subs_[__n_] == -1) |
| 5571 | __result_ = &__position_->prefix(); | 5575 | __result_ = std::addressof(__position_->prefix()); |
| 5572 | else | 5576 | else |
| 5573 | __result_ = &(*__position_)[__subs_[__n_]]; | 5577 | __result_ = std::addressof((*__position_)[__subs_[__n_]]); |
| 5574 | } | 5578 | } |
| 5575 | }; | 5579 | }; |
| 5576 | 5580 | ||
| ... | @@ -5587,7 +5591,7 @@ void regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::__init( | ... | @@ -5587,7 +5591,7 @@ void regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::__init( |
| 5587 | __suffix_.matched = true; | 5591 | __suffix_.matched = true; |
| 5588 | __suffix_.first = __a; | 5592 | __suffix_.first = __a; |
| 5589 | __suffix_.second = __b; | 5593 | __suffix_.second = __b; |
| 5590 | __result_ = &__suffix_; | 5594 | __result_ = std::addressof(__suffix_); |
| 5591 | } else | 5595 | } else |
| 5592 | __result_ = nullptr; | 5596 | __result_ = nullptr; |
| 5593 | } | 5597 | } |
| ... | @@ -5614,7 +5618,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera | ... | @@ -5614,7 +5618,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera |
| 5614 | __init(__a, __b); | 5618 | __init(__a, __b); |
| 5615 | } | 5619 | } |
| 5616 | 5620 | ||
| 5617 | # ifndef _LIBCPP_CXX03_LANG | 5621 | # ifndef _LIBCPP_CXX03_LANG |
| 5618 | 5622 | ||
| 5619 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 5623 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5620 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator( | 5624 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator( |
| ... | @@ -5627,7 +5631,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera | ... | @@ -5627,7 +5631,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera |
| 5627 | __init(__a, __b); | 5631 | __init(__a, __b); |
| 5628 | } | 5632 | } |
| 5629 | 5633 | ||
| 5630 | # endif // _LIBCPP_CXX03_LANG | 5634 | # endif // _LIBCPP_CXX03_LANG |
| 5631 | 5635 | ||
| 5632 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 5636 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5633 | template <size_t _Np> | 5637 | template <size_t _Np> |
| ... | @@ -5648,8 +5652,8 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera | ... | @@ -5648,8 +5652,8 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera |
| 5648 | __suffix_(__x.__suffix_), | 5652 | __suffix_(__x.__suffix_), |
| 5649 | __n_(__x.__n_), | 5653 | __n_(__x.__n_), |
| 5650 | __subs_(__x.__subs_) { | 5654 | __subs_(__x.__subs_) { |
| 5651 | if (__x.__result_ == &__x.__suffix_) | 5655 | if (__x.__result_ == std::addressof(__x.__suffix_)) |
| 5652 | __result_ = &__suffix_; | 5656 | __result_ = std::addressof(__suffix_); |
| 5653 | else if (__result_ != nullptr) | 5657 | else if (__result_ != nullptr) |
| 5654 | __establish_result(); | 5658 | __establish_result(); |
| 5655 | } | 5659 | } |
| ... | @@ -5657,17 +5661,17 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera | ... | @@ -5657,17 +5661,17 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera |
| 5657 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 5661 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5658 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& | 5662 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& |
| 5659 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator=(const regex_token_iterator& __x) { | 5663 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator=(const regex_token_iterator& __x) { |
| 5660 | if (this != &__x) { | 5664 | if (this != std::addressof(__x)) { |
| 5661 | __position_ = __x.__position_; | 5665 | __position_ = __x.__position_; |
| 5662 | if (__x.__result_ == &__x.__suffix_) | 5666 | if (__x.__result_ == std::addressof(__x.__suffix_)) |
| 5663 | __result_ = &__suffix_; | 5667 | __result_ = std::addressof(__suffix_); |
| 5664 | else | 5668 | else |
| 5665 | __result_ = __x.__result_; | 5669 | __result_ = __x.__result_; |
| 5666 | __suffix_ = __x.__suffix_; | 5670 | __suffix_ = __x.__suffix_; |
| 5667 | __n_ = __x.__n_; | 5671 | __n_ = __x.__n_; |
| 5668 | __subs_ = __x.__subs_; | 5672 | __subs_ = __x.__subs_; |
| 5669 | 5673 | ||
| 5670 | if (__result_ != nullptr && __result_ != &__suffix_) | 5674 | if (__result_ != nullptr && __result_ != std::addressof(__suffix_)) |
| 5671 | __establish_result(); | 5675 | __establish_result(); |
| 5672 | } | 5676 | } |
| 5673 | return *this; | 5677 | return *this; |
| ... | @@ -5677,11 +5681,12 @@ template <class _BidirectionalIterator, class _CharT, class _Traits> | ... | @@ -5677,11 +5681,12 @@ template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5677 | bool regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator==(const regex_token_iterator& __x) const { | 5681 | bool regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator==(const regex_token_iterator& __x) const { |
| 5678 | if (__result_ == nullptr && __x.__result_ == nullptr) | 5682 | if (__result_ == nullptr && __x.__result_ == nullptr) |
| 5679 | return true; | 5683 | return true; |
| 5680 | if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ && __suffix_ == __x.__suffix_) | 5684 | if (__result_ == std::addressof(__suffix_) && __x.__result_ == std::addressof(__x.__suffix_) && |
| 5685 | __suffix_ == __x.__suffix_) | ||
| 5681 | return true; | 5686 | return true; |
| 5682 | if (__result_ == nullptr || __x.__result_ == nullptr) | 5687 | if (__result_ == nullptr || __x.__result_ == nullptr) |
| 5683 | return false; | 5688 | return false; |
| 5684 | if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_) | 5689 | if (__result_ == std::addressof(__suffix_) || __x.__result_ == std::addressof(__x.__suffix_)) |
| 5685 | return false; | 5690 | return false; |
| 5686 | return __position_ == __x.__position_ && __n_ == __x.__n_ && __subs_ == __x.__subs_; | 5691 | return __position_ == __x.__position_ && __n_ == __x.__n_ && __subs_ == __x.__subs_; |
| 5687 | } | 5692 | } |
| ... | @@ -5690,7 +5695,7 @@ template <class _BidirectionalIterator, class _CharT, class _Traits> | ... | @@ -5690,7 +5695,7 @@ template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5690 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& | 5695 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& |
| 5691 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { | 5696 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { |
| 5692 | _Position __prev = __position_; | 5697 | _Position __prev = __position_; |
| 5693 | if (__result_ == &__suffix_) | 5698 | if (__result_ == std::addressof(__suffix_)) |
| 5694 | __result_ = nullptr; | 5699 | __result_ = nullptr; |
| 5695 | else if (static_cast<size_t>(__n_ + 1) < __subs_.size()) { | 5700 | else if (static_cast<size_t>(__n_ + 1) < __subs_.size()) { |
| 5696 | ++__n_; | 5701 | ++__n_; |
| ... | @@ -5705,7 +5710,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { | ... | @@ -5705,7 +5710,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { |
| 5705 | __suffix_.matched = true; | 5710 | __suffix_.matched = true; |
| 5706 | __suffix_.first = __prev->suffix().first; | 5711 | __suffix_.first = __prev->suffix().first; |
| 5707 | __suffix_.second = __prev->suffix().second; | 5712 | __suffix_.second = __prev->suffix().second; |
| 5708 | __result_ = &__suffix_; | 5713 | __result_ = std::addressof(__suffix_); |
| 5709 | } else | 5714 | } else |
| 5710 | __result_ = nullptr; | 5715 | __result_ = nullptr; |
| 5711 | } | 5716 | } |
| ... | @@ -5802,7 +5807,7 @@ regex_replace(const _CharT* __s, | ... | @@ -5802,7 +5807,7 @@ regex_replace(const _CharT* __s, |
| 5802 | 5807 | ||
| 5803 | _LIBCPP_END_NAMESPACE_STD | 5808 | _LIBCPP_END_NAMESPACE_STD |
| 5804 | 5809 | ||
| 5805 | # if _LIBCPP_STD_VER >= 17 | 5810 | # if _LIBCPP_STD_VER >= 17 |
| 5806 | _LIBCPP_BEGIN_NAMESPACE_STD | 5811 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 5807 | namespace pmr { | 5812 | namespace pmr { |
| 5808 | template <class _BidirT> | 5813 | template <class _BidirT> |
| ... | @@ -5812,16 +5817,18 @@ using match_results _LIBCPP_AVAILABILITY_PMR = | ... | @@ -5812,16 +5817,18 @@ using match_results _LIBCPP_AVAILABILITY_PMR = |
| 5812 | using cmatch _LIBCPP_AVAILABILITY_PMR = match_results<const char*>; | 5817 | using cmatch _LIBCPP_AVAILABILITY_PMR = match_results<const char*>; |
| 5813 | using smatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::string::const_iterator>; | 5818 | using smatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::string::const_iterator>; |
| 5814 | 5819 | ||
| 5815 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 5820 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| 5816 | using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results<const wchar_t*>; | 5821 | using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results<const wchar_t*>; |
| 5817 | using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::wstring::const_iterator>; | 5822 | using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::wstring::const_iterator>; |
| 5818 | # endif | 5823 | # endif |
| 5819 | } // namespace pmr | 5824 | } // namespace pmr |
| 5820 | _LIBCPP_END_NAMESPACE_STD | 5825 | _LIBCPP_END_NAMESPACE_STD |
| 5821 | # endif | 5826 | # endif |
| 5822 | 5827 | ||
| 5823 | _LIBCPP_POP_MACROS | 5828 | _LIBCPP_POP_MACROS |
| 5824 | 5829 | ||
| 5830 | # endif // _LIBCPP_HAS_LOCALIZATION | ||
| 5831 | |||
| 5825 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 5832 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 5826 | # include <atomic> | 5833 | # include <atomic> |
| 5827 | # include <concepts> | 5834 | # include <concepts> |
lib/libcxx/include/scoped_allocator+2-2| ... | @@ -110,7 +110,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs> | ... | @@ -110,7 +110,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs> |
| 110 | */ | 110 | */ |
| 111 | 111 | ||
| 112 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 112 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 113 | # include <__cxx03/scoped_allocator> | 113 | # include <__cxx03/__config> |
| 114 | #else | 114 | #else |
| 115 | # include <__config> | 115 | # include <__config> |
| 116 | # include <__memory/allocator_traits.h> | 116 | # include <__memory/allocator_traits.h> |
| ... | @@ -334,7 +334,7 @@ struct __outermost<_Alloc, true> { | ... | @@ -334,7 +334,7 @@ struct __outermost<_Alloc, true> { |
| 334 | }; | 334 | }; |
| 335 | 335 | ||
| 336 | template <class _OuterAlloc, class... _InnerAllocs> | 336 | template <class _OuterAlloc, class... _InnerAllocs> |
| 337 | class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> | 337 | class scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> |
| 338 | : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> { | 338 | : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> { |
| 339 | typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base; | 339 | typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base; |
| 340 | typedef allocator_traits<_OuterAlloc> _OuterTraits; | 340 | typedef allocator_traits<_OuterAlloc> _OuterTraits; |
lib/libcxx/include/semaphore+1-1| ... | @@ -46,7 +46,7 @@ using binary_semaphore = counting_semaphore<1>; // since C++20 | ... | @@ -46,7 +46,7 @@ using binary_semaphore = counting_semaphore<1>; // since C++20 |
| 46 | */ | 46 | */ |
| 47 | 47 | ||
| 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 49 | # include <__cxx03/semaphore> | 49 | # include <__cxx03/__config> |
| 50 | #else | 50 | #else |
| 51 | # include <__config> | 51 | # include <__config> |
| 52 | 52 |
lib/libcxx/include/set+36-40| ... | @@ -522,6 +522,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 | ... | @@ -522,6 +522,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
| 522 | # include <__config> | 522 | # include <__config> |
| 523 | # include <__functional/is_transparent.h> | 523 | # include <__functional/is_transparent.h> |
| 524 | # include <__functional/operations.h> | 524 | # include <__functional/operations.h> |
| 525 | # include <__fwd/set.h> | ||
| 525 | # include <__iterator/erase_if_container.h> | 526 | # include <__iterator/erase_if_container.h> |
| 526 | # include <__iterator/iterator_traits.h> | 527 | # include <__iterator/iterator_traits.h> |
| 527 | # include <__iterator/ranges_iterator_traits.h> | 528 | # include <__iterator/ranges_iterator_traits.h> |
| ... | @@ -570,10 +571,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -570,10 +571,7 @@ _LIBCPP_PUSH_MACROS |
| 570 | _LIBCPP_BEGIN_NAMESPACE_STD | 571 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 571 | 572 | ||
| 572 | template <class _Key, class _Compare, class _Allocator> | 573 | template <class _Key, class _Compare, class _Allocator> |
| 573 | class multiset; | 574 | class set { |
| 574 | |||
| 575 | template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > | ||
| 576 | class _LIBCPP_TEMPLATE_VIS set { | ||
| 577 | public: | 575 | public: |
| 578 | // types: | 576 | // types: |
| 579 | typedef _Key key_type; | 577 | typedef _Key key_type; |
| ... | @@ -611,9 +609,9 @@ public: | ... | @@ -611,9 +609,9 @@ public: |
| 611 | # endif | 609 | # endif |
| 612 | 610 | ||
| 613 | template <class _Key2, class _Compare2, class _Alloc2> | 611 | template <class _Key2, class _Compare2, class _Alloc2> |
| 614 | friend class _LIBCPP_TEMPLATE_VIS set; | 612 | friend class set; |
| 615 | template <class _Key2, class _Compare2, class _Alloc2> | 613 | template <class _Key2, class _Compare2, class _Alloc2> |
| 616 | friend class _LIBCPP_TEMPLATE_VIS multiset; | 614 | friend class multiset; |
| 617 | 615 | ||
| 618 | _LIBCPP_HIDE_FROM_ABI set() _NOEXCEPT_( | 616 | _LIBCPP_HIDE_FROM_ABI set() _NOEXCEPT_( |
| 619 | is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&& | 617 | is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&& |
| ... | @@ -664,14 +662,10 @@ public: | ... | @@ -664,14 +662,10 @@ public: |
| 664 | 662 | ||
| 665 | _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); } | 663 | _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); } |
| 666 | 664 | ||
| 667 | _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) { | 665 | _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) = default; |
| 668 | __tree_ = __s.__tree_; | ||
| 669 | return *this; | ||
| 670 | } | ||
| 671 | 666 | ||
| 672 | # ifndef _LIBCPP_CXX03_LANG | 667 | # ifndef _LIBCPP_CXX03_LANG |
| 673 | _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value) | 668 | _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value) = default; |
| 674 | : __tree_(std::move(__s.__tree_)) {} | ||
| 675 | # endif // _LIBCPP_CXX03_LANG | 669 | # endif // _LIBCPP_CXX03_LANG |
| 676 | 670 | ||
| 677 | _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {} | 671 | _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {} |
| ... | @@ -709,7 +703,7 @@ public: | ... | @@ -709,7 +703,7 @@ public: |
| 709 | } | 703 | } |
| 710 | # endif // _LIBCPP_CXX03_LANG | 704 | # endif // _LIBCPP_CXX03_LANG |
| 711 | 705 | ||
| 712 | _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } | 706 | _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); } |
| 713 | 707 | ||
| 714 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 708 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 715 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 709 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| ... | @@ -742,15 +736,15 @@ public: | ... | @@ -742,15 +736,15 @@ public: |
| 742 | } | 736 | } |
| 743 | # endif // _LIBCPP_CXX03_LANG | 737 | # endif // _LIBCPP_CXX03_LANG |
| 744 | 738 | ||
| 745 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); } | 739 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); } |
| 746 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { | 740 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| 747 | return __tree_.__insert_unique(__p, __v); | 741 | return __tree_.__emplace_hint_unique(__p, __v); |
| 748 | } | 742 | } |
| 749 | 743 | ||
| 750 | template <class _InputIterator> | 744 | template <class _InputIterator> |
| 751 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { | 745 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { |
| 752 | for (const_iterator __e = cend(); __f != __l; ++__f) | 746 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 753 | __tree_.__insert_unique(__e, *__f); | 747 | __tree_.__emplace_hint_unique(__e, *__f); |
| 754 | } | 748 | } |
| 755 | 749 | ||
| 756 | # if _LIBCPP_STD_VER >= 23 | 750 | # if _LIBCPP_STD_VER >= 23 |
| ... | @@ -758,18 +752,18 @@ public: | ... | @@ -758,18 +752,18 @@ public: |
| 758 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 752 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 759 | const_iterator __end = cend(); | 753 | const_iterator __end = cend(); |
| 760 | for (auto&& __element : __range) { | 754 | for (auto&& __element : __range) { |
| 761 | __tree_.__insert_unique(__end, std::forward<decltype(__element)>(__element)); | 755 | __tree_.__emplace_hint_unique(__end, std::forward<decltype(__element)>(__element)); |
| 762 | } | 756 | } |
| 763 | } | 757 | } |
| 764 | # endif | 758 | # endif |
| 765 | 759 | ||
| 766 | # ifndef _LIBCPP_CXX03_LANG | 760 | # ifndef _LIBCPP_CXX03_LANG |
| 767 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) { | 761 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) { |
| 768 | return __tree_.__insert_unique(std::move(__v)); | 762 | return __tree_.__emplace_unique(std::move(__v)); |
| 769 | } | 763 | } |
| 770 | 764 | ||
| 771 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { | 765 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { |
| 772 | return __tree_.__insert_unique(__p, std::move(__v)); | 766 | return __tree_.__emplace_hint_unique(__p, std::move(__v)); |
| 773 | } | 767 | } |
| 774 | 768 | ||
| 775 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 769 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| ... | @@ -1003,9 +997,9 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, | ... | @@ -1003,9 +997,9 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, |
| 1003 | 997 | ||
| 1004 | # else // _LIBCPP_STD_VER <= 17 | 998 | # else // _LIBCPP_STD_VER <= 17 |
| 1005 | 999 | ||
| 1006 | template <class _Key, class _Allocator> | 1000 | template <class _Key, class _Compare, class _Allocator> |
| 1007 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> | 1001 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> |
| 1008 | operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) { | 1002 | operator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) { |
| 1009 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | 1003 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1010 | } | 1004 | } |
| 1011 | 1005 | ||
| ... | @@ -1032,10 +1026,12 @@ struct __container_traits<set<_Key, _Compare, _Allocator> > { | ... | @@ -1032,10 +1026,12 @@ struct __container_traits<set<_Key, _Compare, _Allocator> > { |
| 1032 | // For associative containers, if an exception is thrown by any operation from within | 1026 | // For associative containers, if an exception is thrown by any operation from within |
| 1033 | // an insert or emplace function inserting a single element, the insertion has no effect. | 1027 | // an insert or emplace function inserting a single element, the insertion has no effect. |
| 1034 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | 1028 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; |
| 1029 | |||
| 1030 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 1035 | }; | 1031 | }; |
| 1036 | 1032 | ||
| 1037 | template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > | 1033 | template <class _Key, class _Compare, class _Allocator> |
| 1038 | class _LIBCPP_TEMPLATE_VIS multiset { | 1034 | class multiset { |
| 1039 | public: | 1035 | public: |
| 1040 | // types: | 1036 | // types: |
| 1041 | typedef _Key key_type; | 1037 | typedef _Key key_type; |
| ... | @@ -1072,9 +1068,9 @@ public: | ... | @@ -1072,9 +1068,9 @@ public: |
| 1072 | # endif | 1068 | # endif |
| 1073 | 1069 | ||
| 1074 | template <class _Key2, class _Compare2, class _Alloc2> | 1070 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1075 | friend class _LIBCPP_TEMPLATE_VIS set; | 1071 | friend class set; |
| 1076 | template <class _Key2, class _Compare2, class _Alloc2> | 1072 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1077 | friend class _LIBCPP_TEMPLATE_VIS multiset; | 1073 | friend class multiset; |
| 1078 | 1074 | ||
| 1079 | // construct/copy/destroy: | 1075 | // construct/copy/destroy: |
| 1080 | _LIBCPP_HIDE_FROM_ABI multiset() _NOEXCEPT_( | 1076 | _LIBCPP_HIDE_FROM_ABI multiset() _NOEXCEPT_( |
| ... | @@ -1129,14 +1125,10 @@ public: | ... | @@ -1129,14 +1125,10 @@ public: |
| 1129 | insert(__s.begin(), __s.end()); | 1125 | insert(__s.begin(), __s.end()); |
| 1130 | } | 1126 | } |
| 1131 | 1127 | ||
| 1132 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) { | 1128 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) = default; |
| 1133 | __tree_ = __s.__tree_; | ||
| 1134 | return *this; | ||
| 1135 | } | ||
| 1136 | 1129 | ||
| 1137 | # ifndef _LIBCPP_CXX03_LANG | 1130 | # ifndef _LIBCPP_CXX03_LANG |
| 1138 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value) | 1131 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value) = default; |
| 1139 | : __tree_(std::move(__s.__tree_)) {} | ||
| 1140 | 1132 | ||
| 1141 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); | 1133 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); |
| 1142 | # endif // _LIBCPP_CXX03_LANG | 1134 | # endif // _LIBCPP_CXX03_LANG |
| ... | @@ -1174,7 +1166,9 @@ public: | ... | @@ -1174,7 +1166,9 @@ public: |
| 1174 | } | 1166 | } |
| 1175 | # endif // _LIBCPP_CXX03_LANG | 1167 | # endif // _LIBCPP_CXX03_LANG |
| 1176 | 1168 | ||
| 1177 | _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } | 1169 | _LIBCPP_HIDE_FROM_ABI ~multiset() { |
| 1170 | static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); | ||
| 1171 | } | ||
| 1178 | 1172 | ||
| 1179 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } | 1173 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); } |
| 1180 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } | 1174 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); } |
| ... | @@ -1207,15 +1201,15 @@ public: | ... | @@ -1207,15 +1201,15 @@ public: |
| 1207 | } | 1201 | } |
| 1208 | # endif // _LIBCPP_CXX03_LANG | 1202 | # endif // _LIBCPP_CXX03_LANG |
| 1209 | 1203 | ||
| 1210 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } | 1204 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__emplace_multi(__v); } |
| 1211 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { | 1205 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| 1212 | return __tree_.__insert_multi(__p, __v); | 1206 | return __tree_.__emplace_hint_multi(__p, __v); |
| 1213 | } | 1207 | } |
| 1214 | 1208 | ||
| 1215 | template <class _InputIterator> | 1209 | template <class _InputIterator> |
| 1216 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { | 1210 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { |
| 1217 | for (const_iterator __e = cend(); __f != __l; ++__f) | 1211 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1218 | __tree_.__insert_multi(__e, *__f); | 1212 | __tree_.__emplace_hint_multi(__e, *__f); |
| 1219 | } | 1213 | } |
| 1220 | 1214 | ||
| 1221 | # if _LIBCPP_STD_VER >= 23 | 1215 | # if _LIBCPP_STD_VER >= 23 |
| ... | @@ -1223,16 +1217,16 @@ public: | ... | @@ -1223,16 +1217,16 @@ public: |
| 1223 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1217 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1224 | const_iterator __end = cend(); | 1218 | const_iterator __end = cend(); |
| 1225 | for (auto&& __element : __range) { | 1219 | for (auto&& __element : __range) { |
| 1226 | __tree_.__insert_multi(__end, std::forward<decltype(__element)>(__element)); | 1220 | __tree_.__emplace_hint_multi(__end, std::forward<decltype(__element)>(__element)); |
| 1227 | } | 1221 | } |
| 1228 | } | 1222 | } |
| 1229 | # endif | 1223 | # endif |
| 1230 | 1224 | ||
| 1231 | # ifndef _LIBCPP_CXX03_LANG | 1225 | # ifndef _LIBCPP_CXX03_LANG |
| 1232 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); } | 1226 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__emplace_multi(std::move(__v)); } |
| 1233 | 1227 | ||
| 1234 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { | 1228 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { |
| 1235 | return __tree_.__insert_multi(__p, std::move(__v)); | 1229 | return __tree_.__emplace_hint_multi(__p, std::move(__v)); |
| 1236 | } | 1230 | } |
| 1237 | 1231 | ||
| 1238 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 1232 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| ... | @@ -1470,9 +1464,9 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, | ... | @@ -1470,9 +1464,9 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, |
| 1470 | 1464 | ||
| 1471 | # else // _LIBCPP_STD_VER <= 17 | 1465 | # else // _LIBCPP_STD_VER <= 17 |
| 1472 | 1466 | ||
| 1473 | template <class _Key, class _Allocator> | 1467 | template <class _Key, class _Compare, class _Allocator> |
| 1474 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> | 1468 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> |
| 1475 | operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) { | 1469 | operator<=>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) { |
| 1476 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); | 1470 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); |
| 1477 | } | 1471 | } |
| 1478 | 1472 | ||
| ... | @@ -1499,6 +1493,8 @@ struct __container_traits<multiset<_Key, _Compare, _Allocator> > { | ... | @@ -1499,6 +1493,8 @@ struct __container_traits<multiset<_Key, _Compare, _Allocator> > { |
| 1499 | // For associative containers, if an exception is thrown by any operation from within | 1493 | // For associative containers, if an exception is thrown by any operation from within |
| 1500 | // an insert or emplace function inserting a single element, the insertion has no effect. | 1494 | // an insert or emplace function inserting a single element, the insertion has no effect. |
| 1501 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | 1495 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; |
| 1496 | |||
| 1497 | static _LIBCPP_CONSTEXPR const bool __reservable = false; | ||
| 1502 | }; | 1498 | }; |
| 1503 | 1499 | ||
| 1504 | _LIBCPP_END_NAMESPACE_STD | 1500 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/shared_mutex+76-91| ... | @@ -123,7 +123,7 @@ template <class Mutex> | ... | @@ -123,7 +123,7 @@ template <class Mutex> |
| 123 | */ | 123 | */ |
| 124 | 124 | ||
| 125 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 125 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 126 | # include <__cxx03/shared_mutex> | 126 | # include <__cxx03/__config> |
| 127 | #else | 127 | #else |
| 128 | # include <__config> | 128 | # include <__config> |
| 129 | 129 | ||
| ... | @@ -183,7 +183,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base { | ... | @@ -183,7 +183,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base { |
| 183 | }; | 183 | }; |
| 184 | 184 | ||
| 185 | # if _LIBCPP_STD_VER >= 17 | 185 | # if _LIBCPP_STD_VER >= 17 |
| 186 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex { | 186 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_CAPABILITY("shared_mutex") shared_mutex { |
| 187 | __shared_mutex_base __base_; | 187 | __shared_mutex_base __base_; |
| 188 | 188 | ||
| 189 | public: | 189 | public: |
| ... | @@ -194,35 +194,23 @@ public: | ... | @@ -194,35 +194,23 @@ public: |
| 194 | shared_mutex& operator=(const shared_mutex&) = delete; | 194 | shared_mutex& operator=(const shared_mutex&) = delete; |
| 195 | 195 | ||
| 196 | // Exclusive ownership | 196 | // Exclusive ownership |
| 197 | _LIBCPP_HIDE_FROM_ABI void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_capability__()) { | 197 | _LIBCPP_ACQUIRE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI void lock() { return __base_.lock(); } |
| 198 | return __base_.lock(); | 198 | _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock() { return __base_.try_lock(); } |
| 199 | } | 199 | _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI void unlock() { return __base_.unlock(); } |
| 200 | _LIBCPP_HIDE_FROM_ABI bool try_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true)) { | ||
| 201 | return __base_.try_lock(); | ||
| 202 | } | ||
| 203 | _LIBCPP_HIDE_FROM_ABI void unlock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_capability__()) { | ||
| 204 | return __base_.unlock(); | ||
| 205 | } | ||
| 206 | 200 | ||
| 207 | // Shared ownership | 201 | // Shared ownership |
| 208 | _LIBCPP_HIDE_FROM_ABI void lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_shared_capability__()) { | 202 | _LIBCPP_ACQUIRE_SHARED_CAPABILITY _LIBCPP_HIDE_FROM_ABI void lock_shared() { return __base_.lock_shared(); } |
| 209 | return __base_.lock_shared(); | 203 | _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock_shared() { |
| 210 | } | ||
| 211 | _LIBCPP_HIDE_FROM_ABI bool try_lock_shared() | ||
| 212 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true)) { | ||
| 213 | return __base_.try_lock_shared(); | 204 | return __base_.try_lock_shared(); |
| 214 | } | 205 | } |
| 215 | _LIBCPP_HIDE_FROM_ABI void unlock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_shared_capability__()) { | 206 | _LIBCPP_RELEASE_SHARED_CAPABILITY _LIBCPP_HIDE_FROM_ABI void unlock_shared() { return __base_.unlock_shared(); } |
| 216 | return __base_.unlock_shared(); | ||
| 217 | } | ||
| 218 | 207 | ||
| 219 | // typedef __shared_mutex_base::native_handle_type native_handle_type; | 208 | // typedef __shared_mutex_base::native_handle_type native_handle_type; |
| 220 | // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); } | 209 | // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); } |
| 221 | }; | 210 | }; |
| 222 | # endif | 211 | # endif |
| 223 | 212 | ||
| 224 | class _LIBCPP_EXPORTED_FROM_ABI | 213 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_CAPABILITY("shared_timed_mutex") shared_timed_mutex { |
| 225 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex { | ||
| 226 | __shared_mutex_base __base_; | 214 | __shared_mutex_base __base_; |
| 227 | 215 | ||
| 228 | public: | 216 | public: |
| ... | @@ -233,81 +221,77 @@ public: | ... | @@ -233,81 +221,77 @@ public: |
| 233 | shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; | 221 | shared_timed_mutex& operator=(const shared_timed_mutex&) = delete; |
| 234 | 222 | ||
| 235 | // Exclusive ownership | 223 | // Exclusive ownership |
| 236 | void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_capability__()); | 224 | void lock() _LIBCPP_ACQUIRE_CAPABILITY(); |
| 237 | bool try_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true)); | 225 | _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock(); |
| 238 | template <class _Rep, class _Period> | 226 | template <class _Rep, class _Period> |
| 239 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) | 227 | _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool |
| 240 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true)) { | 228 | try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) { |
| 241 | return try_lock_until(chrono::steady_clock::now() + __rel_time); | 229 | return try_lock_until(chrono::steady_clock::now() + __rel_time); |
| 242 | } | 230 | } |
| 231 | |||
| 243 | template <class _Clock, class _Duration> | 232 | template <class _Clock, class _Duration> |
| 244 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool | 233 | _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool |
| 245 | try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) | 234 | try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) { |
| 246 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true)); | 235 | unique_lock<mutex> __lk(__base_.__mut_); |
| 247 | void unlock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_capability__()); | 236 | if (__base_.__state_ & __base_.__write_entered_) { |
| 237 | while (true) { | ||
| 238 | cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time); | ||
| 239 | if ((__base_.__state_ & __base_.__write_entered_) == 0) | ||
| 240 | break; | ||
| 241 | if (__status == cv_status::timeout) | ||
| 242 | return false; | ||
| 243 | } | ||
| 244 | } | ||
| 245 | __base_.__state_ |= __base_.__write_entered_; | ||
| 246 | if (__base_.__state_ & __base_.__n_readers_) { | ||
| 247 | while (true) { | ||
| 248 | cv_status __status = __base_.__gate2_.wait_until(__lk, __abs_time); | ||
| 249 | if ((__base_.__state_ & __base_.__n_readers_) == 0) | ||
| 250 | break; | ||
| 251 | if (__status == cv_status::timeout) { | ||
| 252 | __base_.__state_ &= ~__base_.__write_entered_; | ||
| 253 | __base_.__gate1_.notify_all(); | ||
| 254 | return false; | ||
| 255 | } | ||
| 256 | } | ||
| 257 | } | ||
| 258 | return true; | ||
| 259 | } | ||
| 260 | |||
| 261 | _LIBCPP_RELEASE_CAPABILITY void unlock(); | ||
| 248 | 262 | ||
| 249 | // Shared ownership | 263 | // Shared ownership |
| 250 | void lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_shared_capability__()); | 264 | _LIBCPP_ACQUIRE_SHARED_CAPABILITY void lock_shared(); |
| 251 | bool try_lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true)); | 265 | _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) bool try_lock_shared(); |
| 252 | template <class _Rep, class _Period> | 266 | template <class _Rep, class _Period> |
| 253 | _LIBCPP_HIDE_FROM_ABI bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time) | 267 | _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool |
| 254 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true)) { | 268 | try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time) { |
| 255 | return try_lock_shared_until(chrono::steady_clock::now() + __rel_time); | 269 | return try_lock_shared_until(chrono::steady_clock::now() + __rel_time); |
| 256 | } | 270 | } |
| 257 | template <class _Clock, class _Duration> | ||
| 258 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool | ||
| 259 | try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time) | ||
| 260 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true)); | ||
| 261 | void unlock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_shared_capability__()); | ||
| 262 | }; | ||
| 263 | 271 | ||
| 264 | template <class _Clock, class _Duration> | 272 | template <class _Clock, class _Duration> |
| 265 | bool shared_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) { | 273 | _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool |
| 266 | unique_lock<mutex> __lk(__base_.__mut_); | 274 | try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time) { |
| 267 | if (__base_.__state_ & __base_.__write_entered_) { | 275 | unique_lock<mutex> __lk(__base_.__mut_); |
| 268 | while (true) { | 276 | if ((__base_.__state_ & __base_.__write_entered_) || |
| 269 | cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time); | 277 | (__base_.__state_ & __base_.__n_readers_) == __base_.__n_readers_) { |
| 270 | if ((__base_.__state_ & __base_.__write_entered_) == 0) | 278 | while (true) { |
| 271 | break; | 279 | cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time); |
| 272 | if (__status == cv_status::timeout) | 280 | if ((__base_.__state_ & __base_.__write_entered_) == 0 && |
| 273 | return false; | 281 | (__base_.__state_ & __base_.__n_readers_) < __base_.__n_readers_) |
| 274 | } | 282 | break; |
| 275 | } | 283 | if (__status == cv_status::timeout) |
| 276 | __base_.__state_ |= __base_.__write_entered_; | 284 | return false; |
| 277 | if (__base_.__state_ & __base_.__n_readers_) { | ||
| 278 | while (true) { | ||
| 279 | cv_status __status = __base_.__gate2_.wait_until(__lk, __abs_time); | ||
| 280 | if ((__base_.__state_ & __base_.__n_readers_) == 0) | ||
| 281 | break; | ||
| 282 | if (__status == cv_status::timeout) { | ||
| 283 | __base_.__state_ &= ~__base_.__write_entered_; | ||
| 284 | __base_.__gate1_.notify_all(); | ||
| 285 | return false; | ||
| 286 | } | 285 | } |
| 287 | } | 286 | } |
| 287 | unsigned __num_readers = (__base_.__state_ & __base_.__n_readers_) + 1; | ||
| 288 | __base_.__state_ &= ~__base_.__n_readers_; | ||
| 289 | __base_.__state_ |= __num_readers; | ||
| 290 | return true; | ||
| 288 | } | 291 | } |
| 289 | return true; | ||
| 290 | } | ||
| 291 | 292 | ||
| 292 | template <class _Clock, class _Duration> | 293 | _LIBCPP_RELEASE_SHARED_CAPABILITY void unlock_shared(); |
| 293 | bool shared_timed_mutex::try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time) { | 294 | }; |
| 294 | unique_lock<mutex> __lk(__base_.__mut_); | ||
| 295 | if ((__base_.__state_ & __base_.__write_entered_) || | ||
| 296 | (__base_.__state_ & __base_.__n_readers_) == __base_.__n_readers_) { | ||
| 297 | while (true) { | ||
| 298 | cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time); | ||
| 299 | if ((__base_.__state_ & __base_.__write_entered_) == 0 && | ||
| 300 | (__base_.__state_ & __base_.__n_readers_) < __base_.__n_readers_) | ||
| 301 | break; | ||
| 302 | if (__status == cv_status::timeout) | ||
| 303 | return false; | ||
| 304 | } | ||
| 305 | } | ||
| 306 | unsigned __num_readers = (__base_.__state_ & __base_.__n_readers_) + 1; | ||
| 307 | __base_.__state_ &= ~__base_.__n_readers_; | ||
| 308 | __base_.__state_ |= __num_readers; | ||
| 309 | return true; | ||
| 310 | } | ||
| 311 | 295 | ||
| 312 | template <class _Mutex> | 296 | template <class _Mutex> |
| 313 | class shared_lock { | 297 | class shared_lock { |
| ... | @@ -400,9 +384,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock); | ... | @@ -400,9 +384,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock); |
| 400 | template <class _Mutex> | 384 | template <class _Mutex> |
| 401 | void shared_lock<_Mutex>::lock() { | 385 | void shared_lock<_Mutex>::lock() { |
| 402 | if (__m_ == nullptr) | 386 | if (__m_ == nullptr) |
| 403 | __throw_system_error(EPERM, "shared_lock::lock: references null mutex"); | 387 | std::__throw_system_error(EPERM, "shared_lock::lock: references null mutex"); |
| 404 | if (__owns_) | 388 | if (__owns_) |
| 405 | __throw_system_error(EDEADLK, "shared_lock::lock: already locked"); | 389 | std::__throw_system_error(EDEADLK, "shared_lock::lock: already locked"); |
| 406 | __m_->lock_shared(); | 390 | __m_->lock_shared(); |
| 407 | __owns_ = true; | 391 | __owns_ = true; |
| 408 | } | 392 | } |
| ... | @@ -410,9 +394,9 @@ void shared_lock<_Mutex>::lock() { | ... | @@ -410,9 +394,9 @@ void shared_lock<_Mutex>::lock() { |
| 410 | template <class _Mutex> | 394 | template <class _Mutex> |
| 411 | bool shared_lock<_Mutex>::try_lock() { | 395 | bool shared_lock<_Mutex>::try_lock() { |
| 412 | if (__m_ == nullptr) | 396 | if (__m_ == nullptr) |
| 413 | __throw_system_error(EPERM, "shared_lock::try_lock: references null mutex"); | 397 | std::__throw_system_error(EPERM, "shared_lock::try_lock: references null mutex"); |
| 414 | if (__owns_) | 398 | if (__owns_) |
| 415 | __throw_system_error(EDEADLK, "shared_lock::try_lock: already locked"); | 399 | std::__throw_system_error(EDEADLK, "shared_lock::try_lock: already locked"); |
| 416 | __owns_ = __m_->try_lock_shared(); | 400 | __owns_ = __m_->try_lock_shared(); |
| 417 | return __owns_; | 401 | return __owns_; |
| 418 | } | 402 | } |
| ... | @@ -421,9 +405,9 @@ template <class _Mutex> | ... | @@ -421,9 +405,9 @@ template <class _Mutex> |
| 421 | template <class _Rep, class _Period> | 405 | template <class _Rep, class _Period> |
| 422 | bool shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | 406 | bool shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { |
| 423 | if (__m_ == nullptr) | 407 | if (__m_ == nullptr) |
| 424 | __throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex"); | 408 | std::__throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex"); |
| 425 | if (__owns_) | 409 | if (__owns_) |
| 426 | __throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked"); | 410 | std::__throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked"); |
| 427 | __owns_ = __m_->try_lock_shared_for(__d); | 411 | __owns_ = __m_->try_lock_shared_for(__d); |
| 428 | return __owns_; | 412 | return __owns_; |
| 429 | } | 413 | } |
| ... | @@ -432,9 +416,9 @@ template <class _Mutex> | ... | @@ -432,9 +416,9 @@ template <class _Mutex> |
| 432 | template <class _Clock, class _Duration> | 416 | template <class _Clock, class _Duration> |
| 433 | bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | 417 | bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { |
| 434 | if (__m_ == nullptr) | 418 | if (__m_ == nullptr) |
| 435 | __throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex"); | 419 | std::__throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex"); |
| 436 | if (__owns_) | 420 | if (__owns_) |
| 437 | __throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked"); | 421 | std::__throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked"); |
| 438 | __owns_ = __m_->try_lock_shared_until(__t); | 422 | __owns_ = __m_->try_lock_shared_until(__t); |
| 439 | return __owns_; | 423 | return __owns_; |
| 440 | } | 424 | } |
| ... | @@ -442,7 +426,7 @@ bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat | ... | @@ -442,7 +426,7 @@ bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat |
| 442 | template <class _Mutex> | 426 | template <class _Mutex> |
| 443 | void shared_lock<_Mutex>::unlock() { | 427 | void shared_lock<_Mutex>::unlock() { |
| 444 | if (!__owns_) | 428 | if (!__owns_) |
| 445 | __throw_system_error(EPERM, "shared_lock::unlock: not locked"); | 429 | std::__throw_system_error(EPERM, "shared_lock::unlock: not locked"); |
| 446 | __m_->unlock_shared(); | 430 | __m_->unlock_shared(); |
| 447 | __owns_ = false; | 431 | __owns_ = false; |
| 448 | } | 432 | } |
| ... | @@ -461,6 +445,7 @@ _LIBCPP_POP_MACROS | ... | @@ -461,6 +445,7 @@ _LIBCPP_POP_MACROS |
| 461 | # endif // _LIBCPP_HAS_THREADS | 445 | # endif // _LIBCPP_HAS_THREADS |
| 462 | 446 | ||
| 463 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 447 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 448 | # include <optional> | ||
| 464 | # include <system_error> | 449 | # include <system_error> |
| 465 | # endif | 450 | # endif |
| 466 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 451 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/source_location+1-1| ... | @@ -26,7 +26,7 @@ namespace std { | ... | @@ -26,7 +26,7 @@ namespace std { |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 28 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 29 | # include <__cxx03/source_location> | 29 | # include <__cxx03/__config> |
| 30 | #else | 30 | #else |
| 31 | # include <__config> | 31 | # include <__config> |
| 32 | # include <cstdint> | 32 | # include <cstdint> |
lib/libcxx/include/span+3-3| ... | @@ -145,7 +145,7 @@ template<class R> | ... | @@ -145,7 +145,7 @@ template<class R> |
| 145 | */ | 145 | */ |
| 146 | 146 | ||
| 147 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 147 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 148 | # include <__cxx03/span> | 148 | # include <__cxx03/__config> |
| 149 | #else | 149 | #else |
| 150 | # include <__assert> | 150 | # include <__assert> |
| 151 | # include <__concepts/convertible_to.h> | 151 | # include <__concepts/convertible_to.h> |
| ... | @@ -229,7 +229,7 @@ template <class _Sentinel, class _It> | ... | @@ -229,7 +229,7 @@ template <class _Sentinel, class _It> |
| 229 | concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>; | 229 | concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>; |
| 230 | 230 | ||
| 231 | template <typename _Tp, size_t _Extent> | 231 | template <typename _Tp, size_t _Extent> |
| 232 | class _LIBCPP_TEMPLATE_VIS span { | 232 | class span { |
| 233 | public: | 233 | public: |
| 234 | // constants and types | 234 | // constants and types |
| 235 | using element_type = _Tp; | 235 | using element_type = _Tp; |
| ... | @@ -412,7 +412,7 @@ private: | ... | @@ -412,7 +412,7 @@ private: |
| 412 | }; | 412 | }; |
| 413 | 413 | ||
| 414 | template <typename _Tp> | 414 | template <typename _Tp> |
| 415 | class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> { | 415 | class span<_Tp, dynamic_extent> { |
| 416 | public: | 416 | public: |
| 417 | // constants and types | 417 | // constants and types |
| 418 | using element_type = _Tp; | 418 | using element_type = _Tp; |
lib/libcxx/include/sstream+5-5| ... | @@ -325,7 +325,7 @@ typedef basic_stringstream<wchar_t> wstringstream; | ... | @@ -325,7 +325,7 @@ typedef basic_stringstream<wchar_t> wstringstream; |
| 325 | # include <__utility/swap.h> | 325 | # include <__utility/swap.h> |
| 326 | # include <ios> | 326 | # include <ios> |
| 327 | # include <istream> | 327 | # include <istream> |
| 328 | # include <locale> | 328 | # include <streambuf> |
| 329 | # include <string> | 329 | # include <string> |
| 330 | # include <string_view> | 330 | # include <string_view> |
| 331 | # include <version> | 331 | # include <version> |
| ... | @@ -342,7 +342,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -342,7 +342,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 342 | // Class template basic_stringbuf [stringbuf] | 342 | // Class template basic_stringbuf [stringbuf] |
| 343 | 343 | ||
| 344 | template <class _CharT, class _Traits, class _Allocator> | 344 | template <class _CharT, class _Traits, class _Allocator> |
| 345 | class _LIBCPP_TEMPLATE_VIS basic_stringbuf : public basic_streambuf<_CharT, _Traits> { | 345 | class basic_stringbuf : public basic_streambuf<_CharT, _Traits> { |
| 346 | public: | 346 | public: |
| 347 | typedef _CharT char_type; | 347 | typedef _CharT char_type; |
| 348 | typedef _Traits traits_type; | 348 | typedef _Traits traits_type; |
| ... | @@ -864,7 +864,7 @@ typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf< | ... | @@ -864,7 +864,7 @@ typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf< |
| 864 | // Class template basic_istringstream [istringstream] | 864 | // Class template basic_istringstream [istringstream] |
| 865 | 865 | ||
| 866 | template <class _CharT, class _Traits, class _Allocator> | 866 | template <class _CharT, class _Traits, class _Allocator> |
| 867 | class _LIBCPP_TEMPLATE_VIS basic_istringstream : public basic_istream<_CharT, _Traits> { | 867 | class basic_istringstream : public basic_istream<_CharT, _Traits> { |
| 868 | public: | 868 | public: |
| 869 | typedef _CharT char_type; | 869 | typedef _CharT char_type; |
| 870 | typedef _Traits traits_type; | 870 | typedef _Traits traits_type; |
| ... | @@ -1000,7 +1000,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream< | ... | @@ -1000,7 +1000,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream< |
| 1000 | // Class template basic_ostringstream [ostringstream] | 1000 | // Class template basic_ostringstream [ostringstream] |
| 1001 | 1001 | ||
| 1002 | template <class _CharT, class _Traits, class _Allocator> | 1002 | template <class _CharT, class _Traits, class _Allocator> |
| 1003 | class _LIBCPP_TEMPLATE_VIS basic_ostringstream : public basic_ostream<_CharT, _Traits> { | 1003 | class basic_ostringstream : public basic_ostream<_CharT, _Traits> { |
| 1004 | public: | 1004 | public: |
| 1005 | typedef _CharT char_type; | 1005 | typedef _CharT char_type; |
| 1006 | typedef _Traits traits_type; | 1006 | typedef _Traits traits_type; |
| ... | @@ -1138,7 +1138,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream< | ... | @@ -1138,7 +1138,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream< |
| 1138 | // Class template basic_stringstream [stringstream] | 1138 | // Class template basic_stringstream [stringstream] |
| 1139 | 1139 | ||
| 1140 | template <class _CharT, class _Traits, class _Allocator> | 1140 | template <class _CharT, class _Traits, class _Allocator> |
| 1141 | class _LIBCPP_TEMPLATE_VIS basic_stringstream : public basic_iostream<_CharT, _Traits> { | 1141 | class basic_stringstream : public basic_iostream<_CharT, _Traits> { |
| 1142 | public: | 1142 | public: |
| 1143 | typedef _CharT char_type; | 1143 | typedef _CharT char_type; |
| 1144 | typedef _Traits traits_type; | 1144 | typedef _Traits traits_type; |
lib/libcxx/include/stack+13-7| ... | @@ -153,7 +153,7 @@ template <class _Tp, class _Container> | ... | @@ -153,7 +153,7 @@ template <class _Tp, class _Container> |
| 153 | _LIBCPP_HIDE_FROM_ABI bool operator<(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); | 153 | _LIBCPP_HIDE_FROM_ABI bool operator<(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); |
| 154 | 154 | ||
| 155 | template <class _Tp, class _Container /*= deque<_Tp>*/> | 155 | template <class _Tp, class _Container /*= deque<_Tp>*/> |
| 156 | class _LIBCPP_TEMPLATE_VIS stack { | 156 | class stack { |
| 157 | public: | 157 | public: |
| 158 | typedef _Container container_type; | 158 | typedef _Container container_type; |
| 159 | typedef typename container_type::value_type value_type; | 159 | typedef typename container_type::value_type value_type; |
| ... | @@ -279,10 +279,18 @@ public: | ... | @@ -279,10 +279,18 @@ public: |
| 279 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | 279 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } |
| 280 | 280 | ||
| 281 | template <class _T1, class _OtherContainer> | 281 | template <class _T1, class _OtherContainer> |
| 282 | friend bool operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); | 282 | friend _LIBCPP_HIDE_FROM_ABI bool |
| 283 | operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); | ||
| 283 | 284 | ||
| 284 | template <class _T1, class _OtherContainer> | 285 | template <class _T1, class _OtherContainer> |
| 285 | friend bool operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); | 286 | friend _LIBCPP_HIDE_FROM_ABI bool |
| 287 | operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); | ||
| 288 | |||
| 289 | # if _LIBCPP_STD_VER >= 20 | ||
| 290 | template <class _T1, three_way_comparable _OtherContainer> | ||
| 291 | friend _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_OtherContainer> | ||
| 292 | operator<=>(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); | ||
| 293 | # endif | ||
| 286 | }; | 294 | }; |
| 287 | 295 | ||
| 288 | # if _LIBCPP_STD_VER >= 17 | 296 | # if _LIBCPP_STD_VER >= 17 |
| ... | @@ -353,8 +361,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x, | ... | @@ -353,8 +361,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x, |
| 353 | template <class _Tp, three_way_comparable _Container> | 361 | template <class _Tp, three_way_comparable _Container> |
| 354 | _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> | 362 | _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> |
| 355 | operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { | 363 | operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { |
| 356 | // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors | 364 | return __x.c <=> __y.c; |
| 357 | return __x.__get_container() <=> __y.__get_container(); | ||
| 358 | } | 365 | } |
| 359 | 366 | ||
| 360 | # endif | 367 | # endif |
| ... | @@ -366,8 +373,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _ | ... | @@ -366,8 +373,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _ |
| 366 | } | 373 | } |
| 367 | 374 | ||
| 368 | template <class _Tp, class _Container, class _Alloc> | 375 | template <class _Tp, class _Container, class _Alloc> |
| 369 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { | 376 | struct uses_allocator<stack<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {}; |
| 370 | }; | ||
| 371 | 377 | ||
| 372 | _LIBCPP_END_NAMESPACE_STD | 378 | _LIBCPP_END_NAMESPACE_STD |
| 373 | 379 |
lib/libcxx/include/stdlib.h+2-17| ... | @@ -106,23 +106,8 @@ extern "C++" { | ... | @@ -106,23 +106,8 @@ extern "C++" { |
| 106 | # undef llabs | 106 | # undef llabs |
| 107 | # endif | 107 | # endif |
| 108 | 108 | ||
| 109 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined | 109 | # include <__math/abs.h> |
| 110 | # if !defined(_LIBCPP_MSVCRT) | 110 | using std::__math::abs; |
| 111 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } | ||
| 112 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } | ||
| 113 | # endif // !defined(_LIBCPP_MSVCRT) | ||
| 114 | |||
| 115 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { | ||
| 116 | return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h | ||
| 117 | } | ||
| 118 | |||
| 119 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { | ||
| 120 | return __builtin_fabs(__lcpp_x); | ||
| 121 | } | ||
| 122 | |||
| 123 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { | ||
| 124 | return __builtin_fabsl(__lcpp_x); | ||
| 125 | } | ||
| 126 | 111 | ||
| 127 | // div | 112 | // div |
| 128 | 113 |
lib/libcxx/include/stop_token+1-1| ... | @@ -32,7 +32,7 @@ namespace std { | ... | @@ -32,7 +32,7 @@ namespace std { |
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 34 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 35 | # include <__cxx03/stop_token> | 35 | # include <__cxx03/__config> |
| 36 | #else | 36 | #else |
| 37 | # include <__config> | 37 | # include <__config> |
| 38 | 38 |
lib/libcxx/include/streambuf+38-25| ... | @@ -134,7 +134,7 @@ _LIBCPP_PUSH_MACROS | ... | @@ -134,7 +134,7 @@ _LIBCPP_PUSH_MACROS |
| 134 | _LIBCPP_BEGIN_NAMESPACE_STD | 134 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 135 | 135 | ||
| 136 | template <class _CharT, class _Traits> | 136 | template <class _CharT, class _Traits> |
| 137 | class _LIBCPP_TEMPLATE_VIS basic_streambuf { | 137 | class basic_streambuf { |
| 138 | public: | 138 | public: |
| 139 | // types: | 139 | // types: |
| 140 | typedef _CharT char_type; | 140 | typedef _CharT char_type; |
| ... | @@ -178,8 +178,8 @@ public: | ... | @@ -178,8 +178,8 @@ public: |
| 178 | // Get and put areas: | 178 | // Get and put areas: |
| 179 | // 27.6.2.2.3 Get area: | 179 | // 27.6.2.2.3 Get area: |
| 180 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize in_avail() { | 180 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize in_avail() { |
| 181 | if (__ninp_ < __einp_) | 181 | if (gptr() < egptr()) |
| 182 | return static_cast<streamsize>(__einp_ - __ninp_); | 182 | return static_cast<streamsize>(egptr() - gptr()); |
| 183 | return showmanyc(); | 183 | return showmanyc(); |
| 184 | } | 184 | } |
| 185 | 185 | ||
| ... | @@ -190,37 +190,42 @@ public: | ... | @@ -190,37 +190,42 @@ public: |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sbumpc() { | 192 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sbumpc() { |
| 193 | if (__ninp_ == __einp_) | 193 | if (gptr() == egptr()) |
| 194 | return uflow(); | 194 | return uflow(); |
| 195 | return traits_type::to_int_type(*__ninp_++); | 195 | int_type __c = traits_type::to_int_type(*gptr()); |
| 196 | this->gbump(1); | ||
| 197 | return __c; | ||
| 196 | } | 198 | } |
| 197 | 199 | ||
| 198 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sgetc() { | 200 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sgetc() { |
| 199 | if (__ninp_ == __einp_) | 201 | if (gptr() == egptr()) |
| 200 | return underflow(); | 202 | return underflow(); |
| 201 | return traits_type::to_int_type(*__ninp_); | 203 | return traits_type::to_int_type(*gptr()); |
| 202 | } | 204 | } |
| 203 | 205 | ||
| 204 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sgetn(char_type* __s, streamsize __n) { return xsgetn(__s, __n); } | 206 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sgetn(char_type* __s, streamsize __n) { return xsgetn(__s, __n); } |
| 205 | 207 | ||
| 206 | // 27.6.2.2.4 Putback: | 208 | // 27.6.2.2.4 Putback: |
| 207 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputbackc(char_type __c) { | 209 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputbackc(char_type __c) { |
| 208 | if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1])) | 210 | if (eback() == gptr() || !traits_type::eq(__c, *(gptr() - 1))) |
| 209 | return pbackfail(traits_type::to_int_type(__c)); | 211 | return pbackfail(traits_type::to_int_type(__c)); |
| 210 | return traits_type::to_int_type(*--__ninp_); | 212 | this->gbump(-1); |
| 213 | return traits_type::to_int_type(*gptr()); | ||
| 211 | } | 214 | } |
| 212 | 215 | ||
| 213 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sungetc() { | 216 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sungetc() { |
| 214 | if (__binp_ == __ninp_) | 217 | if (eback() == gptr()) |
| 215 | return pbackfail(); | 218 | return pbackfail(); |
| 216 | return traits_type::to_int_type(*--__ninp_); | 219 | this->gbump(-1); |
| 220 | return traits_type::to_int_type(*gptr()); | ||
| 217 | } | 221 | } |
| 218 | 222 | ||
| 219 | // 27.6.2.2.5 Put area: | 223 | // 27.6.2.2.5 Put area: |
| 220 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputc(char_type __c) { | 224 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputc(char_type __c) { |
| 221 | if (__nout_ == __eout_) | 225 | if (pptr() == epptr()) |
| 222 | return overflow(traits_type::to_int_type(__c)); | 226 | return overflow(traits_type::to_int_type(__c)); |
| 223 | *__nout_++ = __c; | 227 | *pptr() = __c; |
| 228 | this->pbump(1); | ||
| 224 | return traits_type::to_int_type(__c); | 229 | return traits_type::to_int_type(__c); |
| 225 | } | 230 | } |
| 226 | 231 | ||
| ... | @@ -267,6 +272,9 @@ protected: | ... | @@ -267,6 +272,9 @@ protected: |
| 267 | 272 | ||
| 268 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; } | 273 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; } |
| 269 | 274 | ||
| 275 | // gbump takes an int, so it might not be able to represent the offset we want to add. | ||
| 276 | _LIBCPP_HIDE_FROM_ABI void __gbump_ptrdiff(ptrdiff_t __n) { __ninp_ += __n; } | ||
| 277 | |||
| 270 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { | 278 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { |
| 271 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range"); | 279 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range"); |
| 272 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range"); | 280 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range"); |
| ... | @@ -309,17 +317,16 @@ protected: | ... | @@ -309,17 +317,16 @@ protected: |
| 309 | virtual streamsize showmanyc() { return 0; } | 317 | virtual streamsize showmanyc() { return 0; } |
| 310 | 318 | ||
| 311 | virtual streamsize xsgetn(char_type* __s, streamsize __n) { | 319 | virtual streamsize xsgetn(char_type* __s, streamsize __n) { |
| 312 | const int_type __eof = traits_type::eof(); | ||
| 313 | int_type __c; | 320 | int_type __c; |
| 314 | streamsize __i = 0; | 321 | streamsize __i = 0; |
| 315 | while (__i < __n) { | 322 | while (__i < __n) { |
| 316 | if (__ninp_ < __einp_) { | 323 | if (gptr() < egptr()) { |
| 317 | const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(__einp_ - __ninp_, __n - __i)); | 324 | const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(egptr() - gptr(), __n - __i)); |
| 318 | traits_type::copy(__s, __ninp_, __len); | 325 | traits_type::copy(__s, gptr(), __len); |
| 319 | __s += __len; | 326 | __s += __len; |
| 320 | __i += __len; | 327 | __i += __len; |
| 321 | this->gbump(__len); | 328 | this->gbump(__len); |
| 322 | } else if ((__c = uflow()) != __eof) { | 329 | } else if ((__c = uflow()) != traits_type::eof()) { |
| 323 | *__s = traits_type::to_char_type(__c); | 330 | *__s = traits_type::to_char_type(__c); |
| 324 | ++__s; | 331 | ++__s; |
| 325 | ++__i; | 332 | ++__i; |
| ... | @@ -333,7 +340,9 @@ protected: | ... | @@ -333,7 +340,9 @@ protected: |
| 333 | virtual int_type uflow() { | 340 | virtual int_type uflow() { |
| 334 | if (underflow() == traits_type::eof()) | 341 | if (underflow() == traits_type::eof()) |
| 335 | return traits_type::eof(); | 342 | return traits_type::eof(); |
| 336 | return traits_type::to_int_type(*__ninp_++); | 343 | int_type __c = traits_type::to_int_type(*gptr()); |
| 344 | this->gbump(1); | ||
| 345 | return __c; | ||
| 337 | } | 346 | } |
| 338 | 347 | ||
| 339 | // 27.6.2.4.4 Putback: | 348 | // 27.6.2.4.4 Putback: |
| ... | @@ -342,17 +351,16 @@ protected: | ... | @@ -342,17 +351,16 @@ protected: |
| 342 | // 27.6.2.4.5 Put area: | 351 | // 27.6.2.4.5 Put area: |
| 343 | virtual streamsize xsputn(const char_type* __s, streamsize __n) { | 352 | virtual streamsize xsputn(const char_type* __s, streamsize __n) { |
| 344 | streamsize __i = 0; | 353 | streamsize __i = 0; |
| 345 | int_type __eof = traits_type::eof(); | ||
| 346 | while (__i < __n) { | 354 | while (__i < __n) { |
| 347 | if (__nout_ >= __eout_) { | 355 | if (pptr() >= epptr()) { |
| 348 | if (overflow(traits_type::to_int_type(*__s)) == __eof) | 356 | if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof()) |
| 349 | break; | 357 | break; |
| 350 | ++__s; | 358 | ++__s; |
| 351 | ++__i; | 359 | ++__i; |
| 352 | } else { | 360 | } else { |
| 353 | streamsize __chunk_size = std::min(__eout_ - __nout_, __n - __i); | 361 | streamsize __chunk_size = std::min(epptr() - pptr(), __n - __i); |
| 354 | traits_type::copy(__nout_, __s, __chunk_size); | 362 | traits_type::copy(pptr(), __s, __chunk_size); |
| 355 | __nout_ += __chunk_size; | 363 | __pbump(__chunk_size); |
| 356 | __s += __chunk_size; | 364 | __s += __chunk_size; |
| 357 | __i += __chunk_size; | 365 | __i += __chunk_size; |
| 358 | } | 366 | } |
| ... | @@ -370,6 +378,10 @@ private: | ... | @@ -370,6 +378,10 @@ private: |
| 370 | char_type* __bout_ = nullptr; | 378 | char_type* __bout_ = nullptr; |
| 371 | char_type* __nout_ = nullptr; | 379 | char_type* __nout_ = nullptr; |
| 372 | char_type* __eout_ = nullptr; | 380 | char_type* __eout_ = nullptr; |
| 381 | |||
| 382 | template <class _CharT2, class _Traits2, class _Allocator> | ||
| 383 | _LIBCPP_HIDE_FROM_ABI friend basic_istream<_CharT2, _Traits2>& | ||
| 384 | getline(basic_istream<_CharT2, _Traits2>&, basic_string<_CharT2, _Traits2, _Allocator>&, _CharT2); | ||
| 373 | }; | 385 | }; |
| 374 | 386 | ||
| 375 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>; | 387 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>; |
| ... | @@ -386,6 +398,7 @@ _LIBCPP_POP_MACROS | ... | @@ -386,6 +398,7 @@ _LIBCPP_POP_MACROS |
| 386 | 398 | ||
| 387 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | 399 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 388 | # include <cstdint> | 400 | # include <cstdint> |
| 401 | # include <optional> | ||
| 389 | # endif | 402 | # endif |
| 390 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 403 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 391 | 404 |
lib/libcxx/include/string+596-912| ... | @@ -235,9 +235,9 @@ public: | ... | @@ -235,9 +235,9 @@ public: |
| 235 | template <class T> | 235 | template <class T> |
| 236 | basic_string& insert(size_type pos1, const T& t); // constexpr since C++20 | 236 | basic_string& insert(size_type pos1, const T& t); // constexpr since C++20 |
| 237 | basic_string& insert(size_type pos1, const basic_string& str, | 237 | basic_string& insert(size_type pos1, const basic_string& str, |
| 238 | size_type pos2, size_type n); // constexpr since C++20 | 238 | size_type pos2, size_type n2=npos); // constexpr since C++20 |
| 239 | template <class T> | 239 | template <class T> |
| 240 | basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17, constexpr since C++20 | 240 | basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n=npos); // C++17, constexpr since C++20 |
| 241 | basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20 | 241 | basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20 |
| 242 | basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20 | 242 | basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20 |
| 243 | basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20 | 243 | basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20 |
| ... | @@ -260,7 +260,7 @@ public: | ... | @@ -260,7 +260,7 @@ public: |
| 260 | size_type pos2, size_type n2=npos); // C++14, constexpr since C++20 | 260 | size_type pos2, size_type n2=npos); // C++14, constexpr since C++20 |
| 261 | template <class T> | 261 | template <class T> |
| 262 | basic_string& replace(size_type pos1, size_type n1, const T& t, | 262 | basic_string& replace(size_type pos1, size_type n1, const T& t, |
| 263 | size_type pos2, size_type n); // C++17, constexpr since C++20 | 263 | size_type pos2, size_type n2=npos); // C++17, constexpr since C++20 |
| 264 | basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20 | 264 | basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20 |
| 265 | basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20 | 265 | basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20 |
| 266 | basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20 | 266 | basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20 |
| ... | @@ -516,10 +516,10 @@ basic_istream<charT, traits>& | ... | @@ -516,10 +516,10 @@ basic_istream<charT, traits>& |
| 516 | getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); | 516 | getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); |
| 517 | 517 | ||
| 518 | template<class charT, class traits, class Allocator, class U> | 518 | template<class charT, class traits, class Allocator, class U> |
| 519 | typename basic_string<charT, traits, Allocator>::size_type | 519 | constexpr typename basic_string<charT, traits, Allocator>::size_type |
| 520 | erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20 | 520 | erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20 |
| 521 | template<class charT, class traits, class Allocator, class Predicate> | 521 | template<class charT, class traits, class Allocator, class Predicate> |
| 522 | typename basic_string<charT, traits, Allocator>::size_type | 522 | constexpr typename basic_string<charT, traits, Allocator>::size_type |
| 523 | erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20 | 523 | erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20 |
| 524 | 524 | ||
| 525 | typedef basic_string<char> string; | 525 | typedef basic_string<char> string; |
| ... | @@ -630,9 +630,11 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); | ... | @@ -630,9 +630,11 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 630 | # include <__type_traits/is_convertible.h> | 630 | # include <__type_traits/is_convertible.h> |
| 631 | # include <__type_traits/is_nothrow_assignable.h> | 631 | # include <__type_traits/is_nothrow_assignable.h> |
| 632 | # include <__type_traits/is_nothrow_constructible.h> | 632 | # include <__type_traits/is_nothrow_constructible.h> |
| 633 | # include <__type_traits/is_replaceable.h> | ||
| 633 | # include <__type_traits/is_same.h> | 634 | # include <__type_traits/is_same.h> |
| 634 | # include <__type_traits/is_standard_layout.h> | 635 | # include <__type_traits/is_standard_layout.h> |
| 635 | # include <__type_traits/is_trivial.h> | 636 | # include <__type_traits/is_trivially_constructible.h> |
| 637 | # include <__type_traits/is_trivially_copyable.h> | ||
| 636 | # include <__type_traits/is_trivially_relocatable.h> | 638 | # include <__type_traits/is_trivially_relocatable.h> |
| 637 | # include <__type_traits/remove_cvref.h> | 639 | # include <__type_traits/remove_cvref.h> |
| 638 | # include <__type_traits/void_t.h> | 640 | # include <__type_traits/void_t.h> |
| ... | @@ -676,7 +678,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); | ... | @@ -676,7 +678,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 676 | _LIBCPP_PUSH_MACROS | 678 | _LIBCPP_PUSH_MACROS |
| 677 | # include <__undef_macros> | 679 | # include <__undef_macros> |
| 678 | 680 | ||
| 679 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | 681 | # if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN |
| 680 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) | 682 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) |
| 681 | // This macro disables AddressSanitizer (ASan) instrumentation for a specific function, | 683 | // This macro disables AddressSanitizer (ASan) instrumentation for a specific function, |
| 682 | // allowing memory accesses that would normally trigger ASan errors to proceed without crashing. | 684 | // allowing memory accesses that would normally trigger ASan errors to proceed without crashing. |
| ... | @@ -691,50 +693,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -691,50 +693,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 691 | 693 | ||
| 692 | // basic_string | 694 | // basic_string |
| 693 | 695 | ||
| 694 | template <class _CharT, class _Traits, class _Allocator> | ||
| 695 | basic_string<_CharT, _Traits, _Allocator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
| 696 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y); | ||
| 697 | |||
| 698 | template <class _CharT, class _Traits, class _Allocator> | ||
| 699 | _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | ||
| 700 | operator+(const _CharT* __x, const basic_string<_CharT, _Traits, _Allocator>& __y); | ||
| 701 | |||
| 702 | template <class _CharT, class _Traits, class _Allocator> | ||
| 703 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | ||
| 704 | operator+(_CharT __x, const basic_string<_CharT, _Traits, _Allocator>& __y); | ||
| 705 | |||
| 706 | template <class _CharT, class _Traits, class _Allocator> | ||
| 707 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | ||
| 708 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); | ||
| 709 | |||
| 710 | template <class _CharT, class _Traits, class _Allocator> | 696 | template <class _CharT, class _Traits, class _Allocator> |
| 711 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | 697 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 712 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); | 698 | __concatenate_strings(const _Allocator& __alloc, |
| 713 | 699 | __type_identity_t<basic_string_view<_CharT, _Traits> > __str1, | |
| 714 | # if _LIBCPP_STD_VER >= 26 | 700 | __type_identity_t<basic_string_view<_CharT, _Traits> > __str2); |
| 715 | |||
| 716 | template <class _CharT, class _Traits, class _Allocator> | ||
| 717 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 718 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | ||
| 719 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs); | ||
| 720 | |||
| 721 | template <class _CharT, class _Traits, class _Allocator> | ||
| 722 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 723 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs); | ||
| 724 | |||
| 725 | template <class _CharT, class _Traits, class _Allocator> | ||
| 726 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 727 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, | ||
| 728 | const basic_string<_CharT, _Traits, _Allocator>& __rhs); | ||
| 729 | |||
| 730 | template <class _CharT, class _Traits, class _Allocator> | ||
| 731 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 732 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs); | ||
| 733 | |||
| 734 | # endif | ||
| 735 | |||
| 736 | extern template _LIBCPP_EXPORTED_FROM_ABI string operator+ | ||
| 737 | <char, char_traits<char>, allocator<char> >(char const*, string const&); | ||
| 738 | 701 | ||
| 739 | template <class _Iter> | 702 | template <class _Iter> |
| 740 | struct __string_is_trivial_iterator : public false_type {}; | 703 | struct __string_is_trivial_iterator : public false_type {}; |
| ... | @@ -763,22 +726,19 @@ struct __padding<0> {}; | ... | @@ -763,22 +726,19 @@ struct __padding<0> {}; |
| 763 | 726 | ||
| 764 | template <class _CharT, class _Traits, class _Allocator> | 727 | template <class _CharT, class _Traits, class _Allocator> |
| 765 | class basic_string { | 728 | class basic_string { |
| 766 | private: | ||
| 767 | using __default_allocator_type _LIBCPP_NODEBUG = allocator<_CharT>; | ||
| 768 | |||
| 769 | public: | 729 | public: |
| 770 | typedef basic_string __self; | 730 | using __self _LIBCPP_NODEBUG = basic_string; |
| 771 | typedef basic_string_view<_CharT, _Traits> __self_view; | 731 | using __self_view _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>; |
| 772 | typedef _Traits traits_type; | 732 | using traits_type = _Traits; |
| 773 | typedef _CharT value_type; | 733 | using value_type = _CharT; |
| 774 | typedef _Allocator allocator_type; | 734 | using allocator_type = _Allocator; |
| 775 | typedef allocator_traits<allocator_type> __alloc_traits; | 735 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; |
| 776 | typedef typename __alloc_traits::size_type size_type; | 736 | using size_type = typename __alloc_traits::size_type; |
| 777 | typedef typename __alloc_traits::difference_type difference_type; | 737 | using difference_type = typename __alloc_traits::difference_type; |
| 778 | typedef value_type& reference; | 738 | using reference = value_type&; |
| 779 | typedef const value_type& const_reference; | 739 | using const_reference = const value_type&; |
| 780 | typedef typename __alloc_traits::pointer pointer; | 740 | using pointer = typename __alloc_traits::pointer; |
| 781 | typedef typename __alloc_traits::const_pointer const_pointer; | 741 | using const_pointer = typename __alloc_traits::const_pointer; |
| 782 | 742 | ||
| 783 | // A basic_string contains the following members which may be trivially relocatable: | 743 | // A basic_string contains the following members which may be trivially relocatable: |
| 784 | // - pointer: is currently assumed to be trivially relocatable, but is still checked in case that changes | 744 | // - pointer: is currently assumed to be trivially relocatable, but is still checked in case that changes |
| ... | @@ -789,13 +749,16 @@ public: | ... | @@ -789,13 +749,16 @@ public: |
| 789 | // | 749 | // |
| 790 | // This string implementation doesn't contain any references into itself. It only contains a bit that says whether | 750 | // This string implementation doesn't contain any references into itself. It only contains a bit that says whether |
| 791 | // it is in small or large string mode, so the entire structure is trivially relocatable if its members are. | 751 | // it is in small or large string mode, so the entire structure is trivially relocatable if its members are. |
| 792 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | 752 | # if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN |
| 793 | // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially | 753 | // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially |
| 794 | // relocatable. Because the object's memory might be poisoned when its content | 754 | // relocatable. Because the object's memory might be poisoned when its content |
| 795 | // is kept inside objects memory (short string optimization), instead of in allocated | 755 | // is kept inside objects memory (short string optimization), instead of in allocated |
| 796 | // external memory. In such cases, the destructor is responsible for unpoisoning | 756 | // external memory. In such cases, the destructor is responsible for unpoisoning |
| 797 | // the memory to avoid triggering false positives. | 757 | // the memory to avoid triggering false positives. |
| 798 | // Therefore it's crucial to ensure the destructor is called. | 758 | // Therefore it's crucial to ensure the destructor is called. |
| 759 | // | ||
| 760 | // However, it is replaceable since implementing move-assignment as a destroy + move-construct | ||
| 761 | // will maintain the right ASAN state. | ||
| 799 | using __trivially_relocatable = void; | 762 | using __trivially_relocatable = void; |
| 800 | # else | 763 | # else |
| 801 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | 764 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< |
| ... | @@ -803,8 +766,12 @@ public: | ... | @@ -803,8 +766,12 @@ public: |
| 803 | basic_string, | 766 | basic_string, |
| 804 | void>; | 767 | void>; |
| 805 | # endif | 768 | # 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>; | ||
| 806 | 773 | ||
| 807 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | 774 | # if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN |
| 808 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { | 775 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { |
| 809 | if (__libcpp_is_constant_evaluated()) | 776 | if (__libcpp_is_constant_evaluated()) |
| 810 | return __ptr; | 777 | return __ptr; |
| ... | @@ -830,7 +797,9 @@ public: | ... | @@ -830,7 +797,9 @@ public: |
| 830 | 797 | ||
| 831 | static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array"); | 798 | static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array"); |
| 832 | static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout"); | 799 | static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout"); |
| 833 | static_assert(is_trivial<value_type>::value, "Character type of basic_string must be trivial"); | 800 | static_assert(is_trivially_default_constructible<value_type>::value, |
| 801 | "Character type of basic_string must be trivially default constructible"); | ||
| 802 | static_assert(is_trivially_copyable<value_type>::value, "Character type of basic_string must be trivially copyable"); | ||
| 834 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, | 803 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, |
| 835 | "traits_type::char_type must be the same type as CharT"); | 804 | "traits_type::char_type must be the same type as CharT"); |
| 836 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | 805 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| ... | @@ -841,14 +810,14 @@ public: | ... | @@ -841,14 +810,14 @@ public: |
| 841 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's | 810 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's |
| 842 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is | 811 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is |
| 843 | // considered contiguous. | 812 | // considered contiguous. |
| 844 | typedef __bounded_iter<__wrap_iter<pointer> > iterator; | 813 | using iterator = __bounded_iter<__wrap_iter<pointer> >; |
| 845 | typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator; | 814 | using const_iterator = __bounded_iter<__wrap_iter<const_pointer> >; |
| 846 | # else | 815 | # else |
| 847 | typedef __wrap_iter<pointer> iterator; | 816 | using iterator = __wrap_iter<pointer>; |
| 848 | typedef __wrap_iter<const_pointer> const_iterator; | 817 | using const_iterator = __wrap_iter<const_pointer>; |
| 849 | # endif | 818 | # endif |
| 850 | typedef std::reverse_iterator<iterator> reverse_iterator; | 819 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 851 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | 820 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| 852 | 821 | ||
| 853 | private: | 822 | private: |
| 854 | static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); | 823 | static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); |
| ... | @@ -949,7 +918,7 @@ private: | ... | @@ -949,7 +918,7 @@ private: |
| 949 | __uninitialized_size_tag, size_type __size, const allocator_type& __a) | 918 | __uninitialized_size_tag, size_type __size, const allocator_type& __a) |
| 950 | : __alloc_(__a) { | 919 | : __alloc_(__a) { |
| 951 | if (__size > max_size()) | 920 | if (__size > max_size()) |
| 952 | __throw_length_error(); | 921 | this->__throw_length_error(); |
| 953 | if (__fits_in_sso(__size)) { | 922 | if (__fits_in_sso(__size)) { |
| 954 | __rep_ = __rep(); | 923 | __rep_ = __rep(); |
| 955 | __set_short_size(__size); | 924 | __set_short_size(__size); |
| ... | @@ -1005,7 +974,12 @@ public: | ... | @@ -1005,7 +974,12 @@ public: |
| 1005 | 974 | ||
| 1006 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string() | 975 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string() |
| 1007 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | 976 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 1008 | : __rep_() { | 977 | # if _LIBCPP_STD_VER >= 20 // TODO(LLVM 23): Remove this condition; this is a workaround for https://llvm.org/PR154567 |
| 978 | : __rep_(__short()) | ||
| 979 | # else | ||
| 980 | : __rep_() | ||
| 981 | # endif | ||
| 982 | { | ||
| 1009 | __annotate_new(0); | 983 | __annotate_new(0); |
| 1010 | } | 984 | } |
| 1011 | 985 | ||
| ... | @@ -1015,7 +989,12 @@ public: | ... | @@ -1015,7 +989,12 @@ public: |
| 1015 | # else | 989 | # else |
| 1016 | _NOEXCEPT | 990 | _NOEXCEPT |
| 1017 | # endif | 991 | # endif |
| 1018 | : __rep_(), __alloc_(__a) { | 992 | # if _LIBCPP_STD_VER >= 20 // TODO(LLVM 23): Remove this condition; this is a workaround for https://llvm.org/PR154567 |
| 993 | : __rep_(__short()), | ||
| 994 | # else | ||
| 995 | : __rep_(), | ||
| 996 | # endif | ||
| 997 | __alloc_(__a) { | ||
| 1019 | __annotate_new(0); | 998 | __annotate_new(0); |
| 1020 | } | 999 | } |
| 1021 | 1000 | ||
| ... | @@ -1079,13 +1058,14 @@ public: | ... | @@ -1079,13 +1058,14 @@ public: |
| 1079 | # endif // _LIBCPP_CXX03_LANG | 1058 | # endif // _LIBCPP_CXX03_LANG |
| 1080 | 1059 | ||
| 1081 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | 1060 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> |
| 1082 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) { | 1061 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) { |
| 1083 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr"); | 1062 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr"); |
| 1084 | __init(__s, traits_type::length(__s)); | 1063 | __init(__s, traits_type::length(__s)); |
| 1085 | } | 1064 | } |
| 1086 | 1065 | ||
| 1087 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | 1066 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> |
| 1088 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a) | 1067 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1068 | basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, const _Allocator& __a) | ||
| 1089 | : __alloc_(__a) { | 1069 | : __alloc_(__a) { |
| 1090 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); | 1070 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); |
| 1091 | __init(__s, traits_type::length(__s)); | 1071 | __init(__s, traits_type::length(__s)); |
| ... | @@ -1118,7 +1098,7 @@ public: | ... | @@ -1118,7 +1098,7 @@ public: |
| 1118 | basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator()) | 1098 | basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator()) |
| 1119 | : __alloc_(__alloc) { | 1099 | : __alloc_(__alloc) { |
| 1120 | if (__pos > __str.size()) | 1100 | if (__pos > __str.size()) |
| 1121 | __throw_out_of_range(); | 1101 | this->__throw_out_of_range(); |
| 1122 | 1102 | ||
| 1123 | auto __len = std::min<size_type>(__n, __str.size() - __pos); | 1103 | auto __len = std::min<size_type>(__n, __str.size() - __pos); |
| 1124 | if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc_) { | 1104 | if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc_) { |
| ... | @@ -1141,7 +1121,7 @@ public: | ... | @@ -1141,7 +1121,7 @@ public: |
| 1141 | : __alloc_(__a) { | 1121 | : __alloc_(__a) { |
| 1142 | size_type __str_sz = __str.size(); | 1122 | size_type __str_sz = __str.size(); |
| 1143 | if (__pos > __str_sz) | 1123 | if (__pos > __str_sz) |
| 1144 | __throw_out_of_range(); | 1124 | this->__throw_out_of_range(); |
| 1145 | __init(__str.data() + __pos, std::min(__n, __str_sz - __pos)); | 1125 | __init(__str.data() + __pos, std::min(__n, __str_sz - __pos)); |
| 1146 | } | 1126 | } |
| 1147 | 1127 | ||
| ... | @@ -1150,15 +1130,15 @@ public: | ... | @@ -1150,15 +1130,15 @@ public: |
| 1150 | : __alloc_(__a) { | 1130 | : __alloc_(__a) { |
| 1151 | size_type __str_sz = __str.size(); | 1131 | size_type __str_sz = __str.size(); |
| 1152 | if (__pos > __str_sz) | 1132 | if (__pos > __str_sz) |
| 1153 | __throw_out_of_range(); | 1133 | this->__throw_out_of_range(); |
| 1154 | __init(__str.data() + __pos, __str_sz - __pos); | 1134 | __init(__str.data() + __pos, __str_sz - __pos); |
| 1155 | } | 1135 | } |
| 1156 | 1136 | ||
| 1157 | template <class _Tp, | 1137 | template <class _Tp, |
| 1158 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1138 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1159 | !__is_same_uncvref<_Tp, basic_string>::value, | 1139 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1160 | int> = 0> | 1140 | int> = 0> |
| 1161 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1141 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1162 | basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type()) | 1142 | basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type()) |
| 1163 | : __alloc_(__a) { | 1143 | : __alloc_(__a) { |
| 1164 | __self_view __sv0 = __t; | 1144 | __self_view __sv0 = __t; |
| ... | @@ -1168,20 +1148,18 @@ public: | ... | @@ -1168,20 +1148,18 @@ public: |
| 1168 | 1148 | ||
| 1169 | template <class _Tp, | 1149 | template <class _Tp, |
| 1170 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1150 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1171 | !__is_same_uncvref<_Tp, basic_string>::value, | 1151 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1172 | int> = 0> | 1152 | int> = 0> |
| 1173 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1153 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) { |
| 1174 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) { | ||
| 1175 | __self_view __sv = __t; | 1154 | __self_view __sv = __t; |
| 1176 | __init(__sv.data(), __sv.size()); | 1155 | __init(__sv.data(), __sv.size()); |
| 1177 | } | 1156 | } |
| 1178 | 1157 | ||
| 1179 | template <class _Tp, | 1158 | template <class _Tp, |
| 1180 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1159 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1181 | !__is_same_uncvref<_Tp, basic_string>::value, | 1160 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1182 | int> = 0> | 1161 | int> = 0> |
| 1183 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | 1162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a) |
| 1184 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a) | ||
| 1185 | : __alloc_(__a) { | 1163 | : __alloc_(__a) { |
| 1186 | __self_view __sv = __t; | 1164 | __self_view __sv = __t; |
| 1187 | __init(__sv.data(), __sv.size()); | 1165 | __init(__sv.data(), __sv.size()); |
| ... | @@ -1238,7 +1216,7 @@ public: | ... | @@ -1238,7 +1216,7 @@ public: |
| 1238 | 1216 | ||
| 1239 | template <class _Tp, | 1217 | template <class _Tp, |
| 1240 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1218 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1241 | !__is_same_uncvref<_Tp, basic_string>::value, | 1219 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1242 | int> = 0> | 1220 | int> = 0> |
| 1243 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) { | 1221 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) { |
| 1244 | __self_view __sv = __t; | 1222 | __self_view __sv = __t; |
| ... | @@ -1256,7 +1234,8 @@ public: | ... | @@ -1256,7 +1234,8 @@ public: |
| 1256 | return assign(__il.begin(), __il.size()); | 1234 | return assign(__il.begin(), __il.size()); |
| 1257 | } | 1235 | } |
| 1258 | # endif | 1236 | # endif |
| 1259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) { | 1237 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1238 | operator=(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) { | ||
| 1260 | return assign(__s); | 1239 | return assign(__s); |
| 1261 | } | 1240 | } |
| 1262 | # if _LIBCPP_STD_VER >= 23 | 1241 | # if _LIBCPP_STD_VER >= 23 |
| ... | @@ -1303,12 +1282,20 @@ public: | ... | @@ -1303,12 +1282,20 @@ public: |
| 1303 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); } | 1282 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); } |
| 1304 | 1283 | ||
| 1305 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT { | 1284 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT { |
| 1306 | size_type __m = __alloc_traits::max_size(__alloc_); | 1285 | if (size_type __m = __alloc_traits::max_size(__alloc_); __m <= std::numeric_limits<size_type>::max() / 2) { |
| 1307 | if (__m <= std::numeric_limits<size_type>::max() / 2) { | 1286 | size_type __res = __m - __alignment; |
| 1308 | return __m - __alignment; | 1287 | |
| 1288 | // When the __endian_factor == 2, our string representation assumes that the capacity | ||
| 1289 | // (including the null terminator) is always even, so we have to make sure the lowest bit isn't set when the | ||
| 1290 | // string grows to max_size() | ||
| 1291 | if (__endian_factor == 2) | ||
| 1292 | __res &= ~size_type(1); | ||
| 1293 | |||
| 1294 | // We have to allocate space for the null terminator, but max_size() doesn't include it. | ||
| 1295 | return __res - 1; | ||
| 1309 | } else { | 1296 | } else { |
| 1310 | bool __uses_lsb = __endian_factor == 2; | 1297 | bool __uses_lsb = __endian_factor == 2; |
| 1311 | return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment; | 1298 | return __uses_lsb ? __m - __alignment - 1 : (__m / 2) - __alignment - 1; |
| 1312 | } | 1299 | } |
| 1313 | } | 1300 | } |
| 1314 | 1301 | ||
| ... | @@ -1366,15 +1353,15 @@ public: | ... | @@ -1366,15 +1353,15 @@ public: |
| 1366 | 1353 | ||
| 1367 | template <class _Tp, | 1354 | template <class _Tp, |
| 1368 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1355 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1369 | !__is_same_uncvref<_Tp, basic_string >::value, | 1356 | !is_same<__remove_cvref_t<_Tp>, basic_string >::value, |
| 1370 | int> = 0> | 1357 | int> = 0> |
| 1371 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1358 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const _Tp& __t) { |
| 1372 | operator+=(const _Tp& __t) { | ||
| 1373 | __self_view __sv = __t; | 1359 | __self_view __sv = __t; |
| 1374 | return append(__sv); | 1360 | return append(__sv); |
| 1375 | } | 1361 | } |
| 1376 | 1362 | ||
| 1377 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const value_type* __s) { | 1363 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1364 | operator+=(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) { | ||
| 1378 | return append(__s); | 1365 | return append(__s); |
| 1379 | } | 1366 | } |
| 1380 | 1367 | ||
| ... | @@ -1395,10 +1382,9 @@ public: | ... | @@ -1395,10 +1382,9 @@ public: |
| 1395 | 1382 | ||
| 1396 | template <class _Tp, | 1383 | template <class _Tp, |
| 1397 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1384 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1398 | !__is_same_uncvref<_Tp, basic_string>::value, | 1385 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1399 | int> = 0> | 1386 | int> = 0> |
| 1400 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1387 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const _Tp& __t) { |
| 1401 | append(const _Tp& __t) { | ||
| 1402 | __self_view __sv = __t; | 1388 | __self_view __sv = __t; |
| 1403 | return append(__sv.data(), __sv.size()); | 1389 | return append(__sv.data(), __sv.size()); |
| 1404 | } | 1390 | } |
| ... | @@ -1407,21 +1393,25 @@ public: | ... | @@ -1407,21 +1393,25 @@ public: |
| 1407 | 1393 | ||
| 1408 | template <class _Tp, | 1394 | template <class _Tp, |
| 1409 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1395 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1410 | !__is_same_uncvref<_Tp, basic_string>::value, | 1396 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1411 | int> = 0> | 1397 | int> = 0> |
| 1412 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 | 1398 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1413 | 1399 | append(const _Tp& __t, size_type __pos, size_type __n = npos) { | |
| 1414 | basic_string& | 1400 | __self_view __sv = __t; |
| 1415 | append(const _Tp& __t, size_type __pos, size_type __n = npos); | 1401 | size_type __sz = __sv.size(); |
| 1402 | if (__pos > __sz) | ||
| 1403 | __throw_out_of_range(); | ||
| 1404 | return append(__sv.data() + __pos, std::min(__n, __sz - __pos)); | ||
| 1405 | } | ||
| 1416 | 1406 | ||
| 1417 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n); | 1407 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n); |
| 1418 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s); | 1408 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); |
| 1419 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c); | 1409 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c); |
| 1420 | 1410 | ||
| 1421 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append_default_init(size_type __n); | 1411 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append_default_init(size_type __n); |
| 1422 | 1412 | ||
| 1423 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | 1413 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1424 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1414 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1425 | append(_InputIterator __first, _InputIterator __last) { | 1415 | append(_InputIterator __first, _InputIterator __last) { |
| 1426 | const basic_string __temp(__first, __last, __alloc_); | 1416 | const basic_string __temp(__first, __last, __alloc_); |
| 1427 | append(__temp.data(), __temp.size()); | 1417 | append(__temp.data(), __temp.size()); |
| ... | @@ -1429,8 +1419,26 @@ public: | ... | @@ -1429,8 +1419,26 @@ public: |
| 1429 | } | 1419 | } |
| 1430 | 1420 | ||
| 1431 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | 1421 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> |
| 1432 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1422 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1433 | append(_ForwardIterator __first, _ForwardIterator __last); | 1423 | append(_ForwardIterator __first, _ForwardIterator __last) { |
| 1424 | size_type __sz = size(); | ||
| 1425 | size_type __cap = capacity(); | ||
| 1426 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | ||
| 1427 | if (__n) { | ||
| 1428 | if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) { | ||
| 1429 | if (__cap - __sz < __n) | ||
| 1430 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); | ||
| 1431 | __annotate_increase(__n); | ||
| 1432 | auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz)); | ||
| 1433 | traits_type::assign(*__end, value_type()); | ||
| 1434 | __set_size(__sz + __n); | ||
| 1435 | } else { | ||
| 1436 | const basic_string __temp(__first, __last, __alloc_); | ||
| 1437 | append(__temp.data(), __temp.size()); | ||
| 1438 | } | ||
| 1439 | } | ||
| 1440 | return *this; | ||
| 1441 | } | ||
| 1434 | 1442 | ||
| 1435 | # if _LIBCPP_STD_VER >= 23 | 1443 | # if _LIBCPP_STD_VER >= 23 |
| 1436 | template <_ContainerCompatibleRange<_CharT> _Range> | 1444 | template <_ContainerCompatibleRange<_CharT> _Range> |
| ... | @@ -1470,8 +1478,7 @@ public: | ... | @@ -1470,8 +1478,7 @@ public: |
| 1470 | } | 1478 | } |
| 1471 | 1479 | ||
| 1472 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1480 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1473 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1481 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const _Tp& __t) { |
| 1474 | assign(const _Tp& __t) { | ||
| 1475 | __self_view __sv = __t; | 1482 | __self_view __sv = __t; |
| 1476 | return assign(__sv.data(), __sv.size()); | 1483 | return assign(__sv.data(), __sv.size()); |
| 1477 | } | 1484 | } |
| ... | @@ -1513,21 +1520,40 @@ public: | ... | @@ -1513,21 +1520,40 @@ public: |
| 1513 | 1520 | ||
| 1514 | template <class _Tp, | 1521 | template <class _Tp, |
| 1515 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1522 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1516 | !__is_same_uncvref<_Tp, basic_string>::value, | 1523 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1517 | int> = 0> | 1524 | int> = 0> |
| 1518 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1525 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1519 | assign(const _Tp& __t, size_type __pos, size_type __n = npos); | 1526 | assign(const _Tp& __t, size_type __pos, size_type __n = npos) { |
| 1527 | __self_view __sv = __t; | ||
| 1528 | size_type __sz = __sv.size(); | ||
| 1529 | if (__pos > __sz) | ||
| 1530 | __throw_out_of_range(); | ||
| 1531 | return assign(__sv.data() + __pos, std::min(__n, __sz - __pos)); | ||
| 1532 | } | ||
| 1520 | 1533 | ||
| 1521 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n); | 1534 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n); |
| 1522 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s); | 1535 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s); |
| 1523 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c); | 1536 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c); |
| 1537 | |||
| 1524 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | 1538 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1525 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1539 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1526 | assign(_InputIterator __first, _InputIterator __last); | 1540 | assign(_InputIterator __first, _InputIterator __last) { |
| 1541 | __assign_with_sentinel(__first, __last); | ||
| 1542 | return *this; | ||
| 1543 | } | ||
| 1527 | 1544 | ||
| 1528 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | 1545 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> |
| 1529 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1546 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1530 | assign(_ForwardIterator __first, _ForwardIterator __last); | 1547 | assign(_ForwardIterator __first, _ForwardIterator __last) { |
| 1548 | if (__string_is_trivial_iterator<_ForwardIterator>::value) { | ||
| 1549 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | ||
| 1550 | __assign_trivial(__first, __last, __n); | ||
| 1551 | } else { | ||
| 1552 | __assign_with_sentinel(__first, __last); | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | return *this; | ||
| 1556 | } | ||
| 1531 | 1557 | ||
| 1532 | # if _LIBCPP_STD_VER >= 23 | 1558 | # if _LIBCPP_STD_VER >= 23 |
| 1533 | template <_ContainerCompatibleRange<_CharT> _Range> | 1559 | template <_ContainerCompatibleRange<_CharT> _Range> |
| ... | @@ -1557,23 +1583,28 @@ public: | ... | @@ -1557,23 +1583,28 @@ public: |
| 1557 | } | 1583 | } |
| 1558 | 1584 | ||
| 1559 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1585 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1560 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1586 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos1, const _Tp& __t) { |
| 1561 | insert(size_type __pos1, const _Tp& __t) { | ||
| 1562 | __self_view __sv = __t; | 1587 | __self_view __sv = __t; |
| 1563 | return insert(__pos1, __sv.data(), __sv.size()); | 1588 | return insert(__pos1, __sv.data(), __sv.size()); |
| 1564 | } | 1589 | } |
| 1565 | 1590 | ||
| 1566 | template <class _Tp, | 1591 | template <class _Tp, |
| 1567 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1592 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1568 | !__is_same_uncvref<_Tp, basic_string>::value, | 1593 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1569 | int> = 0> | 1594 | int> = 0> |
| 1570 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1595 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1571 | insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n = npos); | 1596 | insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n = npos) { |
| 1597 | __self_view __sv = __t; | ||
| 1598 | size_type __str_sz = __sv.size(); | ||
| 1599 | if (__pos2 > __str_sz) | ||
| 1600 | __throw_out_of_range(); | ||
| 1601 | return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2)); | ||
| 1602 | } | ||
| 1572 | 1603 | ||
| 1573 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1604 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1574 | insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos); | 1605 | insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos); |
| 1575 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n); | 1606 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n); |
| 1576 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s); | 1607 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s); |
| 1577 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c); | 1608 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c); |
| 1578 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c); | 1609 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c); |
| 1579 | 1610 | ||
| ... | @@ -1599,12 +1630,18 @@ public: | ... | @@ -1599,12 +1630,18 @@ public: |
| 1599 | } | 1630 | } |
| 1600 | 1631 | ||
| 1601 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | 1632 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1602 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | 1633 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| 1603 | insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); | 1634 | insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { |
| 1635 | const basic_string __temp(__first, __last, __alloc_); | ||
| 1636 | return insert(__pos, __temp.data(), __temp.data() + __temp.size()); | ||
| 1637 | } | ||
| 1604 | 1638 | ||
| 1605 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | 1639 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> |
| 1606 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | 1640 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| 1607 | insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); | 1641 | insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) { |
| 1642 | auto __n = static_cast<size_type>(std::distance(__first, __last)); | ||
| 1643 | return __insert_with_size(__pos, __first, __last, __n); | ||
| 1644 | } | ||
| 1608 | 1645 | ||
| 1609 | # ifndef _LIBCPP_CXX03_LANG | 1646 | # ifndef _LIBCPP_CXX03_LANG |
| 1610 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | 1647 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| ... | @@ -1623,7 +1660,7 @@ public: | ... | @@ -1623,7 +1660,7 @@ public: |
| 1623 | } | 1660 | } |
| 1624 | 1661 | ||
| 1625 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1662 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1626 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1663 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1627 | replace(size_type __pos1, size_type __n1, const _Tp& __t) { | 1664 | replace(size_type __pos1, size_type __n1, const _Tp& __t) { |
| 1628 | __self_view __sv = __t; | 1665 | __self_view __sv = __t; |
| 1629 | return replace(__pos1, __n1, __sv.data(), __sv.size()); | 1666 | return replace(__pos1, __n1, __sv.data(), __sv.size()); |
| ... | @@ -1634,10 +1671,16 @@ public: | ... | @@ -1634,10 +1671,16 @@ public: |
| 1634 | 1671 | ||
| 1635 | template <class _Tp, | 1672 | template <class _Tp, |
| 1636 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 1673 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1637 | !__is_same_uncvref<_Tp, basic_string>::value, | 1674 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1638 | int> = 0> | 1675 | int> = 0> |
| 1639 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1676 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1640 | replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos); | 1677 | replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) { |
| 1678 | __self_view __sv = __t; | ||
| 1679 | size_type __str_sz = __sv.size(); | ||
| 1680 | if (__pos2 > __str_sz) | ||
| 1681 | __throw_out_of_range(); | ||
| 1682 | return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2)); | ||
| 1683 | } | ||
| 1641 | 1684 | ||
| 1642 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1685 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1643 | replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); | 1686 | replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); |
| ... | @@ -1651,7 +1694,7 @@ public: | ... | @@ -1651,7 +1694,7 @@ public: |
| 1651 | } | 1694 | } |
| 1652 | 1695 | ||
| 1653 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1696 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1654 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1697 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1655 | replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { | 1698 | replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { |
| 1656 | __self_view __sv = __t; | 1699 | __self_view __sv = __t; |
| 1657 | return replace(__i1 - begin(), __i2 - __i1, __sv); | 1700 | return replace(__i1 - begin(), __i2 - __i1, __sv); |
| ... | @@ -1673,8 +1716,11 @@ public: | ... | @@ -1673,8 +1716,11 @@ public: |
| 1673 | } | 1716 | } |
| 1674 | 1717 | ||
| 1675 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> | 1718 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1676 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& | 1719 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1677 | replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); | 1720 | replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) { |
| 1721 | const basic_string __temp(__j1, __j2, __alloc_); | ||
| 1722 | return replace(__i1, __i2, __temp); | ||
| 1723 | } | ||
| 1678 | 1724 | ||
| 1679 | # if _LIBCPP_STD_VER >= 23 | 1725 | # if _LIBCPP_STD_VER >= 23 |
| 1680 | template <_ContainerCompatibleRange<_CharT> _Range> | 1726 | template <_ContainerCompatibleRange<_CharT> _Range> |
| ... | @@ -1716,6 +1762,9 @@ public: | ... | @@ -1716,6 +1762,9 @@ public: |
| 1716 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); | 1762 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 1717 | # endif | 1763 | # endif |
| 1718 | 1764 | ||
| 1765 | // [string.ops] | ||
| 1766 | // ------------ | ||
| 1767 | |||
| 1719 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } | 1768 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } |
| 1720 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT { | 1769 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT { |
| 1721 | return std::__to_address(__get_pointer()); | 1770 | return std::__to_address(__get_pointer()); |
| ... | @@ -1730,113 +1779,267 @@ public: | ... | @@ -1730,113 +1779,267 @@ public: |
| 1730 | return __alloc_; | 1779 | return __alloc_; |
| 1731 | } | 1780 | } |
| 1732 | 1781 | ||
| 1782 | // find | ||
| 1783 | |||
| 1733 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1784 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1734 | find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; | 1785 | find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { |
| 1786 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size()); | ||
| 1787 | } | ||
| 1735 | 1788 | ||
| 1736 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1789 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1737 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1790 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1738 | find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; | 1791 | find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { |
| 1792 | __self_view __sv = __t; | ||
| 1793 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 1794 | } | ||
| 1795 | |||
| 1796 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 1797 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr"); | ||
| 1798 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 1799 | } | ||
| 1739 | 1800 | ||
| 1740 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | ||
| 1741 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1801 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1742 | find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; | 1802 | find(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 1743 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; | 1803 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr"); |
| 1804 | return std::__str_find<value_type, size_type, traits_type, npos>( | ||
| 1805 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 1806 | } | ||
| 1807 | |||
| 1808 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT { | ||
| 1809 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 1810 | } | ||
| 1811 | |||
| 1812 | // rfind | ||
| 1744 | 1813 | ||
| 1745 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1814 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1746 | rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; | 1815 | rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { |
| 1816 | return std::__str_rfind<value_type, size_type, traits_type, npos>( | ||
| 1817 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 1818 | } | ||
| 1747 | 1819 | ||
| 1748 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1820 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1749 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1821 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1750 | rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; | 1822 | rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { |
| 1823 | __self_view __sv = __t; | ||
| 1824 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 1825 | } | ||
| 1826 | |||
| 1827 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 1828 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); | ||
| 1829 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 1830 | } | ||
| 1751 | 1831 | ||
| 1752 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | ||
| 1753 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1832 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1754 | rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; | 1833 | rfind(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 1755 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; | 1834 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr"); |
| 1835 | return std::__str_rfind<value_type, size_type, traits_type, npos>( | ||
| 1836 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 1837 | } | ||
| 1838 | |||
| 1839 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT { | ||
| 1840 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | // find_first_of | ||
| 1756 | 1844 | ||
| 1757 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1845 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1758 | find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; | 1846 | find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { |
| 1847 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | ||
| 1848 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 1849 | } | ||
| 1759 | 1850 | ||
| 1760 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1851 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1761 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1852 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1762 | find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; | 1853 | find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { |
| 1854 | __self_view __sv = __t; | ||
| 1855 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | ||
| 1856 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 1857 | } | ||
| 1763 | 1858 | ||
| 1764 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1859 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1765 | find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1860 | find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { |
| 1861 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); | ||
| 1862 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 1863 | } | ||
| 1864 | |||
| 1766 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1865 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1767 | find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; | 1866 | find_first_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 1867 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr"); | ||
| 1868 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | ||
| 1869 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 1870 | } | ||
| 1871 | |||
| 1768 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1872 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1769 | find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; | 1873 | find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { |
| 1874 | return find(__c, __pos); | ||
| 1875 | } | ||
| 1876 | |||
| 1877 | // find_last_of | ||
| 1770 | 1878 | ||
| 1771 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1879 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1772 | find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; | 1880 | find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { |
| 1881 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | ||
| 1882 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 1883 | } | ||
| 1773 | 1884 | ||
| 1774 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1885 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1775 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1886 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1776 | find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; | 1887 | find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { |
| 1888 | __self_view __sv = __t; | ||
| 1889 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | ||
| 1890 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 1891 | } | ||
| 1777 | 1892 | ||
| 1778 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1893 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1779 | find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1894 | find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { |
| 1895 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); | ||
| 1896 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 1897 | } | ||
| 1898 | |||
| 1780 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1899 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1781 | find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; | 1900 | find_last_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 1901 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr"); | ||
| 1902 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | ||
| 1903 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 1904 | } | ||
| 1905 | |||
| 1782 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1906 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1783 | find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; | 1907 | find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { |
| 1908 | return rfind(__c, __pos); | ||
| 1909 | } | ||
| 1910 | |||
| 1911 | // find_first_not_of | ||
| 1784 | 1912 | ||
| 1785 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1913 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1786 | find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; | 1914 | find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT { |
| 1915 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | ||
| 1916 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 1917 | } | ||
| 1787 | 1918 | ||
| 1788 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1919 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1789 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1920 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1790 | find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; | 1921 | find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT { |
| 1922 | __self_view __sv = __t; | ||
| 1923 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | ||
| 1924 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 1925 | } | ||
| 1791 | 1926 | ||
| 1792 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1927 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1793 | find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1928 | find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { |
| 1929 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); | ||
| 1930 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 1931 | } | ||
| 1932 | |||
| 1794 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1933 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1795 | find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; | 1934 | find_first_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT { |
| 1935 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr"); | ||
| 1936 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | ||
| 1937 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 1938 | } | ||
| 1939 | |||
| 1796 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1940 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1797 | find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; | 1941 | find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT { |
| 1942 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 1943 | } | ||
| 1944 | |||
| 1945 | // find_last_not_of | ||
| 1798 | 1946 | ||
| 1799 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1947 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1800 | find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; | 1948 | find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT { |
| 1949 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | ||
| 1950 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 1951 | } | ||
| 1801 | 1952 | ||
| 1802 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1953 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1803 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1954 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1804 | find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; | 1955 | find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT { |
| 1956 | __self_view __sv = __t; | ||
| 1957 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | ||
| 1958 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 1959 | } | ||
| 1805 | 1960 | ||
| 1806 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1961 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1807 | find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; | 1962 | find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { |
| 1963 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); | ||
| 1964 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 1965 | } | ||
| 1966 | |||
| 1808 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1967 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1809 | find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; | 1968 | find_last_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT { |
| 1969 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr"); | ||
| 1970 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | ||
| 1971 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 1972 | } | ||
| 1973 | |||
| 1810 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 1974 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 1811 | find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; | 1975 | find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT { |
| 1976 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 1977 | } | ||
| 1812 | 1978 | ||
| 1813 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT; | 1979 | // compare |
| 1980 | |||
| 1981 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT { | ||
| 1982 | return compare(__self_view(__str)); | ||
| 1983 | } | ||
| 1814 | 1984 | ||
| 1815 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 1985 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1816 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 1986 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const _Tp& __t) const _NOEXCEPT { |
| 1817 | compare(const _Tp& __t) const _NOEXCEPT; | 1987 | __self_view __sv = __t; |
| 1988 | size_t __lhs_sz = size(); | ||
| 1989 | size_t __rhs_sz = __sv.size(); | ||
| 1990 | int __result = traits_type::compare(data(), __sv.data(), std::min(__lhs_sz, __rhs_sz)); | ||
| 1991 | if (__result != 0) | ||
| 1992 | return __result; | ||
| 1993 | if (__lhs_sz < __rhs_sz) | ||
| 1994 | return -1; | ||
| 1995 | if (__lhs_sz > __rhs_sz) | ||
| 1996 | return 1; | ||
| 1997 | return 0; | ||
| 1998 | } | ||
| 1818 | 1999 | ||
| 1819 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> | 2000 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0> |
| 1820 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2001 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 1821 | compare(size_type __pos1, size_type __n1, const _Tp& __t) const; | 2002 | compare(size_type __pos1, size_type __n1, const _Tp& __t) const { |
| 2003 | __self_view __sv = __t; | ||
| 2004 | return compare(__pos1, __n1, __sv.data(), __sv.size()); | ||
| 2005 | } | ||
| 1822 | 2006 | ||
| 1823 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2007 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 1824 | compare(size_type __pos1, size_type __n1, const basic_string& __str) const; | 2008 | compare(size_type __pos1, size_type __n1, const basic_string& __str) const { |
| 2009 | return compare(__pos1, __n1, __str.data(), __str.size()); | ||
| 2010 | } | ||
| 2011 | |||
| 1825 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2012 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 1826 | compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const; | 2013 | compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const { |
| 2014 | return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); | ||
| 2015 | } | ||
| 1827 | 2016 | ||
| 1828 | template <class _Tp, | 2017 | template <class _Tp, |
| 1829 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | 2018 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1830 | !__is_same_uncvref<_Tp, basic_string>::value, | 2019 | !is_same<__remove_cvref_t<_Tp>, basic_string>::value, |
| 1831 | int> = 0> | 2020 | int> = 0> |
| 1832 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2021 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 1833 | compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const; | 2022 | compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const { |
| 2023 | __self_view __sv = __t; | ||
| 2024 | return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); | ||
| 2025 | } | ||
| 2026 | |||
| 2027 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const _NOEXCEPT { | ||
| 2028 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); | ||
| 2029 | return compare(0, npos, __s, traits_type::length(__s)); | ||
| 2030 | } | ||
| 2031 | |||
| 2032 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | ||
| 2033 | compare(size_type __pos1, size_type __n1, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const { | ||
| 2034 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); | ||
| 2035 | return compare(__pos1, __n1, __s, traits_type::length(__s)); | ||
| 2036 | } | ||
| 1834 | 2037 | ||
| 1835 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT; | ||
| 1836 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const; | ||
| 1837 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | 2038 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 1838 | compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; | 2039 | compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; |
| 1839 | 2040 | ||
| 2041 | // starts_with | ||
| 2042 | |||
| 1840 | # if _LIBCPP_STD_VER >= 20 | 2043 | # if _LIBCPP_STD_VER >= 20 |
| 1841 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { | 2044 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { |
| 1842 | return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); | 2045 | return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); |
| ... | @@ -1846,10 +2049,12 @@ public: | ... | @@ -1846,10 +2049,12 @@ public: |
| 1846 | return !empty() && _Traits::eq(front(), __c); | 2049 | return !empty() && _Traits::eq(front(), __c); |
| 1847 | } | 2050 | } |
| 1848 | 2051 | ||
| 1849 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* __s) const noexcept { | 2052 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { |
| 1850 | return starts_with(__self_view(__s)); | 2053 | return starts_with(__self_view(__s)); |
| 1851 | } | 2054 | } |
| 1852 | 2055 | ||
| 2056 | // ends_with | ||
| 2057 | |||
| 1853 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { | 2058 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { |
| 1854 | return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv); | 2059 | return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv); |
| 1855 | } | 2060 | } |
| ... | @@ -1858,11 +2063,13 @@ public: | ... | @@ -1858,11 +2063,13 @@ public: |
| 1858 | return !empty() && _Traits::eq(back(), __c); | 2063 | return !empty() && _Traits::eq(back(), __c); |
| 1859 | } | 2064 | } |
| 1860 | 2065 | ||
| 1861 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept { | 2066 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept { |
| 1862 | return ends_with(__self_view(__s)); | 2067 | return ends_with(__self_view(__s)); |
| 1863 | } | 2068 | } |
| 1864 | # endif | 2069 | # endif |
| 1865 | 2070 | ||
| 2071 | // contains | ||
| 2072 | |||
| 1866 | # if _LIBCPP_STD_VER >= 23 | 2073 | # if _LIBCPP_STD_VER >= 23 |
| 1867 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { | 2074 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { |
| 1868 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); | 2075 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); |
| ... | @@ -1872,18 +2079,14 @@ public: | ... | @@ -1872,18 +2079,14 @@ public: |
| 1872 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c); | 2079 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c); |
| 1873 | } | 2080 | } |
| 1874 | 2081 | ||
| 1875 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { | 2082 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const { |
| 1876 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s); | 2083 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s); |
| 1877 | } | 2084 | } |
| 1878 | # endif | 2085 | # endif |
| 1879 | 2086 | ||
| 1880 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; | 2087 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; |
| 1881 | 2088 | ||
| 1882 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT; | ||
| 1883 | |||
| 1884 | private: | 2089 | private: |
| 1885 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity); | ||
| 1886 | |||
| 1887 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool | 2090 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool |
| 1888 | __is_long() const _NOEXCEPT { | 2091 | __is_long() const _NOEXCEPT { |
| 1889 | if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) { | 2092 | if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) { |
| ... | @@ -2038,7 +2241,7 @@ private: | ... | @@ -2038,7 +2241,7 @@ private: |
| 2038 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { | 2241 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { |
| 2039 | (void)__old_mid; | 2242 | (void)__old_mid; |
| 2040 | (void)__new_mid; | 2243 | (void)__new_mid; |
| 2041 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | 2244 | # if _LIBCPP_INSTRUMENTED_WITH_ASAN |
| 2042 | # if defined(__APPLE__) | 2245 | # if defined(__APPLE__) |
| 2043 | // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) | 2246 | // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) |
| 2044 | if (!__is_long()) | 2247 | if (!__is_long()) |
| ... | @@ -2049,36 +2252,36 @@ private: | ... | @@ -2049,36 +2252,36 @@ private: |
| 2049 | } | 2252 | } |
| 2050 | 2253 | ||
| 2051 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT { | 2254 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| 2052 | (void)__current_size; | 2255 | __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1); |
| 2053 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | ||
| 2054 | if (!__libcpp_is_constant_evaluated()) | ||
| 2055 | __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1); | ||
| 2056 | # endif | ||
| 2057 | } | 2256 | } |
| 2058 | 2257 | ||
| 2059 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT { | 2258 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT { |
| 2060 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | 2259 | __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1); |
| 2061 | if (!__libcpp_is_constant_evaluated()) | ||
| 2062 | __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1); | ||
| 2063 | # endif | ||
| 2064 | } | 2260 | } |
| 2065 | 2261 | ||
| 2066 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT { | 2262 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT { |
| 2067 | (void)__n; | 2263 | __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n); |
| 2068 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | ||
| 2069 | if (!__libcpp_is_constant_evaluated()) | ||
| 2070 | __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n); | ||
| 2071 | # endif | ||
| 2072 | } | 2264 | } |
| 2073 | 2265 | ||
| 2074 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT { | 2266 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT { |
| 2075 | (void)__old_size; | 2267 | __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1); |
| 2076 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | ||
| 2077 | if (!__libcpp_is_constant_evaluated()) | ||
| 2078 | __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1); | ||
| 2079 | # endif | ||
| 2080 | } | 2268 | } |
| 2081 | 2269 | ||
| 2270 | // Disable ASan annotations and enable them again when going out of scope. It is assumed that the string is in a valid | ||
| 2271 | // state at that point, so `size()` can be called safely. | ||
| 2272 | struct [[__nodiscard__]] __annotation_guard { | ||
| 2273 | __annotation_guard(const __annotation_guard&) = delete; | ||
| 2274 | __annotation_guard& operator=(const __annotation_guard&) = delete; | ||
| 2275 | |||
| 2276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __annotation_guard(basic_string& __str) : __str_(__str) { | ||
| 2277 | __str_.__annotate_delete(); | ||
| 2278 | } | ||
| 2279 | |||
| 2280 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__annotation_guard() { __str_.__annotate_new(__str_.size()); } | ||
| 2281 | |||
| 2282 | basic_string& __str_; | ||
| 2283 | }; | ||
| 2284 | |||
| 2082 | template <size_type __a> | 2285 | template <size_type __a> |
| 2083 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT { | 2286 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT { |
| 2084 | return (__s + (__a - 1)) & ~(__a - 1); | 2287 | return (__s + (__a - 1)) & ~(__a - 1); |
| ... | @@ -2097,7 +2300,6 @@ private: | ... | @@ -2097,7 +2300,6 @@ private: |
| 2097 | return __guess; | 2300 | return __guess; |
| 2098 | } | 2301 | } |
| 2099 | 2302 | ||
| 2100 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz, size_type __reserve); | ||
| 2101 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz); | 2303 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz); |
| 2102 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c); | 2304 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c); |
| 2103 | 2305 | ||
| ... | @@ -2176,7 +2378,11 @@ private: | ... | @@ -2176,7 +2378,11 @@ private: |
| 2176 | __alloc_ = __str.__alloc_; | 2378 | __alloc_ = __str.__alloc_; |
| 2177 | else { | 2379 | else { |
| 2178 | if (!__str.__is_long()) { | 2380 | if (!__str.__is_long()) { |
| 2179 | __clear_and_shrink(); | 2381 | if (__is_long()) { |
| 2382 | __annotate_delete(); | ||
| 2383 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 2384 | __rep_ = __rep(); | ||
| 2385 | } | ||
| 2180 | __alloc_ = __str.__alloc_; | 2386 | __alloc_ = __str.__alloc_; |
| 2181 | } else { | 2387 | } else { |
| 2182 | __annotate_delete(); | 2388 | __annotate_delete(); |
| ... | @@ -2189,7 +2395,7 @@ private: | ... | @@ -2189,7 +2395,7 @@ private: |
| 2189 | __alloc_ = std::move(__a); | 2395 | __alloc_ = std::move(__a); |
| 2190 | __set_long_pointer(__allocation.ptr); | 2396 | __set_long_pointer(__allocation.ptr); |
| 2191 | __set_long_cap(__allocation.count); | 2397 | __set_long_cap(__allocation.count); |
| 2192 | __set_long_size(__str.size()); | 2398 | __set_long_size(__str.__get_long_size()); |
| 2193 | } | 2399 | } |
| 2194 | } | 2400 | } |
| 2195 | } | 2401 | } |
| ... | @@ -2231,8 +2437,14 @@ private: | ... | @@ -2231,8 +2437,14 @@ private: |
| 2231 | size_type __old_size = size(); | 2437 | size_type __old_size = size(); |
| 2232 | if (__n > __old_size) | 2438 | if (__n > __old_size) |
| 2233 | __annotate_increase(__n - __old_size); | 2439 | __annotate_increase(__n - __old_size); |
| 2234 | pointer __p = | 2440 | pointer __p; |
| 2235 | __is_long() ? (__set_long_size(__n), __get_long_pointer()) : (__set_short_size(__n), __get_short_pointer()); | 2441 | if (__is_long()) { |
| 2442 | __set_long_size(__n); | ||
| 2443 | __p = __get_long_pointer(); | ||
| 2444 | } else { | ||
| 2445 | __set_short_size(__n); | ||
| 2446 | __p = __get_short_pointer(); | ||
| 2447 | } | ||
| 2236 | traits_type::move(std::__to_address(__p), __s, __n); | 2448 | traits_type::move(std::__to_address(__p), __s, __n); |
| 2237 | traits_type::assign(__p[__n], value_type()); | 2449 | traits_type::assign(__p[__n], value_type()); |
| 2238 | if (__old_size > __n) | 2450 | if (__old_size > __n) |
| ... | @@ -2265,24 +2477,23 @@ private: | ... | @@ -2265,24 +2477,23 @@ private: |
| 2265 | std::__throw_out_of_range("basic_string"); | 2477 | std::__throw_out_of_range("basic_string"); |
| 2266 | } | 2478 | } |
| 2267 | 2479 | ||
| 2268 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const basic_string&); | 2480 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string |
| 2269 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const value_type*, const basic_string&); | 2481 | __concatenate_strings<>(const _Allocator&, __type_identity_t<__self_view>, __type_identity_t<__self_view>); |
| 2270 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&); | ||
| 2271 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*); | ||
| 2272 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type); | ||
| 2273 | # if _LIBCPP_STD_VER >= 26 | ||
| 2274 | friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>); | ||
| 2275 | friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&); | ||
| 2276 | # endif | ||
| 2277 | 2482 | ||
| 2278 | template <class _CharT2, class _Traits2, class _Allocator2> | 2483 | template <class _CharT2, class _Traits2, class _Allocator2> |
| 2279 | friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool | 2484 | friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool |
| 2280 | operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT; | 2485 | operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT; |
| 2486 | |||
| 2487 | // These functions aren't used anymore but are part of out ABI, so we need to provide them in the dylib for backwards | ||
| 2488 | // compatibility | ||
| 2489 | # ifdef _LIBCPP_BUILDING_LIBRARY | ||
| 2490 | void __init(const value_type* __s, size_type __sz, size_type __reserve); | ||
| 2491 | # endif | ||
| 2281 | }; | 2492 | }; |
| 2282 | 2493 | ||
| 2283 | // These declarations must appear before any functions are implicitly used | 2494 | // These declarations must appear before any functions are implicitly used |
| 2284 | // so that they have the correct visibility specifier. | 2495 | // so that they have the correct visibility specifier. |
| 2285 | # define _LIBCPP_DECLARE(...) extern template __VA_ARGS__; | 2496 | # define _LIBCPP_DECLARE(...) extern template _LIBCPP_EXPORTED_FROM_ABI __VA_ARGS__; |
| 2286 | # ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | 2497 | # ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 2287 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) | 2498 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) |
| 2288 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 2499 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
| ... | @@ -2309,8 +2520,8 @@ template <class _CharT, | ... | @@ -2309,8 +2520,8 @@ template <class _CharT, |
| 2309 | class _Traits, | 2520 | class _Traits, |
| 2310 | class _Allocator = allocator<_CharT>, | 2521 | class _Allocator = allocator<_CharT>, |
| 2311 | class = enable_if_t<__is_allocator<_Allocator>::value> > | 2522 | class = enable_if_t<__is_allocator<_Allocator>::value> > |
| 2312 | explicit basic_string(basic_string_view<_CharT, _Traits>, | 2523 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) |
| 2313 | const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>; | 2524 | -> basic_string<_CharT, _Traits, _Allocator>; |
| 2314 | 2525 | ||
| 2315 | template <class _CharT, | 2526 | template <class _CharT, |
| 2316 | class _Traits, | 2527 | class _Traits, |
| ... | @@ -2329,37 +2540,13 @@ basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) | ... | @@ -2329,37 +2540,13 @@ basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) |
| 2329 | -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>; | 2540 | -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>; |
| 2330 | # endif | 2541 | # endif |
| 2331 | 2542 | ||
| 2332 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2333 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | ||
| 2334 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) { | ||
| 2335 | if (__libcpp_is_constant_evaluated()) | ||
| 2336 | __rep_ = __rep(); | ||
| 2337 | if (__reserve > max_size()) | ||
| 2338 | __throw_length_error(); | ||
| 2339 | pointer __p; | ||
| 2340 | if (__fits_in_sso(__reserve)) { | ||
| 2341 | __set_short_size(__sz); | ||
| 2342 | __p = __get_short_pointer(); | ||
| 2343 | } else { | ||
| 2344 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1); | ||
| 2345 | __p = __allocation.ptr; | ||
| 2346 | __begin_lifetime(__p, __allocation.count); | ||
| 2347 | __set_long_pointer(__p); | ||
| 2348 | __set_long_cap(__allocation.count); | ||
| 2349 | __set_long_size(__sz); | ||
| 2350 | } | ||
| 2351 | traits_type::copy(std::__to_address(__p), __s, __sz); | ||
| 2352 | traits_type::assign(__p[__sz], value_type()); | ||
| 2353 | __annotate_new(__sz); | ||
| 2354 | } | ||
| 2355 | |||
| 2356 | template <class _CharT, class _Traits, class _Allocator> | 2543 | template <class _CharT, class _Traits, class _Allocator> |
| 2357 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 2544 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2358 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { | 2545 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { |
| 2359 | if (__libcpp_is_constant_evaluated()) | 2546 | if (__libcpp_is_constant_evaluated()) |
| 2360 | __rep_ = __rep(); | 2547 | __rep_ = __rep(); |
| 2361 | if (__sz > max_size()) | 2548 | if (__sz > max_size()) |
| 2362 | __throw_length_error(); | 2549 | this->__throw_length_error(); |
| 2363 | pointer __p; | 2550 | pointer __p; |
| 2364 | if (__fits_in_sso(__sz)) { | 2551 | if (__fits_in_sso(__sz)) { |
| 2365 | __set_short_size(__sz); | 2552 | __set_short_size(__sz); |
| ... | @@ -2389,7 +2576,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value | ... | @@ -2389,7 +2576,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value |
| 2389 | __set_short_size(__sz); | 2576 | __set_short_size(__sz); |
| 2390 | } else { | 2577 | } else { |
| 2391 | if (__sz > max_size()) | 2578 | if (__sz > max_size()) |
| 2392 | __throw_length_error(); | 2579 | this->__throw_length_error(); |
| 2393 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); | 2580 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); |
| 2394 | __p = __allocation.ptr; | 2581 | __p = __allocation.ptr; |
| 2395 | __begin_lifetime(__p, __allocation.count); | 2582 | __begin_lifetime(__p, __allocation.count); |
| ... | @@ -2407,7 +2594,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ | ... | @@ -2407,7 +2594,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2407 | __rep_ = __rep(); | 2594 | __rep_ = __rep(); |
| 2408 | 2595 | ||
| 2409 | if (__n > max_size()) | 2596 | if (__n > max_size()) |
| 2410 | __throw_length_error(); | 2597 | this->__throw_length_error(); |
| 2411 | pointer __p; | 2598 | pointer __p; |
| 2412 | if (__fits_in_sso(__n)) { | 2599 | if (__fits_in_sso(__n)) { |
| 2413 | __set_short_size(__n); | 2600 | __set_short_size(__n); |
| ... | @@ -2470,7 +2657,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir | ... | @@ -2470,7 +2657,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir |
| 2470 | __rep_ = __rep(); | 2657 | __rep_ = __rep(); |
| 2471 | 2658 | ||
| 2472 | if (__sz > max_size()) | 2659 | if (__sz > max_size()) |
| 2473 | __throw_length_error(); | 2660 | this->__throw_length_error(); |
| 2474 | 2661 | ||
| 2475 | pointer __p; | 2662 | pointer __p; |
| 2476 | if (__fits_in_sso(__sz)) { | 2663 | if (__fits_in_sso(__sz)) { |
| ... | @@ -2511,11 +2698,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ | ... | @@ -2511,11 +2698,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2511 | size_type __n_add, | 2698 | size_type __n_add, |
| 2512 | const value_type* __p_new_stuff) { | 2699 | const value_type* __p_new_stuff) { |
| 2513 | size_type __ms = max_size(); | 2700 | size_type __ms = max_size(); |
| 2514 | if (__delta_cap > __ms - __old_cap - 1) | 2701 | if (__delta_cap > __ms - __old_cap) |
| 2515 | __throw_length_error(); | 2702 | __throw_length_error(); |
| 2516 | pointer __old_p = __get_pointer(); | 2703 | pointer __old_p = __get_pointer(); |
| 2517 | size_type __cap = | 2704 | size_type __cap = |
| 2518 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; | 2705 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms; |
| 2519 | __annotate_delete(); | 2706 | __annotate_delete(); |
| 2520 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | 2707 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); |
| 2521 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); | 2708 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); |
| ... | @@ -2555,10 +2742,10 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait | ... | @@ -2555,10 +2742,10 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait |
| 2555 | size_type __n_add) { | 2742 | size_type __n_add) { |
| 2556 | size_type __ms = max_size(); | 2743 | size_type __ms = max_size(); |
| 2557 | if (__delta_cap > __ms - __old_cap) | 2744 | if (__delta_cap > __ms - __old_cap) |
| 2558 | __throw_length_error(); | 2745 | this->__throw_length_error(); |
| 2559 | pointer __old_p = __get_pointer(); | 2746 | pointer __old_p = __get_pointer(); |
| 2560 | size_type __cap = | 2747 | size_type __cap = |
| 2561 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; | 2748 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms; |
| 2562 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); | 2749 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); |
| 2563 | pointer __p = __allocation.ptr; | 2750 | pointer __p = __allocation.ptr; |
| 2564 | __begin_lifetime(__p, __allocation.count); | 2751 | __begin_lifetime(__p, __allocation.count); |
| ... | @@ -2597,20 +2784,25 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -2597,20 +2784,25 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2597 | template <bool __is_short> | 2784 | template <bool __is_short> |
| 2598 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>& | 2785 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>& |
| 2599 | basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) { | 2786 | basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) { |
| 2600 | size_type __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap(); | 2787 | const auto __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap(); |
| 2788 | const auto __size = __is_short ? __get_short_size() : __get_long_size(); | ||
| 2601 | if (__n < __cap) { | 2789 | if (__n < __cap) { |
| 2602 | size_type __old_size = __is_short ? __get_short_size() : __get_long_size(); | 2790 | if (__n > __size) |
| 2603 | if (__n > __old_size) | 2791 | __annotate_increase(__n - __size); |
| 2604 | __annotate_increase(__n - __old_size); | 2792 | pointer __p; |
| 2605 | pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer(); | 2793 | if (__is_short) { |
| 2606 | __is_short ? __set_short_size(__n) : __set_long_size(__n); | 2794 | __p = __get_short_pointer(); |
| 2795 | __set_short_size(__n); | ||
| 2796 | } else { | ||
| 2797 | __p = __get_long_pointer(); | ||
| 2798 | __set_long_size(__n); | ||
| 2799 | } | ||
| 2607 | traits_type::copy(std::__to_address(__p), __s, __n); | 2800 | traits_type::copy(std::__to_address(__p), __s, __n); |
| 2608 | traits_type::assign(__p[__n], value_type()); | 2801 | traits_type::assign(__p[__n], value_type()); |
| 2609 | if (__old_size > __n) | 2802 | if (__size > __n) |
| 2610 | __annotate_shrink(__old_size); | 2803 | __annotate_shrink(__size); |
| 2611 | } else { | 2804 | } else { |
| 2612 | size_type __sz = __is_short ? __get_short_size() : __get_long_size(); | 2805 | __grow_by_and_replace(__cap - 1, __n - __cap + 1, __size, 0, __size, __n, __s); |
| 2613 | __grow_by_and_replace(__cap - 1, __n - __cap + 1, __sz, 0, __sz, __n, __s); | ||
| 2614 | } | 2806 | } |
| 2615 | return *this; | 2807 | return *this; |
| 2616 | } | 2808 | } |
| ... | @@ -2618,17 +2810,16 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* _ | ... | @@ -2618,17 +2810,16 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* _ |
| 2618 | template <class _CharT, class _Traits, class _Allocator> | 2810 | template <class _CharT, class _Traits, class _Allocator> |
| 2619 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>& | 2811 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>& |
| 2620 | basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s, size_type __n) { | 2812 | basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s, size_type __n) { |
| 2621 | size_type __cap = capacity(); | 2813 | const auto __cap = capacity(); |
| 2814 | const auto __size = size(); | ||
| 2622 | if (__cap >= __n) { | 2815 | if (__cap >= __n) { |
| 2623 | size_type __old_size = size(); | 2816 | if (__n > __size) |
| 2624 | if (__n > __old_size) | 2817 | __annotate_increase(__n - __size); |
| 2625 | __annotate_increase(__n - __old_size); | ||
| 2626 | value_type* __p = std::__to_address(__get_pointer()); | 2818 | value_type* __p = std::__to_address(__get_pointer()); |
| 2627 | traits_type::move(__p, __s, __n); | 2819 | traits_type::move(__p, __s, __n); |
| 2628 | return __null_terminate_at(__p, __n); | 2820 | return __null_terminate_at(__p, __n); |
| 2629 | } else { | 2821 | } else { |
| 2630 | size_type __sz = size(); | 2822 | __grow_by_and_replace(__cap, __n - __cap, __size, 0, __size, __n, __s); |
| 2631 | __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); | ||
| 2632 | return *this; | 2823 | return *this; |
| 2633 | } | 2824 | } |
| 2634 | } | 2825 | } |
| ... | @@ -2646,8 +2837,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) | ... | @@ -2646,8 +2837,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) |
| 2646 | size_type __cap = capacity(); | 2837 | size_type __cap = capacity(); |
| 2647 | size_type __old_size = size(); | 2838 | size_type __old_size = size(); |
| 2648 | if (__cap < __n) { | 2839 | if (__cap < __n) { |
| 2649 | size_type __sz = size(); | 2840 | __grow_by_without_replace(__cap, __n - __cap, __old_size, 0, __old_size); |
| 2650 | __grow_by_without_replace(__cap, __n - __cap, __sz, 0, __sz); | ||
| 2651 | __annotate_increase(__n); | 2841 | __annotate_increase(__n); |
| 2652 | } else if (__n > __old_size) | 2842 | } else if (__n > __old_size) |
| 2653 | __annotate_increase(__n - __old_size); | 2843 | __annotate_increase(__n - __old_size); |
| ... | @@ -2659,10 +2849,10 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) | ... | @@ -2659,10 +2849,10 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) |
| 2659 | template <class _CharT, class _Traits, class _Allocator> | 2849 | template <class _CharT, class _Traits, class _Allocator> |
| 2660 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 2850 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 2661 | basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) { | 2851 | basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) { |
| 2662 | pointer __p; | ||
| 2663 | size_type __old_size = size(); | 2852 | size_type __old_size = size(); |
| 2664 | if (__old_size == 0) | 2853 | if (__old_size == 0) |
| 2665 | __annotate_increase(1); | 2854 | __annotate_increase(1); |
| 2855 | pointer __p; | ||
| 2666 | if (__is_long()) { | 2856 | if (__is_long()) { |
| 2667 | __p = __get_long_pointer(); | 2857 | __p = __get_long_pointer(); |
| 2668 | __set_long_size(1); | 2858 | __set_long_size(1); |
| ... | @@ -2680,23 +2870,21 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) { | ... | @@ -2680,23 +2870,21 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) { |
| 2680 | template <class _CharT, class _Traits, class _Allocator> | 2870 | template <class _CharT, class _Traits, class _Allocator> |
| 2681 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string<_CharT, _Traits, _Allocator>& | 2871 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string<_CharT, _Traits, _Allocator>& |
| 2682 | basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) { | 2872 | basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) { |
| 2683 | if (this != std::addressof(__str)) { | 2873 | if (this == std::addressof(__str)) |
| 2684 | __copy_assign_alloc(__str); | 2874 | return *this; |
| 2685 | if (!__is_long()) { | 2875 | |
| 2686 | if (!__str.__is_long()) { | 2876 | __copy_assign_alloc(__str); |
| 2687 | size_type __old_size = __get_short_size(); | 2877 | |
| 2688 | if (__get_short_size() < __str.__get_short_size()) | 2878 | if (__is_long()) |
| 2689 | __annotate_increase(__str.__get_short_size() - __get_short_size()); | 2879 | return __assign_no_alias<false>(__str.data(), __str.size()); |
| 2690 | __rep_ = __str.__rep_; | 2880 | |
| 2691 | if (__old_size > __get_short_size()) | 2881 | if (__str.__is_long()) |
| 2692 | __annotate_shrink(__old_size); | 2882 | return __assign_no_alias<true>(__str.data(), __str.size()); |
| 2693 | } else { | 2883 | |
| 2694 | return __assign_no_alias<true>(__str.data(), __str.size()); | 2884 | __annotate_delete(); |
| 2695 | } | 2885 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); |
| 2696 | } else { | 2886 | __rep_ = __str.__rep_; |
| 2697 | return __assign_no_alias<false>(__str.data(), __str.size()); | 2887 | |
| 2698 | } | ||
| 2699 | } | ||
| 2700 | return *this; | 2888 | return *this; |
| 2701 | } | 2889 | } |
| 2702 | 2890 | ||
| ... | @@ -2760,14 +2948,6 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr | ... | @@ -2760,14 +2948,6 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr |
| 2760 | 2948 | ||
| 2761 | # endif | 2949 | # endif |
| 2762 | 2950 | ||
| 2763 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2764 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | ||
| 2765 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 2766 | basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { | ||
| 2767 | __assign_with_sentinel(__first, __last); | ||
| 2768 | return *this; | ||
| 2769 | } | ||
| 2770 | |||
| 2771 | template <class _CharT, class _Traits, class _Allocator> | 2951 | template <class _CharT, class _Traits, class _Allocator> |
| 2772 | template <class _InputIterator, class _Sentinel> | 2952 | template <class _InputIterator, class _Sentinel> |
| 2773 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 2953 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| ... | @@ -2776,20 +2956,6 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator | ... | @@ -2776,20 +2956,6 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator |
| 2776 | assign(__temp.data(), __temp.size()); | 2956 | assign(__temp.data(), __temp.size()); |
| 2777 | } | 2957 | } |
| 2778 | 2958 | ||
| 2779 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2780 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | ||
| 2781 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 2782 | basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 2783 | if (__string_is_trivial_iterator<_ForwardIterator>::value) { | ||
| 2784 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | ||
| 2785 | __assign_trivial(__first, __last, __n); | ||
| 2786 | } else { | ||
| 2787 | __assign_with_sentinel(__first, __last); | ||
| 2788 | } | ||
| 2789 | |||
| 2790 | return *this; | ||
| 2791 | } | ||
| 2792 | |||
| 2793 | template <class _CharT, class _Traits, class _Allocator> | 2959 | template <class _CharT, class _Traits, class _Allocator> |
| 2794 | template <class _Iterator, class _Sentinel> | 2960 | template <class _Iterator, class _Sentinel> |
| 2795 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | 2961 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| ... | @@ -2825,24 +2991,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ... | @@ -2825,24 +2991,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 2825 | basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) { | 2991 | basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) { |
| 2826 | size_type __sz = __str.size(); | 2992 | size_type __sz = __str.size(); |
| 2827 | if (__pos > __sz) | 2993 | if (__pos > __sz) |
| 2828 | __throw_out_of_range(); | 2994 | this->__throw_out_of_range(); |
| 2829 | return assign(__str.data() + __pos, std::min(__n, __sz - __pos)); | 2995 | return assign(__str.data() + __pos, std::min(__n, __sz - __pos)); |
| 2830 | } | 2996 | } |
| 2831 | 2997 | ||
| 2832 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2833 | template <class _Tp, | ||
| 2834 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | ||
| 2835 | !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, | ||
| 2836 | int> > | ||
| 2837 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 2838 | basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp& __t, size_type __pos, size_type __n) { | ||
| 2839 | __self_view __sv = __t; | ||
| 2840 | size_type __sz = __sv.size(); | ||
| 2841 | if (__pos > __sz) | ||
| 2842 | __throw_out_of_range(); | ||
| 2843 | return assign(__sv.data() + __pos, std::min(__n, __sz - __pos)); | ||
| 2844 | } | ||
| 2845 | |||
| 2846 | template <class _CharT, class _Traits, class _Allocator> | 2998 | template <class _CharT, class _Traits, class _Allocator> |
| 2847 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>& | 2999 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>& |
| 2848 | basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) { | 3000 | basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) { |
| ... | @@ -2853,10 +3005,9 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -2853,10 +3005,9 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2853 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3005 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 2854 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { | 3006 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { |
| 2855 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::assign received nullptr"); | 3007 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::assign received nullptr"); |
| 2856 | return __builtin_constant_p(*__s) | 3008 | if (auto __len = traits_type::length(__s); __builtin_constant_p(__len) && __fits_in_sso(__len)) |
| 2857 | ? (__fits_in_sso(traits_type::length(__s)) ? __assign_short(__s, traits_type::length(__s)) | 3009 | return __assign_short(__s, __len); |
| 2858 | : __assign_external(__s, traits_type::length(__s))) | 3010 | return __assign_external(__s); |
| 2859 | : __assign_external(__s); | ||
| 2860 | } | 3011 | } |
| 2861 | // append | 3012 | // append |
| 2862 | 3013 | ||
| ... | @@ -2928,11 +3079,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu | ... | @@ -2928,11 +3079,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu |
| 2928 | } | 3079 | } |
| 2929 | if (__sz == __cap) { | 3080 | if (__sz == __cap) { |
| 2930 | __grow_by_without_replace(__cap, 1, __sz, __sz, 0); | 3081 | __grow_by_without_replace(__cap, 1, __sz, __sz, 0); |
| 2931 | __annotate_increase(1); | ||
| 2932 | __is_short = false; // the string is always long after __grow_by | 3082 | __is_short = false; // the string is always long after __grow_by |
| 2933 | } else | 3083 | } |
| 2934 | __annotate_increase(1); | 3084 | __annotate_increase(1); |
| 2935 | pointer __p = __get_pointer(); | 3085 | pointer __p; |
| 2936 | if (__is_short) { | 3086 | if (__is_short) { |
| 2937 | __p = __get_short_pointer() + __sz; | 3087 | __p = __get_short_pointer() + __sz; |
| 2938 | __set_short_size(__sz + 1); | 3088 | __set_short_size(__sz + 1); |
| ... | @@ -2944,52 +3094,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu | ... | @@ -2944,52 +3094,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu |
| 2944 | traits_type::assign(*++__p, value_type()); | 3094 | traits_type::assign(*++__p, value_type()); |
| 2945 | } | 3095 | } |
| 2946 | 3096 | ||
| 2947 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2948 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | ||
| 2949 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 2950 | basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last) { | ||
| 2951 | size_type __sz = size(); | ||
| 2952 | size_type __cap = capacity(); | ||
| 2953 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | ||
| 2954 | if (__n) { | ||
| 2955 | if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) { | ||
| 2956 | if (__cap - __sz < __n) | ||
| 2957 | __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0); | ||
| 2958 | __annotate_increase(__n); | ||
| 2959 | auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz)); | ||
| 2960 | traits_type::assign(*__end, value_type()); | ||
| 2961 | __set_size(__sz + __n); | ||
| 2962 | } else { | ||
| 2963 | const basic_string __temp(__first, __last, __alloc_); | ||
| 2964 | append(__temp.data(), __temp.size()); | ||
| 2965 | } | ||
| 2966 | } | ||
| 2967 | return *this; | ||
| 2968 | } | ||
| 2969 | |||
| 2970 | template <class _CharT, class _Traits, class _Allocator> | 3097 | template <class _CharT, class _Traits, class _Allocator> |
| 2971 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3098 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 2972 | basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) { | 3099 | basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) { |
| 2973 | size_type __sz = __str.size(); | 3100 | size_type __sz = __str.size(); |
| 2974 | if (__pos > __sz) | 3101 | if (__pos > __sz) |
| 2975 | __throw_out_of_range(); | 3102 | this->__throw_out_of_range(); |
| 2976 | return append(__str.data() + __pos, std::min(__n, __sz - __pos)); | 3103 | return append(__str.data() + __pos, std::min(__n, __sz - __pos)); |
| 2977 | } | 3104 | } |
| 2978 | 3105 | ||
| 2979 | template <class _CharT, class _Traits, class _Allocator> | ||
| 2980 | template <class _Tp, | ||
| 2981 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | ||
| 2982 | !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, | ||
| 2983 | int> > | ||
| 2984 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 2985 | basic_string<_CharT, _Traits, _Allocator>::append(const _Tp& __t, size_type __pos, size_type __n) { | ||
| 2986 | __self_view __sv = __t; | ||
| 2987 | size_type __sz = __sv.size(); | ||
| 2988 | if (__pos > __sz) | ||
| 2989 | __throw_out_of_range(); | ||
| 2990 | return append(__sv.data() + __pos, std::min(__n, __sz - __pos)); | ||
| 2991 | } | ||
| 2992 | |||
| 2993 | template <class _CharT, class _Traits, class _Allocator> | 3106 | template <class _CharT, class _Traits, class _Allocator> |
| 2994 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3107 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 2995 | basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { | 3108 | basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { |
| ... | @@ -3005,7 +3118,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t | ... | @@ -3005,7 +3118,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t |
| 3005 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::insert received nullptr"); | 3118 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::insert received nullptr"); |
| 3006 | size_type __sz = size(); | 3119 | size_type __sz = size(); |
| 3007 | if (__pos > __sz) | 3120 | if (__pos > __sz) |
| 3008 | __throw_out_of_range(); | 3121 | this->__throw_out_of_range(); |
| 3009 | size_type __cap = capacity(); | 3122 | size_type __cap = capacity(); |
| 3010 | if (__cap - __sz >= __n) { | 3123 | if (__cap - __sz >= __n) { |
| 3011 | if (__n) { | 3124 | if (__n) { |
| ... | @@ -3032,7 +3145,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ... | @@ -3032,7 +3145,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3032 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) { | 3145 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) { |
| 3033 | size_type __sz = size(); | 3146 | size_type __sz = size(); |
| 3034 | if (__pos > __sz) | 3147 | if (__pos > __sz) |
| 3035 | __throw_out_of_range(); | 3148 | this->__throw_out_of_range(); |
| 3036 | if (__n) { | 3149 | if (__n) { |
| 3037 | size_type __cap = capacity(); | 3150 | size_type __cap = capacity(); |
| 3038 | value_type* __p; | 3151 | value_type* __p; |
| ... | @@ -3054,23 +3167,6 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n | ... | @@ -3054,23 +3167,6 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 3054 | return *this; | 3167 | return *this; |
| 3055 | } | 3168 | } |
| 3056 | 3169 | ||
| 3057 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3058 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | ||
| 3059 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator | ||
| 3060 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { | ||
| 3061 | const basic_string __temp(__first, __last, __alloc_); | ||
| 3062 | return insert(__pos, __temp.data(), __temp.data() + __temp.size()); | ||
| 3063 | } | ||
| 3064 | |||
| 3065 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3066 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | ||
| 3067 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator | ||
| 3068 | basic_string<_CharT, _Traits, _Allocator>::insert( | ||
| 3069 | const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) { | ||
| 3070 | auto __n = static_cast<size_type>(std::distance(__first, __last)); | ||
| 3071 | return __insert_with_size(__pos, __first, __last, __n); | ||
| 3072 | } | ||
| 3073 | |||
| 3074 | template <class _CharT, class _Traits, class _Allocator> | 3170 | template <class _CharT, class _Traits, class _Allocator> |
| 3075 | template <class _Iterator, class _Sentinel> | 3171 | template <class _Iterator, class _Sentinel> |
| 3076 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator | 3172 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| ... | @@ -3094,24 +3190,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert( | ... | @@ -3094,24 +3190,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert( |
| 3094 | size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n) { | 3190 | size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n) { |
| 3095 | size_type __str_sz = __str.size(); | 3191 | size_type __str_sz = __str.size(); |
| 3096 | if (__pos2 > __str_sz) | 3192 | if (__pos2 > __str_sz) |
| 3097 | __throw_out_of_range(); | 3193 | this->__throw_out_of_range(); |
| 3098 | return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2)); | 3194 | return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2)); |
| 3099 | } | 3195 | } |
| 3100 | 3196 | ||
| 3101 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3102 | template <class _Tp, | ||
| 3103 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | ||
| 3104 | !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, | ||
| 3105 | int> > | ||
| 3106 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 3107 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n) { | ||
| 3108 | __self_view __sv = __t; | ||
| 3109 | size_type __str_sz = __sv.size(); | ||
| 3110 | if (__pos2 > __str_sz) | ||
| 3111 | __throw_out_of_range(); | ||
| 3112 | return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2)); | ||
| 3113 | } | ||
| 3114 | |||
| 3115 | template <class _CharT, class _Traits, class _Allocator> | 3197 | template <class _CharT, class _Traits, class _Allocator> |
| 3116 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3198 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3117 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { | 3199 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { |
| ... | @@ -3152,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace( | ... | @@ -3152,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace( |
| 3152 | _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); | 3234 | _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); |
| 3153 | size_type __sz = size(); | 3235 | size_type __sz = size(); |
| 3154 | if (__pos > __sz) | 3236 | if (__pos > __sz) |
| 3155 | __throw_out_of_range(); | 3237 | this->__throw_out_of_range(); |
| 3156 | __n1 = std::min(__n1, __sz - __pos); | 3238 | __n1 = std::min(__n1, __sz - __pos); |
| 3157 | size_type __cap = capacity(); | 3239 | size_type __cap = capacity(); |
| 3158 | if (__cap - __sz + __n1 >= __n2) { | 3240 | if (__cap - __sz + __n1 >= __n2) { |
| ... | @@ -3194,7 +3276,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ... | @@ -3194,7 +3276,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3194 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) { | 3276 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) { |
| 3195 | size_type __sz = size(); | 3277 | size_type __sz = size(); |
| 3196 | if (__pos > __sz) | 3278 | if (__pos > __sz) |
| 3197 | __throw_out_of_range(); | 3279 | this->__throw_out_of_range(); |
| 3198 | __n1 = std::min(__n1, __sz - __pos); | 3280 | __n1 = std::min(__n1, __sz - __pos); |
| 3199 | size_type __cap = capacity(); | 3281 | size_type __cap = capacity(); |
| 3200 | value_type* __p; | 3282 | value_type* __p; |
| ... | @@ -3215,40 +3297,16 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ | ... | @@ -3215,40 +3297,16 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3215 | return __null_terminate_at(__p, __sz - (__n1 - __n2)); | 3297 | return __null_terminate_at(__p, __sz - (__n1 - __n2)); |
| 3216 | } | 3298 | } |
| 3217 | 3299 | ||
| 3218 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3219 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > | ||
| 3220 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 3221 | basic_string<_CharT, _Traits, _Allocator>::replace( | ||
| 3222 | const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) { | ||
| 3223 | const basic_string __temp(__j1, __j2, __alloc_); | ||
| 3224 | return replace(__i1, __i2, __temp); | ||
| 3225 | } | ||
| 3226 | |||
| 3227 | template <class _CharT, class _Traits, class _Allocator> | 3300 | template <class _CharT, class _Traits, class _Allocator> |
| 3228 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3301 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3229 | basic_string<_CharT, _Traits, _Allocator>::replace( | 3302 | basic_string<_CharT, _Traits, _Allocator>::replace( |
| 3230 | size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) { | 3303 | size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) { |
| 3231 | size_type __str_sz = __str.size(); | 3304 | size_type __str_sz = __str.size(); |
| 3232 | if (__pos2 > __str_sz) | 3305 | if (__pos2 > __str_sz) |
| 3233 | __throw_out_of_range(); | 3306 | this->__throw_out_of_range(); |
| 3234 | return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2)); | 3307 | return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2)); |
| 3235 | } | 3308 | } |
| 3236 | 3309 | ||
| 3237 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3238 | template <class _Tp, | ||
| 3239 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | ||
| 3240 | !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, | ||
| 3241 | int> > | ||
| 3242 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | ||
| 3243 | basic_string<_CharT, _Traits, _Allocator>::replace( | ||
| 3244 | size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) { | ||
| 3245 | __self_view __sv = __t; | ||
| 3246 | size_type __str_sz = __sv.size(); | ||
| 3247 | if (__pos2 > __str_sz) | ||
| 3248 | __throw_out_of_range(); | ||
| 3249 | return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2)); | ||
| 3250 | } | ||
| 3251 | |||
| 3252 | template <class _CharT, class _Traits, class _Allocator> | 3310 | template <class _CharT, class _Traits, class _Allocator> |
| 3253 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3311 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3254 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { | 3312 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { |
| ... | @@ -3278,7 +3336,7 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -3278,7 +3336,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 3278 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& | 3336 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3279 | basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) { | 3337 | basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) { |
| 3280 | if (__pos > size()) | 3338 | if (__pos > size()) |
| 3281 | __throw_out_of_range(); | 3339 | this->__throw_out_of_range(); |
| 3282 | if (__n == npos) { | 3340 | if (__n == npos) { |
| 3283 | __erase_to_end(__pos); | 3341 | __erase_to_end(__pos); |
| 3284 | } else { | 3342 | } else { |
| ... | @@ -3316,11 +3374,13 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat | ... | @@ -3316,11 +3374,13 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat |
| 3316 | 3374 | ||
| 3317 | template <class _CharT, class _Traits, class _Allocator> | 3375 | template <class _CharT, class _Traits, class _Allocator> |
| 3318 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { | 3376 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { |
| 3319 | size_type __old_size = size(); | 3377 | size_type __old_size; |
| 3320 | if (__is_long()) { | 3378 | if (__is_long()) { |
| 3379 | __old_size = __get_long_size(); | ||
| 3321 | traits_type::assign(*__get_long_pointer(), value_type()); | 3380 | traits_type::assign(*__get_long_pointer(), value_type()); |
| 3322 | __set_long_size(0); | 3381 | __set_long_size(0); |
| 3323 | } else { | 3382 | } else { |
| 3383 | __old_size = __get_short_size(); | ||
| 3324 | traits_type::assign(*__get_short_pointer(), value_type()); | 3384 | traits_type::assign(*__get_short_pointer(), value_type()); |
| 3325 | __set_short_size(0); | 3385 | __set_short_size(0); |
| 3326 | } | 3386 | } |
| ... | @@ -3349,7 +3409,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) | ... | @@ -3349,7 +3409,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) |
| 3349 | template <class _CharT, class _Traits, class _Allocator> | 3409 | template <class _CharT, class _Traits, class _Allocator> |
| 3350 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) { | 3410 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) { |
| 3351 | if (__requested_capacity > max_size()) | 3411 | if (__requested_capacity > max_size()) |
| 3352 | __throw_length_error(); | 3412 | this->__throw_length_error(); |
| 3353 | 3413 | ||
| 3354 | // Make sure reserve(n) never shrinks. This is technically only required in C++20 | 3414 | // Make sure reserve(n) never shrinks. This is technically only required in C++20 |
| 3355 | // and later (since P0966R1), however we provide consistent behavior in all Standard | 3415 | // and later (since P0966R1), however we provide consistent behavior in all Standard |
| ... | @@ -3357,7 +3417,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re | ... | @@ -3357,7 +3417,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re |
| 3357 | if (__requested_capacity <= capacity()) | 3417 | if (__requested_capacity <= capacity()) |
| 3358 | return; | 3418 | return; |
| 3359 | 3419 | ||
| 3360 | __shrink_or_extend(__recommend(__requested_capacity)); | 3420 | __annotation_guard __g(*this); |
| 3421 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__requested_capacity) + 1); | ||
| 3422 | auto __size = size(); | ||
| 3423 | __begin_lifetime(__allocation.ptr, __allocation.count); | ||
| 3424 | traits_type::copy(std::__to_address(__allocation.ptr), data(), __size + 1); | ||
| 3425 | if (__is_long()) | ||
| 3426 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | ||
| 3427 | __set_long_cap(__allocation.count); | ||
| 3428 | __set_long_size(__size); | ||
| 3429 | __set_long_pointer(__allocation.ptr); | ||
| 3361 | } | 3430 | } |
| 3362 | 3431 | ||
| 3363 | template <class _CharT, class _Traits, class _Allocator> | 3432 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3366,76 +3435,52 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat | ... | @@ -3366,76 +3435,52 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat |
| 3366 | if (__target_capacity == capacity()) | 3435 | if (__target_capacity == capacity()) |
| 3367 | return; | 3436 | return; |
| 3368 | 3437 | ||
| 3369 | __shrink_or_extend(__target_capacity); | 3438 | _LIBCPP_ASSERT_INTERNAL(__is_long(), "Trying to shrink small string"); |
| 3370 | } | ||
| 3371 | 3439 | ||
| 3372 | template <class _CharT, class _Traits, class _Allocator> | 3440 | // We're a long string and we're shrinking into the small buffer. |
| 3373 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void | 3441 | const auto __ptr = __get_long_pointer(); |
| 3374 | basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) { | 3442 | const auto __size = __get_long_size(); |
| 3375 | __annotate_delete(); | 3443 | const auto __cap = __get_long_cap(); |
| 3376 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | ||
| 3377 | size_type __cap = capacity(); | ||
| 3378 | size_type __sz = size(); | ||
| 3379 | 3444 | ||
| 3380 | pointer __new_data, __p; | ||
| 3381 | bool __was_long, __now_long; | ||
| 3382 | if (__fits_in_sso(__target_capacity)) { | 3445 | if (__fits_in_sso(__target_capacity)) { |
| 3383 | __was_long = true; | 3446 | __annotation_guard __g(*this); |
| 3384 | __now_long = false; | 3447 | __set_short_size(__size); |
| 3385 | __new_data = __get_short_pointer(); | 3448 | traits_type::copy(std::__to_address(__get_short_pointer()), std::__to_address(__ptr), __size + 1); |
| 3386 | __p = __get_long_pointer(); | 3449 | __alloc_traits::deallocate(__alloc_, __ptr, __cap); |
| 3387 | } else { | 3450 | return; |
| 3388 | if (__target_capacity > __cap) { | 3451 | } |
| 3389 | // Extend | 3452 | |
| 3390 | // - called from reserve should propagate the exception thrown. | ||
| 3391 | auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); | ||
| 3392 | __new_data = __allocation.ptr; | ||
| 3393 | __target_capacity = __allocation.count - 1; | ||
| 3394 | } else { | ||
| 3395 | // Shrink | ||
| 3396 | // - called from shrink_to_fit should not throw. | ||
| 3397 | // - called from reserve may throw but is not required to. | ||
| 3398 | # if _LIBCPP_HAS_EXCEPTIONS | 3453 | # if _LIBCPP_HAS_EXCEPTIONS |
| 3399 | try { | 3454 | try { |
| 3400 | # endif // _LIBCPP_HAS_EXCEPTIONS | 3455 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 3401 | auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); | 3456 | __annotation_guard __g(*this); |
| 3402 | 3457 | auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); | |
| 3403 | // The Standard mandates shrink_to_fit() does not increase the capacity. | 3458 | |
| 3404 | // With equal capacity keep the existing buffer. This avoids extra work | 3459 | // The Standard mandates shrink_to_fit() does not increase the capacity. |
| 3405 | // due to swapping the elements. | 3460 | // With equal capacity keep the existing buffer. This avoids extra work |
| 3406 | if (__allocation.count - 1 > capacity()) { | 3461 | // due to swapping the elements. |
| 3407 | __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count); | 3462 | if (__allocation.count - 1 >= capacity()) { |
| 3408 | return; | 3463 | __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count); |
| 3409 | } | 3464 | return; |
| 3410 | __new_data = __allocation.ptr; | 3465 | } |
| 3411 | __target_capacity = __allocation.count - 1; | 3466 | |
| 3467 | __begin_lifetime(__allocation.ptr, __allocation.count); | ||
| 3468 | traits_type::copy(std::__to_address(__allocation.ptr), std::__to_address(__ptr), __size + 1); | ||
| 3469 | __alloc_traits::deallocate(__alloc_, __ptr, __cap); | ||
| 3470 | __set_long_cap(__allocation.count); | ||
| 3471 | __set_long_pointer(__allocation.ptr); | ||
| 3412 | # if _LIBCPP_HAS_EXCEPTIONS | 3472 | # if _LIBCPP_HAS_EXCEPTIONS |
| 3413 | } catch (...) { | 3473 | } catch (...) { |
| 3414 | return; | 3474 | return; |
| 3415 | } | 3475 | } |
| 3416 | # endif // _LIBCPP_HAS_EXCEPTIONS | 3476 | # endif // _LIBCPP_HAS_EXCEPTIONS |
| 3417 | } | ||
| 3418 | __begin_lifetime(__new_data, __target_capacity + 1); | ||
| 3419 | __now_long = true; | ||
| 3420 | __was_long = __is_long(); | ||
| 3421 | __p = __get_pointer(); | ||
| 3422 | } | ||
| 3423 | traits_type::copy(std::__to_address(__new_data), std::__to_address(__p), size() + 1); | ||
| 3424 | if (__was_long) | ||
| 3425 | __alloc_traits::deallocate(__alloc_, __p, __cap + 1); | ||
| 3426 | if (__now_long) { | ||
| 3427 | __set_long_cap(__target_capacity + 1); | ||
| 3428 | __set_long_size(__sz); | ||
| 3429 | __set_long_pointer(__new_data); | ||
| 3430 | } else | ||
| 3431 | __set_short_size(__sz); | ||
| 3432 | } | 3477 | } |
| 3433 | 3478 | ||
| 3434 | template <class _CharT, class _Traits, class _Allocator> | 3479 | template <class _CharT, class _Traits, class _Allocator> |
| 3435 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::const_reference | 3480 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::const_reference |
| 3436 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const { | 3481 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const { |
| 3437 | if (__n >= size()) | 3482 | if (__n >= size()) |
| 3438 | __throw_out_of_range(); | 3483 | this->__throw_out_of_range(); |
| 3439 | return (*this)[__n]; | 3484 | return (*this)[__n]; |
| 3440 | } | 3485 | } |
| 3441 | 3486 | ||
| ... | @@ -3443,7 +3488,7 @@ template <class _CharT, class _Traits, class _Allocator> | ... | @@ -3443,7 +3488,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 3443 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::reference | 3488 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::reference |
| 3444 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) { | 3489 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) { |
| 3445 | if (__n >= size()) | 3490 | if (__n >= size()) |
| 3446 | __throw_out_of_range(); | 3491 | this->__throw_out_of_range(); |
| 3447 | return (*this)[__n]; | 3492 | return (*this)[__n]; |
| 3448 | } | 3493 | } |
| 3449 | 3494 | ||
| ... | @@ -3452,7 +3497,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator> | ... | @@ -3452,7 +3497,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator> |
| 3452 | basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const { | 3497 | basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const { |
| 3453 | size_type __sz = size(); | 3498 | size_type __sz = size(); |
| 3454 | if (__pos > __sz) | 3499 | if (__pos > __sz) |
| 3455 | __throw_out_of_range(); | 3500 | this->__throw_out_of_range(); |
| 3456 | size_type __rlen = std::min(__n, __sz - __pos); | 3501 | size_type __rlen = std::min(__n, __sz - __pos); |
| 3457 | traits_type::copy(__s, data() + __pos, __rlen); | 3502 | traits_type::copy(__s, data() + __pos, __rlen); |
| 3458 | return __rlen; | 3503 | return __rlen; |
| ... | @@ -3482,274 +3527,15 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat | ... | @@ -3482,274 +3527,15 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat |
| 3482 | __str.__annotate_new(__str.__get_short_size()); | 3527 | __str.__annotate_new(__str.__get_short_size()); |
| 3483 | } | 3528 | } |
| 3484 | 3529 | ||
| 3485 | // find | ||
| 3486 | |||
| 3487 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3488 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3489 | basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 3490 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr"); | ||
| 3491 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 3492 | } | ||
| 3493 | |||
| 3494 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3495 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3496 | basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT { | ||
| 3497 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size()); | ||
| 3498 | } | ||
| 3499 | |||
| 3500 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3501 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3502 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3503 | basic_string<_CharT, _Traits, _Allocator>::find(const _Tp& __t, size_type __pos) const _NOEXCEPT { | ||
| 3504 | __self_view __sv = __t; | ||
| 3505 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 3506 | } | ||
| 3507 | |||
| 3508 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3509 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3510 | basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { | ||
| 3511 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr"); | ||
| 3512 | return std::__str_find<value_type, size_type, traits_type, npos>( | ||
| 3513 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 3514 | } | ||
| 3515 | |||
| 3516 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3517 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3518 | basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT { | ||
| 3519 | return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 3520 | } | ||
| 3521 | |||
| 3522 | // rfind | ||
| 3523 | |||
| 3524 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3525 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3526 | basic_string<_CharT, _Traits, _Allocator>::rfind( | ||
| 3527 | const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 3528 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); | ||
| 3529 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 3530 | } | ||
| 3531 | |||
| 3532 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3533 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3534 | basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT { | ||
| 3535 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size()); | ||
| 3536 | } | ||
| 3537 | |||
| 3538 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3539 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3540 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3541 | basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, size_type __pos) const _NOEXCEPT { | ||
| 3542 | __self_view __sv = __t; | ||
| 3543 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 3544 | } | ||
| 3545 | |||
| 3546 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3547 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3548 | basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { | ||
| 3549 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr"); | ||
| 3550 | return std::__str_rfind<value_type, size_type, traits_type, npos>( | ||
| 3551 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 3552 | } | ||
| 3553 | |||
| 3554 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3555 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3556 | basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT { | ||
| 3557 | return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 3558 | } | ||
| 3559 | |||
| 3560 | // find_first_of | ||
| 3561 | |||
| 3562 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3563 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3564 | basic_string<_CharT, _Traits, _Allocator>::find_first_of( | ||
| 3565 | const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 3566 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); | ||
| 3567 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 3568 | } | ||
| 3569 | |||
| 3570 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3571 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3572 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { | ||
| 3573 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | ||
| 3574 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 3575 | } | ||
| 3576 | |||
| 3577 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3578 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3579 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3580 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { | ||
| 3581 | __self_view __sv = __t; | ||
| 3582 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | ||
| 3583 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 3584 | } | ||
| 3585 | |||
| 3586 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3587 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3588 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { | ||
| 3589 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr"); | ||
| 3590 | return std::__str_find_first_of<value_type, size_type, traits_type, npos>( | ||
| 3591 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 3592 | } | ||
| 3593 | |||
| 3594 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3595 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3596 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT { | ||
| 3597 | return find(__c, __pos); | ||
| 3598 | } | ||
| 3599 | |||
| 3600 | // find_last_of | ||
| 3601 | |||
| 3602 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3603 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3604 | basic_string<_CharT, _Traits, _Allocator>::find_last_of( | ||
| 3605 | const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 3606 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); | ||
| 3607 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 3608 | } | ||
| 3609 | |||
| 3610 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3611 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3612 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { | ||
| 3613 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | ||
| 3614 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 3615 | } | ||
| 3616 | |||
| 3617 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3618 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3619 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3620 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { | ||
| 3621 | __self_view __sv = __t; | ||
| 3622 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | ||
| 3623 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 3624 | } | ||
| 3625 | |||
| 3626 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3627 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3628 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { | ||
| 3629 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr"); | ||
| 3630 | return std::__str_find_last_of<value_type, size_type, traits_type, npos>( | ||
| 3631 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 3632 | } | ||
| 3633 | |||
| 3634 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3635 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3636 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT { | ||
| 3637 | return rfind(__c, __pos); | ||
| 3638 | } | ||
| 3639 | |||
| 3640 | // find_first_not_of | ||
| 3641 | |||
| 3642 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3643 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3644 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of( | ||
| 3645 | const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 3646 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); | ||
| 3647 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 3648 | } | ||
| 3649 | |||
| 3650 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3651 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3652 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of( | ||
| 3653 | const basic_string& __str, size_type __pos) const _NOEXCEPT { | ||
| 3654 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | ||
| 3655 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 3656 | } | ||
| 3657 | |||
| 3658 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3659 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3660 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3661 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { | ||
| 3662 | __self_view __sv = __t; | ||
| 3663 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | ||
| 3664 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 3665 | } | ||
| 3666 | |||
| 3667 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3668 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3669 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { | ||
| 3670 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr"); | ||
| 3671 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>( | ||
| 3672 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 3673 | } | ||
| 3674 | |||
| 3675 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3676 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3677 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT { | ||
| 3678 | return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 3679 | } | ||
| 3680 | |||
| 3681 | // find_last_not_of | ||
| 3682 | |||
| 3683 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3684 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3685 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of( | ||
| 3686 | const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { | ||
| 3687 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); | ||
| 3688 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n); | ||
| 3689 | } | ||
| 3690 | |||
| 3691 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3692 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3693 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of( | ||
| 3694 | const basic_string& __str, size_type __pos) const _NOEXCEPT { | ||
| 3695 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | ||
| 3696 | data(), size(), __str.data(), __pos, __str.size()); | ||
| 3697 | } | ||
| 3698 | |||
| 3699 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3700 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3701 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3702 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { | ||
| 3703 | __self_view __sv = __t; | ||
| 3704 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | ||
| 3705 | data(), size(), __sv.data(), __pos, __sv.size()); | ||
| 3706 | } | ||
| 3707 | |||
| 3708 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3709 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3710 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { | ||
| 3711 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr"); | ||
| 3712 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>( | ||
| 3713 | data(), size(), __s, __pos, traits_type::length(__s)); | ||
| 3714 | } | ||
| 3715 | |||
| 3716 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3717 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type | ||
| 3718 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT { | ||
| 3719 | return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos); | ||
| 3720 | } | ||
| 3721 | |||
| 3722 | // compare | 3530 | // compare |
| 3723 | 3531 | ||
| 3724 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3725 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3726 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT { | ||
| 3727 | __self_view __sv = __t; | ||
| 3728 | size_t __lhs_sz = size(); | ||
| 3729 | size_t __rhs_sz = __sv.size(); | ||
| 3730 | int __result = traits_type::compare(data(), __sv.data(), std::min(__lhs_sz, __rhs_sz)); | ||
| 3731 | if (__result != 0) | ||
| 3732 | return __result; | ||
| 3733 | if (__lhs_sz < __rhs_sz) | ||
| 3734 | return -1; | ||
| 3735 | if (__lhs_sz > __rhs_sz) | ||
| 3736 | return 1; | ||
| 3737 | return 0; | ||
| 3738 | } | ||
| 3739 | |||
| 3740 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3741 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int | ||
| 3742 | basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { | ||
| 3743 | return compare(__self_view(__str)); | ||
| 3744 | } | ||
| 3745 | |||
| 3746 | template <class _CharT, class _Traits, class _Allocator> | 3532 | template <class _CharT, class _Traits, class _Allocator> |
| 3747 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare( | 3533 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare( |
| 3748 | size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const { | 3534 | size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const { |
| 3749 | _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); | 3535 | _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); |
| 3750 | size_type __sz = size(); | 3536 | size_type __sz = size(); |
| 3751 | if (__pos1 > __sz || __n2 == npos) | 3537 | if (__pos1 > __sz || __n2 == npos) |
| 3752 | __throw_out_of_range(); | 3538 | this->__throw_out_of_range(); |
| 3753 | size_type __rlen = std::min(__n1, __sz - __pos1); | 3539 | size_type __rlen = std::min(__n1, __sz - __pos1); |
| 3754 | int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2)); | 3540 | int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2)); |
| 3755 | if (__r == 0) { | 3541 | if (__r == 0) { |
| ... | @@ -3761,51 +3547,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocato | ... | @@ -3761,51 +3547,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocato |
| 3761 | return __r; | 3547 | return __r; |
| 3762 | } | 3548 | } |
| 3763 | 3549 | ||
| 3764 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3765 | template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> > | ||
| 3766 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | ||
| 3767 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t) const { | ||
| 3768 | __self_view __sv = __t; | ||
| 3769 | return compare(__pos1, __n1, __sv.data(), __sv.size()); | ||
| 3770 | } | ||
| 3771 | |||
| 3772 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3773 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int | ||
| 3774 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str) const { | ||
| 3775 | return compare(__pos1, __n1, __str.data(), __str.size()); | ||
| 3776 | } | ||
| 3777 | |||
| 3778 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3779 | template <class _Tp, | ||
| 3780 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | ||
| 3781 | !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, | ||
| 3782 | int> > | ||
| 3783 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare( | ||
| 3784 | size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) const { | ||
| 3785 | __self_view __sv = __t; | ||
| 3786 | return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); | ||
| 3787 | } | ||
| 3788 | |||
| 3789 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3790 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare( | ||
| 3791 | size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const { | ||
| 3792 | return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); | ||
| 3793 | } | ||
| 3794 | |||
| 3795 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3796 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | ||
| 3797 | basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { | ||
| 3798 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); | ||
| 3799 | return compare(0, npos, __s, traits_type::length(__s)); | ||
| 3800 | } | ||
| 3801 | |||
| 3802 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3803 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int | ||
| 3804 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { | ||
| 3805 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr"); | ||
| 3806 | return compare(__pos1, __n1, __s, traits_type::length(__s)); | ||
| 3807 | } | ||
| 3808 | |||
| 3809 | // __invariants | 3550 | // __invariants |
| 3810 | 3551 | ||
| 3811 | template <class _CharT, class _Traits, class _Allocator> | 3552 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3821,18 +3562,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 bool basic_string<_CharT, _Traits, _Allocat | ... | @@ -3821,18 +3562,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 bool basic_string<_CharT, _Traits, _Allocat |
| 3821 | return true; | 3562 | return true; |
| 3822 | } | 3563 | } |
| 3823 | 3564 | ||
| 3824 | // __clear_and_shrink | ||
| 3825 | |||
| 3826 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3827 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT { | ||
| 3828 | clear(); | ||
| 3829 | if (__is_long()) { | ||
| 3830 | __annotate_delete(); | ||
| 3831 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), capacity() + 1); | ||
| 3832 | __rep_ = __rep(); | ||
| 3833 | } | ||
| 3834 | } | ||
| 3835 | |||
| 3836 | // operator== | 3565 | // operator== |
| 3837 | 3566 | ||
| 3838 | template <class _CharT, class _Traits, class _Allocator> | 3567 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -3987,83 +3716,73 @@ operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& | ... | @@ -3987,83 +3716,73 @@ operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& |
| 3987 | 3716 | ||
| 3988 | template <class _CharT, class _Traits, class _Allocator> | 3717 | template <class _CharT, class _Traits, class _Allocator> |
| 3989 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | 3718 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 3990 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | 3719 | __concatenate_strings(const _Allocator& __alloc, |
| 3991 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) { | 3720 | __type_identity_t<basic_string_view<_CharT, _Traits> > __str1, |
| 3721 | __type_identity_t<basic_string_view<_CharT, _Traits> > __str2) { | ||
| 3992 | using _String = basic_string<_CharT, _Traits, _Allocator>; | 3722 | using _String = basic_string<_CharT, _Traits, _Allocator>; |
| 3993 | auto __lhs_sz = __lhs.size(); | ||
| 3994 | auto __rhs_sz = __rhs.size(); | ||
| 3995 | _String __r(__uninitialized_size_tag(), | 3723 | _String __r(__uninitialized_size_tag(), |
| 3996 | __lhs_sz + __rhs_sz, | 3724 | __str1.size() + __str2.size(), |
| 3997 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | 3725 | _String::__alloc_traits::select_on_container_copy_construction(__alloc)); |
| 3998 | auto __ptr = std::__to_address(__r.__get_pointer()); | 3726 | auto __ptr = std::__to_address(__r.__get_pointer()); |
| 3999 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | 3727 | _Traits::copy(__ptr, __str1.data(), __str1.size()); |
| 4000 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | 3728 | _Traits::copy(__ptr + __str1.size(), __str2.data(), __str2.size()); |
| 4001 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | 3729 | _Traits::assign(__ptr[__str1.size() + __str2.size()], _CharT()); |
| 4002 | return __r; | 3730 | return __r; |
| 4003 | } | 3731 | } |
| 4004 | 3732 | ||
| 3733 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3734 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | ||
| 3735 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | ||
| 3736 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) { | ||
| 3737 | return std::__concatenate_strings<_CharT, _Traits>(__lhs.get_allocator(), __lhs, __rhs); | ||
| 3738 | } | ||
| 3739 | |||
| 4005 | template <class _CharT, class _Traits, class _Allocator> | 3740 | template <class _CharT, class _Traits, class _Allocator> |
| 4006 | _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | 3741 | _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 4007 | operator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { | 3742 | operator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { |
| 4008 | using _String = basic_string<_CharT, _Traits, _Allocator>; | 3743 | return std::__concatenate_strings<_CharT, _Traits>(__rhs.get_allocator(), __lhs, __rhs); |
| 4009 | auto __lhs_sz = _Traits::length(__lhs); | ||
| 4010 | auto __rhs_sz = __rhs.size(); | ||
| 4011 | _String __r(__uninitialized_size_tag(), | ||
| 4012 | __lhs_sz + __rhs_sz, | ||
| 4013 | _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); | ||
| 4014 | auto __ptr = std::__to_address(__r.__get_pointer()); | ||
| 4015 | _Traits::copy(__ptr, __lhs, __lhs_sz); | ||
| 4016 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | ||
| 4017 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | ||
| 4018 | return __r; | ||
| 4019 | } | 3744 | } |
| 4020 | 3745 | ||
| 3746 | extern template _LIBCPP_EXPORTED_FROM_ABI string operator+ | ||
| 3747 | <char, char_traits<char>, allocator<char> >(char const*, string const&); | ||
| 3748 | |||
| 4021 | template <class _CharT, class _Traits, class _Allocator> | 3749 | template <class _CharT, class _Traits, class _Allocator> |
| 4022 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | 3750 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 4023 | operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { | 3751 | operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { |
| 4024 | using _String = basic_string<_CharT, _Traits, _Allocator>; | 3752 | return std::__concatenate_strings<_CharT, _Traits>( |
| 4025 | typename _String::size_type __rhs_sz = __rhs.size(); | 3753 | __rhs.get_allocator(), basic_string_view<_CharT, _Traits>(std::addressof(__lhs), 1), __rhs); |
| 4026 | _String __r(__uninitialized_size_tag(), | ||
| 4027 | __rhs_sz + 1, | ||
| 4028 | _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); | ||
| 4029 | auto __ptr = std::__to_address(__r.__get_pointer()); | ||
| 4030 | _Traits::assign(__ptr, 1, __lhs); | ||
| 4031 | _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz); | ||
| 4032 | _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT()); | ||
| 4033 | return __r; | ||
| 4034 | } | 3754 | } |
| 4035 | 3755 | ||
| 4036 | template <class _CharT, class _Traits, class _Allocator> | 3756 | template <class _CharT, class _Traits, class _Allocator> |
| 4037 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | 3757 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 4038 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { | 3758 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { |
| 4039 | using _String = basic_string<_CharT, _Traits, _Allocator>; | 3759 | return std::__concatenate_strings<_CharT, _Traits>(__lhs.get_allocator(), __lhs, __rhs); |
| 4040 | typename _String::size_type __lhs_sz = __lhs.size(); | ||
| 4041 | typename _String::size_type __rhs_sz = _Traits::length(__rhs); | ||
| 4042 | _String __r(__uninitialized_size_tag(), | ||
| 4043 | __lhs_sz + __rhs_sz, | ||
| 4044 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | ||
| 4045 | auto __ptr = std::__to_address(__r.__get_pointer()); | ||
| 4046 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | ||
| 4047 | _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz); | ||
| 4048 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | ||
| 4049 | return __r; | ||
| 4050 | } | 3760 | } |
| 4051 | 3761 | ||
| 4052 | template <class _CharT, class _Traits, class _Allocator> | 3762 | template <class _CharT, class _Traits, class _Allocator> |
| 4053 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> | 3763 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 4054 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) { | 3764 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) { |
| 4055 | using _String = basic_string<_CharT, _Traits, _Allocator>; | 3765 | return std::__concatenate_strings<_CharT, _Traits>( |
| 4056 | typename _String::size_type __lhs_sz = __lhs.size(); | 3766 | __lhs.get_allocator(), __lhs, basic_string_view<_CharT, _Traits>(std::addressof(__rhs), 1)); |
| 4057 | _String __r(__uninitialized_size_tag(), | 3767 | } |
| 4058 | __lhs_sz + 1, | 3768 | # if _LIBCPP_STD_VER >= 26 |
| 4059 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | 3769 | |
| 4060 | auto __ptr = std::__to_address(__r.__get_pointer()); | 3770 | template <class _CharT, class _Traits, class _Allocator> |
| 4061 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | 3771 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> |
| 4062 | _Traits::assign(__ptr + __lhs_sz, 1, __rhs); | 3772 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4063 | _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT()); | 3773 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { |
| 4064 | return __r; | 3774 | return std::__concatenate_strings<_CharT, _Traits>(__lhs.get_allocator(), __lhs, __rhs); |
| 4065 | } | 3775 | } |
| 4066 | 3776 | ||
| 3777 | template <class _CharT, class _Traits, class _Allocator> | ||
| 3778 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 3779 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, | ||
| 3780 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) { | ||
| 3781 | return std::__concatenate_strings<_CharT, _Traits>(__rhs.get_allocator(), __lhs, __rhs); | ||
| 3782 | } | ||
| 3783 | |||
| 3784 | # endif // _LIBCPP_STD_VER >= 26 | ||
| 3785 | |||
| 4067 | # ifndef _LIBCPP_CXX03_LANG | 3786 | # ifndef _LIBCPP_CXX03_LANG |
| 4068 | 3787 | ||
| 4069 | template <class _CharT, class _Traits, class _Allocator> | 3788 | template <class _CharT, class _Traits, class _Allocator> |
| ... | @@ -4114,54 +3833,18 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { | ... | @@ -4114,54 +3833,18 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { |
| 4114 | 3833 | ||
| 4115 | # if _LIBCPP_STD_VER >= 26 | 3834 | # if _LIBCPP_STD_VER >= 26 |
| 4116 | 3835 | ||
| 4117 | template <class _CharT, class _Traits, class _Allocator> | ||
| 4118 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 4119 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, | ||
| 4120 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { | ||
| 4121 | using _String = basic_string<_CharT, _Traits, _Allocator>; | ||
| 4122 | typename _String::size_type __lhs_sz = __lhs.size(); | ||
| 4123 | typename _String::size_type __rhs_sz = __rhs.size(); | ||
| 4124 | _String __r(__uninitialized_size_tag(), | ||
| 4125 | __lhs_sz + __rhs_sz, | ||
| 4126 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | ||
| 4127 | auto __ptr = std::__to_address(__r.__get_pointer()); | ||
| 4128 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | ||
| 4129 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | ||
| 4130 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | ||
| 4131 | return __r; | ||
| 4132 | } | ||
| 4133 | |||
| 4134 | template <class _CharT, class _Traits, class _Allocator> | 3836 | template <class _CharT, class _Traits, class _Allocator> |
| 4135 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | 3837 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> |
| 4136 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, | 3838 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, |
| 4137 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { | 3839 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) { |
| 4138 | __lhs.append(__rhs); | 3840 | return std::move(__lhs.append(__rhs)); |
| 4139 | return std::move(__lhs); | ||
| 4140 | } | ||
| 4141 | |||
| 4142 | template <class _CharT, class _Traits, class _Allocator> | ||
| 4143 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | ||
| 4144 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, | ||
| 4145 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) { | ||
| 4146 | using _String = basic_string<_CharT, _Traits, _Allocator>; | ||
| 4147 | typename _String::size_type __lhs_sz = __lhs.size(); | ||
| 4148 | typename _String::size_type __rhs_sz = __rhs.size(); | ||
| 4149 | _String __r(__uninitialized_size_tag(), | ||
| 4150 | __lhs_sz + __rhs_sz, | ||
| 4151 | _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); | ||
| 4152 | auto __ptr = std::__to_address(__r.__get_pointer()); | ||
| 4153 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | ||
| 4154 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | ||
| 4155 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | ||
| 4156 | return __r; | ||
| 4157 | } | 3841 | } |
| 4158 | 3842 | ||
| 4159 | template <class _CharT, class _Traits, class _Allocator> | 3843 | template <class _CharT, class _Traits, class _Allocator> |
| 4160 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> | 3844 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> |
| 4161 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, | 3845 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, |
| 4162 | basic_string<_CharT, _Traits, _Allocator>&& __rhs) { | 3846 | basic_string<_CharT, _Traits, _Allocator>&& __rhs) { |
| 4163 | __rhs.insert(0, __lhs); | 3847 | return std::move(__rhs.insert(0, __lhs)); |
| 4164 | return std::move(__rhs); | ||
| 4165 | } | 3848 | } |
| 4166 | 3849 | ||
| 4167 | # endif // _LIBCPP_STD_VER >= 26 | 3850 | # endif // _LIBCPP_STD_VER >= 26 |
| ... | @@ -4274,7 +3957,7 @@ getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Al | ... | @@ -4274,7 +3957,7 @@ getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Al |
| 4274 | 3957 | ||
| 4275 | # if _LIBCPP_STD_VER >= 20 | 3958 | # if _LIBCPP_STD_VER >= 20 |
| 4276 | template <class _CharT, class _Traits, class _Allocator, class _Up> | 3959 | template <class _CharT, class _Traits, class _Allocator, class _Up> |
| 4277 | inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3960 | inline _LIBCPP_HIDE_FROM_ABI constexpr typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4278 | erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { | 3961 | erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { |
| 4279 | auto __old_size = __str.size(); | 3962 | auto __old_size = __str.size(); |
| 4280 | __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end()); | 3963 | __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end()); |
| ... | @@ -4282,7 +3965,7 @@ erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { | ... | @@ -4282,7 +3965,7 @@ erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { |
| 4282 | } | 3965 | } |
| 4283 | 3966 | ||
| 4284 | template <class _CharT, class _Traits, class _Allocator, class _Predicate> | 3967 | template <class _CharT, class _Traits, class _Allocator, class _Predicate> |
| 4285 | inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type | 3968 | inline _LIBCPP_HIDE_FROM_ABI constexpr typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4286 | erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { | 3969 | erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { |
| 4287 | auto __old_size = __str.size(); | 3970 | auto __old_size = __str.size(); |
| 4288 | __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end()); | 3971 | __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end()); |
| ... | @@ -4345,6 +4028,7 @@ _LIBCPP_POP_MACROS | ... | @@ -4345,6 +4028,7 @@ _LIBCPP_POP_MACROS |
| 4345 | # include <cstdlib> | 4028 | # include <cstdlib> |
| 4346 | # include <iterator> | 4029 | # include <iterator> |
| 4347 | # include <new> | 4030 | # include <new> |
| 4031 | # include <optional> | ||
| 4348 | # include <type_traits> | 4032 | # include <type_traits> |
| 4349 | # include <typeinfo> | 4033 | # include <typeinfo> |
| 4350 | # include <utility> | 4034 | # include <utility> |
lib/libcxx/include/string_view+8-3| ... | @@ -235,7 +235,8 @@ namespace std { | ... | @@ -235,7 +235,8 @@ namespace std { |
| 235 | # include <__type_traits/is_convertible.h> | 235 | # include <__type_traits/is_convertible.h> |
| 236 | # include <__type_traits/is_same.h> | 236 | # include <__type_traits/is_same.h> |
| 237 | # include <__type_traits/is_standard_layout.h> | 237 | # include <__type_traits/is_standard_layout.h> |
| 238 | # include <__type_traits/is_trivial.h> | 238 | # include <__type_traits/is_trivially_constructible.h> |
| 239 | # include <__type_traits/is_trivially_copyable.h> | ||
| 239 | # include <__type_traits/remove_cvref.h> | 240 | # include <__type_traits/remove_cvref.h> |
| 240 | # include <__type_traits/remove_reference.h> | 241 | # include <__type_traits/remove_reference.h> |
| 241 | # include <__type_traits/type_identity.h> | 242 | # include <__type_traits/type_identity.h> |
| ... | @@ -302,7 +303,10 @@ public: | ... | @@ -302,7 +303,10 @@ public: |
| 302 | 303 | ||
| 303 | static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array"); | 304 | static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array"); |
| 304 | static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout"); | 305 | static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout"); |
| 305 | static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial"); | 306 | static_assert(is_trivially_default_constructible<value_type>::value, |
| 307 | "Character type of basic_string_view must be trivially default constructible"); | ||
| 308 | static_assert(is_trivially_copyable<value_type>::value, | ||
| 309 | "Character type of basic_string_view must be trivially copyable"); | ||
| 306 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, | 310 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, |
| 307 | "traits_type::char_type must be the same type as CharT"); | 311 | "traits_type::char_type must be the same type as CharT"); |
| 308 | 312 | ||
| ... | @@ -447,7 +451,7 @@ public: | ... | @@ -447,7 +451,7 @@ public: |
| 447 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type | 451 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| 448 | copy(_CharT* __s, size_type __n, size_type __pos = 0) const { | 452 | copy(_CharT* __s, size_type __n, size_type __pos = 0) const { |
| 449 | if (__pos > size()) | 453 | if (__pos > size()) |
| 450 | __throw_out_of_range("string_view::copy"); | 454 | std::__throw_out_of_range("string_view::copy"); |
| 451 | size_type __rlen = std::min(__n, size() - __pos); | 455 | size_type __rlen = std::min(__n, size() - __pos); |
| 452 | _Traits::copy(__s, data() + __pos, __rlen); | 456 | _Traits::copy(__s, data() + __pos, __rlen); |
| 453 | return __rlen; | 457 | return __rlen; |
| ... | @@ -948,6 +952,7 @@ _LIBCPP_POP_MACROS | ... | @@ -948,6 +952,7 @@ _LIBCPP_POP_MACROS |
| 948 | # include <concepts> | 952 | # include <concepts> |
| 949 | # include <cstdlib> | 953 | # include <cstdlib> |
| 950 | # include <iterator> | 954 | # include <iterator> |
| 955 | # include <optional> | ||
| 951 | # include <type_traits> | 956 | # include <type_traits> |
| 952 | # endif | 957 | # endif |
| 953 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 958 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/strstream+31-24| ... | @@ -133,30 +133,33 @@ private: | ... | @@ -133,30 +133,33 @@ private: |
| 133 | # include <__cxx03/strstream> | 133 | # include <__cxx03/strstream> |
| 134 | #else | 134 | #else |
| 135 | # include <__config> | 135 | # include <__config> |
| 136 | # include <__ostream/basic_ostream.h> | ||
| 137 | # include <istream> | ||
| 138 | # include <streambuf> | ||
| 139 | # include <version> | ||
| 140 | 136 | ||
| 141 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 137 | # if _LIBCPP_HAS_LOCALIZATION |
| 142 | # pragma GCC system_header | ||
| 143 | # endif | ||
| 144 | 138 | ||
| 145 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | 139 | # include <__ostream/basic_ostream.h> |
| 140 | # include <istream> | ||
| 141 | # include <streambuf> | ||
| 142 | # include <version> | ||
| 143 | |||
| 144 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 145 | # pragma GCC system_header | ||
| 146 | # endif | ||
| 147 | |||
| 148 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | ||
| 146 | 149 | ||
| 147 | _LIBCPP_PUSH_MACROS | 150 | _LIBCPP_PUSH_MACROS |
| 148 | # include <__undef_macros> | 151 | # include <__undef_macros> |
| 149 | 152 | ||
| 150 | _LIBCPP_BEGIN_NAMESPACE_STD | 153 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 151 | 154 | ||
| 152 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf { | 155 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf { |
| 153 | public: | 156 | public: |
| 154 | # ifndef _LIBCPP_CXX03_LANG | 157 | # ifndef _LIBCPP_CXX03_LANG |
| 155 | _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {} | 158 | _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {} |
| 156 | explicit strstreambuf(streamsize __alsize); | 159 | explicit strstreambuf(streamsize __alsize); |
| 157 | # else | 160 | # else |
| 158 | explicit strstreambuf(streamsize __alsize = 0); | 161 | explicit strstreambuf(streamsize __alsize = 0); |
| 159 | # endif | 162 | # endif |
| 160 | strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); | 163 | strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); |
| 161 | strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); | 164 | strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); |
| 162 | strstreambuf(const char* __gnext, streamsize __n); | 165 | strstreambuf(const char* __gnext, streamsize __n); |
| ... | @@ -166,10 +169,10 @@ public: | ... | @@ -166,10 +169,10 @@ public: |
| 166 | strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr); | 169 | strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr); |
| 167 | strstreambuf(const unsigned char* __gnext, streamsize __n); | 170 | strstreambuf(const unsigned char* __gnext, streamsize __n); |
| 168 | 171 | ||
| 169 | # ifndef _LIBCPP_CXX03_LANG | 172 | # ifndef _LIBCPP_CXX03_LANG |
| 170 | _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs); | 173 | _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs); |
| 171 | _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs); | 174 | _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs); |
| 172 | # endif // _LIBCPP_CXX03_LANG | 175 | # endif // _LIBCPP_CXX03_LANG |
| 173 | 176 | ||
| 174 | ~strstreambuf() override; | 177 | ~strstreambuf() override; |
| 175 | 178 | ||
| ... | @@ -203,7 +206,7 @@ private: | ... | @@ -203,7 +206,7 @@ private: |
| 203 | void __init(char* __gnext, streamsize __n, char* __pbeg); | 206 | void __init(char* __gnext, streamsize __n, char* __pbeg); |
| 204 | }; | 207 | }; |
| 205 | 208 | ||
| 206 | # ifndef _LIBCPP_CXX03_LANG | 209 | # ifndef _LIBCPP_CXX03_LANG |
| 207 | 210 | ||
| 208 | inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs) | 211 | inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs) |
| 209 | : streambuf(__rhs), | 212 | : streambuf(__rhs), |
| ... | @@ -232,7 +235,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf& | ... | @@ -232,7 +235,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf& |
| 232 | return *this; | 235 | return *this; |
| 233 | } | 236 | } |
| 234 | 237 | ||
| 235 | # endif // _LIBCPP_CXX03_LANG | 238 | # endif // _LIBCPP_CXX03_LANG |
| 236 | 239 | ||
| 237 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream { | 240 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream { |
| 238 | public: | 241 | public: |
| ... | @@ -241,7 +244,7 @@ public: | ... | @@ -241,7 +244,7 @@ public: |
| 241 | _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} | 244 | _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} |
| 242 | _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} | 245 | _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} |
| 243 | 246 | ||
| 244 | # ifndef _LIBCPP_CXX03_LANG | 247 | # ifndef _LIBCPP_CXX03_LANG |
| 245 | _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension | 248 | _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension |
| 246 | : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { | 249 | : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 247 | istream::set_rdbuf(&__sb_); | 250 | istream::set_rdbuf(&__sb_); |
| ... | @@ -252,7 +255,7 @@ public: | ... | @@ -252,7 +255,7 @@ public: |
| 252 | istream::operator=(std::move(__rhs)); | 255 | istream::operator=(std::move(__rhs)); |
| 253 | return *this; | 256 | return *this; |
| 254 | } | 257 | } |
| 255 | # endif // _LIBCPP_CXX03_LANG | 258 | # endif // _LIBCPP_CXX03_LANG |
| 256 | 259 | ||
| 257 | ~istrstream() override; | 260 | ~istrstream() override; |
| 258 | 261 | ||
| ... | @@ -274,7 +277,7 @@ public: | ... | @@ -274,7 +277,7 @@ public: |
| 274 | _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) | 277 | _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) |
| 275 | : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} | 278 | : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} |
| 276 | 279 | ||
| 277 | # ifndef _LIBCPP_CXX03_LANG | 280 | # ifndef _LIBCPP_CXX03_LANG |
| 278 | _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension | 281 | _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension |
| 279 | : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { | 282 | : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 280 | ostream::set_rdbuf(&__sb_); | 283 | ostream::set_rdbuf(&__sb_); |
| ... | @@ -285,7 +288,7 @@ public: | ... | @@ -285,7 +288,7 @@ public: |
| 285 | ostream::operator=(std::move(__rhs)); | 288 | ostream::operator=(std::move(__rhs)); |
| 286 | return *this; | 289 | return *this; |
| 287 | } | 290 | } |
| 288 | # endif // _LIBCPP_CXX03_LANG | 291 | # endif // _LIBCPP_CXX03_LANG |
| 289 | 292 | ||
| 290 | ~ostrstream() override; | 293 | ~ostrstream() override; |
| 291 | 294 | ||
| ... | @@ -316,7 +319,7 @@ public: | ... | @@ -316,7 +319,7 @@ public: |
| 316 | _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) | 319 | _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) |
| 317 | : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} | 320 | : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} |
| 318 | 321 | ||
| 319 | # ifndef _LIBCPP_CXX03_LANG | 322 | # ifndef _LIBCPP_CXX03_LANG |
| 320 | _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension | 323 | _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension |
| 321 | : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { | 324 | : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 322 | iostream::set_rdbuf(&__sb_); | 325 | iostream::set_rdbuf(&__sb_); |
| ... | @@ -327,7 +330,7 @@ public: | ... | @@ -327,7 +330,7 @@ public: |
| 327 | iostream::operator=(std::move(__rhs)); | 330 | iostream::operator=(std::move(__rhs)); |
| 328 | return *this; | 331 | return *this; |
| 329 | } | 332 | } |
| 330 | # endif // _LIBCPP_CXX03_LANG | 333 | # endif // _LIBCPP_CXX03_LANG |
| 331 | 334 | ||
| 332 | ~strstream() override; | 335 | ~strstream() override; |
| 333 | 336 | ||
| ... | @@ -350,7 +353,11 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -350,7 +353,11 @@ _LIBCPP_END_NAMESPACE_STD |
| 350 | 353 | ||
| 351 | _LIBCPP_POP_MACROS | 354 | _LIBCPP_POP_MACROS |
| 352 | 355 | ||
| 353 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | 356 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || |
| 354 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 357 | // defined(_LIBCPP_BUILDING_LIBRARY) |
| 358 | |||
| 359 | # endif // _LIBCPP_HAS_LOCALIZATION | ||
| 360 | |||
| 361 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | ||
| 355 | 362 | ||
| 356 | #endif // _LIBCPP_STRSTREAM | 363 | #endif // _LIBCPP_STRSTREAM |
lib/libcxx/include/syncstream+8-9| ... | @@ -118,10 +118,15 @@ namespace std { | ... | @@ -118,10 +118,15 @@ namespace std { |
| 118 | */ | 118 | */ |
| 119 | 119 | ||
| 120 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 120 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 121 | # include <__cxx03/syncstream> | 121 | # include <__cxx03/__config> |
| 122 | #else | 122 | #else |
| 123 | # include <__config> | 123 | # include <__config> |
| 124 | 124 | ||
| 125 | // standard-mandated includes | ||
| 126 | |||
| 127 | // [syncstream.syn] | ||
| 128 | # include <ostream> | ||
| 129 | |||
| 125 | # if _LIBCPP_HAS_LOCALIZATION | 130 | # if _LIBCPP_HAS_LOCALIZATION |
| 126 | 131 | ||
| 127 | # include <__mutex/lock_guard.h> | 132 | # include <__mutex/lock_guard.h> |
| ... | @@ -130,17 +135,11 @@ namespace std { | ... | @@ -130,17 +135,11 @@ namespace std { |
| 130 | # include <iosfwd> // required for declaration of default arguments | 135 | # include <iosfwd> // required for declaration of default arguments |
| 131 | # include <streambuf> | 136 | # include <streambuf> |
| 132 | # include <string> | 137 | # include <string> |
| 133 | |||
| 134 | # if _LIBCPP_HAS_THREADS | 138 | # if _LIBCPP_HAS_THREADS |
| 135 | # include <map> | 139 | # include <map> |
| 136 | # include <shared_mutex> | 140 | # include <shared_mutex> |
| 137 | # endif | 141 | # endif |
| 138 | 142 | ||
| 139 | // standard-mandated includes | ||
| 140 | |||
| 141 | // [syncstream.syn] | ||
| 142 | # include <ostream> | ||
| 143 | |||
| 144 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 143 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 145 | # pragma GCC system_header | 144 | # pragma GCC system_header |
| 146 | # endif | 145 | # endif |
| ... | @@ -248,7 +247,7 @@ private: | ... | @@ -248,7 +247,7 @@ private: |
| 248 | // Therefore the allocator used in the constructor is passed to the | 247 | // Therefore the allocator used in the constructor is passed to the |
| 249 | // basic_string. The class does not keep a copy of this allocator. | 248 | // basic_string. The class does not keep a copy of this allocator. |
| 250 | template <class _CharT, class _Traits, class _Allocator> | 249 | template <class _CharT, class _Traits, class _Allocator> |
| 251 | class _LIBCPP_TEMPLATE_VIS basic_syncbuf : public basic_streambuf<_CharT, _Traits> { | 250 | class basic_syncbuf : public basic_streambuf<_CharT, _Traits> { |
| 252 | public: | 251 | public: |
| 253 | using char_type = _CharT; | 252 | using char_type = _CharT; |
| 254 | using traits_type = _Traits; | 253 | using traits_type = _Traits; |
| ... | @@ -439,7 +438,7 @@ swap(basic_syncbuf<_CharT, _Traits, _Allocator>& __lhs, basic_syncbuf<_CharT, _T | ... | @@ -439,7 +438,7 @@ swap(basic_syncbuf<_CharT, _Traits, _Allocator>& __lhs, basic_syncbuf<_CharT, _T |
| 439 | // basic_osyncstream | 438 | // basic_osyncstream |
| 440 | 439 | ||
| 441 | template <class _CharT, class _Traits, class _Allocator> | 440 | template <class _CharT, class _Traits, class _Allocator> |
| 442 | class _LIBCPP_TEMPLATE_VIS basic_osyncstream : public basic_ostream<_CharT, _Traits> { | 441 | class basic_osyncstream : public basic_ostream<_CharT, _Traits> { |
| 443 | public: | 442 | public: |
| 444 | using char_type = _CharT; | 443 | using char_type = _CharT; |
| 445 | using traits_type = _Traits; | 444 | using traits_type = _Traits; |
lib/libcxx/include/system_error+1| ... | @@ -168,6 +168,7 @@ template <> struct hash<std::error_condition>; | ... | @@ -168,6 +168,7 @@ template <> struct hash<std::error_condition>; |
| 168 | # include <cstdint> | 168 | # include <cstdint> |
| 169 | # include <cstring> | 169 | # include <cstring> |
| 170 | # include <limits> | 170 | # include <limits> |
| 171 | # include <optional> | ||
| 171 | # include <type_traits> | 172 | # include <type_traits> |
| 172 | # endif | 173 | # endif |
| 173 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 174 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/tuple+24-19| ... | @@ -211,11 +211,12 @@ template <class... Types> | ... | @@ -211,11 +211,12 @@ template <class... Types> |
| 211 | // clang-format on | 211 | // clang-format on |
| 212 | 212 | ||
| 213 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 213 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 214 | # include <__cxx03/tuple> | 214 | # include <__cxx03/__config> |
| 215 | #else | 215 | #else |
| 216 | # include <__compare/common_comparison_category.h> | 216 | # include <__compare/common_comparison_category.h> |
| 217 | # include <__compare/ordering.h> | 217 | # include <__compare/ordering.h> |
| 218 | # include <__compare/synth_three_way.h> | 218 | # include <__compare/synth_three_way.h> |
| 219 | # include <__concepts/boolean_testable.h> | ||
| 219 | # include <__config> | 220 | # include <__config> |
| 220 | # include <__cstddef/size_t.h> | 221 | # include <__cstddef/size_t.h> |
| 221 | # include <__fwd/array.h> | 222 | # include <__fwd/array.h> |
| ... | @@ -250,6 +251,7 @@ template <class... Types> | ... | @@ -250,6 +251,7 @@ template <class... Types> |
| 250 | # include <__type_traits/is_nothrow_assignable.h> | 251 | # include <__type_traits/is_nothrow_assignable.h> |
| 251 | # include <__type_traits/is_nothrow_constructible.h> | 252 | # include <__type_traits/is_nothrow_constructible.h> |
| 252 | # include <__type_traits/is_reference.h> | 253 | # include <__type_traits/is_reference.h> |
| 254 | # include <__type_traits/is_replaceable.h> | ||
| 253 | # include <__type_traits/is_same.h> | 255 | # include <__type_traits/is_same.h> |
| 254 | # include <__type_traits/is_swappable.h> | 256 | # include <__type_traits/is_swappable.h> |
| 255 | # include <__type_traits/is_trivially_relocatable.h> | 257 | # include <__type_traits/is_trivially_relocatable.h> |
| ... | @@ -257,6 +259,7 @@ template <class... Types> | ... | @@ -257,6 +259,7 @@ template <class... Types> |
| 257 | # include <__type_traits/maybe_const.h> | 259 | # include <__type_traits/maybe_const.h> |
| 258 | # include <__type_traits/nat.h> | 260 | # include <__type_traits/nat.h> |
| 259 | # include <__type_traits/negation.h> | 261 | # include <__type_traits/negation.h> |
| 262 | # include <__type_traits/reference_constructs_from_temporary.h> | ||
| 260 | # include <__type_traits/remove_cv.h> | 263 | # include <__type_traits/remove_cv.h> |
| 261 | # include <__type_traits/remove_cvref.h> | 264 | # include <__type_traits/remove_cvref.h> |
| 262 | # include <__type_traits/remove_reference.h> | 265 | # include <__type_traits/remove_reference.h> |
| ... | @@ -307,15 +310,6 @@ template <size_t _Ip, class _Hp, bool> | ... | @@ -307,15 +310,6 @@ template <size_t _Ip, class _Hp, bool> |
| 307 | class __tuple_leaf { | 310 | class __tuple_leaf { |
| 308 | _Hp __value_; | 311 | _Hp __value_; |
| 309 | 312 | ||
| 310 | template <class _Tp> | ||
| 311 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() { | ||
| 312 | # if __has_keyword(__reference_binds_to_temporary) | ||
| 313 | return !__reference_binds_to_temporary(_Hp, _Tp); | ||
| 314 | # else | ||
| 315 | return true; | ||
| 316 | # endif | ||
| 317 | } | ||
| 318 | |||
| 319 | public: | 313 | public: |
| 320 | _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete; | 314 | _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete; |
| 321 | 315 | ||
| ... | @@ -345,7 +339,7 @@ public: | ... | @@ -345,7 +339,7 @@ public: |
| 345 | _LIBCPP_HIDE_FROM_ABI | 339 | _LIBCPP_HIDE_FROM_ABI |
| 346 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value) | 340 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value) |
| 347 | : __value_(std::forward<_Tp>(__t)) { | 341 | : __value_(std::forward<_Tp>(__t)) { |
| 348 | static_assert(__can_bind_reference<_Tp&&>(), | 342 | static_assert(!__reference_constructs_from_temporary_v<_Hp, _Tp&&>, |
| 349 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); | 343 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); |
| 350 | } | 344 | } |
| 351 | 345 | ||
| ... | @@ -353,7 +347,7 @@ public: | ... | @@ -353,7 +347,7 @@ public: |
| 353 | _LIBCPP_HIDE_FROM_ABI | 347 | _LIBCPP_HIDE_FROM_ABI |
| 354 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t) | 348 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t) |
| 355 | : __value_(std::forward<_Tp>(__t)) { | 349 | : __value_(std::forward<_Tp>(__t)) { |
| 356 | static_assert(__can_bind_reference<_Tp&&>(), | 350 | static_assert(!__reference_constructs_from_temporary_v<_Hp, _Tp&&>, |
| 357 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); | 351 | "Attempted construction of reference element binds to a temporary whose lifetime has ended"); |
| 358 | } | 352 | } |
| 359 | 353 | ||
| ... | @@ -462,8 +456,8 @@ template <class _Indx, class... _Tp> | ... | @@ -462,8 +456,8 @@ template <class _Indx, class... _Tp> |
| 462 | struct __tuple_impl; | 456 | struct __tuple_impl; |
| 463 | 457 | ||
| 464 | template <size_t... _Indx, class... _Tp> | 458 | template <size_t... _Indx, class... _Tp> |
| 465 | struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...> | 459 | struct _LIBCPP_DECLSPEC_EMPTY_BASES |
| 466 | : public __tuple_leaf<_Indx, _Tp>... { | 460 | __tuple_impl<__tuple_indices<_Indx...>, _Tp...> : public __tuple_leaf<_Indx, _Tp>... { |
| 467 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept( | 461 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept( |
| 468 | __all<is_nothrow_default_constructible<_Tp>::value...>::value) {} | 462 | __all<is_nothrow_default_constructible<_Tp>::value...>::value) {} |
| 469 | 463 | ||
| ... | @@ -535,7 +529,7 @@ __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up | ... | @@ -535,7 +529,7 @@ __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up |
| 535 | } | 529 | } |
| 536 | 530 | ||
| 537 | template <class... _Tp> | 531 | template <class... _Tp> |
| 538 | class _LIBCPP_TEMPLATE_VIS tuple { | 532 | class _LIBCPP_NO_SPECIALIZATIONS tuple { |
| 539 | typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT; | 533 | typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT; |
| 540 | 534 | ||
| 541 | _BaseT __base_; | 535 | _BaseT __base_; |
| ... | @@ -555,6 +549,7 @@ class _LIBCPP_TEMPLATE_VIS tuple { | ... | @@ -555,6 +549,7 @@ class _LIBCPP_TEMPLATE_VIS tuple { |
| 555 | public: | 549 | public: |
| 556 | using __trivially_relocatable _LIBCPP_NODEBUG = | 550 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 557 | __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>; | 551 | __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>; |
| 552 | using __replaceable _LIBCPP_NODEBUG = __conditional_t<_And<__is_replaceable<_Tp>...>::value, tuple, void>; | ||
| 558 | 553 | ||
| 559 | // [tuple.cnstr] | 554 | // [tuple.cnstr] |
| 560 | 555 | ||
| ... | @@ -1005,8 +1000,12 @@ public: | ... | @@ -1005,8 +1000,12 @@ public: |
| 1005 | # endif // _LIBCPP_STD_VER >= 23 | 1000 | # endif // _LIBCPP_STD_VER >= 23 |
| 1006 | }; | 1001 | }; |
| 1007 | 1002 | ||
| 1003 | _LIBCPP_DIAGNOSTIC_PUSH | ||
| 1004 | # if __has_warning("-Winvalid-specialization") | ||
| 1005 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | ||
| 1006 | # endif | ||
| 1008 | template <> | 1007 | template <> |
| 1009 | class _LIBCPP_TEMPLATE_VIS tuple<> { | 1008 | class tuple<> { |
| 1010 | public: | 1009 | public: |
| 1011 | constexpr tuple() _NOEXCEPT = default; | 1010 | constexpr tuple() _NOEXCEPT = default; |
| 1012 | template <class _Alloc> | 1011 | template <class _Alloc> |
| ... | @@ -1022,18 +1021,19 @@ public: | ... | @@ -1022,18 +1021,19 @@ public: |
| 1022 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {} | 1021 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {} |
| 1023 | # endif | 1022 | # endif |
| 1024 | }; | 1023 | }; |
| 1024 | _LIBCPP_DIAGNOSTIC_POP | ||
| 1025 | 1025 | ||
| 1026 | # if _LIBCPP_STD_VER >= 23 | 1026 | # if _LIBCPP_STD_VER >= 23 |
| 1027 | template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual> | 1027 | template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual> |
| 1028 | requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; } | 1028 | requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; } |
| 1029 | struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> { | 1029 | struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> { |
| 1030 | using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; | 1030 | using type _LIBCPP_NODEBUG = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; |
| 1031 | }; | 1031 | }; |
| 1032 | 1032 | ||
| 1033 | template <class... _TTypes, class... _UTypes> | 1033 | template <class... _TTypes, class... _UTypes> |
| 1034 | requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; } | 1034 | requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; } |
| 1035 | struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> { | 1035 | struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> { |
| 1036 | using type = tuple<common_type_t<_TTypes, _UTypes>...>; | 1036 | using type _LIBCPP_NODEBUG = tuple<common_type_t<_TTypes, _UTypes>...>; |
| 1037 | }; | 1037 | }; |
| 1038 | # endif // _LIBCPP_STD_VER >= 23 | 1038 | # endif // _LIBCPP_STD_VER >= 23 |
| 1039 | 1039 | ||
| ... | @@ -1154,6 +1154,11 @@ struct __tuple_equal<0> { | ... | @@ -1154,6 +1154,11 @@ struct __tuple_equal<0> { |
| 1154 | }; | 1154 | }; |
| 1155 | 1155 | ||
| 1156 | template <class... _Tp, class... _Up> | 1156 | template <class... _Tp, class... _Up> |
| 1157 | # if _LIBCPP_STD_VER >= 26 | ||
| 1158 | requires(__all<requires(const _Tp& __t, const _Up& __u) { | ||
| 1159 | { __t == __u } -> __boolean_testable; | ||
| 1160 | }...>::value && (sizeof...(_Tp) == sizeof...(_Up))) | ||
| 1161 | # endif | ||
| 1157 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | 1162 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool |
| 1158 | operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { | 1163 | operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { |
| 1159 | static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes"); | 1164 | static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes"); |
| ... | @@ -1361,7 +1366,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { | ... | @@ -1361,7 +1366,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { |
| 1361 | } | 1366 | } |
| 1362 | 1367 | ||
| 1363 | template <class... _Tp, class _Alloc> | 1368 | template <class... _Tp, class _Alloc> |
| 1364 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; | 1369 | struct uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; |
| 1365 | 1370 | ||
| 1366 | # if _LIBCPP_STD_VER >= 17 | 1371 | # if _LIBCPP_STD_VER >= 17 |
| 1367 | # define _LIBCPP_NOEXCEPT_RETURN(...) \ | 1372 | # define _LIBCPP_NOEXCEPT_RETURN(...) \ |
lib/libcxx/include/type_traits+189-155| ... | @@ -18,13 +18,11 @@ namespace std | ... | @@ -18,13 +18,11 @@ namespace std |
| 18 | 18 | ||
| 19 | // helper class: | 19 | // helper class: |
| 20 | template <class T, T v> struct integral_constant; | 20 | template <class T, T v> struct integral_constant; |
| 21 | typedef integral_constant<bool, true> true_type; // C++11 | 21 | typedef integral_constant<bool, true> true_type; // since C++11 |
| 22 | typedef integral_constant<bool, false> false_type; // C++11 | 22 | typedef integral_constant<bool, false> false_type; // since C++11 |
| 23 | 23 | ||
| 24 | template <bool B> // C++14 | 24 | template <bool B> |
| 25 | using bool_constant = integral_constant<bool, B>; // C++14 | 25 | using bool_constant = integral_constant<bool, B>; // since C++17 |
| 26 | typedef bool_constant<true> true_type; // C++14 | ||
| 27 | typedef bool_constant<false> false_type; // C++14 | ||
| 28 | 26 | ||
| 29 | // helper traits | 27 | // helper traits |
| 30 | template <bool, class T = void> struct enable_if; | 28 | template <bool, class T = void> struct enable_if; |
| ... | @@ -32,7 +30,7 @@ namespace std | ... | @@ -32,7 +30,7 @@ namespace std |
| 32 | 30 | ||
| 33 | // Primary classification traits: | 31 | // Primary classification traits: |
| 34 | template <class T> struct is_void; | 32 | template <class T> struct is_void; |
| 35 | template <class T> struct is_null_pointer; // C++14 | 33 | template <class T> struct is_null_pointer; // since C++14 |
| 36 | template <class T> struct is_integral; | 34 | template <class T> struct is_integral; |
| 37 | template <class T> struct is_floating_point; | 35 | template <class T> struct is_floating_point; |
| 38 | template <class T> struct is_array; | 36 | template <class T> struct is_array; |
| ... | @@ -51,7 +49,7 @@ namespace std | ... | @@ -51,7 +49,7 @@ namespace std |
| 51 | template <class T> struct is_arithmetic; | 49 | template <class T> struct is_arithmetic; |
| 52 | template <class T> struct is_fundamental; | 50 | template <class T> struct is_fundamental; |
| 53 | template <class T> struct is_member_pointer; | 51 | template <class T> struct is_member_pointer; |
| 54 | template <class T> struct is_scoped_enum; // C++23 | 52 | template <class T> struct is_scoped_enum; // since C++23 |
| 55 | template <class T> struct is_scalar; | 53 | template <class T> struct is_scalar; |
| 56 | template <class T> struct is_object; | 54 | template <class T> struct is_object; |
| 57 | template <class T> struct is_compound; | 55 | template <class T> struct is_compound; |
| ... | @@ -75,9 +73,9 @@ namespace std | ... | @@ -75,9 +73,9 @@ namespace std |
| 75 | template <class T> struct remove_pointer; | 73 | template <class T> struct remove_pointer; |
| 76 | template <class T> struct add_pointer; | 74 | template <class T> struct add_pointer; |
| 77 | 75 | ||
| 78 | template<class T> struct type_identity; // C++20 | 76 | template<class T> struct type_identity; // since C++20 |
| 79 | template<class T> | 77 | template<class T> |
| 80 | using type_identity_t = typename type_identity<T>::type; // C++20 | 78 | using type_identity_t = typename type_identity<T>::type; // since C++20 |
| 81 | 79 | ||
| 82 | // Integral properties: | 80 | // Integral properties: |
| 83 | template <class T> struct is_signed; | 81 | template <class T> struct is_signed; |
| ... | @@ -91,20 +89,20 @@ namespace std | ... | @@ -91,20 +89,20 @@ namespace std |
| 91 | template <class T> struct remove_extent; | 89 | template <class T> struct remove_extent; |
| 92 | template <class T> struct remove_all_extents; | 90 | template <class T> struct remove_all_extents; |
| 93 | 91 | ||
| 94 | template <class T> struct is_bounded_array; // C++20 | 92 | template <class T> struct is_bounded_array; // since C++20 |
| 95 | template <class T> struct is_unbounded_array; // C++20 | 93 | template <class T> struct is_unbounded_array; // since C++20 |
| 96 | 94 | ||
| 97 | // Member introspection: | 95 | // Member introspection: |
| 98 | template <class T> struct is_pod; | 96 | template <class T> struct is_trivial; // deprecated in C++26 |
| 99 | template <class T> struct is_trivial; | 97 | template <class T> struct is_pod; // deprecated in C++20 |
| 100 | template <class T> struct is_trivially_copyable; | 98 | template <class T> struct is_trivially_copyable; |
| 101 | template <class T> struct is_standard_layout; | 99 | template <class T> struct is_standard_layout; |
| 102 | template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20 | 100 | template <class T> struct is_literal_type; // deprecated in C++17; removed in C++20 |
| 103 | template <class T> struct is_empty; | 101 | template <class T> struct is_empty; |
| 104 | template <class T> struct is_polymorphic; | 102 | template <class T> struct is_polymorphic; |
| 105 | template <class T> struct is_abstract; | 103 | template <class T> struct is_abstract; |
| 106 | template <class T> struct is_final; // C++14 | 104 | template <class T> struct is_final; // since C++14 |
| 107 | template <class T> struct is_aggregate; // C++17 | 105 | template <class T> struct is_aggregate; // since C++17 |
| 108 | 106 | ||
| 109 | template <class T, class... Args> struct is_constructible; | 107 | template <class T, class... Args> struct is_constructible; |
| 110 | template <class T> struct is_default_constructible; | 108 | template <class T> struct is_default_constructible; |
| ... | @@ -113,8 +111,8 @@ namespace std | ... | @@ -113,8 +111,8 @@ namespace std |
| 113 | template <class T, class U> struct is_assignable; | 111 | template <class T, class U> struct is_assignable; |
| 114 | template <class T> struct is_copy_assignable; | 112 | template <class T> struct is_copy_assignable; |
| 115 | template <class T> struct is_move_assignable; | 113 | template <class T> struct is_move_assignable; |
| 116 | template <class T, class U> struct is_swappable_with; // C++17 | 114 | template <class T, class U> struct is_swappable_with; // since C++17 |
| 117 | template <class T> struct is_swappable; // C++17 | 115 | template <class T> struct is_swappable; // since C++17 |
| 118 | template <class T> struct is_destructible; | 116 | template <class T> struct is_destructible; |
| 119 | 117 | ||
| 120 | template <class T, class... Args> struct is_trivially_constructible; | 118 | template <class T, class... Args> struct is_trivially_constructible; |
| ... | @@ -133,292 +131,328 @@ namespace std | ... | @@ -133,292 +131,328 @@ namespace std |
| 133 | template <class T, class U> struct is_nothrow_assignable; | 131 | template <class T, class U> struct is_nothrow_assignable; |
| 134 | template <class T> struct is_nothrow_copy_assignable; | 132 | template <class T> struct is_nothrow_copy_assignable; |
| 135 | template <class T> struct is_nothrow_move_assignable; | 133 | template <class T> struct is_nothrow_move_assignable; |
| 136 | template <class T, class U> struct is_nothrow_swappable_with; // C++17 | 134 | template <class T, class U> |
| 137 | template <class T> struct is_nothrow_swappable; // C++17 | 135 | struct is_nothrow_swappable_with; // since C++17 |
| 136 | template <class T> | ||
| 137 | struct is_nothrow_swappable; // since C++17 | ||
| 138 | template <class T> struct is_nothrow_destructible; | 138 | template <class T> struct is_nothrow_destructible; |
| 139 | 139 | ||
| 140 | template<class T> struct is_implicit_lifetime; // Since C++23 | 140 | template <class T> struct is_implicit_lifetime; // since C++23 |
| 141 | 141 | ||
| 142 | template <class T> struct has_virtual_destructor; | 142 | template <class T> struct has_virtual_destructor; |
| 143 | 143 | ||
| 144 | template<class T> struct has_unique_object_representations; // C++17 | 144 | template <class T> |
| 145 | struct has_unique_object_representations; // since C++17 | ||
| 146 | |||
| 147 | template<class T, class U> | ||
| 148 | struct reference_constructs_from_temporary; // since C++23 | ||
| 149 | template<class T, class U> | ||
| 150 | struct reference_converts_from_temporary; // since C++23 | ||
| 145 | 151 | ||
| 146 | // Relationships between types: | 152 | // Relationships between types: |
| 147 | template <class T, class U> struct is_same; | 153 | template <class T, class U> struct is_same; |
| 148 | template <class Base, class Derived> struct is_base_of; | 154 | template <class Base, class Derived> struct is_base_of; |
| 149 | template <class Base, class Derived> struct is_virtual_base_of; // C++26 | 155 | template <class Base, class Derived> |
| 156 | struct is_virtual_base_of; // since C++26 | ||
| 150 | 157 | ||
| 151 | template <class From, class To> struct is_convertible; | 158 | template <class From, class To> struct is_convertible; |
| 152 | template <typename From, typename To> struct is_nothrow_convertible; // C++20 | 159 | template <class From, class To> |
| 153 | template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20 | 160 | struct is_nothrow_convertible; // since C++20 |
| 154 | 161 | ||
| 155 | template <class Fn, class... ArgTypes> struct is_invocable; | 162 | template <class Fn, class... ArgTypes> struct is_invocable; // since C++17 |
| 156 | template <class R, class Fn, class... ArgTypes> struct is_invocable_r; | 163 | template <class R, class Fn, class... ArgTypes> |
| 164 | struct is_invocable_r; // since C++17 | ||
| 157 | 165 | ||
| 158 | template <class Fn, class... ArgTypes> struct is_nothrow_invocable; | 166 | template <class Fn, class... ArgTypes> |
| 159 | template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r; | 167 | struct is_nothrow_invocable; // since C++17 |
| 168 | template <class R, class Fn, class... ArgTypes> | ||
| 169 | struct is_nothrow_invocable_r; // since C++17 | ||
| 160 | 170 | ||
| 161 | // Alignment properties and transformations: | 171 | // Alignment properties and transformations: |
| 162 | template <class T> struct alignment_of; | 172 | template <class T> struct alignment_of; |
| 163 | template <size_t Len, size_t Align = most_stringent_alignment_requirement> | 173 | template <size_t Len, size_t Align = most_stringent_alignment_requirement> |
| 164 | struct aligned_storage; // deprecated in C++23 | 174 | struct aligned_storage; // deprecated in C++23 |
| 165 | template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23 | 175 | template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23 |
| 166 | template <class T> struct remove_cvref; // C++20 | 176 | template <class T> struct remove_cvref; // since C++20 |
| 167 | 177 | ||
| 168 | template <class T> struct decay; | 178 | template <class T> struct decay; |
| 169 | template <class... T> struct common_type; | 179 | template <class... T> struct common_type; |
| 170 | template <class T> struct underlying_type; | 180 | template <class T> struct underlying_type; |
| 171 | template <class> class result_of; // undefined; deprecated in C++17; removed in C++20 | 181 | template <class> struct result_of; // undefined; deprecated in C++17; removed in C++20 |
| 172 | template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20 | 182 | template <class Fn, class... ArgTypes> |
| 173 | template <class Fn, class... ArgTypes> struct invoke_result; // C++17 | 183 | struct result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20 |
| 184 | template <class Fn, class... ArgTypes> | ||
| 185 | struct invoke_result; // since C++17 | ||
| 174 | 186 | ||
| 175 | // const-volatile modifications: | 187 | // const-volatile modifications: |
| 176 | template <class T> | 188 | template <class T> |
| 177 | using remove_const_t = typename remove_const<T>::type; // C++14 | 189 | using remove_const_t = typename remove_const<T>::type; // since C++14 |
| 178 | template <class T> | 190 | template <class T> |
| 179 | using remove_volatile_t = typename remove_volatile<T>::type; // C++14 | 191 | using remove_volatile_t |
| 192 | = typename remove_volatile<T>::type; // since C++14 | ||
| 180 | template <class T> | 193 | template <class T> |
| 181 | using remove_cv_t = typename remove_cv<T>::type; // C++14 | 194 | using remove_cv_t = typename remove_cv<T>::type; // since C++14 |
| 182 | template <class T> | 195 | template <class T> |
| 183 | using add_const_t = typename add_const<T>::type; // C++14 | 196 | using add_const_t = typename add_const<T>::type; // since C++14 |
| 184 | template <class T> | 197 | template <class T> |
| 185 | using add_volatile_t = typename add_volatile<T>::type; // C++14 | 198 | using add_volatile_t = typename add_volatile<T>::type; // since C++14 |
| 186 | template <class T> | 199 | template <class T> |
| 187 | using add_cv_t = typename add_cv<T>::type; // C++14 | 200 | using add_cv_t = typename add_cv<T>::type; // since C++14 |
| 188 | 201 | ||
| 189 | // reference modifications: | 202 | // reference modifications: |
| 190 | template <class T> | 203 | template <class T> |
| 191 | using remove_reference_t = typename remove_reference<T>::type; // C++14 | 204 | using remove_reference_t |
| 205 | = typename remove_reference<T>::type; // since C++14 | ||
| 192 | template <class T> | 206 | template <class T> |
| 193 | using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 | 207 | using add_lvalue_reference_t |
| 208 | = typename add_lvalue_reference<T>::type; // since C++14 | ||
| 194 | template <class T> | 209 | template <class T> |
| 195 | using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 | 210 | using add_rvalue_reference_t |
| 211 | = typename add_rvalue_reference<T>::type; // since C++14 | ||
| 196 | 212 | ||
| 197 | // sign modifications: | 213 | // sign modifications: |
| 198 | template <class T> | 214 | template <class T> |
| 199 | using make_signed_t = typename make_signed<T>::type; // C++14 | 215 | using make_signed_t = typename make_signed<T>::type; // since C++14 |
| 200 | template <class T> | 216 | template <class T> |
| 201 | using make_unsigned_t = typename make_unsigned<T>::type; // C++14 | 217 | using make_unsigned_t = typename make_unsigned<T>::type; // since C++14 |
| 202 | 218 | ||
| 203 | // array modifications: | 219 | // array modifications: |
| 204 | template <class T> | 220 | template <class T> |
| 205 | using remove_extent_t = typename remove_extent<T>::type; // C++14 | 221 | using remove_extent_t |
| 222 | = typename remove_extent<T>::type; // since C++14 | ||
| 206 | template <class T> | 223 | template <class T> |
| 207 | using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 | 224 | using remove_all_extents_t |
| 225 | = typename remove_all_extents<T>::type; // since C++14 | ||
| 208 | 226 | ||
| 209 | template <class T> | 227 | template <class T> |
| 210 | inline constexpr bool is_bounded_array_v | 228 | inline constexpr bool is_bounded_array_v |
| 211 | = is_bounded_array<T>::value; // C++20 | 229 | = is_bounded_array<T>::value; // since C++20 |
| 212 | inline constexpr bool is_unbounded_array_v | 230 | inline constexpr bool is_unbounded_array_v |
| 213 | = is_unbounded_array<T>::value; // C++20 | 231 | = is_unbounded_array<T>::value; // since C++20 |
| 214 | 232 | ||
| 215 | // pointer modifications: | 233 | // pointer modifications: |
| 216 | template <class T> | 234 | template <class T> |
| 217 | using remove_pointer_t = typename remove_pointer<T>::type; // C++14 | 235 | using remove_pointer_t |
| 236 | = typename remove_pointer<T>::type; // since C++14 | ||
| 218 | template <class T> | 237 | template <class T> |
| 219 | using add_pointer_t = typename add_pointer<T>::type; // C++14 | 238 | using add_pointer_t = typename add_pointer<T>::type; // since C++14 |
| 220 | 239 | ||
| 221 | // other transformations: | 240 | // other transformations: |
| 222 | template <size_t Len, size_t Align=default-alignment> | 241 | template <size_t Len, size_t Align=default-alignment> |
| 223 | using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 | 242 | using aligned_storage_t |
| 243 | = typename aligned_storage<Len,Align>::type; // since C++14 | ||
| 224 | template <size_t Len, class... Types> | 244 | template <size_t Len, class... Types> |
| 225 | using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 | 245 | using aligned_union_t |
| 246 | = typename aligned_union<Len,Types...>::type; // since C++14 | ||
| 226 | template <class T> | 247 | template <class T> |
| 227 | using remove_cvref_t = typename remove_cvref<T>::type; // C++20 | 248 | using remove_cvref_t |
| 249 | = typename remove_cvref<T>::type; // since C++20 | ||
| 228 | template <class T> | 250 | template <class T> |
| 229 | using decay_t = typename decay<T>::type; // C++14 | 251 | using decay_t = typename decay<T>::type; // since C++14 |
| 230 | template <bool b, class T=void> | 252 | template <bool b, class T=void> |
| 231 | using enable_if_t = typename enable_if<b,T>::type; // C++14 | 253 | using enable_if_t = typename enable_if<b,T>::type; // since C++14 |
| 232 | template <bool b, class T, class F> | 254 | template <bool b, class T, class F> |
| 233 | using conditional_t = typename conditional<b,T,F>::type; // C++14 | 255 | using conditional_t |
| 256 | = typename conditional<b,T,F>::type; // since C++14 | ||
| 234 | template <class... T> | 257 | template <class... T> |
| 235 | using common_type_t = typename common_type<T...>::type; // C++14 | 258 | using common_type_t |
| 259 | = typename common_type<T...>::type; // since C++14 | ||
| 236 | template <class T> | 260 | template <class T> |
| 237 | using underlying_type_t = typename underlying_type<T>::type; // C++14 | 261 | using underlying_type_t |
| 262 | = typename underlying_type<T>::type; // since C++14 | ||
| 238 | template <class T> | 263 | template <class T> |
| 239 | using result_of_t = typename result_of<T>::type; // C++14; deprecated in C++17; removed in C++20 | 264 | using result_of_t = typename result_of<T>::type; // since C++14; deprecated in C++17; removed in C++20 |
| 240 | template <class Fn, class... ArgTypes> | 265 | template <class Fn, class... ArgTypes> |
| 241 | using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17 | 266 | using invoke_result_t |
| 267 | = typename invoke_result<Fn, ArgTypes...>::type; // since C++17 | ||
| 242 | 268 | ||
| 243 | template <class...> | 269 | template <class...> |
| 244 | using void_t = void; // C++17 | 270 | using void_t = void; // since C++17 |
| 245 | 271 | ||
| 246 | // See C++14 20.10.4.1, primary type categories | 272 | // See C++14 20.10.4.1, primary type categories |
| 247 | template <class T> inline constexpr bool is_void_v | 273 | template <class T> inline constexpr bool is_void_v |
| 248 | = is_void<T>::value; // C++17 | 274 | = is_void<T>::value; // since C++17 |
| 249 | template <class T> inline constexpr bool is_null_pointer_v | 275 | template <class T> inline constexpr bool is_null_pointer_v |
| 250 | = is_null_pointer<T>::value; // C++17 | 276 | = is_null_pointer<T>::value; // since C++17 |
| 251 | template <class T> inline constexpr bool is_integral_v | 277 | template <class T> inline constexpr bool is_integral_v |
| 252 | = is_integral<T>::value; // C++17 | 278 | = is_integral<T>::value; // since C++17 |
| 253 | template <class T> inline constexpr bool is_floating_point_v | 279 | template <class T> inline constexpr bool is_floating_point_v |
| 254 | = is_floating_point<T>::value; // C++17 | 280 | = is_floating_point<T>::value; // since C++17 |
| 255 | template <class T> inline constexpr bool is_array_v | 281 | template <class T> inline constexpr bool is_array_v |
| 256 | = is_array<T>::value; // C++17 | 282 | = is_array<T>::value; // since C++17 |
| 257 | template <class T> inline constexpr bool is_pointer_v | 283 | template <class T> inline constexpr bool is_pointer_v |
| 258 | = is_pointer<T>::value; // C++17 | 284 | = is_pointer<T>::value; // since C++17 |
| 259 | template <class T> inline constexpr bool is_lvalue_reference_v | 285 | template <class T> inline constexpr bool is_lvalue_reference_v |
| 260 | = is_lvalue_reference<T>::value; // C++17 | 286 | = is_lvalue_reference<T>::value; // since C++17 |
| 261 | template <class T> inline constexpr bool is_rvalue_reference_v | 287 | template <class T> inline constexpr bool is_rvalue_reference_v |
| 262 | = is_rvalue_reference<T>::value; // C++17 | 288 | = is_rvalue_reference<T>::value; // since C++17 |
| 263 | template <class T> inline constexpr bool is_member_object_pointer_v | 289 | template <class T> inline constexpr bool is_member_object_pointer_v |
| 264 | = is_member_object_pointer<T>::value; // C++17 | 290 | = is_member_object_pointer<T>::value; // since C++17 |
| 265 | template <class T> inline constexpr bool is_member_function_pointer_v | 291 | template <class T> inline constexpr bool is_member_function_pointer_v |
| 266 | = is_member_function_pointer<T>::value; // C++17 | 292 | = is_member_function_pointer<T>::value; // since C++17 |
| 267 | template <class T> inline constexpr bool is_enum_v | 293 | template <class T> inline constexpr bool is_enum_v |
| 268 | = is_enum<T>::value; // C++17 | 294 | = is_enum<T>::value; // since C++17 |
| 269 | template <class T> inline constexpr bool is_union_v | 295 | template <class T> inline constexpr bool is_union_v |
| 270 | = is_union<T>::value; // C++17 | 296 | = is_union<T>::value; // since C++17 |
| 271 | template <class T> inline constexpr bool is_class_v | 297 | template <class T> inline constexpr bool is_class_v |
| 272 | = is_class<T>::value; // C++17 | 298 | = is_class<T>::value; // since C++17 |
| 273 | template <class T> inline constexpr bool is_function_v | 299 | template <class T> inline constexpr bool is_function_v |
| 274 | = is_function<T>::value; // C++17 | 300 | = is_function<T>::value; // since C++17 |
| 275 | 301 | ||
| 276 | // See C++14 20.10.4.2, composite type categories | 302 | // See C++14 20.10.4.2, composite type categories |
| 277 | template <class T> inline constexpr bool is_reference_v | 303 | template <class T> inline constexpr bool is_reference_v |
| 278 | = is_reference<T>::value; // C++17 | 304 | = is_reference<T>::value; // since C++17 |
| 279 | template <class T> inline constexpr bool is_arithmetic_v | 305 | template <class T> inline constexpr bool is_arithmetic_v |
| 280 | = is_arithmetic<T>::value; // C++17 | 306 | = is_arithmetic<T>::value; // since C++17 |
| 281 | template <class T> inline constexpr bool is_fundamental_v | 307 | template <class T> inline constexpr bool is_fundamental_v |
| 282 | = is_fundamental<T>::value; // C++17 | 308 | = is_fundamental<T>::value; // since C++17 |
| 283 | template <class T> inline constexpr bool is_object_v | 309 | template <class T> inline constexpr bool is_object_v |
| 284 | = is_object<T>::value; // C++17 | 310 | = is_object<T>::value; // since C++17 |
| 285 | template <class T> inline constexpr bool is_scalar_v | 311 | template <class T> inline constexpr bool is_scalar_v |
| 286 | = is_scalar<T>::value; // C++17 | 312 | = is_scalar<T>::value; // since C++17 |
| 287 | template <class T> inline constexpr bool is_compound_v | 313 | template <class T> inline constexpr bool is_compound_v |
| 288 | = is_compound<T>::value; // C++17 | 314 | = is_compound<T>::value; // since C++17 |
| 289 | template <class T> inline constexpr bool is_member_pointer_v | 315 | template <class T> inline constexpr bool is_member_pointer_v |
| 290 | = is_member_pointer<T>::value; // C++17 | 316 | = is_member_pointer<T>::value; // since C++17 |
| 291 | template <class T> inline constexpr bool is_scoped_enum_v | 317 | template <class T> inline constexpr bool is_scoped_enum_v |
| 292 | = is_scoped_enum<T>::value; // C++23 | 318 | = is_scoped_enum<T>::value; // since C++23 |
| 293 | 319 | ||
| 294 | // See C++14 20.10.4.3, type properties | 320 | // See C++14 20.10.4.3, type properties |
| 295 | template <class T> inline constexpr bool is_const_v | 321 | template <class T> inline constexpr bool is_const_v |
| 296 | = is_const<T>::value; // C++17 | 322 | = is_const<T>::value; // since C++17 |
| 297 | template <class T> inline constexpr bool is_volatile_v | 323 | template <class T> inline constexpr bool is_volatile_v |
| 298 | = is_volatile<T>::value; // C++17 | 324 | = is_volatile<T>::value; // since C++17 |
| 299 | template <class T> inline constexpr bool is_trivial_v | 325 | template <class T> inline constexpr bool is_trivial_v |
| 300 | = is_trivial<T>::value; // C++17 | 326 | = is_trivial<T>::value; // since C++17; deprecated in C++26 |
| 301 | template <class T> inline constexpr bool is_trivially_copyable_v | 327 | template <class T> inline constexpr bool is_trivially_copyable_v |
| 302 | = is_trivially_copyable<T>::value; // C++17 | 328 | = is_trivially_copyable<T>::value; // since C++17 |
| 303 | template <class T> inline constexpr bool is_standard_layout_v | 329 | template <class T> inline constexpr bool is_standard_layout_v |
| 304 | = is_standard_layout<T>::value; // C++17 | 330 | = is_standard_layout<T>::value; // since C++17 |
| 305 | template <class T> inline constexpr bool is_pod_v | 331 | template <class T> inline constexpr bool is_pod_v |
| 306 | = is_pod<T>::value; // C++17 | 332 | = is_pod<T>::value; // since C++17; deprecated in C++20 |
| 307 | template <class T> inline constexpr bool is_literal_type_v | 333 | template <class T> inline constexpr bool is_literal_type_v |
| 308 | = is_literal_type<T>::value; // C++17; deprecated in C++17; removed in C++20 | 334 | = is_literal_type<T>::value; // since C++17; deprecated in C++17; removed in C++20 |
| 309 | template <class T> inline constexpr bool is_empty_v | 335 | template <class T> inline constexpr bool is_empty_v |
| 310 | = is_empty<T>::value; // C++17 | 336 | = is_empty<T>::value; // since C++17 |
| 311 | template <class T> inline constexpr bool is_polymorphic_v | 337 | template <class T> inline constexpr bool is_polymorphic_v |
| 312 | = is_polymorphic<T>::value; // C++17 | 338 | = is_polymorphic<T>::value; // since C++17 |
| 313 | template <class T> inline constexpr bool is_abstract_v | 339 | template <class T> inline constexpr bool is_abstract_v |
| 314 | = is_abstract<T>::value; // C++17 | 340 | = is_abstract<T>::value; // since C++17 |
| 315 | template <class T> inline constexpr bool is_final_v | 341 | template <class T> inline constexpr bool is_final_v |
| 316 | = is_final<T>::value; // C++17 | 342 | = is_final<T>::value; // since C++17 |
| 317 | template <class T> inline constexpr bool is_aggregate_v | 343 | template <class T> inline constexpr bool is_aggregate_v |
| 318 | = is_aggregate<T>::value; // C++17 | 344 | = is_aggregate<T>::value; // since C++17 |
| 319 | template <class T> inline constexpr bool is_signed_v | 345 | template <class T> inline constexpr bool is_signed_v |
| 320 | = is_signed<T>::value; // C++17 | 346 | = is_signed<T>::value; // since C++17 |
| 321 | template <class T> inline constexpr bool is_unsigned_v | 347 | template <class T> inline constexpr bool is_unsigned_v |
| 322 | = is_unsigned<T>::value; // C++17 | 348 | = is_unsigned<T>::value; // since C++17 |
| 323 | template <class T, class... Args> inline constexpr bool is_constructible_v | 349 | template <class T, class... Args> inline constexpr bool is_constructible_v |
| 324 | = is_constructible<T, Args...>::value; // C++17 | 350 | = is_constructible<T, Args...>::value; // since C++17 |
| 325 | template <class T> inline constexpr bool is_default_constructible_v | 351 | template <class T> inline constexpr bool is_default_constructible_v |
| 326 | = is_default_constructible<T>::value; // C++17 | 352 | = is_default_constructible<T>::value; // since C++17 |
| 327 | template <class T> inline constexpr bool is_copy_constructible_v | 353 | template <class T> inline constexpr bool is_copy_constructible_v |
| 328 | = is_copy_constructible<T>::value; // C++17 | 354 | = is_copy_constructible<T>::value; // since C++17 |
| 329 | template <class T> inline constexpr bool is_move_constructible_v | 355 | template <class T> inline constexpr bool is_move_constructible_v |
| 330 | = is_move_constructible<T>::value; // C++17 | 356 | = is_move_constructible<T>::value; // since C++17 |
| 331 | template <class T, class U> inline constexpr bool is_assignable_v | 357 | template <class T, class U> inline constexpr bool is_assignable_v |
| 332 | = is_assignable<T, U>::value; // C++17 | 358 | = is_assignable<T, U>::value; // since C++17 |
| 333 | template <class T> inline constexpr bool is_copy_assignable_v | 359 | template <class T> inline constexpr bool is_copy_assignable_v |
| 334 | = is_copy_assignable<T>::value; // C++17 | 360 | = is_copy_assignable<T>::value; // since C++17 |
| 335 | template <class T> inline constexpr bool is_move_assignable_v | 361 | template <class T> inline constexpr bool is_move_assignable_v |
| 336 | = is_move_assignable<T>::value; // C++17 | 362 | = is_move_assignable<T>::value; // since C++17 |
| 337 | template <class T, class U> inline constexpr bool is_swappable_with_v | 363 | template <class T, class U> inline constexpr bool is_swappable_with_v |
| 338 | = is_swappable_with<T, U>::value; // C++17 | 364 | = is_swappable_with<T, U>::value; // since C++17 |
| 339 | template <class T> inline constexpr bool is_swappable_v | 365 | template <class T> inline constexpr bool is_swappable_v |
| 340 | = is_swappable<T>::value; // C++17 | 366 | = is_swappable<T>::value; // since C++17 |
| 341 | template <class T> inline constexpr bool is_destructible_v | 367 | template <class T> inline constexpr bool is_destructible_v |
| 342 | = is_destructible<T>::value; // C++17 | 368 | = is_destructible<T>::value; // since C++17 |
| 343 | template <class T, class... Args> inline constexpr bool is_trivially_constructible_v | 369 | template <class T, class... Args> inline constexpr bool is_trivially_constructible_v |
| 344 | = is_trivially_constructible<T, Args...>::value; // C++17 | 370 | = is_trivially_constructible<T, Args...>::value; // since C++17 |
| 345 | template <class T> inline constexpr bool is_trivially_default_constructible_v | 371 | template <class T> inline constexpr bool is_trivially_default_constructible_v |
| 346 | = is_trivially_default_constructible<T>::value; // C++17 | 372 | = is_trivially_default_constructible<T>::value; // since C++17 |
| 347 | template <class T> inline constexpr bool is_trivially_copy_constructible_v | 373 | template <class T> inline constexpr bool is_trivially_copy_constructible_v |
| 348 | = is_trivially_copy_constructible<T>::value; // C++17 | 374 | = is_trivially_copy_constructible<T>::value; // since C++17 |
| 349 | template <class T> inline constexpr bool is_trivially_move_constructible_v | 375 | template <class T> inline constexpr bool is_trivially_move_constructible_v |
| 350 | = is_trivially_move_constructible<T>::value; // C++17 | 376 | = is_trivially_move_constructible<T>::value; // since C++17 |
| 351 | template <class T, class U> inline constexpr bool is_trivially_assignable_v | 377 | template <class T, class U> inline constexpr bool is_trivially_assignable_v |
| 352 | = is_trivially_assignable<T, U>::value; // C++17 | 378 | = is_trivially_assignable<T, U>::value; // since C++17 |
| 353 | template <class T> inline constexpr bool is_trivially_copy_assignable_v | 379 | template <class T> inline constexpr bool is_trivially_copy_assignable_v |
| 354 | = is_trivially_copy_assignable<T>::value; // C++17 | 380 | = is_trivially_copy_assignable<T>::value; // since C++17 |
| 355 | template <class T> inline constexpr bool is_trivially_move_assignable_v | 381 | template <class T> inline constexpr bool is_trivially_move_assignable_v |
| 356 | = is_trivially_move_assignable<T>::value; // C++17 | 382 | = is_trivially_move_assignable<T>::value; // since C++17 |
| 357 | template <class T> inline constexpr bool is_trivially_destructible_v | 383 | template <class T> inline constexpr bool is_trivially_destructible_v |
| 358 | = is_trivially_destructible<T>::value; // C++17 | 384 | = is_trivially_destructible<T>::value; // since C++17 |
| 359 | template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v | 385 | template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v |
| 360 | = is_nothrow_constructible<T, Args...>::value; // C++17 | 386 | = is_nothrow_constructible<T, Args...>::value; // since C++17 |
| 361 | template <class T> inline constexpr bool is_nothrow_default_constructible_v | 387 | template <class T> inline constexpr bool is_nothrow_default_constructible_v |
| 362 | = is_nothrow_default_constructible<T>::value; // C++17 | 388 | = is_nothrow_default_constructible<T>::value; // since C++17 |
| 363 | template <class T> inline constexpr bool is_nothrow_copy_constructible_v | 389 | template <class T> inline constexpr bool is_nothrow_copy_constructible_v |
| 364 | = is_nothrow_copy_constructible<T>::value; // C++17 | 390 | = is_nothrow_copy_constructible<T>::value; // since C++17 |
| 365 | template <class T> inline constexpr bool is_nothrow_move_constructible_v | 391 | template <class T> inline constexpr bool is_nothrow_move_constructible_v |
| 366 | = is_nothrow_move_constructible<T>::value; // C++17 | 392 | = is_nothrow_move_constructible<T>::value; // since C++17 |
| 367 | template <class T, class U> inline constexpr bool is_nothrow_assignable_v | 393 | template <class T, class U> inline constexpr bool is_nothrow_assignable_v |
| 368 | = is_nothrow_assignable<T, U>::value; // C++17 | 394 | = is_nothrow_assignable<T, U>::value; // since C++17 |
| 369 | template <class T> inline constexpr bool is_nothrow_copy_assignable_v | 395 | template <class T> inline constexpr bool is_nothrow_copy_assignable_v |
| 370 | = is_nothrow_copy_assignable<T>::value; // C++17 | 396 | = is_nothrow_copy_assignable<T>::value; // since C++17 |
| 371 | template <class T> inline constexpr bool is_nothrow_move_assignable_v | 397 | template <class T> inline constexpr bool is_nothrow_move_assignable_v |
| 372 | = is_nothrow_move_assignable<T>::value; // C++17 | 398 | = is_nothrow_move_assignable<T>::value; // since C++17 |
| 373 | template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v | 399 | template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v |
| 374 | = is_nothrow_swappable_with<T, U>::value; // C++17 | 400 | = is_nothrow_swappable_with<T, U>::value; // since C++17 |
| 375 | template <class T> inline constexpr bool is_nothrow_swappable_v | 401 | template <class T> inline constexpr bool is_nothrow_swappable_v |
| 376 | = is_nothrow_swappable<T>::value; // C++17 | 402 | = is_nothrow_swappable<T>::value; // since C++17 |
| 377 | template <class T> inline constexpr bool is_nothrow_destructible_v | 403 | template <class T> inline constexpr bool is_nothrow_destructible_v |
| 378 | = is_nothrow_destructible<T>::value; // C++17 | 404 | = is_nothrow_destructible<T>::value; // since C++17 |
| 379 | template<class T> | 405 | template <class T> inline constexpr bool is_implicit_lifetime_v |
| 380 | constexpr bool is_implicit_lifetime_v = is_implicit_lifetime<T>::value; // Since C++23 | 406 | = is_implicit_lifetime<T>::value; // since C++23 |
| 381 | template <class T> inline constexpr bool has_virtual_destructor_v | 407 | template <class T> inline constexpr bool has_virtual_destructor_v |
| 382 | = has_virtual_destructor<T>::value; // C++17 | 408 | = has_virtual_destructor<T>::value; // since C++17 |
| 383 | template<class T> inline constexpr bool has_unique_object_representations_v // C++17 | 409 | template<class T> inline constexpr bool has_unique_object_representations_v |
| 384 | = has_unique_object_representations<T>::value; | 410 | = has_unique_object_representations<T>::value; // since C++17 |
| 411 | template<class T, class U> | ||
| 412 | constexpr bool reference_constructs_from_temporary_v | ||
| 413 | = reference_constructs_from_temporary<T, U>::value; // since C++23 | ||
| 414 | template<class T, class U> | ||
| 415 | constexpr bool reference_converts_from_temporary_v | ||
| 416 | = reference_converts_from_temporary<T, U>::value; // since C++23 | ||
| 385 | 417 | ||
| 386 | // See C++14 20.10.5, type property queries | 418 | // See C++14 20.10.5, type property queries |
| 387 | template <class T> inline constexpr size_t alignment_of_v | 419 | template <class T> inline constexpr size_t alignment_of_v |
| 388 | = alignment_of<T>::value; // C++17 | 420 | = alignment_of<T>::value; // since C++17 |
| 389 | template <class T> inline constexpr size_t rank_v | 421 | template <class T> inline constexpr size_t rank_v |
| 390 | = rank<T>::value; // C++17 | 422 | = rank<T>::value; // since C++17 |
| 391 | template <class T, unsigned I = 0> inline constexpr size_t extent_v | 423 | template <class T, unsigned I = 0> inline constexpr size_t extent_v |
| 392 | = extent<T, I>::value; // C++17 | 424 | = extent<T, I>::value; // since C++17 |
| 393 | 425 | ||
| 394 | // See C++14 20.10.6, type relations | 426 | // See C++14 20.10.6, type relations |
| 395 | template <class T, class U> inline constexpr bool is_same_v | 427 | template <class T, class U> inline constexpr bool is_same_v |
| 396 | = is_same<T, U>::value; // C++17 | 428 | = is_same<T, U>::value; // since C++17 |
| 397 | template <class Base, class Derived> inline constexpr bool is_base_of_v | 429 | template <class Base, class Derived> inline constexpr bool is_base_of_v |
| 398 | = is_base_of<Base, Derived>::value; // C++17 | 430 | = is_base_of<Base, Derived>::value; // since C++17 |
| 399 | template <class Base, class Derived> inline constexpr bool is_virtual_base_of_v | 431 | template <class Base, class Derived> inline constexpr bool is_virtual_base_of_v |
| 400 | = is_virtual_base_of<Base, Derived>::value; // C++26 | 432 | = is_virtual_base_of<Base, Derived>::value; // since C++26 |
| 401 | template <class From, class To> inline constexpr bool is_convertible_v | 433 | template <class From, class To> inline constexpr bool is_convertible_v |
| 402 | = is_convertible<From, To>::value; // C++17 | 434 | = is_convertible<From, To>::value; // since C++17 |
| 435 | template <class From, class To> inline constexpr bool is_nothrow_convertible_v | ||
| 436 | = is_nothrow_convertible<From, To>::value; // since C++20 | ||
| 403 | template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v | 437 | template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v |
| 404 | = is_invocable<Fn, ArgTypes...>::value; // C++17 | 438 | = is_invocable<Fn, ArgTypes...>::value; // since C++17 |
| 405 | template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v | 439 | template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v |
| 406 | = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17 | 440 | = is_invocable_r<R, Fn, ArgTypes...>::value; // since C++17 |
| 407 | template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v | 441 | template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v |
| 408 | = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17 | 442 | = is_nothrow_invocable<Fn, ArgTypes...>::value; // since C++17 |
| 409 | template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v | 443 | template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v |
| 410 | = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17 | 444 | = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // since C++17 |
| 411 | 445 | ||
| 412 | // [meta.logical], logical operator traits: | 446 | // [meta.logical], logical operator traits: |
| 413 | template<class... B> struct conjunction; // C++17 | 447 | template<class... B> struct conjunction; // since C++17 |
| 414 | template<class... B> | 448 | template<class... B> inline constexpr bool conjunction_v |
| 415 | inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17 | 449 | = conjunction<B...>::value; // since C++17 |
| 416 | template<class... B> struct disjunction; // C++17 | 450 | template<class... B> struct disjunction; // since C++17 |
| 417 | template<class... B> | 451 | template<class... B> inline constexpr bool disjunction_v |
| 418 | inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17 | 452 | = disjunction<B...>::value; // since C++17 |
| 419 | template<class B> struct negation; // C++17 | 453 | template<class B> struct negation; // since C++17 |
| 420 | template<class B> | 454 | template<class B> inline constexpr bool negation_v |
| 421 | inline constexpr bool negation_v = negation<B>::value; // C++17 | 455 | = negation<B>::value; // since C++17 |
| 422 | 456 | ||
| 423 | } | 457 | } |
| 424 | 458 | ||
| ... | @@ -429,9 +463,8 @@ namespace std | ... | @@ -429,9 +463,8 @@ namespace std |
| 429 | #else | 463 | #else |
| 430 | # include <__config> | 464 | # include <__config> |
| 431 | # include <__type_traits/add_cv_quals.h> | 465 | # include <__type_traits/add_cv_quals.h> |
| 432 | # include <__type_traits/add_lvalue_reference.h> | ||
| 433 | # include <__type_traits/add_pointer.h> | 466 | # include <__type_traits/add_pointer.h> |
| 434 | # include <__type_traits/add_rvalue_reference.h> | 467 | # include <__type_traits/add_reference.h> |
| 435 | # include <__type_traits/aligned_storage.h> | 468 | # include <__type_traits/aligned_storage.h> |
| 436 | # include <__type_traits/aligned_union.h> | 469 | # include <__type_traits/aligned_union.h> |
| 437 | # include <__type_traits/alignment_of.h> | 470 | # include <__type_traits/alignment_of.h> |
| ... | @@ -515,7 +548,6 @@ namespace std | ... | @@ -515,7 +548,6 @@ namespace std |
| 515 | # include <__type_traits/common_reference.h> | 548 | # include <__type_traits/common_reference.h> |
| 516 | # include <__type_traits/is_bounded_array.h> | 549 | # include <__type_traits/is_bounded_array.h> |
| 517 | # include <__type_traits/is_constant_evaluated.h> | 550 | # include <__type_traits/is_constant_evaluated.h> |
| 518 | # include <__type_traits/is_nothrow_convertible.h> | ||
| 519 | # include <__type_traits/is_unbounded_array.h> | 551 | # include <__type_traits/is_unbounded_array.h> |
| 520 | # include <__type_traits/type_identity.h> | 552 | # include <__type_traits/type_identity.h> |
| 521 | # include <__type_traits/unwrap_ref.h> | 553 | # include <__type_traits/unwrap_ref.h> |
| ... | @@ -523,6 +555,8 @@ namespace std | ... | @@ -523,6 +555,8 @@ namespace std |
| 523 | 555 | ||
| 524 | # if _LIBCPP_STD_VER >= 23 | 556 | # if _LIBCPP_STD_VER >= 23 |
| 525 | # include <__type_traits/is_implicit_lifetime.h> | 557 | # include <__type_traits/is_implicit_lifetime.h> |
| 558 | # include <__type_traits/reference_constructs_from_temporary.h> | ||
| 559 | # include <__type_traits/reference_converts_from_temporary.h> | ||
| 526 | # endif | 560 | # endif |
| 527 | 561 | ||
| 528 | # include <version> | 562 | # include <version> |
lib/libcxx/include/typeindex+3-3| ... | @@ -62,7 +62,7 @@ struct hash<type_index> | ... | @@ -62,7 +62,7 @@ struct hash<type_index> |
| 62 | 62 | ||
| 63 | _LIBCPP_BEGIN_NAMESPACE_STD | 63 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 64 | 64 | ||
| 65 | class _LIBCPP_TEMPLATE_VIS type_index { | 65 | class type_index { |
| 66 | const type_info* __t_; | 66 | const type_info* __t_; |
| 67 | 67 | ||
| 68 | public: | 68 | public: |
| ... | @@ -91,10 +91,10 @@ public: | ... | @@ -91,10 +91,10 @@ public: |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | template <class _Tp> | 93 | template <class _Tp> |
| 94 | struct _LIBCPP_TEMPLATE_VIS hash; | 94 | struct hash; |
| 95 | 95 | ||
| 96 | template <> | 96 | template <> |
| 97 | struct _LIBCPP_TEMPLATE_VIS 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 | _LIBCPP_HIDE_FROM_ABI size_t operator()(type_index __index) const _NOEXCEPT { return __index.hash_code(); } |
| 99 | }; | 99 | }; |
| 100 | 100 |
lib/libcxx/include/typeinfo+2-2| ... | @@ -354,7 +354,7 @@ public: | ... | @@ -354,7 +354,7 @@ public: |
| 354 | 354 | ||
| 355 | # if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 | 355 | # if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 |
| 356 | 356 | ||
| 357 | namespace std { | 357 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 358 | 358 | ||
| 359 | class bad_cast : public exception { | 359 | class bad_cast : public exception { |
| 360 | public: | 360 | public: |
| ... | @@ -372,7 +372,7 @@ private: | ... | @@ -372,7 +372,7 @@ private: |
| 372 | bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {} | 372 | bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {} |
| 373 | }; | 373 | }; |
| 374 | 374 | ||
| 375 | } // namespace std | 375 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 376 | 376 | ||
| 377 | # endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 | 377 | # endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 |
| 378 | 378 |
lib/libcxx/include/unordered_map+68-161| ... | @@ -654,9 +654,7 @@ public: | ... | @@ -654,9 +654,7 @@ public: |
| 654 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) | 654 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) |
| 655 | : _Hash(__h) {} | 655 | : _Hash(__h) {} |
| 656 | _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return *this; } | 656 | _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return *this; } |
| 657 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { | 657 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return static_cast<const _Hash&>(*this)(__x.first); } |
| 658 | return static_cast<const _Hash&>(*this)(__x.__get_value().first); | ||
| 659 | } | ||
| 660 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); } | 658 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); } |
| 661 | # if _LIBCPP_STD_VER >= 20 | 659 | # if _LIBCPP_STD_VER >= 20 |
| 662 | template <typename _K2> | 660 | template <typename _K2> |
| ... | @@ -680,7 +678,7 @@ public: | ... | @@ -680,7 +678,7 @@ public: |
| 680 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) | 678 | _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) |
| 681 | : __hash_(__h) {} | 679 | : __hash_(__h) {} |
| 682 | _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; } | 680 | _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; } |
| 683 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.__get_value().first); } | 681 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.first); } |
| 684 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); } | 682 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); } |
| 685 | # if _LIBCPP_STD_VER >= 20 | 683 | # if _LIBCPP_STD_VER >= 20 |
| 686 | template <typename _K2> | 684 | template <typename _K2> |
| ... | @@ -713,10 +711,10 @@ public: | ... | @@ -713,10 +711,10 @@ public: |
| 713 | : _Pred(__p) {} | 711 | : _Pred(__p) {} |
| 714 | _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return *this; } | 712 | _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return *this; } |
| 715 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { | 713 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { |
| 716 | return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first); | 714 | return static_cast<const _Pred&>(*this)(__x.first, __y.first); |
| 717 | } | 715 | } |
| 718 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { | 716 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { |
| 719 | return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y); | 717 | return static_cast<const _Pred&>(*this)(__x.first, __y); |
| 720 | } | 718 | } |
| 721 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { | 719 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { |
| 722 | return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first); | 720 | return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first); |
| ... | @@ -724,7 +722,7 @@ public: | ... | @@ -724,7 +722,7 @@ public: |
| 724 | # if _LIBCPP_STD_VER >= 20 | 722 | # if _LIBCPP_STD_VER >= 20 |
| 725 | template <typename _K2> | 723 | template <typename _K2> |
| 726 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const { | 724 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const { |
| 727 | return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y); | 725 | return static_cast<const _Pred&>(*this)(__x.first, __y); |
| 728 | } | 726 | } |
| 729 | template <typename _K2> | 727 | template <typename _K2> |
| 730 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const { | 728 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const { |
| ... | @@ -755,23 +753,17 @@ public: | ... | @@ -755,23 +753,17 @@ public: |
| 755 | _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value) | 753 | _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value) |
| 756 | : __pred_(__p) {} | 754 | : __pred_(__p) {} |
| 757 | _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return __pred_; } | 755 | _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return __pred_; } |
| 758 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { | 756 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { return __pred_(__x.first, __y.first); } |
| 759 | return __pred_(__x.__get_value().first, __y.__get_value().first); | 757 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { return __pred_(__x.first, __y); } |
| 760 | } | 758 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { return __pred_(__x, __y.first); } |
| 761 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { | ||
| 762 | return __pred_(__x.__get_value().first, __y); | ||
| 763 | } | ||
| 764 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { | ||
| 765 | return __pred_(__x, __y.__get_value().first); | ||
| 766 | } | ||
| 767 | # if _LIBCPP_STD_VER >= 20 | 759 | # if _LIBCPP_STD_VER >= 20 |
| 768 | template <typename _K2> | 760 | template <typename _K2> |
| 769 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const { | 761 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const { |
| 770 | return __pred_(__x.__get_value().first, __y); | 762 | return __pred_(__x.first, __y); |
| 771 | } | 763 | } |
| 772 | template <typename _K2> | 764 | template <typename _K2> |
| 773 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const { | 765 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const { |
| 774 | return __pred_(__x, __y.__get_value().first); | 766 | return __pred_(__x, __y.first); |
| 775 | } | 767 | } |
| 776 | template <typename _K2> | 768 | template <typename _K2> |
| 777 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _K2& __y) const { | 769 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _K2& __y) const { |
| ... | @@ -833,99 +825,19 @@ public: | ... | @@ -833,99 +825,19 @@ public: |
| 833 | 825 | ||
| 834 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { | 826 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 835 | if (__second_constructed) | 827 | if (__second_constructed) |
| 836 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().second)); | 828 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().second)); |
| 837 | if (__first_constructed) | 829 | if (__first_constructed) |
| 838 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().first)); | 830 | __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().first)); |
| 839 | if (__p) | 831 | if (__p) |
| 840 | __alloc_traits::deallocate(__na_, __p, 1); | 832 | __alloc_traits::deallocate(__na_, __p, 1); |
| 841 | } | 833 | } |
| 842 | }; | 834 | }; |
| 843 | 835 | ||
| 844 | # ifndef _LIBCPP_CXX03_LANG | ||
| 845 | template <class _Key, class _Tp> | 836 | template <class _Key, class _Tp> |
| 846 | struct _LIBCPP_STANDALONE_DEBUG __hash_value_type { | 837 | struct __hash_value_type; |
| 847 | typedef _Key key_type; | ||
| 848 | typedef _Tp mapped_type; | ||
| 849 | typedef pair<const key_type, mapped_type> value_type; | ||
| 850 | typedef pair<key_type&, mapped_type&> __nc_ref_pair_type; | ||
| 851 | typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type; | ||
| 852 | |||
| 853 | private: | ||
| 854 | value_type __cc_; | ||
| 855 | |||
| 856 | public: | ||
| 857 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { | ||
| 858 | # if _LIBCPP_STD_VER >= 17 | ||
| 859 | return *std::launder(std::addressof(__cc_)); | ||
| 860 | # else | ||
| 861 | return __cc_; | ||
| 862 | # endif | ||
| 863 | } | ||
| 864 | |||
| 865 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { | ||
| 866 | # if _LIBCPP_STD_VER >= 17 | ||
| 867 | return *std::launder(std::addressof(__cc_)); | ||
| 868 | # else | ||
| 869 | return __cc_; | ||
| 870 | # endif | ||
| 871 | } | ||
| 872 | |||
| 873 | _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() { | ||
| 874 | value_type& __v = __get_value(); | ||
| 875 | return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second); | ||
| 876 | } | ||
| 877 | |||
| 878 | _LIBCPP_HIDE_FROM_ABI __nc_rref_pair_type __move() { | ||
| 879 | value_type& __v = __get_value(); | ||
| 880 | return __nc_rref_pair_type(std::move(const_cast<key_type&>(__v.first)), std::move(__v.second)); | ||
| 881 | } | ||
| 882 | |||
| 883 | _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(const __hash_value_type& __v) { | ||
| 884 | __ref() = __v.__get_value(); | ||
| 885 | return *this; | ||
| 886 | } | ||
| 887 | |||
| 888 | _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(__hash_value_type&& __v) { | ||
| 889 | __ref() = __v.__move(); | ||
| 890 | return *this; | ||
| 891 | } | ||
| 892 | |||
| 893 | template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0> | ||
| 894 | _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(_ValueTp&& __v) { | ||
| 895 | __ref() = std::forward<_ValueTp>(__v); | ||
| 896 | return *this; | ||
| 897 | } | ||
| 898 | |||
| 899 | __hash_value_type(const __hash_value_type& __v) = delete; | ||
| 900 | __hash_value_type(__hash_value_type&& __v) = delete; | ||
| 901 | template <class... _Args> | ||
| 902 | explicit __hash_value_type(_Args&&... __args) = delete; | ||
| 903 | |||
| 904 | ~__hash_value_type() = delete; | ||
| 905 | }; | ||
| 906 | |||
| 907 | # else | ||
| 908 | |||
| 909 | template <class _Key, class _Tp> | ||
| 910 | struct __hash_value_type { | ||
| 911 | typedef _Key key_type; | ||
| 912 | typedef _Tp mapped_type; | ||
| 913 | typedef pair<const key_type, mapped_type> value_type; | ||
| 914 | |||
| 915 | private: | ||
| 916 | value_type __cc_; | ||
| 917 | |||
| 918 | public: | ||
| 919 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } | ||
| 920 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } | ||
| 921 | |||
| 922 | ~__hash_value_type() = delete; | ||
| 923 | }; | ||
| 924 | |||
| 925 | # endif | ||
| 926 | 838 | ||
| 927 | template <class _HashIterator> | 839 | template <class _HashIterator> |
| 928 | class _LIBCPP_TEMPLATE_VIS __hash_map_iterator { | 840 | class __hash_map_iterator { |
| 929 | _HashIterator __i_; | 841 | _HashIterator __i_; |
| 930 | 842 | ||
| 931 | typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; | 843 | typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; |
| ... | @@ -941,8 +853,8 @@ public: | ... | @@ -941,8 +853,8 @@ public: |
| 941 | 853 | ||
| 942 | _LIBCPP_HIDE_FROM_ABI __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} | 854 | _LIBCPP_HIDE_FROM_ABI __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} |
| 943 | 855 | ||
| 944 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } | 856 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; } |
| 945 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } | 857 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); } |
| 946 | 858 | ||
| 947 | _LIBCPP_HIDE_FROM_ABI __hash_map_iterator& operator++() { | 859 | _LIBCPP_HIDE_FROM_ABI __hash_map_iterator& operator++() { |
| 948 | ++__i_; | 860 | ++__i_; |
| ... | @@ -964,19 +876,19 @@ public: | ... | @@ -964,19 +876,19 @@ public: |
| 964 | # endif | 876 | # endif |
| 965 | 877 | ||
| 966 | template <class, class, class, class, class> | 878 | template <class, class, class, class, class> |
| 967 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; | 879 | friend class unordered_map; |
| 968 | template <class, class, class, class, class> | 880 | template <class, class, class, class, class> |
| 969 | friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; | 881 | friend class unordered_multimap; |
| 970 | template <class> | 882 | template <class> |
| 971 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; | 883 | friend class __hash_const_iterator; |
| 972 | template <class> | 884 | template <class> |
| 973 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; | 885 | friend class __hash_const_local_iterator; |
| 974 | template <class> | 886 | template <class> |
| 975 | friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; | 887 | friend class __hash_map_const_iterator; |
| 976 | }; | 888 | }; |
| 977 | 889 | ||
| 978 | template <class _HashIterator> | 890 | template <class _HashIterator> |
| 979 | class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator { | 891 | class __hash_map_const_iterator { |
| 980 | _HashIterator __i_; | 892 | _HashIterator __i_; |
| 981 | 893 | ||
| 982 | typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; | 894 | typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; |
| ... | @@ -995,8 +907,8 @@ public: | ... | @@ -995,8 +907,8 @@ public: |
| 995 | __hash_map_const_iterator(__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) _NOEXCEPT | 907 | __hash_map_const_iterator(__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) _NOEXCEPT |
| 996 | : __i_(__i.__i_) {} | 908 | : __i_(__i.__i_) {} |
| 997 | 909 | ||
| 998 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } | 910 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; } |
| 999 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); } | 911 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); } |
| 1000 | 912 | ||
| 1001 | _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator& operator++() { | 913 | _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator& operator++() { |
| 1002 | ++__i_; | 914 | ++__i_; |
| ... | @@ -1020,13 +932,13 @@ public: | ... | @@ -1020,13 +932,13 @@ public: |
| 1020 | # endif | 932 | # endif |
| 1021 | 933 | ||
| 1022 | template <class, class, class, class, class> | 934 | template <class, class, class, class, class> |
| 1023 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; | 935 | friend class unordered_map; |
| 1024 | template <class, class, class, class, class> | 936 | template <class, class, class, class, class> |
| 1025 | friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; | 937 | friend class unordered_multimap; |
| 1026 | template <class> | 938 | template <class> |
| 1027 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; | 939 | friend class __hash_const_iterator; |
| 1028 | template <class> | 940 | template <class> |
| 1029 | friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; | 941 | friend class __hash_const_local_iterator; |
| 1030 | }; | 942 | }; |
| 1031 | 943 | ||
| 1032 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 944 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -1037,7 +949,7 @@ template <class _Key, | ... | @@ -1037,7 +949,7 @@ template <class _Key, |
| 1037 | class _Hash = hash<_Key>, | 949 | class _Hash = hash<_Key>, |
| 1038 | class _Pred = equal_to<_Key>, | 950 | class _Pred = equal_to<_Key>, |
| 1039 | class _Alloc = allocator<pair<const _Key, _Tp> > > | 951 | class _Alloc = allocator<pair<const _Key, _Tp> > > |
| 1040 | class _LIBCPP_TEMPLATE_VIS unordered_map { | 952 | class unordered_map { |
| 1041 | public: | 953 | public: |
| 1042 | // types | 954 | // types |
| 1043 | typedef _Key key_type; | 955 | typedef _Key key_type; |
| ... | @@ -1053,11 +965,10 @@ public: | ... | @@ -1053,11 +965,10 @@ public: |
| 1053 | 965 | ||
| 1054 | private: | 966 | private: |
| 1055 | typedef __hash_value_type<key_type, mapped_type> __value_type; | 967 | typedef __hash_value_type<key_type, mapped_type> __value_type; |
| 1056 | typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher; | 968 | typedef __unordered_map_hasher<key_type, value_type, hasher, key_equal> __hasher; |
| 1057 | typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal; | 969 | typedef __unordered_map_equal<key_type, value_type, key_equal, hasher> __key_equal; |
| 1058 | typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; | ||
| 1059 | 970 | ||
| 1060 | typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; | 971 | typedef __hash_table<__value_type, __hasher, __key_equal, allocator_type> __table; |
| 1061 | 972 | ||
| 1062 | __table __table_; | 973 | __table __table_; |
| 1063 | 974 | ||
| ... | @@ -1073,9 +984,6 @@ private: | ... | @@ -1073,9 +984,6 @@ private: |
| 1073 | 984 | ||
| 1074 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | 985 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 1075 | 986 | ||
| 1076 | static_assert(is_same<typename __table::__container_value_type, value_type>::value, ""); | ||
| 1077 | static_assert(is_same<typename __table::__node_value_type, __value_type>::value, ""); | ||
| 1078 | |||
| 1079 | public: | 987 | public: |
| 1080 | typedef typename __alloc_traits::pointer pointer; | 988 | typedef typename __alloc_traits::pointer pointer; |
| 1081 | typedef typename __alloc_traits::const_pointer const_pointer; | 989 | typedef typename __alloc_traits::const_pointer const_pointer; |
| ... | @@ -1093,9 +1001,9 @@ public: | ... | @@ -1093,9 +1001,9 @@ public: |
| 1093 | # endif | 1001 | # endif |
| 1094 | 1002 | ||
| 1095 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> | 1003 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> |
| 1096 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; | 1004 | friend class unordered_map; |
| 1097 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> | 1005 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> |
| 1098 | friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; | 1006 | friend class unordered_multimap; |
| 1099 | 1007 | ||
| 1100 | _LIBCPP_HIDE_FROM_ABI unordered_map() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} | 1008 | _LIBCPP_HIDE_FROM_ABI unordered_map() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} |
| 1101 | explicit _LIBCPP_HIDE_FROM_ABI | 1009 | explicit _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -1227,7 +1135,7 @@ public: | ... | @@ -1227,7 +1135,7 @@ public: |
| 1227 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } | 1135 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 1228 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } | 1136 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 1229 | 1137 | ||
| 1230 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); } | 1138 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__emplace_unique(__x); } |
| 1231 | 1139 | ||
| 1232 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } | 1140 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } |
| 1233 | 1141 | ||
| ... | @@ -1238,7 +1146,7 @@ public: | ... | @@ -1238,7 +1146,7 @@ public: |
| 1238 | template <_ContainerCompatibleRange<value_type> _Range> | 1146 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1239 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1147 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1240 | for (auto&& __element : __range) { | 1148 | for (auto&& __element : __range) { |
| 1241 | __table_.__insert_unique(std::forward<decltype(__element)>(__element)); | 1149 | __table_.__emplace_unique(std::forward<decltype(__element)>(__element)); |
| 1242 | } | 1150 | } |
| 1243 | } | 1151 | } |
| 1244 | # endif | 1152 | # endif |
| ... | @@ -1247,16 +1155,16 @@ public: | ... | @@ -1247,16 +1155,16 @@ public: |
| 1247 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 1155 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1248 | 1156 | ||
| 1249 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { | 1157 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { |
| 1250 | return __table_.__insert_unique(std::move(__x)); | 1158 | return __table_.__emplace_unique(std::move(__x)); |
| 1251 | } | 1159 | } |
| 1252 | 1160 | ||
| 1253 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { | 1161 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { |
| 1254 | return __table_.__insert_unique(std::move(__x)).first; | 1162 | return __table_.__emplace_unique(std::move(__x)).first; |
| 1255 | } | 1163 | } |
| 1256 | 1164 | ||
| 1257 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1165 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 1258 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) { | 1166 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) { |
| 1259 | return __table_.__insert_unique(std::forward<_Pp>(__x)); | 1167 | return __table_.__emplace_unique(std::forward<_Pp>(__x)); |
| 1260 | } | 1168 | } |
| 1261 | 1169 | ||
| 1262 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1170 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| ... | @@ -1680,9 +1588,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __ | ... | @@ -1680,9 +1588,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __ |
| 1680 | : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) { | 1588 | : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) { |
| 1681 | if (__a != __u.get_allocator()) { | 1589 | if (__a != __u.get_allocator()) { |
| 1682 | iterator __i = __u.begin(); | 1590 | iterator __i = __u.begin(); |
| 1683 | while (__u.size() != 0) { | 1591 | while (__u.size() != 0) |
| 1684 | __table_.__emplace_unique(__u.__table_.remove((__i++).__i_)->__get_value().__move()); | 1592 | __table_.__insert_unique_from_orphaned_node(std::move(__u.__table_.remove((__i++).__i_)->__get_value())); |
| 1685 | } | ||
| 1686 | } | 1593 | } |
| 1687 | } | 1594 | } |
| 1688 | 1595 | ||
| ... | @@ -1732,7 +1639,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -1732,7 +1639,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1732 | template <class _InputIterator> | 1639 | template <class _InputIterator> |
| 1733 | inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 1640 | inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 1734 | for (; __first != __last; ++__first) | 1641 | for (; __first != __last; ++__first) |
| 1735 | __table_.__insert_unique(*__first); | 1642 | __table_.__emplace_unique(*__first); |
| 1736 | } | 1643 | } |
| 1737 | 1644 | ||
| 1738 | # ifndef _LIBCPP_CXX03_LANG | 1645 | # ifndef _LIBCPP_CXX03_LANG |
| ... | @@ -1741,8 +1648,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -1741,8 +1648,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1741 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) { | 1648 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) { |
| 1742 | return __table_ | 1649 | return __table_ |
| 1743 | .__emplace_unique_key_args(__k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) | 1650 | .__emplace_unique_key_args(__k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) |
| 1744 | .first->__get_value() | 1651 | .first->second; |
| 1745 | .second; | ||
| 1746 | } | 1652 | } |
| 1747 | 1653 | ||
| 1748 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 1654 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -1750,8 +1656,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) | ... | @@ -1750,8 +1656,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) |
| 1750 | return __table_ | 1656 | return __table_ |
| 1751 | .__emplace_unique_key_args( | 1657 | .__emplace_unique_key_args( |
| 1752 | __k, piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) | 1658 | __k, piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple()) |
| 1753 | .first->__get_value() | 1659 | .first->second; |
| 1754 | .second; | ||
| 1755 | } | 1660 | } |
| 1756 | # else // _LIBCPP_CXX03_LANG | 1661 | # else // _LIBCPP_CXX03_LANG |
| 1757 | 1662 | ||
| ... | @@ -1760,9 +1665,9 @@ typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder | ... | @@ -1760,9 +1665,9 @@ typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 1760 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) { | 1665 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) { |
| 1761 | __node_allocator& __na = __table_.__node_alloc(); | 1666 | __node_allocator& __na = __table_.__node_alloc(); |
| 1762 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); | 1667 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
| 1763 | __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().first), __k); | 1668 | __node_traits::construct(__na, std::addressof(__h->__get_value().first), __k); |
| 1764 | __h.get_deleter().__first_constructed = true; | 1669 | __h.get_deleter().__first_constructed = true; |
| 1765 | __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().second)); | 1670 | __node_traits::construct(__na, std::addressof(__h->__get_value().second)); |
| 1766 | __h.get_deleter().__second_constructed = true; | 1671 | __h.get_deleter().__second_constructed = true; |
| 1767 | return __h; | 1672 | return __h; |
| 1768 | } | 1673 | } |
| ... | @@ -1784,7 +1689,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -1784,7 +1689,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1784 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) { | 1689 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) { |
| 1785 | iterator __i = find(__k); | 1690 | iterator __i = find(__k); |
| 1786 | if (__i == end()) | 1691 | if (__i == end()) |
| 1787 | __throw_out_of_range("unordered_map::at: key not found"); | 1692 | std::__throw_out_of_range("unordered_map::at: key not found"); |
| 1788 | return __i->second; | 1693 | return __i->second; |
| 1789 | } | 1694 | } |
| 1790 | 1695 | ||
| ... | @@ -1792,7 +1697,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -1792,7 +1697,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1792 | const _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const { | 1697 | const _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const { |
| 1793 | const_iterator __i = find(__k); | 1698 | const_iterator __i = find(__k); |
| 1794 | if (__i == end()) | 1699 | if (__i == end()) |
| 1795 | __throw_out_of_range("unordered_map::at: key not found"); | 1700 | std::__throw_out_of_range("unordered_map::at: key not found"); |
| 1796 | return __i->second; | 1701 | return __i->second; |
| 1797 | } | 1702 | } |
| 1798 | 1703 | ||
| ... | @@ -1843,6 +1748,8 @@ struct __container_traits<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> > { | ... | @@ -1843,6 +1748,8 @@ struct __container_traits<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> > { |
| 1843 | // inserting a single element, the insertion has no effect. | 1748 | // inserting a single element, the insertion has no effect. |
| 1844 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | 1749 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = |
| 1845 | __is_nothrow_invocable_v<_Hash, const _Key&>; | 1750 | __is_nothrow_invocable_v<_Hash, const _Key&>; |
| 1751 | |||
| 1752 | static _LIBCPP_CONSTEXPR const bool __reservable = true; | ||
| 1846 | }; | 1753 | }; |
| 1847 | 1754 | ||
| 1848 | template <class _Key, | 1755 | template <class _Key, |
| ... | @@ -1850,7 +1757,7 @@ template <class _Key, | ... | @@ -1850,7 +1757,7 @@ template <class _Key, |
| 1850 | class _Hash = hash<_Key>, | 1757 | class _Hash = hash<_Key>, |
| 1851 | class _Pred = equal_to<_Key>, | 1758 | class _Pred = equal_to<_Key>, |
| 1852 | class _Alloc = allocator<pair<const _Key, _Tp> > > | 1759 | class _Alloc = allocator<pair<const _Key, _Tp> > > |
| 1853 | class _LIBCPP_TEMPLATE_VIS unordered_multimap { | 1760 | class unordered_multimap { |
| 1854 | public: | 1761 | public: |
| 1855 | // types | 1762 | // types |
| 1856 | typedef _Key key_type; | 1763 | typedef _Key key_type; |
| ... | @@ -1867,11 +1774,10 @@ public: | ... | @@ -1867,11 +1774,10 @@ public: |
| 1867 | 1774 | ||
| 1868 | private: | 1775 | private: |
| 1869 | typedef __hash_value_type<key_type, mapped_type> __value_type; | 1776 | typedef __hash_value_type<key_type, mapped_type> __value_type; |
| 1870 | typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher; | 1777 | typedef __unordered_map_hasher<key_type, value_type, hasher, key_equal> __hasher; |
| 1871 | typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal; | 1778 | typedef __unordered_map_equal<key_type, value_type, key_equal, hasher> __key_equal; |
| 1872 | typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type; | ||
| 1873 | 1779 | ||
| 1874 | typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; | 1780 | typedef __hash_table<__value_type, __hasher, __key_equal, allocator_type> __table; |
| 1875 | 1781 | ||
| 1876 | __table __table_; | 1782 | __table __table_; |
| 1877 | 1783 | ||
| ... | @@ -1901,9 +1807,9 @@ public: | ... | @@ -1901,9 +1807,9 @@ public: |
| 1901 | # endif | 1807 | # endif |
| 1902 | 1808 | ||
| 1903 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> | 1809 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> |
| 1904 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; | 1810 | friend class unordered_map; |
| 1905 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> | 1811 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> |
| 1906 | friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; | 1812 | friend class unordered_multimap; |
| 1907 | 1813 | ||
| 1908 | _LIBCPP_HIDE_FROM_ABI unordered_multimap() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} | 1814 | _LIBCPP_HIDE_FROM_ABI unordered_multimap() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} |
| 1909 | explicit _LIBCPP_HIDE_FROM_ABI | 1815 | explicit _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -2036,10 +1942,10 @@ public: | ... | @@ -2036,10 +1942,10 @@ public: |
| 2036 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } | 1942 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 2037 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } | 1943 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 2038 | 1944 | ||
| 2039 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); } | 1945 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); } |
| 2040 | 1946 | ||
| 2041 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) { | 1947 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) { |
| 2042 | return __table_.__insert_multi(__p.__i_, __x); | 1948 | return __table_.__emplace_hint_multi(__p.__i_, __x); |
| 2043 | } | 1949 | } |
| 2044 | 1950 | ||
| 2045 | template <class _InputIterator> | 1951 | template <class _InputIterator> |
| ... | @@ -2049,27 +1955,27 @@ public: | ... | @@ -2049,27 +1955,27 @@ public: |
| 2049 | template <_ContainerCompatibleRange<value_type> _Range> | 1955 | template <_ContainerCompatibleRange<value_type> _Range> |
| 2050 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1956 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 2051 | for (auto&& __element : __range) { | 1957 | for (auto&& __element : __range) { |
| 2052 | __table_.__insert_multi(std::forward<decltype(__element)>(__element)); | 1958 | __table_.__emplace_multi(std::forward<decltype(__element)>(__element)); |
| 2053 | } | 1959 | } |
| 2054 | } | 1960 | } |
| 2055 | # endif | 1961 | # endif |
| 2056 | 1962 | ||
| 2057 | # ifndef _LIBCPP_CXX03_LANG | 1963 | # ifndef _LIBCPP_CXX03_LANG |
| 2058 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 1964 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 2059 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); } | 1965 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__emplace_multi(std::move(__x)); } |
| 2060 | 1966 | ||
| 2061 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) { | 1967 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) { |
| 2062 | return __table_.__insert_multi(__p.__i_, std::move(__x)); | 1968 | return __table_.__emplace_hint_multi(__p.__i_, std::move(__x)); |
| 2063 | } | 1969 | } |
| 2064 | 1970 | ||
| 2065 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1971 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 2066 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) { | 1972 | _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) { |
| 2067 | return __table_.__insert_multi(std::forward<_Pp>(__x)); | 1973 | return __table_.__emplace_multi(std::forward<_Pp>(__x)); |
| 2068 | } | 1974 | } |
| 2069 | 1975 | ||
| 2070 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> | 1976 | template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0> |
| 2071 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) { | 1977 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) { |
| 2072 | return __table_.__insert_multi(__p.__i_, std::forward<_Pp>(__x)); | 1978 | return __table_.__emplace_hint_multi(__p.__i_, std::forward<_Pp>(__x)); |
| 2073 | } | 1979 | } |
| 2074 | 1980 | ||
| 2075 | template <class... _Args> | 1981 | template <class... _Args> |
| ... | @@ -2437,9 +2343,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( | ... | @@ -2437,9 +2343,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2437 | : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) { | 2343 | : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) { |
| 2438 | if (__a != __u.get_allocator()) { | 2344 | if (__a != __u.get_allocator()) { |
| 2439 | iterator __i = __u.begin(); | 2345 | iterator __i = __u.begin(); |
| 2440 | while (__u.size() != 0) { | 2346 | while (__u.size() != 0) |
| 2441 | __table_.__insert_multi(__u.__table_.remove((__i++).__i_)->__get_value().__move()); | 2347 | __table_.__insert_multi_from_orphaned_node(std::move(__u.__table_.remove((__i++).__i_)->__get_value())); |
| 2442 | } | ||
| 2443 | } | 2348 | } |
| 2444 | } | 2349 | } |
| 2445 | 2350 | ||
| ... | @@ -2489,7 +2394,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | ... | @@ -2489,7 +2394,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2489 | template <class _InputIterator> | 2394 | template <class _InputIterator> |
| 2490 | inline void unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 2395 | inline void unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 2491 | for (; __first != __last; ++__first) | 2396 | for (; __first != __last; ++__first) |
| 2492 | __table_.__insert_multi(*__first); | 2397 | __table_.__emplace_multi(*__first); |
| 2493 | } | 2398 | } |
| 2494 | 2399 | ||
| 2495 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | 2400 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -2543,6 +2448,8 @@ struct __container_traits<unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> > | ... | @@ -2543,6 +2448,8 @@ struct __container_traits<unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> > |
| 2543 | // inserting a single element, the insertion has no effect. | 2448 | // inserting a single element, the insertion has no effect. |
| 2544 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | 2449 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = |
| 2545 | __is_nothrow_invocable_v<_Hash, const _Key&>; | 2450 | __is_nothrow_invocable_v<_Hash, const _Key&>; |
| 2451 | |||
| 2452 | static _LIBCPP_CONSTEXPR const bool __reservable = true; | ||
| 2546 | }; | 2453 | }; |
| 2547 | 2454 | ||
| 2548 | _LIBCPP_END_NAMESPACE_STD | 2455 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/unordered_set+22-18| ... | @@ -594,7 +594,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> | ... | @@ -594,7 +594,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 594 | class unordered_multiset; | 594 | class unordered_multiset; |
| 595 | 595 | ||
| 596 | template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > | 596 | template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > |
| 597 | class _LIBCPP_TEMPLATE_VIS unordered_set { | 597 | class unordered_set { |
| 598 | public: | 598 | public: |
| 599 | // types | 599 | // types |
| 600 | typedef _Value key_type; | 600 | typedef _Value key_type; |
| ... | @@ -630,9 +630,9 @@ public: | ... | @@ -630,9 +630,9 @@ public: |
| 630 | # endif | 630 | # endif |
| 631 | 631 | ||
| 632 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> | 632 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> |
| 633 | friend class _LIBCPP_TEMPLATE_VIS unordered_set; | 633 | friend class unordered_set; |
| 634 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> | 634 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> |
| 635 | friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; | 635 | friend class unordered_multiset; |
| 636 | 636 | ||
| 637 | _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} | 637 | _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} |
| 638 | explicit _LIBCPP_HIDE_FROM_ABI | 638 | explicit _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -769,13 +769,13 @@ public: | ... | @@ -769,13 +769,13 @@ public: |
| 769 | } | 769 | } |
| 770 | 770 | ||
| 771 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { | 771 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { |
| 772 | return __table_.__insert_unique(std::move(__x)); | 772 | return __table_.__emplace_unique(std::move(__x)); |
| 773 | } | 773 | } |
| 774 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; } | 774 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; } |
| 775 | 775 | ||
| 776 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 776 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 777 | # endif // _LIBCPP_CXX03_LANG | 777 | # endif // _LIBCPP_CXX03_LANG |
| 778 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); } | 778 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__emplace_unique(__x); } |
| 779 | 779 | ||
| 780 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } | 780 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } |
| 781 | template <class _InputIterator> | 781 | template <class _InputIterator> |
| ... | @@ -785,7 +785,7 @@ public: | ... | @@ -785,7 +785,7 @@ public: |
| 785 | template <_ContainerCompatibleRange<value_type> _Range> | 785 | template <_ContainerCompatibleRange<value_type> _Range> |
| 786 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 786 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 787 | for (auto&& __element : __range) { | 787 | for (auto&& __element : __range) { |
| 788 | __table_.__insert_unique(std::forward<decltype(__element)>(__element)); | 788 | __table_.__emplace_unique(std::forward<decltype(__element)>(__element)); |
| 789 | } | 789 | } |
| 790 | } | 790 | } |
| 791 | # endif | 791 | # endif |
| ... | @@ -1096,7 +1096,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u, | ... | @@ -1096,7 +1096,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u, |
| 1096 | if (__a != __u.get_allocator()) { | 1096 | if (__a != __u.get_allocator()) { |
| 1097 | iterator __i = __u.begin(); | 1097 | iterator __i = __u.begin(); |
| 1098 | while (__u.size() != 0) | 1098 | while (__u.size() != 0) |
| 1099 | __table_.__insert_unique(std::move(__u.__table_.remove(__i++)->__get_value())); | 1099 | __table_.__emplace_unique(std::move(__u.__table_.remove(__i++)->__get_value())); |
| 1100 | } | 1100 | } |
| 1101 | } | 1101 | } |
| 1102 | 1102 | ||
| ... | @@ -1146,7 +1146,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> | ... | @@ -1146,7 +1146,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1146 | template <class _InputIterator> | 1146 | template <class _InputIterator> |
| 1147 | inline void unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 1147 | inline void unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 1148 | for (; __first != __last; ++__first) | 1148 | for (; __first != __last; ++__first) |
| 1149 | __table_.__insert_unique(*__first); | 1149 | __table_.__emplace_unique(*__first); |
| 1150 | } | 1150 | } |
| 1151 | 1151 | ||
| 1152 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1152 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -1196,10 +1196,12 @@ struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > { | ... | @@ -1196,10 +1196,12 @@ struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > { |
| 1196 | // inserting a single element, the insertion has no effect. | 1196 | // inserting a single element, the insertion has no effect. |
| 1197 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | 1197 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = |
| 1198 | __is_nothrow_invocable_v<_Hash, const _Value&>; | 1198 | __is_nothrow_invocable_v<_Hash, const _Value&>; |
| 1199 | |||
| 1200 | static _LIBCPP_CONSTEXPR const bool __reservable = true; | ||
| 1199 | }; | 1201 | }; |
| 1200 | 1202 | ||
| 1201 | template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > | 1203 | template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > |
| 1202 | class _LIBCPP_TEMPLATE_VIS unordered_multiset { | 1204 | class unordered_multiset { |
| 1203 | public: | 1205 | public: |
| 1204 | // types | 1206 | // types |
| 1205 | typedef _Value key_type; | 1207 | typedef _Value key_type; |
| ... | @@ -1233,9 +1235,9 @@ public: | ... | @@ -1233,9 +1235,9 @@ public: |
| 1233 | # endif | 1235 | # endif |
| 1234 | 1236 | ||
| 1235 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> | 1237 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> |
| 1236 | friend class _LIBCPP_TEMPLATE_VIS unordered_set; | 1238 | friend class unordered_set; |
| 1237 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> | 1239 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> |
| 1238 | friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; | 1240 | friend class unordered_multiset; |
| 1239 | 1241 | ||
| 1240 | _LIBCPP_HIDE_FROM_ABI unordered_multiset() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} | 1242 | _LIBCPP_HIDE_FROM_ABI unordered_multiset() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} |
| 1241 | explicit _LIBCPP_HIDE_FROM_ABI | 1243 | explicit _LIBCPP_HIDE_FROM_ABI |
| ... | @@ -1372,17 +1374,17 @@ public: | ... | @@ -1372,17 +1374,17 @@ public: |
| 1372 | return __table_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...); | 1374 | return __table_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...); |
| 1373 | } | 1375 | } |
| 1374 | 1376 | ||
| 1375 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); } | 1377 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__emplace_multi(std::move(__x)); } |
| 1376 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) { | 1378 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) { |
| 1377 | return __table_.__insert_multi(__p, std::move(__x)); | 1379 | return __table_.__emplace_hint_multi(__p, std::move(__x)); |
| 1378 | } | 1380 | } |
| 1379 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | 1381 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1380 | # endif // _LIBCPP_CXX03_LANG | 1382 | # endif // _LIBCPP_CXX03_LANG |
| 1381 | 1383 | ||
| 1382 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); } | 1384 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); } |
| 1383 | 1385 | ||
| 1384 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) { | 1386 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) { |
| 1385 | return __table_.__insert_multi(__p, __x); | 1387 | return __table_.__emplace_hint_multi(__p, __x); |
| 1386 | } | 1388 | } |
| 1387 | 1389 | ||
| 1388 | template <class _InputIterator> | 1390 | template <class _InputIterator> |
| ... | @@ -1392,7 +1394,7 @@ public: | ... | @@ -1392,7 +1394,7 @@ public: |
| 1392 | template <_ContainerCompatibleRange<value_type> _Range> | 1394 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1393 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | 1395 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1394 | for (auto&& __element : __range) { | 1396 | for (auto&& __element : __range) { |
| 1395 | __table_.__insert_multi(std::forward<decltype(__element)>(__element)); | 1397 | __table_.__emplace_multi(std::forward<decltype(__element)>(__element)); |
| 1396 | } | 1398 | } |
| 1397 | } | 1399 | } |
| 1398 | # endif | 1400 | # endif |
| ... | @@ -1712,7 +1714,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( | ... | @@ -1712,7 +1714,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1712 | if (__a != __u.get_allocator()) { | 1714 | if (__a != __u.get_allocator()) { |
| 1713 | iterator __i = __u.begin(); | 1715 | iterator __i = __u.begin(); |
| 1714 | while (__u.size() != 0) | 1716 | while (__u.size() != 0) |
| 1715 | __table_.__insert_multi(std::move(__u.__table_.remove(__i++)->__get_value())); | 1717 | __table_.__emplace_multi(std::move(__u.__table_.remove(__i++)->__get_value())); |
| 1716 | } | 1718 | } |
| 1717 | } | 1719 | } |
| 1718 | 1720 | ||
| ... | @@ -1762,7 +1764,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> | ... | @@ -1762,7 +1764,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1762 | template <class _InputIterator> | 1764 | template <class _InputIterator> |
| 1763 | inline void unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { | 1765 | inline void unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) { |
| 1764 | for (; __first != __last; ++__first) | 1766 | for (; __first != __last; ++__first) |
| 1765 | __table_.__insert_multi(*__first); | 1767 | __table_.__emplace_multi(*__first); |
| 1766 | } | 1768 | } |
| 1767 | 1769 | ||
| 1768 | template <class _Value, class _Hash, class _Pred, class _Alloc> | 1770 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | @@ -1816,6 +1818,8 @@ struct __container_traits<unordered_multiset<_Value, _Hash, _Pred, _Alloc> > { | ... | @@ -1816,6 +1818,8 @@ struct __container_traits<unordered_multiset<_Value, _Hash, _Pred, _Alloc> > { |
| 1816 | // inserting a single element, the insertion has no effect. | 1818 | // inserting a single element, the insertion has no effect. |
| 1817 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | 1819 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = |
| 1818 | __is_nothrow_invocable_v<_Hash, const _Value&>; | 1820 | __is_nothrow_invocable_v<_Hash, const _Value&>; |
| 1821 | |||
| 1822 | static _LIBCPP_CONSTEXPR const bool __reservable = true; | ||
| 1819 | }; | 1823 | }; |
| 1820 | 1824 | ||
| 1821 | _LIBCPP_END_NAMESPACE_STD | 1825 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/utility+4| ... | @@ -279,6 +279,10 @@ template <class T> | ... | @@ -279,6 +279,10 @@ template <class T> |
| 279 | # include <__utility/unreachable.h> | 279 | # include <__utility/unreachable.h> |
| 280 | # endif | 280 | # endif |
| 281 | 281 | ||
| 282 | # if _LIBCPP_STD_VER >= 26 | ||
| 283 | # include <__variant/monostate.h> | ||
| 284 | # endif | ||
| 285 | |||
| 282 | # include <version> | 286 | # include <version> |
| 283 | 287 | ||
| 284 | // standard-mandated includes | 288 | // standard-mandated includes |
lib/libcxx/include/valarray+18-18| ... | @@ -382,9 +382,9 @@ _LIBCPP_PUSH_MACROS | ... | @@ -382,9 +382,9 @@ _LIBCPP_PUSH_MACROS |
| 382 | _LIBCPP_BEGIN_NAMESPACE_STD | 382 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 383 | 383 | ||
| 384 | template <class _Tp> | 384 | template <class _Tp> |
| 385 | class _LIBCPP_TEMPLATE_VIS valarray; | 385 | class valarray; |
| 386 | 386 | ||
| 387 | class _LIBCPP_TEMPLATE_VIS slice { | 387 | class slice { |
| 388 | size_t __start_; | 388 | size_t __start_; |
| 389 | size_t __size_; | 389 | size_t __size_; |
| 390 | size_t __stride_; | 390 | size_t __stride_; |
| ... | @@ -409,14 +409,14 @@ public: | ... | @@ -409,14 +409,14 @@ public: |
| 409 | }; | 409 | }; |
| 410 | 410 | ||
| 411 | template <class _Tp> | 411 | template <class _Tp> |
| 412 | class _LIBCPP_TEMPLATE_VIS slice_array; | 412 | class slice_array; |
| 413 | class _LIBCPP_EXPORTED_FROM_ABI gslice; | 413 | class _LIBCPP_EXPORTED_FROM_ABI gslice; |
| 414 | template <class _Tp> | 414 | template <class _Tp> |
| 415 | class _LIBCPP_TEMPLATE_VIS gslice_array; | 415 | class gslice_array; |
| 416 | template <class _Tp> | 416 | template <class _Tp> |
| 417 | class _LIBCPP_TEMPLATE_VIS mask_array; | 417 | class mask_array; |
| 418 | template <class _Tp> | 418 | template <class _Tp> |
| 419 | class _LIBCPP_TEMPLATE_VIS indirect_array; | 419 | class indirect_array; |
| 420 | 420 | ||
| 421 | template <class _Tp> | 421 | template <class _Tp> |
| 422 | _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v); | 422 | _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v); |
| ... | @@ -638,7 +638,7 @@ public: | ... | @@ -638,7 +638,7 @@ public: |
| 638 | template <class> | 638 | template <class> |
| 639 | friend class __val_expr; | 639 | friend class __val_expr; |
| 640 | template <class> | 640 | template <class> |
| 641 | friend class _LIBCPP_TEMPLATE_VIS valarray; | 641 | friend class valarray; |
| 642 | }; | 642 | }; |
| 643 | 643 | ||
| 644 | template <class _ValExpr> | 644 | template <class _ValExpr> |
| ... | @@ -780,7 +780,7 @@ template <class _Tp> | ... | @@ -780,7 +780,7 @@ template <class _Tp> |
| 780 | struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {}; | 780 | struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {}; |
| 781 | 781 | ||
| 782 | template <class _Tp> | 782 | template <class _Tp> |
| 783 | class _LIBCPP_TEMPLATE_VIS valarray { | 783 | class valarray { |
| 784 | public: | 784 | public: |
| 785 | typedef _Tp value_type; | 785 | typedef _Tp value_type; |
| 786 | typedef _Tp __result_type; | 786 | typedef _Tp __result_type; |
| ... | @@ -918,17 +918,17 @@ public: | ... | @@ -918,17 +918,17 @@ public: |
| 918 | 918 | ||
| 919 | private: | 919 | private: |
| 920 | template <class> | 920 | template <class> |
| 921 | friend class _LIBCPP_TEMPLATE_VIS valarray; | 921 | friend class valarray; |
| 922 | template <class> | 922 | template <class> |
| 923 | friend class _LIBCPP_TEMPLATE_VIS slice_array; | 923 | friend class slice_array; |
| 924 | template <class> | 924 | template <class> |
| 925 | friend class _LIBCPP_TEMPLATE_VIS gslice_array; | 925 | friend class gslice_array; |
| 926 | template <class> | 926 | template <class> |
| 927 | friend class _LIBCPP_TEMPLATE_VIS mask_array; | 927 | friend class mask_array; |
| 928 | template <class> | 928 | template <class> |
| 929 | friend class __mask_expr; | 929 | friend class __mask_expr; |
| 930 | template <class> | 930 | template <class> |
| 931 | friend class _LIBCPP_TEMPLATE_VIS indirect_array; | 931 | friend class indirect_array; |
| 932 | template <class> | 932 | template <class> |
| 933 | friend class __indirect_expr; | 933 | friend class __indirect_expr; |
| 934 | template <class> | 934 | template <class> |
| ... | @@ -1038,7 +1038,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > { | ... | @@ -1038,7 +1038,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > { |
| 1038 | // slice_array | 1038 | // slice_array |
| 1039 | 1039 | ||
| 1040 | template <class _Tp> | 1040 | template <class _Tp> |
| 1041 | class _LIBCPP_TEMPLATE_VIS slice_array { | 1041 | class slice_array { |
| 1042 | public: | 1042 | public: |
| 1043 | typedef _Tp value_type; | 1043 | typedef _Tp value_type; |
| 1044 | 1044 | ||
| ... | @@ -1268,7 +1268,7 @@ private: | ... | @@ -1268,7 +1268,7 @@ private: |
| 1268 | // gslice_array | 1268 | // gslice_array |
| 1269 | 1269 | ||
| 1270 | template <class _Tp> | 1270 | template <class _Tp> |
| 1271 | class _LIBCPP_TEMPLATE_VIS gslice_array { | 1271 | class gslice_array { |
| 1272 | public: | 1272 | public: |
| 1273 | typedef _Tp value_type; | 1273 | typedef _Tp value_type; |
| 1274 | 1274 | ||
| ... | @@ -1453,7 +1453,7 @@ inline void gslice_array<_Tp>::operator=(const value_type& __x) const { | ... | @@ -1453,7 +1453,7 @@ inline void gslice_array<_Tp>::operator=(const value_type& __x) const { |
| 1453 | // mask_array | 1453 | // mask_array |
| 1454 | 1454 | ||
| 1455 | template <class _Tp> | 1455 | template <class _Tp> |
| 1456 | class _LIBCPP_TEMPLATE_VIS mask_array { | 1456 | class mask_array { |
| 1457 | public: | 1457 | public: |
| 1458 | typedef _Tp value_type; | 1458 | typedef _Tp value_type; |
| 1459 | 1459 | ||
| ... | @@ -1658,7 +1658,7 @@ public: | ... | @@ -1658,7 +1658,7 @@ public: |
| 1658 | // indirect_array | 1658 | // indirect_array |
| 1659 | 1659 | ||
| 1660 | template <class _Tp> | 1660 | template <class _Tp> |
| 1661 | class _LIBCPP_TEMPLATE_VIS indirect_array { | 1661 | class indirect_array { |
| 1662 | public: | 1662 | public: |
| 1663 | typedef _Tp value_type; | 1663 | typedef _Tp value_type; |
| 1664 | 1664 | ||
| ... | @@ -1860,7 +1860,7 @@ public: | ... | @@ -1860,7 +1860,7 @@ public: |
| 1860 | template <class> | 1860 | template <class> |
| 1861 | friend class __val_expr; | 1861 | friend class __val_expr; |
| 1862 | template <class> | 1862 | template <class> |
| 1863 | friend class _LIBCPP_TEMPLATE_VIS valarray; | 1863 | friend class valarray; |
| 1864 | }; | 1864 | }; |
| 1865 | 1865 | ||
| 1866 | template <class _ValExpr> | 1866 | template <class _ValExpr> |
lib/libcxx/include/variant+96-76| ... | @@ -213,7 +213,7 @@ namespace std { | ... | @@ -213,7 +213,7 @@ namespace std { |
| 213 | */ | 213 | */ |
| 214 | 214 | ||
| 215 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | 215 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 216 | # include <__cxx03/variant> | 216 | # include <__cxx03/__config> |
| 217 | #else | 217 | #else |
| 218 | # include <__compare/common_comparison_category.h> | 218 | # include <__compare/common_comparison_category.h> |
| 219 | # include <__compare/compare_three_way_result.h> | 219 | # include <__compare/compare_three_way_result.h> |
| ... | @@ -242,10 +242,12 @@ namespace std { | ... | @@ -242,10 +242,12 @@ namespace std { |
| 242 | # include <__type_traits/is_assignable.h> | 242 | # include <__type_traits/is_assignable.h> |
| 243 | # include <__type_traits/is_constructible.h> | 243 | # include <__type_traits/is_constructible.h> |
| 244 | # include <__type_traits/is_convertible.h> | 244 | # include <__type_traits/is_convertible.h> |
| 245 | # include <__type_traits/is_core_convertible.h> | ||
| 245 | # include <__type_traits/is_destructible.h> | 246 | # include <__type_traits/is_destructible.h> |
| 246 | # include <__type_traits/is_nothrow_assignable.h> | 247 | # include <__type_traits/is_nothrow_assignable.h> |
| 247 | # include <__type_traits/is_nothrow_constructible.h> | 248 | # include <__type_traits/is_nothrow_constructible.h> |
| 248 | # include <__type_traits/is_reference.h> | 249 | # include <__type_traits/is_reference.h> |
| 250 | # include <__type_traits/is_replaceable.h> | ||
| 249 | # include <__type_traits/is_same.h> | 251 | # include <__type_traits/is_same.h> |
| 250 | # include <__type_traits/is_swappable.h> | 252 | # include <__type_traits/is_swappable.h> |
| 251 | # include <__type_traits/is_trivially_assignable.h> | 253 | # include <__type_traits/is_trivially_assignable.h> |
| ... | @@ -283,14 +285,14 @@ namespace std { | ... | @@ -283,14 +285,14 @@ namespace std { |
| 283 | _LIBCPP_PUSH_MACROS | 285 | _LIBCPP_PUSH_MACROS |
| 284 | # include <__undef_macros> | 286 | # include <__undef_macros> |
| 285 | 287 | ||
| 286 | namespace std { // explicitly not using versioning namespace | 288 | _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD |
| 287 | 289 | ||
| 288 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception { | 290 | class _LIBCPP_EXPORTED_FROM_ABI bad_variant_access : public exception { |
| 289 | public: | 291 | public: |
| 290 | const char* what() const _NOEXCEPT override; | 292 | const char* what() const _NOEXCEPT override; |
| 291 | }; | 293 | }; |
| 292 | 294 | ||
| 293 | } // namespace std | 295 | _LIBCPP_END_UNVERSIONED_NAMESPACE_STD |
| 294 | 296 | ||
| 295 | _LIBCPP_BEGIN_NAMESPACE_STD | 297 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 296 | 298 | ||
| ... | @@ -306,8 +308,7 @@ struct __farray { | ... | @@ -306,8 +308,7 @@ struct __farray { |
| 306 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; } | 308 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; } |
| 307 | }; | 309 | }; |
| 308 | 310 | ||
| 309 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void | 311 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_variant_access() { |
| 310 | __throw_bad_variant_access() { | ||
| 311 | # if _LIBCPP_HAS_EXCEPTIONS | 312 | # if _LIBCPP_HAS_EXCEPTIONS |
| 312 | throw bad_variant_access(); | 313 | throw bad_variant_access(); |
| 313 | # else | 314 | # else |
| ... | @@ -317,31 +318,31 @@ __throw_bad_variant_access() { | ... | @@ -317,31 +318,31 @@ __throw_bad_variant_access() { |
| 317 | 318 | ||
| 318 | // variant_size | 319 | // variant_size |
| 319 | template <class _Tp> | 320 | template <class _Tp> |
| 320 | struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {}; | 321 | struct variant_size<const _Tp> : variant_size<_Tp> {}; |
| 321 | 322 | ||
| 322 | template <class _Tp> | 323 | template <class _Tp> |
| 323 | struct _LIBCPP_TEMPLATE_VIS variant_size<volatile _Tp> : variant_size<_Tp> {}; | 324 | struct variant_size<volatile _Tp> : variant_size<_Tp> {}; |
| 324 | 325 | ||
| 325 | template <class _Tp> | 326 | template <class _Tp> |
| 326 | struct _LIBCPP_TEMPLATE_VIS variant_size<const volatile _Tp> : variant_size<_Tp> {}; | 327 | struct variant_size<const volatile _Tp> : variant_size<_Tp> {}; |
| 327 | 328 | ||
| 328 | template <class... _Types> | 329 | template <class... _Types> |
| 329 | struct _LIBCPP_TEMPLATE_VIS variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {}; | 330 | struct variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {}; |
| 330 | 331 | ||
| 331 | // variant_alternative | 332 | // variant_alternative |
| 332 | template <size_t _Ip, class _Tp> | 333 | template <size_t _Ip, class _Tp> |
| 333 | struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {}; | 334 | struct variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {}; |
| 334 | 335 | ||
| 335 | template <size_t _Ip, class _Tp> | 336 | template <size_t _Ip, class _Tp> |
| 336 | struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, volatile _Tp> : add_volatile<variant_alternative_t<_Ip, _Tp>> {}; | 337 | struct variant_alternative<_Ip, volatile _Tp> : add_volatile<variant_alternative_t<_Ip, _Tp>> {}; |
| 337 | 338 | ||
| 338 | template <size_t _Ip, class _Tp> | 339 | template <size_t _Ip, class _Tp> |
| 339 | struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const volatile _Tp> : add_cv<variant_alternative_t<_Ip, _Tp>> {}; | 340 | struct variant_alternative<_Ip, const volatile _Tp> : add_cv<variant_alternative_t<_Ip, _Tp>> {}; |
| 340 | 341 | ||
| 341 | template <size_t _Ip, class... _Types> | 342 | template <size_t _Ip, class... _Types> |
| 342 | struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> { | 343 | struct variant_alternative<_Ip, variant<_Types...>> { |
| 343 | static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>"); | 344 | static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>"); |
| 344 | using type = __type_pack_element<_Ip, _Types...>; | 345 | using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>; |
| 345 | }; | 346 | }; |
| 346 | 347 | ||
| 347 | template <size_t _NumAlternatives> | 348 | template <size_t _NumAlternatives> |
| ... | @@ -409,7 +410,8 @@ template <> | ... | @@ -409,7 +410,8 @@ template <> |
| 409 | struct __find_unambiguous_index_sfinae_impl<__ambiguous> {}; | 410 | struct __find_unambiguous_index_sfinae_impl<__ambiguous> {}; |
| 410 | 411 | ||
| 411 | template <class _Tp, class... _Types> | 412 | template <class _Tp, class... _Types> |
| 412 | struct __find_unambiguous_index_sfinae : __find_unambiguous_index_sfinae_impl<__find_index<_Tp, _Types...>()> {}; | 413 | struct __find_unambiguous_index_sfinae |
| 414 | : __find_unambiguous_index_sfinae_impl<__find_detail::__find_index<_Tp, _Types...>()> {}; | ||
| 413 | 415 | ||
| 414 | } // namespace __find_detail | 416 | } // namespace __find_detail |
| 415 | 417 | ||
| ... | @@ -657,7 +659,7 @@ private: | ... | @@ -657,7 +659,7 @@ private: |
| 657 | # define _LIBCPP_EAT_SEMICOLON static_assert(true, "") | 659 | # define _LIBCPP_EAT_SEMICOLON static_assert(true, "") |
| 658 | 660 | ||
| 659 | template <size_t _Index, class _Tp> | 661 | template <size_t _Index, class _Tp> |
| 660 | struct _LIBCPP_TEMPLATE_VIS __alt { | 662 | struct __alt { |
| 661 | using __value_type _LIBCPP_NODEBUG = _Tp; | 663 | using __value_type _LIBCPP_NODEBUG = _Tp; |
| 662 | static constexpr size_t __index = _Index; | 664 | static constexpr size_t __index = _Index; |
| 663 | 665 | ||
| ... | @@ -669,14 +671,14 @@ struct _LIBCPP_TEMPLATE_VIS __alt { | ... | @@ -669,14 +671,14 @@ struct _LIBCPP_TEMPLATE_VIS __alt { |
| 669 | }; | 671 | }; |
| 670 | 672 | ||
| 671 | template <_Trait _DestructibleTrait, size_t _Index, class... _Types> | 673 | template <_Trait _DestructibleTrait, size_t _Index, class... _Types> |
| 672 | union _LIBCPP_TEMPLATE_VIS __union; | 674 | union __union; |
| 673 | 675 | ||
| 674 | template <_Trait _DestructibleTrait, size_t _Index> | 676 | template <_Trait _DestructibleTrait, size_t _Index> |
| 675 | union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; | 677 | union __union<_DestructibleTrait, _Index> {}; |
| 676 | 678 | ||
| 677 | # define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \ | 679 | # define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \ |
| 678 | template <size_t _Index, class _Tp, class... _Types> \ | 680 | template <size_t _Index, class _Tp, class... _Types> \ |
| 679 | union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \ | 681 | union __union<destructible_trait, _Index, _Tp, _Types...> { \ |
| 680 | public: \ | 682 | public: \ |
| 681 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \ | 683 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \ |
| 682 | \ | 684 | \ |
| ... | @@ -711,7 +713,7 @@ _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTE | ... | @@ -711,7 +713,7 @@ _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTE |
| 711 | # undef _LIBCPP_VARIANT_UNION | 713 | # undef _LIBCPP_VARIANT_UNION |
| 712 | 714 | ||
| 713 | template <_Trait _DestructibleTrait, class... _Types> | 715 | template <_Trait _DestructibleTrait, class... _Types> |
| 714 | class _LIBCPP_TEMPLATE_VIS __base { | 716 | class __base { |
| 715 | public: | 717 | public: |
| 716 | using __index_t _LIBCPP_NODEBUG = __variant_index_t<sizeof...(_Types)>; | 718 | using __index_t _LIBCPP_NODEBUG = __variant_index_t<sizeof...(_Types)>; |
| 717 | 719 | ||
| ... | @@ -747,12 +749,11 @@ protected: | ... | @@ -747,12 +749,11 @@ protected: |
| 747 | }; | 749 | }; |
| 748 | 750 | ||
| 749 | template <class _Traits, _Trait = _Traits::__destructible_trait> | 751 | template <class _Traits, _Trait = _Traits::__destructible_trait> |
| 750 | class _LIBCPP_TEMPLATE_VIS __dtor; | 752 | class __dtor; |
| 751 | 753 | ||
| 752 | # define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \ | 754 | # define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \ |
| 753 | template <class... _Types> \ | 755 | template <class... _Types> \ |
| 754 | class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \ | 756 | class __dtor<__traits<_Types...>, destructible_trait> : public __base<destructible_trait, _Types...> { \ |
| 755 | : public __base<destructible_trait, _Types...> { \ | ||
| 756 | using __base_type _LIBCPP_NODEBUG = __base<destructible_trait, _Types...>; \ | 757 | using __base_type _LIBCPP_NODEBUG = __base<destructible_trait, _Types...>; \ |
| 757 | using __index_t _LIBCPP_NODEBUG = typename __base_type::__index_t; \ | 758 | using __index_t _LIBCPP_NODEBUG = typename __base_type::__index_t; \ |
| 758 | \ | 759 | \ |
| ... | @@ -798,7 +799,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable, | ... | @@ -798,7 +799,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable, |
| 798 | # undef _LIBCPP_VARIANT_DESTRUCTOR | 799 | # undef _LIBCPP_VARIANT_DESTRUCTOR |
| 799 | 800 | ||
| 800 | template <class _Traits> | 801 | template <class _Traits> |
| 801 | class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> { | 802 | class __ctor : public __dtor<_Traits> { |
| 802 | using __base_type _LIBCPP_NODEBUG = __dtor<_Traits>; | 803 | using __base_type _LIBCPP_NODEBUG = __dtor<_Traits>; |
| 803 | 804 | ||
| 804 | public: | 805 | public: |
| ... | @@ -825,12 +826,11 @@ protected: | ... | @@ -825,12 +826,11 @@ protected: |
| 825 | }; | 826 | }; |
| 826 | 827 | ||
| 827 | template <class _Traits, _Trait = _Traits::__move_constructible_trait> | 828 | template <class _Traits, _Trait = _Traits::__move_constructible_trait> |
| 828 | class _LIBCPP_TEMPLATE_VIS __move_constructor; | 829 | class __move_constructor; |
| 829 | 830 | ||
| 830 | # define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \ | 831 | # define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \ |
| 831 | template <class... _Types> \ | 832 | template <class... _Types> \ |
| 832 | class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \ | 833 | class __move_constructor<__traits<_Types...>, move_constructible_trait> : public __ctor<__traits<_Types...>> { \ |
| 833 | : public __ctor<__traits<_Types...>> { \ | ||
| 834 | using __base_type _LIBCPP_NODEBUG = __ctor<__traits<_Types...>>; \ | 834 | using __base_type _LIBCPP_NODEBUG = __ctor<__traits<_Types...>>; \ |
| 835 | \ | 835 | \ |
| 836 | public: \ | 836 | public: \ |
| ... | @@ -851,8 +851,7 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( | ... | @@ -851,8 +851,7 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 851 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( | 851 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 852 | _Trait::_Available, | 852 | _Trait::_Available, |
| 853 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) noexcept( | 853 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) noexcept( |
| 854 | __all<is_nothrow_move_constructible_v<_Types>...>::value) | 854 | __all<is_nothrow_move_constructible_v<_Types>...>::value) : __move_constructor(__valueless_t{}) { |
| 855 | : __move_constructor(__valueless_t{}) { | ||
| 856 | this->__generic_construct(*this, std::move(__that)); | 855 | this->__generic_construct(*this, std::move(__that)); |
| 857 | } _LIBCPP_EAT_SEMICOLON); | 856 | } _LIBCPP_EAT_SEMICOLON); |
| 858 | 857 | ||
| ... | @@ -863,11 +862,11 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( | ... | @@ -863,11 +862,11 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 863 | # undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR | 862 | # undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR |
| 864 | 863 | ||
| 865 | template <class _Traits, _Trait = _Traits::__copy_constructible_trait> | 864 | template <class _Traits, _Trait = _Traits::__copy_constructible_trait> |
| 866 | class _LIBCPP_TEMPLATE_VIS __copy_constructor; | 865 | class __copy_constructor; |
| 867 | 866 | ||
| 868 | # define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \ | 867 | # define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \ |
| 869 | template <class... _Types> \ | 868 | template <class... _Types> \ |
| 870 | class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \ | 869 | class __copy_constructor<__traits<_Types...>, copy_constructible_trait> \ |
| 871 | : public __move_constructor<__traits<_Types...>> { \ | 870 | : public __move_constructor<__traits<_Types...>> { \ |
| 872 | using __base_type _LIBCPP_NODEBUG = __move_constructor<__traits<_Types...>>; \ | 871 | using __base_type _LIBCPP_NODEBUG = __move_constructor<__traits<_Types...>>; \ |
| 873 | \ | 872 | \ |
| ... | @@ -888,8 +887,9 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR( | ... | @@ -888,8 +887,9 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 888 | 887 | ||
| 889 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( | 888 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 890 | _Trait::_Available, | 889 | _Trait::_Available, |
| 891 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that) | 890 | _LIBCPP_HIDE_FROM_ABI |
| 892 | : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON); | 891 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that) : __copy_constructor( |
| 892 | __valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON); | ||
| 893 | 893 | ||
| 894 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( | 894 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 895 | _Trait::_Unavailable, | 895 | _Trait::_Unavailable, |
| ... | @@ -898,7 +898,7 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR( | ... | @@ -898,7 +898,7 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 898 | # undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR | 898 | # undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR |
| 899 | 899 | ||
| 900 | template <class _Traits> | 900 | template <class _Traits> |
| 901 | class _LIBCPP_TEMPLATE_VIS __assignment : public __copy_constructor<_Traits> { | 901 | class __assignment : public __copy_constructor<_Traits> { |
| 902 | using __base_type _LIBCPP_NODEBUG = __copy_constructor<_Traits>; | 902 | using __base_type _LIBCPP_NODEBUG = __copy_constructor<_Traits>; |
| 903 | 903 | ||
| 904 | public: | 904 | public: |
| ... | @@ -952,12 +952,11 @@ protected: | ... | @@ -952,12 +952,11 @@ protected: |
| 952 | }; | 952 | }; |
| 953 | 953 | ||
| 954 | template <class _Traits, _Trait = _Traits::__move_assignable_trait> | 954 | template <class _Traits, _Trait = _Traits::__move_assignable_trait> |
| 955 | class _LIBCPP_TEMPLATE_VIS __move_assignment; | 955 | class __move_assignment; |
| 956 | 956 | ||
| 957 | # define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \ | 957 | # define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \ |
| 958 | template <class... _Types> \ | 958 | template <class... _Types> \ |
| 959 | class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \ | 959 | class __move_assignment<__traits<_Types...>, move_assignable_trait> : public __assignment<__traits<_Types...>> { \ |
| 960 | : public __assignment<__traits<_Types...>> { \ | ||
| 961 | using __base_type _LIBCPP_NODEBUG = __assignment<__traits<_Types...>>; \ | 960 | using __base_type _LIBCPP_NODEBUG = __assignment<__traits<_Types...>>; \ |
| 962 | \ | 961 | \ |
| 963 | public: \ | 962 | public: \ |
| ... | @@ -991,11 +990,11 @@ _LIBCPP_VARIANT_MOVE_ASSIGNMENT( | ... | @@ -991,11 +990,11 @@ _LIBCPP_VARIANT_MOVE_ASSIGNMENT( |
| 991 | # undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT | 990 | # undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT |
| 992 | 991 | ||
| 993 | template <class _Traits, _Trait = _Traits::__copy_assignable_trait> | 992 | template <class _Traits, _Trait = _Traits::__copy_assignable_trait> |
| 994 | class _LIBCPP_TEMPLATE_VIS __copy_assignment; | 993 | class __copy_assignment; |
| 995 | 994 | ||
| 996 | # define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \ | 995 | # define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \ |
| 997 | template <class... _Types> \ | 996 | template <class... _Types> \ |
| 998 | class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \ | 997 | class __copy_assignment<__traits<_Types...>, copy_assignable_trait> \ |
| 999 | : public __move_assignment<__traits<_Types...>> { \ | 998 | : public __move_assignment<__traits<_Types...>> { \ |
| 1000 | using __base_type _LIBCPP_NODEBUG = __move_assignment<__traits<_Types...>>; \ | 999 | using __base_type _LIBCPP_NODEBUG = __move_assignment<__traits<_Types...>>; \ |
| 1001 | \ | 1000 | \ |
| ... | @@ -1029,7 +1028,7 @@ _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable, | ... | @@ -1029,7 +1028,7 @@ _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable, |
| 1029 | # undef _LIBCPP_VARIANT_COPY_ASSIGNMENT | 1028 | # undef _LIBCPP_VARIANT_COPY_ASSIGNMENT |
| 1030 | 1029 | ||
| 1031 | template <class... _Types> | 1030 | template <class... _Types> |
| 1032 | class _LIBCPP_TEMPLATE_VIS __impl : public __copy_assignment<__traits<_Types...>> { | 1031 | class __impl : public __copy_assignment<__traits<_Types...>> { |
| 1033 | using __base_type _LIBCPP_NODEBUG = __copy_assignment<__traits<_Types...>>; | 1032 | using __base_type _LIBCPP_NODEBUG = __copy_assignment<__traits<_Types...>>; |
| 1034 | 1033 | ||
| 1035 | public: | 1034 | public: |
| ... | @@ -1143,20 +1142,18 @@ using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_ | ... | @@ -1143,20 +1142,18 @@ using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_ |
| 1143 | } // namespace __variant_detail | 1142 | } // namespace __variant_detail |
| 1144 | 1143 | ||
| 1145 | template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>> | 1144 | template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>> |
| 1146 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto) | 1145 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs); |
| 1147 | visit(_Visitor&& __visitor, _Vs&&... __vs); | ||
| 1148 | 1146 | ||
| 1149 | # if _LIBCPP_STD_VER >= 20 | 1147 | # if _LIBCPP_STD_VER >= 20 |
| 1150 | template <class _Rp, | 1148 | template <class _Rp, |
| 1151 | class _Visitor, | 1149 | class _Visitor, |
| 1152 | class... _Vs, | 1150 | class... _Vs, |
| 1153 | typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>> | 1151 | typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>> |
| 1154 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp | 1152 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs); |
| 1155 | visit(_Visitor&& __visitor, _Vs&&... __vs); | ||
| 1156 | # endif | 1153 | # endif |
| 1157 | 1154 | ||
| 1158 | template <class... _Types> | 1155 | template <class... _Types> |
| 1159 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant | 1156 | class _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant |
| 1160 | : private __sfinae_ctor_base< __all<is_copy_constructible_v<_Types>...>::value, | 1157 | : private __sfinae_ctor_base< __all<is_copy_constructible_v<_Types>...>::value, |
| 1161 | __all<is_move_constructible_v<_Types>...>::value>, | 1158 | __all<is_move_constructible_v<_Types>...>::value>, |
| 1162 | private __sfinae_assign_base< | 1159 | private __sfinae_assign_base< |
| ... | @@ -1175,6 +1172,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIO | ... | @@ -1175,6 +1172,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIO |
| 1175 | public: | 1172 | public: |
| 1176 | using __trivially_relocatable _LIBCPP_NODEBUG = | 1173 | using __trivially_relocatable _LIBCPP_NODEBUG = |
| 1177 | conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>; | 1174 | conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>; |
| 1175 | using __replaceable _LIBCPP_NODEBUG = conditional_t<_And<__is_replaceable<_Types>...>::value, variant, void>; | ||
| 1178 | 1176 | ||
| 1179 | template <bool _Dummy = true, | 1177 | template <bool _Dummy = true, |
| 1180 | enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0> | 1178 | enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0> |
| ... | @@ -1338,35 +1336,30 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>& | ... | @@ -1338,35 +1336,30 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>& |
| 1338 | } | 1336 | } |
| 1339 | 1337 | ||
| 1340 | template <size_t _Ip, class _Vp> | 1338 | template <size_t _Ip, class _Vp> |
| 1341 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr auto&& __generic_get(_Vp&& __v) { | 1339 | _LIBCPP_HIDE_FROM_ABI constexpr auto&& __generic_get(_Vp&& __v) { |
| 1342 | using __variant_detail::__access::__variant; | 1340 | using __variant_detail::__access::__variant; |
| 1343 | if (!std::__holds_alternative<_Ip>(__v)) { | 1341 | if (!std::__holds_alternative<_Ip>(__v)) { |
| 1344 | __throw_bad_variant_access(); | 1342 | std::__throw_bad_variant_access(); |
| 1345 | } | 1343 | } |
| 1346 | return __variant::__get_alt<_Ip>(std::forward<_Vp>(__v)).__value; | 1344 | return __variant::__get_alt<_Ip>(std::forward<_Vp>(__v)).__value; |
| 1347 | } | 1345 | } |
| 1348 | 1346 | ||
| 1349 | template <size_t _Ip, class... _Types> | 1347 | template <size_t _Ip, class... _Types> |
| 1350 | _LIBCPP_HIDE_FROM_ABI | 1348 | _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(variant<_Types...>& __v) { |
| 1351 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>& | ||
| 1352 | get(variant<_Types...>& __v) { | ||
| 1353 | static_assert(_Ip < sizeof...(_Types)); | 1349 | static_assert(_Ip < sizeof...(_Types)); |
| 1354 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1350 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1355 | return std::__generic_get<_Ip>(__v); | 1351 | return std::__generic_get<_Ip>(__v); |
| 1356 | } | 1352 | } |
| 1357 | 1353 | ||
| 1358 | template <size_t _Ip, class... _Types> | 1354 | template <size_t _Ip, class... _Types> |
| 1359 | _LIBCPP_HIDE_FROM_ABI | 1355 | _LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(variant<_Types...>&& __v) { |
| 1360 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&& | ||
| 1361 | get(variant<_Types...>&& __v) { | ||
| 1362 | static_assert(_Ip < sizeof...(_Types)); | 1356 | static_assert(_Ip < sizeof...(_Types)); |
| 1363 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1357 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| 1364 | return std::__generic_get<_Ip>(std::move(__v)); | 1358 | return std::__generic_get<_Ip>(std::move(__v)); |
| 1365 | } | 1359 | } |
| 1366 | 1360 | ||
| 1367 | template <size_t _Ip, class... _Types> | 1361 | template <size_t _Ip, class... _Types> |
| 1368 | _LIBCPP_HIDE_FROM_ABI | 1362 | _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>& |
| 1369 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>& | ||
| 1370 | get(const variant<_Types...>& __v) { | 1363 | get(const variant<_Types...>& __v) { |
| 1371 | static_assert(_Ip < sizeof...(_Types)); | 1364 | static_assert(_Ip < sizeof...(_Types)); |
| 1372 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1365 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| ... | @@ -1374,8 +1367,7 @@ get(const variant<_Types...>& __v) { | ... | @@ -1374,8 +1367,7 @@ get(const variant<_Types...>& __v) { |
| 1374 | } | 1367 | } |
| 1375 | 1368 | ||
| 1376 | template <size_t _Ip, class... _Types> | 1369 | template <size_t _Ip, class... _Types> |
| 1377 | _LIBCPP_HIDE_FROM_ABI | 1370 | _LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& |
| 1378 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& | ||
| 1379 | get(const variant<_Types...>&& __v) { | 1371 | get(const variant<_Types...>&& __v) { |
| 1380 | static_assert(_Ip < sizeof...(_Types)); | 1372 | static_assert(_Ip < sizeof...(_Types)); |
| 1381 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); | 1373 | static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>); |
| ... | @@ -1383,27 +1375,25 @@ get(const variant<_Types...>&& __v) { | ... | @@ -1383,27 +1375,25 @@ get(const variant<_Types...>&& __v) { |
| 1383 | } | 1375 | } |
| 1384 | 1376 | ||
| 1385 | template <class _Tp, class... _Types> | 1377 | template <class _Tp, class... _Types> |
| 1386 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>& __v) { | 1378 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>& __v) { |
| 1387 | static_assert(!is_void_v<_Tp>); | 1379 | static_assert(!is_void_v<_Tp>); |
| 1388 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); | 1380 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1389 | } | 1381 | } |
| 1390 | 1382 | ||
| 1391 | template <class _Tp, class... _Types> | 1383 | template <class _Tp, class... _Types> |
| 1392 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&& __v) { | 1384 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&& __v) { |
| 1393 | static_assert(!is_void_v<_Tp>); | 1385 | static_assert(!is_void_v<_Tp>); |
| 1394 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); | 1386 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); |
| 1395 | } | 1387 | } |
| 1396 | 1388 | ||
| 1397 | template <class _Tp, class... _Types> | 1389 | template <class _Tp, class... _Types> |
| 1398 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp& | 1390 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>& __v) { |
| 1399 | get(const variant<_Types...>& __v) { | ||
| 1400 | static_assert(!is_void_v<_Tp>); | 1391 | static_assert(!is_void_v<_Tp>); |
| 1401 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); | 1392 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1402 | } | 1393 | } |
| 1403 | 1394 | ||
| 1404 | template <class _Tp, class... _Types> | 1395 | template <class _Tp, class... _Types> |
| 1405 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&& | 1396 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&& __v) { |
| 1406 | get(const variant<_Types...>&& __v) { | ||
| 1407 | static_assert(!is_void_v<_Tp>); | 1397 | static_assert(!is_void_v<_Tp>); |
| 1408 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); | 1398 | return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v)); |
| 1409 | } | 1399 | } |
| ... | @@ -1453,6 +1443,11 @@ struct __convert_to_bool { | ... | @@ -1453,6 +1443,11 @@ struct __convert_to_bool { |
| 1453 | }; | 1443 | }; |
| 1454 | 1444 | ||
| 1455 | template <class... _Types> | 1445 | template <class... _Types> |
| 1446 | # if _LIBCPP_STD_VER >= 26 | ||
| 1447 | requires(requires(const _Types& __t) { | ||
| 1448 | { __t == __t } -> __core_convertible_to<bool>; | ||
| 1449 | } && ...) | ||
| 1450 | # endif | ||
| 1456 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { | 1451 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1457 | using __variant_detail::__visitation::__variant; | 1452 | using __variant_detail::__visitation::__variant; |
| 1458 | if (__lhs.index() != __rhs.index()) | 1453 | if (__lhs.index() != __rhs.index()) |
| ... | @@ -1485,6 +1480,11 @@ operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { | ... | @@ -1485,6 +1480,11 @@ operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1485 | # endif // _LIBCPP_STD_VER >= 20 | 1480 | # endif // _LIBCPP_STD_VER >= 20 |
| 1486 | 1481 | ||
| 1487 | template <class... _Types> | 1482 | template <class... _Types> |
| 1483 | # if _LIBCPP_STD_VER >= 26 | ||
| 1484 | requires(requires(const _Types& __t) { | ||
| 1485 | { __t != __t } -> __core_convertible_to<bool>; | ||
| 1486 | } && ...) | ||
| 1487 | # endif | ||
| 1488 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { | 1488 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1489 | using __variant_detail::__visitation::__variant; | 1489 | using __variant_detail::__visitation::__variant; |
| 1490 | if (__lhs.index() != __rhs.index()) | 1490 | if (__lhs.index() != __rhs.index()) |
| ... | @@ -1495,6 +1495,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, | ... | @@ -1495,6 +1495,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, |
| 1495 | } | 1495 | } |
| 1496 | 1496 | ||
| 1497 | template <class... _Types> | 1497 | template <class... _Types> |
| 1498 | # if _LIBCPP_STD_VER >= 26 | ||
| 1499 | requires(requires(const _Types& __t) { | ||
| 1500 | { __t < __t } -> __core_convertible_to<bool>; | ||
| 1501 | } && ...) | ||
| 1502 | # endif | ||
| 1498 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { | 1503 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1499 | using __variant_detail::__visitation::__variant; | 1504 | using __variant_detail::__visitation::__variant; |
| 1500 | if (__rhs.valueless_by_exception()) | 1505 | if (__rhs.valueless_by_exception()) |
| ... | @@ -1509,6 +1514,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs, | ... | @@ -1509,6 +1514,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs, |
| 1509 | } | 1514 | } |
| 1510 | 1515 | ||
| 1511 | template <class... _Types> | 1516 | template <class... _Types> |
| 1517 | # if _LIBCPP_STD_VER >= 26 | ||
| 1518 | requires(requires(const _Types& __t) { | ||
| 1519 | { __t > __t } -> __core_convertible_to<bool>; | ||
| 1520 | } && ...) | ||
| 1521 | # endif | ||
| 1512 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { | 1522 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1513 | using __variant_detail::__visitation::__variant; | 1523 | using __variant_detail::__visitation::__variant; |
| 1514 | if (__lhs.valueless_by_exception()) | 1524 | if (__lhs.valueless_by_exception()) |
| ... | @@ -1523,6 +1533,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs, | ... | @@ -1523,6 +1533,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs, |
| 1523 | } | 1533 | } |
| 1524 | 1534 | ||
| 1525 | template <class... _Types> | 1535 | template <class... _Types> |
| 1536 | # if _LIBCPP_STD_VER >= 26 | ||
| 1537 | requires(requires(const _Types& __t) { | ||
| 1538 | { __t <= __t } -> __core_convertible_to<bool>; | ||
| 1539 | } && ...) | ||
| 1540 | # endif | ||
| 1526 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { | 1541 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1527 | using __variant_detail::__visitation::__variant; | 1542 | using __variant_detail::__visitation::__variant; |
| 1528 | if (__lhs.valueless_by_exception()) | 1543 | if (__lhs.valueless_by_exception()) |
| ... | @@ -1537,6 +1552,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs, | ... | @@ -1537,6 +1552,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs, |
| 1537 | } | 1552 | } |
| 1538 | 1553 | ||
| 1539 | template <class... _Types> | 1554 | template <class... _Types> |
| 1555 | # if _LIBCPP_STD_VER >= 26 | ||
| 1556 | requires(requires(const _Types& __t) { | ||
| 1557 | { __t >= __t } -> __core_convertible_to<bool>; | ||
| 1558 | } && ...) | ||
| 1559 | # endif | ||
| 1540 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { | 1560 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1541 | using __variant_detail::__visitation::__variant; | 1561 | using __variant_detail::__visitation::__variant; |
| 1542 | if (__rhs.valueless_by_exception()) | 1562 | if (__rhs.valueless_by_exception()) |
| ... | @@ -1551,16 +1571,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs, | ... | @@ -1551,16 +1571,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs, |
| 1551 | } | 1571 | } |
| 1552 | 1572 | ||
| 1553 | template <class... _Vs> | 1573 | template <class... _Vs> |
| 1554 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr void __throw_if_valueless(_Vs&&... __vs) { | 1574 | _LIBCPP_HIDE_FROM_ABI constexpr void __throw_if_valueless(_Vs&&... __vs) { |
| 1555 | const bool __valueless = (... || std::__as_variant(__vs).valueless_by_exception()); | 1575 | const bool __valueless = (... || std::__as_variant(__vs).valueless_by_exception()); |
| 1556 | if (__valueless) { | 1576 | if (__valueless) { |
| 1557 | __throw_bad_variant_access(); | 1577 | std::__throw_bad_variant_access(); |
| 1558 | } | 1578 | } |
| 1559 | } | 1579 | } |
| 1560 | 1580 | ||
| 1561 | template < class _Visitor, class... _Vs, typename> | 1581 | template < class _Visitor, class... _Vs, typename> |
| 1562 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto) | 1582 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| 1563 | visit(_Visitor&& __visitor, _Vs&&... __vs) { | ||
| 1564 | using __variant_detail::__visitation::__variant; | 1583 | using __variant_detail::__visitation::__variant; |
| 1565 | std::__throw_if_valueless(std::forward<_Vs>(__vs)...); | 1584 | std::__throw_if_valueless(std::forward<_Vs>(__vs)...); |
| 1566 | return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...); | 1585 | return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...); |
| ... | @@ -1568,8 +1587,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { | ... | @@ -1568,8 +1587,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| 1568 | 1587 | ||
| 1569 | # if _LIBCPP_STD_VER >= 20 | 1588 | # if _LIBCPP_STD_VER >= 20 |
| 1570 | template < class _Rp, class _Visitor, class... _Vs, typename> | 1589 | template < class _Rp, class _Visitor, class... _Vs, typename> |
| 1571 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp | 1590 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| 1572 | visit(_Visitor&& __visitor, _Vs&&... __vs) { | ||
| 1573 | using __variant_detail::__visitation::__variant; | 1591 | using __variant_detail::__visitation::__variant; |
| 1574 | std::__throw_if_valueless(std::forward<_Vs>(__vs)...); | 1592 | std::__throw_if_valueless(std::forward<_Vs>(__vs)...); |
| 1575 | return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...); | 1593 | return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...); |
| ... | @@ -1578,17 +1596,19 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { | ... | @@ -1578,17 +1596,19 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| 1578 | 1596 | ||
| 1579 | template <class... _Types> | 1597 | template <class... _Types> |
| 1580 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto | 1598 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto |
| 1581 | swap(variant<_Types...>& __lhs, | 1599 | swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) |
| 1582 | variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) -> decltype(__lhs.swap(__rhs)) { | 1600 | -> decltype(__lhs.swap(__rhs)) { |
| 1583 | return __lhs.swap(__rhs); | 1601 | return __lhs.swap(__rhs); |
| 1584 | } | 1602 | } |
| 1585 | 1603 | ||
| 1586 | template <class... _Types> | 1604 | template <class... _Types> |
| 1587 | struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...>> { | 1605 | struct hash< __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...>> { |
| 1588 | using argument_type = variant<_Types...>; | 1606 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) |
| 1589 | using result_type = size_t; | 1607 | using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = variant<_Types...>; |
| 1608 | using result_type _LIBCPP_DEPRECATED_IN_CXX17 = size_t; | ||
| 1609 | # endif | ||
| 1590 | 1610 | ||
| 1591 | _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type& __v) const { | 1611 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const variant<_Types...>& __v) const { |
| 1592 | using __variant_detail::__visitation::__variant; | 1612 | using __variant_detail::__visitation::__variant; |
| 1593 | size_t __res = | 1613 | size_t __res = |
| 1594 | __v.valueless_by_exception() | 1614 | __v.valueless_by_exception() |
lib/libcxx/include/vector+1| ... | @@ -362,6 +362,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ | ... | @@ -362,6 +362,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ |
| 362 | # if _LIBCPP_HAS_LOCALIZATION | 362 | # if _LIBCPP_HAS_LOCALIZATION |
| 363 | # include <locale> | 363 | # include <locale> |
| 364 | # endif | 364 | # endif |
| 365 | # include <optional> | ||
| 365 | # include <string> | 366 | # include <string> |
| 366 | # include <string_view> | 367 | # include <string_view> |
| 367 | # include <tuple> | 368 | # include <tuple> |
lib/libcxx/include/version+24-7| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | Macro name Value Headers | 16 | Macro name Value Headers |
| 17 | __cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack> | 17 | __cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack> |
| 18 | __cpp_lib_addressof_constexpr 201603L <memory> | 18 | __cpp_lib_addressof_constexpr 201603L <memory> |
| 19 | __cpp_lib_aligned_accessor 202411L <mdspan> | ||
| 19 | __cpp_lib_allocate_at_least 202302L <memory> | 20 | __cpp_lib_allocate_at_least 202302L <memory> |
| 20 | __cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list> | 21 | __cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list> |
| 21 | <map> <memory> <scoped_allocator> | 22 | <map> <memory> <scoped_allocator> |
| ... | @@ -58,28 +59,34 @@ __cpp_lib_char8_t 201907L <atomic> <filesy | ... | @@ -58,28 +59,34 @@ __cpp_lib_char8_t 201907L <atomic> <filesy |
| 58 | __cpp_lib_chrono 201611L <chrono> | 59 | __cpp_lib_chrono 201611L <chrono> |
| 59 | __cpp_lib_chrono_udls 201304L <chrono> | 60 | __cpp_lib_chrono_udls 201304L <chrono> |
| 60 | __cpp_lib_clamp 201603L <algorithm> | 61 | __cpp_lib_clamp 201603L <algorithm> |
| 62 | __cpp_lib_common_reference 202302L <type_traits> | ||
| 63 | __cpp_lib_common_reference_wrapper 202302L <functional> | ||
| 61 | __cpp_lib_complex_udls 201309L <complex> | 64 | __cpp_lib_complex_udls 201309L <complex> |
| 62 | __cpp_lib_concepts 202002L <concepts> | 65 | __cpp_lib_concepts 202002L <concepts> |
| 63 | __cpp_lib_constexpr_algorithms 201806L <algorithm> <utility> | 66 | __cpp_lib_constexpr_algorithms 202306L <algorithm> <utility> |
| 67 | 201806L // C++20 | ||
| 64 | __cpp_lib_constexpr_bitset 202207L <bitset> | 68 | __cpp_lib_constexpr_bitset 202207L <bitset> |
| 65 | __cpp_lib_constexpr_charconv 202207L <charconv> | 69 | __cpp_lib_constexpr_charconv 202207L <charconv> |
| 66 | __cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib> | 70 | __cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib> |
| 67 | __cpp_lib_constexpr_complex 201711L <complex> | 71 | __cpp_lib_constexpr_complex 201711L <complex> |
| 68 | __cpp_lib_constexpr_dynamic_alloc 201907L <memory> | 72 | __cpp_lib_constexpr_dynamic_alloc 201907L <memory> |
| 73 | __cpp_lib_constexpr_forward_list 202502L <forward_list> | ||
| 69 | __cpp_lib_constexpr_functional 201907L <functional> | 74 | __cpp_lib_constexpr_functional 201907L <functional> |
| 70 | __cpp_lib_constexpr_iterator 201811L <iterator> | 75 | __cpp_lib_constexpr_iterator 201811L <iterator> |
| 76 | __cpp_lib_constexpr_list 202502L <list> | ||
| 71 | __cpp_lib_constexpr_memory 202202L <memory> | 77 | __cpp_lib_constexpr_memory 202202L <memory> |
| 72 | 201811L // C++20 | 78 | 201811L // C++20 |
| 73 | __cpp_lib_constexpr_new 202406L <new> | 79 | __cpp_lib_constexpr_new 202406L <new> |
| 74 | __cpp_lib_constexpr_numeric 201911L <numeric> | 80 | __cpp_lib_constexpr_numeric 201911L <numeric> |
| 81 | __cpp_lib_constexpr_queue 202502L <queue> | ||
| 75 | __cpp_lib_constexpr_string 201907L <string> | 82 | __cpp_lib_constexpr_string 201907L <string> |
| 76 | __cpp_lib_constexpr_string_view 201811L <string_view> | 83 | __cpp_lib_constexpr_string_view 201811L <string_view> |
| 77 | __cpp_lib_constexpr_tuple 201811L <tuple> | 84 | __cpp_lib_constexpr_tuple 201811L <tuple> |
| 78 | __cpp_lib_constexpr_typeinfo 202106L <typeinfo> | 85 | __cpp_lib_constexpr_typeinfo 202106L <typeinfo> |
| 79 | __cpp_lib_constexpr_utility 201811L <utility> | 86 | __cpp_lib_constexpr_utility 201811L <utility> |
| 80 | __cpp_lib_constexpr_vector 201907L <vector> | 87 | __cpp_lib_constexpr_vector 201907L <vector> |
| 81 | __cpp_lib_constrained_equality 202403L <optional> <tuple> <utility> | 88 | __cpp_lib_constrained_equality 202411L <expected> <optional> <tuple> |
| 82 | <variant> | 89 | <utility> <variant> |
| 83 | __cpp_lib_containers_ranges 202202L <deque> <forward_list> <list> | 90 | __cpp_lib_containers_ranges 202202L <deque> <forward_list> <list> |
| 84 | <map> <queue> <set> | 91 | <map> <queue> <set> |
| 85 | <stack> <string> <unordered_map> | 92 | <stack> <string> <unordered_map> |
| ... | @@ -147,6 +154,7 @@ __cpp_lib_is_nothrow_convertible 201806L <type_traits> | ... | @@ -147,6 +154,7 @@ __cpp_lib_is_nothrow_convertible 201806L <type_traits> |
| 147 | __cpp_lib_is_null_pointer 201309L <type_traits> | 154 | __cpp_lib_is_null_pointer 201309L <type_traits> |
| 148 | __cpp_lib_is_pointer_interconvertible 201907L <type_traits> | 155 | __cpp_lib_is_pointer_interconvertible 201907L <type_traits> |
| 149 | __cpp_lib_is_scoped_enum 202011L <type_traits> | 156 | __cpp_lib_is_scoped_enum 202011L <type_traits> |
| 157 | __cpp_lib_is_sufficiently_aligned 202411L <memory> | ||
| 150 | __cpp_lib_is_swappable 201603L <type_traits> | 158 | __cpp_lib_is_swappable 201603L <type_traits> |
| 151 | __cpp_lib_is_virtual_base_of 202406L <type_traits> | 159 | __cpp_lib_is_virtual_base_of 202406L <type_traits> |
| 152 | __cpp_lib_is_within_lifetime 202306L <type_traits> | 160 | __cpp_lib_is_within_lifetime 202306L <type_traits> |
| ... | @@ -396,6 +404,8 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -396,6 +404,8 @@ __cpp_lib_void_t 201411L <type_traits> |
| 396 | # if _LIBCPP_HAS_CHAR8_T | 404 | # if _LIBCPP_HAS_CHAR8_T |
| 397 | # define __cpp_lib_char8_t 201907L | 405 | # define __cpp_lib_char8_t 201907L |
| 398 | # endif | 406 | # endif |
| 407 | # define __cpp_lib_common_reference 202302L | ||
| 408 | # define __cpp_lib_common_reference_wrapper 202302L | ||
| 399 | # define __cpp_lib_concepts 202002L | 409 | # define __cpp_lib_concepts 202002L |
| 400 | # define __cpp_lib_constexpr_algorithms 201806L | 410 | # define __cpp_lib_constexpr_algorithms 201806L |
| 401 | # define __cpp_lib_constexpr_complex 201711L | 411 | # define __cpp_lib_constexpr_complex 201711L |
| ... | @@ -485,7 +495,7 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -485,7 +495,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 485 | # define __cpp_lib_containers_ranges 202202L | 495 | # define __cpp_lib_containers_ranges 202202L |
| 486 | # define __cpp_lib_expected 202211L | 496 | # define __cpp_lib_expected 202211L |
| 487 | # define __cpp_lib_flat_map 202207L | 497 | # define __cpp_lib_flat_map 202207L |
| 488 | // # define __cpp_lib_flat_set 202207L | 498 | # define __cpp_lib_flat_set 202207L |
| 489 | # define __cpp_lib_format_ranges 202207L | 499 | # define __cpp_lib_format_ranges 202207L |
| 490 | // # define __cpp_lib_formatters 202302L | 500 | // # define __cpp_lib_formatters 202302L |
| 491 | # define __cpp_lib_forward_like 202207L | 501 | # define __cpp_lib_forward_like 202207L |
| ... | @@ -512,8 +522,8 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -512,8 +522,8 @@ __cpp_lib_void_t 201411L <type_traits> |
| 512 | # define __cpp_lib_ranges_chunk_by 202202L | 522 | # define __cpp_lib_ranges_chunk_by 202202L |
| 513 | # define __cpp_lib_ranges_contains 202207L | 523 | # define __cpp_lib_ranges_contains 202207L |
| 514 | # define __cpp_lib_ranges_find_last 202207L | 524 | # define __cpp_lib_ranges_find_last 202207L |
| 515 | // # define __cpp_lib_ranges_iota 202202L | 525 | # define __cpp_lib_ranges_iota 202202L |
| 516 | // # define __cpp_lib_ranges_join_with 202202L | 526 | # define __cpp_lib_ranges_join_with 202202L |
| 517 | # define __cpp_lib_ranges_repeat 202207L | 527 | # define __cpp_lib_ranges_repeat 202207L |
| 518 | // # define __cpp_lib_ranges_slide 202202L | 528 | // # define __cpp_lib_ranges_slide 202202L |
| 519 | # define __cpp_lib_ranges_starts_ends_with 202106L | 529 | # define __cpp_lib_ranges_starts_ends_with 202106L |
| ... | @@ -531,15 +541,21 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -531,15 +541,21 @@ __cpp_lib_void_t 201411L <type_traits> |
| 531 | #endif | 541 | #endif |
| 532 | 542 | ||
| 533 | #if _LIBCPP_STD_VER >= 26 | 543 | #if _LIBCPP_STD_VER >= 26 |
| 544 | # define __cpp_lib_aligned_accessor 202411L | ||
| 534 | // # define __cpp_lib_associative_heterogeneous_insertion 202306L | 545 | // # define __cpp_lib_associative_heterogeneous_insertion 202306L |
| 535 | // # define __cpp_lib_atomic_min_max 202403L | 546 | // # define __cpp_lib_atomic_min_max 202403L |
| 536 | # undef __cpp_lib_bind_front | 547 | # undef __cpp_lib_bind_front |
| 537 | # define __cpp_lib_bind_front 202306L | 548 | # define __cpp_lib_bind_front 202306L |
| 538 | # define __cpp_lib_bitset 202306L | 549 | # define __cpp_lib_bitset 202306L |
| 550 | # undef __cpp_lib_constexpr_algorithms | ||
| 551 | # define __cpp_lib_constexpr_algorithms 202306L | ||
| 552 | # define __cpp_lib_constexpr_forward_list 202502L | ||
| 553 | # define __cpp_lib_constexpr_list 202502L | ||
| 539 | # if !defined(_LIBCPP_ABI_VCRUNTIME) | 554 | # if !defined(_LIBCPP_ABI_VCRUNTIME) |
| 540 | # define __cpp_lib_constexpr_new 202406L | 555 | # define __cpp_lib_constexpr_new 202406L |
| 541 | # endif | 556 | # endif |
| 542 | // # define __cpp_lib_constrained_equality 202403L | 557 | # define __cpp_lib_constexpr_queue 202502L |
| 558 | // # define __cpp_lib_constrained_equality 202411L | ||
| 543 | // # define __cpp_lib_copyable_function 202306L | 559 | // # define __cpp_lib_copyable_function 202306L |
| 544 | // # define __cpp_lib_debugging 202311L | 560 | // # define __cpp_lib_debugging 202311L |
| 545 | // # define __cpp_lib_default_template_type_for_algorithm_values 202403L | 561 | // # define __cpp_lib_default_template_type_for_algorithm_values 202403L |
| ... | @@ -559,6 +575,7 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -559,6 +575,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 559 | // # define __cpp_lib_generate_random 202403L | 575 | // # define __cpp_lib_generate_random 202403L |
| 560 | // # define __cpp_lib_hazard_pointer 202306L | 576 | // # define __cpp_lib_hazard_pointer 202306L |
| 561 | // # define __cpp_lib_inplace_vector 202406L | 577 | // # define __cpp_lib_inplace_vector 202406L |
| 578 | # define __cpp_lib_is_sufficiently_aligned 202411L | ||
| 562 | # if __has_builtin(__builtin_is_virtual_base_of) | 579 | # if __has_builtin(__builtin_is_virtual_base_of) |
| 563 | # define __cpp_lib_is_virtual_base_of 202406L | 580 | # define __cpp_lib_is_virtual_base_of 202406L |
| 564 | # endif | 581 | # endif |
lib/libcxx/src/any.cpp+1-1| ... | @@ -18,7 +18,7 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; } | ... | @@ -18,7 +18,7 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; } |
| 18 | // Even though it no longer exists in a header file | 18 | // Even though it no longer exists in a header file |
| 19 | _LIBCPP_BEGIN_NAMESPACE_LFTS | 19 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 20 | 20 | ||
| 21 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast { | 21 | class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast { |
| 22 | public: | 22 | public: |
| 23 | virtual const char* what() const noexcept; | 23 | virtual const char* what() const noexcept; |
| 24 | }; | 24 | }; |
lib/libcxx/src/atomic.cpp+5-2| ... | @@ -151,7 +151,10 @@ __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__con | ... | @@ -151,7 +151,10 @@ __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__con |
| 151 | static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state, | 151 | static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state, |
| 152 | __cxx_atomic_contention_t const volatile* __platform_state, | 152 | __cxx_atomic_contention_t const volatile* __platform_state, |
| 153 | __cxx_contention_t __old_value) { | 153 | __cxx_contention_t __old_value) { |
| 154 | __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_seq_cst); | 154 | __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_relaxed); |
| 155 | // https://github.com/llvm/llvm-project/issues/109290 | ||
| 156 | // There are no platform guarantees of a memory barrier in the platform wait implementation | ||
| 157 | __cxx_atomic_thread_fence(memory_order_seq_cst); | ||
| 155 | // We sleep as long as the monitored value hasn't changed. | 158 | // We sleep as long as the monitored value hasn't changed. |
| 156 | __libcpp_platform_wait_on_address(__platform_state, __old_value); | 159 | __libcpp_platform_wait_on_address(__platform_state, __old_value); |
| 157 | __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release); | 160 | __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release); |
| ... | @@ -163,7 +166,7 @@ static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __conte | ... | @@ -163,7 +166,7 @@ static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __conte |
| 163 | static void __libcpp_atomic_notify(void const volatile* __location) { | 166 | static void __libcpp_atomic_notify(void const volatile* __location) { |
| 164 | auto const __entry = __libcpp_contention_state(__location); | 167 | auto const __entry = __libcpp_contention_state(__location); |
| 165 | // The value sequence laundering happens on the next line below. | 168 | // The value sequence laundering happens on the next line below. |
| 166 | __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_release); | 169 | __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_seq_cst); |
| 167 | __libcpp_contention_notify( | 170 | __libcpp_contention_notify( |
| 168 | &__entry->__contention_state, | 171 | &__entry->__contention_state, |
| 169 | &__entry->__platform_state, | 172 | &__entry->__platform_state, |
lib/libcxx/src/call_once.cpp+1| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__config> | ||
| 9 | #include <__mutex/once_flag.h> | 10 | #include <__mutex/once_flag.h> |
| 10 | #include <__utility/exception_guard.h> | 11 | #include <__utility/exception_guard.h> |
| 11 | 12 |
lib/libcxx/src/chrono.cpp+6-6| ... | @@ -124,7 +124,7 @@ static system_clock::time_point __libcpp_system_clock_now() { | ... | @@ -124,7 +124,7 @@ static system_clock::time_point __libcpp_system_clock_now() { |
| 124 | static system_clock::time_point __libcpp_system_clock_now() { | 124 | static system_clock::time_point __libcpp_system_clock_now() { |
| 125 | struct timespec ts; | 125 | struct timespec ts; |
| 126 | if (timespec_get(&ts, TIME_UTC) != TIME_UTC) | 126 | if (timespec_get(&ts, TIME_UTC) != TIME_UTC) |
| 127 | __throw_system_error(errno, "timespec_get(TIME_UTC) failed"); | 127 | std::__throw_system_error(errno, "timespec_get(TIME_UTC) failed"); |
| 128 | return system_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000)); | 128 | return system_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000)); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| ... | @@ -133,7 +133,7 @@ static system_clock::time_point __libcpp_system_clock_now() { | ... | @@ -133,7 +133,7 @@ static system_clock::time_point __libcpp_system_clock_now() { |
| 133 | static system_clock::time_point __libcpp_system_clock_now() { | 133 | static system_clock::time_point __libcpp_system_clock_now() { |
| 134 | struct timespec tp; | 134 | struct timespec tp; |
| 135 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) | 135 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) |
| 136 | __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); | 136 | std::__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); |
| 137 | return system_clock::time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000)); | 137 | return system_clock::time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000)); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| ... | @@ -180,7 +180,7 @@ system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return s | ... | @@ -180,7 +180,7 @@ system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return s |
| 180 | static steady_clock::time_point __libcpp_steady_clock_now() { | 180 | static steady_clock::time_point __libcpp_steady_clock_now() { |
| 181 | struct timespec tp; | 181 | struct timespec tp; |
| 182 | if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp)) | 182 | if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp)) |
| 183 | __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed"); | 183 | std::__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed"); |
| 184 | return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); | 184 | return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| ... | @@ -213,7 +213,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() { | ... | @@ -213,7 +213,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() { |
| 213 | static steady_clock::time_point __libcpp_steady_clock_now() { | 213 | static steady_clock::time_point __libcpp_steady_clock_now() { |
| 214 | struct timespec64 ts; | 214 | struct timespec64 ts; |
| 215 | if (0 != gettimeofdayMonotonic(&ts)) | 215 | if (0 != gettimeofdayMonotonic(&ts)) |
| 216 | __throw_system_error(errno, "failed to obtain time of day"); | 216 | std::__throw_system_error(errno, "failed to obtain time of day"); |
| 217 | 217 | ||
| 218 | return steady_clock::time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec)); | 218 | return steady_clock::time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec)); |
| 219 | } | 219 | } |
| ... | @@ -234,7 +234,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept { | ... | @@ -234,7 +234,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept { |
| 234 | static steady_clock::time_point __libcpp_steady_clock_now() { | 234 | static steady_clock::time_point __libcpp_steady_clock_now() { |
| 235 | struct timespec ts; | 235 | struct timespec ts; |
| 236 | if (timespec_get(&ts, TIME_MONOTONIC) != TIME_MONOTONIC) | 236 | if (timespec_get(&ts, TIME_MONOTONIC) != TIME_MONOTONIC) |
| 237 | __throw_system_error(errno, "timespec_get(TIME_MONOTONIC) failed"); | 237 | std::__throw_system_error(errno, "timespec_get(TIME_MONOTONIC) failed"); |
| 238 | return steady_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000)); | 238 | return steady_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000)); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| ... | @@ -243,7 +243,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() { | ... | @@ -243,7 +243,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() { |
| 243 | static steady_clock::time_point __libcpp_steady_clock_now() { | 243 | static steady_clock::time_point __libcpp_steady_clock_now() { |
| 244 | struct timespec tp; | 244 | struct timespec tp; |
| 245 | if (0 != clock_gettime(CLOCK_MONOTONIC, &tp)) | 245 | if (0 != clock_gettime(CLOCK_MONOTONIC, &tp)) |
| 246 | __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed"); | 246 | std::__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed"); |
| 247 | return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); | 247 | return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); |
| 248 | } | 248 | } |
| 249 | 249 |
lib/libcxx/src/condition_variable.cpp+10-4| ... | @@ -7,7 +7,13 @@ | ... | @@ -7,7 +7,13 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <condition_variable> | 9 | #include <condition_variable> |
| 10 | #include <limits> | ||
| 11 | #include <ratio> | ||
| 10 | #include <thread> | 12 | #include <thread> |
| 13 | #include <__chrono/duration.h> | ||
| 14 | #include <__chrono/system_clock.h> | ||
| 15 | #include <__chrono/time_point.h> | ||
| 16 | #include <__system_error/throw_system_error.h> | ||
| 11 | 17 | ||
| 12 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | 18 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) |
| 13 | # pragma comment(lib, "pthread") | 19 | # pragma comment(lib, "pthread") |
| ... | @@ -26,17 +32,17 @@ void condition_variable::notify_all() noexcept { __libcpp_condvar_broadcast(&__c | ... | @@ -26,17 +32,17 @@ void condition_variable::notify_all() noexcept { __libcpp_condvar_broadcast(&__c |
| 26 | 32 | ||
| 27 | void condition_variable::wait(unique_lock<mutex>& lk) noexcept { | 33 | void condition_variable::wait(unique_lock<mutex>& lk) noexcept { |
| 28 | if (!lk.owns_lock()) | 34 | if (!lk.owns_lock()) |
| 29 | __throw_system_error(EPERM, "condition_variable::wait: mutex not locked"); | 35 | std::__throw_system_error(EPERM, "condition_variable::wait: mutex not locked"); |
| 30 | int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle()); | 36 | int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle()); |
| 31 | if (ec) | 37 | if (ec) |
| 32 | __throw_system_error(ec, "condition_variable wait failed"); | 38 | std::__throw_system_error(ec, "condition_variable wait failed"); |
| 33 | } | 39 | } |
| 34 | 40 | ||
| 35 | void condition_variable::__do_timed_wait(unique_lock<mutex>& lk, | 41 | void condition_variable::__do_timed_wait(unique_lock<mutex>& lk, |
| 36 | chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept { | 42 | chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept { |
| 37 | using namespace chrono; | 43 | using namespace chrono; |
| 38 | if (!lk.owns_lock()) | 44 | if (!lk.owns_lock()) |
| 39 | __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); | 45 | std::__throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); |
| 40 | nanoseconds d = tp.time_since_epoch(); | 46 | nanoseconds d = tp.time_since_epoch(); |
| 41 | if (d > nanoseconds(0x59682F000000E941)) | 47 | if (d > nanoseconds(0x59682F000000E941)) |
| 42 | d = nanoseconds(0x59682F000000E941); | 48 | d = nanoseconds(0x59682F000000E941); |
| ... | @@ -53,7 +59,7 @@ void condition_variable::__do_timed_wait(unique_lock<mutex>& lk, | ... | @@ -53,7 +59,7 @@ void condition_variable::__do_timed_wait(unique_lock<mutex>& lk, |
| 53 | } | 59 | } |
| 54 | int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts); | 60 | int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts); |
| 55 | if (ec != 0 && ec != ETIMEDOUT) | 61 | if (ec != 0 && ec != ETIMEDOUT) |
| 56 | __throw_system_error(ec, "condition_variable timed_wait failed"); | 62 | std::__throw_system_error(ec, "condition_variable timed_wait failed"); |
| 57 | } | 63 | } |
| 58 | 64 | ||
| 59 | void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) { | 65 | void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) { |
lib/libcxx/src/experimental/log_hardening_failure.cpp created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #include <__config> | ||
| 10 | #include <__log_hardening_failure> | ||
| 11 | #include <cstdio> | ||
| 12 | |||
| 13 | #ifdef __BIONIC__ | ||
| 14 | # include <syslog.h> | ||
| 15 | #endif // __BIONIC__ | ||
| 16 | |||
| 17 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 18 | |||
| 19 | void __log_hardening_failure(const char* message) noexcept { | ||
| 20 | // Always log the message to `stderr` in case the platform-specific system calls fail. | ||
| 21 | std::fputs(message, stderr); | ||
| 22 | |||
| 23 | #if defined(__BIONIC__) | ||
| 24 | // Show error in logcat. The latter two arguments are ignored on Android. | ||
| 25 | openlog("libc++", 0, 0); | ||
| 26 | syslog(LOG_CRIT, "%s", message); | ||
| 27 | closelog(); | ||
| 28 | #endif | ||
| 29 | } | ||
| 30 | |||
| 31 | _LIBCPP_END_NAMESPACE_STD | ||
lib/libcxx/src/experimental/time_zone.cpp+9| ... | @@ -29,6 +29,15 @@ | ... | @@ -29,6 +29,15 @@ |
| 29 | // These quirks often use a 12h interval; this is the scan interval of zdump, | 29 | // These quirks often use a 12h interval; this is the scan interval of zdump, |
| 30 | // which implies there are no sys_info objects with a duration of less than 12h. | 30 | // which implies there are no sys_info objects with a duration of less than 12h. |
| 31 | 31 | ||
| 32 | // Work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120502 | ||
| 33 | |||
| 34 | #include <__config> | ||
| 35 | |||
| 36 | // TODO(LLVM 23): When upgrading to GCC 16 this can be removed | ||
| 37 | #ifdef _LIBCPP_COMPILER_GCC | ||
| 38 | # pragma GCC optimize("-O0") | ||
| 39 | #endif | ||
| 40 | |||
| 32 | #include <algorithm> | 41 | #include <algorithm> |
| 33 | #include <cctype> | 42 | #include <cctype> |
| 34 | #include <chrono> | 43 | #include <chrono> |
lib/libcxx/src/experimental/tzdb.cpp+50-18| ... | @@ -709,6 +709,39 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { | ... | @@ -709,6 +709,39 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { |
| 709 | std::__throw_runtime_error("unknown time zone"); | 709 | std::__throw_runtime_error("unknown time zone"); |
| 710 | } | 710 | } |
| 711 | #else // ifdef _WIN32 | 711 | #else // ifdef _WIN32 |
| 712 | |||
| 713 | [[nodiscard]] static string __current_zone_environment() { | ||
| 714 | if (const char* __tz = std::getenv("TZ")) | ||
| 715 | return __tz; | ||
| 716 | |||
| 717 | return {}; | ||
| 718 | } | ||
| 719 | |||
| 720 | [[nodiscard]] static string __current_zone_etc_localtime() { | ||
| 721 | filesystem::path __path = "/etc/localtime"; | ||
| 722 | if (!filesystem::exists(__path) || !filesystem::is_symlink(__path)) | ||
| 723 | return {}; | ||
| 724 | |||
| 725 | filesystem::path __tz = filesystem::read_symlink(__path); | ||
| 726 | // The path may be a relative path, in that case convert it to an absolute | ||
| 727 | // path based on the proper initial directory. | ||
| 728 | if (__tz.is_relative()) | ||
| 729 | __tz = filesystem::canonical("/etc" / __tz); | ||
| 730 | |||
| 731 | return filesystem::relative(__tz, "/usr/share/zoneinfo/"); | ||
| 732 | } | ||
| 733 | |||
| 734 | [[nodiscard]] static string __current_zone_etc_timezone() { | ||
| 735 | filesystem::path __path = "/etc/timezone"; | ||
| 736 | if (!filesystem::exists(__path)) | ||
| 737 | return {}; | ||
| 738 | |||
| 739 | ifstream __f(__path); | ||
| 740 | string __name; | ||
| 741 | std::getline(__f, __name); | ||
| 742 | return __name; | ||
| 743 | } | ||
| 744 | |||
| 712 | [[nodiscard]] static const time_zone* __current_zone_posix(const tzdb& tzdb) { | 745 | [[nodiscard]] static const time_zone* __current_zone_posix(const tzdb& tzdb) { |
| 713 | // On POSIX systems there are several ways to configure the time zone. | 746 | // On POSIX systems there are several ways to configure the time zone. |
| 714 | // In order of priority they are: | 747 | // In order of priority they are: |
| ... | @@ -727,30 +760,29 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { | ... | @@ -727,30 +760,29 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) { |
| 727 | // | 760 | // |
| 728 | // - The time zone name is the target of the symlink /etc/localtime | 761 | // - The time zone name is the target of the symlink /etc/localtime |
| 729 | // relative to /usr/share/zoneinfo/ | 762 | // relative to /usr/share/zoneinfo/ |
| 763 | // | ||
| 764 | // - The file /etc/timezone. This text file contains the name of the time | ||
| 765 | // zone. | ||
| 766 | // | ||
| 767 | // On Linux systems it seems /etc/timezone is deprecated and being phased out. | ||
| 768 | // This file is used when /etc/localtime does not exist, or when it exists but | ||
| 769 | // is not a symlink. For more information and links see | ||
| 770 | // https://github.com/llvm/llvm-project/issues/105634 | ||
| 730 | 771 | ||
| 731 | // The algorithm is like this: | 772 | string __name = chrono::__current_zone_environment(); |
| 732 | // - If the environment variable TZ is set and points to a valid | ||
| 733 | // record use this value. | ||
| 734 | // - Else use the name based on the `/etc/localtime` symlink. | ||
| 735 | 773 | ||
| 736 | if (const char* __tz = getenv("TZ")) | 774 | // Ignore invalid names in the environment. |
| 737 | if (const time_zone* __result = tzdb.__locate_zone(__tz)) | 775 | if (!__name.empty()) |
| 776 | if (const time_zone* __result = tzdb.__locate_zone(__name)) | ||
| 738 | return __result; | 777 | return __result; |
| 739 | 778 | ||
| 740 | filesystem::path __path = "/etc/localtime"; | 779 | __name = chrono::__current_zone_etc_localtime(); |
| 741 | if (!filesystem::exists(__path)) | 780 | if (__name.empty()) |
| 742 | std::__throw_runtime_error("tzdb: the symlink '/etc/localtime' does not exist"); | 781 | __name = chrono::__current_zone_etc_timezone(); |
| 743 | |||
| 744 | if (!filesystem::is_symlink(__path)) | ||
| 745 | std::__throw_runtime_error("tzdb: the path '/etc/localtime' is not a symlink"); | ||
| 746 | 782 | ||
| 747 | filesystem::path __tz = filesystem::read_symlink(__path); | 783 | if (__name.empty()) |
| 748 | // The path may be a relative path, in that case convert it to an absolute | 784 | std::__throw_runtime_error("tzdb: unable to determine the name of the current time zone"); |
| 749 | // path based on the proper initial directory. | ||
| 750 | if (__tz.is_relative()) | ||
| 751 | __tz = filesystem::canonical("/etc" / __tz); | ||
| 752 | 785 | ||
| 753 | string __name = filesystem::relative(__tz, "/usr/share/zoneinfo/"); | ||
| 754 | if (const time_zone* __result = tzdb.__locate_zone(__name)) | 786 | if (const time_zone* __result = tzdb.__locate_zone(__name)) |
| 755 | return __result; | 787 | return __result; |
| 756 | 788 |
lib/libcxx/src/filesystem/directory_iterator.cpp+1| ... | @@ -8,6 +8,7 @@ | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | ||
| 9 | #include <__assert> | 9 | #include <__assert> |
| 10 | #include <__config> | 10 | #include <__config> |
| 11 | #include <__memory/shared_ptr.h> | ||
| 11 | #include <errno.h> | 12 | #include <errno.h> |
| 12 | #include <filesystem> | 13 | #include <filesystem> |
| 13 | #include <stack> | 14 | #include <stack> |
lib/libcxx/src/filesystem/error.h+7-6| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define FILESYSTEM_ERROR_H | 10 | #define FILESYSTEM_ERROR_H |
| 11 | 11 | ||
| 12 | #include <__assert> | 12 | #include <__assert> |
| 13 | #include <__chrono/time_point.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <cerrno> | 15 | #include <cerrno> |
| 15 | #include <cstdarg> | 16 | #include <cstdarg> |
| ... | @@ -96,11 +97,11 @@ struct ErrorHandler { | ... | @@ -96,11 +97,11 @@ struct ErrorHandler { |
| 96 | string what = string("in ") + func_name_; | 97 | string what = string("in ") + func_name_; |
| 97 | switch (bool(p1_) + bool(p2_)) { | 98 | switch (bool(p1_) + bool(p2_)) { |
| 98 | case 0: | 99 | case 0: |
| 99 | __throw_filesystem_error(what, ec); | 100 | filesystem::__throw_filesystem_error(what, ec); |
| 100 | case 1: | 101 | case 1: |
| 101 | __throw_filesystem_error(what, *p1_, ec); | 102 | filesystem::__throw_filesystem_error(what, *p1_, ec); |
| 102 | case 2: | 103 | case 2: |
| 103 | __throw_filesystem_error(what, *p1_, *p2_, ec); | 104 | filesystem::__throw_filesystem_error(what, *p1_, *p2_, ec); |
| 104 | } | 105 | } |
| 105 | __libcpp_unreachable(); | 106 | __libcpp_unreachable(); |
| 106 | } | 107 | } |
| ... | @@ -114,11 +115,11 @@ struct ErrorHandler { | ... | @@ -114,11 +115,11 @@ struct ErrorHandler { |
| 114 | string what = string("in ") + func_name_ + ": " + detail::vformat_string(msg, ap); | 115 | string what = string("in ") + func_name_ + ": " + detail::vformat_string(msg, ap); |
| 115 | switch (bool(p1_) + bool(p2_)) { | 116 | switch (bool(p1_) + bool(p2_)) { |
| 116 | case 0: | 117 | case 0: |
| 117 | __throw_filesystem_error(what, ec); | 118 | filesystem::__throw_filesystem_error(what, ec); |
| 118 | case 1: | 119 | case 1: |
| 119 | __throw_filesystem_error(what, *p1_, ec); | 120 | filesystem::__throw_filesystem_error(what, *p1_, ec); |
| 120 | case 2: | 121 | case 2: |
| 121 | __throw_filesystem_error(what, *p1_, *p2_, ec); | 122 | filesystem::__throw_filesystem_error(what, *p1_, *p2_, ec); |
| 122 | } | 123 | } |
| 123 | __libcpp_unreachable(); | 124 | __libcpp_unreachable(); |
| 124 | } | 125 | } |
lib/libcxx/src/filesystem/filesystem_clock.cpp+4-2| ... | @@ -8,8 +8,10 @@ | ... | @@ -8,8 +8,10 @@ |
| 8 | 8 | ||
| 9 | #include <__config> | 9 | #include <__config> |
| 10 | #include <__system_error/throw_system_error.h> | 10 | #include <__system_error/throw_system_error.h> |
| 11 | #include <cerrno> | ||
| 11 | #include <chrono> | 12 | #include <chrono> |
| 12 | #include <filesystem> | 13 | #include <filesystem> |
| 14 | #include <ratio> | ||
| 13 | #include <time.h> | 15 | #include <time.h> |
| 14 | 16 | ||
| 15 | #if defined(_LIBCPP_WIN32API) | 17 | #if defined(_LIBCPP_WIN32API) |
| ... | @@ -58,13 +60,13 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept { | ... | @@ -58,13 +60,13 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept { |
| 58 | typedef chrono::duration<rep, nano> __nsecs; | 60 | typedef chrono::duration<rep, nano> __nsecs; |
| 59 | struct timespec ts; | 61 | struct timespec ts; |
| 60 | if (timespec_get(&ts, TIME_UTC) != TIME_UTC) | 62 | if (timespec_get(&ts, TIME_UTC) != TIME_UTC) |
| 61 | __throw_system_error(errno, "timespec_get(TIME_UTC) failed"); | 63 | std::__throw_system_error(errno, "timespec_get(TIME_UTC) failed"); |
| 62 | return time_point(__secs(ts.tv_sec) + chrono::duration_cast<duration>(__nsecs(ts.tv_nsec))); | 64 | return time_point(__secs(ts.tv_sec) + chrono::duration_cast<duration>(__nsecs(ts.tv_nsec))); |
| 63 | #elif defined(_LIBCPP_HAS_CLOCK_GETTIME) | 65 | #elif defined(_LIBCPP_HAS_CLOCK_GETTIME) |
| 64 | typedef chrono::duration<rep, nano> __nsecs; | 66 | typedef chrono::duration<rep, nano> __nsecs; |
| 65 | struct timespec tp; | 67 | struct timespec tp; |
| 66 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) | 68 | if (0 != clock_gettime(CLOCK_REALTIME, &tp)) |
| 67 | __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); | 69 | std::__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); |
| 68 | return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec))); | 70 | return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec))); |
| 69 | #else | 71 | #else |
| 70 | typedef chrono::duration<rep, micro> __microsecs; | 72 | typedef chrono::duration<rep, micro> __microsecs; |
lib/libcxx/src/filesystem/filesystem_error.cpp+1| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__config> | 9 | #include <__config> |
| 10 | #include <__memory/shared_ptr.h> | ||
| 10 | #include <__utility/unreachable.h> | 11 | #include <__utility/unreachable.h> |
| 11 | #include <filesystem> | 12 | #include <filesystem> |
| 12 | #include <system_error> | 13 | #include <system_error> |
lib/libcxx/src/filesystem/operations.cpp+1| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__algorithm/copy.h> | ||
| 9 | #include <__assert> | 10 | #include <__assert> |
| 10 | #include <__config> | 11 | #include <__config> |
| 11 | #include <__utility/unreachable.h> | 12 | #include <__utility/unreachable.h> |
lib/libcxx/src/filesystem/path_parser.h+1-1| ... | @@ -90,7 +90,7 @@ public: | ... | @@ -90,7 +90,7 @@ public: |
| 90 | if (TkEnd) | 90 | if (TkEnd) |
| 91 | return makeState(PS_InRootName, Start, TkEnd); | 91 | return makeState(PS_InRootName, Start, TkEnd); |
| 92 | } | 92 | } |
| 93 | _LIBCPP_FALLTHROUGH(); | 93 | [[__fallthrough__]]; |
| 94 | case PS_InRootName: { | 94 | case PS_InRootName: { |
| 95 | PosPtr TkEnd = consumeAllSeparators(Start, End); | 95 | PosPtr TkEnd = consumeAllSeparators(Start, End); |
| 96 | if (TkEnd) | 96 | if (TkEnd) |
lib/libcxx/src/functional.cpp+4-2| ... | @@ -12,8 +12,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -12,8 +12,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | ||
| 13 | bad_function_call::~bad_function_call() noexcept {} | 13 | bad_function_call::~bad_function_call() noexcept {} |
| 14 | 14 | ||
| 15 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | ||
| 16 | const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; } | 15 | const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; } |
| 17 | #endif | 16 | |
| 17 | size_t __hash_memory(_LIBCPP_NOESCAPE const void* ptr, size_t size) noexcept { | ||
| 18 | return __murmur2_or_cityhash<size_t>()(ptr, size); | ||
| 19 | } | ||
| 18 | 20 | ||
| 19 | _LIBCPP_END_NAMESPACE_STD | 21 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/future.cpp+10-10| ... | @@ -62,7 +62,7 @@ void __assoc_sub_state::__on_zero_shared() noexcept { delete this; } | ... | @@ -62,7 +62,7 @@ void __assoc_sub_state::__on_zero_shared() noexcept { delete this; } |
| 62 | void __assoc_sub_state::set_value() { | 62 | void __assoc_sub_state::set_value() { |
| 63 | unique_lock<mutex> __lk(__mut_); | 63 | unique_lock<mutex> __lk(__mut_); |
| 64 | if (__has_value()) | 64 | if (__has_value()) |
| 65 | __throw_future_error(future_errc::promise_already_satisfied); | 65 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 66 | __state_ |= __constructed | ready; | 66 | __state_ |= __constructed | ready; |
| 67 | __cv_.notify_all(); | 67 | __cv_.notify_all(); |
| 68 | } | 68 | } |
| ... | @@ -70,7 +70,7 @@ void __assoc_sub_state::set_value() { | ... | @@ -70,7 +70,7 @@ void __assoc_sub_state::set_value() { |
| 70 | void __assoc_sub_state::set_value_at_thread_exit() { | 70 | void __assoc_sub_state::set_value_at_thread_exit() { |
| 71 | unique_lock<mutex> __lk(__mut_); | 71 | unique_lock<mutex> __lk(__mut_); |
| 72 | if (__has_value()) | 72 | if (__has_value()) |
| 73 | __throw_future_error(future_errc::promise_already_satisfied); | 73 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 74 | __state_ |= __constructed; | 74 | __state_ |= __constructed; |
| 75 | __thread_local_data()->__make_ready_at_thread_exit(this); | 75 | __thread_local_data()->__make_ready_at_thread_exit(this); |
| 76 | } | 76 | } |
| ... | @@ -78,7 +78,7 @@ void __assoc_sub_state::set_value_at_thread_exit() { | ... | @@ -78,7 +78,7 @@ void __assoc_sub_state::set_value_at_thread_exit() { |
| 78 | void __assoc_sub_state::set_exception(exception_ptr __p) { | 78 | void __assoc_sub_state::set_exception(exception_ptr __p) { |
| 79 | unique_lock<mutex> __lk(__mut_); | 79 | unique_lock<mutex> __lk(__mut_); |
| 80 | if (__has_value()) | 80 | if (__has_value()) |
| 81 | __throw_future_error(future_errc::promise_already_satisfied); | 81 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 82 | __exception_ = __p; | 82 | __exception_ = __p; |
| 83 | __state_ |= ready; | 83 | __state_ |= ready; |
| 84 | __cv_.notify_all(); | 84 | __cv_.notify_all(); |
| ... | @@ -87,7 +87,7 @@ void __assoc_sub_state::set_exception(exception_ptr __p) { | ... | @@ -87,7 +87,7 @@ void __assoc_sub_state::set_exception(exception_ptr __p) { |
| 87 | void __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p) { | 87 | void __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p) { |
| 88 | unique_lock<mutex> __lk(__mut_); | 88 | unique_lock<mutex> __lk(__mut_); |
| 89 | if (__has_value()) | 89 | if (__has_value()) |
| 90 | __throw_future_error(future_errc::promise_already_satisfied); | 90 | std::__throw_future_error(future_errc::promise_already_satisfied); |
| 91 | __exception_ = __p; | 91 | __exception_ = __p; |
| 92 | __thread_local_data()->__make_ready_at_thread_exit(this); | 92 | __thread_local_data()->__make_ready_at_thread_exit(this); |
| 93 | } | 93 | } |
| ... | @@ -122,7 +122,7 @@ void __assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk) { | ... | @@ -122,7 +122,7 @@ void __assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk) { |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | void __assoc_sub_state::__execute() { __throw_future_error(future_errc::no_state); } | 125 | void __assoc_sub_state::__execute() { std::__throw_future_error(future_errc::no_state); } |
| 126 | 126 | ||
| 127 | future<void>::future(__assoc_sub_state* __state) : __state_(__state) { __state_->__attach_future(); } | 127 | future<void>::future(__assoc_sub_state* __state) : __state_(__state) { __state_->__attach_future(); } |
| 128 | 128 | ||
| ... | @@ -152,31 +152,31 @@ promise<void>::~promise() { | ... | @@ -152,31 +152,31 @@ promise<void>::~promise() { |
| 152 | 152 | ||
| 153 | future<void> promise<void>::get_future() { | 153 | future<void> promise<void>::get_future() { |
| 154 | if (__state_ == nullptr) | 154 | if (__state_ == nullptr) |
| 155 | __throw_future_error(future_errc::no_state); | 155 | std::__throw_future_error(future_errc::no_state); |
| 156 | return future<void>(__state_); | 156 | return future<void>(__state_); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | void promise<void>::set_value() { | 159 | void promise<void>::set_value() { |
| 160 | if (__state_ == nullptr) | 160 | if (__state_ == nullptr) |
| 161 | __throw_future_error(future_errc::no_state); | 161 | std::__throw_future_error(future_errc::no_state); |
| 162 | __state_->set_value(); | 162 | __state_->set_value(); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | void promise<void>::set_exception(exception_ptr __p) { | 165 | void promise<void>::set_exception(exception_ptr __p) { |
| 166 | if (__state_ == nullptr) | 166 | if (__state_ == nullptr) |
| 167 | __throw_future_error(future_errc::no_state); | 167 | std::__throw_future_error(future_errc::no_state); |
| 168 | __state_->set_exception(__p); | 168 | __state_->set_exception(__p); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | void promise<void>::set_value_at_thread_exit() { | 171 | void promise<void>::set_value_at_thread_exit() { |
| 172 | if (__state_ == nullptr) | 172 | if (__state_ == nullptr) |
| 173 | __throw_future_error(future_errc::no_state); | 173 | std::__throw_future_error(future_errc::no_state); |
| 174 | __state_->set_value_at_thread_exit(); | 174 | __state_->set_value_at_thread_exit(); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | void promise<void>::set_exception_at_thread_exit(exception_ptr __p) { | 177 | void promise<void>::set_exception_at_thread_exit(exception_ptr __p) { |
| 178 | if (__state_ == nullptr) | 178 | if (__state_ == nullptr) |
| 179 | __throw_future_error(future_errc::no_state); | 179 | std::__throw_future_error(future_errc::no_state); |
| 180 | __state_->set_exception_at_thread_exit(__p); | 180 | __state_->set_exception_at_thread_exit(__p); |
| 181 | } | 181 | } |
| 182 | 182 |
lib/libcxx/src/hash.cpp+8-11| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #include <__hash_table> | 9 | #include <__hash_table> |
| 10 | #include <algorithm> | 10 | #include <algorithm> |
| 11 | #include <stdexcept> | 11 | #include <stdexcept> |
| 12 | #include <type_traits> | ||
| 13 | 12 | ||
| 14 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare") | 13 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare") |
| 15 | 14 | ||
| ... | @@ -52,16 +51,14 @@ const unsigned indices[] = { | ... | @@ -52,16 +51,14 @@ const unsigned indices[] = { |
| 52 | // are fewer potential primes to search, and fewer potential primes to divide | 51 | // are fewer potential primes to search, and fewer potential primes to divide |
| 53 | // against. | 52 | // against. |
| 54 | 53 | ||
| 55 | template <size_t _Sz = sizeof(size_t)> | 54 | inline void __check_for_overflow(size_t N) { |
| 56 | inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 4, void>::type __check_for_overflow(size_t N) { | 55 | if constexpr (sizeof(size_t) == 4) { |
| 57 | if (N > 0xFFFFFFFB) | 56 | if (N > 0xFFFFFFFB) |
| 58 | __throw_overflow_error("__next_prime overflow"); | 57 | std::__throw_overflow_error("__next_prime overflow"); |
| 59 | } | 58 | } else { |
| 60 | 59 | if (N > 0xFFFFFFFFFFFFFFC5ull) | |
| 61 | template <size_t _Sz = sizeof(size_t)> | 60 | std::__throw_overflow_error("__next_prime overflow"); |
| 62 | inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 8, void>::type __check_for_overflow(size_t N) { | 61 | } |
| 63 | if (N > 0xFFFFFFFFFFFFFFC5ull) | ||
| 64 | __throw_overflow_error("__next_prime overflow"); | ||
| 65 | } | 62 | } |
| 66 | 63 | ||
| 67 | size_t __next_prime(size_t n) { | 64 | size_t __next_prime(size_t n) { |
lib/libcxx/src/include/overridable_function.h+16-15| ... | @@ -29,14 +29,14 @@ | ... | @@ -29,14 +29,14 @@ |
| 29 | // This is a low-level utility which does not work on all platforms, since it 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 annotated with the _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE macro. | 32 | // overridden) to be defined using the _LIBCPP_OVERRIDABLE_FUNCTION macro. |
| 33 | // | 33 | // |
| 34 | // This currently works with Mach-O files (used on Darwin) and with ELF files (used on 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_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE macro is defined to | 37 | // other platforms. The _LIBCPP_OVERRIDABLE_FUNCTION macro is defined to perform a normal |
| 38 | // nothing on unsupported platforms so that it can be used to decorate functions regardless | 38 | // function definition on unsupported platforms so that it can be used to define functions |
| 39 | // of whether detection is actually supported. | 39 | // regardless of whether detection is actually supported. |
| 40 | // | 40 | // |
| 41 | // How does this work? | 41 | // How does this work? |
| 42 | // ------------------- | 42 | // ------------------- |
| ... | @@ -44,7 +44,7 @@ | ... | @@ -44,7 +44,7 @@ |
| 44 | // Let's say we want to check whether a weak function `f` has been overridden by the user. | 44 | // Let's say we want to check whether a weak function `f` has been overridden by the user. |
| 45 | // The general mechanism works by placing `f`'s definition (in the libc++ built library) | 45 | // The general mechanism works by placing `f`'s definition (in the libc++ built library) |
| 46 | // inside a special section, which we do using the `__section__` attribute via the | 46 | // inside a special section, which we do using the `__section__` attribute via the |
| 47 | // _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE macro. | 47 | // _LIBCPP_OVERRIDABLE_FUNCTION macro. |
| 48 | // | 48 | // |
| 49 | // Then, when comes the time to check whether the function has been overridden, we 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,12 +66,12 @@ | ... | @@ -66,12 +66,12 @@ |
| 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_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE \ | 69 | # define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) \ |
| 70 | __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions"))) | 70 | __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions"))) _LIBCPP_WEAK type name arglist |
| 71 | 71 | ||
| 72 | _LIBCPP_BEGIN_NAMESPACE_STD | 72 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 73 | template <class _Ret, class... _Args> | 73 | template <typename T, T* _Func> |
| 74 | _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) noexcept { | 74 | _LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept { |
| 75 | // Declare two dummy bytes and give them these special `__asm` values. These values are | 75 | // 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 | 76 | // defined by the linker, which means that referring to `&__lcxx_override_start` will |
| 77 | // effectively refer to the address where the section starts (and same for the end). | 77 | // effectively refer to the address where the section starts (and same for the end). |
| ... | @@ -81,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no | ... | @@ -81,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no |
| 81 | // Now get a uintptr_t out of these locations, and out of the function pointer. | 81 | // Now get a uintptr_t out of these locations, and out of the function pointer. |
| 82 | uintptr_t __start = reinterpret_cast<uintptr_t>(&__lcxx_override_start); | 82 | uintptr_t __start = reinterpret_cast<uintptr_t>(&__lcxx_override_start); |
| 83 | uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end); | 83 | uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end); |
| 84 | uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr); | 84 | uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func); |
| 85 | 85 | ||
| 86 | # if __has_feature(ptrauth_calls) | 86 | # if __has_feature(ptrauth_calls) |
| 87 | // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular, | 87 | // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular, |
| ... | @@ -100,7 +100,8 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -100,7 +100,8 @@ _LIBCPP_END_NAMESPACE_STD |
| 100 | #elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__) | 100 | #elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__) |
| 101 | 101 | ||
| 102 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 | 102 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 |
| 103 | # define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE __attribute__((__section__("__lcxx_override"))) | 103 | # define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) \ |
| 104 | __attribute__((__section__("__lcxx_override"))) _LIBCPP_WEAK type name arglist | ||
| 104 | 105 | ||
| 105 | // This is very similar to what we do for Mach-O above. The ELF linker will implicitly define | 106 | // This is very similar to what we do for Mach-O above. The ELF linker will implicitly define |
| 106 | // variables with those names corresponding to the start and the end of the section. | 107 | // variables with those names corresponding to the start and the end of the section. |
| ... | @@ -110,11 +111,11 @@ extern char __start___lcxx_override; | ... | @@ -110,11 +111,11 @@ extern char __start___lcxx_override; |
| 110 | extern char __stop___lcxx_override; | 111 | extern char __stop___lcxx_override; |
| 111 | 112 | ||
| 112 | _LIBCPP_BEGIN_NAMESPACE_STD | 113 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 113 | template <class _Ret, class... _Args> | 114 | template <typename T, T* _Func> |
| 114 | _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) noexcept { | 115 | _LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept { |
| 115 | uintptr_t __start = reinterpret_cast<uintptr_t>(&__start___lcxx_override); | 116 | uintptr_t __start = reinterpret_cast<uintptr_t>(&__start___lcxx_override); |
| 116 | uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override); | 117 | uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override); |
| 117 | uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr); | 118 | uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func); |
| 118 | 119 | ||
| 119 | # if __has_feature(ptrauth_calls) | 120 | # if __has_feature(ptrauth_calls) |
| 120 | // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above. | 121 | // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above. |
| ... | @@ -128,7 +129,7 @@ _LIBCPP_END_NAMESPACE_STD | ... | @@ -128,7 +129,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 128 | #else | 129 | #else |
| 129 | 130 | ||
| 130 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 0 | 131 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 0 |
| 131 | # define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE /* nothing */ | 132 | # define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) _LIBCPP_WEAK type name arglist |
| 132 | 133 | ||
| 133 | #endif | 134 | #endif |
| 134 | 135 |
lib/libcxx/src/include/ryu/common.h+1| ... | @@ -44,6 +44,7 @@ | ... | @@ -44,6 +44,7 @@ |
| 44 | 44 | ||
| 45 | #include <__assert> | 45 | #include <__assert> |
| 46 | #include <__config> | 46 | #include <__config> |
| 47 | #include <cstdint> | ||
| 47 | #include <cstring> | 48 | #include <cstring> |
| 48 | 49 | ||
| 49 | _LIBCPP_BEGIN_NAMESPACE_STD | 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/src/ios.cpp+5-5| ... | @@ -217,7 +217,7 @@ void ios_base::clear(iostate state) { | ... | @@ -217,7 +217,7 @@ void ios_base::clear(iostate state) { |
| 217 | __rdstate_ = state | badbit; | 217 | __rdstate_ = state | badbit; |
| 218 | 218 | ||
| 219 | if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0) | 219 | if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0) |
| 220 | __throw_failure("ios_base::clear"); | 220 | std::__throw_failure("ios_base::clear"); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | // init | 223 | // init |
| ... | @@ -253,24 +253,24 @@ void ios_base::copyfmt(const ios_base& rhs) { | ... | @@ -253,24 +253,24 @@ void ios_base::copyfmt(const ios_base& rhs) { |
| 253 | size_t newesize = sizeof(event_callback) * rhs.__event_size_; | 253 | size_t newesize = sizeof(event_callback) * rhs.__event_size_; |
| 254 | new_callbacks.reset(static_cast<event_callback*>(malloc(newesize))); | 254 | new_callbacks.reset(static_cast<event_callback*>(malloc(newesize))); |
| 255 | if (!new_callbacks) | 255 | if (!new_callbacks) |
| 256 | __throw_bad_alloc(); | 256 | std::__throw_bad_alloc(); |
| 257 | 257 | ||
| 258 | size_t newisize = sizeof(int) * rhs.__event_size_; | 258 | size_t newisize = sizeof(int) * rhs.__event_size_; |
| 259 | new_ints.reset(static_cast<int*>(malloc(newisize))); | 259 | new_ints.reset(static_cast<int*>(malloc(newisize))); |
| 260 | if (!new_ints) | 260 | if (!new_ints) |
| 261 | __throw_bad_alloc(); | 261 | std::__throw_bad_alloc(); |
| 262 | } | 262 | } |
| 263 | if (__iarray_cap_ < rhs.__iarray_size_) { | 263 | if (__iarray_cap_ < rhs.__iarray_size_) { |
| 264 | size_t newsize = sizeof(long) * rhs.__iarray_size_; | 264 | size_t newsize = sizeof(long) * rhs.__iarray_size_; |
| 265 | new_longs.reset(static_cast<long*>(malloc(newsize))); | 265 | new_longs.reset(static_cast<long*>(malloc(newsize))); |
| 266 | if (!new_longs) | 266 | if (!new_longs) |
| 267 | __throw_bad_alloc(); | 267 | std::__throw_bad_alloc(); |
| 268 | } | 268 | } |
| 269 | if (__parray_cap_ < rhs.__parray_size_) { | 269 | if (__parray_cap_ < rhs.__parray_size_) { |
| 270 | size_t newsize = sizeof(void*) * rhs.__parray_size_; | 270 | size_t newsize = sizeof(void*) * rhs.__parray_size_; |
| 271 | new_pointers.reset(static_cast<void**>(malloc(newsize))); | 271 | new_pointers.reset(static_cast<void**>(malloc(newsize))); |
| 272 | if (!new_pointers) | 272 | if (!new_pointers) |
| 273 | __throw_bad_alloc(); | 273 | std::__throw_bad_alloc(); |
| 274 | } | 274 | } |
| 275 | // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_ | 275 | // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_ |
| 276 | __fmtflags_ = rhs.__fmtflags_; | 276 | __fmtflags_ = rhs.__fmtflags_; |
lib/libcxx/src/iostream.cpp+66-95| ... | @@ -7,90 +7,64 @@ | ... | @@ -7,90 +7,64 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include "std_stream.h" | 9 | #include "std_stream.h" |
| 10 | #include <__locale> | ||
| 11 | #include <new> | ||
| 12 | #include <string> | ||
| 13 | 10 | ||
| 14 | #define _str(s) #s | 11 | #include <__memory/construct_at.h> |
| 15 | #define str(s) _str(s) | 12 | #include <__ostream/basic_ostream.h> |
| 16 | #define _LIBCPP_ABI_NAMESPACE_STR str(_LIBCPP_ABI_NAMESPACE) | 13 | #include <istream> |
| 14 | |||
| 15 | #define ABI_NAMESPACE_STR _LIBCPP_TOSTRING(_LIBCPP_ABI_NAMESPACE) | ||
| 17 | 16 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | 17 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 18 | ||
| 20 | alignas(istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)] | 19 | template <class StreamT, class BufferT> |
| 21 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 20 | union stream_data { |
| 22 | __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | 21 | constexpr stream_data() {} |
| 23 | "@std@@@12@A") | 22 | constexpr ~stream_data() {} |
| 24 | #endif | 23 | struct { |
| 25 | ; | 24 | // The stream has to be the first element, since that's referenced by the stream declarations in <iostream> |
| 26 | alignas(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)]; | 25 | StreamT stream; |
| 27 | static mbstate_t mb_cin; | 26 | BufferT buffer; |
| 27 | mbstate_t mb; | ||
| 28 | }; | ||
| 29 | |||
| 30 | void init(FILE* stdstream) { | ||
| 31 | mb = {}; | ||
| 32 | std::construct_at(&buffer, stdstream, &mb); | ||
| 33 | std::construct_at(&stream, &buffer); | ||
| 34 | } | ||
| 35 | }; | ||
| 28 | 36 | ||
| 29 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 37 | #define CHAR_MANGLING_char "D" |
| 30 | alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)] | 38 | #define CHAR_MANGLING_wchar_t "_W" |
| 31 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 39 | #define CHAR_MANGLING(CharT) CHAR_MANGLING_##CharT |
| 32 | __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | ||
| 33 | "@std@@@12@A") | ||
| 34 | # endif | ||
| 35 | ; | ||
| 36 | alignas(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)]; | ||
| 37 | static mbstate_t mb_wcin; | ||
| 38 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 39 | 40 | ||
| 40 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)] | 41 | #ifdef _LIBCPP_COMPILER_CLANG_BASED |
| 41 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 42 | # define STRING_DATA_CONSTINIT constinit |
| 42 | __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | 43 | #else |
| 43 | "@std@@@12@A") | 44 | # define STRING_DATA_CONSTINIT |
| 44 | #endif | 45 | #endif |
| 45 | ; | ||
| 46 | alignas(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)]; | ||
| 47 | static mbstate_t mb_cout; | ||
| 48 | 46 | ||
| 49 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 47 | #ifdef _LIBCPP_ABI_MICROSOFT |
| 50 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)] | 48 | # define STREAM(StreamT, BufferT, CharT, var) \ |
| 51 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 49 | STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var __asm__( \ |
| 52 | __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | 50 | "?" #var "@" ABI_NAMESPACE_STR "@std@@3V?$" #StreamT \ |
| 53 | "@std@@@12@A") | 51 | "@" CHAR_MANGLING(CharT) "U?$char_traits@" CHAR_MANGLING(CharT) "@" ABI_NAMESPACE_STR "@std@@@12@A") |
| 54 | # endif | 52 | #else |
| 55 | ; | 53 | # define STREAM(StreamT, BufferT, CharT, var) STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var |
| 56 | alignas(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)]; | ||
| 57 | static mbstate_t mb_wcout; | ||
| 58 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 59 | |||
| 60 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)] | ||
| 61 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | ||
| 62 | __asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | ||
| 63 | "@std@@@12@A") | ||
| 64 | #endif | 54 | #endif |
| 65 | ; | ||
| 66 | alignas(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)]; | ||
| 67 | static mbstate_t mb_cerr; | ||
| 68 | |||
| 69 | #if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 70 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)] | ||
| 71 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | ||
| 72 | __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | ||
| 73 | "@std@@@12@A") | ||
| 74 | # endif | ||
| 75 | ; | ||
| 76 | alignas(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)]; | ||
| 77 | static mbstate_t mb_wcerr; | ||
| 78 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 79 | 55 | ||
| 80 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)] | 56 | // These definitions and the declarations in <iostream> technically cause ODR violations, since they have different |
| 81 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 57 | // types (stream_data and {i,o}stream respectively). This means that <iostream> should never be included in this TU. |
| 82 | __asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR | ||
| 83 | "@std@@@12@A") | ||
| 84 | #endif | ||
| 85 | ; | ||
| 86 | 58 | ||
| 59 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, char, cin); | ||
| 60 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cout); | ||
| 61 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cerr); | ||
| 62 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, clog); | ||
| 87 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 63 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 88 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)] | 64 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, wchar_t, wcin); |
| 89 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) | 65 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcout); |
| 90 | __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR | 66 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcerr); |
| 91 | "@std@@@12@A") | 67 | _LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wclog); |
| 92 | # endif | ||
| 93 | ; | ||
| 94 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 68 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| 95 | 69 | ||
| 96 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority | 70 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority |
| ... | @@ -124,37 +98,34 @@ public: | ... | @@ -124,37 +98,34 @@ public: |
| 124 | DoIOSInit::DoIOSInit() { | 98 | DoIOSInit::DoIOSInit() { |
| 125 | force_locale_initialization(); | 99 | force_locale_initialization(); |
| 126 | 100 | ||
| 127 | istream* cin_ptr = ::new (cin) istream(::new (__cin) __stdinbuf<char>(stdin, &mb_cin)); | 101 | cin.init(stdin); |
| 128 | ostream* cout_ptr = ::new (cout) ostream(::new (__cout) __stdoutbuf<char>(stdout, &mb_cout)); | 102 | cout.init(stdout); |
| 129 | ostream* cerr_ptr = ::new (cerr) ostream(::new (__cerr) __stdoutbuf<char>(stderr, &mb_cerr)); | 103 | cerr.init(stderr); |
| 130 | ::new (clog) ostream(cerr_ptr->rdbuf()); | 104 | clog.init(stderr); |
| 131 | cin_ptr->tie(cout_ptr); | 105 | |
| 132 | std::unitbuf(*cerr_ptr); | 106 | cin.stream.tie(&cout.stream); |
| 133 | cerr_ptr->tie(cout_ptr); | 107 | std::unitbuf(cerr.stream); |
| 108 | cerr.stream.tie(&cout.stream); | ||
| 134 | 109 | ||
| 135 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 110 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 136 | wistream* wcin_ptr = ::new (wcin) wistream(::new (__wcin) __stdinbuf<wchar_t>(stdin, &mb_wcin)); | 111 | wcin.init(stdin); |
| 137 | wostream* wcout_ptr = ::new (wcout) wostream(::new (__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout)); | 112 | wcout.init(stdout); |
| 138 | wostream* wcerr_ptr = ::new (wcerr) wostream(::new (__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr)); | 113 | wcerr.init(stderr); |
| 139 | ::new (wclog) wostream(wcerr_ptr->rdbuf()); | 114 | wclog.init(stderr); |
| 140 | 115 | ||
| 141 | wcin_ptr->tie(wcout_ptr); | 116 | wcin.stream.tie(&wcout.stream); |
| 142 | std::unitbuf(*wcerr_ptr); | 117 | std::unitbuf(wcerr.stream); |
| 143 | wcerr_ptr->tie(wcout_ptr); | 118 | wcerr.stream.tie(&wcout.stream); |
| 144 | #endif | 119 | #endif |
| 145 | } | 120 | } |
| 146 | 121 | ||
| 147 | DoIOSInit::~DoIOSInit() { | 122 | DoIOSInit::~DoIOSInit() { |
| 148 | ostream* cout_ptr = reinterpret_cast<ostream*>(cout); | 123 | cout.stream.flush(); |
| 149 | cout_ptr->flush(); | 124 | clog.stream.flush(); |
| 150 | ostream* clog_ptr = reinterpret_cast<ostream*>(clog); | ||
| 151 | clog_ptr->flush(); | ||
| 152 | 125 | ||
| 153 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 126 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 154 | wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout); | 127 | wcout.stream.flush(); |
| 155 | wcout_ptr->flush(); | 128 | wclog.stream.flush(); |
| 156 | wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog); | ||
| 157 | wclog_ptr->flush(); | ||
| 158 | #endif | 129 | #endif |
| 159 | } | 130 | } |
| 160 | 131 |
lib/libcxx/src/locale.cpp+67-146| ... | @@ -34,10 +34,6 @@ | ... | @@ -34,10 +34,6 @@ |
| 34 | # define _CTYPE_DISABLE_MACROS | 34 | # define _CTYPE_DISABLE_MACROS |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #if __has_include("<langinfo.h>") | ||
| 38 | # include <langinfo.h> | ||
| 39 | #endif | ||
| 40 | |||
| 41 | #include "include/atomic_support.h" | 37 | #include "include/atomic_support.h" |
| 42 | #include "include/sso_allocator.h" | 38 | #include "include/sso_allocator.h" |
| 43 | 39 | ||
| ... | @@ -482,7 +478,7 @@ void locale::__imp::install(facet* f, long id) { | ... | @@ -482,7 +478,7 @@ void locale::__imp::install(facet* f, long id) { |
| 482 | 478 | ||
| 483 | const locale::facet* locale::__imp::use_facet(long id) const { | 479 | const locale::facet* locale::__imp::use_facet(long id) const { |
| 484 | if (!has_facet(id)) | 480 | if (!has_facet(id)) |
| 485 | __throw_bad_cast(); | 481 | std::__throw_bad_cast(); |
| 486 | return facets_[static_cast<size_t>(id)]; | 482 | return facets_[static_cast<size_t>(id)]; |
| 487 | } | 483 | } |
| 488 | 484 | ||
| ... | @@ -602,7 +598,7 @@ long locale::id::__get() { | ... | @@ -602,7 +598,7 @@ long locale::id::__get() { |
| 602 | collate_byname<char>::collate_byname(const char* n, size_t refs) | 598 | collate_byname<char>::collate_byname(const char* n, size_t refs) |
| 603 | : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) { | 599 | : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) { |
| 604 | if (__l_ == 0) | 600 | if (__l_ == 0) |
| 605 | __throw_runtime_error( | 601 | std::__throw_runtime_error( |
| 606 | ("collate_byname<char>::collate_byname" | 602 | ("collate_byname<char>::collate_byname" |
| 607 | " failed to construct for " + | 603 | " failed to construct for " + |
| 608 | string(n)) | 604 | string(n)) |
| ... | @@ -612,7 +608,7 @@ collate_byname<char>::collate_byname(const char* n, size_t refs) | ... | @@ -612,7 +608,7 @@ collate_byname<char>::collate_byname(const char* n, size_t refs) |
| 612 | collate_byname<char>::collate_byname(const string& name, size_t refs) | 608 | collate_byname<char>::collate_byname(const string& name, size_t refs) |
| 613 | : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | 609 | : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { |
| 614 | if (__l_ == 0) | 610 | if (__l_ == 0) |
| 615 | __throw_runtime_error( | 611 | std::__throw_runtime_error( |
| 616 | ("collate_byname<char>::collate_byname" | 612 | ("collate_byname<char>::collate_byname" |
| 617 | " failed to construct for " + | 613 | " failed to construct for " + |
| 618 | name) | 614 | name) |
| ... | @@ -646,7 +642,7 @@ collate_byname<char>::string_type collate_byname<char>::do_transform(const char_ | ... | @@ -646,7 +642,7 @@ collate_byname<char>::string_type collate_byname<char>::do_transform(const char_ |
| 646 | collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) | 642 | collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) |
| 647 | : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) { | 643 | : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) { |
| 648 | if (__l_ == 0) | 644 | if (__l_ == 0) |
| 649 | __throw_runtime_error( | 645 | std::__throw_runtime_error( |
| 650 | ("collate_byname<wchar_t>::collate_byname(size_t refs)" | 646 | ("collate_byname<wchar_t>::collate_byname(size_t refs)" |
| 651 | " failed to construct for " + | 647 | " failed to construct for " + |
| 652 | string(n)) | 648 | string(n)) |
| ... | @@ -656,7 +652,7 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) | ... | @@ -656,7 +652,7 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) |
| 656 | collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) | 652 | collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) |
| 657 | : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | 653 | : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { |
| 658 | if (__l_ == 0) | 654 | if (__l_ == 0) |
| 659 | __throw_runtime_error( | 655 | std::__throw_runtime_error( |
| 660 | ("collate_byname<wchar_t>::collate_byname(size_t refs)" | 656 | ("collate_byname<wchar_t>::collate_byname(size_t refs)" |
| 661 | " failed to construct for " + | 657 | " failed to construct for " + |
| 662 | name) | 658 | name) |
| ... | @@ -701,6 +697,20 @@ const ctype_base::mask ctype_base::graph; | ... | @@ -701,6 +697,20 @@ const ctype_base::mask ctype_base::graph; |
| 701 | 697 | ||
| 702 | // template <> class ctype<wchar_t>; | 698 | // template <> class ctype<wchar_t>; |
| 703 | 699 | ||
| 700 | template <class CharT> | ||
| 701 | static CharT to_upper_impl(CharT c) { | ||
| 702 | if (c < 'a' || c > 'z') | ||
| 703 | return c; | ||
| 704 | return c & ~0x20; | ||
| 705 | } | ||
| 706 | |||
| 707 | template <class CharT> | ||
| 708 | static CharT to_lower_impl(CharT c) { | ||
| 709 | if (c < 'A' || c > 'Z') | ||
| 710 | return c; | ||
| 711 | return c | 0x20; | ||
| 712 | } | ||
| 713 | |||
| 704 | #if _LIBCPP_HAS_WIDE_CHARACTERS | 714 | #if _LIBCPP_HAS_WIDE_CHARACTERS |
| 705 | constinit locale::id ctype<wchar_t>::id; | 715 | constinit locale::id ctype<wchar_t>::id; |
| 706 | 716 | ||
| ... | @@ -730,48 +740,19 @@ const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const c | ... | @@ -730,48 +740,19 @@ const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const c |
| 730 | return low; | 740 | return low; |
| 731 | } | 741 | } |
| 732 | 742 | ||
| 733 | wchar_t ctype<wchar_t>::do_toupper(char_type c) const { | 743 | wchar_t ctype<wchar_t>::do_toupper(char_type c) const { return to_upper_impl(c); } |
| 734 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | ||
| 735 | return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c; | ||
| 736 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) | ||
| 737 | return std::__libcpp_isascii(c) ? ctype<char>::__classic_upper_table()[c] : c; | ||
| 738 | # else | ||
| 739 | return (std::__libcpp_isascii(c) && __locale::__iswlower(c, _LIBCPP_GET_C_LOCALE)) ? c - L'a' + L'A' : c; | ||
| 740 | # endif | ||
| 741 | } | ||
| 742 | 744 | ||
| 743 | const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const { | 745 | const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const { |
| 744 | for (; low != high; ++low) | 746 | for (; low != high; ++low) |
| 745 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | 747 | *low = to_upper_impl(*low); |
| 746 | *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low; | ||
| 747 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) | ||
| 748 | *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_upper_table()[*low] : *low; | ||
| 749 | # else | ||
| 750 | *low = | ||
| 751 | (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? (*low - L'a' + L'A') : *low; | ||
| 752 | # endif | ||
| 753 | return low; | 748 | return low; |
| 754 | } | 749 | } |
| 755 | 750 | ||
| 756 | wchar_t ctype<wchar_t>::do_tolower(char_type c) const { | 751 | wchar_t ctype<wchar_t>::do_tolower(char_type c) const { return to_lower_impl(c); } |
| 757 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | ||
| 758 | return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__maplower[c] : c; | ||
| 759 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) | ||
| 760 | return std::__libcpp_isascii(c) ? ctype<char>::__classic_lower_table()[c] : c; | ||
| 761 | # else | ||
| 762 | return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - L'A' + 'a' : c; | ||
| 763 | # endif | ||
| 764 | } | ||
| 765 | 752 | ||
| 766 | const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const { | 753 | const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const { |
| 767 | for (; low != high; ++low) | 754 | for (; low != high; ++low) |
| 768 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | 755 | *low = to_lower_impl(*low); |
| 769 | *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low; | ||
| 770 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) | ||
| 771 | *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_lower_table()[*low] : *low; | ||
| 772 | # else | ||
| 773 | *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - L'A' + L'a' : *low; | ||
| 774 | # endif | ||
| 775 | return low; | 756 | return low; |
| 776 | } | 757 | } |
| 777 | 758 | ||
| ... | @@ -815,59 +796,19 @@ ctype<char>::~ctype() { | ... | @@ -815,59 +796,19 @@ ctype<char>::~ctype() { |
| 815 | delete[] __tab_; | 796 | delete[] __tab_; |
| 816 | } | 797 | } |
| 817 | 798 | ||
| 818 | char ctype<char>::do_toupper(char_type c) const { | 799 | char ctype<char>::do_toupper(char_type c) const { return to_upper_impl(c); } |
| 819 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | ||
| 820 | return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c; | ||
| 821 | #elif defined(__NetBSD__) | ||
| 822 | return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]); | ||
| 823 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | ||
| 824 | return std::__libcpp_isascii(c) ? static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c; | ||
| 825 | #else | ||
| 826 | return (std::__libcpp_isascii(c) && __locale::__islower(c, _LIBCPP_GET_C_LOCALE)) ? c - 'a' + 'A' : c; | ||
| 827 | #endif | ||
| 828 | } | ||
| 829 | 800 | ||
| 830 | const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const { | 801 | const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const { |
| 831 | for (; low != high; ++low) | 802 | for (; low != high; ++low) |
| 832 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | 803 | *low = to_upper_impl(*low); |
| 833 | *low = std::__libcpp_isascii(*low) | ||
| 834 | ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) | ||
| 835 | : *low; | ||
| 836 | #elif defined(__NetBSD__) | ||
| 837 | *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]); | ||
| 838 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | ||
| 839 | *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low; | ||
| 840 | #else | ||
| 841 | *low = (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'a' + 'A' : *low; | ||
| 842 | #endif | ||
| 843 | return low; | 804 | return low; |
| 844 | } | 805 | } |
| 845 | 806 | ||
| 846 | char ctype<char>::do_tolower(char_type c) const { | 807 | char ctype<char>::do_tolower(char_type c) const { return to_lower_impl(c); } |
| 847 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | ||
| 848 | return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c; | ||
| 849 | #elif defined(__NetBSD__) | ||
| 850 | return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]); | ||
| 851 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | ||
| 852 | return std::__libcpp_isascii(c) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c; | ||
| 853 | #else | ||
| 854 | return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - 'A' + 'a' : c; | ||
| 855 | #endif | ||
| 856 | } | ||
| 857 | 808 | ||
| 858 | const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const { | 809 | const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const { |
| 859 | for (; low != high; ++low) | 810 | for (; low != high; ++low) |
| 860 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE | 811 | *low = to_lower_impl(*low); |
| 861 | *low = std::__libcpp_isascii(*low) | ||
| 862 | ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) | ||
| 863 | : *low; | ||
| 864 | #elif defined(__NetBSD__) | ||
| 865 | *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]); | ||
| 866 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | ||
| 867 | *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low; | ||
| 868 | #else | ||
| 869 | *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'A' + 'a' : *low; | ||
| 870 | #endif | ||
| 871 | return low; | 812 | return low; |
| 872 | } | 813 | } |
| 873 | 814 | ||
| ... | @@ -1014,42 +955,12 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept { | ... | @@ -1014,42 +955,12 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept { |
| 1014 | } | 955 | } |
| 1015 | #endif | 956 | #endif |
| 1016 | 957 | ||
| 1017 | #if defined(__GLIBC__) | ||
| 1018 | const int* ctype<char>::__classic_lower_table() noexcept { return _LIBCPP_GET_C_LOCALE->__ctype_tolower; } | ||
| 1019 | |||
| 1020 | const int* ctype<char>::__classic_upper_table() noexcept { return _LIBCPP_GET_C_LOCALE->__ctype_toupper; } | ||
| 1021 | #elif defined(__NetBSD__) | ||
| 1022 | const short* ctype<char>::__classic_lower_table() noexcept { return _C_tolower_tab_ + 1; } | ||
| 1023 | |||
| 1024 | const short* ctype<char>::__classic_upper_table() noexcept { return _C_toupper_tab_ + 1; } | ||
| 1025 | |||
| 1026 | #elif defined(__EMSCRIPTEN__) | ||
| 1027 | const int* ctype<char>::__classic_lower_table() noexcept { return *__ctype_tolower_loc(); } | ||
| 1028 | |||
| 1029 | const int* ctype<char>::__classic_upper_table() noexcept { return *__ctype_toupper_loc(); } | ||
| 1030 | #elif defined(__MVS__) | ||
| 1031 | const unsigned short* ctype<char>::__classic_lower_table() _NOEXCEPT { | ||
| 1032 | # if defined(__NATIVE_ASCII_F) | ||
| 1033 | return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->lower); | ||
| 1034 | # else | ||
| 1035 | return const_cast<const unsigned short*>(__ctype + __TOLOWER_INDEX); | ||
| 1036 | # endif | ||
| 1037 | } | ||
| 1038 | const unsigned short* ctype<char>::__classic_upper_table() _NOEXCEPT { | ||
| 1039 | # if defined(__NATIVE_ASCII_F) | ||
| 1040 | return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->upper); | ||
| 1041 | # else | ||
| 1042 | return const_cast<const unsigned short*>(__ctype + __TOUPPER_INDEX); | ||
| 1043 | # endif | ||
| 1044 | } | ||
| 1045 | #endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ || __MVS__ | ||
| 1046 | |||
| 1047 | // template <> class ctype_byname<char> | 958 | // template <> class ctype_byname<char> |
| 1048 | 959 | ||
| 1049 | ctype_byname<char>::ctype_byname(const char* name, size_t refs) | 960 | ctype_byname<char>::ctype_byname(const char* name, size_t refs) |
| 1050 | : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) { | 961 | : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) { |
| 1051 | if (__l_ == 0) | 962 | if (__l_ == 0) |
| 1052 | __throw_runtime_error( | 963 | std::__throw_runtime_error( |
| 1053 | ("ctype_byname<char>::ctype_byname" | 964 | ("ctype_byname<char>::ctype_byname" |
| 1054 | " failed to construct for " + | 965 | " failed to construct for " + |
| 1055 | string(name)) | 966 | string(name)) |
| ... | @@ -1059,7 +970,7 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs) | ... | @@ -1059,7 +970,7 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs) |
| 1059 | ctype_byname<char>::ctype_byname(const string& name, size_t refs) | 970 | ctype_byname<char>::ctype_byname(const string& name, size_t refs) |
| 1060 | : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | 971 | : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { |
| 1061 | if (__l_ == 0) | 972 | if (__l_ == 0) |
| 1062 | __throw_runtime_error( | 973 | std::__throw_runtime_error( |
| 1063 | ("ctype_byname<char>::ctype_byname" | 974 | ("ctype_byname<char>::ctype_byname" |
| 1064 | " failed to construct for " + | 975 | " failed to construct for " + |
| 1065 | name) | 976 | name) |
| ... | @@ -1094,7 +1005,7 @@ const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high | ... | @@ -1094,7 +1005,7 @@ const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high |
| 1094 | ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) | 1005 | ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) |
| 1095 | : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) { | 1006 | : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) { |
| 1096 | if (__l_ == 0) | 1007 | if (__l_ == 0) |
| 1097 | __throw_runtime_error( | 1008 | std::__throw_runtime_error( |
| 1098 | ("ctype_byname<wchar_t>::ctype_byname" | 1009 | ("ctype_byname<wchar_t>::ctype_byname" |
| 1099 | " failed to construct for " + | 1010 | " failed to construct for " + |
| 1100 | string(name)) | 1011 | string(name)) |
| ... | @@ -1104,7 +1015,7 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) | ... | @@ -1104,7 +1015,7 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) |
| 1104 | ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) | 1015 | ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) |
| 1105 | : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | 1016 | : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { |
| 1106 | if (__l_ == 0) | 1017 | if (__l_ == 0) |
| 1107 | __throw_runtime_error( | 1018 | std::__throw_runtime_error( |
| 1108 | ("ctype_byname<wchar_t>::ctype_byname" | 1019 | ("ctype_byname<wchar_t>::ctype_byname" |
| 1109 | " failed to construct for " + | 1020 | " failed to construct for " + |
| 1110 | name) | 1021 | name) |
| ... | @@ -1344,7 +1255,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), _ | ... | @@ -1344,7 +1255,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), _ |
| 1344 | codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) | 1255 | codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) |
| 1345 | : locale::facet(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { | 1256 | : locale::facet(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { |
| 1346 | if (__l_ == 0) | 1257 | if (__l_ == 0) |
| 1347 | __throw_runtime_error( | 1258 | std::__throw_runtime_error( |
| 1348 | ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" | 1259 | ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" |
| 1349 | " failed to construct for " + | 1260 | " failed to construct for " + |
| 1350 | string(nm)) | 1261 | string(nm)) |
| ... | @@ -3957,7 +3868,7 @@ static bool is_narrow_non_breaking_space(const char* ptr) { | ... | @@ -3957,7 +3868,7 @@ static bool is_narrow_non_breaking_space(const char* ptr) { |
| 3957 | } | 3868 | } |
| 3958 | 3869 | ||
| 3959 | static bool is_non_breaking_space(const char* ptr) { | 3870 | static bool is_non_breaking_space(const char* ptr) { |
| 3960 | // https://www.fileformat.info/info/unicode/char/0a/index.htm | 3871 | // https://www.fileformat.info/info/unicode/char/a0/index.htm |
| 3961 | return ptr[0] == '\xc2' && ptr[1] == '\xa0'; | 3872 | return ptr[0] == '\xc2' && ptr[1] == '\xa0'; |
| 3962 | } | 3873 | } |
| 3963 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 3874 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| ... | @@ -4061,7 +3972,7 @@ void numpunct_byname<char>::__init(const char* nm) { | ... | @@ -4061,7 +3972,7 @@ void numpunct_byname<char>::__init(const char* nm) { |
| 4061 | if (strcmp(nm, "C") != 0) { | 3972 | if (strcmp(nm, "C") != 0) { |
| 4062 | __libcpp_unique_locale loc(nm); | 3973 | __libcpp_unique_locale loc(nm); |
| 4063 | if (!loc) | 3974 | if (!loc) |
| 4064 | __throw_runtime_error( | 3975 | std::__throw_runtime_error( |
| 4065 | ("numpunct_byname<char>::numpunct_byname" | 3976 | ("numpunct_byname<char>::numpunct_byname" |
| 4066 | " failed to construct for " + | 3977 | " failed to construct for " + |
| 4067 | string(nm)) | 3978 | string(nm)) |
| ... | @@ -4092,7 +4003,7 @@ void numpunct_byname<wchar_t>::__init(const char* nm) { | ... | @@ -4092,7 +4003,7 @@ void numpunct_byname<wchar_t>::__init(const char* nm) { |
| 4092 | if (strcmp(nm, "C") != 0) { | 4003 | if (strcmp(nm, "C") != 0) { |
| 4093 | __libcpp_unique_locale loc(nm); | 4004 | __libcpp_unique_locale loc(nm); |
| 4094 | if (!loc) | 4005 | if (!loc) |
| 4095 | __throw_runtime_error( | 4006 | std::__throw_runtime_error( |
| 4096 | ("numpunct_byname<wchar_t>::numpunct_byname" | 4007 | ("numpunct_byname<wchar_t>::numpunct_byname" |
| 4097 | " failed to construct for " + | 4008 | " failed to construct for " + |
| 4098 | string(nm)) | 4009 | string(nm)) |
| ... | @@ -4444,12 +4355,12 @@ const wstring& __time_get_c_storage<wchar_t>::__r() const { | ... | @@ -4444,12 +4355,12 @@ const wstring& __time_get_c_storage<wchar_t>::__r() const { |
| 4444 | 4355 | ||
| 4445 | __time_get::__time_get(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { | 4356 | __time_get::__time_get(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { |
| 4446 | if (__loc_ == 0) | 4357 | if (__loc_ == 0) |
| 4447 | __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str()); | 4358 | std::__throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str()); |
| 4448 | } | 4359 | } |
| 4449 | 4360 | ||
| 4450 | __time_get::__time_get(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) { | 4361 | __time_get::__time_get(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) { |
| 4451 | if (__loc_ == 0) | 4362 | if (__loc_ == 0) |
| 4452 | __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str()); | 4363 | std::__throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str()); |
| 4453 | } | 4364 | } |
| 4454 | 4365 | ||
| 4455 | __time_get::~__time_get() { __locale::__freelocale(__loc_); } | 4366 | __time_get::~__time_get() { __locale::__freelocale(__loc_); } |
| ... | @@ -4610,7 +4521,7 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c | ... | @@ -4610,7 +4521,7 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c |
| 4610 | const char* bb = buf; | 4521 | const char* bb = buf; |
| 4611 | size_t j = __locale::__mbsrtowcs(wbb, &bb, countof(wbuf), &mb, __loc_); | 4522 | size_t j = __locale::__mbsrtowcs(wbb, &bb, countof(wbuf), &mb, __loc_); |
| 4612 | if (j == size_t(-1)) | 4523 | if (j == size_t(-1)) |
| 4613 | __throw_runtime_error("locale not supported"); | 4524 | std::__throw_runtime_error("locale not supported"); |
| 4614 | wchar_t* wbe = wbb + j; | 4525 | wchar_t* wbe = wbb + j; |
| 4615 | wstring result; | 4526 | wstring result; |
| 4616 | while (wbb != wbe) { | 4527 | while (wbb != wbe) { |
| ... | @@ -4771,7 +4682,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4771,7 +4682,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4771 | const char* bb = buf; | 4682 | const char* bb = buf; |
| 4772 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4683 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); |
| 4773 | if (j == size_t(-1) || j == 0) | 4684 | if (j == size_t(-1) || j == 0) |
| 4774 | __throw_runtime_error("locale not supported"); | 4685 | std::__throw_runtime_error("locale not supported"); |
| 4775 | wbe = wbuf + j; | 4686 | wbe = wbuf + j; |
| 4776 | __weeks_[i].assign(wbuf, wbe); | 4687 | __weeks_[i].assign(wbuf, wbe); |
| 4777 | __locale::__strftime(buf, countof(buf), "%a", &t, __loc_); | 4688 | __locale::__strftime(buf, countof(buf), "%a", &t, __loc_); |
| ... | @@ -4779,7 +4690,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4779,7 +4690,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4779 | bb = buf; | 4690 | bb = buf; |
| 4780 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4691 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); |
| 4781 | if (j == size_t(-1) || j == 0) | 4692 | if (j == size_t(-1) || j == 0) |
| 4782 | __throw_runtime_error("locale not supported"); | 4693 | std::__throw_runtime_error("locale not supported"); |
| 4783 | wbe = wbuf + j; | 4694 | wbe = wbuf + j; |
| 4784 | __weeks_[i + 7].assign(wbuf, wbe); | 4695 | __weeks_[i + 7].assign(wbuf, wbe); |
| 4785 | } | 4696 | } |
| ... | @@ -4791,7 +4702,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4791,7 +4702,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4791 | const char* bb = buf; | 4702 | const char* bb = buf; |
| 4792 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4703 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); |
| 4793 | if (j == size_t(-1) || j == 0) | 4704 | if (j == size_t(-1) || j == 0) |
| 4794 | __throw_runtime_error("locale not supported"); | 4705 | std::__throw_runtime_error("locale not supported"); |
| 4795 | wbe = wbuf + j; | 4706 | wbe = wbuf + j; |
| 4796 | __months_[i].assign(wbuf, wbe); | 4707 | __months_[i].assign(wbuf, wbe); |
| 4797 | __locale::__strftime(buf, countof(buf), "%b", &t, __loc_); | 4708 | __locale::__strftime(buf, countof(buf), "%b", &t, __loc_); |
| ... | @@ -4799,7 +4710,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4799,7 +4710,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4799 | bb = buf; | 4710 | bb = buf; |
| 4800 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4711 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); |
| 4801 | if (j == size_t(-1) || j == 0) | 4712 | if (j == size_t(-1) || j == 0) |
| 4802 | __throw_runtime_error("locale not supported"); | 4713 | std::__throw_runtime_error("locale not supported"); |
| 4803 | wbe = wbuf + j; | 4714 | wbe = wbuf + j; |
| 4804 | __months_[i + 12].assign(wbuf, wbe); | 4715 | __months_[i + 12].assign(wbuf, wbe); |
| 4805 | } | 4716 | } |
| ... | @@ -4810,7 +4721,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4810,7 +4721,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4810 | const char* bb = buf; | 4721 | const char* bb = buf; |
| 4811 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4722 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); |
| 4812 | if (j == size_t(-1)) | 4723 | if (j == size_t(-1)) |
| 4813 | __throw_runtime_error("locale not supported"); | 4724 | std::__throw_runtime_error("locale not supported"); |
| 4814 | wbe = wbuf + j; | 4725 | wbe = wbuf + j; |
| 4815 | __am_pm_[0].assign(wbuf, wbe); | 4726 | __am_pm_[0].assign(wbuf, wbe); |
| 4816 | t.tm_hour = 13; | 4727 | t.tm_hour = 13; |
| ... | @@ -4819,7 +4730,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { | ... | @@ -4819,7 +4730,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4819 | bb = buf; | 4730 | bb = buf; |
| 4820 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | 4731 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); |
| 4821 | if (j == size_t(-1)) | 4732 | if (j == size_t(-1)) |
| 4822 | __throw_runtime_error("locale not supported"); | 4733 | std::__throw_runtime_error("locale not supported"); |
| 4823 | wbe = wbuf + j; | 4734 | wbe = wbuf + j; |
| 4824 | __am_pm_[1].assign(wbuf, wbe); | 4735 | __am_pm_[1].assign(wbuf, wbe); |
| 4825 | __c_ = __analyze('c', ct); | 4736 | __c_ = __analyze('c', ct); |
| ... | @@ -5029,12 +4940,12 @@ time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const { | ... | @@ -5029,12 +4940,12 @@ time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const { |
| 5029 | 4940 | ||
| 5030 | __time_put::__time_put(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { | 4941 | __time_put::__time_put(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { |
| 5031 | if (__loc_ == 0) | 4942 | if (__loc_ == 0) |
| 5032 | __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str()); | 4943 | std::__throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str()); |
| 5033 | } | 4944 | } |
| 5034 | 4945 | ||
| 5035 | __time_put::__time_put(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) { | 4946 | __time_put::__time_put(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) { |
| 5036 | if (__loc_ == 0) | 4947 | if (__loc_ == 0) |
| 5037 | __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str()); | 4948 | std::__throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str()); |
| 5038 | } | 4949 | } |
| 5039 | 4950 | ||
| 5040 | __time_put::~__time_put() { | 4951 | __time_put::~__time_put() { |
| ... | @@ -5059,7 +4970,7 @@ void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __ | ... | @@ -5059,7 +4970,7 @@ void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __ |
| 5059 | const char* __nb = __nar; | 4970 | const char* __nb = __nar; |
| 5060 | size_t j = __locale::__mbsrtowcs(__wb, &__nb, countof(__wb, __we), &mb, __loc_); | 4971 | size_t j = __locale::__mbsrtowcs(__wb, &__nb, countof(__wb, __we), &mb, __loc_); |
| 5061 | if (j == size_t(-1)) | 4972 | if (j == size_t(-1)) |
| 5062 | __throw_runtime_error("locale not supported"); | 4973 | std::__throw_runtime_error("locale not supported"); |
| 5063 | __we = __wb + j; | 4974 | __we = __wb + j; |
| 5064 | } | 4975 | } |
| 5065 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | 4976 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS |
| ... | @@ -5431,7 +5342,7 @@ void moneypunct_byname<char, false>::init(const char* nm) { | ... | @@ -5431,7 +5342,7 @@ void moneypunct_byname<char, false>::init(const char* nm) { |
| 5431 | typedef moneypunct<char, false> base; | 5342 | typedef moneypunct<char, false> base; |
| 5432 | __libcpp_unique_locale loc(nm); | 5343 | __libcpp_unique_locale loc(nm); |
| 5433 | if (!loc) | 5344 | if (!loc) |
| 5434 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); | 5345 | std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5435 | 5346 | ||
| 5436 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | 5347 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); |
| 5437 | if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) | 5348 | if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| ... | @@ -5466,7 +5377,7 @@ void moneypunct_byname<char, true>::init(const char* nm) { | ... | @@ -5466,7 +5377,7 @@ void moneypunct_byname<char, true>::init(const char* nm) { |
| 5466 | typedef moneypunct<char, true> base; | 5377 | typedef moneypunct<char, true> base; |
| 5467 | __libcpp_unique_locale loc(nm); | 5378 | __libcpp_unique_locale loc(nm); |
| 5468 | if (!loc) | 5379 | if (!loc) |
| 5469 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); | 5380 | std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5470 | 5381 | ||
| 5471 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | 5382 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); |
| 5472 | if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) | 5383 | if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| ... | @@ -5522,7 +5433,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { | ... | @@ -5522,7 +5433,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5522 | typedef moneypunct<wchar_t, false> base; | 5433 | typedef moneypunct<wchar_t, false> base; |
| 5523 | __libcpp_unique_locale loc(nm); | 5434 | __libcpp_unique_locale loc(nm); |
| 5524 | if (!loc) | 5435 | if (!loc) |
| 5525 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); | 5436 | std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5526 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | 5437 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); |
| 5527 | if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) | 5438 | if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| 5528 | __decimal_point_ = base::do_decimal_point(); | 5439 | __decimal_point_ = base::do_decimal_point(); |
| ... | @@ -5534,7 +5445,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { | ... | @@ -5534,7 +5445,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5534 | const char* bb = lc->currency_symbol; | 5445 | const char* bb = lc->currency_symbol; |
| 5535 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5446 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); |
| 5536 | if (j == size_t(-1)) | 5447 | if (j == size_t(-1)) |
| 5537 | __throw_runtime_error("locale not supported"); | 5448 | std::__throw_runtime_error("locale not supported"); |
| 5538 | wchar_t* wbe = wbuf + j; | 5449 | wchar_t* wbe = wbuf + j; |
| 5539 | __curr_symbol_.assign(wbuf, wbe); | 5450 | __curr_symbol_.assign(wbuf, wbe); |
| 5540 | if (lc->frac_digits != CHAR_MAX) | 5451 | if (lc->frac_digits != CHAR_MAX) |
| ... | @@ -5548,7 +5459,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { | ... | @@ -5548,7 +5459,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5548 | bb = lc->positive_sign; | 5459 | bb = lc->positive_sign; |
| 5549 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5460 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); |
| 5550 | if (j == size_t(-1)) | 5461 | if (j == size_t(-1)) |
| 5551 | __throw_runtime_error("locale not supported"); | 5462 | std::__throw_runtime_error("locale not supported"); |
| 5552 | wbe = wbuf + j; | 5463 | wbe = wbuf + j; |
| 5553 | __positive_sign_.assign(wbuf, wbe); | 5464 | __positive_sign_.assign(wbuf, wbe); |
| 5554 | } | 5465 | } |
| ... | @@ -5559,7 +5470,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { | ... | @@ -5559,7 +5470,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5559 | bb = lc->negative_sign; | 5470 | bb = lc->negative_sign; |
| 5560 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5471 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); |
| 5561 | if (j == size_t(-1)) | 5472 | if (j == size_t(-1)) |
| 5562 | __throw_runtime_error("locale not supported"); | 5473 | std::__throw_runtime_error("locale not supported"); |
| 5563 | wbe = wbuf + j; | 5474 | wbe = wbuf + j; |
| 5564 | __negative_sign_.assign(wbuf, wbe); | 5475 | __negative_sign_.assign(wbuf, wbe); |
| 5565 | } | 5476 | } |
| ... | @@ -5576,7 +5487,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5576,7 +5487,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5576 | typedef moneypunct<wchar_t, true> base; | 5487 | typedef moneypunct<wchar_t, true> base; |
| 5577 | __libcpp_unique_locale loc(nm); | 5488 | __libcpp_unique_locale loc(nm); |
| 5578 | if (!loc) | 5489 | if (!loc) |
| 5579 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); | 5490 | std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5580 | 5491 | ||
| 5581 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | 5492 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); |
| 5582 | if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) | 5493 | if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| ... | @@ -5589,7 +5500,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5589,7 +5500,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5589 | const char* bb = lc->int_curr_symbol; | 5500 | const char* bb = lc->int_curr_symbol; |
| 5590 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5501 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); |
| 5591 | if (j == size_t(-1)) | 5502 | if (j == size_t(-1)) |
| 5592 | __throw_runtime_error("locale not supported"); | 5503 | std::__throw_runtime_error("locale not supported"); |
| 5593 | wchar_t* wbe = wbuf + j; | 5504 | wchar_t* wbe = wbuf + j; |
| 5594 | __curr_symbol_.assign(wbuf, wbe); | 5505 | __curr_symbol_.assign(wbuf, wbe); |
| 5595 | if (lc->int_frac_digits != CHAR_MAX) | 5506 | if (lc->int_frac_digits != CHAR_MAX) |
| ... | @@ -5607,7 +5518,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5607,7 +5518,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5607 | bb = lc->positive_sign; | 5518 | bb = lc->positive_sign; |
| 5608 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5519 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); |
| 5609 | if (j == size_t(-1)) | 5520 | if (j == size_t(-1)) |
| 5610 | __throw_runtime_error("locale not supported"); | 5521 | std::__throw_runtime_error("locale not supported"); |
| 5611 | wbe = wbuf + j; | 5522 | wbe = wbuf + j; |
| 5612 | __positive_sign_.assign(wbuf, wbe); | 5523 | __positive_sign_.assign(wbuf, wbe); |
| 5613 | } | 5524 | } |
| ... | @@ -5622,7 +5533,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5622,7 +5533,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5622 | bb = lc->negative_sign; | 5533 | bb = lc->negative_sign; |
| 5623 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | 5534 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); |
| 5624 | if (j == size_t(-1)) | 5535 | if (j == size_t(-1)) |
| 5625 | __throw_runtime_error("locale not supported"); | 5536 | std::__throw_runtime_error("locale not supported"); |
| 5626 | wbe = wbuf + j; | 5537 | wbe = wbuf + j; |
| 5627 | __negative_sign_.assign(wbuf, wbe); | 5538 | __negative_sign_.assign(wbuf, wbe); |
| 5628 | } | 5539 | } |
| ... | @@ -5650,6 +5561,16 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { | ... | @@ -5650,6 +5561,16 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5650 | 5561 | ||
| 5651 | void __do_nothing(void*) {} | 5562 | void __do_nothing(void*) {} |
| 5652 | 5563 | ||
| 5564 | // Legacy ABI __num_get functions - the new ones are _LIBCPP_HIDE_FROM_ABI | ||
| 5565 | template <class _CharT> | ||
| 5566 | string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { | ||
| 5567 | locale __loc = __iob.getloc(); | ||
| 5568 | std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms); | ||
| 5569 | const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc); | ||
| 5570 | __thousands_sep = __np.thousands_sep(); | ||
| 5571 | return __np.grouping(); | ||
| 5572 | } | ||
| 5573 | |||
| 5653 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>; | 5574 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>; |
| 5654 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;) | 5575 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;) |
| 5655 | 5576 |
lib/libcxx/src/memory.cpp+2| ... | @@ -11,7 +11,9 @@ | ... | @@ -11,7 +11,9 @@ |
| 11 | # define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS | 11 | # define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS |
| 12 | #endif | 12 | #endif |
| 13 | 13 | ||
| 14 | #include <__functional/hash.h> | ||
| 14 | #include <memory> | 15 | #include <memory> |
| 16 | #include <typeinfo> | ||
| 15 | 17 | ||
| 16 | #if _LIBCPP_HAS_THREADS | 18 | #if _LIBCPP_HAS_THREADS |
| 17 | # include <mutex> | 19 | # include <mutex> |
lib/libcxx/src/memory_resource.cpp+4-4| ... | @@ -38,7 +38,7 @@ static bool is_aligned_to(void* ptr, size_t align) { | ... | @@ -38,7 +38,7 @@ static bool is_aligned_to(void* ptr, size_t align) { |
| 38 | } | 38 | } |
| 39 | #endif | 39 | #endif |
| 40 | 40 | ||
| 41 | class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory_resource { | 41 | class _LIBCPP_HIDDEN __new_delete_memory_resource_imp : public memory_resource { |
| 42 | void* do_allocate(size_t bytes, size_t align) override { | 42 | void* do_allocate(size_t bytes, size_t align) override { |
| 43 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION | 43 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION |
| 44 | return std::__libcpp_allocate<std::byte>(__element_count(bytes), align); | 44 | return std::__libcpp_allocate<std::byte>(__element_count(bytes), align); |
| ... | @@ -48,7 +48,7 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory | ... | @@ -48,7 +48,7 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory |
| 48 | std::byte* result = std::__libcpp_allocate<std::byte>(__element_count(bytes), align); | 48 | std::byte* result = std::__libcpp_allocate<std::byte>(__element_count(bytes), align); |
| 49 | if (!is_aligned_to(result, align)) { | 49 | if (!is_aligned_to(result, align)) { |
| 50 | std::__libcpp_deallocate<std::byte>(result, __element_count(bytes), align); | 50 | std::__libcpp_deallocate<std::byte>(result, __element_count(bytes), align); |
| 51 | __throw_bad_alloc(); | 51 | std::__throw_bad_alloc(); |
| 52 | } | 52 | } |
| 53 | return result; | 53 | return result; |
| 54 | #endif | 54 | #endif |
| ... | @@ -63,8 +63,8 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory | ... | @@ -63,8 +63,8 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory |
| 63 | 63 | ||
| 64 | // null_memory_resource() | 64 | // null_memory_resource() |
| 65 | 65 | ||
| 66 | class _LIBCPP_EXPORTED_FROM_ABI __null_memory_resource_imp : public memory_resource { | 66 | class _LIBCPP_HIDDEN __null_memory_resource_imp : public memory_resource { |
| 67 | void* do_allocate(size_t, size_t) override { __throw_bad_alloc(); } | 67 | void* do_allocate(size_t, size_t) override { std::__throw_bad_alloc(); } |
| 68 | void do_deallocate(void*, size_t, size_t) override {} | 68 | void do_deallocate(void*, size_t, size_t) override {} |
| 69 | bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; } | 69 | bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; } |
| 70 | }; | 70 | }; |
lib/libcxx/src/mutex.cpp+5-4| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__assert> | 9 | #include <__assert> |
| 10 | #include <__system_error/throw_system_error.h> | ||
| 10 | #include <__thread/id.h> | 11 | #include <__thread/id.h> |
| 11 | #include <__utility/exception_guard.h> | 12 | #include <__utility/exception_guard.h> |
| 12 | #include <limits> | 13 | #include <limits> |
| ... | @@ -28,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -28,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | void mutex::lock() { | 29 | void mutex::lock() { |
| 29 | int ec = __libcpp_mutex_lock(&__m_); | 30 | int ec = __libcpp_mutex_lock(&__m_); |
| 30 | if (ec) | 31 | if (ec) |
| 31 | __throw_system_error(ec, "mutex lock failed"); | 32 | std::__throw_system_error(ec, "mutex lock failed"); |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | bool mutex::try_lock() noexcept { return __libcpp_mutex_trylock(&__m_); } | 35 | bool mutex::try_lock() noexcept { return __libcpp_mutex_trylock(&__m_); } |
| ... | @@ -45,7 +46,7 @@ void mutex::unlock() noexcept { | ... | @@ -45,7 +46,7 @@ void mutex::unlock() noexcept { |
| 45 | recursive_mutex::recursive_mutex() { | 46 | recursive_mutex::recursive_mutex() { |
| 46 | int ec = __libcpp_recursive_mutex_init(&__m_); | 47 | int ec = __libcpp_recursive_mutex_init(&__m_); |
| 47 | if (ec) | 48 | if (ec) |
| 48 | __throw_system_error(ec, "recursive_mutex constructor failed"); | 49 | std::__throw_system_error(ec, "recursive_mutex constructor failed"); |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | recursive_mutex::~recursive_mutex() { | 52 | recursive_mutex::~recursive_mutex() { |
| ... | @@ -57,7 +58,7 @@ recursive_mutex::~recursive_mutex() { | ... | @@ -57,7 +58,7 @@ recursive_mutex::~recursive_mutex() { |
| 57 | void recursive_mutex::lock() { | 58 | void recursive_mutex::lock() { |
| 58 | int ec = __libcpp_recursive_mutex_lock(&__m_); | 59 | int ec = __libcpp_recursive_mutex_lock(&__m_); |
| 59 | if (ec) | 60 | if (ec) |
| 60 | __throw_system_error(ec, "recursive_mutex lock failed"); | 61 | std::__throw_system_error(ec, "recursive_mutex lock failed"); |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | void recursive_mutex::unlock() noexcept { | 64 | void recursive_mutex::unlock() noexcept { |
| ... | @@ -108,7 +109,7 @@ void recursive_timed_mutex::lock() { | ... | @@ -108,7 +109,7 @@ void recursive_timed_mutex::lock() { |
| 108 | unique_lock<mutex> lk(__m_); | 109 | unique_lock<mutex> lk(__m_); |
| 109 | if (id == __id_) { | 110 | if (id == __id_) { |
| 110 | if (__count_ == numeric_limits<size_t>::max()) | 111 | if (__count_ == numeric_limits<size_t>::max()) |
| 111 | __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached"); | 112 | std::__throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached"); |
| 112 | ++__count_; | 113 | ++__count_; |
| 113 | return; | 114 | return; |
| 114 | } | 115 | } |
lib/libcxx/src/new.cpp+9-14| ... | @@ -43,7 +43,7 @@ static void* operator_new_impl(std::size_t size) { | ... | @@ -43,7 +43,7 @@ static void* operator_new_impl(std::size_t size) { |
| 43 | return p; | 43 | return p; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC { | 46 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size)) _THROW_BAD_ALLOC { |
| 47 | void* p = operator_new_impl(size); | 47 | void* p = operator_new_impl(size); |
| 48 | if (p == nullptr) | 48 | if (p == nullptr) |
| 49 | __throw_bad_alloc_shim(); | 49 | __throw_bad_alloc_shim(); |
| ... | @@ -54,7 +54,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { | ... | @@ -54,7 +54,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { |
| 54 | # if !_LIBCPP_HAS_EXCEPTIONS | 54 | # if !_LIBCPP_HAS_EXCEPTIONS |
| 55 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION | 55 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 56 | _LIBCPP_ASSERT_SHIM( | 56 | _LIBCPP_ASSERT_SHIM( |
| 57 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)), | 57 | (!std::__is_function_overridden < void*(std::size_t), &operator new>()), |
| 58 | "libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, " | 58 | "libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, " |
| 59 | "but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because " | 59 | "but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because " |
| 60 | "`operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case " | 60 | "`operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case " |
| ... | @@ -74,15 +74,13 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { | ... | @@ -74,15 +74,13 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { |
| 74 | # endif | 74 | # endif |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC { | 77 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size)) _THROW_BAD_ALLOC { return ::operator new(size); } |
| 78 | return ::operator new(size); | ||
| 79 | } | ||
| 80 | 78 | ||
| 81 | _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { | 79 | _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { |
| 82 | # if !_LIBCPP_HAS_EXCEPTIONS | 80 | # if !_LIBCPP_HAS_EXCEPTIONS |
| 83 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION | 81 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 84 | _LIBCPP_ASSERT_SHIM( | 82 | _LIBCPP_ASSERT_SHIM( |
| 85 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])), | 83 | (!std::__is_function_overridden < void*(std::size_t), &operator new[]>()), |
| 86 | "libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, " | 84 | "libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, " |
| 87 | "but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because " | 85 | "but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because " |
| 88 | "`operator new[](size_t, nothrow_t)` must call `operator new[](size_t)`, which will terminate in case " | 86 | "`operator new[](size_t, nothrow_t)` must call `operator new[](size_t)`, which will terminate in case " |
| ... | @@ -136,8 +134,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm | ... | @@ -136,8 +134,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm |
| 136 | return p; | 134 | return p; |
| 137 | } | 135 | } |
| 138 | 136 | ||
| 139 | _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* | 137 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC { |
| 140 | operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { | ||
| 141 | void* p = operator_new_aligned_impl(size, alignment); | 138 | void* p = operator_new_aligned_impl(size, alignment); |
| 142 | if (p == nullptr) | 139 | if (p == nullptr) |
| 143 | __throw_bad_alloc_shim(); | 140 | __throw_bad_alloc_shim(); |
| ... | @@ -148,7 +145,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s | ... | @@ -148,7 +145,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s |
| 148 | # if !_LIBCPP_HAS_EXCEPTIONS | 145 | # if !_LIBCPP_HAS_EXCEPTIONS |
| 149 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION | 146 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 150 | _LIBCPP_ASSERT_SHIM( | 147 | _LIBCPP_ASSERT_SHIM( |
| 151 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)), | 148 | (!std::__is_function_overridden < void*(std::size_t, std::align_val_t), &operator new>()), |
| 152 | "libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, " | 149 | "libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, " |
| 153 | "but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because " | 150 | "but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because " |
| 154 | "`operator new(size_t, align_val_t, nothrow_t)` must call `operator new(size_t, align_val_t)`, which will " | 151 | "`operator new(size_t, align_val_t, nothrow_t)` must call `operator new(size_t, align_val_t)`, which will " |
| ... | @@ -168,8 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s | ... | @@ -168,8 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s |
| 168 | # endif | 165 | # endif |
| 169 | } | 166 | } |
| 170 | 167 | ||
| 171 | _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* | 168 | _LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC { |
| 172 | operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { | ||
| 173 | return ::operator new(size, alignment); | 169 | return ::operator new(size, alignment); |
| 174 | } | 170 | } |
| 175 | 171 | ||
| ... | @@ -177,14 +173,13 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const | ... | @@ -177,14 +173,13 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const |
| 177 | # if !_LIBCPP_HAS_EXCEPTIONS | 173 | # if !_LIBCPP_HAS_EXCEPTIONS |
| 178 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION | 174 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 179 | _LIBCPP_ASSERT_SHIM( | 175 | _LIBCPP_ASSERT_SHIM( |
| 180 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])), | 176 | (!std::__is_function_overridden < void*(std::size_t, std::align_val_t), &operator new[]>()), |
| 181 | "libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, " | 177 | "libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, " |
| 182 | "but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because " | 178 | "but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because " |
| 183 | "`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will " | 179 | "`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will " |
| 184 | "terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, " | 180 | "terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, " |
| 185 | "nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you " | 181 | "nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you " |
| 186 | "override " | 182 | "override `operator new[](size_t, align_val_t, nothrow_t)` as well."); |
| 187 | "`operator new[](size_t, align_val_t, nothrow_t)` as well."); | ||
| 188 | # endif | 183 | # endif |
| 189 | 184 | ||
| 190 | return operator_new_aligned_impl(size, alignment); | 185 | return operator_new_aligned_impl(size, alignment); |
lib/libcxx/src/optional.cpp+1-1| ... | @@ -23,7 +23,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac | ... | @@ -23,7 +23,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac |
| 23 | // Even though it no longer exists in a header file | 23 | // Even though it no longer exists in a header file |
| 24 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL | 24 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL |
| 25 | 25 | ||
| 26 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error { | 26 | class _LIBCPP_EXPORTED_FROM_ABI bad_optional_access : public std::logic_error { |
| 27 | public: | 27 | public: |
| 28 | bad_optional_access() : std::logic_error("Bad optional Access") {} | 28 | bad_optional_access() : std::logic_error("Bad optional Access") {} |
| 29 | 29 |
lib/libcxx/src/print.cpp+1-1| ... | @@ -51,7 +51,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst | ... | @@ -51,7 +51,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst |
| 51 | __view.size(), | 51 | __view.size(), |
| 52 | nullptr, | 52 | nullptr, |
| 53 | nullptr) == 0) { | 53 | nullptr) == 0) { |
| 54 | __throw_system_error(filesystem::detail::get_last_error(), "failed to write formatted output"); | 54 | std::__throw_system_error(filesystem::detail::get_last_error(), "failed to write formatted output"); |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | 57 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS |
lib/libcxx/src/random.cpp+13-12| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | #include <__system_error/throw_system_error.h> | 16 | #include <__system_error/throw_system_error.h> |
| 17 | #include <limits> | 17 | #include <limits> |
| 18 | #include <random> | 18 | #include <random> |
| 19 | #include <string> | ||
| 19 | 20 | ||
| 20 | #include <errno.h> | 21 | #include <errno.h> |
| 21 | #include <stdio.h> | 22 | #include <stdio.h> |
| ... | @@ -42,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -42,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 42 | 43 | ||
| 43 | random_device::random_device(const string& __token) { | 44 | random_device::random_device(const string& __token) { |
| 44 | if (__token != "/dev/urandom") | 45 | if (__token != "/dev/urandom") |
| 45 | __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); | 46 | std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | random_device::~random_device() {} | 49 | random_device::~random_device() {} |
| ... | @@ -52,7 +53,7 @@ unsigned random_device::operator()() { | ... | @@ -52,7 +53,7 @@ unsigned random_device::operator()() { |
| 52 | size_t n = sizeof(r); | 53 | size_t n = sizeof(r); |
| 53 | int err = getentropy(&r, n); | 54 | int err = getentropy(&r, n); |
| 54 | if (err) | 55 | if (err) |
| 55 | __throw_system_error(errno, "random_device getentropy failed"); | 56 | std::__throw_system_error(errno, "random_device getentropy failed"); |
| 56 | return r; | 57 | return r; |
| 57 | } | 58 | } |
| 58 | 59 | ||
| ... | @@ -68,7 +69,7 @@ unsigned random_device::operator()() { return arc4random(); } | ... | @@ -68,7 +69,7 @@ unsigned random_device::operator()() { return arc4random(); } |
| 68 | 69 | ||
| 69 | random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) { | 70 | random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) { |
| 70 | if (__f_ < 0) | 71 | if (__f_ < 0) |
| 71 | __throw_system_error(errno, ("random_device failed to open " + __token).c_str()); | 72 | std::__throw_system_error(errno, ("random_device failed to open " + __token).c_str()); |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | random_device::~random_device() { close(__f_); } | 75 | random_device::~random_device() { close(__f_); } |
| ... | @@ -80,10 +81,10 @@ unsigned random_device::operator()() { | ... | @@ -80,10 +81,10 @@ unsigned random_device::operator()() { |
| 80 | while (n > 0) { | 81 | while (n > 0) { |
| 81 | ssize_t s = read(__f_, p, n); | 82 | ssize_t s = read(__f_, p, n); |
| 82 | if (s == 0) | 83 | if (s == 0) |
| 83 | __throw_system_error(ENOMSG, "random_device got EOF"); | 84 | std::__throw_system_error(ENOMSG, "random_device got EOF"); |
| 84 | if (s == -1) { | 85 | if (s == -1) { |
| 85 | if (errno != EINTR) | 86 | if (errno != EINTR) |
| 86 | __throw_system_error(errno, "random_device got an unexpected error"); | 87 | std::__throw_system_error(errno, "random_device got an unexpected error"); |
| 87 | continue; | 88 | continue; |
| 88 | } | 89 | } |
| 89 | n -= static_cast<size_t>(s); | 90 | n -= static_cast<size_t>(s); |
| ... | @@ -96,10 +97,10 @@ unsigned random_device::operator()() { | ... | @@ -96,10 +97,10 @@ unsigned random_device::operator()() { |
| 96 | 97 | ||
| 97 | random_device::random_device(const string& __token) { | 98 | random_device::random_device(const string& __token) { |
| 98 | if (__token != "/dev/urandom") | 99 | if (__token != "/dev/urandom") |
| 99 | __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); | 100 | std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); |
| 100 | int error = nacl_secure_random_init(); | 101 | int error = nacl_secure_random_init(); |
| 101 | if (error) | 102 | if (error) |
| 102 | __throw_system_error(error, ("random device failed to open " + __token).c_str()); | 103 | std::__throw_system_error(error, ("random device failed to open " + __token).c_str()); |
| 103 | } | 104 | } |
| 104 | 105 | ||
| 105 | random_device::~random_device() {} | 106 | random_device::~random_device() {} |
| ... | @@ -110,9 +111,9 @@ unsigned random_device::operator()() { | ... | @@ -110,9 +111,9 @@ unsigned random_device::operator()() { |
| 110 | size_t bytes_written; | 111 | size_t bytes_written; |
| 111 | int error = nacl_secure_random(&r, n, &bytes_written); | 112 | int error = nacl_secure_random(&r, n, &bytes_written); |
| 112 | if (error != 0) | 113 | if (error != 0) |
| 113 | __throw_system_error(error, "random_device failed getting bytes"); | 114 | std::__throw_system_error(error, "random_device failed getting bytes"); |
| 114 | else if (bytes_written != n) | 115 | else if (bytes_written != n) |
| 115 | __throw_runtime_error("random_device failed to obtain enough bytes"); | 116 | std::__throw_runtime_error("random_device failed to obtain enough bytes"); |
| 116 | return r; | 117 | return r; |
| 117 | } | 118 | } |
| 118 | 119 | ||
| ... | @@ -120,7 +121,7 @@ unsigned random_device::operator()() { | ... | @@ -120,7 +121,7 @@ unsigned random_device::operator()() { |
| 120 | 121 | ||
| 121 | random_device::random_device(const string& __token) { | 122 | random_device::random_device(const string& __token) { |
| 122 | if (__token != "/dev/urandom") | 123 | if (__token != "/dev/urandom") |
| 123 | __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); | 124 | std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); |
| 124 | } | 125 | } |
| 125 | 126 | ||
| 126 | random_device::~random_device() {} | 127 | random_device::~random_device() {} |
| ... | @@ -129,7 +130,7 @@ unsigned random_device::operator()() { | ... | @@ -129,7 +130,7 @@ unsigned random_device::operator()() { |
| 129 | unsigned r; | 130 | unsigned r; |
| 130 | errno_t err = rand_s(&r); | 131 | errno_t err = rand_s(&r); |
| 131 | if (err) | 132 | if (err) |
| 132 | __throw_system_error(err, "random_device rand_s failed."); | 133 | std::__throw_system_error(err, "random_device rand_s failed."); |
| 133 | return r; | 134 | return r; |
| 134 | } | 135 | } |
| 135 | 136 | ||
| ... | @@ -137,7 +138,7 @@ unsigned random_device::operator()() { | ... | @@ -137,7 +138,7 @@ unsigned random_device::operator()() { |
| 137 | 138 | ||
| 138 | random_device::random_device(const string& __token) { | 139 | random_device::random_device(const string& __token) { |
| 139 | if (__token != "/dev/urandom") | 140 | if (__token != "/dev/urandom") |
| 140 | __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); | 141 | std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); |
| 141 | } | 142 | } |
| 142 | 143 | ||
| 143 | random_device::~random_device() {} | 144 | random_device::~random_device() {} |
lib/libcxx/src/ryu/d2fixed.cpp+1| ... | @@ -42,6 +42,7 @@ | ... | @@ -42,6 +42,7 @@ |
| 42 | #include <__assert> | 42 | #include <__assert> |
| 43 | #include <__config> | 43 | #include <__config> |
| 44 | #include <charconv> | 44 | #include <charconv> |
| 45 | #include <cstddef> | ||
| 45 | #include <cstring> | 46 | #include <cstring> |
| 46 | 47 | ||
| 47 | #include "include/ryu/common.h" | 48 | #include "include/ryu/common.h" |
lib/libcxx/src/ryu/d2s.cpp+1| ... | @@ -42,6 +42,7 @@ | ... | @@ -42,6 +42,7 @@ |
| 42 | #include <__assert> | 42 | #include <__assert> |
| 43 | #include <__config> | 43 | #include <__config> |
| 44 | #include <charconv> | 44 | #include <charconv> |
| 45 | #include <cstddef> | ||
| 45 | 46 | ||
| 46 | #include "include/ryu/common.h" | 47 | #include "include/ryu/common.h" |
| 47 | #include "include/ryu/d2fixed.h" | 48 | #include "include/ryu/d2fixed.h" |
lib/libcxx/src/ryu/f2s.cpp+2| ... | @@ -42,6 +42,8 @@ | ... | @@ -42,6 +42,8 @@ |
| 42 | #include <__assert> | 42 | #include <__assert> |
| 43 | #include <__config> | 43 | #include <__config> |
| 44 | #include <charconv> | 44 | #include <charconv> |
| 45 | #include <cstdint> | ||
| 46 | #include <cstddef> | ||
| 45 | 47 | ||
| 46 | #include "include/ryu/common.h" | 48 | #include "include/ryu/common.h" |
| 47 | #include "include/ryu/d2fixed.h" | 49 | #include "include/ryu/d2fixed.h" |
lib/libcxx/src/std_stream.h+1-1| ... | @@ -86,7 +86,7 @@ void __stdinbuf<_CharT>::imbue(const locale& __loc) { | ... | @@ -86,7 +86,7 @@ void __stdinbuf<_CharT>::imbue(const locale& __loc) { |
| 86 | __encoding_ = __cv_->encoding(); | 86 | __encoding_ = __cv_->encoding(); |
| 87 | __always_noconv_ = __cv_->always_noconv(); | 87 | __always_noconv_ = __cv_->always_noconv(); |
| 88 | if (__encoding_ > __limit) | 88 | if (__encoding_ > __limit) |
| 89 | __throw_runtime_error("unsupported locale for standard input"); | 89 | std::__throw_runtime_error("unsupported locale for standard input"); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | template <class _CharT> | 92 | template <class _CharT> |
lib/libcxx/src/string.cpp+39-1| ... | @@ -37,7 +37,45 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou | ... | @@ -37,7 +37,45 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou |
| 37 | 37 | ||
| 38 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | 38 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON |
| 39 | 39 | ||
| 40 | #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; | 40 | // Define legacy ABI functions |
| 41 | // --------------------------- | ||
| 42 | |||
| 43 | #ifndef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | ||
| 44 | |||
| 45 | 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 | if (__libcpp_is_constant_evaluated()) | ||
| 48 | __rep_ = __rep(); | ||
| 49 | if (__reserve > max_size()) | ||
| 50 | __throw_length_error(); | ||
| 51 | pointer __p; | ||
| 52 | if (__fits_in_sso(__reserve)) { | ||
| 53 | __set_short_size(__sz); | ||
| 54 | __p = __get_short_pointer(); | ||
| 55 | } else { | ||
| 56 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1); | ||
| 57 | __p = __allocation.ptr; | ||
| 58 | __begin_lifetime(__p, __allocation.count); | ||
| 59 | __set_long_pointer(__p); | ||
| 60 | __set_long_cap(__allocation.count); | ||
| 61 | __set_long_size(__sz); | ||
| 62 | } | ||
| 63 | traits_type::copy(std::__to_address(__p), __s, __sz); | ||
| 64 | traits_type::assign(__p[__sz], value_type()); | ||
| 65 | __annotate_new(__sz); | ||
| 66 | } | ||
| 67 | |||
| 68 | # define STRING_LEGACY_API(CharT) \ | ||
| 69 | template _LIBCPP_EXPORTED_FROM_ABI void basic_string<CharT>::__init(const value_type*, size_type, size_type) | ||
| 70 | |||
| 71 | STRING_LEGACY_API(char); | ||
| 72 | # if _LIBCPP_HAS_WIDE_CHARACTERS | ||
| 73 | STRING_LEGACY_API(wchar_t); | ||
| 74 | # endif | ||
| 75 | |||
| 76 | #endif // _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | ||
| 77 | |||
| 78 | #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template _LIBCPP_EXPORTED_FROM_ABI __VA_ARGS__; | ||
| 41 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | 79 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 42 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) | 80 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) |
| 43 | # if _LIBCPP_HAS_WIDE_CHARACTERS | 81 | # if _LIBCPP_HAS_WIDE_CHARACTERS |
lib/libcxx/src/thread.cpp+4-2| ... | @@ -6,8 +6,10 @@ | ... | @@ -6,8 +6,10 @@ |
| 6 | // | 6 | // |
| 7 | //===----------------------------------------------------------------------===// | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | ||
| 9 | #include <__system_error/throw_system_error.h> | ||
| 9 | #include <__thread/poll_with_backoff.h> | 10 | #include <__thread/poll_with_backoff.h> |
| 10 | #include <__thread/timed_backoff_policy.h> | 11 | #include <__thread/timed_backoff_policy.h> |
| 12 | #include <__utility/pair.h> | ||
| 11 | #include <exception> | 13 | #include <exception> |
| 12 | #include <future> | 14 | #include <future> |
| 13 | #include <limits> | 15 | #include <limits> |
| ... | @@ -46,7 +48,7 @@ void thread::join() { | ... | @@ -46,7 +48,7 @@ void thread::join() { |
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | if (ec) | 50 | if (ec) |
| 49 | __throw_system_error(ec, "thread::join failed"); | 51 | std::__throw_system_error(ec, "thread::join failed"); |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | void thread::detach() { | 54 | void thread::detach() { |
| ... | @@ -58,7 +60,7 @@ void thread::detach() { | ... | @@ -58,7 +60,7 @@ void thread::detach() { |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | if (ec) | 62 | if (ec) |
| 61 | __throw_system_error(ec, "thread::detach failed"); | 63 | std::__throw_system_error(ec, "thread::detach failed"); |
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | unsigned thread::hardware_concurrency() noexcept { | 66 | unsigned thread::hardware_concurrency() noexcept { |
lib/libcxx/src/verbose_abort.cpp+1-1| ... | @@ -23,7 +23,7 @@ extern "C" void android_set_abort_message(const char* msg); | ... | @@ -23,7 +23,7 @@ extern "C" void android_set_abort_message(const char* msg); |
| 23 | 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | ||
| 26 | _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT { | 26 | _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept { |
| 27 | // Write message to stderr. We do this before formatting into a | 27 | // Write message to stderr. We do this before formatting into a |
| 28 | // buffer so that we still get some information out if that fails. | 28 | // buffer so that we still get some information out if that fails. |
| 29 | { | 29 | { |